Skip to content

Instantly share code, notes, and snippets.

@BitPatty
Created January 21, 2017 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BitPatty/5bf4003ae1016896d13aadea757ee5ef to your computer and use it in GitHub Desktop.
Save BitPatty/5bf4003ae1016896d13aadea757ee5ef to your computer and use it in GitHub Desktop.
; cStick values:
; 0 = Neutral
; 1 = Left
; 2 = Right
; 4 = Down
; 5 = Down, Left
; 6 = Down, Right
; 8 = Up
; 9 = Up, Left
; 10 = Up, Right
; button values:
; DPad Left = 0x1
; DPad Right = 0x2
; DPad Down = 0x4
; DPad Up = 0x8
; Z = 0x10
; R = 0x20
; L = 0x40
; A = 0x100
; B = 0x200
; X = 0x400
; Y = 0x800
; Start = 0x1000
;=========== CODE (NTSC-U) ===========
0x0 lis r3, 0x803E
0x4 ori r3, r3, 0x9710 ;r3 points to stageInfo
0x8 lis r5, 0x8040
0xC ori r5, r5, 0x4484 ;r5 points to currentInput
0x10 lbz r4, 2(r3) ;r4 = loadingType
0x14 cmpwi r4, 1 ;if loadingType <= 1; checks if entering/leaving a world/episode.
0x18 ble- 0x10 ;jmp checkInput
0x1C cmpwi r4, 13 ;if loadingType == 13; checks if the player is entering the park in Pinna
0x20 beq- 0x240 ;jmp setupPinnaPark
0x24 b 0x2A4 ;else jmp end
checkInput:
0x28 lbz r6, 1(r5) ;r6 = cStick
0x2C lhz r7, 2(r5) ;r7 = buttons
0x30 cmpwi r6, 0 ;if cStick != 0
0x34 bne- 0x18 ;jmp checkCStickUpLeft
0x38 cmpwi r7, 0 ;if buttons == 0
0x3C beq- 0x28C ;jmp end; cStick and buttons are neutral, continue as usual
0x40 cmpwi r7, 0x100 ;if buttons == 0x100;
0x44 beq- 0x284 ;jmp end; prevents the game from resetting when mashing A during cutscenes or normal loadings
0x48 b 0x0F8 ;jmp checkLevelReset; cStick neutral and buttons pressed
checkCStickUpLeft:
0x4C cmpwi r6, 9 ;if cStick == 9
0x50 beq- 0x124 ;jmp checkSpecial
0x54 cmpwi r6,8 ;if cStick != 8
0x58 bne- 0x0C ;continue
0x5C li r8,512 ;else nextStage = r8 = 0x200; Bianco
0x60 b 0x60 ;jmp checkEpisode
0x64 cmpwi r6,10 ;if cStick != 10
0x68 bne- 0x0C ;continue
0x6C li r8,768 ;else nextStage = 0x300: Ricco
0x70 b 0x50 ;jmp checkEpisode
0x74 cmpwi r6,2 ;...
0x78 bne- 0x0C
0x7C li r8,1024
0x80 b 0x40
0x84 cmpwi r6,6
0x88 bne- 0x0C
0x8C li r8,1280
0x90 b 0x30
0x94 cmpwi r6,4
0x98 bne- 0x0C
0x9C li r8,1536
0xA0 b 0x20
0xA4 cmpwi r6,5
0xA8 bne- 0x0C
0xAC li r8,2048
0xB0 b 0x10 ;...
0xB4 cmpwi r6,1 ;if cStick != 1
0xB8 bne- 0x210 ;jmp end; Invalid value
0xBC li r8,2304 ;else nextStage = 0x800 ;Noki
checkEpisode:
0xC0 cmpwi r7,0 ;if buttons != 0
0xC4 bne- 0x0C ;continue
0xC8 li r9,0 ;else nextEpisode = r9 = 0
0xCC b 0x180 ;jmp storeData
0xD0 cmpwi r7,64 ;...
0xD4 bne- 0x0C
0xD8 li r9,1
0xDC b 0x170
0xE0 cmpwi r7,32
0xE4 bne- 0x0C
0xE8 li r9,2
0xEC b 0x160
0xF0 cmpwi r7,96
0xF4 bne- 0x0C
0xF8 li r9,3
0xFC b 0x150
0x100 cmpwi r7,16
0x104 bne- 0x0C
0x108 li r9,4
0x10C b 0x140
0x110 cmpwi r7,80
0x114 bne- 0x0C
0x118 li r9,5
0x11C b 0x130
0x120 cmpwi r7,48
0x124 bne- 0x0C
0x128 li r9,6
0x12C b 0x120 ;...
0x130 cmpwi r7,112 ;if buttons != 112; ZLR
0x134 bne- 0x194 ;jmp end; Invalid value
0x138 li r9,7 ;else r9 = 7
0x13C b 0x110 ;jmp storeData
checkLevelReset:
0x140 cmpwi r7, 16 ;if buttons != 16; Z
0x144 bne- 0x30 ;jmp checkSpecial
0x148 lis r10, -32385 ;r10 = 817F0000
0x14C lwz r8, 0(r10) ;r8 = savedStage
0x150 cmpwi r4, 1 ;if loadingType = 1; enter
0x154 beq- 0x0C ;continue
0x158 li r8, 257 ;else r8 = 0x101
0x15C b 0x10 ;jmp setupSpecialStage
0x160 cmpwi r8, 0 ;if savedStage != 0x00000000
0x164 bne- 0x08 ;jmp setupSpecialStage
0x168 li r8, 258 ;else r8 = 0x102
setupSpecialStage:
0x16C li r9,0 ;r9 = 0;
0x170 b 0xDC ;jmp storeStage
checkSpecial:
0x174 cmpwi r7, 64 ;if r7 != 0x40; buttons != L
0x178 bne- 0x10 ;continue
0x17C li r8, 0x1400 ;else r8 = 0x1400; Airstrip 2
0x180 li r9, 0x2E00 ;r9 = 0x2E00; Bianco 6
0x184 b 0xB8 ;jmp switchSpecial
0x188 cmpwi r7, 32 ;...
0x18C bne- 0x10
0x190 li r8, 0x1500
0x194 li r9, 0x3000
0x198 B 0xA4
0x19C cmpwi r7, 96
0x1A0 bne- 0x10
0x1A4 li r8, 0x1600
0x1A8 li r9, 0x2000
0x1AC b 0x90
0x1B0 cmpwi r7, 80
0x1B4 bne- 0x10
0x1B8 li r8, 0x1700
0x1BC li r9, 0x2900
0x1C0 b 0x7C
0x1C4 cmpwi r7, 48
0x1C8 bne- 0x10
0x1CC li r8, 0x1800
0x1D0 li r9, 0x3300
0x1D4 b 0x68
0x1D8 cmpwi r7, 112
0x1DC bne- 0x10
0x1E0 li r8, 0x1D00
0x1E4 li r9, 0x2800
0x1E8 b 0x54
0x1EC cmpwi r7, 1024
0x1F0 bne- 0x0C
0x1F4 li r9, 0x2A00
0x1F8 b 0x44
0x1FC cmpwi r7, 1088
0x200 bne- 0x0C
0x204 li r9, 0x1F00
0x208 b 0x34
0x20C cmpwi r7, 2048
0x210 bne- 0x0C
0x214 li r9, 0x3A01
0x218 b 0x24
0x21C cmpwi r7, 2112
0x220 bne- 0x0C
0x224 li r9, 0x3C00
0x228 b 0x14 ;...
0x22C cmpwi r7, 16 ;if r7 == 0x10; Z again but this time for secrets
0x230 li r9, 0x3200 ;r9 = 0x3200; Pinna 2
0x234 beq- 0x08 ;jmp switchSpecial
0x238 li r9, 0x2F00 ;else r9 = 0x2F00; Entering any combination but L to LRZ loads Bianco 3, will be changed in a future update
switchSpecial:
0x23C cmpwi r6, 9 ;if r6 == 9; if cStick Up Left, load secret stage
0x240 beq- 0x08 ;continue
0x244 b -0xD8 ;else jmp setupSpecialStage
0x248 li r8, 0 ;r8 = 0; clear r8, it holds all the special stages from checkSpecial
storeData:
0x24C add r8,r8,r9 ;r8 = r8 + r9; r8 = 0xAABB, where AA is the stage and BB the episode
0x250 stw r8,0(r3) ;store r8 as nextStage
0x254 lis r3,-32385 ;r3 = 0x817F0000
0x258 stw r8,0(r3) ;store r8 at r3; backup for level reset
0x25C b 0x6C ;jmp end; Done!
setupPinnaPark:
0x260 li r8,3328 ;r8 = 0xD00
0x264 lwz r4,-4(r3) ;r4 = 4B at (r3)-4; r4 = previousStage
0x268 cmpwi r4,1280 ;if r4 != 0x500; if previousStage == Pinna 1, set Pinna Park event 1
0x26C bne- 0x0C ;continue
0x270 li r9,0 ;else r9 = 0
0x274 b 0xFFFFFFD8 ;jmp storeData
0x278 cmpwi r4,1282 ;if r4 != 0x502; if previousStage == Pinna 3, set Pinna Park Event 2
0x27C bne- 0x0C ;continue
0x280 li r9,1 ;else r9 = 1
0x284 b 0xFFFFFFC8 ;jmp storeData
0x288 cmpwi r4,1284 ;...
0x28C bne- 0x0C
0x290 li r9,2
0x294 b 0xFFFFFFB8
0x298 cmpwi r4,1285
0x29C bne- 0x0C
0x2A0 li r9,3
0x2A4 b 0xFFFFFFA8
0x2A8 cmpwi r4,1286
0x2AC bne- 0x0C
0x2B0 li r9,4
0x2B4 b 0xFFFFFF98
0x2B8 cmpwi r4,1287
0x2BC bne+ 0xFFFFFF90
0x2C0 li r9,5 ;if none of the previous, set Pinna Park Event 5 (the one before balloons)
0x2C4 b 0xFFFFFF88 ;jmp storeData
end:
0x2C8 lwz r3,32(r31) ;original function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment