Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
cannonball
Commits
5d28010c
Commit
5d28010c
authored
Nov 10, 2013
by
reassembler
Browse files
Added debug output for Layout
parent
772ec023
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/engine/ohud.cpp
View file @
5d28010c
...
...
@@ -29,14 +29,11 @@ OHud::~OHud(void)
{
}
int
mask
=
-
1
;
// Draw Text Labels For HUD
//
// Source: 0xB462
void
OHud
::
draw_main_hud
()
{
mask
+=
2
;
blit_text1
(
HUD_LAP1
);
blit_text1
(
HUD_LAP2
);
...
...
@@ -566,6 +563,19 @@ void OHud::blit_text2(uint32_t src_addr)
// Enhanced Cannonball Routines Below
// ------------------------------------------------------------------------------------------------
void
OHud
::
draw_debug_info
(
uint32_t
pos
,
uint16_t
height_pat
,
uint8_t
sprite_pat
)
{
ohud
.
blit_text_new
(
0
,
4
,
"LEVEL POS"
,
OHud
::
GREEN
);
ohud
.
blit_text_new
(
16
,
4
,
" "
);
ohud
.
blit_text_new
(
16
,
4
,
config
.
to_string
((
int
)(
pos
>>
16
)).
c_str
(),
OHud
::
PINK
);
ohud
.
blit_text_new
(
0
,
5
,
"HEIGHT PATTERN"
,
OHud
::
GREEN
);
ohud
.
blit_text_new
(
16
,
5
,
" "
);
ohud
.
blit_text_new
(
16
,
5
,
config
.
to_string
((
int
)
height_pat
).
c_str
(),
OHud
::
PINK
);
ohud
.
blit_text_new
(
0
,
6
,
"SPRITE PATTERN"
,
OHud
::
GREEN
);
ohud
.
blit_text_new
(
16
,
6
,
" "
);
ohud
.
blit_text_new
(
16
,
6
,
config
.
to_string
((
int
)
sprite_pat
).
c_str
(),
OHud
::
PINK
);
}
// Big Yellow Text. Always Centered.
void
OHud
::
blit_text_big
(
const
uint8_t
Y
,
const
char
*
text
,
bool
do_notes
)
{
...
...
src/main/engine/ohud.hpp
View file @
5d28010c
...
...
@@ -44,6 +44,7 @@ public:
void
draw_score_tile
(
uint32_t
,
const
uint32_t
,
const
uint8_t
);
void
draw_digits
(
uint32_t
,
uint8_t
,
uint16_t
col
=
GREEN
);
void
draw_rev_counter
();
void
draw_debug_info
(
uint32_t
pos
,
uint16_t
height_pat
,
uint8_t
sprite_pat
);
void
blit_text1
(
uint32_t
);
void
blit_text1
(
uint8_t
x
,
uint8_t
y
,
uint32_t
src_addr
);
void
blit_text2
(
uint32_t
);
...
...
src/main/trackloader.cpp
View file @
5d28010c
#include <iostream>
/***************************************************************************
Track Loading Code.
Abstracts the level format, so that the original ROMs as well as
in conjunction with track data from the LayOut editor.
- Handles levels (path, width, height, scenery)
- Handles additional level sections (road split, end section)
- Handles road/level related palettes
Copyright Chris White.
See license.txt for more details.
***************************************************************************/
#include <iostream>
#include "trackloader.hpp"
#include "roms.hpp"
#include "engine/outrun.hpp"
#include "engine/oaddresses.hpp"
// TODO: Make Japanese Tracks Work!
// Stage Mapping Data
//
// This effectively is the master table that controls the order of the stages.
// ------------------------------------------------------------------------------------------------
// Stage Mapping Data: This is the master table that controls the order of the stages.
//
// You can change the stage order by editing this table.
// Bear in mind that the double lanes are hard coded in Stage 1.
...
...
@@ -19,6 +28,7 @@
// 0x3A = Unused Coconut Beach
// 0x25 = Original Gateway track from Japanese edition
// 0x19 = Devils Canyon Variant
// ------------------------------------------------------------------------------------------------
static
uint8_t
STAGE_MAPPING_USA
[]
=
{
...
...
@@ -44,11 +54,9 @@ TrackLoader::TrackLoader()
{
layout
=
NULL
;
levels
=
new
Level
[
STAGES
];
levels_
bonus
=
new
Level
[
5
];
levels_
end
=
new
Level
[
5
];
level_split
=
new
Level
();
current_level
=
&
levels
[
0
];
track_data
=
NULL
;
mode
=
MODE_ORIGINAL
;
}
...
...
@@ -58,20 +66,17 @@ TrackLoader::~TrackLoader()
if
(
layout
!=
NULL
)
delete
layout
;
if
(
track_data
!=
NULL
)
delete
[]
track_data
;
delete
[]
levels_bonus
;
delete
[]
levels_end
;
delete
[]
levels
;
delete
level_split
;
}
void
TrackLoader
::
init
()
void
TrackLoader
::
init
(
bool
jap
)
{
if
(
mode
==
MODE_ORIGINAL
)
init_original_tracks
();
init_original_tracks
(
jap
);
else
init_layout_tracks
();
init_layout_tracks
(
jap
);
}
bool
TrackLoader
::
set_layout_track
(
const
char
*
filename
)
...
...
@@ -89,9 +94,9 @@ bool TrackLoader::set_layout_track(const char* filename)
return
true
;
}
void
TrackLoader
::
init_original_tracks
()
void
TrackLoader
::
init_original_tracks
(
bool
jap
)
{
stage_data
=
STAGE_MAPPING_USA
;
// todo: Convert to also work with jap
stage_data
=
jap
?
STAGE_MAPPING_JAP
:
STAGE_MAPPING_USA
;
display_start_line
=
true
;
...
...
@@ -100,11 +105,11 @@ void TrackLoader::init_original_tracks()
// --------------------------------------------------------------------------------------------
// Height Map Entries
heightmap_offset
=
ROAD_HEIGHT_LOOKUP
;
// todo: replace with
outrun.adr.height_lookup
heightmap_offset
=
outrun
.
adr
.
road_
height_lookup
;
heightmap_data
=
&
roms
.
rom1p
->
rom
[
0
];
// Scenery Map Entries
scenerymap_offset
=
SPRITE_MASTER_TABLE
;
// todo: replace with outrun.adr equivalent
scenerymap_offset
=
outrun
.
adr
.
sprite_master_table
;
scenerymap_data
=
&
roms
.
rom0p
->
rom
[
0
];
// Palette Entries
...
...
@@ -129,7 +134,7 @@ void TrackLoader::init_original_tracks()
const
uint16_t
STAGE_OFFSET
=
stage_data
[
STAGE_ORDER
[
i
]]
<<
2
;
// CPU 0 Data
const
uint32_t
STAGE_ADR
=
roms
.
rom0p
->
read32
(
ROAD_SEG_TABLE
+
STAGE_OFFSET
);
// todo: replace road seg table
const
uint32_t
STAGE_ADR
=
roms
.
rom0p
->
read32
(
outrun
.
adr
.
road_seg_table
+
STAGE_OFFSET
);
setup_level
(
&
levels
[
i
],
roms
.
rom0p
,
STAGE_ADR
);
// CPU 1 Data
...
...
@@ -138,33 +143,35 @@ void TrackLoader::init_original_tracks()
}
// --------------------------------------------------------------------------------------------
// Setup
B
on
u
s & Split Stages
// Setup
End Secti
ons & Split Stages
// --------------------------------------------------------------------------------------------
// Split stages don't contain palette information
level_split
->
curve
=
&
roms
.
rom0p
->
rom
[
roms
.
rom0p
->
read32
(
ROAD_SEG_TABLE_SPLIT
+
0
)];
level_split
->
width_height
=
&
roms
.
rom0p
->
rom
[
roms
.
rom0p
->
read32
(
ROAD_SEG_TABLE_SPLIT
+
4
)];
level_split
->
scenery
=
&
roms
.
rom0p
->
rom
[
roms
.
rom0p
->
read32
(
ROAD_SEG_TABLE_SPLIT
+
8
)];
setup_section
(
level_split
,
roms
.
rom0p
,
outrun
.
adr
.
road_seg_split
);
level_split
->
path
=
&
roms
.
rom1p
->
rom
[
ROAD_DATA_SPLIT
];
for
(
int
i
=
0
;
i
<
5
;
i
++
)
setup_level
(
&
levels_bonus
[
i
],
roms
.
rom0p
,
ROAD_SEG_TABLE_END
+
(
i
<<
2
));
// todo: replace with outrun.adr equivalent
{
const
uint32_t
STAGE_ADR
=
roms
.
rom0p
->
read32
(
outrun
.
adr
.
road_seg_end
+
(
i
<<
2
));
setup_section
(
&
levels_end
[
i
],
roms
.
rom0p
,
STAGE_ADR
);
levels_end
[
i
].
path
=
&
roms
.
rom1p
->
rom
[
ROAD_DATA_BONUS
];
}
}
void
TrackLoader
::
init_layout_tracks
()
void
TrackLoader
::
init_layout_tracks
(
bool
jap
)
{
stage_data
=
STAGE_MAPPING_USA
;
// --------------------------------------------------------------------------------------------
// Check Version is Correct
// --------------------------------------------------------------------------------------------
if
(
layout
->
read32
(
LayOut
::
HEADER
)
!=
LayOut
::
EXPECTED_VERSION
)
{
std
::
cout
<<
"Incompatible LayOut Version Detected. Try upgrading CannonBall to the latest version"
<<
std
::
endl
;
init_original_tracks
();
init_original_tracks
(
jap
);
return
;
}
stage_data
=
STAGE_MAPPING_USA
;
// This should be replaced
display_start_line
=
layout
->
read8
(
LayOut
::
HEADER
+
sizeof
(
uint32_t
));
// --------------------------------------------------------------------------------------------
...
...
@@ -201,17 +208,24 @@ void TrackLoader::init_layout_tracks()
}
// --------------------------------------------------------------------------------------------
// Setup
B
on
u
s & Split Stages
// Setup
End Secti
ons & Split Stages
// --------------------------------------------------------------------------------------------
// Split stages don't contain palette information
setup_s
plit
(
level_split
,
layout
,
layout
->
read32
(
LayOut
::
SPLIT_LEVEL
));
setup_s
ection
(
level_split
,
layout
,
layout
->
read32
(
LayOut
::
SPLIT_LEVEL
));
level_split
->
path
=
&
layout
->
rom
[
layout
->
read32
(
LayOut
::
SPLIT_PATH
)
];
// End sections don't contain palette information. Shared path.
uint8_t
*
end_path
=
&
layout
->
rom
[
layout
->
read32
(
LayOut
::
END_PATH
)
];
for
(
int
i
=
0
;
i
<
5
;
i
++
)
setup_level
(
&
levels_bonus
[
i
],
roms
.
rom0p
,
ROAD_SEG_TABLE_END
+
(
i
<<
2
));
// todo: replace with outrun.adr equivalent
{
const
uint32_t
STAGE_ADR
=
layout
->
read32
(
LayOut
::
END_LEVELS
+
(
i
*
sizeof
(
uint32_t
)));
setup_section
(
&
levels_end
[
i
],
layout
,
STAGE_ADR
);
levels_end
[
i
].
path
=
end_path
;
}
}
// Setup a normal level
void
TrackLoader
::
setup_level
(
Level
*
l
,
RomLoader
*
data
,
const
int
STAGE_ADR
)
{
// Sky Palette
...
...
@@ -252,7 +266,9 @@ void TrackLoader::setup_level(Level* l, RomLoader* data, const int STAGE_ADR)
l
->
scenery
=
&
data
->
rom
[
scenery_offset
];
}
void
TrackLoader
::
setup_split
(
Level
*
l
,
RomLoader
*
data
,
const
int
STAGE_ADR
)
// Setup a special section of track (end section or level split)
// Special sections do not contain palette information
void
TrackLoader
::
setup_section
(
Level
*
l
,
RomLoader
*
data
,
const
int
STAGE_ADR
)
{
// Curve Data
curve_offset
=
data
->
read32
(
STAGE_ADR
+
0
);
...
...
@@ -276,8 +292,7 @@ void TrackLoader::init_track(const uint32_t offset)
curve_offset
=
0
;
wh_offset
=
0
;
scenery_offset
=
0
;
current_level
=
&
levels
[
stage_offset_to_level
(
offset
)];
current_level
=
&
levels
[
stage_offset_to_level
(
offset
)];
}
int8_t
TrackLoader
::
stage_offset_to_level
(
uint32_t
id
)
...
...
@@ -292,7 +307,7 @@ void TrackLoader::init_track_split()
curve_offset
=
0
;
wh_offset
=
0
;
scenery_offset
=
0
;
current_level
=
level_split
;
current_level
=
level_split
;
}
void
TrackLoader
::
init_track_bonus
(
const
uint32_t
id
)
...
...
@@ -300,11 +315,11 @@ void TrackLoader::init_track_bonus(const uint32_t id)
curve_offset
=
0
;
wh_offset
=
0
;
scenery_offset
=
0
;
current_level
=
&
levels_
bonus
[
id
];
current_level
=
&
levels_
end
[
id
];
}
// ------------------------------------------------------------------------------------------------
// CPU 1:
Initialize Road Path
// CPU 1:
Road Path Functions
// ------------------------------------------------------------------------------------------------
void
TrackLoader
::
init_path
(
const
uint32_t
offset
)
...
...
@@ -317,29 +332,9 @@ void TrackLoader::init_path_split()
current_path
=
level_split
->
path
;
}
void
TrackLoader
::
init_path_
bonus
()
void
TrackLoader
::
init_path_
end
()
{
current_path
=
&
roms
.
rom1p
->
rom
[
ROAD_DATA_BONUS
];
}
uint32_t
TrackLoader
::
read_pal_sky_table
(
uint16_t
entry
)
{
return
read32
(
pal_sky_data
,
pal_sky_offset
+
(
entry
*
4
));
}
uint32_t
TrackLoader
::
read_pal_gnd_table
(
uint16_t
entry
)
{
return
read32
(
pal_gnd_data
,
pal_gnd_offset
+
(
entry
*
4
));
}
uint32_t
TrackLoader
::
read_heightmap_table
(
uint16_t
entry
)
{
return
read32
(
heightmap_data
,
heightmap_offset
+
(
entry
*
4
));
}
uint32_t
TrackLoader
::
read_scenerymap_table
(
uint16_t
entry
)
{
return
read32
(
scenerymap_data
,
scenerymap_offset
+
(
entry
*
4
));
current_path
=
levels_end
[
0
].
path
;
// Path is shared for end sections
}
// ------------------------------------------------------------------------------------------------
...
...
@@ -388,4 +383,24 @@ uint8_t TrackLoader::read_sprite_pattern_index()
Level
*
TrackLoader
::
get_level
(
uint32_t
id
)
{
return
&
levels
[
stage_offset_to_level
(
id
)];
}
uint32_t
TrackLoader
::
read_pal_sky_table
(
uint16_t
entry
)
{
return
read32
(
pal_sky_data
,
pal_sky_offset
+
(
entry
*
4
));
}
uint32_t
TrackLoader
::
read_pal_gnd_table
(
uint16_t
entry
)
{
return
read32
(
pal_gnd_data
,
pal_gnd_offset
+
(
entry
*
4
));
}
uint32_t
TrackLoader
::
read_heightmap_table
(
uint16_t
entry
)
{
return
read32
(
heightmap_data
,
heightmap_offset
+
(
entry
*
4
));
}
uint32_t
TrackLoader
::
read_scenerymap_table
(
uint16_t
entry
)
{
return
read32
(
scenerymap_data
,
scenerymap_offset
+
(
entry
*
4
));
}
\ No newline at end of file
src/main/trackloader.hpp
View file @
5d28010c
/***************************************************************************
Track Loading Code.
Abstracts the level format, so that the original ROMs as well as
in conjunction with track data from the LayOut editor.
- Handles levels (path, width, height, scenery)
- Handles additional level sections (road split, end section)
- Handles road/level related palettes
Copyright Chris White.
See license.txt for more details.
***************************************************************************/
#pragma once
#include "globals.hpp"
// Road Generator Palette Representation
struct
RoadPalette
{
uint32_t
stripe_centre
;
// Centre Stripe Colour
...
...
@@ -10,6 +25,7 @@ struct RoadPalette
uint32_t
road
;
// Main Road Colour
};
// OutRun Level Representation
struct
Level
{
uint8_t
*
path
;
// CPU 1 Path Data
...
...
@@ -24,20 +40,7 @@ struct Level
RoadPalette
palr2
;
// Road 2 Generator Palette
};
// LayOut Header Format
/*struct LayOut
{
static const uint32_t EXPECTED_VERSION = 1;
static const uint32_t HEADER = 0;
static const uint32_t PATH = HEADER + sizeof(uint32_t) + sizeof(uint8_t);
static const uint32_t LEVELS = PATH + sizeof(uint32_t);
static const uint32_t PAL_SKY = LEVELS + (STAGES * sizeof(uint32_t));
static const uint32_t PAL_GND = PAL_SKY + sizeof(uint32_t);
static const uint32_t SPRITE_MAPS = PAL_GND + sizeof(uint32_t);
static const uint32_t HEIGHT_MAPS = SPRITE_MAPS + sizeof(uint32_t);
};*/
// LayOut Binary Header Format
struct
LayOut
{
static
const
uint32_t
EXPECTED_VERSION
=
1
;
...
...
@@ -45,7 +48,9 @@ struct LayOut
static
const
uint32_t
HEADER
=
0
;
static
const
uint32_t
PATH
=
HEADER
+
sizeof
(
uint32_t
)
+
sizeof
(
uint8_t
);
static
const
uint32_t
LEVELS
=
PATH
+
sizeof
(
uint32_t
);
static
const
uint32_t
SPLIT_PATH
=
LEVELS
+
(
STAGES
*
sizeof
(
uint32_t
));
static
const
uint32_t
END_PATH
=
LEVELS
+
(
STAGES
*
sizeof
(
uint32_t
));
static
const
uint32_t
END_LEVELS
=
END_PATH
+
sizeof
(
uint32_t
);
static
const
uint32_t
SPLIT_PATH
=
END_LEVELS
+
(
5
*
sizeof
(
uint32_t
));
static
const
uint32_t
SPLIT_LEVEL
=
SPLIT_PATH
+
sizeof
(
uint32_t
);
static
const
uint32_t
PAL_SKY
=
SPLIT_LEVEL
+
sizeof
(
uint32_t
);
static
const
uint32_t
PAL_GND
=
PAL_SKY
+
sizeof
(
uint32_t
);
...
...
@@ -67,6 +72,7 @@ public:
const
static
int
MODE_ORIGINAL
=
0
;
const
static
int
MODE_LAYOUT
=
1
;
// Display start line on Stage 1
uint8_t
display_start_line
;
uint32_t
curve_offset
;
...
...
@@ -87,17 +93,17 @@ public:
TrackLoader
();
~
TrackLoader
();
void
init
();
void
init
(
bool
jap
);
bool
set_layout_track
(
const
char
*
filename
);
void
init_original_tracks
();
void
init_layout_tracks
();
void
init_original_tracks
(
bool
jap
);
void
init_layout_tracks
(
bool
jap
);
void
init_track
(
const
uint32_t
);
void
init_track_split
();
void
init_track_bonus
(
const
uint32_t
);
void
init_path
(
const
uint32_t
);
void
init_path_split
();
void
init_path_
bonus
();
void
init_path_
end
();
uint32_t
read_pal_sky_table
(
uint16_t
entry
);
uint32_t
read_pal_gnd_table
(
uint16_t
entry
);
...
...
@@ -155,16 +161,14 @@ private:
int
mode
;
Level
*
levels
;
Level
*
level_split
;
Level
*
levels_bonus
;
uint8_t
*
track_data
;
// Custom track data
Level
*
levels
;
// Normal Stages
Level
*
level_split
;
// Split Section
Level
*
levels_end
;
// End Section
uint8_t
*
current_path
;
// CPU 1
uint8_t
*
current_path
;
// CPU 1
Road Path
void
setup_level
(
Level
*
l
,
RomLoader
*
data
,
const
int
STAGE_ADR
);
void
setup_s
plit
(
Level
*
l
,
RomLoader
*
data
,
const
int
STAGE_ADR
);
void
setup_s
ection
(
Level
*
l
,
RomLoader
*
data
,
const
int
STAGE_ADR
);
};
extern
TrackLoader
trackloader
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment