diff --git a/.gitignore b/.gitignore index ceaab94..f444c08 100644 --- a/.gitignore +++ b/.gitignore @@ -7,19 +7,12 @@ *.bak Thumbs.db snapshots/ -xkas/ -new/ notes/ -resize/ -ignore/ -workingold/ -mother12/ -vwf_src/ -temp/ fresh/ working/*.asm working/*.bin -xkas-symbols.sym +armips.exe +armips-symbols.sym m12.sym ## Ignore Visual Studio temporary files, build results, and diff --git a/README.md b/README.md index b2bcbe9..c0d21af 100644 --- a/README.md +++ b/README.md @@ -26,4 +26,4 @@ Some screenshots: ![](./screenshots/itshappening2.png) ![](./screenshots/itshappening4.png) ![](./screenshots/itshappening5.png) ![](./screenshots/m2-status2.png) ### Dependencies -If you want to just use the graphical tool to help with the translation, you just need .NET 4.5.1. If you want to actually compile the hack code and test it out, you will need a copy of xkas. Unfortunately I have no idea where I got my copy (my version seems to be much newer than anything I can find on Google) and the program author hasn't uploaded any copies either. The game also crashes horribly 99% of the time in its current state, so there's no point in trying it. I might post the xkas binary once the hack is in a playable state. +If you want to just use the graphical tool to help with the translation, you just need .NET 4.5.1. If you want to actually compile the hack code and test it out, you will need [armips](https://github.com/Kingcom/armips). The game also crashes horribly 99% of the time in its current state, so there's no point in trying it. diff --git a/ScriptTool/ScriptTool/Program.cs b/ScriptTool/ScriptTool/Program.cs index 44b6594..6ef5758 100644 --- a/ScriptTool/ScriptTool/Program.cs +++ b/ScriptTool/ScriptTool/Program.cs @@ -71,7 +71,8 @@ namespace ScriptTool using (IncludeFile = File.CreateText(Path.Combine(options.WorkingDirectory, "m12-includes.asm"))) { - IncludeFile.WriteLine("arch gba.thumb"); + IncludeFile.WriteLine(".gba"); + IncludeFile.WriteLine(".open \"../m12.gba\",0x8000000"); // Compile main string tables if (options.DoMainText) @@ -84,6 +85,8 @@ namespace ScriptTool { CompileM12Misc(); } + + IncludeFile.WriteLine(".close"); } } } @@ -376,7 +379,7 @@ namespace ScriptTool using (var labelAsmFile = File.CreateText(Path.Combine(options.WorkingDirectory, "m12-main-strings.asm"))) { - labelAsmFile.WriteLine(String.Format("org ${0:X}; incbin m12-main-strings.bin", baseAddress | 0x8000000)); + labelAsmFile.WriteLine(String.Format(".org 0x{0:X} :: .incbin \"m12-main-strings.bin\"", baseAddress | 0x8000000)); labelAsmFile.WriteLine(); foreach (var file in labelFiles) @@ -386,13 +389,13 @@ namespace ScriptTool foreach (var stringRef in mainStringRefs) { - labelAsmFile.WriteLine(String.Format("org ${0:X}; dd ${1:X8}", + labelAsmFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}", stringRef.PointerLocation | 0x8000000, m12Compiler.AddressMap[stringRef.Label] | 0x8000000)); } } } - IncludeFile.WriteLine("incsrc m12-main-strings.asm"); + IncludeFile.WriteLine(".include \"m12-main-strings.asm\""); } static void CompileM12Misc() @@ -428,7 +431,7 @@ namespace ScriptTool IncludeFile.WriteLine("// Fix pointers to \"PSI \""); foreach (var address in updateAddresses) { - IncludeFile.WriteLine(String.Format("org ${0:X}; dd ${1:X8}", + IncludeFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}", address | 0x8000000, psiPointer | 0x8000000)); } @@ -452,14 +455,14 @@ namespace ScriptTool using (var offsetFile = File.CreateText(Path.Combine(options.WorkingDirectory, name + ".asm"))) { // Include the binfile - offsetFile.WriteLine(String.Format("org ${0:X}; incbin {1}.bin", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: .incbin \"{1}.bin\"", baseAddress | 0x8000000, name)); offsetFile.WriteLine(); // Compile all strings foreach (var str in stringCollection.StringRefs.OrderBy(s => s.Index)) { - offsetFile.WriteLine(String.Format("org ${0:X}; dd ${1:X8}", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}", str.OffsetLocation | 0x8000000, referenceAddress - stringCollection.StringsLocation)); m12Compiler.CompileString(str.New, buffer, ref referenceAddress, ebCharLookup); @@ -470,7 +473,7 @@ namespace ScriptTool File.WriteAllBytes(Path.Combine(options.WorkingDirectory, name + ".bin"), buffer.ToArray()); // Add to the include file - IncludeFile.WriteLine("incsrc " + name + ".asm"); + IncludeFile.WriteLine(".include \"" + name + ".asm\""); } static IList CompileM12FixedStringCollection(string name, ref int referenceAddress) @@ -487,14 +490,14 @@ namespace ScriptTool using (var offsetFile = File.CreateText(Path.Combine(options.WorkingDirectory, name + ".asm"))) { // Include the binfile - offsetFile.WriteLine(String.Format("org ${0:X}; incbin {1}.bin", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: .incbin \"{1}.bin\"", baseAddress | 0x8000000, name)); offsetFile.WriteLine(); // Update table pointers foreach (int tablePointer in stringCollection.TablePointers) { - offsetFile.WriteLine(String.Format("org ${0:X}; dd ${1:X8}", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}", tablePointer | 0x8000000, baseAddress | 0x8000000)); } @@ -510,7 +513,7 @@ namespace ScriptTool File.WriteAllBytes(Path.Combine(options.WorkingDirectory, name + ".bin"), buffer.ToArray()); // Add to the include file - IncludeFile.WriteLine("incsrc " + name + ".asm"); + IncludeFile.WriteLine(".include \"" + name + ".asm\""); return newPointers; } @@ -530,7 +533,7 @@ namespace ScriptTool using (var offsetFile = File.CreateText(Path.Combine(options.WorkingDirectory, name + ".asm"))) { // Include the binfile - offsetFile.WriteLine(String.Format("org ${0:X}; incbin {1}.bin", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: .incbin \"{1}.bin\"", baseAddress | 0x8000000, name)); offsetFile.WriteLine(); @@ -540,7 +543,7 @@ namespace ScriptTool { foreach (int ptr in str.PointerLocations) { - offsetFile.WriteLine(String.Format("org ${0:X}; dd ${1:X8}", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}", ptr | 0x8000000, referenceAddress | 0x8000000)); } @@ -553,7 +556,7 @@ namespace ScriptTool File.WriteAllBytes(Path.Combine(options.WorkingDirectory, name + ".bin"), buffer.ToArray()); // Add to the include file - IncludeFile.WriteLine("incsrc " + name + ".asm"); + IncludeFile.WriteLine(".include \"" + name + ".asm\""); return stringAddresses; } @@ -571,7 +574,7 @@ namespace ScriptTool using (var offsetFile = File.CreateText(Path.Combine(options.WorkingDirectory, name + ".asm"))) { // Include the binfile - offsetFile.WriteLine(String.Format("org ${0:X}; incbin {1}.bin", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: .incbin \"{1}.bin\"", baseAddress | 0x8000000, name)); offsetFile.WriteLine(); @@ -583,7 +586,7 @@ namespace ScriptTool foreach (int ptr in str.PointerLocations) { - offsetFile.WriteLine(String.Format("org ${0:X}; dd ${1:X8}", + offsetFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}", ptr | 0x8000000, referenceAddress | 0x8000000)); } @@ -598,7 +601,7 @@ namespace ScriptTool File.WriteAllBytes(Path.Combine(options.WorkingDirectory, name + ".bin"), buffer.ToArray()); // Add to the include file - IncludeFile.WriteLine("incsrc " + name + ".asm"); + IncludeFile.WriteLine(".include \"" + name + ".asm\""); } } } diff --git a/insert.bat b/insert.bat index 030f4c7..a0c11e8 100644 --- a/insert.bat +++ b/insert.bat @@ -1,8 +1,7 @@ copy /Y m12fresh.gba m12.gba -xkas\xkas.exe m12.gba m2-hack.asm xkas-symbols.sym +armips.exe m2-hack.asm -sym armips-symbols.sym pushd working -..\xkas\xkas.exe ..\m12.gba m12-includes.asm +..\armips.exe m12-includes.asm popd -resize m12.gba 16777216 -SymbolTableBuilder\SymbolTableBuilder\bin\Debug\symbols.exe m12.sym m12-symbols.sym xkas-symbols.sym +SymbolTableBuilder\SymbolTableBuilder\bin\Debug\symbols.exe m12.sym m12-symbols.sym armips-symbols.sym pause diff --git a/m2-customcodes.asm b/m2-customcodes.asm index 8914b2d..835d43f 100644 --- a/m2-customcodes.asm +++ b/m2-customcodes.asm @@ -1,5 +1,3 @@ -m2_customcodes: - //============================================================================== // void parse(int code, char* parserAddress, WINDOW* window) // In: @@ -10,84 +8,81 @@ m2_customcodes: // r0: control code length (0 if not matched) //============================================================================== -.parse: +customcodes_parse: push {r1-r5,lr} -mov r3,#0 +mov r3,0 mov r4,r0 //-------------------------------- // 60 FF XX: Add XX pixels to the renderer -cmp r4,#0x60 -bne + -mov r3,#3 +cmp r4,0x60 +bne @@next +mov r3,3 // Get the current X offset -ldrh r4,[r2,#2] +ldrh r4,[r2,2] // Get the current X tile -ldrh r5,[r2,#0x2A] +ldrh r5,[r2,0x2A] -lsl r5,r5,#3 +lsl r5,r5,3 add r4,r4,r5 // Current X location (in pixels) // Get the value to add -ldrb r5,[r1,#2] // Control code parameter +ldrb r5,[r1,2] // Control code parameter add r4,r4,r5 // New X location // Store the pixel offset of the new location -.store_x: -lsl r5,r4,#29 -lsr r5,r5,#29 -strh r5,[r2,#2] +@@store_x: +lsl r5,r4,29 +lsr r5,r5,29 +strh r5,[r2,2] // Store the X tile of the new location -lsr r4,r4,#3 -strh r4,[r2,#0x2A] -b .parse_end +lsr r4,r4,3 +strh r4,[r2,0x2A] +b @@end -+ +@@next: //-------------------------------- // 5F FF XX: Set the X value of the renderer -cmp r4,#0x5F -bne + -mov r3,#3 +cmp r4,0x5F +bne @@next2 +mov r3,3 // Get the new X value -ldrb r4,[r1,#2] -b .store_x +ldrb r4,[r1,2] +b @@store_x -+ +@@next2: //-------------------------------- // 5E FF XX: Load value into memory -cmp r4,#0x5E -bne + -mov r3,#3 +cmp r4,0x5E +bne @@end +mov r3,3 // Get the argument -ldrb r4,[r1,#2] -cmp r4,#1 -bne .parse_5e_next01 +ldrb r4,[r1,2] +cmp r4,1 +bne @@end // 01: load enemy plurality -ldr r1,=#0x2025038 -ldrb r1,[r1,#0] // number of enemies at start of battle -cmp r1,#4 -blt .parse_5e_01_small -mov r1,#3 -.parse_5e_01_small: +ldr r1,=0x2025038 +ldrb r1,[r1,0] // number of enemies at start of battle +cmp r1,4 +blt @@small +mov r1,3 +@@small: mov r0,r1 // the jump table is 1-indexed mov r4,r3 -bl $80A334C // store to window memory +bl 0x80A334C // store to window memory mov r3,r4 -.parse_5e_next01: - -+ - //-------------------------------- -.parse_end: +@@end: mov r0,r3 pop {r1-r5,pc} +.pool diff --git a/m2-formatting.asm b/m2-formatting.asm index ae14be9..9c7461c 100644 --- a/m2-formatting.asm +++ b/m2-formatting.asm @@ -1,6 +1,3 @@ -m2_formatting: - - //============================================================================== // http://en.wikipedia.org/wiki/Double_dabble // int bin_to_bcd(int binary) @@ -11,112 +8,112 @@ m2_formatting: // r1: amount of digits used //============================================================================== -.bin_to_bcd: +bin_to_bcd: push {r2-r7,lr} mov r2,r8 mov r3,r9 push {r2-r3} -lsl r0,r0,#5 -mov r1,#0 -mov r3,#27 -mov r4,#3 -lsl r4,r4,#8 -lsl r5,r4,#4 -lsl r6,r5,#4 -lsl r7,r6,#12 +lsl r0,r0,5 +mov r1,0 +mov r3,27 +mov r4,3 +lsl r4,r4,8 +lsl r5,r4,4 +lsl r6,r5,4 +lsl r7,r6,12 mov r9,r7 -lsl r7,r6,#8 +lsl r7,r6,8 mov r8,r7 -lsl r7,r6,#4 +lsl r7,r6,4 //-------------------------------- -- +@@prev: // Ones -lsl r2,r1,#28 -lsr r2,r2,#28 -cmp r2,#5 -bcc + -add r1,r1,#3 -+ +lsl r2,r1,28 +lsr r2,r2,28 +cmp r2,5 +bcc @@next +add r1,r1,3 +@@next: // Tens -lsl r2,r1,#24 -lsr r2,r2,#28 -cmp r2,#5 -bcc + -add r1,#0x30 -+ +lsl r2,r1,24 +lsr r2,r2,28 +cmp r2,5 +bcc @@next2 +add r1,0x30 +@@next2: // Hundreds -lsl r2,r1,#20 -lsr r2,r2,#28 -cmp r2,#5 -bcc + +lsl r2,r1,20 +lsr r2,r2,28 +cmp r2,5 +bcc @@next3 add r1,r1,r4 -+ +@@next3: // Thousands -lsl r2,r1,#16 -lsr r2,r2,#28 -cmp r2,#5 -bcc + +lsl r2,r1,16 +lsr r2,r2,28 +cmp r2,5 +bcc @@next4 add r1,r1,r5 -+ +@@next4: // Ten-thousands -lsl r2,r1,#12 -lsr r2,r2,#28 -cmp r2,#5 -bcc + +lsl r2,r1,12 +lsr r2,r2,28 +cmp r2,5 +bcc @@next5 add r1,r1,r6 -+ +@@next5: // Hundred-thousands -lsl r2,r1,#8 -lsr r2,r2,#28 -cmp r2,#5 -bcc + +lsl r2,r1,8 +lsr r2,r2,28 +cmp r2,5 +bcc @@next6 add r1,r1,r7 -+ +@@next6: // Millions -lsl r2,r1,#4 -lsr r2,r2,#28 -cmp r2,#5 -bcc + +lsl r2,r1,4 +lsr r2,r2,28 +cmp r2,5 +bcc @@next7 add r1,r8 -+ +@@next7: // Ten-millions -lsr r2,r2,#28 -cmp r2,#5 -bcc + +lsr r2,r2,28 +cmp r2,5 +bcc @@next8 add r1,r9 -+ +@@next8: // Shift -lsl r1,r1,#1 +lsl r1,r1,1 tst r0,r0 -bpl + -add r1,r1,#1 -+ -lsl r0,r0,#1 -sub r3,r3,#1 -bne - +bpl @@next9 +add r1,r1,1 +@@next9: +lsl r0,r0,1 +sub r3,r3,1 +bne @@prev mov r0,r1 //-------------------------------- // Check how many digits are used -mov r3,#1 -- -lsr r1,r1,#4 -beq + -add r3,r3,#1 -b - -+ +mov r3,1 +@@prev2: +lsr r1,r1,4 +beq @@next10 +add r3,r3,1 +b @@prev2 +@@next10: //-------------------------------- mov r1,r3 @@ -134,65 +131,65 @@ pop {r2-r7,pc} // r0: binary number //============================================================================== -.bcd_to_bin: +bcd_to_bin: push {r1-r4,lr} -mov r1,#0 -mov r2,#10 -mov r3,#1 +mov r1,0 +mov r2,10 +mov r3,1 //-------------------------------- // Ones -lsl r4,r0,#28 -lsr r4,r4,#28 +lsl r4,r0,28 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Tens -lsl r4,r0,#24 -lsr r4,r4,#28 +lsl r4,r0,24 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Hundreds -lsl r4,r0,#20 -lsr r4,r4,#28 +lsl r4,r0,20 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Thousands -lsl r4,r0,#16 -lsr r4,r4,#28 +lsl r4,r0,16 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Ten-thousands -lsl r4,r0,#12 -lsr r4,r4,#28 +lsl r4,r0,12 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Hundred-thousands -lsl r4,r0,#8 -lsr r4,r4,#28 +lsl r4,r0,8 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Millions -lsl r4,r0,#4 -lsr r4,r4,#28 +lsl r4,r0,4 +lsr r4,r4,28 mul r4,r3 add r1,r1,r4 mul r3,r2 // Ten-millions -lsr r4,r0,#28 +lsr r4,r0,28 mul r4,r3 add r1,r1,r4 @@ -211,7 +208,7 @@ pop {r1-r4,pc} // r0: = digits - (digits rendered) - 1 //============================================================================== -.format_cash: +format_cash: push {r1-r7,lr} mov r4,r1 @@ -219,57 +216,57 @@ mov r6,r2 //-------------------------------- // Figure out how many digits we need -bl .bin_to_bcd +bl bin_to_bcd mov r5,r1 mov r7,r1 // The window is 56 pixels wide: -// each digit uses 6 pixels, the $ sign uses 6, and the +// each digit uses 6 pixels, the 0x sign uses 6, and the // double-zero uses 8 -mov r2,#42 // = 56 - 6 - 8 -lsl r3,r1,#2 +mov r2,42 // = 56 - 6 - 8 +lsl r3,r1,2 add r3,r3,r1 add r1,r1,r3 // r1 *= 6 sub r1,r2,r1 // r1 = 42 - r1 // Store the control code to the output -mov r2,#0x5F -strb r2,[r4,#0] -mov r2,#0xFF -strb r2,[r4,#1] -strb r1,[r4,#2] +mov r2,0x5F +strb r2,[r4,0] +mov r2,0xFF +strb r2,[r4,1] +strb r1,[r4,2] // Store the dollar sign -mov r2,#0x54 -strb r2,[r4,#3] -add r4,r4,#4 +mov r2,0x54 +strb r2,[r4,3] +add r4,r4,4 // Store the digits to the output -mov r2,#8 +mov r2,8 sub r2,r2,r5 -lsl r2,r2,#2 +lsl r2,r2,2 lsl r0,r2 // Now the number is pushed to the left of the register -- -lsr r1,r0,#28 // Get the left-most digit -add r1,#0x60 // Integer-to-char -strb r1,[r4,#0] -add r4,r4,#1 -lsl r0,r0,#4 -sub r5,r5,#1 -bne - +@@prev: +lsr r1,r0,28 // Get the left-most digit +add r1,0x60 // Integer-to-char +strb r1,[r4,0] +add r4,r4,1 +lsl r0,r0,4 +sub r5,r5,1 +bne @@prev // Store the double-zero sign -mov r1,#0x56 -strb r1,[r4,#0] +mov r1,0x56 +strb r1,[r4,0] // Store the end code -mov r1,#0 -strb r1,[r4,#1] -mov r1,#0xFF -strb r1,[r4,#2] +mov r1,0 +strb r1,[r4,1] +mov r1,0xFF +strb r1,[r4,2] //-------------------------------- sub r5,r6,r7 -sub r0,r5,#1 +sub r0,r5,1 pop {r1-r7,pc} diff --git a/m2-hack.asm b/m2-hack.asm index 4f69356..775ab9b 100644 --- a/m2-hack.asm +++ b/m2-hack.asm @@ -1,28 +1,29 @@ -arch gba.thumb +.gba +.open "m12.gba",0x8000000 //============================================================================== // Relocation hacks //============================================================================== // Move the weird box font from 0xFCE6C -org $80B3274; dd m2_font_relocate +.org 0x80B3274 :: dw m2_font_relocate //============================================================================== // Font hacks //============================================================================== -org $8AFED84; incbin m2-mainfont1-empty.bin -org $8B0F424; incbin m2-mainfont2-empty.bin -org $8B13424; incbin m2-mainfont3-empty.bin -org $8B088A4; incbin m2-shifted-cursor.bin +.org 0x8AFED84 :: .incbin "m2-mainfont1-empty.bin" +.org 0x8B0F424 :: .incbin "m2-mainfont2-empty.bin" +.org 0x8B13424 :: .incbin "m2-mainfont3-empty.bin" +.org 0x8B088A4 :: .incbin "m2-shifted-cursor.bin" // Greek letters -org $8B1B907; db $8B // alpha -org $8B1B90A; db $8C // beta -org $8B1B90D; db $8D // gamma -org $8B1B910; db $8E // sigma -org $8B1B913; db $8F // omega +.org 0x8B1B907 :: db 0x8B // alpha +.org 0x8B1B90A :: db 0x8C // beta +.org 0x8B1B90D :: db 0x8D // gamma +.org 0x8B1B910 :: db 0x8E // sigma +.org 0x8B1B913 :: db 0x8F // omega //============================================================================== @@ -30,227 +31,227 @@ org $8B1B913; db $8F // omega //============================================================================== // 32- to 16-bit access change for window flags -org $80BE16A; strh r2,[r4,#0] -org $80BE1FA; strh r2,[r6,#0] -org $80BE222; strh r6,[r1,#0] +.org 0x80BE16A :: strh r2,[r4,0] +.org 0x80BE1FA :: strh r2,[r6,0] +.org 0x80BE222 :: strh r6,[r1,0] // PSI class window size -org $80B7820 -mov r1,#4 -mov r2,#1 -mov r3,#6 +.org 0x80B7820 +mov r1,4 +mov r2,1 +mov r3,6 //--------------------------------------------------------- // C0A5C hacks (status window) //--------------------------------------------------------- -incsrc m2-status-initial.asm -incsrc m2-status-switch.asm +.include "m2-status-initial.asm" +.include "m2-status-switch.asm" //--------------------------------------------------------- // BAC18 hacks (status window switching) //--------------------------------------------------------- -org $80BACFC; bl m2_vwf_entries.bac18_redraw_status -org $80BADE6; bl m2_vwf_entries.bac18_redraw_status -org $80BACEE; bl m2_vwf_entries.bac18_clear_psi -org $80BADC8 -bl m2_vwf_entries.bac18_check_button -b $80BADD8 +.org 0x80BACFC :: bl bac18_redraw_status +.org 0x80BADE6 :: bl bac18_redraw_status +.org 0x80BACEE :: bl bac18_clear_psi +.org 0x80BADC8 +bl bac18_check_button +b 0x80BADD8 //--------------------------------------------------------- // BAEF8 hacks (equip window) //--------------------------------------------------------- // Erase offense change -define erase_offense "mov r0,#0xC; mov r1,#0xB; mov r2,#4; bl m2_vwf.print_blankstr" -org $80BB216; {erase_offense} -org $80BB38C; {erase_offense} -org $80BB4C6; {erase_offense} -org $80BB5FC; {erase_offense} -org $80BBAAE; {erase_offense} -org $80BBBF6; {erase_offense} -org $80BBD54; {erase_offense} +erase_offense equ mov r0,0xC :: mov r1,0xB :: mov r2,4 :: bl print_blankstr +.org 0x80BB216 :: erase_offense +.org 0x80BB38C :: erase_offense +.org 0x80BB4C6 :: erase_offense +.org 0x80BB5FC :: erase_offense +.org 0x80BBAAE :: erase_offense +.org 0x80BBBF6 :: erase_offense +.org 0x80BBD54 :: erase_offense // Erase defense change -define erase_defense "mov r0,#0xC; mov r1,#0xD; mov r2,#4; bl m2_vwf.print_blankstr" -org $80BB226; {erase_defense} -org $80BBABE; {erase_defense} -org $80BBC06; {erase_defense} -org $80BBD64; {erase_defense} +erase_defense equ mov r0,0xC :: mov r1,0xD :: mov r2,4 :: bl print_blankstr +.org 0x80BB226 :: erase_defense +.org 0x80BBABE :: erase_defense +.org 0x80BBC06 :: erase_defense +.org 0x80BBD64 :: erase_defense // Erase offense/defense after changing equipment -org $80BB3E2; bl m2_vwf_entries.baef8_reequip_erase -org $80BB518; bl m2_vwf_entries.baef8_reequip_erase -org $80BBB12; bl m2_vwf_entries.baef8_reequip_erase -org $80BBC70; bl m2_vwf_entries.baef8_reequip_erase +.org 0x80BB3E2 :: bl baef8_reequip_erase +.org 0x80BB518 :: bl baef8_reequip_erase +.org 0x80BBB12 :: bl baef8_reequip_erase +.org 0x80BBC70 :: bl baef8_reequip_erase //--------------------------------------------------------- // C5500 hacks (equip window switching) //--------------------------------------------------------- // Clear offense/defense changes when moving cursor -org $80C5AA2; bl m2_vwf_entries.c5500_clear_up -org $80C5B12; bl m2_vwf_entries.c5500_clear_down +.org 0x80C5AA2 :: bl c5500_clear_up +.org 0x80C5B12 :: bl c5500_clear_down // Don't draw equip icon -org $80C5A1A; nop -org $80C5A28; nop +.org 0x80C5A1A :: nop +.org 0x80C5A28 :: nop //--------------------------------------------------------- // C1FBC hacks (PSI window) //--------------------------------------------------------- -org $80C203E; mov r1,#0x14 // new PSI name entry length -org $80C21B4; mov r1,#0x14 -org $80C224A; mov r1,#0x14 -org $80C229E; mov r1,#0x14 +.org 0x80C203E :: mov r1,0x14 // new PSI name entry length +.org 0x80C21B4 :: mov r1,0x14 +.org 0x80C224A :: mov r1,0x14 +.org 0x80C229E :: mov r1,0x14 // Draw PSI Rockin -org $80C2192 +.org 0x80C2192 mov r2,r8 -str r2,[sp,#0] -mov r2,#0xFD -lsl r2,r2,#1 +str r2,[sp,0] +mov r2,0xFD +lsl r2,r2,1 add r0,r6,r2 -mov r1,#0x71 -mov r2,#8 -bl m2_vwf.print_string +mov r1,0x71 +mov r2,8 +bl print_string //--------------------------------------------------------- // C239C hacks (print PSI name) //--------------------------------------------------------- -org $80C23AA; lsr r2,r2,#0xD // tiles-to-pixels -org $80C23AE; lsr r6,r3,#0xD // tiles-to-pixels -org $80C23CE; bl m2_vwf_entries.c239c_print_psi; nop; nop; nop -org $80C23DA; add r4,#17 // pixel width of "PSI " -org $80C23F0; bl m2_vwf.print_string_hlight_pixels // print rockin' -org $80C2402; mov r0,#3; lsl r0,r0,#0x10 // pixel width of space -org $80C242E; mov r0,#0x14 // new PSI name entry length -org $80C2448 -bl m2_vwf.print_string_hlight_pixels // print PSI name -mov r2,r1 // record X width -add r2,#3 // add a space -org $80C2468; bl m2_vwf.print_string_hlight_pixels +.org 0x80C23AA :: lsr r2,r2,0xD // tiles-to-pixels +.org 0x80C23AE :: lsr r6,r3,0xD // tiles-to-pixels +.org 0x80C23CE :: bl c239c_print_psi :: nop :: nop :: nop +.org 0x80C23DA :: add r4,17 // pixel width of "PSI " +.org 0x80C23F0 :: bl print_string_hlight_pixels // print rockin' +.org 0x80C2402 :: mov r0,3 :: lsl r0,r0,0x10 // pixel width of space +.org 0x80C242E :: mov r0,0x14 // new PSI name entry length +.org 0x80C2448 +bl print_string_hlight_pixels // print PSI name +mov r2,r1 // record X width +add r2,3 // add a space +.org 0x80C2468 :: bl print_string_hlight_pixels //--------------------------------------------------------- // C438C hacks (PSI window cursor movement) //--------------------------------------------------------- -org $80C4580; bl m2_vwf_entries.c438c_moveup -org $80C4642; bl m2_vwf_entries.c438c_movedown -org $80C4768; bl m2_vwf_entries.c438c_moveright -org $80C48B2; bl m2_vwf_entries.c438c_moveleft +.org 0x80C4580 :: bl c438c_moveup +.org 0x80C4642 :: bl c438c_movedown +.org 0x80C4768 :: bl c438c_moveright +.org 0x80C48B2 :: bl c438c_moveleft //--------------------------------------------------------- // PSI target window hacks //--------------------------------------------------------- // PSI target length hack -org $80B8B12; mov r0,#0x14 -org $80C24EE; mov r1,#0x14 +.org 0x80B8B12 :: mov r0,0x14 +.org 0x80C24EE :: mov r1,0x14 // Fix PSI target offset calculation -org $80B8B08 -mov r1,#100 +.org 0x80B8B08 +mov r1,100 mul r1,r2 nop nop // Make PP cost use correct number values -org $80CA732 -add r1,#0x60 +.org 0x80CA732 +add r1,0x60 // Make PP cost use the correct space value if there's only one digit -org $80CA712 -mov r0,#0x50 +.org 0x80CA712 +mov r0,0x50 //--------------------------------------------------------- // B8BBC hacks (PSI window) //--------------------------------------------------------- // Redraw main menu when exiting PSI target window -org $80B8E3A; bl m2_vwf_entries.b8bbc_redraw_menu_2to1 +.org 0x80B8E3A :: bl b8bbc_redraw_menu_2to1 // Redraw main menu when entering PSI target window -org $80B8CF8; bl m2_vwf_entries.b8bbc_redraw_menu_13to2 // 1 to 2 -org $80B920C; bl m2_vwf_entries.b8bbc_redraw_menu_13to2 // 3 to 2 +.org 0x80B8CF8 :: bl b8bbc_redraw_menu_13to2 // 1 to 2 +.org 0x80B920C :: bl b8bbc_redraw_menu_13to2 // 3 to 2 //--------------------------------------------------------- // C4B2C hacks (Equip window render) //--------------------------------------------------------- // Start equipment at the 6th tile instead of 5th -org $80C4C96; mov r2,#6 // Weapon -org $80C4D1C; mov r2,#6 // Body -org $80C4DA4; mov r2,#6 // Arms -org $80C4E2C; mov r2,#6 // Other +.org 0x80C4C96 :: mov r2,6 // Weapon +.org 0x80C4D1C :: mov r2,6 // Body +.org 0x80C4DA4 :: mov r2,6 // Arms +.org 0x80C4E2C :: mov r2,6 // Other // Only render (None) if necessary -org $80C4C0C -bl m2_vwf_entries.c4b2c_skip_nones -b $80C4C58 +.org 0x80C4C0C +bl c4b2c_skip_nones +b 0x80C4C58 // Don't render equip symbols -org $80C4CD0; nop -org $80C4CDE; nop -org $80C4D58; nop -org $80C4D66; nop -org $80C4DE0; nop -org $80C4DEE; nop -org $80C4E68; nop -org $80C4E76; nop +.org 0x80C4CD0 :: nop +.org 0x80C4CDE :: nop +.org 0x80C4D58 :: nop +.org 0x80C4D66 :: nop +.org 0x80C4DE0 :: nop +.org 0x80C4DEE :: nop +.org 0x80C4E68 :: nop +.org 0x80C4E76 :: nop // Widen the who/where/etc window -org $80B77B4; mov r3,#5 -org $80BA9E2; mov r3,#5 +.org 0x80B77B4 :: mov r3,5 +.org 0x80BA9E2 :: mov r3,5 //--------------------------------------------------------- // C4B2C hacks (Equip window loop) //--------------------------------------------------------- -org $80C4F80; bl m2_vwf_entries.c4b2c_clear_left -org $80C4F84; bl m2_vwf_entries.c4b2c_clear_right +.org 0x80C4F80 :: bl c4b2c_clear_left +.org 0x80C4F84 :: bl c4b2c_clear_right //--------------------------------------------------------- // C980C hacks (main character printing) //--------------------------------------------------------- // Reset pixel X during scroll -org $80C9858; bl m2_vwf_entries.c980c_resetx_newline -org $80C9BF0; bl m2_vwf_entries.c980c_resetx_scroll -org $80C9D18; bl m2_vwf_entries.c980c_resetx_newline -org $80CA336; bl m2_vwf_entries.c980c_resetx_newline +.org 0x80C9858 :: bl c980c_resetx_newline +.org 0x80C9BF0 :: bl c980c_resetx_scroll +.org 0x80C9D18 :: bl c980c_resetx_newline +.org 0x80CA336 :: bl c980c_resetx_newline // Reset pixel X during a newline -org $80C9CC4 -bl m2_vwf_entries.c980c_resetx_newline +.org 0x80C9CC4 +bl c980c_resetx_newline // Other reset X -org $80C9D62; bl m2_vwf_entries.c980c_resetx_other -org $80C9D76; bl m2_vwf_entries.c980c_resetx_other2 -org $80C9EEC; bl m2_vwf_entries.c980c_resetx_other3 -org $80C9F34; bl m2_vwf_entries.c980c_resetx_other3 -org $80CA204; bl m2_vwf_entries.c980c_resetx_other4 -org $80CA274; bl m2_vwf_entries.c980c_resetx_other4 -org $80CA30E; bl m2_vwf_entries.c980c_resetx_newline +.org 0x80C9D62 :: bl c980c_resetx_other +.org 0x80C9D76 :: bl c980c_resetx_other2 +.org 0x80C9EEC :: bl c980c_resetx_other3 +.org 0x80C9F34 :: bl c980c_resetx_other3 +.org 0x80CA204 :: bl c980c_resetx_other4 +.org 0x80CA274 :: bl c980c_resetx_other4 +.org 0x80CA30E :: bl c980c_resetx_newline // Custom codes check -org $80CA2BC -bl m2_vwf_entries.c980c_custom_codes +.org 0x80CA2BC +bl c980c_custom_codes // Reset pixel X when redrawing the window -org $80CA2E6 -bl m2_vwf_entries.c980c_resetx +.org 0x80CA2E6 +bl c980c_resetx // Welding entry -org $80CA448 -bl m2_vwf_entries.c980c_weld_entry -b $80CA46C +.org 0x80CA448 +bl c980c_weld_entry +b 0x80CA46C // Disable X coordinate incrementing -org $80CA48E +.org 0x80CA48E nop //--------------------------------------------------------- @@ -258,146 +259,146 @@ nop //--------------------------------------------------------- // Custom codes check -org $80C90A2 -bl m2_vwf_entries.c8ffc_custom_codes +.org 0x80C90A2 +bl c8ffc_custom_codes // Welding entry -org $80C9114 -bl m2_vwf_entries.c8ffc_weld_entry -b $80C9144 +.org 0x80C9114 +bl c8ffc_weld_entry +b 0x80C9144 // Integer-to-char changes -org $80CA67C; mov r3,#0x50 // space -org $80CA69C; mov r2,#0x60 // zero -org $80CA78A; mov r0,#0x60 // zero -org $80CA7AC; mov r2,#0x69 // nine -org $80CA7EC; sub r1,#0xA0 +.org 0x80CA67C :: mov r3,0x50 // space +.org 0x80CA69C :: mov r2,0x60 // zero +.org 0x80CA78A :: mov r0,0x60 // zero +.org 0x80CA7AC :: mov r2,0x69 // nine +.org 0x80CA7EC :: sub r1,0xA0 //--------------------------------------------------------- // C87D0 hacks (draw blank window) //--------------------------------------------------------- -org $80C87DC -bl m2_vwf_entries.c87d0_clear_entry +.org 0x80C87DC +bl c87d0_clear_entry //--------------------------------------------------------- // C9634 hacks (string printing) //--------------------------------------------------------- -org $80C967E -bl m2_vwf_entries.c9634_resetx +.org 0x80C967E +bl c9634_resetx //--------------------------------------------------------- // C96F0 hacks (string printing with highlight) //--------------------------------------------------------- -org $80C9714 -lsl r3,r3,#1 // change from row coords to tile coords -ldrh r1,[r0,#0x22] +.org 0x80C9714 +lsl r3,r3,1 // change from row coords to tile coords +ldrh r1,[r0,0x22] add r1,r1,r2 -lsl r1,r1,#3 // r1 = tile_x * 8 -ldrh r2,[r0,#0x24] +lsl r1,r1,3 // r1 = tile_x * 8 +ldrh r2,[r0,0x24] add r2,r2,r3 -lsl r2,r2,#3 // r2 = tile_y * 8 +lsl r2,r2,3 // r2 = tile_y * 8 mov r0,r6 -bl m2_vwf.print_string +bl print_string mov r7,r0 -b $80C9788 +b 0x80C9788 //--------------------------------------------------------- // CA4BC hacks (scroll text) //--------------------------------------------------------- -org $80CA55E; bl m2_vwf_entries.ca4bc_erase_tile_short -org $80CA60E; bl m2_vwf_entries.ca4bc_copy_tile_up -org $80CA626; bl m2_vwf_entries.ca4bc_erase_tile +.org 0x80CA55E :: bl ca4bc_erase_tile_short +.org 0x80CA60E :: bl ca4bc_copy_tile_up +.org 0x80CA626 :: bl ca4bc_erase_tile //--------------------------------------------------------- // D2E94 hacks (print party character name) //--------------------------------------------------------- -org $80D2F24 +.org 0x80D2F24 mov r1,r6 mov r2,r7 mov r0,r4 -bl m2_vwf.weld_entry -b $80D2F52 +bl weld_entry +b 0x80D2F52 // Disable X increment -org $80D2F5A; nop +.org 0x80D2F5A :: nop //--------------------------------------------------------- // D2FA0 hacks (print item) //--------------------------------------------------------- -org $80D3044 +.org 0x80D3044 mov r0,r4 mov r1,r6 -bl m2_vwf.weld_entry -b $80D3072 +bl weld_entry +b 0x80D3072 // Disable X increment -org $80D307A; nop +.org 0x80D307A :: nop //--------------------------------------------------------- // D30C4 hacks (print number) //--------------------------------------------------------- -org $80D314A +.org 0x80D314A mov r0,r5 mov r1,r7 -bl m2_vwf.weld_entry -b $80D3178 +bl weld_entry +b 0x80D3178 // Disable X increment -org $80D3180; nop +.org 0x80D3180 :: nop //--------------------------------------------------------- // D332C hacks (print name) //--------------------------------------------------------- -org $80D34E8 +.org 0x80D34E8 mov r0,r5 mov r1,r4 -bl m2_vwf.weld_entry -b $80D3514 +bl weld_entry +b 0x80D3514 // Disable X increment -org $80D351A; nop +.org 0x80D351A :: nop //--------------------------------------------------------- // D3934 hacks (print PSI name) //--------------------------------------------------------- -org $80D39BA; mov r0,#0x14 // PSI name length +.org 0x80D39BA :: mov r0,0x14 // PSI name length // Weld entry -org $80D39E2 +.org 0x80D39E2 mov r0,r4 mov r1,r5 -bl m2_vwf.weld_entry -b $80D3A14 +bl weld_entry +b 0x80D3A14 // Print a space before the Greek letter -org $80D39D4; bl m2_vwf_entries.d3934_print_space +.org 0x80D39D4 :: bl d3934_print_space // Battle command hacks -org $8B1F4C8; db $11 // Extend command window width two tiles (Normal) -org $8B1F4CC; db $16 // Extend command window width two tiles (Paula paralyzed leader) -org $80D7A56; mov r1,#4 // Move PSI class window left one tile -org $80D7A5A; mov r3,#6 // Extend PSI class window width one tile -org $80DC038; add r5,#0x30 // String address calculation -org $80DC0A8; add r1,#0x60 // String address calculation +.org 0x8B1F4C8 :: db 0x11 // Extend command window width two tiles (Normal) +.org 0x8B1F4CC :: db 0x16 // Extend command window width two tiles (Paula paralyzed leader) +.org 0x80D7A56 :: mov r1,4 // Move PSI class window left one tile +.org 0x80D7A5A :: mov r3,6 // Extend PSI class window width one tile +.org 0x80DC038 :: add r5,0x30 // String address calculation +.org 0x80DC0A8 :: add r1,0x60 // String address calculation -org $80DC27C; lsl r1,r2,#4; nop // String address calculation -org $80DC2AC; lsl r1,r2,#4; nop // String address calculation +.org 0x80DC27C :: lsl r1,r2,4 :: nop // String address calculation +.org 0x80DC2AC :: lsl r1,r2,4 :: nop // String address calculation -org $80DCC36; mov r2,#2 // "to X" position -org $80DCCE0; mov r2,#2 // "to the Front Row" position +.org 0x80DCC36 :: mov r2,2 // "to X" position +.org 0x80DCCE0 :: mov r2,2 // "to the Front Row" position -org $80E079E; bl m2_vwf_entries.e06ec_clear_window -org $80E0888; bl m2_vwf_entries.e06ec_redraw_psi -org $80E0A16; bl m2_vwf_entries.e06ec_redraw_bash_psi +.org 0x80E079E :: bl e06ec_clear_window +.org 0x80E0888 :: bl e06ec_redraw_psi +.org 0x80E0A16 :: bl e06ec_redraw_bash_psi //--------------------------------------------------------- // BD918 hacks (battle setup) @@ -410,119 +411,113 @@ org $80E0A16; bl m2_vwf_entries.e06ec_redraw_bash_psi // and target strings on the heap. The game only allocates 16 each. // Goal: allocate an extra 128 bytes and fix all the offsets to the user/target // strings. We'll store the user string at +0x4C0 and the target string at +0x500. -org $80BD97A; mov r0,#0xA8 // malloc an extra 128 bytes for longer user/target strings +.org 0x80BD97A :: mov r0,0xA8 // malloc an extra 128 bytes for longer user/target strings // Fix user/target pointers -org $80C9942; bl m2_vwf_entries.c980c_user_pointer -org $80C9954; bl m2_vwf_entries.c980c_target_pointer -org $80EBFDC; bl m2_vwf_entries.ebfd4_user_pointer; b $80EBFFA -org $80EC004; push {lr}; bl m2_vwf_entries.ec004_user_pointer -org $80EC018; bl m2_vwf_entries.ec010_target_pointer; b $80EC038 -org $80EC046; push {lr}; bl m2_vwf_entries.ec046_target_pointer +.org 0x80C9942 :: bl c980c_user_pointer +.org 0x80C9954 :: bl c980c_target_pointer +.org 0x80EBFDC :: bl ebfd4_user_pointer :: b 0x80EBFFA +.org 0x80EC004 :: push {lr} :: bl ec004_user_pointer +.org 0x80EC018 :: bl ec010_target_pointer :: b 0x80EC038 +.org 0x80EC046 :: push {lr} :: bl ec046_target_pointer // Length fixes -org $80DAE02; add sp,#-0x40 -org $80DAE08; mov r2,#0x3E -org $80DAE38; mov r2,#0x3A -org $80DAEA2; mov r1,#0x3E -org $80DAEDE; add sp,#0x40 +.org 0x80DAE02 :: add sp,-0x40 +.org 0x80DAE08 :: mov r2,0x3E +.org 0x80DAE38 :: mov r2,0x3A +.org 0x80DAEA2 :: mov r1,0x3E +.org 0x80DAEDE :: add sp,0x40 -org $80DB04E; add sp,#-0x40 -org $80DB058; mov r2,#0x3E -org $80DB08C; mov r2,#0x3A -org $80DB116; mov r1,#0x3E -org $80DB15A; add sp,#0x40 +.org 0x80DB04E :: add sp,-0x40 +.org 0x80DB058 :: mov r2,0x3E +.org 0x80DB08C :: mov r2,0x3A +.org 0x80DB116 :: mov r1,0x3E +.org 0x80DB15A :: add sp,0x40 -org $80DCD02; add sp,#-0x40 -org $80DCD0C; mov r2,#0x3C -org $80DCD64; mov r2,#0x3A -org $80DCDA2; mov r1,#0x3E -org $80DCDA8; add sp,#0x40 +.org 0x80DCD02 :: add sp,-0x40 +.org 0x80DCD0C :: mov r2,0x3C +.org 0x80DCD64 :: mov r2,0x3A +.org 0x80DCDA2 :: mov r1,0x3E +.org 0x80DCDA8 :: add sp,0x40 // Add a space between enemy name and letter -org $80DCD94; bl m2_vwf_entries.dcd00_enemy_letter -org $80DCD9A; strb r0,[r5,#2] -org $80DCD9E; strb r0,[r5,#3] +.org 0x80DCD94 :: bl dcd00_enemy_letter +.org 0x80DCD9A :: strb r0,[r5,2] +.org 0x80DCD9E :: strb r0,[r5,3] -org $80DAE7E; bl m2_vwf_entries.dae00_enemy_letter -org $80DAE84; strb r0,[r4,#2] -org $80DAE88; strb r0,[r4,#3] +.org 0x80DAE7E :: bl dae00_enemy_letter +.org 0x80DAE84 :: strb r0,[r4,2] +.org 0x80DAE88 :: strb r0,[r4,3] -org $80DB0CE; bl m2_vwf_entries.dae00_enemy_letter -org $80DB0D2; strb r5,[r4,#2] -org $80DB0D6; strb r0,[r4,#3] +.org 0x80DB0CE :: bl dae00_enemy_letter +.org 0x80DB0D2 :: strb r5,[r4,2] +.org 0x80DB0D6 :: strb r0,[r4,3] // "The" flag checks -org $80DB084; bl m2_vwf_entries.db04c_theflag; nop; nop +.org 0x80DB084 :: bl db04c_theflag :: nop :: nop // Ignore the hard-coded Japanese "and cohorts" -org $80DB0E6; b $80DB0FE +.org 0x80DB0E6 :: b 0x80DB0FE //============================================================================== // Data files //============================================================================== -org $8B2C000 +.org 0x8B2C000 // Box font relocation m2_font_relocate: -incbin m2-font-relocate.bin +.incbin "m2-font-relocate.bin" // Co-ordinate table m2_coord_table: -incbin m2-coord-table.bin +.incbin "m2-coord-table.bin" // EB fonts m2_font_table: -dd m2_font_main -dd m2_font_saturn +dw m2_font_main +dw m2_font_saturn m2_font_main: -incbin m2-font-main.bin +.incbin "m2-font-main.bin" m2_font_saturn: -incbin m2-font-saturn.bin +.incbin "m2-font-saturn.bin" // EB font heights m2_height_table: -db $02, $02, $01, $00 // last byte for alignment +db 0x02, 0x02, 0x01, 0x00 // last byte for alignment // EB font widths m2_widths_table: -dd m2_widths_main -dd m2_widths_saturn +dw m2_widths_main +dw m2_widths_saturn m2_widths_main: -incbin m2-widths-main.bin +.incbin "m2-widths-main.bin" m2_widths_saturn: // tbd m2_bits_to_nybbles: -incbin m2-bits-to-nybbles.bin +.incbin "m2-bits-to-nybbles.bin" m2_nybbles_to_bits: -incbin m2-nybbles-to-bits.bin +.incbin "m2-nybbles-to-bits.bin" m2_enemy_attributes: -incbin m2-enemy-attributes.bin - - -//============================================================================== -// Misc -//============================================================================== - -org $2027FC0 -m2_custom_wram: +.incbin "m2-enemy-attributes.bin" //============================================================================== // Code files //============================================================================== -org $80FCE6C -incsrc m2-vwf.asm -incsrc m2-vwf-entries.asm -incsrc m2-formatting.asm -incsrc m2-customcodes.asm +.org 0x80FCE6C +.include "m2-vwf.asm" +.include "m2-vwf-entries.asm" +.include "m2-formatting.asm" +.include "m2-customcodes.asm" + +.close diff --git a/m2-status-initial.asm b/m2-status-initial.asm index 89adb38..0f19344 100644 --- a/m2-status-initial.asm +++ b/m2-status-initial.asm @@ -1,227 +1,227 @@ // Level -org $80C0BAE -mov r0,#5 -mov r1,#1 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r3,#6 +.org 0x80C0BAE +mov r0,5 +mov r1,1 +mov r2,3 +bl print_blankstr +mov r3,6 mul r3,r4 -mov r2,#56 +mov r2,56 sub r2,r2,r3 -org $80C0BC6 -mov r3,#8 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0BC6 +mov r3,8 +bl c0a5c_printstr // Max HP -org $80C0C06 -mov r0,#0x10 -mov r1,#7 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r5,#6 +.org 0x80C0C06 +mov r0,0x10 +mov r1,7 +mov r2,3 +bl print_blankstr +mov r5,6 mul r4,r5 -mov r5,#147 +mov r5,147 sub r4,r5,r4 -org $80C0C20 -mov r3,#56 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0C20 +mov r3,56 +bl c0a5c_printstr // Current HP -org $80C0C62 -mov r0,#0xC -mov r1,#7 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r5,#6 +.org 0x80C0C62 +mov r0,0xC +mov r1,7 +mov r2,3 +bl print_blankstr +mov r5,6 mul r4,r5 -mov r5,#120 +mov r5,120 sub r4,r5,r4 -org $80C0C7C -mov r3,#56 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0C7C +mov r3,56 +bl c0a5c_printstr // Max PP -org $80C0CBE -mov r0,#0x10 -mov r1,#9 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r0,#6 +.org 0x80C0CBE +mov r0,0x10 +mov r1,9 +mov r2,3 +bl print_blankstr +mov r0,6 mul r4,r0 -mov r0,#147 +mov r0,147 sub r4,r0,r4 -org $80C0CD8 -mov r3,#72 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0CD8 +mov r3,72 +bl c0a5c_printstr // Current PP -org $80C0D1A -mov r0,#0xC -mov r1,#9 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r5,#6 +.org 0x80C0D1A +mov r0,0xC +mov r1,9 +mov r2,3 +bl print_blankstr +mov r5,6 mul r4,r5 -mov r5,#120 +mov r5,120 -org $80C0D30 +.org 0x80C0D30 sub r2,r5,r4 -mov r3,#72 -bl m2_vwf_entries.c0a5c_printstr +mov r3,72 +bl c0a5c_printstr // Total exp -org $80C0D78 -mov r0,#0xC -mov r1,#0xB -mov r2,#7 -bl m2_vwf.print_blankstr -mov r1,#6 +.org 0x80C0D78 +mov r0,0xC +mov r1,0xB +mov r2,7 +bl print_blankstr +mov r1,6 mul r4,r1 -mov r1,#147 +mov r1,147 sub r4,r1,r4 -org $80C0D92 -mov r3,#88 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0D92 +mov r3,88 +bl c0a5c_printstr // Exp to next level -org $80C0DF8 -mov r0,#2 -mov r1,#0xD -mov r2,#6 -bl m2_vwf.print_blankstr -mov r3,#6 +.org 0x80C0DF8 +mov r0,2 +mov r1,0xD +mov r2,6 +bl print_blankstr +mov r3,6 mul r4,r3 -mov r3,#61 +mov r3,61 sub r4,r3,r4 -org $80C0E12 -mov r3,#104 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0E12 +mov r3,104 +bl c0a5c_printstr -org $80C0E38 -mov r0,#2 -mov r1,#0xD -mov r2,#6 -bl m2_vwf.print_blankstr +.org 0x80C0E38 +mov r0,2 +mov r1,0xD +mov r2,6 +bl print_blankstr // Offense -org $80C0E86 -mov r0,#0x19 -mov r1,#1 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r6,#6 +.org 0x80C0E86 +mov r0,0x19 +mov r1,1 +mov r2,4 +bl print_blankstr +mov r6,6 mul r4,r6 -mov r6,#225 +mov r6,225 sub r4,r6,r4 -org $80C0EA0 -mov r3,#8 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0EA0 +mov r3,8 +bl c0a5c_printstr // Defense -org $80C0EE0 -mov r0,#0x19 -mov r1,#3 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C0EE0 +mov r0,0x19 +mov r1,3 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C0EF8 -mov r3,#24 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0EF8 +mov r3,24 +bl c0a5c_printstr // Speed -org $80C0F38 -mov r0,#0x19 -mov r1,#5 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C0F38 +mov r0,0x19 +mov r1,5 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C0F50 -mov r3,#40 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0F50 +mov r3,40 +bl c0a5c_printstr // Guts -org $80C0F90 -mov r0,#0x19 -mov r1,#7 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C0F90 +mov r0,0x19 +mov r1,7 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C0FA8 -mov r3,#56 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C0FA8 +mov r3,56 +bl c0a5c_printstr // Vitality -org $80C0FE8 -mov r0,#0x19 -mov r1,#9 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C0FE8 +mov r0,0x19 +mov r1,9 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C1000 -mov r3,#72 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C1000 +mov r3,72 +bl c0a5c_printstr // IQ -org $80C1040 -mov r0,#0x19 -mov r1,#0xB -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C1040 +mov r0,0x19 +mov r1,0xB +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C1058 -mov r3,#88 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C1058 +mov r3,88 +bl c0a5c_printstr // Luck -org $80C1098 -mov r0,#0x19 -mov r1,#0xD -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C1098 +mov r0,0x19 +mov r1,0xD +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r6,r6,r4 -org $80C10B0 -mov r3,#104 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C10B0 +mov r3,104 +bl c0a5c_printstr // Press A for PSI info -org $80C10C0 -bl m2_vwf_entries.c0a5c_psi_info_blank -b $80C10FA +.org 0x80C10C0 +bl c0a5c_psi_info_blank +b 0x80C10FA -org $80C10F2 -mov r2,#44 -mov r3,#120 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C10F2 +mov r2,44 +mov r3,120 +bl c0a5c_printstr // Ailment -org $80C10FE -mov r0,#1 -mov r1,#3 -mov r2,#10 -bl m2_vwf.print_blankstr -b $80C1116 +.org 0x80C10FE +mov r0,1 +mov r1,3 +mov r2,10 +bl print_blankstr +b 0x80C1116 diff --git a/m2-status-switch.asm b/m2-status-switch.asm index 0cefbab..9b37183 100644 --- a/m2-status-switch.asm +++ b/m2-status-switch.asm @@ -1,227 +1,227 @@ // Level -org $80C1392 -mov r0,#5 -mov r1,#1 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r3,#6 +.org 0x80C1392 +mov r0,5 +mov r1,1 +mov r2,3 +bl print_blankstr +mov r3,6 mul r3,r4 -mov r2,#56 +mov r2,56 sub r2,r2,r3 -org $80C13AA -mov r3,#8 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C13AA +mov r3,8 +bl c0a5c_printstr // Max HP -org $80C13EC -mov r0,#0x10 -mov r1,#7 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r3,#6 +.org 0x80C13EC +mov r0,0x10 +mov r1,7 +mov r2,3 +bl print_blankstr +mov r3,6 mul r4,r3 -mov r3,#147 +mov r3,147 sub r4,r3,r4 -org $80C1406 -mov r3,#56 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C1406 +mov r3,56 +bl c0a5c_printstr // Current HP -org $80C1448 -mov r0,#0xC -mov r1,#7 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r3,#6 +.org 0x80C1448 +mov r0,0xC +mov r1,7 +mov r2,3 +bl print_blankstr +mov r3,6 mul r4,r3 -mov r3,#120 +mov r3,120 sub r4,r3,r4 -org $80C1462 -mov r3,#56 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C1462 +mov r3,56 +bl c0a5c_printstr // Max PP -org $80C14A4 -mov r0,#0x10 -mov r1,#9 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r0,#6 +.org 0x80C14A4 +mov r0,0x10 +mov r1,9 +mov r2,3 +bl print_blankstr +mov r0,6 mul r4,r0 -mov r0,#147 +mov r0,147 sub r4,r0,r4 -org $80C14BE -mov r3,#72 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C14BE +mov r3,72 +bl c0a5c_printstr // Current PP -org $80C1500 -mov r0,#0xC -mov r1,#9 -mov r2,#3 -bl m2_vwf.print_blankstr -mov r3,#6 +.org 0x80C1500 +mov r0,0xC +mov r1,9 +mov r2,3 +bl print_blankstr +mov r3,6 mul r4,r3 -mov r3,#120 +mov r3,120 -org $80C1516 +.org 0x80C1516 sub r2,r3,r4 -mov r3,#72 -bl m2_vwf_entries.c0a5c_printstr +mov r3,72 +bl c0a5c_printstr // Total exp -org $80C1560 -mov r0,#0xC -mov r1,#0xB -mov r2,#7 -bl m2_vwf.print_blankstr -mov r1,#6 +.org 0x80C1560 +mov r0,0xC +mov r1,0xB +mov r2,7 +bl print_blankstr +mov r1,6 mul r4,r1 -mov r1,#147 +mov r1,147 sub r4,r1,r4 -org $80C157A -mov r3,#88 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C157A +mov r3,88 +bl c0a5c_printstr // Exp to next level -org $80C15E2 -mov r0,#2 -mov r1,#0xD -mov r2,#6 -bl m2_vwf.print_blankstr -mov r0,#6 +.org 0x80C15E2 +mov r0,2 +mov r1,0xD +mov r2,6 +bl print_blankstr +mov r0,6 mul r4,r0 -mov r0,#61 +mov r0,61 sub r4,r0,r4 -org $80C15FC -mov r3,#104 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C15FC +mov r3,104 +bl c0a5c_printstr -org $80C1624 -mov r0,#2 -mov r1,#0xD -mov r2,#6 -bl m2_vwf.print_blankstr +.org 0x80C1624 +mov r0,2 +mov r1,0xD +mov r2,6 +bl print_blankstr // Offense -org $80C1672 -mov r0,#0x19 -mov r1,#1 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r6,#6 +.org 0x80C1672 +mov r0,0x19 +mov r1,1 +mov r2,4 +bl print_blankstr +mov r6,6 mul r4,r6 -mov r6,#225 +mov r6,225 sub r4,r6,r4 -org $80C168C -mov r3,#8 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C168C +mov r3,8 +bl c0a5c_printstr // Defense -org $80C16CC -mov r0,#0x19 -mov r1,#3 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C16CC +mov r0,0x19 +mov r1,3 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C16E4 -mov r3,#24 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C16E4 +mov r3,24 +bl c0a5c_printstr // Speed -org $80C1724 -mov r0,#0x19 -mov r1,#5 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C1724 +mov r0,0x19 +mov r1,5 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C173C -mov r3,#40 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C173C +mov r3,40 +bl c0a5c_printstr // Guts -org $80C177C -mov r0,#0x19 -mov r1,#7 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C177C +mov r0,0x19 +mov r1,7 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C1794 -mov r3,#56 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C1794 +mov r3,56 +bl c0a5c_printstr // Vitality -org $80C17D4 -mov r0,#0x19 -mov r1,#9 -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C17D4 +mov r0,0x19 +mov r1,9 +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C17EC -mov r3,#72 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C17EC +mov r3,72 +bl c0a5c_printstr // IQ -org $80C182C -mov r0,#0x19 -mov r1,#0xB -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C182C +mov r0,0x19 +mov r1,0xB +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r4,r6,r4 -org $80C1844 -mov r3,#88 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C1844 +mov r3,88 +bl c0a5c_printstr // Luck -org $80C1884 -mov r0,#0x19 -mov r1,#0xD -mov r2,#4 -bl m2_vwf.print_blankstr -mov r2,#6 +.org 0x80C1884 +mov r0,0x19 +mov r1,0xD +mov r2,4 +bl print_blankstr +mov r2,6 mul r4,r2 sub r6,r6,r4 -org $80C189C -mov r3,#104 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C189C +mov r3,104 +bl c0a5c_printstr // Press A for PSI info -org $80C18AC -bl m2_vwf_entries.c0a5c_psi_info_blank -b $80C18E2 +.org 0x80C18AC +bl c0a5c_psi_info_blank +b 0x80C18E2 -org $80C18DA -mov r2,#44 -mov r3,#120 -bl m2_vwf_entries.c0a5c_printstr +.org 0x80C18DA +mov r2,44 +mov r3,120 +bl c0a5c_printstr // Ailment -org $80C18E2 -mov r0,#1 -mov r1,#3 -mov r2,#10 -bl m2_vwf.print_blankstr -b $80C18FA +.org 0x80C18E2 +mov r0,1 +mov r1,3 +mov r2,10 +bl print_blankstr +b 0x80C18FA diff --git a/m2-vwf-entries.asm b/m2-vwf-entries.asm index 2c7e4ad..07bad1d 100644 --- a/m2-vwf-entries.asm +++ b/m2-vwf-entries.asm @@ -1,556 +1,570 @@ -m2_vwf_entries: - //============================================================================== -.c980c_custom_codes: +c980c_custom_codes: push {r1-r2,lr} mov r1,r7 mov r2,r5 -bl m2_customcodes.parse -ldr r1,[r6,#0] +bl customcodes_parse +ldr r1,[r6,0] // If 0, return [r6]+2; otherwise, return [r6]+r0 -beq + +beq @@next add r0,r0,r1 pop {r1-r2,pc} -+ -add r0,r1,#2 +@@next: +add r0,r1,2 pop {r1-r2,pc} //============================================================================== -.c980c_weld_entry: +c980c_weld_entry: push {r0-r1,lr} mov r0,r5 mov r1,r7 -bl m2_vwf.weld_entry +bl weld_entry pop {r0-r1,pc} //============================================================================== -.c8ffc_custom_codes: +c8ffc_custom_codes: push {r2,r5,lr} -ldrb r0,[r2,#0] +ldrb r0,[r2,0] mov r5,r0 mov r1,r2 mov r2,r4 -bl m2_customcodes.parse -cmp r0,#0 -beq + +bl customcodes_parse +cmp r0,0 +beq @@next mov r2,r12 add r0,r0,r2 -strh r0,[r4,#0x14] +strh r0,[r4,0x14] pop {r2,r5} -add sp,#4 -ldr r1,=#0x80C904D +add sp,4 +ldr r1,=0x80C904D bx r1 -+ +@@next: mov r0,r5 -cmp r0,#1 +cmp r0,1 pop {r2,r5,pc} +.pool + //============================================================================== -.c8ffc_weld_entry: +c8ffc_weld_entry: push {r0-r1,lr} mov r0,r4 mov r1,r2 -bl m2_vwf.weld_entry +bl weld_entry pop {r0-r1,pc} //============================================================================== -.c980c_resetx: +c980c_resetx: push {r1,lr} -mov r1,#0 -strh r1,[r0,#2] +mov r1,0 +strh r1,[r0,2] pop {r1} -bl $80C87D0 +bl 0x80C87D0 pop {pc} //============================================================================== -.c980c_resetx_newline: +c980c_resetx_newline: push {lr} -strh r0,[r5,#0x2C] -strh r4,[r5,#0x2A] -strh r4,[r5,#2] +strh r0,[r5,0x2C] +strh r4,[r5,0x2A] +strh r4,[r5,2] pop {pc} //============================================================================== -.c980c_resetx_scroll: +c980c_resetx_scroll: push {lr} -strh r0,[r5,#0x2C] -strh r1,[r5,#0x2A] -strh r1,[r5,#2] +strh r0,[r5,0x2C] +strh r1,[r5,0x2A] +strh r1,[r5,2] pop {pc} //============================================================================== -.c980c_resetx_other: +c980c_resetx_other: push {lr} -strh r0,[r5,#0x2C] -strh r2,[r5,#0x2A] -strh r2,[r5,#2] +strh r0,[r5,0x2C] +strh r2,[r5,0x2A] +strh r2,[r5,2] pop {pc} //============================================================================== -.c980c_resetx_other2: +c980c_resetx_other2: push {lr} -mov r2,#0 -strh r2,[r5,#0x2A] -strh r2,[r5,#2] +mov r2,0 +strh r2,[r5,0x2A] +strh r2,[r5,2] pop {pc} //============================================================================== -.c980c_resetx_other3: +c980c_resetx_other3: push {lr} -mov r1,#0 -strh r1,[r5,#0x2A] -strh r1,[r5,#2] +mov r1,0 +strh r1,[r5,0x2A] +strh r1,[r5,2] pop {pc} //============================================================================== -.c980c_resetx_other4: +c980c_resetx_other4: push {lr} -strh r0,[r5,#0x2C] -strh r6,[r5,#0x2A] -strh r6,[r5,#2] +strh r0,[r5,0x2C] +strh r6,[r5,0x2A] +strh r6,[r5,2] pop {pc} //============================================================================== -.c87d0_clear_entry: +c87d0_clear_entry: push {lr} // Reset X -mov r1,#0 -strh r1,[r0,#2] +mov r1,0 +strh r1,[r0,2] // Clear window -mov r1,#4 -bl m2_vwf.clear_window +mov r1,4 +bl clear_window // Clobbered code -ldr r4,=#0x3005270 -mov r1,#0x24 +ldr r4,=0x3005270 +mov r1,0x24 pop {pc} +.pool + //============================================================================== -.c9634_resetx: +c9634_resetx: push {lr} -mov r4,#0 -strh r4,[r6,#2] +mov r4,0 +strh r4,[r6,2] // Clobbered code -strh r5,[r1,#0] +strh r5,[r1,0] pop {pc} //============================================================================== // Only render the (None) strings in the equip window if there's nothing equipped -.c4b2c_skip_nones: +c4b2c_skip_nones: push {r7,lr} -add sp,#-4 -mov r7,#0 +add sp,-4 +mov r7,0 // Get the (none) pointer mov r0,r4 mov r1,r10 -mov r2,#0x2A -bl $80BE260 +mov r2,0x2A +bl 0x80BE260 mov r5,r0 // Check each equip slot -ldr r6,=#0x3001D40 -ldr r3,=#0x3005264 -ldrh r0,[r3,#0] // active party character -mov r1,#0x6C +ldr r6,=0x3001D40 +ldr r3,=0x3005264 +ldrh r0,[r3,0] // active party character +mov r1,0x6C mul r0,r1 add r6,r0,r6 -add r6,#0x75 -ldrb r0,[r6,#0] -cmp r0,#0 -bne + +add r6,0x75 +ldrb r0,[r6,0] +cmp r0,0 +bne @@next // Weapon mov r0,r8 mov r1,r5 -mov r2,#0x6 -mov r3,#0 -str r7,[sp,#0] -bl $80C9634 +mov r2,0x6 +mov r3,0 +str r7,[sp,0] +bl 0x80C9634 -+ -ldrb r0,[r6,#1] -cmp r0,#0 -bne + +@@next: +ldrb r0,[r6,1] +cmp r0,0 +bne @@next2 // Body mov r0,r8 mov r1,r5 -mov r2,#0x6 -mov r3,#1 -str r7,[sp,#0] -bl $80C9634 +mov r2,0x6 +mov r3,1 +str r7,[sp,0] +bl 0x80C9634 -+ -ldrb r0,[r6,#2] -cmp r0,#0 -bne + +@@next2: +ldrb r0,[r6,2] +cmp r0,0 +bne @@next3 // Arms mov r0,r8 mov r1,r5 -mov r2,#0x6 -mov r3,#2 -str r7,[sp,#0] -bl $80C9634 +mov r2,0x6 +mov r3,2 +str r7,[sp,0] +bl 0x80C9634 -+ -ldrb r0,[r6,#3] -cmp r0,#0 -bne + +@@next3: +ldrb r0,[r6,3] +cmp r0,0 +bne @@next4 // Other mov r0,r8 mov r1,r5 -mov r2,#0x6 -mov r3,#3 -str r7,[sp,#0] -bl $80C9634 +mov r2,0x6 +mov r3,3 +str r7,[sp,0] +bl 0x80C9634 -+ -mov r0,#0 +@@next4: +mov r0,0 mov r10,r0 -add sp,#4 +add sp,4 pop {r7,pc} +.pool + //============================================================================== // Clears the equipment portion of the equip window // r0 = window pointer -.clear_equipment: +clear_equipment: push {r0-r2,lr} -add sp,#-16 +add sp,-16 mov r1,r0 mov r0,sp -ldrh r2,[r1,#0x22] // window X -add r2,#6 // horizontal offset -strh r2,[r0,#0] -ldrh r2,[r1,#0x24] // window Y -strh r2,[r0,#2] -ldrh r2,[r1,#0x26] // window width -sub r2,#6 -strh r2,[r0,#0xC] -ldrh r2,[r1,#0x28] // window height -strh r2,[r0,#0xE] +ldrh r2,[r1,0x22] // window X +add r2,6 // horizontal offset +strh r2,[r0,0] +ldrh r2,[r1,0x24] // window Y +strh r2,[r0,2] +ldrh r2,[r1,0x26] // window width +sub r2,6 +strh r2,[r0,0xC] +ldrh r2,[r1,0x28] // window height +strh r2,[r0,0xE] -ldr r2,=#0x44444444 -str r2,[r0,#4] -ldr r2,=#0x30051EC -ldrh r2,[r2,#0] -strh r2,[r0,#8] +ldr r2,=0x44444444 +str r2,[r0,4] +ldr r2,=0x30051EC +ldrh r2,[r2,0] +strh r2,[r0,8] -bl m2_vwf.clear_rect +bl clear_rect -add sp,#16 +add sp,16 pop {r0-r2,pc} +.pool //============================================================================== // Clear equipment and offense/defense when moving left/right on equip screen // r6 = window pointer -.c4b2c_clear_left: +c4b2c_clear_left: mov r0,r6 -bl .clear_equipment +bl clear_equipment // Clear offense/defense push {r0-r2} -mov r0,#8 +mov r0,8 mov r2,r0 -mov r1,#0xB -bl m2_vwf.print_blankstr -add r1,#2 -bl m2_vwf.print_blankstr +mov r1,0xB +bl print_blankstr +add r1,2 +bl print_blankstr pop {r0-r2} // Clobbered code -strh r1,[r3,#0] -ldr r0,=#0x80C4F3B +strh r1,[r3,0] +ldr r0,=0x80C4F3B bx r0 -.c4b2c_clear_right: +c4b2c_clear_right: mov r0,r6 -bl .clear_equipment +bl clear_equipment // Clear offense/defense push {r0-r2} -mov r0,#8 +mov r0,8 mov r2,r0 -mov r1,#0xB -bl m2_vwf.print_blankstr -add r1,#2 -bl m2_vwf.print_blankstr +mov r1,0xB +bl print_blankstr +add r1,2 +bl print_blankstr pop {r0-r2} // Clobbered code -strh r1,[r3,#0] -ldr r0,=#0x80C4EFF +strh r1,[r3,0] +ldr r0,=0x80C4EFF bx r0 +.pool + //============================================================================== // Clear PSI target window when moving left/right on PSI screen -.c438c_moveright: +c438c_moveright: push {r0-r1,lr} -ldr r1,=#0x3005230 -ldr r0,[r1,#0x24] // PSI target window pointer -mov r1,#4 -bl m2_vwf.clear_window +ldr r1,=0x3005230 +ldr r0,[r1,0x24] // PSI target window pointer +mov r1,4 +bl clear_window pop {r0-r1} // Clobbered code -add r0,#1 -strh r0,[r5,#0x34] +add r0,1 +strh r0,[r5,0x34] pop {pc} -.c438c_moveleft: +c438c_moveleft: push {r0-r1,lr} -ldr r1,=#0x3005230 -ldr r0,[r1,#0x24] // PSI target window pointer -mov r1,#4 -bl m2_vwf.clear_window +ldr r1,=0x3005230 +ldr r0,[r1,0x24] // PSI target window pointer +mov r1,4 +bl clear_window pop {r0-r1} // Clobbered code -sub r0,#1 -strh r0,[r5,#0x34] +sub r0,1 +strh r0,[r5,0x34] pop {pc} -.c438c_moveup: +c438c_moveup: push {r0-r1,lr} -ldr r1,=#0x3005230 -ldr r0,[r1,#0x24] // PSI target window pointer -mov r1,#4 -bl m2_vwf.clear_window +ldr r1,=0x3005230 +ldr r0,[r1,0x24] // PSI target window pointer +mov r1,4 +bl clear_window pop {r0-r1} // Clobbered code -sub r0,#1 -strh r0,[r5,#0x36] +sub r0,1 +strh r0,[r5,0x36] pop {pc} -.c438c_movedown: +c438c_movedown: push {r0-r1,lr} -ldr r1,=#0x3005230 -ldr r0,[r1,#0x24] // PSI target window pointer -mov r1,#4 -bl m2_vwf.clear_window +ldr r1,=0x3005230 +ldr r0,[r1,0x24] // PSI target window pointer +mov r1,4 +bl clear_window pop {r0-r1} // Clobbered code -add r0,#1 -strh r0,[r5,#0x36] +add r0,1 +strh r0,[r5,0x36] pop {pc} +.pool + //============================================================================== // Prints a string in the status window -.c0a5c_printstr: +c0a5c_printstr: push {r0-r2,lr} mov r0,r1 mov r1,r2 mov r2,r3 -bl m2_vwf.print_string +bl print_string pop {r0-r2,pc} //============================================================================== // Prints an empty space instead of the "Press A for PSI info" string -.c0a5c_psi_info_blank: +c0a5c_psi_info_blank: push {lr} -mov r0,#5 -mov r1,#0xF -mov r2,#0x14 -bl m2_vwf.print_blankstr +mov r0,5 +mov r1,0xF +mov r2,0x14 +bl print_blankstr pop {pc} //============================================================================== // Redraws the status window (when exiting the PSI submenu, etc.) -.bac18_redraw_status: +bac18_redraw_status: push {r4,lr} -ldr r4,=#0x3005230 -ldr r4,[r4,#0x18] +ldr r4,=0x3005230 +ldr r4,[r4,0x18] // Get the address of the status text -ldr r0,=#0x8B17EE4 -ldr r1,=#0x8B17424 -mov r2,#0x11 -bl $80BE260 +ldr r0,=0x8B17EE4 +ldr r1,=0x8B17424 +mov r2,0x11 +bl 0x80BE260 // Prepare the window for parsing mov r1,r0 mov r0,r4 -mov r2,#0 -bl $80BE458 +mov r2,0 +bl 0x80BE458 // Render text mov r0,r4 -bl $80C8FFC +bl 0x80C8FFC // Render numbers mov r0,r4 -mov r1,#0 -bl $80C0A5C +mov r1,0 +bl 0x80C0A5C pop {r4,pc} +.pool + //============================================================================== // Clears the PSI window when switching classes // r5 = 0x3005230 -.bac18_clear_psi: +bac18_clear_psi: push {r0,lr} -ldr r0,[r5,#0x20] // PSI class window pointer -ldrb r0,[r0,#0] -mov r1,#0x10 +ldr r0,[r5,0x20] // PSI class window pointer +ldrb r0,[r0,0] +mov r1,0x10 and r0,r1 -cmp r0,#0 -beq + +cmp r0,0 +beq @@next // If flag 0x10 is set, clear the PSI window -ldr r0,[r5,#0x1C] // PSI window -mov r1,#4 -bl m2_vwf.clear_window +ldr r0,[r5,0x1C] // PSI window +mov r1,4 +bl clear_window -+ +@@next: // Clobbered code pop {r0} -lsl r0,r0,#0x10 -asr r4,r0,#0x10 +lsl r0,r0,0x10 +asr r4,r0,0x10 pop {pc} //============================================================================== // Only clear+redraw the PSI help if a button has been pressed -.bac18_check_button: +bac18_check_button: push {lr} -ldr r0,=#0x3002500 -ldrh r0,[r0,#0] -cmp r0,#0 -beq + +ldr r0,=0x3002500 +ldrh r0,[r0,0] +cmp r0,0 +beq @@next // Clear window -ldr r0,[r5,#0x28] +ldr r0,[r5,0x28] mov r1,r2 -mov r2,#0 -bl $80BE458 +mov r2,0 +bl 0x80BE458 // Render window -ldr r0,[r5,#0x28] -bl $80C8BE4 +ldr r0,[r5,0x28] +bl 0x80C8BE4 -+ +@@next: pop {pc} +.pool //============================================================================== // Clear offense/defense changes when switching in equip select window -.c5500_clear_up: +c5500_clear_up: push {r1-r2,lr} -mov r0,#0xD -mov r1,#0xB -mov r2,#0x3 -bl m2_vwf.print_blankstr -add r1,#2 -bl m2_vwf.print_blankstr +mov r0,0xD +mov r1,0xB +mov r2,0x3 +bl print_blankstr +add r1,2 +bl print_blankstr // Clobbered code -sub r0,r3,#1 -strh r0,[r7,#0x36] +sub r0,r3,1 +strh r0,[r7,0x36] pop {r1-r2,pc} -.c5500_clear_down: +c5500_clear_down: push {r0-r2,lr} -mov r0,#0xD -mov r1,#0xB -mov r2,#0x3 -bl m2_vwf.print_blankstr -add r1,#2 -bl m2_vwf.print_blankstr +mov r0,0xD +mov r1,0xB +mov r2,0x3 +bl print_blankstr +add r1,2 +bl print_blankstr // Clobbered code pop {r0-r2} -add r0,#1 -strh r0,[r7,#0x36] +add r0,1 +strh r0,[r7,0x36] pop {pc} //============================================================================== // Clear offense/defense when re-equipping (or un-equipping) something -.baef8_reequip_erase: +baef8_reequip_erase: push {r1,lr} -mov r0,#8 -mov r1,#0xB -mov r2,#4 -bl m2_vwf.print_blankstr -add r1,#2 -bl m2_vwf.print_blankstr +mov r0,8 +mov r1,0xB +mov r2,4 +bl print_blankstr +add r1,2 +bl print_blankstr // Clobbered code pop {r1} -mov r0,#2 -strh r0,[r1,#0] +mov r0,2 +strh r0,[r1,0] pop {pc} //============================================================================== // Redraw main menu when exiting PSI target window -.b8bbc_redraw_menu_2to1: +b8bbc_redraw_menu_2to1: push {r1-r4,lr} -add sp,#-4 +add sp,-4 // Copied from 80B7A74 -mov r0,#0 -str r0,[sp,#0] -ldr r0,=#0x3005230 -ldr r0,[r0,#0] // main menu window pointer -ldr r1,[r0,#4] // text pointer -mov r2,#5 -mov r3,#2 +mov r0,0 +str r0,[sp,0] +ldr r0,=0x3005230 +ldr r0,[r0,0] // main menu window pointer +ldr r1,[r0,4] // text pointer +mov r2,5 +mov r3,2 mov r4,r0 -bl $80BE4C8 +bl 0x80BE4C8 mov r0,r4 -bl $80C8BE4 +bl 0x80C8BE4 // Clobbered code (restore the window borders, etc.) -mov r0,#1 -bl $80BD7AC +mov r0,1 +bl 0x80BD7AC -add sp,#4 +add sp,4 pop {r1-r4,pc} +.pool //============================================================================== // Redraw main menu when entering PSI target window -.b8bbc_redraw_menu_13to2: +b8bbc_redraw_menu_13to2: push {r1-r4,lr} -add sp,#-4 +add sp,-4 // Copied from 80B7A74 -mov r0,#0 -str r0,[sp,#0] -ldr r0,=#0x3005230 -ldr r0,[r0,#0] // main menu window pointer -ldr r1,[r0,#4] // text pointer -mov r2,#5 -mov r3,#2 +mov r0,0 +str r0,[sp,0] +ldr r0,=0x3005230 +ldr r0,[r0,0] // main menu window pointer +ldr r1,[r0,4] // text pointer +mov r2,5 +mov r3,2 mov r4,r0 -bl $80BE4C8 +bl 0x80BE4C8 mov r0,r4 -bl $80C8BE4 +bl 0x80C8BE4 // Clobbered code (restore the window borders, etc.) -mov r0,#1 -bl $80BD7F8 +mov r0,1 +bl 0x80BD7F8 -add sp,#4 +add sp,4 pop {r1-r4,pc} +.pool //============================================================================== // Print a space before the Greek letter -.d3934_print_space: +d3934_print_space: push {lr} mov r0,r4 -bl m2_vwf.print_space +bl print_space // Clobbered code -ldrb r1,[r3,#1] -lsl r0,r1,#1 +ldrb r1,[r3,1] +lsl r0,r1,1 pop {pc} //============================================================================== @@ -561,7 +575,7 @@ pop {pc} // r7: source tilemap // r8: y (dest, relative) // r10: 3005270 -.ca4bc_copy_tile_up: +ca4bc_copy_tile_up: push {r4-r7,lr} // Four cases: @@ -579,69 +593,70 @@ push {r4-r7,lr} // Check blank by comparing tilemap with 0xE2FF // 0xE2FF is already stored to [sp+(# of regs pushed * 4)] -ldr r0,[sp,#20] -ldrh r1,[r7,#0] -ldrh r2,[r5,#0] +ldr r0,[sp,20] +ldrh r1,[r7,0] +ldrh r2,[r5,0] cmp r1,r0 -bne + +bne @@next cmp r2,r0 -bne .ca4bc_blank_to_nonblank +bne @@blank_to_nonblank // Case 1: blank to blank -b .ca4bc_end +b @@end -+ +@@next: cmp r2,r0 -bne .ca4bc_nonblank_to_nonblank +bne @@nonblank_to_nonblank // Case 3: non-blank to blank -.ca4bc_nonblank_to_blank: +@@nonblank_to_blank: // Copy pixels up - ldrh r0,[r6,#0x22] - lsl r0,r0,#16 + ldrh r0,[r6,0x22] + lsl r0,r0,16 add r0,r0,r4 - lsr r0,r0,#16 // x - ldrh r1,[r6,#0x24] + lsr r0,r0,16 // x + ldrh r1,[r6,0x24] add r1,r8 // dest y mov r4,r1 - add r1,#2 // source y - bl m2_vwf.copy_tile_up + add r1,2 // source y + bl copy_tile_up // Set proper tilemap mov r1,r4 // dest y - bl m2_vwf.get_tile_number - ldr r1,=#0x30051EC - ldrh r2,[r1,#0] + bl get_tile_number + ldr r1,=0x30051EC + ldrh r2,[r1,0] add r0,r0,r2 // dest tile number - ldrh r1,[r1,#0x3C] // 0xE000 + ldrh r1,[r1,0x3C] // 0xE000 orr r0,r1 - strh r0,[r5,#0] - b .ca4bc_end + strh r0,[r5,0] + b @@end // Case 2: blank to non-blank -.ca4bc_blank_to_nonblank: +@@blank_to_nonblank: // Set dest tilemap to 0xE2FF - strh r0,[r5,#0] + strh r0,[r5,0] // Case 4: non-blank to non-blank -.ca4bc_nonblank_to_nonblank: +@@nonblank_to_nonblank: // Copy pixels up - ldrh r0,[r6,#0x22] - lsl r0,r0,#16 + ldrh r0,[r6,0x22] + lsl r0,r0,16 add r0,r0,r4 - lsr r0,r0,#16 // x - ldrh r1,[r6,#0x24] + lsr r0,r0,16 // x + ldrh r1,[r6,0x24] add r1,r8 // dest y - add r1,#2 // source y - bl m2_vwf.copy_tile_up - b .ca4bc_end + add r1,2 // source y + bl copy_tile_up + b @@end -.ca4bc_end: +@@end: pop {r4-r7,pc} +.pool //============================================================================== // Erase tile (for short windows) @@ -650,279 +665,286 @@ pop {r4-r7,pc} // r5: dest tilemap // r6: window // r8: y (dest, relative) -.ca4bc_erase_tile_short: +ca4bc_erase_tile_short: push {lr} -add sp,#-12 +add sp,-12 // Clobbered code orr r0,r1 // 0xE2FF -strh r0,[r5,#0] // dest tilemap +strh r0,[r5,0] // dest tilemap // We need to erase the pixels -.ca4bc_erase_tile_common: +ca4bc_erase_tile_common: mov r0,sp -strh r2,[r0,#8] // tile offset -ldr r2,=#0x44444444 -str r2,[r0,#4] // empty row of pixels -ldrh r2,[r6,#0x22] -lsl r2,r2,#16 +strh r2,[r0,8] // tile offset +ldr r2,=0x44444444 +str r2,[r0,4] // empty row of pixels +ldrh r2,[r6,0x22] +lsl r2,r2,16 add r2,r2,r4 -lsr r2,r2,#16 // x -ldrh r1,[r6,#0x24] +lsr r2,r2,16 // x +ldrh r1,[r6,0x24] add r1,r8 // y -strh r2,[r0,#0] -strh r1,[r0,#2] -bl m2_vwf.clear_tile_internal +strh r2,[r0,0] +strh r1,[r0,2] +bl clear_tile_internal -add sp,#12 +add sp,12 pop {pc} +.pool //============================================================================== // Erase tile -.ca4bc_erase_tile: +ca4bc_erase_tile: push {lr} -add sp,#-12 +add sp,-12 // Clobbered code -ldrh r1,[r1,#0] -strh r1,[r5,#0] +ldrh r1,[r1,0] +strh r1,[r5,0] // We need to erase the pixels -ldr r2,=#0x30051EC -ldrh r2,[r2,#0] -b .ca4bc_erase_tile_common +ldr r2,=0x30051EC +ldrh r2,[r2,0] +b ca4bc_erase_tile_common +.pool //============================================================================== // Clear PSI window when scrolling through classes -.e06ec_clear_window: +e06ec_clear_window: push {r0-r1,lr} -ldr r0,=#0x3002500 -ldrh r0,[r0,#0] -cmp r0,#0 -beq + -ldr r0,=#0x3005230 -ldr r0,[r0,#0x1C] -mov r1,#4 -bl m2_vwf.clear_window +ldr r0,=0x3002500 +ldrh r0,[r0,0] +cmp r0,0 +beq @@next +ldr r0,=0x3005230 +ldr r0,[r0,0x1C] +mov r1,4 +bl clear_window -+ +@@next: pop {r0-r1} // Clobbered code -lsl r0,r0,#0x10 -asr r4,r0,#0x10 +lsl r0,r0,0x10 +asr r4,r0,0x10 pop {pc} +.pool //============================================================================== // Redraw PSI command when exiting PSI subwindow -.e06ec_redraw_psi: +e06ec_redraw_psi: push {r0-r3,lr} // Clear old tiles -mov r0,#2 -mov r1,#3 -mov r2,#1 -bl m2_vwf.print_blankstr +mov r0,2 +mov r1,3 +mov r2,1 +bl print_blankstr // Render PSI string -add sp,#-4 -ldr r0,=#0x80DC1EC // address of PSI string pointer -ldr r1,[r0,#0] // PSI string pointer -ldr r0,=#0x3005230 -ldr r0,[r0,#0] // window pointer -mov r2,#1 // highlight -str r2,[sp,#0] -mov r2,#1 -mov r3,#1 -bl $80C96F0 // render string -add sp,#4 +add sp,-4 +ldr r0,=0x80DC1EC // address of PSI string pointer +ldr r1,[r0,0] // PSI string pointer +ldr r0,=0x3005230 +ldr r0,[r0,0] // window pointer +mov r2,1 // highlight +str r2,[sp,0] +mov r2,1 +mov r3,1 +bl 0x80C96F0 // render string +add sp,4 // Clobbered code pop {r0-r3} -bl $80BD7F8 // restore tilemaps +bl 0x80BD7F8 // restore tilemaps pop {pc} +.pool //============================================================================== // Redraw Bash/Do Nothing and PSI commands when exiting PSI ally target subwindow -.e06ec_redraw_bash_psi: +e06ec_redraw_bash_psi: push {r0-r3,lr} -add sp,#-4 +add sp,-4 // Clear old tiles -mov r0,#2 -mov r1,#1 -mov r2,#1 -bl m2_vwf.print_blankstr -add r1,#2 -bl m2_vwf.print_blankstr +mov r0,2 +mov r1,1 +mov r2,1 +bl print_blankstr +add r1,2 +bl print_blankstr // We need to figure out whether to draw Bash or Do Nothing // If [0x2025122] == 2, draw Do Nothing; else, draw Bash // We'll never draw Shoot because Jeff doesn't use PSI -ldr r0,=#0x2025122 -ldrh r0,[r0,#0] -cmp r0,#2 -beq .e06ec_redraw_donothing -ldr r0,=#0x80DBFB0 -b + -.e06ec_redraw_donothing: -ldr r0,=#0x80DC108 -+ -ldr r1,[r0,#0] -ldr r0,=#0x3005230 -ldr r0,[r0,#0] // window pointer -mov r2,#0 // no highlight -str r2,[sp,#0] -mov r2,#1 -mov r3,#0 -bl $80C96F0 // render string +ldr r0,=0x2025122 +ldrh r0,[r0,0] +cmp r0,2 +beq @@donothing +ldr r0,=0x80DBFB0 +b @@next +@@donothing: +ldr r0,=0x80DC108 +@@next: +ldr r1,[r0,0] +ldr r0,=0x3005230 +ldr r0,[r0,0] // window pointer +mov r2,0 // no highlight +str r2,[sp,0] +mov r2,1 +mov r3,0 +bl 0x80C96F0 // render string // Render PSI string -ldr r0,=#0x80DC1EC // address of PSI string pointer -ldr r1,[r0,#0] // PSI string pointer -ldr r0,=#0x3005230 -ldr r0,[r0,#0] // window pointer -mov r2,#1 // highlight -str r2,[sp,#0] -mov r2,#1 -mov r3,#1 -bl $80C96F0 // render string -add sp,#4 +ldr r0,=0x80DC1EC // address of PSI string pointer +ldr r1,[r0,0] // PSI string pointer +ldr r0,=0x3005230 +ldr r0,[r0,0] // window pointer +mov r2,1 // highlight +str r2,[sp,0] +mov r2,1 +mov r3,1 +bl 0x80C96F0 // render string +add sp,4 // Clobbered code pop {r0-r3} -bl $80BD7F8 // restore tilemaps +bl 0x80BD7F8 // restore tilemaps pop {pc} +.pool //============================================================================== // Print "PSI " -.c239c_print_psi: +c239c_print_psi: push {lr} -add sp,#-4 -mov r2,#0 -str r2,[sp,#0] +add sp,-4 +mov r2,0 +str r2,[sp,0] mov r2,r4 -lsl r3,r3,#3 // tiles-to-pixels -bl m2_vwf.print_string_hlight_pixels -add sp,#4 +lsl r3,r3,3 // tiles-to-pixels +bl print_string_hlight_pixels +add sp,4 pop {pc} //============================================================================== // Use new pointer for user/target strings -.ebfd4_user_pointer: +ebfd4_user_pointer: push {lr} -mov r4,#0x4C -lsl r4,r4,#4 +mov r4,0x4C +lsl r4,r4,4 add r0,r0,r4 mov r5,r0 -lsl r4,r1,#0x10 -asr r4,r4,#0x10 +lsl r4,r1,0x10 +asr r4,r4,0x10 mov r1,r2 mov r2,r4 -bl $80F4C78 +bl 0x80F4C78 add r0,r4,r5 -mov r1,#0 -strb r1,[r0,#0] -mov r1,#0xFF -strb r1,[r0,#1] +mov r1,0 +strb r1,[r0,0] +mov r1,0xFF +strb r1,[r0,1] pop {pc} -.ec004_user_pointer: +ec004_user_pointer: push {r1} -ldr r1,[sp,#4] +ldr r1,[sp,4] mov lr,r1 pop {r1} -add sp,#4 -ldr r0,=#0x3005220 -ldr r0,[r0,#0] -mov r1,#0x4C -lsl r1,r1,#4 +add sp,4 +ldr r0,=0x3005220 +ldr r0,[r0,0] +mov r1,0x4C +lsl r1,r1,4 add r0,r0,r1 bx lr -.ec010_target_pointer: +ec010_target_pointer: push {lr} -mov r4,#0x50 -lsl r4,r4,#4 +mov r4,0x50 +lsl r4,r4,4 add r0,r0,r4 mov r5,r0 -lsl r4,r1,#0x10 -asr r4,r4,#0x10 +lsl r4,r1,0x10 +asr r4,r4,0x10 mov r1,r2 mov r2,r4 -bl $80F4C78 +bl 0x80F4C78 add r0,r4,r5 -mov r1,#0 -strb r1,[r0,#0] -mov r1,#0xFF -strb r1,[r0,#1] +mov r1,0 +strb r1,[r0,0] +mov r1,0xFF +strb r1,[r0,1] pop {pc} -.ec046_target_pointer: +ec046_target_pointer: push {r1} -ldr r1,[sp,#4] +ldr r1,[sp,4] mov lr,r1 pop {r1} -add sp,#4 -ldr r0,[r0,#0] -mov r1,#0x50 -lsl r1,r1,#4 +add sp,4 +ldr r0,[r0,0] +mov r1,0x50 +lsl r1,r1,4 add r0,r0,r1 bx lr -.c980c_user_pointer: -ldr r1,[r0,#0] -mov r0,#0x4C -lsl r0,r0,#4 +c980c_user_pointer: +ldr r1,[r0,0] +mov r0,0x4C +lsl r0,r0,4 add r1,r0,r1 -ldr r0,[r5,#0x1C] +ldr r0,[r5,0x1C] bx lr -.c980c_target_pointer: -ldr r0,[r0,#0] -mov r7,#0x50 -lsl r7,r7,#4 +c980c_target_pointer: +ldr r0,[r0,0] +mov r7,0x50 +lsl r7,r7,4 add r0,r0,r7 bx lr +.pool //============================================================================== // Add a space between enemy name and letter in multi-enemy fights -.dcd00_enemy_letter: -sub r0,#0x90 -strb r0,[r5,#1] -mov r0,#0x50 -strb r0,[r5,#0] +dcd00_enemy_letter: +sub r0,0x90 +strb r0,[r5,1] +mov r0,0x50 +strb r0,[r5,0] bx lr -.dae00_enemy_letter: -sub r0,#0x90 -strb r0,[r4,#1] -mov r0,#0x50 -strb r0,[r4,#0] +dae00_enemy_letter: +sub r0,0x90 +strb r0,[r4,1] +mov r0,0x50 +strb r0,[r4,0] bx lr //============================================================================== // "The" flag checks -.db04c_theflag: +db04c_theflag: push {r4,lr} // Clobbered code: get enemy string pointer -lsl r4,r2,#1 -bl $80BE260 +lsl r4,r2,1 +bl 0x80BE260 mov r1,r0 mov r0,sp -add r0,#8 +add r0,8 // Check for "The" flag -ldr r3,=#m2_enemy_attributes +ldr r3,=m2_enemy_attributes ldrb r3,[r3,r4] // "The" flag -cmp r3,#0 -beq + +cmp r3,0 +beq @@next // Write "The " before the enemy name -ldr r2,=#0x50959884 -str r2,[r0,#0] -add r0,#4 +ldr r2,=0x50959884 +str r2,[r0,0] +add r0,4 -+ +@@next: pop {r4,pc} +.pool diff --git a/m2-vwf.asm b/m2-vwf.asm index 34defa1..3f50f82 100644 --- a/m2-vwf.asm +++ b/m2-vwf.asm @@ -1,5 +1,3 @@ -m2_vwf: - //============================================================================== // int get_tile_number(int x, int y) // In: @@ -9,26 +7,27 @@ m2_vwf: // r0: tile number //============================================================================== -.get_tile_number: +get_tile_number: push {r1-r5,lr} -ldr r4,=#m2_coord_table -sub r0,r0,#1 -sub r1,r1,#1 -lsl r2,r1,#0x1F -lsr r2,r2,#0x1F -lsr r1,r1,#1 -lsl r5,r1,#4 +ldr r4,=m2_coord_table +sub r0,r0,1 +sub r1,r1,1 +lsl r2,r1,0x1F +lsr r2,r2,0x1F +lsr r1,r1,1 +lsl r5,r1,4 sub r5,r5,r1 sub r5,r5,r1 -lsl r5,r5,#2 -lsl r0,r0,#1 +lsl r5,r5,2 +lsl r0,r0,1 add r4,r4,r0 add r4,r4,r5 -ldrh r0,[r4,#0] -lsl r2,r2,#5 +ldrh r0,[r4,0] +lsl r2,r2,5 add r0,r0,r2 pop {r1-r5,pc} +.pool //============================================================================== @@ -39,50 +38,50 @@ pop {r1-r5,pc} //============================================================================== //-------------------------------- -.weld_entry: +weld_entry: push {r0-r5,lr} // Check for valid character value mov r4,r0 -ldrb r0,[r1,#0] -sub r0,#0x50 -bpl + -mov r0,#0x1F -b .weld_entry_valid -+ -cmp r0,#0x60 -bcc .weld_entry_valid -mov r0,#0x1F +ldrb r0,[r1,0] +sub r0,0x50 +bpl @@next +mov r0,0x1F +b @@valid +@@next: +cmp r0,0x60 +bcc @@valid +mov r0,0x1F -.weld_entry_valid: +@@valid: // Calculate X coord -ldrh r1,[r4,#0x22] // window_X +ldrh r1,[r4,0x22] // window_X mov r5,r1 -ldrh r2,[r4,#0x2A] // text_X +ldrh r2,[r4,0x2A] // text_X add r1,r1,r2 -lsl r1,r1,#3 -ldrh r2,[r4,#2] // pixel_X +lsl r1,r1,3 +ldrh r2,[r4,2] // pixel_X add r1,r1,r2 // screen pixel X // Calculate Y coord -ldrh r2,[r4,#0x24] // window_Y -ldrh r3,[r4,#0x2C] // text_Y +ldrh r2,[r4,0x24] // window_Y +ldrh r3,[r4,0x2C] // text_Y add r2,r2,r3 -lsl r2,r2,#3 +lsl r2,r2,3 // Print -mov r3,#0 // font -bl .print_character +mov r3,0 // font +bl print_character // Store new X coords add r0,r0,r1 // new screen pixel_X -lsr r1,r0,#3 +lsr r1,r0,3 sub r1,r1,r5 // new text_X -strh r1,[r4,#0x2A] -lsl r0,r0,#29 -lsr r0,r0,#29 // new pixel_X -strh r0,[r4,#2] +strh r1,[r4,0x2A] +lsl r0,r0,29 +lsr r0,r0,29 // new pixel_X +strh r0,[r4,2] pop {r0-r5,pc} @@ -98,26 +97,26 @@ pop {r0-r5,pc} // r1: number of pixels printed //============================================================================= -.print_string: +print_string: push {r2-r6,lr} -mov r3,#0 +mov r3,0 mov r5,r3 mov r6,r1 mov r4,r0 -- -ldrb r0,[r4,#1] -cmp r0,#0xFF -beq .print_string_end -ldrb r0,[r4,#0] -sub r0,#0x50 -bl .print_character +@@prev: +ldrb r0,[r4,1] +cmp r0,0xFF +beq @@end +ldrb r0,[r4,0] +sub r0,0x50 +bl print_character add r1,r0,r1 -add r4,#1 -add r5,#1 -b - +add r4,1 +add r5,1 +b @@prev -.print_string_end: +@@end: mov r0,r5 sub r1,r1,r6 pop {r2-r6,pc} @@ -137,52 +136,53 @@ pop {r2-r6,pc} // r1: number of pixels printed //============================================================================= -.print_string_hlight_pixels: +print_string_hlight_pixels: // Copied from C96F0 // Basically it's the exact same subroutine, only in pixels instead of tiles push {r4-r7,lr} mov r7,r8 push {r7} mov r6,r1 -ldr r1,[sp,#0x18] -lsl r1,r1,#0x10 -mov r7,#0 -ldr r5,=#0x3005228 -ldrh r4,[r5,#0] -lsl r4,r4,#0x10 -asr r4,r4,#0x1C +ldr r1,[sp,0x18] +lsl r1,r1,0x10 +mov r7,0 +ldr r5,=0x3005228 +ldrh r4,[r5,0] +lsl r4,r4,0x10 +asr r4,r4,0x1C mov r8,r4 -lsr r4,r1,#0x10 +lsr r4,r1,0x10 mov r12,r4 -asr r1,r1,#0x10 +asr r1,r1,0x10 add r1,r8 -lsl r1,r1,#0xC -strh r1,[r5,#0] -ldrh r1,[r0,#0x22] -lsl r1,r1,#3 +lsl r1,r1,0xC +strh r1,[r5,0] +ldrh r1,[r0,0x22] +lsl r1,r1,3 add r1,r1,r2 -ldrh r2,[r0,#0x24] -lsl r2,r2,#3 +ldrh r2,[r0,0x24] +lsl r2,r2,3 add r2,r2,r3 mov r0,r6 -bl .print_string +bl print_string mov r7,r0 -ldrh r0,[r5,#0] -lsl r0,r0,#0x10 -asr r0,r0,#0x1C +ldrh r0,[r5,0] +lsl r0,r0,0x10 +asr r0,r0,0x1C mov r4,r12 -lsl r3,r4,#0x10 -asr r3,r3,#0x10 +lsl r3,r4,0x10 +asr r3,r3,0x10 sub r0,r0,r3 -lsl r0,r0,#0xC -strh r0,[r5,#0] -lsl r0,r7,#0x10 -asr r0,r0,#0x10 +lsl r0,r0,0xC +strh r0,[r5,0] +lsl r0,r7,0x10 +asr r0,r0,0x10 pop {r3} mov r8,r3 pop {r4-r7} pop {r2} bx r2 +.pool //============================================================================= @@ -199,7 +199,7 @@ bx r2 // r0: virtual width //============================================================================= -.print_character: +print_character: push {r1-r7,lr} mov r4,r8 @@ -209,7 +209,7 @@ mov r7,r11 push {r4-r7} mov r4,r12 push {r4} -add sp,#-24 +add sp,-24 mov r10,r1 mov r11,r2 @@ -217,180 +217,180 @@ mov r12,r0 mov r5,r3 //---------------------------------------- -ldr r3,=#0x30051EC -ldrh r4,[r3,#0] // Tile offset -add r3,#0x3C -ldrh r6,[r3,#0] // Palette mask -add r3,#0x48 -ldr r7,[r3,#0] // Tilemap address -lsr r1,r1,#3 -lsr r2,r2,#3 -lsl r2,r2,#5 +ldr r3,=0x30051EC +ldrh r4,[r3,0] // Tile offset +add r3,0x3C +ldrh r6,[r3,0] // Palette mask +add r3,0x48 +ldr r7,[r3,0] // Tilemap address +lsr r1,r1,3 +lsr r2,r2,3 +lsl r2,r2,5 add r1,r1,r2 -lsl r1,r1,#1 +lsl r1,r1,1 add r7,r7,r1 // Local tilemap address mov r8,r4 //---------------------------------------- -ldr r0,=#m2_widths_table -lsl r1,r5,#2 // Font number * 4 +ldr r0,=m2_widths_table +lsl r1,r5,2 // Font number * 4 ldr r0,[r0,r1] mov r3,r12 // Character -lsl r2,r3,#1 +lsl r2,r3,1 ldrb r1,[r0,r2] // Virtual width mov r9,r1 -add r2,r2,#1 +add r2,r2,1 ldrb r0,[r0,r2] // Render width -cmp r0,#0 -beq + // Don't bother rendering a zero-width character -ldr r2,=#m2_height_table +cmp r0,0 +beq @@next // Don't bother rendering a zero-width character +ldr r2,=m2_height_table ldrb r2,[r2,r5] -str r2,[sp,#16] // No more registers, gotta store this on the stack +str r2,[sp,16] // No more registers, gotta store this on the stack mov r3,sp -strb r0,[r3,#9] -strb r2,[r3,#12] +strb r0,[r3,9] +strb r2,[r3,12] mov r1,r10 -lsl r1,r1,#29 -lsr r1,r1,#29 -strb r1,[r3,#8] -mov r1,#4 -strb r1,[r3,#10] -mov r1,#0xF -strb r1,[r3,#11] +lsl r1,r1,29 +lsr r1,r1,29 +strb r1,[r3,8] +mov r1,4 +strb r1,[r3,10] +mov r1,0xF +strb r1,[r3,11] //---------------------------------------- mov r0,r10 mov r1,r11 -lsr r0,r0,#3 -lsr r1,r1,#3 -bl .get_tile_number +lsr r0,r0,3 +lsr r1,r1,3 +bl get_tile_number add r4,r0,r4 -lsl r0,r4,#5 -mov r1,#6 -lsl r1,r1,#0x18 +lsl r0,r4,5 +mov r1,6 +lsl r1,r1,0x18 add r0,r0,r1 // VRAM address -str r0,[sp,#0] +str r0,[sp,0] //---------------------------------------- -ldr r0,=#m2_font_table -lsl r1,r5,#2 +ldr r0,=m2_font_table +lsl r1,r5,2 ldr r0,[r0,r1] mov r1,r12 -lsl r1,r1,#5 +lsl r1,r1,5 add r0,r0,r1 // Glyph address -str r0,[sp,#4] +str r0,[sp,4] //---------------------------------------- // Render left portion mov r0,sp -bl .print_left +bl print_left //---------------------------------------- // Update the map orr r4,r6 mov r1,r7 -- -strh r4,[r1,#0] -add r4,#0x20 -add r1,#0x40 -sub r2,r2,#1 -bne - -add r7,r7,#2 +@@prev2: +strh r4,[r1,0] +add r4,0x20 +add r1,0x40 +sub r2,r2,1 +bne @@prev2 +add r7,r7,2 //---------------------------------------- // Now we've rendered the left portion; // we need to determine whether or not to render the right portion -ldrb r1,[r0,#8] // VRAM x offset -str r1,[sp,#20] // No more registers, gotta store this on the stack -ldrb r2,[r0,#9] // Render width +ldrb r1,[r0,8] // VRAM x offset +str r1,[sp,20] // No more registers, gotta store this on the stack +ldrb r2,[r0,9] // Render width add r2,r1,r2 -cmp r2,#8 -bls + +cmp r2,8 +bls @@next // We still have more to render; figure out how much we already rendered -mov r3,#8 +mov r3,8 sub r3,r3,r1 -strb r3,[r0,#8] +strb r3,[r0,8] // Allocate a new tile mov r0,r10 mov r1,r11 -lsr r0,r0,#3 -add r0,r0,#1 -lsr r1,r1,#3 -bl .get_tile_number +lsr r0,r0,3 +add r0,r0,1 +lsr r1,r1,3 +bl get_tile_number add r0,r8 mov r4,r0 -lsl r0,r0,#5 -mov r1,#6 -lsl r1,r1,#0x18 +lsl r0,r0,5 +mov r1,6 +lsl r1,r1,0x18 add r0,r0,r1 -str r0,[sp,#0] +str r0,[sp,0] mov r0,sp -bl .print_right +bl print_right //---------------------------------------- // Update the map orr r4,r6 mov r1,r7 -ldr r2,[sp,#16] -- -strh r4,[r1,#0] -add r4,#0x20 -add r1,#0x40 -sub r2,r2,#1 -bne - -add r7,r7,#2 +ldr r2,[sp,16] +@@prev3: +strh r4,[r1,0] +add r4,0x20 +add r1,0x40 +sub r2,r2,1 +bne @@prev3 +add r7,r7,2 //---------------------------------------- // Now we've rendered the left and right portions; // we need to determin whether or not to do a final // right portion for super wide characters -ldr r1,[sp,#20] // Original pixel X offset -ldrb r2,[r0,#9] // Render width +ldr r1,[sp,20] // Original pixel X offset +ldrb r2,[r0,9] // Render width add r2,r1,r2 // Right side of glyph -cmp r2,#16 -bls + +cmp r2,16 +bls @@next // We have one more chunk to render; figure out how much we already rendered -mov r3,#16 +mov r3,16 sub r3,r3,r1 -strb r3,[r0,#8] +strb r3,[r0,8] // Allocate a new tile mov r0,r10 mov r1,r11 -lsr r0,r0,#3 -add r0,r0,#2 -lsr r1,r1,#3 -bl .get_tile_number +lsr r0,r0,3 +add r0,r0,2 +lsr r1,r1,3 +bl get_tile_number add r0,r8 mov r4,r0 -lsl r0,r0,#5 -mov r1,#6 -lsl r1,r1,#0x18 +lsl r0,r0,5 +mov r1,6 +lsl r1,r1,0x18 add r0,r0,r1 -str r0,[sp,#0] +str r0,[sp,0] mov r0,sp -bl .print_right +bl print_right //---------------------------------------- // Update the map orr r4,r6 mov r1,r7 -ldr r2,[sp,#16] -- -strh r4,[r1,#0] -add r4,#0x20 -add r1,#0x40 -sub r2,r2,#1 -bne - -add r7,r7,#2 +ldr r2,[sp,16] +@@prev4: +strh r4,[r1,0] +add r4,0x20 +add r1,0x40 +sub r2,r2,1 +bne @@prev4 +add r7,r7,2 //---------------------------------------- -+ +@@next: mov r0,r9 -add sp,#24 +add sp,24 pop {r4} mov r12,r4 pop {r4-r7} @@ -399,6 +399,7 @@ mov r9,r5 mov r10,r6 mov r11,r7 pop {r1-r7,pc} +.pool //============================================================================= @@ -416,47 +417,47 @@ pop {r1-r7,pc} // [r0+12]: height in tiles (byte) // [r0+13]: (3 bytes) -.print_left: +print_left: push {r0-r7,lr} mov r7,r0 //---------------------------------------- -ldr r6,[r7,#0] // VRAM address -ldr r3,[r7,#4] // Glyph address -ldrb r4,[r7,#12] // Height in tiles +ldr r6,[r7,0] // VRAM address +ldr r3,[r7,4] // Glyph address +ldrb r4,[r7,12] // Height in tiles -.print_left_loop: -mov r5,#8 -- -ldr r0,[r6,#0] // 4BPP VRAM row -ldrb r1,[r7,#11] // Foreground index -bl .reduce_bit_depth // Returns r0 = 1BPP VRAM row -ldrb r1,[r7,#9] // Glyph render width -mov r2,#32 +@@loop: +mov r5,8 +@@prev: +ldr r0,[r6,0] // 4BPP VRAM row +ldrb r1,[r7,11] // Foreground index +bl reduce_bit_depth // Returns r0 = 1BPP VRAM row +ldrb r1,[r7,9] // Glyph render width +mov r2,32 sub r2,r2,r1 -ldrb r1,[r3,#0] // Glyph row +ldrb r1,[r3,0] // Glyph row lsl r1,r2 // Cut off the pixels we don't want to render lsr r1,r2 -ldrb r2,[r7,#8] // X offset +ldrb r2,[r7,8] // X offset lsl r1,r2 -lsl r1,r1,#0x18 -lsr r1,r1,#0x18 +lsl r1,r1,0x18 +lsr r1,r1,0x18 orr r0,r1 -ldrb r1,[r7,#10] -ldrb r2,[r7,#11] -bl .expand_bit_depth -str r0,[r6,#0] -add r6,r6,#4 -add r3,r3,#1 -sub r5,r5,#1 -bne - -mov r0,#0x1F -lsl r0,r0,#5 +ldrb r1,[r7,10] +ldrb r2,[r7,11] +bl expand_bit_depth +str r0,[r6,0] +add r6,r6,4 +add r3,r3,1 +sub r5,r5,1 +bne @@prev +mov r0,0x1F +lsl r0,r0,5 add r6,r0,r6 -add r3,#8 -sub r4,r4,#1 -bne .print_left_loop +add r3,8 +sub r4,r4,1 +bne @@loop //---------------------------------------- pop {r0-r7,pc} @@ -477,47 +478,47 @@ pop {r0-r7,pc} // [r0+12]: height in tiles (byte) // [r0+13]: (3 bytes) -.print_right: +print_right: push {r0-r7,lr} mov r7,r0 //---------------------------------------- -ldr r6,[r7,#0] // VRAM address -ldr r3,[r7,#4] // Glyph address -ldrb r4,[r7,#12] // Height in tiles +ldr r6,[r7,0] // VRAM address +ldr r3,[r7,4] // Glyph address +ldrb r4,[r7,12] // Height in tiles -.print_right_loop: -mov r5,#8 -- -ldr r0,[r6,#0] // 4BPP VRAM row -ldrb r1,[r7,#11] // Foreground index -bl .reduce_bit_depth // Returns r0 = 1BPP VRAM row -ldrb r1,[r7,#9] // Glyph render width -mov r2,#32 +@@loop: +mov r5,8 +@@prev: +ldr r0,[r6,0] // 4BPP VRAM row +ldrb r1,[r7,11] // Foreground index +bl reduce_bit_depth // Returns r0 = 1BPP VRAM row +ldrb r1,[r7,9] // Glyph render width +mov r2,32 sub r2,r2,r1 -ldrb r1,[r3,#0] // Glyph row +ldrb r1,[r3,0] // Glyph row lsl r1,r2 // Cut off the pixels we don't want to render lsr r1,r2 -ldrb r2,[r7,#8] // X offset +ldrb r2,[r7,8] // X offset lsr r1,r2 -lsl r1,r1,#0x18 -lsr r1,r1,#0x18 +lsl r1,r1,0x18 +lsr r1,r1,0x18 orr r0,r1 -ldrb r1,[r7,#10] -ldrb r2,[r7,#11] -bl .expand_bit_depth -str r0,[r6,#0] -add r6,r6,#4 -add r3,r3,#1 -sub r5,r5,#1 -bne - -mov r0,#0x1F -lsl r0,r0,#5 +ldrb r1,[r7,10] +ldrb r2,[r7,11] +bl expand_bit_depth +str r0,[r6,0] +add r6,r6,4 +add r3,r3,1 +sub r5,r5,1 +bne @@prev +mov r0,0x1F +lsl r0,r0,5 add r6,r0,r6 -add r3,#8 -sub r4,r4,#1 -bne .print_right_loop +add r3,8 +sub r4,r4,1 +bne @@loop //---------------------------------------- pop {r0-r7,pc} @@ -533,10 +534,6 @@ pop {r0-r7,pc} //============================================================================== // Some notes: -// - to go faster, load in constants manually using PC-relative loads -// instead of the ldr rX,=#Y pseudoinstruction (which implicitly branches) -// - in order to do this properly the instructions need to be 32-bit aligned, -// hence there are some alignment hacks below // - the goal is to reduce the 4BPP row of pixels in r0 to a 1BPP row according // to the foreground index in r1 // - this is achieved quickly using a lookup @@ -551,31 +548,25 @@ pop {r0-r7,pc} // there are thus 16^4 = 65536 possible index values and the lookup table will be 64KB // - this uses 63 cycles while the previous method used 273 cycles -// Alignment hack -ldr r0,=#0xDEADBEEF - -.reduce_bit_depth: +reduce_bit_depth: push {r1-r3,lr} -ldr r3,[pc,#32] // 0x11111111 +ldr r3,=0x11111111 mul r1,r3 -ldr r2,[pc,#32] // m2_nybbles_to_bits +ldr r2,=m2_nybbles_to_bits eor r0,r1 -lsl r1,r0,#16 -lsr r1,r1,#16 -lsr r0,r0,#16 +lsl r1,r0,16 +lsr r1,r1,16 +lsr r0,r0,16 ldrb r3,[r2,r0] ldrb r0,[r2,r1] -lsl r3,r3,#4 +lsl r3,r3,4 orr r0,r3 pop {r1-r3,pc} +.pool -// Literal pool -ldr r0,=#0xDEADBEEF -dd 0x11111111 -dd m2_nybbles_to_bits //============================================================================== @@ -596,35 +587,30 @@ dd m2_nybbles_to_bits // - XOR the two values together to get the final 4BPP row of pixels // - this uses 61 cycles while the previous method used 287 cycles -// Alignment hack -ldr r0,=#0xDEADBEEF - -.expand_bit_depth: +expand_bit_depth: push {r1-r6,lr} -ldr r6,[pc,#36] // m2_bits_to_nybbles +ldr r6,=m2_bits_to_nybbles // Foreground -lsl r4,r2,#10 -lsl r3,r0,#2 +lsl r4,r2,10 +lsl r3,r0,2 add r5,r4,r6 ldr r2,[r5,r3] // Background -lsl r4,r1,#10 +lsl r4,r1,10 add r5,r4,r6 -mov r4,#0xFF +mov r4,0xFF eor r0,r4 -lsl r3,r0,#2 +lsl r3,r0,2 ldr r1,[r5,r3] orr r2,r1 mov r0,r2 pop {r1-r6,pc} +.pool -// Literal pool -ldr r0,=#0xDEADBEEF -dd m2_bits_to_nybbles //============================================================================== @@ -635,32 +621,32 @@ dd m2_bits_to_nybbles //============================================================================== // - clears all VWF-ified tiles in a window -.clear_window: +clear_window: push {r0-r3,lr} -add sp,#-16 +add sp,-16 mov r3,r0 mov r0,sp -ldr r2,=#0x30051EC -ldrh r2,[r2,#0] // tile offset -strh r2,[r0,#8] -ldr r2,=#0x11111111 +ldr r2,=0x30051EC +ldrh r2,[r2,0] // tile offset +strh r2,[r0,8] +ldr r2,=0x11111111 mul r1,r2 -str r1,[r0,#4] // empty row of pixels +str r1,[r0,4] // empty row of pixels -ldrh r1,[r3,#0x22] // window X -strh r1,[r0,#0] -ldrh r1,[r3,#0x24] // window Y -strh r1,[r0,#2] -ldrh r1,[r3,#0x26] // window width -strh r1,[r0,#0xC] -ldrh r1,[r3,#0x28] // window height -strh r1,[r0,#0xE] +ldrh r1,[r3,0x22] // window X +strh r1,[r0,0] +ldrh r1,[r3,0x24] // window Y +strh r1,[r0,2] +ldrh r1,[r3,0x26] // window width +strh r1,[r0,0xC] +ldrh r1,[r3,0x28] // window height +strh r1,[r0,0xE] -bl .clear_rect +bl clear_rect -.clear_window_end: -add sp,#16 +add sp,16 pop {r0-r3,pc} +.pool //============================================================================== @@ -677,36 +663,36 @@ pop {r0-r3,pc} // - clears a rectangle -.clear_rect: +clear_rect: push {r0-r6,lr} -ldrh r1,[r0,#0xC] // width -ldrh r2,[r0,#0xE] // height -ldrh r6,[r0,#0] // initial X -mov r3,#0 // current row -.clear_rect_outer_start: +ldrh r1,[r0,0xC] // width +ldrh r2,[r0,0xE] // height +ldrh r6,[r0,0] // initial X +mov r3,0 // current row +@@outer_start: cmp r3,r2 -bge .clear_rect_end -mov r4,#0 // current col -- +bge @@end +mov r4,0 // current col +@@prev: cmp r4,r1 -bge .clear_rect_inner_end -bl .clear_tile_internal -ldrh r5,[r0,#0] -add r5,r5,#1 -strh r5,[r0,#0] -add r4,r4,#1 -b - -.clear_rect_inner_end: -ldrh r5,[r0,#2] -add r5,r5,#1 -strh r5,[r0,#2] +bge @@inner_end +bl clear_tile_internal +ldrh r5,[r0,0] +add r5,r5,1 +strh r5,[r0,0] +add r4,r4,1 +b @@prev +@@inner_end: +ldrh r5,[r0,2] +add r5,r5,1 +strh r5,[r0,2] mov r5,r6 -strh r5,[r0,#0] -add r3,r3,#1 -b .clear_rect_outer_start +strh r5,[r0,0] +add r3,r3,1 +b @@outer_start -.clear_rect_end: +@@end: pop {r0-r6,pc} @@ -722,28 +708,26 @@ pop {r0-r6,pc} // - clears a VWF tile at (x,y) -.clear_tile_internal: +clear_tile_internal: push {r0-r3,lr} mov r3,r0 -ldrh r0,[r3,#0] -ldrh r1,[r3,#2] -bl .get_tile_number -ldrh r1,[r3,#8] +ldrh r0,[r3,0] +ldrh r1,[r3,2] +bl get_tile_number +ldrh r1,[r3,8] add r0,r0,r1 -lsl r1,r0,#5 -mov r0,#6 -lsl r0,r0,#24 +lsl r1,r0,5 +mov r0,6 +lsl r0,r0,24 add r1,r0,r1 // VRAM dest address -add r0,r3,#4 // source address -mov r2,#1 -lsl r2,r2,#21 -add r2,r2,#1 -lsl r2,r2,#3 // r2 = 0x1000008 - // set the fixed source address flag + copy 8 words -swi #0xC // CpuFastSet +add r0,r3,4 // source address +ldr r2,=0x1000008 // set the fixed source address flag + copy 8 words +swi 0xC // CpuFastSet pop {r0-r3,pc} +.pool + //============================================================================== // void print_blankstr(int x, int y, int width) @@ -754,26 +738,28 @@ pop {r0-r3,pc} //============================================================================== // - prints a blank string at (x,y) of width tiles -.print_blankstr: +print_blankstr: push {r0-r5,lr} -add sp,#-16 +add sp,-16 mov r4,r0 mov r0,sp -strh r4,[r0,#0] -strh r1,[r0,#2] -ldr r1,=#0x44444444 -str r1,[r0,#4] -ldr r1,=#0x30051EC -ldrh r1,[r1,#0] -str r1,[r0,#8] -strh r2,[r0,#0xC] -mov r2,#2 -strh r2,[r0,#0xE] -bl .clear_rect +strh r4,[r0,0] +strh r1,[r0,2] +ldr r1,=0x44444444 +str r1,[r0,4] +ldr r1,=0x30051EC +ldrh r1,[r1,0] +str r1,[r0,8] +strh r2,[r0,0xC] +mov r2,2 +strh r2,[r0,0xE] +bl clear_rect -add sp,#16 +add sp,16 pop {r0-r5,pc} +.pool + //============================================================================== // void print_space(WINDOW* window) @@ -782,16 +768,17 @@ pop {r0-r5,pc} //============================================================================== // - prints a space character to window -.print_space: +print_space: push {r0-r1,lr} -add sp,#-4 -mov r1,#0x50 -str r1,[sp,#0] +add sp,-4 +mov r1,0x50 +str r1,[sp,0] mov r1,sp -bl .weld_entry -add sp,#4 +bl weld_entry +add sp,4 pop {r0-r1,pc} + //============================================================================== // void copy_tile(int x1, int y1, int x2, int y2) // In: @@ -800,34 +787,36 @@ pop {r0-r1,pc} //============================================================================== // - copies a tile from (x1,y1) to (x2,y2) -.copy_tile: +copy_tile: push {r0-r4,lr} -// Get the source and dest tile numbers + offset -bl .get_tile_number +// Get the source and dest tile numbers @@next offset +bl get_tile_number mov r4,r0 mov r0,r2 mov r1,r3 -bl .get_tile_number +bl get_tile_number mov r3,r0 -ldr r0,=#0x30051EC -ldrh r1,[r0,#0] +ldr r0,=0x30051EC +ldrh r1,[r0,0] add r0,r1,r4 // source tile add r1,r1,r3 // dest tile // Get VRAM addresses -mov r2,#6 -lsl r2,r2,#0x18 // VRAM tile base -lsl r0,r0,#5 -lsl r1,r1,#5 +mov r2,6 +lsl r2,r2,0x18 // VRAM tile base +lsl r0,r0,5 +lsl r1,r1,5 add r0,r0,r2 // VRAM source address add r1,r1,r2 // VRAM dest address // Copy -mov r2,#8 -swi #0xC +mov r2,8 +swi 0xC pop {r0-r4,pc} +.pool + //============================================================================== // void copy_tile_up(int x, int y) @@ -836,9 +825,9 @@ pop {r0-r4,pc} //============================================================================== // - copies a tile upward by one line (16 pixels) -.copy_tile_up: +copy_tile_up: push {r2-r3,lr} -sub r3,r1,#2 +sub r3,r1,2 mov r2,r0 -bl .copy_tile +bl copy_tile pop {r2-r3,pc} diff --git a/resize.exe b/resize.exe deleted file mode 100644 index 195fc04..0000000 Binary files a/resize.exe and /dev/null differ