diff --git a/HackSources/Ghosts/additional hacks.txt b/HackSources/Ghosts/additional hacks.txt index 41aa8165e..9a42469bd 100644 --- a/HackSources/Ghosts/additional hacks.txt +++ b/HackSources/Ghosts/additional hacks.txt @@ -1,9 +1,9 @@ <--- Hooks the ghost update function into area_update_objects ---> -US: -8027B188: 0C 10 20 00 +US: +8027B188: 0C 18 20 00 JP: -8027ABD8: 0C 10 20 00 +8027ABD8: 0C 18 20 00 <--- Disables low resolution Mario entirely ---> US: diff --git a/HackSources/Ghosts/gfx_generate_colored_hats.asm b/HackSources/Ghosts/gfx_generate_colored_hats.asm index e0b4642ed..ed30b50c9 100644 --- a/HackSources/Ghosts/gfx_generate_colored_hats.asm +++ b/HackSources/Ghosts/gfx_generate_colored_hats.asm @@ -32,7 +32,7 @@ lui at, 0x0388 ori at, at, 0x0010 sw at, 0x18 (v0) sw at, 0x0 (v0) -lui t0, 0x8040 +lui t0, GhostBaseHi ; defined in ghost_loop.asm (included first); with the ori below, must match COLORED_HATS_LIGHTS_ADDR in ColoredHats.cs ori t0, t0, 0x8300 lw t1, 0x20 (sp) sll t1, t1, 0x5 diff --git a/HackSources/Ghosts/ghost_hack_JP.asm b/HackSources/Ghosts/ghost_hack_JP.asm index c5dd45219..e41589c28 100644 --- a/HackSources/Ghosts/ghost_hack_JP.asm +++ b/HackSources/Ghosts/ghost_hack_JP.asm @@ -20,7 +20,7 @@ gMarioStatesLo equ 0x9e00 alloc_display_list equ 0x8027897c -.create "./build/JP_80408000_ghost_loop.bin", 0x00000000 +.create "./build/JP_80608000_ghost_loop.bin", 0x00000000 .include "./ghost_loop.asm" .Close @@ -37,6 +37,6 @@ alloc_display_list equ 0x8027897c .include "./avoid_holp_desyncs.asm" .close -.create "./build/JP_80408200_gfx_generate_colored_hats.bin", 0x00000000 +.create "./build/JP_80608200_gfx_generate_colored_hats.bin", 0x00000000 .include "./gfx_generate_colored_hats.asm" .close \ No newline at end of file diff --git a/HackSources/Ghosts/ghost_hack_US.asm b/HackSources/Ghosts/ghost_hack_US.asm index 3d58cee6b..9079cabe2 100644 --- a/HackSources/Ghosts/ghost_hack_US.asm +++ b/HackSources/Ghosts/ghost_hack_US.asm @@ -20,7 +20,7 @@ gMarioStatesLo equ 0xB170 alloc_display_list equ 0x80278f2c -.create "./build/US_80408000_ghost_loop.bin", 0x00000000 +.create "./build/US_80608000_ghost_loop.bin", 0x00000000 .include "./ghost_loop.asm" .close @@ -37,6 +37,6 @@ alloc_display_list equ 0x80278f2c .include "./avoid_holp_desyncs.asm" .close -.create "./build/US_80408200_gfx_generate_colored_hats.bin", 0x00000000 +.create "./build/US_80608200_gfx_generate_colored_hats.bin", 0x00000000 .include "./gfx_generate_colored_hats.asm" .close \ No newline at end of file diff --git a/HackSources/Ghosts/ghost_loop.asm b/HackSources/Ghosts/ghost_loop.asm index 6566928f7..0a8340666 100644 --- a/HackSources/Ghosts/ghost_loop.asm +++ b/HackSources/Ghosts/ghost_loop.asm @@ -8,12 +8,14 @@ RegPointerToCurrentGhost equ s1 ; Pointer to the currently processed ghost node RegProcessedGhostCount equ s0 ; Iteration counter for loops that process all ghosts ; hardcoded offsets -ExtendedRAMStartHi equ 0x8040 ; The Hi part of the address pointing to the start of extended RAM +GhostBaseHi equ 0x8060 ; Hi halfword of the extended-RAM base. Must match GHOST_REGION_BASE in GhostTab.cs, + ; the inject addresses + hook bytes in Resources/Hacks/GhostHack*.hck and "additional hacks.txt", + ; and the .create filenames in ghost_hack_US.asm / ghost_hack_JP.asm (this file is included by both). NumRequestedGhosts equ 0x7FFF ; Offset from extended RAM start to the byte indicating the number of ghosts to display. This value is written by STROOP. PointerToFirstGhost equ 0x7FF8 ; Offset from extended RAM start to the 4 byte pointer to the first ghost node NegativeGhostStructSize equ 0xFF98 ; The negative size of a single ghost node, used to iterate ghosts like a reversed array AnimationBufferSize equ 0x4000 ; The number of bytes reserved for animation data for each ghost -FirstAnimationBufferAddrHi equ 0x8050 ; The Hi part of the address pointing to the animation buffer used by the first ghost +FirstAnimationBufferAddrHi equ GhostBaseHi + 0x10 ; The Hi part of the address pointing to the animation buffer used by the first ghost InitializedGhostsFlag equ 0x40 ; A custom bit flag that can be set on the Mario object, indicating whether the ghost hack is active .n64 @@ -44,7 +46,7 @@ sh t1, 0x2 (RegMarioObject) beq r0, r0, @@RETURN ; clean up (this can cause failure?) -lui RegPointerToCurrentGhost, ExtendedRAMStartHi +lui RegPointerToCurrentGhost, GhostBaseHi beq r0, r0, @@CLEAN_UP_EARLY ori RegPointerToCurrentGhost, RegPointerToCurrentGhost, PointerToFirstGhost @@SKIP_INIT: @@ -61,7 +63,7 @@ sw at, 0x5B8 (t8) ; clean up if no ghosts are requested or RegProcessedGhostCount, r0, r0 -lui at, ExtendedRAMStartHi +lui at, GhostBaseHi ori RegPointerToCurrentGhost, at, PointerToFirstGhost lb at, NumRequestedGhosts (at) beq r0, at, @@CLEAN_UP_EARLY @@ -107,7 +109,7 @@ andi t0, t0, 0x7F sll t0, t0, 0x5 sll t1, RegProcessedGhostCount, 0xC addu t0, t0, t1 -lui at, 0x8041 +lui at, GhostBaseHi + 1 ; +1 because the addiu 0x9B00 below sign-extends; the pair lands at base + 0x9B00 addu t0, t0, at addiu t0, t0, 0x9B00 @@ -147,7 +149,7 @@ sh t1, 0x40 (RegCurrentGhost) addiu RegAnimationBuffer, RegAnimationBuffer, AnimationBufferSize addiu RegPointerToCurrentGhost, RegPointerToCurrentGhost, NegativeGhostStructSize addiu RegProcessedGhostCount, RegProcessedGhostCount, 0x1 -lui at, ExtendedRAMStartHi +lui at, GhostBaseHi lb at, NumRequestedGhosts (at) sltu t0, RegProcessedGhostCount, at bnez t0, @@ITERATE_GHOSTS diff --git a/STROOP/Controls/VariablePanel/VariablePanel.cs b/STROOP/Controls/VariablePanel/VariablePanel.cs index 2a6cc2ba1..8e4b5e9c4 100644 --- a/STROOP/Controls/VariablePanel/VariablePanel.cs +++ b/STROOP/Controls/VariablePanel/VariablePanel.cs @@ -410,16 +410,15 @@ private void AddToVarHackTab(List cells) private static CustomVariable CreateDummyVariable() where T : struct, IConvertible { T capturedValue = default(T); - - var variable = new CustomVariable("Number"); - variable.getter = () => capturedValue.Yield(); - variable.setter = value => + return new CustomVariable("Number") { - capturedValue = value; - return true.Yield(); + getter = () => capturedValue.Yield(), + setter = value => + { + capturedValue = value; + return true.Yield(); + }, }; - - return variable; } private ToolStripMenuItem CreateFilterItem(string varGroup) diff --git a/STROOP/Resources/Hacks/GhostHackJP.hck b/STROOP/Resources/Hacks/GhostHackJP.hck index df2629e62..213aabe79 100644 --- a/STROOP/Resources/Hacks/GhostHackJP.hck +++ b/STROOP/Resources/Hacks/GhostHackJP.hck @@ -1,8 +1,8 @@ -8027ABD8: 0C 10 20 00 +8027ABD8: 0C 18 20 00 -80408000: 27 BD FF C0 3C 08 80 36 8D 08 FD E8 10 08 00 6B AF BF 00 34 AF B4 00 30 AF B3 00 2C AF B2 00 28 AF B1 00 24 AF B0 00 20 00 08 A0 25 86 88 00 02 31 09 00 40 15 20 00 06 35 09 00 40 A6 89 00 02 10 00 00 58 3C 11 80 40 10 00 00 53 36 31 7F F8 3C 13 80 50 3C 18 80 37 34 01 00 BD A7 01 05 A8 37 01 05 B8 AF 01 05 98 3C 01 80 06 24 21 40 40 AF 01 05 B8 00 00 80 25 3C 01 80 40 34 31 7F F8 80 21 7F FF 10 01 00 44 00 00 00 00 8E 28 00 00 15 00 00 0E 00 00 20 25 26 25 FF 9C 8E 86 00 14 3C 07 80 38 34 E1 5F DC AF A1 00 10 34 E1 5F E4 AF A1 00 14 0C 0D EE 78 34 E7 5F D0 AE 22 00 00 8E 84 00 0C 0C 0D F0 11 00 40 28 25 8E 32 00 00 82 89 00 18 A2 49 00 18 8E 89 00 38 AE 49 00 38 3C 01 80 33 8C 28 C6 94 31 08 00 7F 00 08 41 40 00 10 4B 00 01 09 40 21 3C 01 80 41 01 01 40 21 25 08 9B 00 8D 09 00 00 AE 49 00 20 8D 09 00 04 AE 49 00 24 8D 09 00 08 AE 49 00 28 8D 09 00 10 A6 49 00 1A 8D 09 00 14 A6 49 00 1C 8D 09 00 18 A6 49 00 1E 3C 18 80 37 AF 12 05 80 AF 13 05 C0 85 09 00 1C A7 A9 00 38 37 04 04 F8 A6 40 00 38 AF 00 05 BC 0C 09 41 FA 8D 05 00 0C 87 A9 00 38 A6 49 00 40 26 73 40 00 26 31 FF 98 26 10 00 01 3C 01 80 40 80 21 7F FF 02 01 40 2B 15 00 FF C3 A2 50 00 60 8E 32 00 00 12 40 00 06 00 12 20 25 0C 0D F0 2F AE 20 00 00 8E 24 00 00 14 80 FF FC 26 31 FF 98 8F BF 00 34 8F B4 00 30 8F B3 00 2C 8F B2 00 28 8F B1 00 24 8F B0 00 20 03 E0 00 08 27 BD 00 40 +80608000: 27 BD FF C0 3C 08 80 36 8D 08 FD E8 10 08 00 6B AF BF 00 34 AF B4 00 30 AF B3 00 2C AF B2 00 28 AF B1 00 24 AF B0 00 20 00 08 A0 25 86 88 00 02 31 09 00 40 15 20 00 06 35 09 00 40 A6 89 00 02 10 00 00 58 3C 11 80 60 10 00 00 53 36 31 7F F8 3C 13 80 70 3C 18 80 37 34 01 00 BD A7 01 05 A8 37 01 05 B8 AF 01 05 98 3C 01 80 06 24 21 40 40 AF 01 05 B8 00 00 80 25 3C 01 80 60 34 31 7F F8 80 21 7F FF 10 01 00 44 00 00 00 00 8E 28 00 00 15 00 00 0E 00 00 20 25 26 25 FF 9C 8E 86 00 14 3C 07 80 38 34 E1 5F DC AF A1 00 10 34 E1 5F E4 AF A1 00 14 0C 0D EE 78 34 E7 5F D0 AE 22 00 00 8E 84 00 0C 0C 0D F0 11 00 40 28 25 8E 32 00 00 82 89 00 18 A2 49 00 18 8E 89 00 38 AE 49 00 38 3C 01 80 33 8C 28 C6 94 31 08 00 7F 00 08 41 40 00 10 4B 00 01 09 40 21 3C 01 80 61 01 01 40 21 25 08 9B 00 8D 09 00 00 AE 49 00 20 8D 09 00 04 AE 49 00 24 8D 09 00 08 AE 49 00 28 8D 09 00 10 A6 49 00 1A 8D 09 00 14 A6 49 00 1C 8D 09 00 18 A6 49 00 1E 3C 18 80 37 AF 12 05 80 AF 13 05 C0 85 09 00 1C A7 A9 00 38 37 04 04 F8 A6 40 00 38 AF 00 05 BC 0C 09 41 FA 8D 05 00 0C 87 A9 00 38 A6 49 00 40 26 73 40 00 26 31 FF 98 26 10 00 01 3C 01 80 60 80 21 7F FF 02 01 40 2B 15 00 FF C3 A2 50 00 60 8E 32 00 00 12 40 00 06 00 12 20 25 0C 0D F0 2F AE 20 00 00 8E 24 00 00 14 80 FF FC 26 31 FF 98 8F BF 00 34 8F B4 00 30 8F B3 00 2C 8F B2 00 28 8F B1 00 24 8F B0 00 20 03 E0 00 08 27 BD 00 40 -80408200: 27 BD FF C0 AF BF 00 14 3C 09 04 01 35 28 19 A0 3C 01 80 36 8C 21 FD E8 3C 18 80 33 8F 18 CF A0 13 01 00 02 00 00 50 25 83 0A 00 60 35 29 19 78 AF A8 00 18 AF A9 00 1C AF AA 00 20 24 01 00 01 14 24 00 1B 34 04 00 38 0C 09 E2 5F 00 00 00 00 3C 0C 06 00 AC 4C 00 10 8F A1 00 18 AC 41 00 14 3C 01 03 88 34 21 00 10 AC 41 00 18 AC 41 00 00 3C 08 80 40 35 08 83 00 8F A9 00 20 00 09 49 40 01 28 50 21 AC 4A 00 1C AC 4A 00 04 3C 01 03 86 34 21 00 10 AC 41 00 20 AC 41 00 08 25 4B 00 08 AC 4B 00 24 AC 4B 00 0C AC 4C 00 28 8F A8 00 1C AC 48 00 2C 3C 01 B8 00 AC 41 00 30 8F BF 00 14 03 E0 00 08 27 BD 00 40 +80608200: 27 BD FF C0 AF BF 00 14 3C 09 04 01 35 28 19 A0 3C 01 80 36 8C 21 FD E8 3C 18 80 33 8F 18 CF A0 13 01 00 02 00 00 50 25 83 0A 00 60 35 29 19 78 AF A8 00 18 AF A9 00 1C AF AA 00 20 24 01 00 01 14 24 00 1B 34 04 00 38 0C 09 E2 5F 00 00 00 00 3C 0C 06 00 AC 4C 00 10 8F A1 00 18 AC 41 00 14 3C 01 03 88 34 21 00 10 AC 41 00 18 AC 41 00 00 3C 08 80 60 35 08 83 00 8F A9 00 20 00 09 49 40 01 28 50 21 AC 4A 00 1C AC 4A 00 04 3C 01 03 86 34 21 00 10 AC 41 00 20 AC 41 00 08 25 4B 00 08 AC 4B 00 24 AC 4B 00 0C AC 4C 00 28 8F A8 00 1C AC 48 00 2C 3C 01 B8 00 AC 41 00 30 8F BF 00 14 03 E0 00 08 27 BD 00 40 802773D8: 3C 09 80 33 35 2A 9E 00 3C 19 80 33 8F 39 CF A0 3C 01 80 36 8C 21 FD E8 17 21 00 57 00 00 00 00 00 00 00 00 diff --git a/STROOP/Resources/Hacks/GhostHackUS.hck b/STROOP/Resources/Hacks/GhostHackUS.hck index d0067db58..79b501ed8 100644 --- a/STROOP/Resources/Hacks/GhostHackUS.hck +++ b/STROOP/Resources/Hacks/GhostHackUS.hck @@ -1,8 +1,8 @@ -8027B188: 0C 10 20 00 +8027B188: 0C 18 20 00 -80408000: 27 BD FF C0 3C 08 80 36 8D 08 11 58 10 08 00 6B AF BF 00 34 AF B4 00 30 AF B3 00 2C AF B2 00 28 AF B1 00 24 AF B0 00 20 00 08 A0 25 86 88 00 02 31 09 00 40 15 20 00 06 35 09 00 40 A6 89 00 02 10 00 00 58 3C 11 80 40 10 00 00 53 36 31 7F F8 3C 13 80 50 3C 18 80 37 34 01 00 BD A7 01 05 A8 37 01 05 B8 AF 01 05 98 3C 01 80 06 24 21 40 40 AF 01 05 B8 00 00 80 25 3C 01 80 40 34 31 7F F8 80 21 7F FF 10 01 00 44 00 00 00 00 8E 28 00 00 15 00 00 0E 00 00 20 25 26 25 FF 9C 8E 86 00 14 3C 07 80 38 34 E1 5F DC AF A1 00 10 34 E1 5F E4 AF A1 00 14 0C 0D EE 78 34 E7 5F D0 AE 22 00 00 8E 84 00 0C 0C 0D F0 11 00 40 28 25 8E 32 00 00 82 89 00 18 A2 49 00 18 8E 89 00 38 AE 49 00 38 3C 01 80 33 8C 28 D5 D4 31 08 00 7F 00 08 41 40 00 10 4B 00 01 09 40 21 3C 01 80 41 01 01 40 21 25 08 9B 00 8D 09 00 00 AE 49 00 20 8D 09 00 04 AE 49 00 24 8D 09 00 08 AE 49 00 28 8D 09 00 10 A6 49 00 1A 8D 09 00 14 A6 49 00 1C 8D 09 00 18 A6 49 00 1E 3C 18 80 37 AF 12 05 80 AF 13 05 C0 85 09 00 1C A7 A9 00 38 37 04 04 F8 A6 40 00 38 AF 00 05 BC 0C 09 42 6E 8D 05 00 0C 87 A9 00 38 A6 49 00 40 26 73 40 00 26 31 FF 98 26 10 00 01 3C 01 80 40 80 21 7F FF 02 01 40 2B 15 00 FF C3 A2 50 00 60 8E 32 00 00 12 40 00 06 00 12 20 25 0C 0D F0 2F AE 20 00 00 8E 24 00 00 14 80 FF FC 26 31 FF 98 8F BF 00 34 8F B4 00 30 8F B3 00 2C 8F B2 00 28 8F B1 00 24 8F B0 00 20 03 E0 00 08 27 BD 00 40 +80608000: 27 BD FF C0 3C 08 80 36 8D 08 11 58 10 08 00 6B AF BF 00 34 AF B4 00 30 AF B3 00 2C AF B2 00 28 AF B1 00 24 AF B0 00 20 00 08 A0 25 86 88 00 02 31 09 00 40 15 20 00 06 35 09 00 40 A6 89 00 02 10 00 00 58 3C 11 80 60 10 00 00 53 36 31 7F F8 3C 13 80 70 3C 18 80 37 34 01 00 BD A7 01 05 A8 37 01 05 B8 AF 01 05 98 3C 01 80 06 24 21 40 40 AF 01 05 B8 00 00 80 25 3C 01 80 60 34 31 7F F8 80 21 7F FF 10 01 00 44 00 00 00 00 8E 28 00 00 15 00 00 0E 00 00 20 25 26 25 FF 9C 8E 86 00 14 3C 07 80 38 34 E1 5F DC AF A1 00 10 34 E1 5F E4 AF A1 00 14 0C 0D EE 78 34 E7 5F D0 AE 22 00 00 8E 84 00 0C 0C 0D F0 11 00 40 28 25 8E 32 00 00 82 89 00 18 A2 49 00 18 8E 89 00 38 AE 49 00 38 3C 01 80 33 8C 28 D5 D4 31 08 00 7F 00 08 41 40 00 10 4B 00 01 09 40 21 3C 01 80 61 01 01 40 21 25 08 9B 00 8D 09 00 00 AE 49 00 20 8D 09 00 04 AE 49 00 24 8D 09 00 08 AE 49 00 28 8D 09 00 10 A6 49 00 1A 8D 09 00 14 A6 49 00 1C 8D 09 00 18 A6 49 00 1E 3C 18 80 37 AF 12 05 80 AF 13 05 C0 85 09 00 1C A7 A9 00 38 37 04 04 F8 A6 40 00 38 AF 00 05 BC 0C 09 42 6E 8D 05 00 0C 87 A9 00 38 A6 49 00 40 26 73 40 00 26 31 FF 98 26 10 00 01 3C 01 80 60 80 21 7F FF 02 01 40 2B 15 00 FF C3 A2 50 00 60 8E 32 00 00 12 40 00 06 00 12 20 25 0C 0D F0 2F AE 20 00 00 8E 24 00 00 14 80 FF FC 26 31 FF 98 8F BF 00 34 8F B4 00 30 8F B3 00 2C 8F B2 00 28 8F B1 00 24 8F B0 00 20 03 E0 00 08 27 BD 00 40 -80408200: 27 BD FF C0 AF BF 00 14 3C 09 04 01 35 28 19 A0 3C 01 80 36 8C 21 11 58 3C 18 80 33 8F 18 DF 00 13 01 00 02 00 00 50 25 83 0A 00 60 35 29 19 78 AF A8 00 18 AF A9 00 1C AF AA 00 20 24 01 00 01 14 24 00 1B 34 04 00 38 0C 09 E3 CB 00 00 00 00 3C 0C 06 00 AC 4C 00 10 8F A1 00 18 AC 41 00 14 3C 01 03 88 34 21 00 10 AC 41 00 18 AC 41 00 00 3C 08 80 40 35 08 83 00 8F A9 00 20 00 09 49 40 01 28 50 21 AC 4A 00 1C AC 4A 00 04 3C 01 03 86 34 21 00 10 AC 41 00 20 AC 41 00 08 25 4B 00 08 AC 4B 00 24 AC 4B 00 0C AC 4C 00 28 8F A8 00 1C AC 48 00 2C 3C 01 B8 00 AC 41 00 30 8F BF 00 14 03 E0 00 08 27 BD 00 40 +80608200: 27 BD FF C0 AF BF 00 14 3C 09 04 01 35 28 19 A0 3C 01 80 36 8C 21 11 58 3C 18 80 33 8F 18 DF 00 13 01 00 02 00 00 50 25 83 0A 00 60 35 29 19 78 AF A8 00 18 AF A9 00 1C AF AA 00 20 24 01 00 01 14 24 00 1B 34 04 00 38 0C 09 E3 CB 00 00 00 00 3C 0C 06 00 AC 4C 00 10 8F A1 00 18 AC 41 00 14 3C 01 03 88 34 21 00 10 AC 41 00 18 AC 41 00 00 3C 08 80 60 35 08 83 00 8F A9 00 20 00 09 49 40 01 28 50 21 AC 4A 00 1C AC 4A 00 04 3C 01 03 86 34 21 00 10 AC 41 00 20 AC 41 00 08 25 4B 00 08 AC 4B 00 24 AC 4B 00 0C AC 4C 00 28 8F A8 00 1C AC 48 00 2C 3C 01 B8 00 AC 41 00 30 8F BF 00 14 03 E0 00 08 27 BD 00 40 80277988: 3C 09 80 34 25 2A B1 70 3C 19 80 33 8F 39 DF 00 3C 01 80 36 8C 21 11 58 17 21 00 57 00 00 00 00 00 00 00 00 diff --git a/STROOP/Tabs/GhostTab/ColoredHats.cs b/STROOP/Tabs/GhostTab/ColoredHats.cs index ea56fd809..4dedab010 100644 --- a/STROOP/Tabs/GhostTab/ColoredHats.cs +++ b/STROOP/Tabs/GhostTab/ColoredHats.cs @@ -36,8 +36,8 @@ partial class GhostTab const uint S_SEGMENT_TABLE_OFFSET_JP = 0x8033a090; const uint S_SEGMENT_TABLE_OFFSET_US = 0x8033b400; - const uint COLORED_HATS_CODE_TARGET_ADDR = 0x80408200; - const uint COLORED_HATS_LIGHTS_ADDR = 0x80408300; + const uint COLORED_HATS_CODE_TARGET_ADDR = GHOST_CODE_ADDR + 0x200u; + const uint COLORED_HATS_LIGHTS_ADDR = GHOST_REGION_BASE + 0x8300u; private static void EnableColoredHats() { diff --git a/STROOP/Tabs/GhostTab/GhostTab.Designer.cs b/STROOP/Tabs/GhostTab/GhostTab.Designer.cs index 84281af1e..8fc24754e 100644 --- a/STROOP/Tabs/GhostTab/GhostTab.Designer.cs +++ b/STROOP/Tabs/GhostTab/GhostTab.Designer.cs @@ -455,7 +455,7 @@ private void InitializeComponent() this.textBoxPoolAddr2.Name = "textBoxPoolAddr2"; this.textBoxPoolAddr2.Size = new System.Drawing.Size(69, 20); this.textBoxPoolAddr2.TabIndex = 2; - this.textBoxPoolAddr2.Text = "80700000"; + this.textBoxPoolAddr2.Text = "80500000"; // // textBoxPoolAddr1 // @@ -463,7 +463,7 @@ private void InitializeComponent() this.textBoxPoolAddr1.Name = "textBoxPoolAddr1"; this.textBoxPoolAddr1.Size = new System.Drawing.Size(69, 20); this.textBoxPoolAddr1.TabIndex = 2; - this.textBoxPoolAddr1.Text = "80600000"; + this.textBoxPoolAddr1.Text = "80400000"; // // labelPoolSize // diff --git a/STROOP/Tabs/GhostTab/GhostTab.cs b/STROOP/Tabs/GhostTab/GhostTab.cs index a571e2f25..bc96ccddf 100644 --- a/STROOP/Tabs/GhostTab/GhostTab.cs +++ b/STROOP/Tabs/GhostTab/GhostTab.cs @@ -18,7 +18,17 @@ namespace STROOP.Tabs.GhostTab { public partial class GhostTab : STROOPTab { - const uint bufferBaseAddress = 0x80409B00; + // Base of the ghost hack's extended-RAM region. Must match GhostBaseHi in ghost_loop.asm + // and the inject addresses + hook bytes in Resources/Hacks/GhostHack*.hck. + const uint GHOST_REGION_BASE = 0x80600000; + + const uint GHOST_CODE_ADDR = GHOST_REGION_BASE + 0x8000u; + // These offsets mirror NumRequestedGhosts / PointerToFirstGhost in ghost_loop.asm. + const uint NUM_GHOSTS_ADDR = GHOST_REGION_BASE + 0x7FFFu; + const uint FIRST_GHOST_POINTER_ADDR = GHOST_REGION_BASE + 0x7FF8u; + const uint DISABLE_REQUEST_ADDR = GHOST_REGION_BASE + 0x7FFCu; + + const uint bufferBaseAddress = GHOST_REGION_BASE + 0x9B00u; static IEnumerable GetActiveGhostIndices() { @@ -85,7 +95,7 @@ public override void Update(bool active) int numGhosts = Math.Max(1, ghostArr.Length); if (updateGhostData) { - Config.Stream.SetValue((byte)numGhosts, 0x80407FFF); + Config.Stream.SetValue((byte)numGhosts, NUM_GHOSTS_ADDR); WriteMarioColorToStream(); } @@ -165,7 +175,7 @@ public override void Update(bool active) WriteGhostColorToStream(ghostIndex, ghostArr); - var ptr = Config.Stream.GetUInt32((uint)(0x80407ff8 - ghostIndex * 0x68)); + var ptr = Config.Stream.GetUInt32((uint)(FIRST_GHOST_POINTER_ADDR - ghostIndex * 0x68)); Config.Stream.SetValue((byte)(ghostTransparent ? 1 : 0), ptr + 0x61); lastGlobalTimer = globalTimer; } @@ -248,16 +258,16 @@ bool UpdateHackStatus() if (ghostHack?.Name != expectedHackName) ghostHack = new RomHack($"Resources/Hacks/GhostHack{RomVersionConfig.Version}.hck", expectedHackName); - var ghostPointer = Config.Stream.GetInt32(0x80407FF8); + var ghostPointer = Config.Stream.GetInt32(FIRST_GHOST_POINTER_ADDR); bool ghostsActive = (ghostPointer & 0xFF000000) == 0x80000000; - bool shouldDisable = Config.Stream.GetByte(0x80407FFC) == 0xFF; + bool shouldDisable = Config.Stream.GetByte(DISABLE_REQUEST_ADDR) == 0xFF; if (shouldDisable) { labelHackActiveState.Text = "Disabling Ghost hack...\nInside a level, frame advance\nthen save state and load state.\nNot doing so will crash.\n(Not on Pure Interpreter)"; if (!ghostsActive) { ghostHack.ClearPayload(); - Config.Stream.SetValue((byte)0, 0x80407FFC); + Config.Stream.SetValue((byte)0, DISABLE_REQUEST_ADDR); } else return true; @@ -345,13 +355,13 @@ private void buttonEnableGhostHack_Click(object sender, EventArgs e) if (Config.Stream.GetInt32(0x80000000) != 0) { ghostHack.LoadPayload(); - Config.Stream.WriteRam(new byte[4], 0x80407FFC, EndiannessType.Little); - Config.Stream.WriteRam(new byte[0x70], 0x80407F90, EndiannessType.Little); + Config.Stream.WriteRam(new byte[4], DISABLE_REQUEST_ADDR, EndiannessType.Little); + Config.Stream.WriteRam(new byte[0x70], GHOST_REGION_BASE + 0x7F90u, EndiannessType.Little); EnableColoredHats(); //Tell ROM Hacks to suck it and get rid of the 01010101 pattern - Config.Stream.WriteRam(new byte[0x1000], 0x80408000 - 0x1000, EndiannessType.Big); + Config.Stream.WriteRam(new byte[0x1000], GHOST_CODE_ADDR - 0x1000u, EndiannessType.Big); } } @@ -366,8 +376,8 @@ It is recommended that you load a savestate without the hack enabled instead. Are you sure you want to continue?"; if (MessageBox.Show(txt, "You should not have to do this.", MessageBoxButtons.YesNo) == DialogResult.Yes) { - Config.Stream.SetValue((byte)0, 0x80407FFF); - Config.Stream.SetValue((byte)0xFF, 0x80407FFC); + Config.Stream.SetValue((byte)0, NUM_GHOSTS_ADDR); + Config.Stream.SetValue((byte)0xFF, DISABLE_REQUEST_ADDR); } }