You've already forked HackerSM64
mirror of
https://github.com/HackerN64/HackerSM64.git
synced 2026-01-21 10:35:32 -08:00
Add hardcoded segments to segments page + move segment data to new files
This commit is contained in:
@@ -89,7 +89,7 @@ DECLARE_SEGMENT(capcom) // Hardcoded
|
||||
#endif // HVQM
|
||||
DECLARE_SEGMENT_NOLOAD_TEXT(main) // Hardcoded
|
||||
DECLARE_SEGMENT_NOLOAD_TEXT(engine) // Hardcoded
|
||||
DECLARE_SEGMENT_NOLOAD_TEXT(crashscreen) // Hardcoded
|
||||
DECLARE_SEGMENT_NOLOAD_TEXT(crashScreen) // Hardcoded
|
||||
DECLARE_SEGMENT_NOLOAD(framebuffers) // Hardcoded
|
||||
DECLARE_SEGMENT(entry) // Segment 16 (level entry)
|
||||
DECLARE_SEGMENT_NOLOAD_TEXT(behavior) // Segment 19 (bhv data)
|
||||
|
||||
14
sm64.ld
14
sm64.ld
@@ -304,24 +304,24 @@ SECTIONS
|
||||
|
||||
. = _engineSegmentBssEnd;
|
||||
|
||||
BEGIN_SEG(crashscreen, .)
|
||||
BEGIN_SEG(crashScreen, .)
|
||||
{
|
||||
BEGIN_TEXT(crashscreen)
|
||||
BEGIN_TEXT(crashScreen)
|
||||
BUILD_DIR/src/crash_screen*.o(.text*);
|
||||
END_TEXT(crashscreen)
|
||||
END_TEXT(crashScreen)
|
||||
BUILD_DIR/src/crash_screen*.o(.*data*);
|
||||
BUILD_DIR/src/crash_screen*.o(.rodata*);
|
||||
. = ALIGN(0x10);
|
||||
}
|
||||
END_SEG(crashscreen)
|
||||
BEGIN_NOLOAD(crashscreen)
|
||||
END_SEG(crashScreen)
|
||||
BEGIN_NOLOAD(crashScreen)
|
||||
{
|
||||
BUILD_DIR/src/crash_screen*.o(.*bss*);
|
||||
. = ALIGN(0x40);
|
||||
}
|
||||
END_NOLOAD(crashscreen)
|
||||
END_NOLOAD(crashScreen)
|
||||
|
||||
. = _crashscreenSegmentBssEnd;
|
||||
. = _crashScreenSegmentBssEnd;
|
||||
|
||||
BEGIN_NOLOAD(framebuffers)
|
||||
{
|
||||
|
||||
@@ -348,7 +348,7 @@ void thread3_main(UNUSED void *arg) {
|
||||
setup_mesg_queues();
|
||||
alloc_pool();
|
||||
load_code_segment(_engineSegmentStart, _engineSegmentEnd, _engineSegmentRomStart, _engineSegmentRomEnd);
|
||||
load_code_segment(_crashscreenSegmentStart, _crashscreenSegmentEnd, _crashscreenSegmentRomStart, _crashscreenSegmentRomEnd);
|
||||
load_code_segment(_crashScreenSegmentStart, _crashScreenSegmentEnd, _crashScreenSegmentRomStart, _crashScreenSegmentRomEnd);
|
||||
detect_emulator();
|
||||
create_crash_screen_thread();
|
||||
#ifdef UNF
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include "cs_descriptions.h"
|
||||
|
||||
#include "buffers/buffers.h"
|
||||
#include "engine/surface_load.h"
|
||||
#include "game/emutest.h"
|
||||
#include "game/game_init.h"
|
||||
@@ -213,286 +212,12 @@ const char* get_level_name(enum LevelNum levelNum) {
|
||||
}
|
||||
|
||||
|
||||
// -- SEGMENTS --
|
||||
|
||||
#define DEF_ROM_SEG_IMPL(_name, _str) { .id = (uintptr_t)_##_name##SegmentRomStart, .name = EXPAND_AND_STRINGIFY(_str), }
|
||||
#define DEF_ROM_SEG(_name) DEF_ROM_SEG_IMPL(_name, _name)
|
||||
#define DEF_ROM_SEG_YAY0(_name) DEF_ROM_SEG_IMPL(_name##_yay0, _name)
|
||||
#define DEF_ROM_SEG_GEO(_name) DEF_ROM_SEG_IMPL(_name##_geo, _name)
|
||||
#define DEF_ROM_SEG_SKY_YAY0(_name) DEF_ROM_SEG_IMPL(_name##_skybox_yay0, _name)
|
||||
#define DEF_ROM_SEG_SEG7(_name) DEF_ROM_SEG_IMPL(_name##_segment_7, _name)
|
||||
#define DEF_ROM_SEG_LANG_YAY0(_name) DEF_ROM_SEG_IMPL(translation_##_name##_yay0, _name)
|
||||
#define DEF_ROM_SEG_GLOBAL_VAR(_name) { .id = (uintptr_t)_name, .name = EXPAND_AND_STRINGIFY(_name), }
|
||||
|
||||
// 00: SEGMENT_MAIN
|
||||
static const IdNamePair sROMSegNames_00_main[] = {
|
||||
DEF_ROM_SEG(main),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 01: SEGMENT_RENDER
|
||||
static const IdNamePair sROMSegNames_01_render[] = {
|
||||
{ .id = OS_K0_TO_PHYSICAL(gGfxPools[0].buffer), .name = "gGfxPools[0]", },
|
||||
{ .id = OS_K0_TO_PHYSICAL(gGfxPools[1].buffer), .name = "gGfxPools[1]", },
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 02: SEGMENT_SEGMENT2
|
||||
static const IdNamePair sROMSegNames_02_segment2[] = {
|
||||
DEF_ROM_SEG_YAY0(segment2),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 03: SEGMENT_COMMON1_YAY0
|
||||
static const IdNamePair sROMSegNames_03_common1_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(common1),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 04: SEGMENT_GROUP0_YAY0
|
||||
static const IdNamePair sROMSegNames_04_group0_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(group0),
|
||||
DEF_ROM_SEG(boot),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 05: SEGMENT_GROUPA_YAY0
|
||||
static const IdNamePair sROMSegNames_05_groupA_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(group1),
|
||||
DEF_ROM_SEG_YAY0(group2),
|
||||
DEF_ROM_SEG_YAY0(group3),
|
||||
DEF_ROM_SEG_YAY0(group4),
|
||||
DEF_ROM_SEG_YAY0(group5),
|
||||
DEF_ROM_SEG_YAY0(group6),
|
||||
DEF_ROM_SEG_YAY0(group7),
|
||||
DEF_ROM_SEG_YAY0(group8),
|
||||
DEF_ROM_SEG_YAY0(group9),
|
||||
DEF_ROM_SEG_YAY0(group10),
|
||||
DEF_ROM_SEG_YAY0(group11),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 06: SEGMENT_GROUPB_YAY0
|
||||
static const IdNamePair sROMSegNames_06_groupB_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(group12),
|
||||
DEF_ROM_SEG_YAY0(group13),
|
||||
DEF_ROM_SEG_YAY0(group14),
|
||||
DEF_ROM_SEG_YAY0(group15),
|
||||
DEF_ROM_SEG_YAY0(group16),
|
||||
DEF_ROM_SEG_YAY0(group17),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 07: SEGMENT_LEVEL_DATA
|
||||
static const IdNamePair sROMSegNames_07_level_data[] = {
|
||||
#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
|
||||
#define DEFINE_LEVEL(textname, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) DEF_ROM_SEG_SEG7(folder),
|
||||
#include "levels/level_defines.h"
|
||||
#undef STUB_LEVEL
|
||||
#undef DEFINE_LEVEL
|
||||
DEF_ROM_SEG_YAY0(debug_level_select),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 08: SEGMENT_COMMON0_YAY0
|
||||
static const IdNamePair sROMSegNames_08_common0_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(common0),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 09: SEGMENT_TEXTURE
|
||||
static const IdNamePair sROMSegNames_09_texture[] = {
|
||||
DEF_ROM_SEG_YAY0(fire),
|
||||
DEF_ROM_SEG_YAY0(spooky),
|
||||
DEF_ROM_SEG_YAY0(generic),
|
||||
DEF_ROM_SEG_YAY0(water),
|
||||
DEF_ROM_SEG_YAY0(sky),
|
||||
DEF_ROM_SEG_YAY0(snow),
|
||||
DEF_ROM_SEG_YAY0(cave),
|
||||
DEF_ROM_SEG_YAY0(machine),
|
||||
DEF_ROM_SEG_YAY0(mountain),
|
||||
DEF_ROM_SEG_YAY0(grass),
|
||||
DEF_ROM_SEG_YAY0(outside),
|
||||
DEF_ROM_SEG_YAY0(inside),
|
||||
DEF_ROM_SEG_YAY0(effect),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 10: SEGMENT_SKYBOX
|
||||
static const IdNamePair sROMSegNames_10_skybox[] = {
|
||||
DEF_ROM_SEG_SKY_YAY0(water),
|
||||
DEF_ROM_SEG_SKY_YAY0(ccm),
|
||||
DEF_ROM_SEG_SKY_YAY0(clouds),
|
||||
DEF_ROM_SEG_SKY_YAY0(bitfs),
|
||||
DEF_ROM_SEG_SKY_YAY0(wdw),
|
||||
DEF_ROM_SEG_SKY_YAY0(cloud_floor),
|
||||
DEF_ROM_SEG_SKY_YAY0(ssl),
|
||||
DEF_ROM_SEG_SKY_YAY0(bbh),
|
||||
DEF_ROM_SEG_SKY_YAY0(bidw),
|
||||
DEF_ROM_SEG_SKY_YAY0(bits),
|
||||
DEF_ROM_SEG_YAY0(title_screen_bg), // For some reason the game uses the skybox segment for this.
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 11: SEGMENT_COMMON0_YAY0
|
||||
static const IdNamePair sROMSegNames_11_effect_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(effect),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 12: SEGMENT_GROUPA_GEO
|
||||
static const IdNamePair sROMSegNames_12_groupA_geo[] = {
|
||||
DEF_ROM_SEG_GEO(group1),
|
||||
DEF_ROM_SEG_GEO(group2),
|
||||
DEF_ROM_SEG_GEO(group3),
|
||||
DEF_ROM_SEG_GEO(group4),
|
||||
DEF_ROM_SEG_GEO(group5),
|
||||
DEF_ROM_SEG_GEO(group6),
|
||||
DEF_ROM_SEG_GEO(group7),
|
||||
DEF_ROM_SEG_GEO(group8),
|
||||
DEF_ROM_SEG_GEO(group9),
|
||||
DEF_ROM_SEG_GEO(group10),
|
||||
DEF_ROM_SEG_GEO(group11),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 13: SEGMENT_GROUPB_GEO
|
||||
static const IdNamePair sROMSegNames_13_groupB_geo[] = {
|
||||
DEF_ROM_SEG_GEO(group12),
|
||||
DEF_ROM_SEG_GEO(group13),
|
||||
DEF_ROM_SEG_GEO(group14),
|
||||
DEF_ROM_SEG_GEO(group15),
|
||||
DEF_ROM_SEG_GEO(group16),
|
||||
DEF_ROM_SEG_GEO(group17),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 14: SEGMENT_LEVEL_SCRIPT
|
||||
static const IdNamePair sROMSegNames_14_level_script[] = {
|
||||
#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
|
||||
#define DEFINE_LEVEL(textname, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) DEF_ROM_SEG(folder),
|
||||
#include "levels/level_defines.h"
|
||||
#undef STUB_LEVEL
|
||||
#undef DEFINE_LEVEL
|
||||
DEF_ROM_SEG(ending),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 15: SEGMENT_COMMON0_GEO
|
||||
static const IdNamePair sROMSegNames_15_common0_geo[] = {
|
||||
DEF_ROM_SEG_GEO(common0),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 16: SEGMENT_LEVEL_ENTRY
|
||||
static const IdNamePair sROMSegNames_16_entry[] = {
|
||||
DEF_ROM_SEG(entry),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 17: SEGMENT_MARIO_ANIMS
|
||||
static const IdNamePair sROMSegNames_17_mario_anims[] = {
|
||||
DEF_ROM_SEG_GLOBAL_VAR(gMarioAnims),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 18: SEGMENT_UNKNOWN_18
|
||||
// 19: SEGMENT_BEHAVIOR_DATA
|
||||
static const IdNamePair sROMSegNames_19_behavior[] = {
|
||||
DEF_ROM_SEG(behavior),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 20: SEGMENT_MENU_INTRO
|
||||
static const IdNamePair sROMSegNames_20_menu_intro[] = {
|
||||
DEF_ROM_SEG(intro),
|
||||
DEF_ROM_SEG(menu),
|
||||
DEF_ROM_SEG(ending),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 21: SEGMENT_GLOBAL_LEVEL_SCRIPT
|
||||
static const IdNamePair sROMSegNames_21_global_level_script[] = {
|
||||
DEF_ROM_SEG(scripts),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 22: SEGMENT_COMMON1_GEO
|
||||
static const IdNamePair sROMSegNames_22_common1_geo[] = {
|
||||
DEF_ROM_SEG_GEO(common1),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 23: SEGMENT_GROUP0_GEO
|
||||
static const IdNamePair sROMSegNames_23_group0_geo[] = {
|
||||
DEF_ROM_SEG_GEO(group0),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 24: SEGMENT_DEMO_INPUTS
|
||||
static const IdNamePair sROMSegNames_24_demo_inputs[] = {
|
||||
DEF_ROM_SEG_GLOBAL_VAR(gDemoInputs),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 25: SEGMENT_EU_TRANSLATION
|
||||
//! TODO: Update this when ASCII PR is merged:
|
||||
static const IdNamePair sROMSegNames_25_eu_translation[] = {
|
||||
#if MULTILANG
|
||||
DEF_ROM_SEG_IMPL(translation_en_yay0, english),
|
||||
DEF_ROM_SEG_IMPL(translation_fr_yay0, french),
|
||||
DEF_ROM_SEG_IMPL(translation_de_yay0, german),
|
||||
#endif // MULTILANG
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 26: SEGMENT_UNKNOWN_26
|
||||
// 27: SEGMENT_UNKNOWN_27
|
||||
// 28: SEGMENT_UNKNOWN_28
|
||||
// 29: SEGMENT_UNKNOWN_29
|
||||
// 30: SEGMENT_UNKNOWN_30
|
||||
// 31: SEGMENT_UNKNOWN_31
|
||||
|
||||
typedef struct SegmentInfo {
|
||||
const IdNamePair* list;
|
||||
const char* name;
|
||||
} SegmentInfo;
|
||||
static const SegmentInfo sSegmentInfos[32] = {
|
||||
[SEGMENT_MAIN ] = { .list = sROMSegNames_00_main, .name = "main", },
|
||||
[SEGMENT_RENDER ] = { .list = sROMSegNames_01_render, .name = "render", },
|
||||
[SEGMENT_SEGMENT2 ] = { .list = sROMSegNames_02_segment2, .name = "hud gfx", },
|
||||
[SEGMENT_COMMON1_YAY0 ] = { .list = sROMSegNames_03_common1_gfx, .name = "common1 gfx", },
|
||||
[SEGMENT_GROUP0_YAY0 ] = { .list = sROMSegNames_04_group0_gfx, .name = "group0 gfx", },
|
||||
[SEGMENT_GROUPA_YAY0 ] = { .list = sROMSegNames_05_groupA_gfx, .name = "groupA gfx", },
|
||||
[SEGMENT_GROUPB_YAY0 ] = { .list = sROMSegNames_06_groupB_gfx, .name = "groupB gfx", },
|
||||
[SEGMENT_LEVEL_DATA ] = { .list = sROMSegNames_07_level_data, .name = "level data", },
|
||||
[SEGMENT_COMMON0_YAY0 ] = { .list = sROMSegNames_08_common0_gfx, .name = "common0 gfx", },
|
||||
[SEGMENT_TEXTURE ] = { .list = sROMSegNames_09_texture, .name = "textures bin", },
|
||||
[SEGMENT_SKYBOX ] = { .list = sROMSegNames_10_skybox, .name = "skybox bin", },
|
||||
[SEGMENT_EFFECT_YAY0 ] = { .list = sROMSegNames_11_effect_gfx, .name = "effects gfx", },
|
||||
[SEGMENT_GROUPA_GEO ] = { .list = sROMSegNames_12_groupA_geo, .name = "groupA geo", },
|
||||
[SEGMENT_GROUPB_GEO ] = { .list = sROMSegNames_13_groupB_geo, .name = "groupB geo", },
|
||||
[SEGMENT_LEVEL_SCRIPT ] = { .list = sROMSegNames_14_level_script, .name = "level script", },
|
||||
[SEGMENT_COMMON0_GEO ] = { .list = sROMSegNames_15_common0_geo, .name = "common0 geo", },
|
||||
[SEGMENT_LEVEL_ENTRY ] = { .list = sROMSegNames_16_entry, .name = "level entry", },
|
||||
[SEGMENT_MARIO_ANIMS ] = { .list = sROMSegNames_17_mario_anims, .name = "mario anims", },
|
||||
[SEGMENT_UNKNOWN_18 ] = { .list = NULL, .name = "unknown 18", },
|
||||
[SEGMENT_BEHAVIOR_DATA ] = { .list = sROMSegNames_19_behavior, .name = "bhv data", },
|
||||
[SEGMENT_MENU_INTRO ] = { .list = sROMSegNames_20_menu_intro, .name = "menu/intro", },
|
||||
[SEGMENT_GLOBAL_LEVEL_SCRIPT] = { .list = sROMSegNames_21_global_level_script, .name = "global level script", },
|
||||
[SEGMENT_COMMON1_GEO ] = { .list = sROMSegNames_22_common1_geo, .name = "common1 geo", },
|
||||
[SEGMENT_GROUP0_GEO ] = { .list = sROMSegNames_23_group0_geo, .name = "group0 geo", },
|
||||
[SEGMENT_DEMO_INPUTS ] = { .list = sROMSegNames_24_demo_inputs, .name = "demo inputs", },
|
||||
[SEGMENT_EU_TRANSLATION ] = { .list = sROMSegNames_25_eu_translation, .name = "languages", },
|
||||
[SEGMENT_UNKNOWN_26 ] = { .list = NULL, .name = "unknown 26", },
|
||||
[SEGMENT_UNKNOWN_27 ] = { .list = NULL, .name = "unknown 27", },
|
||||
[SEGMENT_UNKNOWN_28 ] = { .list = NULL, .name = "unknown 28", },
|
||||
[SEGMENT_UNKNOWN_29 ] = { .list = NULL, .name = "unknown 29", },
|
||||
[SEGMENT_UNKNOWN_30 ] = { .list = NULL, .name = "unknown 30", },
|
||||
[SEGMENT_UNKNOWN_31 ] = { .list = NULL, .name = "unknown 31", },
|
||||
};
|
||||
// Get the name of a segment.
|
||||
const char* get_segment_name(u8 segmentId) {
|
||||
return ((segmentId < ARRAY_COUNT(sSegmentInfos)) ? sSegmentInfos[segmentId].name : "unknown");
|
||||
}
|
||||
// Get the name of what is currently loaded in a segment.
|
||||
const char* get_segment_sub_name(u8 segmentId) {
|
||||
const char* ret = NULL;
|
||||
Address romAddr = sSegmentROMTable[segmentId];
|
||||
if (romAddr == (uintptr_t)NULL) {
|
||||
return "unloaded";
|
||||
}
|
||||
|
||||
const IdNamePair* list = sSegmentInfos[segmentId].list;
|
||||
if (list != NULL) {
|
||||
ret = get_name_from_null_terminated_id_list(romAddr, list);
|
||||
}
|
||||
|
||||
return str_null_fallback(ret, "unknown");
|
||||
}
|
||||
|
||||
|
||||
// -- RAM POOLS --
|
||||
|
||||
static const RangeNamePair sHardcodedSegmentRanges[] = {
|
||||
{ .start = (Address)_mainSegmentStart, .end = (Address)_mainSegmentEnd, .name = "main", },
|
||||
{ .start = (Address)_engineSegmentStart, .end = (Address)_engineSegmentEnd, .name = "engine", },
|
||||
{ .start = (Address)_crashscreenSegmentStart, .end = (Address)_crashscreenSegmentBssEnd, .name = "crash screeen", },
|
||||
{ .start = (Address)_crashScreenSegmentStart, .end = (Address)_crashScreenSegmentBssEnd, .name = "crash screeen", },
|
||||
{ .start = (Address)_goddardSegmentStart, .end = (Address)_goddardSegmentEnd, .name = "goddard", },
|
||||
{ .start = (Address)_framebuffersSegmentBssStart, .end = (Address)_framebuffersSegmentBssEnd, .name = "framebuffers", },
|
||||
{ .start = (Address)_zbufferSegmentBssStart, .end = (Address)_zbufferSegmentBssEnd, .name = "zbuffer", },
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "game/level_update.h"
|
||||
#include "game/main.h"
|
||||
|
||||
#include "util/cs_segments.h"
|
||||
|
||||
|
||||
extern char HackerSM64_version_txt[];
|
||||
extern char CrashScreen_version_txt[];
|
||||
@@ -41,8 +43,6 @@ const char* get_thread_flags_str(OSThread* thread);
|
||||
const char* get_warp_node_name(enum WarpNodes id);
|
||||
const char* get_level_name(enum LevelNum levelNum);
|
||||
|
||||
const char* get_segment_name(u8 segmentId);
|
||||
const char* get_segment_sub_name(u8 segmentId);
|
||||
const char* get_hardcoded_memory_str(Address addr);
|
||||
|
||||
const char* get_processor_name(u8 imp);
|
||||
|
||||
@@ -152,7 +152,7 @@ void _cs_about_func_save_type(char* buf) {
|
||||
}
|
||||
ABOUT_ENTRY_FUNC(compression, gCompressionFormat)
|
||||
void _cs_about_func_crash_screen(char* buf) {
|
||||
size_t csSize = ((Address)_crashscreenSegmentRomEnd - (Address)_crashscreenSegmentRomStart);
|
||||
size_t csSize = ((Address)_crashScreenSegmentRomEnd - (Address)_crashScreenSegmentRomStart);
|
||||
char* p = buf;
|
||||
p += sprintf_int_with_commas(p, csSize);
|
||||
p += sprintf(p, (STR_SUFFIX_BYTES" "STR_PERCENT_OF_ROM), percent_of(csSize, (size_t)gRomSize));
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "sm64.h"
|
||||
|
||||
#include "crash_screen/util/map_parser.h"
|
||||
#include "crash_screen/util/cs_segments.h"
|
||||
#include "crash_screen/cs_controls.h"
|
||||
#include "crash_screen/cs_draw.h"
|
||||
#include "crash_screen/cs_descriptions.h"
|
||||
@@ -44,8 +45,8 @@ const enum ControlTypes cs_cont_list_segments[] = {
|
||||
};
|
||||
|
||||
|
||||
u32 sSegmentsSelectedIndex = 0;
|
||||
static u32 sSegmentsViewportIndex = 0;
|
||||
SegmentsList sSegmentsSelectedIndex = 0;
|
||||
static SegmentsList sSegmentsViewportIndex = 0;
|
||||
|
||||
|
||||
void page_segments_init(void) {
|
||||
@@ -53,9 +54,17 @@ void page_segments_init(void) {
|
||||
sSegmentsViewportIndex = 0;
|
||||
}
|
||||
|
||||
void draw_ram_segment(void) {
|
||||
|
||||
}
|
||||
|
||||
void draw_hardcoded_segment(void) {
|
||||
|
||||
}
|
||||
|
||||
void draw_segments_list(CSTextCoord_u32 line) {
|
||||
_Bool showAddresses = cs_get_setting_val(CS_OPT_GROUP_PAGE_SEGMENTS, CS_OPT_SEGMENTS_SHOW_ADDRESSES);
|
||||
u32 currIndex = sSegmentsViewportIndex;
|
||||
SegmentsList currIndex = sSegmentsViewportIndex;
|
||||
|
||||
for (CSTextCoord_u32 row = 0; row < (NUM_SHOWN_SEGMENTS * 2); row += 2) {
|
||||
ScreenCoord_u32 y = TEXT_Y(line + row);
|
||||
@@ -66,31 +75,41 @@ void draw_segments_list(CSTextCoord_u32 line) {
|
||||
|
||||
cs_draw_divider_translucent(DIVIDER_Y(line + row));
|
||||
|
||||
Address start = (uintptr_t)get_segment_base_addr(currIndex);
|
||||
size_t size = get_segment_size(currIndex);
|
||||
Address romStart = sSegmentROMTable[currIndex];
|
||||
_Bool isLoaded = (romStart != (Address)NULL);
|
||||
Address pAddr = cs_get_segment_pAddr(currIndex);
|
||||
_Bool isLoaded = is_segment_loaded(currIndex);
|
||||
_Bool isHardcoded = is_segment_hardcoded(currIndex);
|
||||
|
||||
// Line 1:
|
||||
CSTextCoord_u32 textEnd = CRASH_SCREEN_NUM_CHARS_X;
|
||||
if (showAddresses && isLoaded) {
|
||||
textEnd -= STRLEN("00000000-00000000");
|
||||
cs_print(TEXT_X(textEnd), y, (STR_HEX_WORD" "STR_COLOR_PREFIX STR_HEX_WORD), start, COLOR_RGBA32_CRASH_HEADER, romStart);
|
||||
cs_print(TEXT_X(textEnd), y, (STR_HEX_WORD" "STR_COLOR_PREFIX STR_HEX_WORD),
|
||||
cs_get_segment_vAddr(currIndex), COLOR_RGBA32_CRASH_HEADER, pAddr
|
||||
);
|
||||
}
|
||||
const RGBA32 segColor = COLOR_RGBA32_LIGHT_CYAN;
|
||||
CSTextCoord_u32 textStart = cs_print(TEXT_X(0), y, STR_COLOR_PREFIX"seg%02d:", segColor, currIndex);
|
||||
cs_print_scroll(TEXT_X(textStart), y, (textEnd - textStart), STR_COLOR_PREFIX"%s", segColor, get_segment_name(currIndex));
|
||||
CSTextCoord_u32 textStart = 0;
|
||||
if (!isHardcoded) {
|
||||
textStart += cs_print(TEXT_X(0), y, STR_COLOR_PREFIX"seg%02d:", segColor, SEGMENT_LIST_TO_TABLE(currIndex));
|
||||
}
|
||||
cs_print_scroll(TEXT_X(textStart), y, (textEnd - textStart), STR_COLOR_PREFIX"%s", segColor, cs_get_segment_name(currIndex));
|
||||
|
||||
y += TEXT_HEIGHT(1);
|
||||
|
||||
// Line 2:
|
||||
if (showAddresses && isLoaded) {
|
||||
const RGBA32 romColor = COLOR_RGBA32_LIGHT_BLUE;
|
||||
CSTextCoord_u32 romStrStart = cs_print(TEXT_X(1), y, STR_COLOR_PREFIX"loaded:", COLOR_RGBA32_CRASH_HEADER);
|
||||
cs_print_scroll(TEXT_X(1 + romStrStart), y, (textEnd - (1 + romStrStart)), STR_COLOR_PREFIX"%s",
|
||||
romColor, get_segment_sub_name(currIndex)
|
||||
if (isHardcoded) {
|
||||
cs_print(TEXT_X(1), y, STR_COLOR_PREFIX"hardcoded", COLOR_RGBA32_GRAY);
|
||||
} else {
|
||||
const RGBA32 romColor = COLOR_RGBA32_LIGHT_BLUE;
|
||||
CSTextCoord_u32 romStrStart = cs_print(TEXT_X(1), y, STR_COLOR_PREFIX"loaded:", COLOR_RGBA32_CRASH_HEADER);
|
||||
cs_print_scroll(TEXT_X(1 + romStrStart), y, (textEnd - (1 + romStrStart)), STR_COLOR_PREFIX"%s",
|
||||
romColor, cs_get_segment_sub_name(currIndex)
|
||||
);
|
||||
}
|
||||
cs_print(TEXT_X(textEnd + 4), y, (STR_COLOR_PREFIX"size:"STR_HEX_PREFIX"%X"), COLOR_RGBA32_GRAY,
|
||||
cs_get_segment_size(currIndex)
|
||||
);
|
||||
cs_print(TEXT_X(textEnd + 4), y, (STR_COLOR_PREFIX"size:"STR_HEX_PREFIX"%X"), COLOR_RGBA32_GRAY, size);
|
||||
} else {
|
||||
cs_print(TEXT_X(1), y, STR_COLOR_PREFIX"unloaded", COLOR_RGBA32_GRAY);
|
||||
}
|
||||
@@ -117,7 +136,7 @@ void page_segments_draw(void) {
|
||||
// Scroll Bar:
|
||||
cs_draw_scroll_bar(
|
||||
(DIVIDER_Y(line) + 1), DIVIDER_Y(CRASH_SCREEN_NUM_CHARS_Y),
|
||||
NUM_SHOWN_SEGMENTS, 32,
|
||||
NUM_SHOWN_SEGMENTS, NUM_SEGS,
|
||||
sSegmentsViewportIndex,
|
||||
COLOR_RGBA32_CRASH_SCROLL_BAR, TRUE
|
||||
);
|
||||
@@ -129,15 +148,15 @@ void page_segments_draw(void) {
|
||||
}
|
||||
void page_segments_input(void) {
|
||||
if (gCSCompositeController->buttonPressed & A_BUTTON) {
|
||||
if (sSegmentROMTable[sSegmentsSelectedIndex] != (Address)NULL) {
|
||||
open_address_select((Address)get_segment_base_addr(sSegmentsSelectedIndex));
|
||||
if (is_segment_loaded(sSegmentsSelectedIndex)) {
|
||||
open_address_select(cs_get_segment_vAddr(sSegmentsSelectedIndex));
|
||||
}
|
||||
}
|
||||
|
||||
s32 change = 0;
|
||||
if (gCSDirectionFlags.pressed.up ) change = -1; // Scroll up.
|
||||
if (gCSDirectionFlags.pressed.down) change = +1; // Scroll down.
|
||||
sSegmentsSelectedIndex = WRAP(((s32)sSegmentsSelectedIndex + change), 0, (s32)(32 - 1));
|
||||
sSegmentsSelectedIndex = WRAP(((s32)sSegmentsSelectedIndex + change), 0, (s32)(NUM_SEGS - 1));
|
||||
|
||||
sSegmentsViewportIndex = cs_clamp_view_to_selection(sSegmentsViewportIndex, sSegmentsSelectedIndex, NUM_SHOWN_SEGMENTS, 1);
|
||||
}
|
||||
@@ -146,11 +165,15 @@ void page_segments_print(void) {
|
||||
#ifdef UNF
|
||||
osSyncPrintf("\n");
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
Address start = (uintptr_t)get_segment_base_addr(i);
|
||||
Address end = (start + get_segment_size(i));
|
||||
Address romStart = sSegmentROMTable[i];
|
||||
osSyncPrintf("["STR_HEX_WORD"-"STR_HEX_WORD"]: seg%02d %s\t\tloaded: "STR_HEX_WORD" %s\n", start, end, i, get_segment_name(i), romStart, get_segment_sub_name(i));
|
||||
for (int i = 0; i < NUM_SEGS; i++) {
|
||||
Address start = cs_get_segment_vAddr(i);
|
||||
Address end = (start + cs_get_segment_size(i));
|
||||
Address romStart = cs_get_segment_pAddr(i);
|
||||
osSyncPrintf(
|
||||
"["STR_HEX_WORD"-"STR_HEX_WORD"]: seg%02d %s\t\tloaded: "STR_HEX_WORD" %s\n",
|
||||
start, end, SEGMENT_LIST_TO_TABLE(i),
|
||||
cs_get_segment_name(i), romStart, cs_get_segment_sub_name(i)
|
||||
);
|
||||
}
|
||||
#endif // UNF
|
||||
}
|
||||
|
||||
164
src/crash_screen/util/cs_segments.c
Normal file
164
src/crash_screen/util/cs_segments.c
Normal file
@@ -0,0 +1,164 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "sm64.h"
|
||||
|
||||
#include "crash_screen/cs_main.h"
|
||||
#include "crash_screen/cs_descriptions.h"
|
||||
|
||||
#include "cs_segments.h"
|
||||
|
||||
|
||||
// -- SEGMENTS --
|
||||
|
||||
#include "segment_data.inc.c"
|
||||
|
||||
typedef struct SegmentNameList {
|
||||
const IdNamePair* list;
|
||||
const char* name;
|
||||
} SegmentNameList;
|
||||
ALIGNED8 static const SegmentNameList sSegmentNames[NUM_TABLE_SEGS] = {
|
||||
[SEG_TABLE_MAIN ] = { .list = sROMSegNames_00_main, .name = "main", },
|
||||
[SEG_TABLE_RENDER ] = { .list = sROMSegNames_01_render, .name = "render", },
|
||||
[SEG_TABLE_SEGMENT2 ] = { .list = sROMSegNames_02_segment2, .name = "hud gfx", },
|
||||
[SEG_TABLE_COMMON1_YAY0 ] = { .list = sROMSegNames_03_common1_gfx, .name = "common1 gfx", },
|
||||
[SEG_TABLE_GROUP0_YAY0 ] = { .list = sROMSegNames_04_group0_gfx, .name = "group0 gfx", },
|
||||
[SEG_TABLE_GROUPA_YAY0 ] = { .list = sROMSegNames_05_groupA_gfx, .name = "groupA gfx", },
|
||||
[SEG_TABLE_GROUPB_YAY0 ] = { .list = sROMSegNames_06_groupB_gfx, .name = "groupB gfx", },
|
||||
[SEG_TABLE_LEVEL_DATA ] = { .list = sROMSegNames_07_level_data, .name = "level data", },
|
||||
[SEG_TABLE_COMMON0_YAY0 ] = { .list = sROMSegNames_08_common0_gfx, .name = "common0 gfx", },
|
||||
[SEG_TABLE_TEXTURE ] = { .list = sROMSegNames_09_texture, .name = "textures bin", },
|
||||
[SEG_TABLE_SKYBOX ] = { .list = sROMSegNames_10_skybox, .name = "skybox bin", },
|
||||
[SEG_TABLE_EFFECT_YAY0 ] = { .list = sROMSegNames_11_effect_gfx, .name = "effects gfx", },
|
||||
[SEG_TABLE_GROUPA_GEO ] = { .list = sROMSegNames_12_groupA_geo, .name = "groupA geo", },
|
||||
[SEG_TABLE_GROUPB_GEO ] = { .list = sROMSegNames_13_groupB_geo, .name = "groupB geo", },
|
||||
[SEG_TABLE_LEVEL_SCRIPT ] = { .list = sROMSegNames_14_level_script, .name = "level script", },
|
||||
[SEG_TABLE_COMMON0_GEO ] = { .list = sROMSegNames_15_common0_geo, .name = "common0 geo", },
|
||||
[SEG_TABLE_LEVEL_ENTRY ] = { .list = sROMSegNames_16_entry, .name = "level entry", },
|
||||
[SEG_TABLE_MARIO_ANIMS ] = { .list = sROMSegNames_17_mario_anims, .name = "mario anims", },
|
||||
[SEG_TABLE_UNKNOWN_18 ] = { .list = NULL, .name = "unknown 18", },
|
||||
[SEG_TABLE_BEHAVIOR_DATA ] = { .list = sROMSegNames_19_behavior, .name = "bhv data", },
|
||||
[SEG_TABLE_MENU_INTRO ] = { .list = sROMSegNames_20_menu_intro, .name = "menu/intro", },
|
||||
[SEG_TABLE_GLOBAL_LEVEL_SCRIPT] = { .list = sROMSegNames_21_global_level_script, .name = "global level script", },
|
||||
[SEG_TABLE_COMMON1_GEO ] = { .list = sROMSegNames_22_common1_geo, .name = "common1 geo", },
|
||||
[SEG_TABLE_GROUP0_GEO ] = { .list = sROMSegNames_23_group0_geo, .name = "group0 geo", },
|
||||
[SEG_TABLE_DEMO_INPUTS ] = { .list = sROMSegNames_24_demo_inputs, .name = "demo inputs", },
|
||||
[SEG_TABLE_EU_TRANSLATION ] = { .list = sROMSegNames_25_eu_translation, .name = "languages", },
|
||||
[SEG_TABLE_UNKNOWN_26 ] = { .list = NULL, .name = "unknown 26", },
|
||||
[SEG_TABLE_UNKNOWN_27 ] = { .list = NULL, .name = "unknown 27", },
|
||||
[SEG_TABLE_UNKNOWN_28 ] = { .list = NULL, .name = "unknown 28", },
|
||||
[SEG_TABLE_UNKNOWN_29 ] = { .list = NULL, .name = "unknown 29", },
|
||||
[SEG_TABLE_UNKNOWN_30 ] = { .list = NULL, .name = "unknown 30", },
|
||||
[SEG_TABLE_UNKNOWN_31 ] = { .list = NULL, .name = "unknown 31", },
|
||||
};
|
||||
typedef struct HardcodedSegmentInfo {
|
||||
/*0x00*/ const char* name;
|
||||
/*0x00*/ const Address pStart;
|
||||
/*0x04*/ const Address pEnd;
|
||||
/*0x08*/ const Address vStart;
|
||||
/*0x0C*/ const Address vEnd;
|
||||
} HardcodedSegmentInfo; /*0x10*/
|
||||
#define HARDCODED_SEG(_name, _seg, _romType, _startType, _endType) { \
|
||||
.name = _name, \
|
||||
.pStart = (const Address)_##_seg##Segment##_romType##Start, \
|
||||
.pEnd = (const Address)_##_seg##Segment##_romType##End, \
|
||||
.vStart = (const Address)_##_seg##Segment##_startType##Start, \
|
||||
.vEnd = (const Address)_##_seg##Segment##_endType##End, \
|
||||
}
|
||||
static const HardcodedSegmentInfo sHardcodedSegmentInfos[NUM_HARDCODED_SEGS] = {
|
||||
[SEG_HARDCODED_MAIN ] = HARDCODED_SEG("main", main, Rom, , Bss),
|
||||
[SEG_HARDCODED_ENGINE ] = HARDCODED_SEG("engine", engine, Rom, , Bss),
|
||||
[SEG_HARDCODED_CRASH_SCREEN] = HARDCODED_SEG("crash screen", crashScreen, Rom, , Bss),
|
||||
[SEG_HARDCODED_FRAMEBUFFERS] = HARDCODED_SEG("framebuffers", framebuffers, Bss, Bss, Bss),
|
||||
[SEG_HARDCODED_ZBUFFER ] = HARDCODED_SEG("zbuffer", zbuffer, Bss, Bss, Bss),
|
||||
[SEG_HARDCODED_BUFFERS ] = HARDCODED_SEG("buffers", buffers, Bss, Bss, Bss),
|
||||
[SEG_HARDCODED_MAPDATA ] = HARDCODED_SEG("map data", mapData, Rom, , ),
|
||||
[SEG_HARDCODED_GODDARD ] = HARDCODED_SEG("goddard", goddard, Rom, , Bss),
|
||||
};
|
||||
|
||||
_Bool is_segment_hardcoded(SegmentsList segment) {
|
||||
return (IS_HARDCODED_FIRST() ? (segment < SEG_TABLE_START) : (segment >= SEG_HARDCODED_START));
|
||||
}
|
||||
|
||||
_Bool is_segment_loaded(SegmentsList segment) {
|
||||
//! TODO: Is it possible to check if hardcoded segments are loaded?
|
||||
if (is_segment_hardcoded(segment)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return (FITS_IN_ARRAY(segment, sSegmentROMTable) ? (sSegmentROMTable[SEGMENT_LIST_TO_TABLE(segment)] != (Address)NULL) : FALSE);
|
||||
}
|
||||
|
||||
static const HardcodedSegmentInfo* get_hardcoded_segment_info_from_list(SegmentsList segment) {
|
||||
HardcodedSegments hseg = SEGMENT_LIST_TO_HARDCODED(segment);
|
||||
return (FITS_IN_ARRAY(hseg, sHardcodedSegmentInfos) ? &sHardcodedSegmentInfos[hseg] : NULL);
|
||||
}
|
||||
|
||||
// Get the name of a segment.
|
||||
const char* get_segment_name(TableSegments segment) {
|
||||
return (FITS_IN_ARRAY(segment, sSegmentNames) ? sSegmentNames[segment].name : "unknown");
|
||||
}
|
||||
const char* cs_get_segment_name(SegmentsList segment) {
|
||||
if (is_segment_hardcoded(segment)) {
|
||||
const HardcodedSegmentInfo* info = get_hardcoded_segment_info_from_list(segment);
|
||||
return ((info != NULL) ? info->name : "unknown");
|
||||
} else {
|
||||
return get_segment_name(SEGMENT_LIST_TO_TABLE(segment));
|
||||
}
|
||||
}
|
||||
// Get the name of what is currently loaded in a segment.
|
||||
const char* get_segment_sub_name(TableSegments segment) {
|
||||
const char* ret = NULL;
|
||||
|
||||
Address romAddr = sSegmentROMTable[segment];
|
||||
if (romAddr == (uintptr_t)NULL) {
|
||||
return "unloaded";
|
||||
}
|
||||
|
||||
const IdNamePair* list = sSegmentNames[segment].list;
|
||||
if (list != NULL) {
|
||||
ret = get_name_from_null_terminated_id_list(romAddr, list);
|
||||
}
|
||||
|
||||
return str_null_fallback(ret, "unknown");
|
||||
}
|
||||
const char* cs_get_segment_sub_name(SegmentsList segment) {
|
||||
const char* ret = NULL;
|
||||
|
||||
if (!is_segment_hardcoded(segment)) {
|
||||
ret = get_segment_sub_name(SEGMENT_LIST_TO_TABLE(segment));
|
||||
}
|
||||
|
||||
return str_null_fallback(ret, "unknown");
|
||||
}
|
||||
|
||||
Address cs_get_segment_vAddr(SegmentsList segment) {
|
||||
if (is_segment_hardcoded(segment)) {
|
||||
const HardcodedSegmentInfo* info = get_hardcoded_segment_info_from_list(segment);
|
||||
return ((info != NULL) ? info->vStart : (Address)NULL);
|
||||
} else {
|
||||
return (Address)get_segment_base_addr(SEGMENT_LIST_TO_TABLE(segment));
|
||||
}
|
||||
}
|
||||
|
||||
Address cs_get_segment_pAddr(SegmentsList segment) {
|
||||
if (is_segment_hardcoded(segment)) {
|
||||
const HardcodedSegmentInfo* info = get_hardcoded_segment_info_from_list(segment);
|
||||
return ((info != NULL) ? info->pStart : (Address)NULL);
|
||||
} else {
|
||||
TableSegments tseg = SEGMENT_LIST_TO_TABLE(segment);
|
||||
return (FITS_IN_ARRAY(tseg, sSegmentROMTable) ? sSegmentROMTable[tseg] : (Address)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
size_t cs_get_segment_size(SegmentsList segment) {
|
||||
if (is_segment_hardcoded(segment)) {
|
||||
const HardcodedSegmentInfo* info = get_hardcoded_segment_info_from_list(segment);
|
||||
return ((info != NULL) ? (info->vEnd - info->vStart) : 0);
|
||||
} else {
|
||||
TableSegments tseg = SEGMENT_LIST_TO_TABLE(segment);
|
||||
return (FITS_IN_ARRAY(tseg, sSegmentSizes) ? sSegmentSizes[tseg] : (Address)NULL);
|
||||
}
|
||||
}
|
||||
118
src/crash_screen/util/cs_segments.h
Normal file
118
src/crash_screen/util/cs_segments.h
Normal file
@@ -0,0 +1,118 @@
|
||||
#pragma once
|
||||
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef enum TableSegments {
|
||||
SEG_TABLE_MAIN = SEGMENT_MAIN,
|
||||
SEG_TABLE_RENDER = SEGMENT_RENDER,
|
||||
SEG_TABLE_SEGMENT2 = SEGMENT_SEGMENT2,
|
||||
SEG_TABLE_COMMON1_YAY0 = SEGMENT_COMMON1_YAY0,
|
||||
SEG_TABLE_GROUP0_YAY0 = SEGMENT_GROUP0_YAY0,
|
||||
SEG_TABLE_GROUPA_YAY0 = SEGMENT_GROUPA_YAY0,
|
||||
SEG_TABLE_GROUPB_YAY0 = SEGMENT_GROUPB_YAY0,
|
||||
SEG_TABLE_LEVEL_DATA = SEGMENT_LEVEL_DATA,
|
||||
SEG_TABLE_COMMON0_YAY0 = SEGMENT_COMMON0_YAY0,
|
||||
SEG_TABLE_TEXTURE = SEGMENT_TEXTURE,
|
||||
SEG_TABLE_SKYBOX = SEGMENT_SKYBOX,
|
||||
SEG_TABLE_EFFECT_YAY0 = SEGMENT_EFFECT_YAY0,
|
||||
SEG_TABLE_GROUPA_GEO = SEGMENT_GROUPA_GEO,
|
||||
SEG_TABLE_GROUPB_GEO = SEGMENT_GROUPB_GEO,
|
||||
SEG_TABLE_LEVEL_SCRIPT = SEGMENT_LEVEL_SCRIPT,
|
||||
SEG_TABLE_COMMON0_GEO = SEGMENT_COMMON0_GEO,
|
||||
SEG_TABLE_LEVEL_ENTRY = SEGMENT_LEVEL_ENTRY,
|
||||
SEG_TABLE_MARIO_ANIMS = SEGMENT_MARIO_ANIMS,
|
||||
SEG_TABLE_UNKNOWN_18 = SEGMENT_UNKNOWN_18,
|
||||
SEG_TABLE_BEHAVIOR_DATA = SEGMENT_BEHAVIOR_DATA,
|
||||
SEG_TABLE_MENU_INTRO = SEGMENT_MENU_INTRO,
|
||||
SEG_TABLE_GLOBAL_LEVEL_SCRIPT = SEGMENT_GLOBAL_LEVEL_SCRIPT,
|
||||
SEG_TABLE_COMMON1_GEO = SEGMENT_COMMON1_GEO,
|
||||
SEG_TABLE_GROUP0_GEO = SEGMENT_GROUP0_GEO,
|
||||
SEG_TABLE_DEMO_INPUTS = SEGMENT_DEMO_INPUTS,
|
||||
SEG_TABLE_EU_TRANSLATION = SEGMENT_EU_TRANSLATION,
|
||||
SEG_TABLE_UNKNOWN_26 = SEGMENT_UNKNOWN_26,
|
||||
SEG_TABLE_UNKNOWN_27 = SEGMENT_UNKNOWN_27,
|
||||
SEG_TABLE_UNKNOWN_28 = SEGMENT_UNKNOWN_28,
|
||||
SEG_TABLE_UNKNOWN_29 = SEGMENT_UNKNOWN_29,
|
||||
SEG_TABLE_UNKNOWN_30 = SEGMENT_UNKNOWN_30,
|
||||
SEG_TABLE_UNKNOWN_31 = SEGMENT_UNKNOWN_31,
|
||||
NUM_TABLE_SEGS,
|
||||
} TableSegments;
|
||||
|
||||
typedef enum HardcodedSegments {
|
||||
SEG_HARDCODED_MAIN,
|
||||
SEG_HARDCODED_ENGINE,
|
||||
SEG_HARDCODED_CRASH_SCREEN,
|
||||
SEG_HARDCODED_FRAMEBUFFERS,
|
||||
SEG_HARDCODED_ZBUFFER,
|
||||
SEG_HARDCODED_BUFFERS,
|
||||
SEG_HARDCODED_MAPDATA,
|
||||
SEG_HARDCODED_GODDARD,
|
||||
NUM_HARDCODED_SEGS,
|
||||
} HardcodedSegments;
|
||||
|
||||
typedef enum SegmentsList {
|
||||
SEG_TABLE_START,
|
||||
SEG_MAIN = (SEG_TABLE_START + SEG_TABLE_MAIN),
|
||||
SEG_RENDER = (SEG_TABLE_START + SEG_TABLE_RENDER),
|
||||
SEG_SEGMENT2 = (SEG_TABLE_START + SEG_TABLE_SEGMENT2),
|
||||
SEG_COMMON1_YAY0 = (SEG_TABLE_START + SEG_TABLE_COMMON1_YAY0),
|
||||
SEG_GROUP0_YAY0 = (SEG_TABLE_START + SEG_TABLE_GROUP0_YAY0),
|
||||
SEG_GROUPA_YAY0 = (SEG_TABLE_START + SEG_TABLE_GROUPA_YAY0),
|
||||
SEG_GROUPB_YAY0 = (SEG_TABLE_START + SEG_TABLE_GROUPB_YAY0),
|
||||
SEG_LEVEL_DATA = (SEG_TABLE_START + SEG_TABLE_LEVEL_DATA),
|
||||
SEG_COMMON0_YAY0 = (SEG_TABLE_START + SEG_TABLE_COMMON0_YAY0),
|
||||
SEG_TEXTURE = (SEG_TABLE_START + SEG_TABLE_TEXTURE),
|
||||
SEG_SKYBOX = (SEG_TABLE_START + SEG_TABLE_SKYBOX),
|
||||
SEG_EFFECT_YAY0 = (SEG_TABLE_START + SEG_TABLE_EFFECT_YAY0),
|
||||
SEG_GROUPA_GEO = (SEG_TABLE_START + SEG_TABLE_GROUPA_GEO),
|
||||
SEG_GROUPB_GEO = (SEG_TABLE_START + SEG_TABLE_GROUPB_GEO),
|
||||
SEG_LEVEL_SCRIPT = (SEG_TABLE_START + SEG_TABLE_LEVEL_SCRIPT),
|
||||
SEG_COMMON0_GEO = (SEG_TABLE_START + SEG_TABLE_COMMON0_GEO),
|
||||
SEG_LEVEL_ENTRY = (SEG_TABLE_START + SEG_TABLE_LEVEL_ENTRY),
|
||||
SEG_MARIO_ANIMS = (SEG_TABLE_START + SEG_TABLE_MARIO_ANIMS),
|
||||
SEG_UNKNOWN_18 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_18),
|
||||
SEG_BEHAVIOR_DATA = (SEG_TABLE_START + SEG_TABLE_BEHAVIOR_DATA),
|
||||
SEG_MENU_INTRO = (SEG_TABLE_START + SEG_TABLE_MENU_INTRO),
|
||||
SEG_GLOBAL_LEVEL_SCRIPT = (SEG_TABLE_START + SEG_TABLE_GLOBAL_LEVEL_SCRIPT),
|
||||
SEG_COMMON1_GEO = (SEG_TABLE_START + SEG_TABLE_COMMON1_GEO),
|
||||
SEG_GROUP0_GEO = (SEG_TABLE_START + SEG_TABLE_GROUP0_GEO),
|
||||
SEG_DEMO_INPUTS = (SEG_TABLE_START + SEG_TABLE_DEMO_INPUTS),
|
||||
SEG_EU_TRANSLATION = (SEG_TABLE_START + SEG_TABLE_EU_TRANSLATION),
|
||||
SEG_UNKNOWN_26 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_26),
|
||||
SEG_UNKNOWN_27 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_27),
|
||||
SEG_UNKNOWN_28 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_28),
|
||||
SEG_UNKNOWN_29 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_29),
|
||||
SEG_UNKNOWN_30 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_30),
|
||||
SEG_UNKNOWN_31 = (SEG_TABLE_START + SEG_TABLE_UNKNOWN_31),
|
||||
|
||||
SEG_HARDCODED_START,
|
||||
SEG_HMAIN = (SEG_HARDCODED_START + SEG_HARDCODED_MAIN),
|
||||
SEG_ENGINE = (SEG_HARDCODED_START + SEG_HARDCODED_ENGINE),
|
||||
SEG_CRASH_SCREEN = (SEG_HARDCODED_START + SEG_HARDCODED_CRASH_SCREEN),
|
||||
SEG_FRAMEBUFFERS = (SEG_HARDCODED_START + SEG_HARDCODED_FRAMEBUFFERS),
|
||||
SEG_ZBUFFER = (SEG_HARDCODED_START + SEG_HARDCODED_ZBUFFER),
|
||||
SEG_BUFFERS = (SEG_HARDCODED_START + SEG_HARDCODED_BUFFERS),
|
||||
SEG_MAPDATA = (SEG_HARDCODED_START + SEG_HARDCODED_MAPDATA),
|
||||
SEG_GODDARD = (SEG_HARDCODED_START + SEG_HARDCODED_GODDARD),
|
||||
|
||||
NUM_SEGS,
|
||||
} SegmentsList;
|
||||
|
||||
|
||||
#define IS_HARDCODED_FIRST() (SEG_HARDCODED_START < SEG_TABLE_START)
|
||||
#define SEGMENT_LIST_TO_HARDCODED(segment) (HardcodedSegments)(!IS_HARDCODED_FIRST() ? ((segment) - SEG_HARDCODED_START) : (segment))
|
||||
#define SEGMENT_LIST_TO_TABLE(segment) (TableSegments )( IS_HARDCODED_FIRST() ? ((segment) - SEG_TABLE_START ) : (segment))
|
||||
|
||||
_Bool is_segment_hardcoded(SegmentsList segment);
|
||||
_Bool is_segment_loaded(SegmentsList segment);
|
||||
|
||||
const char* get_segment_name(TableSegments segment);
|
||||
const char* cs_get_segment_name(SegmentsList segment);
|
||||
const char* get_segment_sub_name(TableSegments segment);
|
||||
const char* cs_get_segment_sub_name(SegmentsList segment);
|
||||
|
||||
Address cs_get_segment_vAddr(SegmentsList segment);
|
||||
Address cs_get_segment_pAddr(SegmentsList segment);
|
||||
size_t cs_get_segment_size(SegmentsList segment);
|
||||
@@ -15,7 +15,7 @@ ALIGNED8 static const AddressPair sTextRegions[] = {
|
||||
TEXT_REGION_SEGMENT(boot)
|
||||
TEXT_REGION_SEGMENT(main)
|
||||
TEXT_REGION_SEGMENT(engine)
|
||||
TEXT_REGION_SEGMENT(crashscreen)
|
||||
TEXT_REGION_SEGMENT(crashScreen)
|
||||
TEXT_REGION_SEGMENT(behavior)
|
||||
TEXT_REGION_SEGMENT(goddard)
|
||||
#ifdef KEEP_MARIO_HEAD
|
||||
|
||||
220
src/crash_screen/util/segment_data.inc.c
Normal file
220
src/crash_screen/util/segment_data.inc.c
Normal file
@@ -0,0 +1,220 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "segments.h"
|
||||
#include "crash_screen/cs_descriptions.h"
|
||||
#include "buffers/buffers.h"
|
||||
|
||||
|
||||
#define DEF_ROM_SEG_IMPL(_name, _str) { .id = (uintptr_t)_##_name##SegmentRomStart, .name = EXPAND_AND_STRINGIFY(_str), }
|
||||
#define DEF_ROM_SEG(_name) DEF_ROM_SEG_IMPL(_name, _name)
|
||||
#define DEF_ROM_SEG_YAY0(_name) DEF_ROM_SEG_IMPL(_name##_yay0, _name)
|
||||
#define DEF_ROM_SEG_GEO(_name) DEF_ROM_SEG_IMPL(_name##_geo, _name)
|
||||
#define DEF_ROM_SEG_SKY_YAY0(_name) DEF_ROM_SEG_IMPL(_name##_skybox_yay0, _name)
|
||||
#define DEF_ROM_SEG_SEG7(_name) DEF_ROM_SEG_IMPL(_name##_segment_7, _name)
|
||||
#define DEF_ROM_SEG_LANG_YAY0(_name) DEF_ROM_SEG_IMPL(translation_##_name##_yay0, _name)
|
||||
#define DEF_ROM_SEG_GLOBAL_VAR(_name) { .id = (uintptr_t)_name, .name = EXPAND_AND_STRINGIFY(_name), }
|
||||
|
||||
// 00: SEGMENT_MAIN
|
||||
static const IdNamePair sROMSegNames_00_main[] = {
|
||||
DEF_ROM_SEG(main),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 01: SEGMENT_RENDER
|
||||
static const IdNamePair sROMSegNames_01_render[] = {
|
||||
{ .id = OS_K0_TO_PHYSICAL(gGfxPools[0].buffer), .name = "gGfxPools[0]", },
|
||||
{ .id = OS_K0_TO_PHYSICAL(gGfxPools[1].buffer), .name = "gGfxPools[1]", },
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 02: SEGMENT_SEGMENT2
|
||||
static const IdNamePair sROMSegNames_02_segment2[] = {
|
||||
DEF_ROM_SEG_YAY0(segment2),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 03: SEGMENT_COMMON1_YAY0
|
||||
static const IdNamePair sROMSegNames_03_common1_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(common1),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 04: SEGMENT_GROUP0_YAY0
|
||||
static const IdNamePair sROMSegNames_04_group0_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(group0),
|
||||
DEF_ROM_SEG(boot),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 05: SEGMENT_GROUPA_YAY0
|
||||
static const IdNamePair sROMSegNames_05_groupA_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(group1),
|
||||
DEF_ROM_SEG_YAY0(group2),
|
||||
DEF_ROM_SEG_YAY0(group3),
|
||||
DEF_ROM_SEG_YAY0(group4),
|
||||
DEF_ROM_SEG_YAY0(group5),
|
||||
DEF_ROM_SEG_YAY0(group6),
|
||||
DEF_ROM_SEG_YAY0(group7),
|
||||
DEF_ROM_SEG_YAY0(group8),
|
||||
DEF_ROM_SEG_YAY0(group9),
|
||||
DEF_ROM_SEG_YAY0(group10),
|
||||
DEF_ROM_SEG_YAY0(group11),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 06: SEGMENT_GROUPB_YAY0
|
||||
static const IdNamePair sROMSegNames_06_groupB_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(group12),
|
||||
DEF_ROM_SEG_YAY0(group13),
|
||||
DEF_ROM_SEG_YAY0(group14),
|
||||
DEF_ROM_SEG_YAY0(group15),
|
||||
DEF_ROM_SEG_YAY0(group16),
|
||||
DEF_ROM_SEG_YAY0(group17),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 07: SEGMENT_LEVEL_DATA
|
||||
static const IdNamePair sROMSegNames_07_level_data[] = {
|
||||
#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
|
||||
#define DEFINE_LEVEL(textname, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) DEF_ROM_SEG_SEG7(folder),
|
||||
#include "levels/level_defines.h"
|
||||
#undef STUB_LEVEL
|
||||
#undef DEFINE_LEVEL
|
||||
DEF_ROM_SEG_YAY0(debug_level_select),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 08: SEGMENT_COMMON0_YAY0
|
||||
static const IdNamePair sROMSegNames_08_common0_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(common0),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 09: SEGMENT_TEXTURE
|
||||
static const IdNamePair sROMSegNames_09_texture[] = {
|
||||
DEF_ROM_SEG_YAY0(fire),
|
||||
DEF_ROM_SEG_YAY0(spooky),
|
||||
DEF_ROM_SEG_YAY0(generic),
|
||||
DEF_ROM_SEG_YAY0(water),
|
||||
DEF_ROM_SEG_YAY0(sky),
|
||||
DEF_ROM_SEG_YAY0(snow),
|
||||
DEF_ROM_SEG_YAY0(cave),
|
||||
DEF_ROM_SEG_YAY0(machine),
|
||||
DEF_ROM_SEG_YAY0(mountain),
|
||||
DEF_ROM_SEG_YAY0(grass),
|
||||
DEF_ROM_SEG_YAY0(outside),
|
||||
DEF_ROM_SEG_YAY0(inside),
|
||||
DEF_ROM_SEG_YAY0(effect),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 10: SEGMENT_SKYBOX
|
||||
static const IdNamePair sROMSegNames_10_skybox[] = {
|
||||
DEF_ROM_SEG_SKY_YAY0(water),
|
||||
DEF_ROM_SEG_SKY_YAY0(ccm),
|
||||
DEF_ROM_SEG_SKY_YAY0(clouds),
|
||||
DEF_ROM_SEG_SKY_YAY0(bitfs),
|
||||
DEF_ROM_SEG_SKY_YAY0(wdw),
|
||||
DEF_ROM_SEG_SKY_YAY0(cloud_floor),
|
||||
DEF_ROM_SEG_SKY_YAY0(ssl),
|
||||
DEF_ROM_SEG_SKY_YAY0(bbh),
|
||||
DEF_ROM_SEG_SKY_YAY0(bidw),
|
||||
DEF_ROM_SEG_SKY_YAY0(bits),
|
||||
DEF_ROM_SEG_YAY0(title_screen_bg), // For some reason the game uses the skybox segment for this.
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 11: SEGMENT_COMMON0_YAY0
|
||||
static const IdNamePair sROMSegNames_11_effect_gfx[] = {
|
||||
DEF_ROM_SEG_YAY0(effect),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 12: SEGMENT_GROUPA_GEO
|
||||
static const IdNamePair sROMSegNames_12_groupA_geo[] = {
|
||||
DEF_ROM_SEG_GEO(group1),
|
||||
DEF_ROM_SEG_GEO(group2),
|
||||
DEF_ROM_SEG_GEO(group3),
|
||||
DEF_ROM_SEG_GEO(group4),
|
||||
DEF_ROM_SEG_GEO(group5),
|
||||
DEF_ROM_SEG_GEO(group6),
|
||||
DEF_ROM_SEG_GEO(group7),
|
||||
DEF_ROM_SEG_GEO(group8),
|
||||
DEF_ROM_SEG_GEO(group9),
|
||||
DEF_ROM_SEG_GEO(group10),
|
||||
DEF_ROM_SEG_GEO(group11),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 13: SEGMENT_GROUPB_GEO
|
||||
static const IdNamePair sROMSegNames_13_groupB_geo[] = {
|
||||
DEF_ROM_SEG_GEO(group12),
|
||||
DEF_ROM_SEG_GEO(group13),
|
||||
DEF_ROM_SEG_GEO(group14),
|
||||
DEF_ROM_SEG_GEO(group15),
|
||||
DEF_ROM_SEG_GEO(group16),
|
||||
DEF_ROM_SEG_GEO(group17),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 14: SEGMENT_LEVEL_SCRIPT
|
||||
static const IdNamePair sROMSegNames_14_level_script[] = {
|
||||
#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
|
||||
#define DEFINE_LEVEL(textname, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) DEF_ROM_SEG(folder),
|
||||
#include "levels/level_defines.h"
|
||||
#undef STUB_LEVEL
|
||||
#undef DEFINE_LEVEL
|
||||
DEF_ROM_SEG(ending),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 15: SEGMENT_COMMON0_GEO
|
||||
static const IdNamePair sROMSegNames_15_common0_geo[] = {
|
||||
DEF_ROM_SEG_GEO(common0),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 16: SEGMENT_LEVEL_ENTRY
|
||||
static const IdNamePair sROMSegNames_16_entry[] = {
|
||||
DEF_ROM_SEG(entry),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 17: SEGMENT_MARIO_ANIMS
|
||||
static const IdNamePair sROMSegNames_17_mario_anims[] = {
|
||||
DEF_ROM_SEG_GLOBAL_VAR(gMarioAnims),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 18: SEGMENT_UNKNOWN_18
|
||||
// 19: SEGMENT_BEHAVIOR_DATA
|
||||
static const IdNamePair sROMSegNames_19_behavior[] = {
|
||||
DEF_ROM_SEG(behavior),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 20: SEGMENT_MENU_INTRO
|
||||
static const IdNamePair sROMSegNames_20_menu_intro[] = {
|
||||
DEF_ROM_SEG(intro),
|
||||
DEF_ROM_SEG(menu),
|
||||
DEF_ROM_SEG(ending),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 21: SEGMENT_GLOBAL_LEVEL_SCRIPT
|
||||
static const IdNamePair sROMSegNames_21_global_level_script[] = {
|
||||
DEF_ROM_SEG(scripts),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 22: SEGMENT_COMMON1_GEO
|
||||
static const IdNamePair sROMSegNames_22_common1_geo[] = {
|
||||
DEF_ROM_SEG_GEO(common1),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 23: SEGMENT_GROUP0_GEO
|
||||
static const IdNamePair sROMSegNames_23_group0_geo[] = {
|
||||
DEF_ROM_SEG_GEO(group0),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 24: SEGMENT_DEMO_INPUTS
|
||||
static const IdNamePair sROMSegNames_24_demo_inputs[] = {
|
||||
DEF_ROM_SEG_GLOBAL_VAR(gDemoInputs),
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 25: SEGMENT_EU_TRANSLATION
|
||||
//! TODO: Update this when ASCII PR is merged:
|
||||
static const IdNamePair sROMSegNames_25_eu_translation[] = {
|
||||
#if MULTILANG
|
||||
DEF_ROM_SEG_IMPL(translation_en_yay0, english),
|
||||
DEF_ROM_SEG_IMPL(translation_fr_yay0, french),
|
||||
DEF_ROM_SEG_IMPL(translation_de_yay0, german),
|
||||
#endif // MULTILANG
|
||||
ID_LIST_END(),
|
||||
};
|
||||
// 26: SEGMENT_UNKNOWN_26
|
||||
// 27: SEGMENT_UNKNOWN_27
|
||||
// 28: SEGMENT_UNKNOWN_28
|
||||
// 29: SEGMENT_UNKNOWN_29
|
||||
// 30: SEGMENT_UNKNOWN_30
|
||||
// 31: SEGMENT_UNKNOWN_31
|
||||
Reference in New Issue
Block a user