Changed how symbols are resolved
Got rid of the m12-symbols.sym file that I was manually curating; moved it into m2-hack.asm instead, in the form of .definelabel directives. This allows existing ROM symbols to be resolved gracefully when the assembler exports everything, so that we can call existing ROM subroutines, etc. from our compiled code. Also added label definitions for hardcoded strings. Makes it easy to refer to such strings in our compiled code as well. Updated build scripts to reflect this.
This commit is contained in:
parent
94f725298b
commit
96b7850733
|
@ -15,8 +15,7 @@ armtest/
|
|||
working/*.asm
|
||||
working/*.bin
|
||||
armips.exe
|
||||
armips-symbols.sym
|
||||
m12.sym
|
||||
*.sym
|
||||
m2-compiled.asm
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
|
|
|
@ -599,6 +599,8 @@ namespace ScriptTool
|
|||
int i = 0;
|
||||
foreach (var str in hardcodedStrings)
|
||||
{
|
||||
offsetFile.WriteLine($".definelabel {name.Replace('-', '_')}_str{i},0x{referenceAddress | 0x8000000:X}");
|
||||
|
||||
foreach (int ptr in str.PointerLocations)
|
||||
{
|
||||
offsetFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}",
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Amalgamator
|
|||
const string ArmipsExec = "armips.exe";
|
||||
const string HackFile = "m2-hack.asm";
|
||||
const string ArmipsSymFile = "armips-symbols.sym";
|
||||
const string IncludesSymFile = "working\\includes-symbols.sym";
|
||||
const string LinkerScript = "linker.ld";
|
||||
const string LinkedObjectFile = "linked.o";
|
||||
|
||||
|
@ -80,6 +81,7 @@ namespace Amalgamator
|
|||
linkerScript.AppendLine($"SECTIONS {{ .text 0x{options.CompiledAddress:X} : {{ *(.text .data .rodata) }} }}");
|
||||
|
||||
foreach (var sym in EnumerateArmipsSymbols(options.GetRootFile(ArmipsSymFile))
|
||||
.Concat(EnumerateArmipsSymbols(options.GetRootFile(IncludesSymFile)))
|
||||
.Where(s => undefinedSymbols.Contains(s.Key)))
|
||||
{
|
||||
linkerScript.AppendLine($"{sym.Key} = 0x{sym.Value:X};");
|
||||
|
|
13
insert.bat
13
insert.bat
|
@ -3,6 +3,12 @@
|
|||
echo Copying fresh ROM...
|
||||
copy /Y m12fresh.gba m12.gba
|
||||
|
||||
:: Assemble includes
|
||||
echo Assembling includes...
|
||||
pushd working
|
||||
..\armips.exe m12-includes.asm -sym includes-symbols.sym
|
||||
popd
|
||||
|
||||
:: Compile all C and ASM code
|
||||
echo Compiling and assembling...
|
||||
pushd compiled
|
||||
|
@ -10,11 +16,6 @@ Amalgamator\Amalgamator\bin\Debug\Amalgamator.exe -r m12.gba -c 0x8100000 -d "..
|
|||
popd
|
||||
if errorlevel 1 (pause && goto :eof)
|
||||
|
||||
:: Assemble includes
|
||||
echo Assembling includes...
|
||||
pushd working
|
||||
..\armips.exe m12-includes.asm
|
||||
popd
|
||||
SymbolTableBuilder\SymbolTableBuilder\bin\Debug\symbols.exe m12.sym m12-symbols.sym armips-symbols.sym
|
||||
SymbolTableBuilder\SymbolTableBuilder\bin\Debug\symbols.exe m12.sym armips-symbols.sym working/includes-symbols.sym
|
||||
|
||||
echo Success!
|
|
@ -1,20 +0,0 @@
|
|||
03001F10 m2_ness_name
|
||||
03001F16 m2_paula_name
|
||||
03001F1C m2_jeff_name
|
||||
03001F22 m2_poo_name
|
||||
03001F28 m2_king_name
|
||||
03001F30 m2_food
|
||||
03001F3A m2_rockin
|
||||
03001F50 m2_player1
|
||||
08001720 m2_soundeffect
|
||||
080B8AE0 m2_psitargetwindow
|
||||
080BD7AC m2_swapwindowbuf
|
||||
080BE260 m2_strlookup
|
||||
080BE458 m2_initwindow
|
||||
080C0A5C m2_statuswindow_numbers
|
||||
080C1FBC m2_psiwindow
|
||||
080C87D0 m2_drawwindow
|
||||
080C9634 m2_printstr
|
||||
080C96F0 m2_printstr_hlight
|
||||
080C980C m2_printnextch
|
||||
080CA4BC m2_scrolltext
|
26
m2-hack.asm
26
m2-hack.asm
|
@ -644,6 +644,32 @@ m2_enemy_attributes:
|
|||
.incbin "m2-enemy-attributes.bin"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// Existing subroutines/data
|
||||
//==============================================================================
|
||||
|
||||
.definelabel m2_ness_name ,0x3001F10
|
||||
.definelabel m2_paula_name ,0x3001F16
|
||||
.definelabel m2_jeff_name ,0x3001F1C
|
||||
.definelabel m2_poo_name ,0x3001F22
|
||||
.definelabel m2_king_name ,0x3001F28
|
||||
.definelabel m2_food ,0x3001F30
|
||||
.definelabel m2_rockin ,0x3001F3A
|
||||
.definelabel m2_player1 ,0x3001F50
|
||||
.definelabel m2_soundeffect ,0x8001720
|
||||
.definelabel m2_psitargetwindow ,0x80B8AE0
|
||||
.definelabel m2_swapwindowbuf ,0x80BD7AC
|
||||
.definelabel m2_strlookup ,0x80BE260
|
||||
.definelabel m2_initwindow ,0x80BE458
|
||||
.definelabel m2_statuswindow_numbers,0x80C0A5C
|
||||
.definelabel m2_psiwindow ,0x80C1FBC
|
||||
.definelabel m2_drawwindow ,0x80C87D0
|
||||
.definelabel m2_printstr ,0x80C9634
|
||||
.definelabel m2_printstr_hlight ,0x80C96F0
|
||||
.definelabel m2_printnextch ,0x80C980C
|
||||
.definelabel m2_scrolltext ,0x80CA4BC
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// Code files
|
||||
//==============================================================================
|
||||
|
|
Loading…
Reference in New Issue