Commit f5dacdb0 authored by reassembler's avatar reassembler
Browse files

LayOut options & support

parent 5d28010c
......@@ -222,6 +222,9 @@
<!-- Fix minor bugs present in the original engine. -->
<!-- Tile on music select screen, ms value at checkpoint etc. -->
<fix_bugs>1</fix_bugs>
<!-- Display debug info that's useful for LayOut track editing -->
<layout_debug>0</layout_debug>
</engine>
<!-- Settings for Time Trial Mode -->
......
......@@ -74,9 +74,7 @@ void OInitEngine::init(int8_t level)
// Road Renderer: Setup correct stage address
if (level)
//trackloader.setup_path(stage_data[oroad.stage_lookup_off] << 2);
trackloader.init_path(oroad.stage_lookup_off);
//oroad.stage_addr = roms.rom1p->read32(ROAD_DATA_LOOKUP + (stage_data[oroad.stage_lookup_off] << 2));
opalette.setup_sky_palette();
opalette.setup_ground_color();
......@@ -126,15 +124,6 @@ void OInitEngine::setup_stage1()
void OInitEngine::init_road_seg_master()
{
//uint16_t stage_offset = stage_data[oroad.stage_lookup_off] << 2; // convert to long
//road_seg_master = roms.rom0p->read32(outrun.adr.road_seg_table + stage_offset);
// Rolled the following lines in from elsewhere
//road_seg_addr3 = roms.rom0p->read32(0x18 + road_seg_master); // Type of curve and unknown
//road_seg_addr2 = roms.rom0p->read32(0x1C + road_seg_master); // Width/Height Lookup
//road_seg_addr1 = roms.rom0p->read32(0x20 + road_seg_master); // Sprite information
//trackloader.setup_track(road_seg_master + 0x18, outrun.adr.road_height_lookup);
trackloader.init_track(oroad.stage_lookup_off);
}
......@@ -154,8 +143,8 @@ void OInitEngine::init_road_seg_master()
void OInitEngine::update_road()
{
check_road_split(); // Check/Process road split if necessary
uint32_t addr = 0;//road_seg_addr2;
uint16_t d0 = trackloader.read_width_height(&addr);//roms.rom0p->read16(&addr);
uint32_t addr = 0;
uint16_t d0 = trackloader.read_width_height(&addr);
// Update next road section
if (d0 <= oroad.road_pos >> 16)
{
......@@ -182,7 +171,6 @@ void OInitEngine::update_road()
change_width = -1; // Denote road width is changing
}
}
//road_seg_addr2 += 8;
trackloader.wh_offset += 8;
}
......@@ -226,7 +214,7 @@ void OInitEngine::update_road()
// ROM:0000B91C set_road_type:
int16_t segment_pos = trackloader.read_curve(0);//roms.rom0p->read16(road_seg_addr3);
int16_t segment_pos = trackloader.read_curve(0);
if (segment_pos != -1)
{
......@@ -234,15 +222,14 @@ void OInitEngine::update_road()
if (d1 <= (int16_t) (oroad.road_pos >> 16))
{
road_curve_next = trackloader.read_curve(2);//roms.rom0p->read16(2 + road_seg_addr3);
road_type_next = trackloader.read_curve(4);//roms.rom0p->read16(4 + road_seg_addr3);
road_curve_next = trackloader.read_curve(2);
road_type_next = trackloader.read_curve(4);
}
if (segment_pos <= (int16_t) (oroad.road_pos >> 16))
{
road_curve = trackloader.read_curve(2);//roms.rom0p->read16(2 + road_seg_addr3);
road_type = trackloader.read_curve(4);//roms.rom0p->read16(4 + road_seg_addr3);
//road_seg_addr3 += 6;
road_curve = trackloader.read_curve(2);
road_type = trackloader.read_curve(4);
trackloader.curve_offset += 6;
road_type_next = 0;
road_curve_next = 0;
......@@ -300,6 +287,9 @@ void OInitEngine::update_engine()
else
ohud.blit_text_new(9, 26, "L");
}
if (config.engine.layout_debug)
ohud.draw_debug_info(oroad.road_pos, oroad.height_lookup_wrk, trackloader.read_sprite_pattern_index());
}
if (olevelobjs.spray_counter > 0)
......@@ -530,15 +520,11 @@ void OInitEngine::init_split1()
{
rd_split_state = SPLIT_CHOICE1;
oroad.road_load_split = -1;
oroad.road_ctrl = ORoad::ROAD_BOTH_P0_INV; // Both Roads (Road 0 Priority) (Road Split. Invert Road 0)
road_width_orig = oroad.road_width >> 16;
oroad.road_pos = 0;
oroad.road_load_split = -1;
oroad.road_ctrl = ORoad::ROAD_BOTH_P0_INV; // Both Roads (Road 0 Priority) (Road Split. Invert Road 0)
road_width_orig = oroad.road_width >> 16;
oroad.road_pos = 0;
oroad.tilemap_h_target = 0;
//road_seg_addr3 = roms.rom0p->read32(outrun.adr.road_seg_split);
//road_seg_addr2 = roms.rom0p->read32(outrun.adr.road_seg_split + 4);
//trackloader.setup_track(outrun.adr.road_seg_split, outrun.adr.road_height_lookup);
//road_seg_addr1 = roms.rom0p->read32(outrun.adr.road_seg_split + 8);
trackloader.init_track_split();
}
......@@ -733,11 +719,6 @@ void OInitEngine::init_bonus()
oroad.road_pos = 0;
oroad.tilemap_h_target = 0;
oanimseq.end_seq = oroad.stage_lookup_off - 0x20; // Set End Sequence (0 - 4)
uint32_t adr = roms.rom0p->read32(outrun.adr.road_seg_end + (oanimseq.end_seq << 2)); // Road Data Addr
//road_seg_addr3 = roms.rom0p->read32(&adr);
//road_seg_addr2 = roms.rom0p->read32(&adr);
//trackloader.setup_track(adr, outrun.adr.road_height_lookup);
//road_seg_addr1 = roms.rom0p->read32(adr + 8);
trackloader.init_track_bonus(oanimseq.end_seq);
outrun.game_state = GS_INIT_BONUS;
rd_split_state = 0x11;
......
......@@ -161,12 +161,6 @@ void OLevelObjs::setup_sprite(oentry* sprite, uint32_t z)
uint32_t addr = osprites.seg_spr_addr + osprites.seg_spr_offset1;
// Set sprite x,y (world coordinates)
//sprite->xw1 =
//sprite->xw2 = ((int8_t) roms.rom0p->read8(addr + 1)) << 4;
//sprite->yw = roms.rom0p->read16(addr + 2) << 7;
//sprite->type = roms.rom0p->read8(addr + 5) << 2;
//sprite->addr = roms.rom0p->read32(outrun.adr.sprite_type_table + sprite->type);
//sprite->pal_src = roms.rom0p->read8(addr + 7);
sprite->xw1 =
sprite->xw2 = READ8(addr + 1) << 4;
sprite->yw = READ16(addr + 2) << 7;
......
......@@ -396,53 +396,28 @@ void OPalette::write_next_pal_to_ram()
oinitengine.end_stage_props &= ~BIT_1;
// Lookup palette entry from the road seg table based on route chosen
//uint32_t src_pal_addr = outrun.adr.road_seg_table + (oinitengine.stage_data[stage_offset] << 2);
//uint32_t road_seg_addr = roms.rom0p->read32(src_pal_addr);
Level *next_level = trackloader.get_level(stage_offset);
// road palette
//uint32_t pal_entries = roms.rom0p->read32(road_seg_addr + 0x10);
//pal_fade[dst] = roms.rom0p->read16(pal_entries);
pal_fade[dst] = next_level->palr1.road >> 16;
dst += 9;
pal_fade[dst] = next_level->palr1.road >> 16; dst += 9;
// sky palette
//pal_fade[dst] = roms.rom0p->read16(pal_entries + 2);
pal_fade[dst] = next_level->palr1.road & 0xFFFF;
dst += 9;
pal_fade[dst] = next_level->palr1.road & 0xFFFF; dst += 9;
// Road Stripe Palette Entries
//pal_entries = roms.rom0p->read32(road_seg_addr + 0x8);
//pal_fade[dst] = roms.rom0p->read16(pal_entries); // first word
pal_fade[dst] = next_level->palr1.stripe >> 16;
dst += 9;
//pal_fade[dst] = roms.rom0p->read16(pal_entries + 2); // second word
pal_fade[dst] = next_level->palr1.stripe & 0xFFFF;
dst += 9;
pal_fade[dst] = next_level->palr1.stripe >> 16; dst += 9;
pal_fade[dst] = next_level->palr1.stripe & 0xFFFF; dst += 9;
// Road Side Palette Entries
//pal_entries = roms.rom0p->read32(road_seg_addr + 0xC);
//pal_fade[dst] = roms.rom0p->read16(pal_entries); // first word
pal_fade[dst] = next_level->palr1.side >> 16;
dst += 9;
//pal_fade[dst] = roms.rom0p->read16(pal_entries + 2); // second word
pal_fade[dst] = next_level->palr1.side & 0xFFFF;
dst += 9;
pal_fade[dst] = next_level->palr1.side >> 16; dst += 9;
pal_fade[dst] = next_level->palr1.side & 0xFFFF; dst += 9;
// Road Stripe Centre Palette Entries
//pal_entries = roms.rom0p->read32(road_seg_addr + 0x4);
//pal_fade[dst] = roms.rom0p->read16(pal_entries); // first word
pal_fade[dst] = next_level->palr1.stripe_centre >> 16;
dst += 9;
//pal_fade[dst] = roms.rom0p->read16(pal_entries + 2); // second word
pal_fade[dst] = next_level->palr1.stripe_centre & 0xFFFF;
dst += 9;
pal_fade[dst] = next_level->palr1.stripe_centre >> 16; dst += 9;
pal_fade[dst] = next_level->palr1.stripe_centre & 0xFFFF; dst += 9;
// Ground Palette Entries (Index to table below)
//pal_entries = roms.rom0p->read32(road_seg_addr + 0x14);
//uint16_t d0 = roms.rom0p->read16(pal_entries) << 2;
//uint32_t ground_pal_addr = roms.rom0.read32(PAL_GND_TABLE + d0);
uint32_t ground_pal_addr = trackloader.read_pal_gnd_table(next_level->pal_gnd);
for (int16_t i = 0; i <= 15; i++)
{
pal_fade[dst] = trackloader.read16(trackloader.pal_gnd_data, &ground_pal_addr);//roms.rom0.read16(&ground_pal_addr);
pal_fade[dst] = trackloader.read16(trackloader.pal_gnd_data, &ground_pal_addr);
dst += 9;
}
}
......
......@@ -68,7 +68,7 @@ void ORoad::init()
car_x_bak = 0;
height_lookup = 0;
road_pos_change = 0;
road_load_bonus = 0;
road_load_end = 0;
road_ctrl = ROAD_OFF;
road_load_split = 0;
road_width = 0;
......@@ -201,12 +201,7 @@ void ORoad::clear_road_ram()
void ORoad::init_stage1()
{
// Sets to 0x3c [Stage 1] - First Entry Of Stage Master Table In RAM
// Multiply by 4, as table contains longs
//const uint16_t stage1 = oinitengine.stage_data[0] << 2;
//stage_addr = roms.rom1p->read32(ROAD_DATA_LOOKUP + stage1);
trackloader.init_path(0);
trackloader.init_path(0);
road_pos = 0;
road_ctrl = ROAD_BOTH_P0;
// ignore init counter stuff (move.b #$A,$49(a5))
......@@ -244,12 +239,7 @@ void ORoad::check_load_road()
if (ostats.cur_stage != stage_loaded)
{
stage_loaded = ostats.cur_stage; // Denote loaded
// Table contains longs, so multiply by 4
//const uint16_t stage_index = oinitengine.stage_data[stage_lookup_off] << 2;
//trackloader.setup_path(stage_index);
trackloader.init_path(stage_lookup_off);
//stage_addr = roms.rom1p->read32(ROAD_DATA_LOOKUP + stage_index);
return;
}
......@@ -257,16 +247,14 @@ void ORoad::check_load_road()
if (road_load_split)
{
trackloader.init_path_split();
//stage_addr = ROAD_DATA_SPLIT;
road_load_split = 0;
}
// Check Bonus
else if (road_load_bonus)
// Check End Section
else if (road_load_end)
{
trackloader.init_path_bonus();
//stage_addr = ROAD_DATA_BONUS;
road_load_bonus = 0;
trackloader.init_path_end();
road_load_end = 0;
}
}
......
......@@ -63,8 +63,8 @@ public:
// 0x6C: Change in road position
int32_t road_pos_change;
// 0x5E: Instruct CPU 1 to load bonus road. Set Bit 1.
uint8_t road_load_bonus;
// 0x5E: Instruct CPU 1 to load end section road. Set Bit 1.
uint8_t road_load_end;
// 0x306: Road Control
uint8_t road_ctrl;
......
......@@ -207,29 +207,25 @@ void OSprites::tick()
// The entire sequence can repeat, until the max sprites counter expires.
//
// So the above example would draw 3 sprites in succession, then break for three attempts, then three again etc.
#include <iostream>
void OSprites::sprite_control()
{
uint16_t d0 = trackloader.read_scenery_pos();
uint16_t pos = trackloader.read_scenery_pos();
// Populate next road segment
if (d0 <= oroad.road_pos >> 16)
if (pos <= oroad.road_pos >> 16)
{
seg_pos = d0; // Position In Level Data [Word]
seg_total_sprites = trackloader.read_total_sprites(); // Number of Sprites In Segment
d0 = trackloader.read_sprite_pattern_index(); // Block Of Sprites
trackloader.scenery_offset += 4; // Advance to next scenery point
seg_pos = pos; // Position In Level Data [Word]
seg_total_sprites = trackloader.read_total_sprites(); // Number of Sprites In Segment
uint8_t pattern_index = trackloader.read_sprite_pattern_index(); // Block Of Sprites
trackloader.scenery_offset += 4; // Advance to next scenery point
uint32_t a0 = trackloader.read_scenerymap_table(d0); // Get Address of Scenery Pattern
seg_sprite_freq = trackloader.read16(trackloader.scenerymap_data, &a0);
seg_spr_offset2 = trackloader.read16(trackloader.scenerymap_data, &a0);
//uint32_t a0 = roms.rom0p->read32(outrun.adr.sprite_master_table + d0); // Set a0 to new address from master table of addresses
//seg_sprite_freq = roms.rom0p->read16(&a0); // Set Sprite Frequency Value
//seg_spr_offset2 = roms.rom0p->read16(&a0); // Set Reload value for sprite info offset
seg_spr_addr = a0; // Set ROM address for sprite info lookup (x, y, type)
// NOTE: Sets to value of a0 itself, not memory location
seg_spr_offset1 = 0; // And Clear the offset into the above table
uint32_t a0 = trackloader.read_scenerymap_table(pattern_index); // Get Address of Scenery Pattern
seg_sprite_freq = trackloader.read16(trackloader.scenerymap_data, &a0); // Scenery Frequency
seg_spr_offset2 = trackloader.read16(trackloader.scenerymap_data, &a0); // Reload value for scenery pattern
seg_spr_addr = a0; // Set ROM address for sprite info lookup (x, y, type)
// NOTE: Sets to value of a0 itself, not memory location
seg_spr_offset1 = 0; // And Clear the offset into the above table
}
// Process segment
......
......@@ -431,7 +431,7 @@ void Outrun::main_switch()
case GS_INIT_BONUS:
ostats.frame_counter = ostats.frame_reset;
obonus.bonus_control = OBonus::BONUS_INIT; // Initialize Bonus Mode Logic
oroad.road_load_bonus |= BIT_0; // Instruct CPU 1 to load bonus road section
oroad.road_load_end |= BIT_0; // Instruct CPU 1 to load end road section
ostats.game_completed |= BIT_0; // Denote game completed
obonus.bonus_timer = 3600; // Safety Timer Added in Rev. A Roms
game_state = GS_BONUS;
......@@ -637,7 +637,7 @@ void Outrun::init_jump_table()
if (trackloader.display_start_line)
olevelobjs.init_startline_sprites(); // Hard coded start line sprites (not part of level data)
}
else
else if (trackloader.display_start_line)
olevelobjs.init_timetrial_sprites();
otraffic.init();
......@@ -905,8 +905,7 @@ void Outrun::select_course(bool jap, bool prototype)
adr.road_height_lookup = ROAD_HEIGHT_LOOKUP;
}
//trackloader.init_original_tracks();
trackloader.init();
trackloader.init(jap);
// Use Prototype Coconut Beach Track
trackloader.stage_data[0] = prototype ? 0x3A : 0x3C;
......
......@@ -147,6 +147,7 @@ void Config::load(const std::string &filename)
engine.level_objects = pt_config.get("engine.levelobjects", 1);
engine.randomgen = pt_config.get("engine.randomgen", 1);
engine.fix_bugs = pt_config.get("engine.fix_bugs", 1) != 0;
engine.layout_debug = pt_config.get("engine.layout_debug", 0) != 0;
// ------------------------------------------------------------------------
// Time Trial Mode
......
......@@ -88,6 +88,7 @@ struct engine_settings_t
int randomgen;
int level_objects;
bool fix_bugs;
bool layout_debug;
};
class Config
......
......@@ -27,7 +27,6 @@
#include "engine/outrun.hpp"
#include "frontend/config.hpp"
#include "frontend/menu.hpp"
#include "tracked/tracked.hpp"
// Direct X Haptic Support.
// Fine to include on non-windows builds as dummy functions used.
......@@ -46,7 +45,6 @@ Audio cannonball::audio;
#endif
Menu menu;
Tracked tracked;
static void quit_func(int code)
{
......@@ -180,10 +178,6 @@ static void tick()
menu.init();
state = STATE_MENU;
break;
case STATE_TRACKED:
tracked.tick();
break;
}
// Draw SDL Video
video.draw_frame();
......
......@@ -31,7 +31,6 @@ namespace cannonball
STATE_MENU,
STATE_INIT_GAME,
STATE_GAME,
STATE_TRACKED,
STATE_QUIT
};
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment