Commit c5a9841a authored by reassembler's avatar reassembler
Browse files

Preliminary work to support LayOut Editor

parent 605a39aa
......@@ -10,7 +10,7 @@ if (NOT DEFINED ENV{DXSDK})
endif()
# Use OpenGL for rendering.
set(OPENGL 1)
set(OPENGL 0)
include_directories(
"${sdl_root}/include"
......@@ -19,8 +19,8 @@ include_directories(
link_libraries(cannonball
SDL
SDLmain
opengl32 # For OpenGL
glu32 # For OpenGL
#opengl32 # For OpenGL
#glu32 # For OpenGL
dxguid
dinput8
)
......
......@@ -173,10 +173,10 @@ const uint32_t PAL_MUSIC_SELECT = 0x175CC;
const uint32_t PAL_DATA = 0x14ED8;
// Table of long addresses of ground colours
const uint32_t PAL_GROUND_TABLE = 0x17350;
const uint32_t PAL_GND_TABLE = 0x17350;
// Table of palette addresses
const uint32_t PAL_TABLE = 0x17590;
const uint32_t PAL_SKY_TABLE = 0x17590;
// Palette Data: Best Outrunners Name Entry
const uint32_t PAL_BESTOR = 0x17DCC;
......
......@@ -74,7 +74,8 @@ 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.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();
......@@ -125,15 +126,16 @@ 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);
//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
//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.setup_track(road_seg_master + 0x18, outrun.adr.road_height_lookup);
trackloader.init_track(oroad.stage_lookup_off);
}
//
......@@ -535,8 +537,9 @@ void OInitEngine::init_split1()
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.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,8 +736,9 @@ void OInitEngine::init_bonus()
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.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;
bonus1();
......@@ -947,34 +951,4 @@ void OInitEngine::test_bonus_mode(bool do_bonus_check)
// finalise_skid:
if (!ocrash.skid_counter)
otraffic.collision_traffic = 0;
}
// Stage Data
//
// This effectively 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.
//
// For USA there are unused tracks:
// 0x3A = Unused Coconut Beach
// 0x25 = Original Gateway track from Japanese edition
// 0x19 = Devils Canyon Variant
uint8_t OInitEngine::stage_data_usa[] =
{
0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stage 1
0x1E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stage 2
0x20, 0x2F, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, // Stage 3
0x2D, 0x35, 0x33, 0x21, 0x00, 0x00, 0x00, 0x00, // Stage 4
0x32, 0x23, 0x38, 0x22, 0x26, 0x00, 0x00, 0x00, // Stage 5
};
uint8_t OInitEngine::stage_data_jap[] =
{
0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stage 1
0x20, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stage 2
0x1E, 0x2F, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, // Stage 3
0x2D, 0x25, 0x33, 0x21, 0x00, 0x00, 0x00, 0x00, // Stage 4
0x32, 0x23, 0x38, 0x22, 0x26, 0x00, 0x00, 0x00, // Stage 5
};
}
\ No newline at end of file
......@@ -18,9 +18,6 @@
class OInitEngine
{
public:
// Hard Coded End Point of every level
const static uint16_t ROAD_END = 0x79C;
// Debug: Camera X Offset
int16_t camera_x_off;
......@@ -30,32 +27,6 @@ public:
// Time to wait before enabling ingame_engine after crash
int16_t ingame_counter;
// Road Segment Master.
// Points to location in ROM used to setup road_seg_addrx and other variables
uint32_t road_seg_master;
// road_seg_addr1 Format: [4 byte boundaries]
// [+0] Segment Position [Word]
// [+2] Number Of Sprites In Segment [Byte]
// [+3] Sprite Data Entry Number From Lookup Table * 4 [Byte]
uint32_t road_seg_addr1;
// road_seg_addr2 Format: [8 byte boundaries]
//
// [+0] Segment Position
// [+2] Set = Denotes Road Height Info. Unset = Denotes Road Width
// [+4] Segment Road Width / Segment Road Height Index
// [+6] Segment Width Adjustment SIGNED (Speed at which width is adjusted)
//uint32_t road_seg_addr2;
// road_seg_addr3 [6 byte boundaries]
//
// [+0] Segment Position
// [+2] Unknown data
// [+4] Segment Road type (1 = Straight, 2 = Slight Bend, 3 = Severe Bend)
//uint32_t road_seg_addr3;
// Road Split State
// 0 = No Road Split
// 1 = Init Road Split
......@@ -133,11 +104,6 @@ public:
// -1 = In Progress
int16_t change_width;
// Stage Order Tables
static uint8_t stage_data_usa[];
static uint8_t stage_data_jap[];
uint8_t* stage_data;
OInitEngine();
~OInitEngine();
void init(int8_t debug_level);
......
......@@ -14,6 +14,9 @@
See license.txt for more details.
***************************************************************************/
#include <iostream>
#include "../trackloader.hpp"
#include "engine/outils.hpp"
#include "engine/olevelobjs.hpp"
#include "engine/ostats.hpp"
......@@ -150,16 +153,27 @@ void OLevelObjs::setup_sprites(uint32_t z)
// +7: [Byte] Sprite Palette
void OLevelObjs::setup_sprite(oentry* sprite, uint32_t z)
{
#define READ8(x) trackloader.read8(trackloader.scenerymap_data, x)
#define READ16(x) trackloader.read16(trackloader.scenerymap_data, x)
#define READ32(x) trackloader.read32(trackloader.scenerymap_data, x)
sprite->control |= OSprites::ENABLE; // Turn sprite on
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 = ((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->xw2 = READ8(addr + 1) << 4;
sprite->yw = READ16(addr + 2) << 7;
sprite->type = ((uint8_t) 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->pal_src = READ8 (addr + 7);
osprites.map_palette(sprite);
......@@ -167,12 +181,12 @@ void OLevelObjs::setup_sprite(oentry* sprite, uint32_t z)
sprite->reload = 0;
sprite->z = z; // Set default zoom
if (roms.rom0p->read8(addr + 0) & 1)
if (READ8(addr + 0) & 1)
sprite->control |= OSprites::HFLIP;
else
sprite->control &=~ OSprites::HFLIP;
if (roms.rom0p->read8(addr + 0) & 2)
if (READ8(addr + 0) & 2)
sprite->control |= OSprites::SHADOW;
else
sprite->control &=~ OSprites::SHADOW;
......@@ -182,7 +196,7 @@ void OLevelObjs::setup_sprite(oentry* sprite, uint32_t z)
else
sprite->control &=~ OSprites::WIDE_ROAD;
sprite->draw_props = roms.rom0p->read8(addr + 0) & 0xF0;
sprite->draw_props = READ8(addr + 0) & 0xF0;
sprite->function_holder = sprite->draw_props >> 4; // set sprite type
setup_sprite_routine(sprite);
......
......@@ -7,6 +7,8 @@
See license.txt for more details.
***************************************************************************/
#include "../trackloader.hpp"
#include "engine/ohud.hpp"
#include "engine/oinputs.hpp"
#include "engine/opalette.hpp"
......@@ -36,17 +38,12 @@ void OPalette::init()
// Source: 8CA4
void OPalette::setup_sky_palette()
{
// Table of long palette addresses and other stage specific info
uint32_t stage_addr_table = roms.rom0p->read32(0x00 + oinitengine.road_seg_master);
// Address of sky palette information
uint16_t pal_addr = roms.rom0p->read16(stage_addr_table) << 2;
uint32_t src = roms.rom0.read32(PAL_TABLE + pal_addr);
// Read Address of sky palette information from index
uint32_t src = trackloader.read_pal_sky_table(trackloader.current_level->pal_sky);
uint32_t dst = 0x120F00; // palette ram
for (int16_t i = 0; i <= 0x1F; i++)
video.write_pal32(&dst, roms.rom0.read32(&src));
video.write_pal32(&dst, trackloader.read32(trackloader.pal_sky_data, &src));
}
// Setup data in RAM necessary for sky palette fade.
......@@ -71,14 +68,10 @@ void OPalette::setup_sky_change()
oinitengine.end_stage_props &= ~BIT_2; // Denote setup_sky_change done
// Address Of Sky Palette Entries for next stage
uint32_t src_pal_addr = outrun.adr.road_seg_table + (oinitengine.stage_data[stage_offset] << 2);
// Get index into palette table
uint16_t pal_index = roms.rom0p->read16(roms.rom0p->read32(roms.rom0p->read32(src_pal_addr))) << 2;
uint32_t src_addr = roms.rom0.read32(PAL_TABLE + pal_index);
uint32_t src = trackloader.read_pal_sky_table(trackloader.get_level(stage_offset)->pal_sky);
for (int16_t i = 0; i <= 0x1F; i++)
pal_manip[i + 0x3E0] = roms.rom0.read32(&src_addr);
pal_manip[i + 0x3E0] = trackloader.read32(trackloader.pal_sky_data, &src);
sky_palette_init |= BIT_0; // Denote new sky palette setup
......@@ -130,7 +123,7 @@ void OPalette::setup_sky_cycle()
start_colour >>= 16;
end_colour >>= 16;
}
fade_sky_pal_entry(start_colour, end_colour, dst_addr);
fade_sky_pal_entry(start_colour, end_colour, dst_addr);
}
//D15 : Shade hi/lo
......@@ -403,42 +396,53 @@ 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);
//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);
//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;
// sky palette
pal_fade[dst] = roms.rom0p->read16(pal_entries + 2);
//pal_fade[dst] = roms.rom0p->read16(pal_entries + 2);
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_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] = roms.rom0p->read16(pal_entries + 2); // second word
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_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] = roms.rom0p->read16(pal_entries + 2); // second word
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_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] = roms.rom0p->read16(pal_entries + 2); // second word
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_GROUND_TABLE + d0);
//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] = roms.rom0.read16(&ground_pal_addr);
pal_fade[dst] = trackloader.read16(trackloader.pal_gnd_data, &ground_pal_addr);//roms.rom0.read16(&ground_pal_addr);
dst += 9;
}
}
......@@ -521,19 +525,14 @@ void OPalette::write_fade_to_palram()
// Source: 8ED2
void OPalette::setup_ground_color()
{
// Table of long palette addresses and other stage specific info
uint32_t stage_addr_table = roms.rom0p->read32(0x14 + oinitengine.road_seg_master);
// Address of ground palette information
uint16_t pal_addr = roms.rom0p->read16(stage_addr_table) << 2;
uint32_t src = roms.rom0.read32(PAL_GROUND_TABLE + pal_addr);
// Read Address of ground palette information
uint32_t src = trackloader.read_pal_gnd_table(trackloader.current_level->pal_gnd);
uint32_t dst_pal_ground1 = 0x120840; // palette ram: ground 1
uint32_t dst_pal_ground2 = 0x120860; // palette ram: ground 2
for (int16_t i = 0; i < 8; i++)
{
uint32_t data = roms.rom0.read32(&src);
uint32_t data = trackloader.read32(trackloader.pal_gnd_data, &src);
video.write_pal32(&dst_pal_ground1, data);
video.write_pal32(&dst_pal_ground2, data);
}
......@@ -541,28 +540,24 @@ void OPalette::setup_ground_color()
void OPalette::setup_road_centre()
{
uint32_t stage_addr_table = roms.rom0p->read32(0x4 + oinitengine.road_seg_master);
video.write_pal32(0x12080C, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x12081C, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x12080C, trackloader.current_level->palr1.stripe_centre);
video.write_pal32(0x12081C, trackloader.current_level->palr2.stripe_centre);
}
void OPalette::setup_road_stripes()
{
uint32_t stage_addr_table = roms.rom0p->read32(0x8 + oinitengine.road_seg_master);
video.write_pal32(0x120804, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x120814, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x120804, trackloader.current_level->palr1.stripe);
video.write_pal32(0x120814, trackloader.current_level->palr2.stripe);
}
void OPalette::setup_road_side()
{
uint32_t stage_addr_table = roms.rom0p->read32(0xC + oinitengine.road_seg_master);
video.write_pal32(0x120808, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x120818, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x120808, trackloader.current_level->palr1.side);
video.write_pal32(0x120818, trackloader.current_level->palr2.side);
}
void OPalette::setup_road_colour()
{
uint32_t stage_addr_table = roms.rom0p->read32(0x10 + oinitengine.road_seg_master);
video.write_pal32(0x120800, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x120810, roms.rom0p->read32(&stage_addr_table));
video.write_pal32(0x120800, trackloader.current_level->palr1.road);
video.write_pal32(0x120810, trackloader.current_level->palr2.road);
}
......@@ -203,9 +203,9 @@ 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;
//const uint16_t stage1 = oinitengine.stage_data[0] << 2;
//stage_addr = roms.rom1p->read32(ROAD_DATA_LOOKUP + stage1);
trackloader.setup_path(stage1);
trackloader.init_path(0);
road_pos = 0;
road_ctrl = ROAD_BOTH_P0;
......@@ -246,8 +246,9 @@ void ORoad::check_load_road()
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);
//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;
}
......@@ -255,7 +256,7 @@ void ORoad::check_load_road()
// Check Split
if (road_load_split)
{
trackloader.set_split();
trackloader.init_path_split();
//stage_addr = ROAD_DATA_SPLIT;
road_load_split = 0;
}
......@@ -263,7 +264,7 @@ void ORoad::check_load_road()
// Check Bonus
else if (road_load_bonus)
{
trackloader.set_bonus();
trackloader.init_path_bonus();
//stage_addr = ROAD_DATA_BONUS;
road_load_bonus = 0;
}
......
......@@ -12,6 +12,8 @@
See license.txt for more details.
***************************************************************************/
#include "../trackloader.hpp"
#include "engine/oanimseq.hpp"
#include "engine/ocrash.hpp"
#include "engine/oferrari.hpp"
......@@ -205,23 +207,26 @@ 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()
{
uint32_t a0 = oinitengine.road_seg_addr1;
uint16_t d0 = roms.rom0p->read16(a0); // memory location stored in 60a00 (e.g.0x1de3e)
uint16_t d0 = trackloader.read_scenery_pos();
// Populate next road segment
if (d0 <= oroad.road_pos >> 16)
{
oinitengine.road_seg_addr1 += 4; // Increment to next long
seg_pos = roms.rom0p->read16(&a0); // Position In Level Data [Word]
seg_total_sprites = roms.rom0p->read8(&a0); // Number Of Sprites In Segment [byte]
d0 = roms.rom0p->read8(a0) * 4; // Block of Sprites [Byte]
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
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
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
......
......@@ -11,6 +11,7 @@
See license.txt for more details.
***************************************************************************/
#include "../trackloader.hpp"
#include "engine/opalette.hpp"
#include "engine/ostats.hpp"
#include "engine/otiles.hpp"
......@@ -611,7 +612,7 @@ void OTiles::init_next_tilemap()
void OTiles::init_tilemap_palette(uint16_t stage_id)
{
// Get internal level number
uint8_t level = oinitengine.stage_data[stage_id];
uint8_t level = trackloader.stage_data[stage_id];
switch (level)
{
......
......@@ -634,7 +634,8 @@ void Outrun::init_jump_table()
if (!ttrial.enabled)
{
otraffic.init_stage1_traffic(); // Hard coded traffic in right hand lane
olevelobjs.init_startline_sprites(); // Hard coded start line sprites (not part of level data)
if (trackloader.display_start_line)
olevelobjs.init_startline_sprites(); // Hard coded start line sprites (not part of level data)
}
else
olevelobjs.init_timetrial_sprites();
......@@ -703,7 +704,7 @@ void Outrun::select_course(bool jap, bool prototype)
roms.rom0p = &roms.j_rom0;
roms.rom1p = &roms.j_rom1;
oinitengine.stage_data = oinitengine.stage_data_jap;
//oinitengine.stage_data = oinitengine.stage_data_jap;
// Main CPU
adr.tiles_def_lookup = TILES_DEF_LOOKUP_J;
......@@ -804,7 +805,7 @@ void Outrun::select_course(bool jap, bool prototype)
roms.rom0p = &roms.rom0;
roms.rom1p = &roms.rom1;
oinitengine.stage_data = oinitengine.stage_data_usa;
//oinitengine.stage_data = oinitengine.stage_data_usa;
// Main CPU
adr.tiles_def_lookup = TILES_DEF_LOOKUP;
......@@ -904,6 +905,9 @@ void Outrun::select_course(bool jap, bool prototype)
adr.road_height_lookup = ROAD_HEIGHT_LOOKUP;
}
//trackloader.init_original_tracks();
trackloader.init();
// Use Prototype Coconut Beach Track
oinitengine.stage_data[0] = prototype ? 0x3A : 0x3C;
trackloader.stage_data[0] = prototype ? 0x3A : 0x3C;
}
\ No newline at end of file
......@@ -308,7 +308,7 @@ void Menu::tick_ui()
uint32_t result = 0x12F * (oinitengine.car_increment >> 16);
oroad.road_pos_change = result;
oroad.road_pos += result;
if (oroad.road_pos >> 16 > oinitengine.ROAD_END) // loop to beginning of track data
if (oroad.road_pos >> 16 > ROAD_END) // loop to beginning of track data
oroad.road_pos = 0;
oinitengine.update_road();
oinitengine.set_granular_position();
......
......@@ -29,6 +29,15 @@ const uint16_t S16_WIDTH_WIDE = 398;
const uint16_t S16_PALETTE_ENTRIES = 0x1000;
// Number of stages
const uint16_t STAGES = 15;
// Hard Coded End Point of every level
const static uint16_t ROAD_END = 0x79C;
// End Point of level for CPU1, including horizon
const static uint16_t ROAD_END_CPU1 = 0x904;
enum
{
BIT_0 = 0x01,
......
......@@ -27,7 +27,7 @@
#include "engine/outrun.hpp"
#include "frontend/config.hpp"
#include "frontend/menu.hpp"
//#include "tracked/tracked.hpp"
#include "tracked/tracked.hpp"
// Direct X Haptic Support.
// Fine to include on non-windows builds as dummy functions used.
......@@ -46,7 +46,7 @@ Audio cannonball::audio;
#endif