Getting rid of hardcoded data in Koopa-The-Quick



With this hack, the trajectory pointer and star position for Koopa-The-Quick will be read from specific
offsets in the RAM object,
instead of reading fixed values. With this, you'll be able to do have multiple
trajectories for Koopa-The-Quick, instead of the original
two. It will only work then Param 01 (Type) = 01
( "Koopa The Quick Level 1").


You'll need an extra Koopa behavior for each new set of data. These are the commands to set the trajecotry/star
parameters in the
Koopa behavior:

27 3E 00 00 07 01 16 A0 [0x180 = Pointer to coordinates path]
27 3F 00 00 0B D6 11 94 [0x184 = X, Y spawned star coordinates]
27 50 00 00 EE 08 00 00 [0x1c8 = Z spawned star coordinate. Last 2 bytes are unused]

Koopa Behavior with flexible params example

00 05 00 00
11 01 20 41
27 3E 00 00 07 01 16 A0
27 3F 00 00 0B D6 11 94
27 50 00 00 EE 08 00 00
1E 00 00 00
27 26 00 00 06 01 13 64
28 09 00 00
2D 00 00 00
30 00 00 00 00 32 FE 70 00 00 00 00 03 E8 00 C8 00 00 00 00
32 00 00 96
0E 1B 00 01
0C 00 00 00 80 2F BC 4C
08 00 00 00
0C 00 00 00 80 2F D7 F8
09 00 00 00


Here's the instructions that needs to be patched:

[RAM/ROM]
802FCDF0/0xB7DF0: LUI A0, 0x8036     # Base address so we can get RAM object pointer # 3C048036
802FCDFC/0xB7DFC: LW A0, 0x1160 (A0) # Read pointer and stores at A0. # 8C841160
802FCE04/0xB7E04: LW A0, 0x0180 (A0) # Load word (Koopa's pointer) from offset 0x180 of RAM object. # 8C840180
802FD658/0xB8658: LH T2, 0x01C8 (T4) # Spawned Star Z position (16-bit int) # 858A01C8
802FD65C/0xB865C: LH T1, 0x0184 (T4) # Spawned Star X position (16-bit int) # 85890184
802FD660/0xB8660: LH T7, 0x0186 (T4) # Spawned Star Y position (16-bit int) # 858F0186

Comments