diff options
author | Treeki <treeki@gmail.com> | 2011-05-21 23:43:03 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-05-21 23:43:03 +0200 |
commit | 0cd2a002ce31be65bc4e5e847c172b7d9e6145b4 (patch) | |
tree | 0e81f4093781dad96b361457420910a20a49ce9d /src | |
parent | 23fbdd37ecbff448f6e2b62f35752698f8711de5 (diff) | |
download | kamek-0cd2a002ce31be65bc4e5e847c172b7d9e6145b4.tar.gz kamek-0cd2a002ce31be65bc4e5e847c172b7d9e6145b4.zip |
trying to fix switch blocks
Diffstat (limited to 'src')
-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 |