More shiftability fixes (#1203)

This commit is contained in:
Ethan Roseman 2024-09-13 03:22:01 +09:00 committed by GitHub
parent 888b27eec8
commit 41e7f56f0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 43 additions and 136 deletions

View File

@ -11,6 +11,6 @@ intervaltree
n64img
python-githooks
crunch64>=0.5.1
spimdisasm>=1.28.1
splat64>=0.27.0
spimdisasm>=1.30.0
splat64>=0.27.2
requests

View File

@ -8,7 +8,8 @@
#include "ld_addrs.h"
#ifdef SHIFT
#define PLAYER_ACTION_VRAM_DEF texture_memory_VRAM_END
extern Addr world_action_CLASS_VRAM;
#define PLAYER_ACTION_VRAM_DEF world_action_CLASS_VRAM
#else
#define PLAYER_ACTION_VRAM_DEF (void*) 0x802B6000
#endif

View File

@ -321,7 +321,7 @@ s32 load_effect(s32 effectIndex) {
// Map space for the effect
tlbMappablePages = &D_80197000;
osMapTLB(i, 0, effectEntry->dmaDest, (s32)((*tlbMappablePages)[i]) & 0xFFFFFF, -1, -1);
osMapTLB(i, OS_PM_4K, effectEntry->dmaDest, (s32)((*tlbMappablePages)[i]) & 0xFFFFFF, -1, -1);
// Copy the effect into the newly mapped space
dma_copy(effectEntry->dmaStart, effectEntry->dmaEnd, effectEntry->dmaDest);

View File

@ -5,12 +5,12 @@
typedef s32 TlbEntry[0x1000 / 4];
typedef TlbEntry TlbMappablePage[15];
BSS TlbMappablePage D_80197000;
BSS u8 D_801A6000[0x1000];
BSS u8 BattleEntityHeapBottom[0x3000];
BSS u8 AuHeapBase[AUDIO_HEAP_SIZE];
BSS u8 D_80200000[0x4000];
BSS u8 D_80204000[0x3000];
BSS u8 D_80207000[0x3000];
BSS u8 D_8020A000[0x6000];
BSS TlbMappablePage D_80197000 ALIGNED(0x1000);
BSS u8 D_801A6000[0x1000] ALIGNED(0x1000);
BSS u8 BattleEntityHeapBottom[0x3000] ALIGNED(0x1000);
BSS u8 AuHeapBase[AUDIO_HEAP_SIZE] ALIGNED(0x1000);
BSS u8 D_80200000[0x4000] ALIGNED(0x1000);
BSS u8 D_80204000[0x3000] ALIGNED(0x1000);
BSS u8 D_80207000[0x3000] ALIGNED(0x1000);
BSS u8 D_8020A000[0x6000] ALIGNED(0x1000);
BSS ShapeFile gMapShapeData;

View File

@ -632,8 +632,8 @@ void msg_play_speech_sound(MessagePrintState* printer, u8 character) {
extern s32 gItemIconRasterOffsets[];
extern s32 gItemIconPaletteOffsets[];
extern u8* MsgLetterRasterOffsets[];
extern u16* MsgLetterPaletteOffsets[];
extern IMG_PTR MsgLetterRasterOffsets[];
extern PAL_PTR MsgLetterPaletteOffsets[];
extern MsgVoice MsgVoices[];
#if VERSION_PAL

View File

@ -875,7 +875,7 @@ MessageCharset* MsgCharsets[] = {
NULL
};
u8* MsgLetterRasterOffsets[] = {
IMG_PTR MsgLetterRasterOffsets[] = {
charset_letter_content_1_OFFSET,
charset_letter_content_2_OFFSET,
charset_letter_content_3_OFFSET,
@ -890,7 +890,7 @@ u8* MsgLetterRasterOffsets[] = {
charset_letter_content_12_OFFSET,
};
u16* MsgLetterPaletteOffsets[] = {
PAL_PTR MsgLetterPaletteOffsets[] = {
charset_letter_content_1_pal_OFFSET,
charset_letter_content_2_pal_OFFSET,
charset_letter_content_3_pal_OFFSET,

View File

@ -99,20 +99,21 @@ s32 N(LetterBodyStringIDs)[] = {
MSG_Document_Letter_Mario12_Body,
};
u8* N(LetterDmaOffsets)[] = {
charset_postcard_OFFSET, (u8*) charset_postcard_pal_OFFSET,
charset_letter_content_1_OFFSET, (u8*) charset_letter_content_1_pal_OFFSET,
charset_letter_content_2_OFFSET, (u8*) charset_letter_content_2_pal_OFFSET,
charset_letter_content_3_OFFSET, (u8*) charset_letter_content_3_pal_OFFSET,
charset_letter_content_4_OFFSET, (u8*) charset_letter_content_4_pal_OFFSET,
charset_letter_content_5_OFFSET, (u8*) charset_letter_content_5_pal_OFFSET,
charset_letter_content_6_OFFSET, (u8*) charset_letter_content_6_pal_OFFSET,
charset_letter_content_7_OFFSET, (u8*) charset_letter_content_7_pal_OFFSET,
charset_letter_content_8_OFFSET, (u8*) charset_letter_content_8_pal_OFFSET,
charset_letter_content_9_OFFSET, (u8*) charset_letter_content_9_pal_OFFSET,
charset_letter_content_10_OFFSET, (u8*) charset_letter_content_10_pal_OFFSET,
charset_letter_content_11_OFFSET, (u8*) charset_letter_content_11_pal_OFFSET,
charset_letter_content_12_OFFSET, (u8*) charset_letter_content_12_pal_OFFSET,
// TODO mix of image / palette pointers
IMG_PTR N(LetterDmaOffsets)[] = {
charset_postcard_OFFSET, (IMG_PTR) charset_postcard_pal_OFFSET,
charset_letter_content_1_OFFSET, (IMG_PTR) charset_letter_content_1_pal_OFFSET,
charset_letter_content_2_OFFSET, (IMG_PTR) charset_letter_content_2_pal_OFFSET,
charset_letter_content_3_OFFSET, (IMG_PTR) charset_letter_content_3_pal_OFFSET,
charset_letter_content_4_OFFSET, (IMG_PTR) charset_letter_content_4_pal_OFFSET,
charset_letter_content_5_OFFSET, (IMG_PTR) charset_letter_content_5_pal_OFFSET,
charset_letter_content_6_OFFSET, (IMG_PTR) charset_letter_content_6_pal_OFFSET,
charset_letter_content_7_OFFSET, (IMG_PTR) charset_letter_content_7_pal_OFFSET,
charset_letter_content_8_OFFSET, (IMG_PTR) charset_letter_content_8_pal_OFFSET,
charset_letter_content_9_OFFSET, (IMG_PTR) charset_letter_content_9_pal_OFFSET,
charset_letter_content_10_OFFSET, (IMG_PTR) charset_letter_content_10_pal_OFFSET,
charset_letter_content_11_OFFSET, (IMG_PTR) charset_letter_content_11_pal_OFFSET,
charset_letter_content_12_OFFSET, (IMG_PTR) charset_letter_content_12_pal_OFFSET,
};
API_CALLABLE(N(InitLetters)){

View File

@ -93,15 +93,6 @@ def write_ninja_rules(
ld_args = f"-T ver/$version/build/undefined_syms.txt -T ver/$version/undefined_syms_auto.txt -T ver/$version/undefined_funcs_auto.txt -Map $mapfile --no-check-sections -T $in -o $out"
ld = f"{cross}ld" if not "PAPERMARIO_LD" in os.environ else os.environ["PAPERMARIO_LD"]
if shift:
# For the shiftable build, we link twice to resolve some addresses that gnu ld can't figure out all in one go.
ninja.rule(
"ld",
description="link($version) $out",
command=f"{ld} $$(tools/build/ld/multilink_calc.py $version hardcode) {ld_args} && \
{ld} $$(tools/build/ld/multilink_calc.py $version calc) {ld_args}",
)
else:
ninja.rule(
"ld",
description="link($version) $out",

View File

@ -1,90 +0,0 @@
#!/usr/bin/env python3
import os
from pathlib import Path
import sys
from typing import Dict, List
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
root_dir = script_dir / "../../.."
HARDCODED_ADDR = 0x80000000
if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <version> <mode>")
print("mode: hardcode, calc")
sys.exit(1)
version = sys.argv[1]
mode = sys.argv[2]
syms_to_max = {
"entity_data_vram_end": [
"entity_default_VRAM_END",
"entity_jan_iwa_VRAM_END",
"entity_sbk_omo_VRAM_END",
],
"world_action_vram_end": [
"world_action_idle_VRAM_END",
"world_action_walk_VRAM_END",
"world_action_jump_VRAM_END",
"world_action_step_up_VRAM_END",
"world_action_land_VRAM_END",
"world_action_hammer_VRAM_END",
"world_action_spin_VRAM_END",
"world_action_tornado_jump_VRAM_END",
"world_action_spin_jump_VRAM_END",
"world_action_slide_VRAM_END",
"world_action_hit_fire_VRAM_END",
"world_action_hit_lava_VRAM_END",
"world_action_knockback_VRAM_END",
"world_action_misc_VRAM_END",
"world_action_use_munchlesia_VRAM_END",
"world_action_use_spinning_flower_VRAM_END",
"world_action_use_tweester_VRAM_END",
"world_action_sneaky_parasol_VRAM_END",
],
}
addrs: Dict[str, List[int]] = {}
if mode == "hardcode":
out = ""
for sym in syms_to_max:
addrs[sym] = [HARDCODED_ADDR]
elif mode == "calc":
with open(root_dir / "ver" / version / "build/papermario.map") as f:
lines = f.readlines()
finished = False
syms_to_go = set(syms_to_max.keys())
for line in lines:
for sym in syms_to_max:
for max_sym in syms_to_max[sym]:
if f"{max_sym} = ." in line:
if sym not in addrs:
addrs[sym] = []
addrs[sym].append(int(line.strip().split()[0], 16))
syms_to_max[sym].remove(max_sym)
if len(syms_to_max[sym]) == 0:
syms_to_go.remove(sym)
if not syms_to_go:
finished = True
if finished:
break
if syms_to_go:
print(f"Error: {syms_to_max} not found in map file")
sys.exit(1)
out_addrs = {sym: max(addrs[sym]) for sym in addrs}
out_addrs["entity_data_vram_end"] = (
out_addrs["entity_data_vram_end"] + out_addrs["world_action_vram_end"] - HARDCODED_ADDR
)
out = ""
for sym in out_addrs:
out += f" --defsym {sym}=0x{out_addrs[sym]:X}"
print(out)

View File

@ -1,2 +1,3 @@
options:
ld_use_symbolic_vram_addresses: True
emit_subalign: False

View File

@ -1,2 +1,3 @@
options:
ld_use_symbolic_vram_addresses: True
emit_subalign: False

View File

@ -1,2 +1,3 @@
options:
ld_use_symbolic_vram_addresses: True
emit_subalign: False

View File

@ -1,2 +1,3 @@
options:
ld_use_symbolic_vram_addresses: True
emit_subalign: False

View File

@ -56,10 +56,10 @@ vram_classes:
# Totally linear past this point
- { name: texture_memory, vram: 0x8028E000, follows_classes: [battle_code, world_script_api] }
- { name: world_action, vram: 0x802B6000, follows_classes: [texture_memory] }
- { name: indicator_icon, vram: 0x802B7000, vram_symbol: world_action_vram_end } # follows_classes: [world_action] }
- { name: indicator_icon, vram: 0x802B7000, follows_classes: [world_action] }
- { name: model_clear_render_tasks, vram: 0x802B7E00, follows_classes: [indicator_icon] }
- { name: area_entities, vram: 0x802BAE00, vram_symbol: model_clear_render_tasks_VRAM_END }
- { name: world_partner, vram: 0x802BD100, vram_symbol: entity_data_vram_end } # follows_classes: [area_entities] }
- { name: world_partner, vram: 0x802BD100, follows_classes: [area_entities] }
- { name: world_use_item, vram: 0x802C0000, follows_classes: [world_partner] }
- { name: evt, vram: 0x802C3000, vram_symbol: world_use_item_VRAM_END }
- { name: engine4, vram: 0x802DBD40, vram_symbol: evt_VRAM_END }