diff options
author | Treeki <treeki@gmail.com> | 2011-05-21 23:47:47 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-05-21 23:47:47 +0200 |
commit | 173e876db1287224164fbca60217817932d03e25 (patch) | |
tree | f2f385dca11f6e76c302f3f90102e628642b4d12 /src/switchblock.S | |
parent | 2250fae42d1cae329924f402b19523c771f10710 (diff) | |
download | kamek-173e876db1287224164fbca60217817932d03e25.tar.gz kamek-173e876db1287224164fbca60217817932d03e25.zip |
fixed switch blocks
Diffstat (limited to '')
-rw-r--r-- | src/switchblock.S | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/switchblock.S b/src/switchblock.S index fd192df..b86d5e2 100644 --- a/src/switchblock.S +++ b/src/switchblock.S @@ -13,6 +13,7 @@ .align 4 .extern GameMgr .extern BG_GM_ptr +.extern _restgpr_27 .global BG_GM_InitRedSwitchFlag_Patch BG_GM_InitRedSwitchFlag_Patch: @@ -25,6 +26,63 @@ BG_GM_InitRedSwitchFlag_Patch: stb r0, 0xAA8(r4) blr +.global CheckBehaviourOverride_EndPatch +CheckBehaviourOverride_EndPatch: + lis r5, BG_GM_ptr@h + ori r5, r5, BG_GM_ptr@l + lwz r5, 0(r5) + + # Get the switch value + addis r5, r5, 9 + lbz r5, 0xAA8(r5) + + # not sure why this happens + cmpwi r28, 0 + bne returnRegularBehaviour + + # now do the rest of the checks: + cmplwi r29, 0x58 + bne cboNotRed + andi. r3, r5, 1 + beq cboNotRed + b returnSbBehaviour +cboNotRed: + cmplwi r29, 0x5A + bne cboNotGreen + andi. r3, r5, 2 + beq cboNotGreen + b returnSbBehaviour +cboNotGreen: + cmplwi r29, 0x56 + bne cboNotYellow + andi. r3, r5, 4 + beq cboNotYellow + b returnSbBehaviour +cboNotYellow: + cmplwi r29, 0x54 + bne cboNotBlue + andi. r3, r5, 8 + beq cboNotBlue + b returnSbBehaviour +cboNotBlue: + b returnRegularBehaviour + + # done! +returnSbBehaviour: + li r4, 3 + li r3, 8 + b cboReturn +returnRegularBehaviour: + mr r4, r27 + mr r3, r28 +cboReturn: + addi r11, r1, 0x20 + bl _restgpr_27 + lwz r0, 0x24(r1) + mtlr r0 + addi r1, r1, 0x20 + blr + .global ProcessTileNum_EndPatch ProcessTileNum_EndPatch: lis r5, BG_GM_ptr@h |