From 7d4e4c0b34a613dd3c0220475ae4e448197522c1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 12 Mar 2011 23:17:12 +0100 Subject: initial commit. now I can start playing with stuff! --- src/poweruphax.S | 689 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 689 insertions(+) create mode 100644 src/poweruphax.S (limited to 'src/poweruphax.S') diff --git a/src/poweruphax.S b/src/poweruphax.S new file mode 100644 index 0000000..bfd8c83 --- /dev/null +++ b/src/poweruphax.S @@ -0,0 +1,689 @@ +.text +.align 4 +.set sp, 1 + +.extern returnFromGPSFASixth +.extern daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot +.extern dAcPy_c__ChangePowerupWithAnimation +.extern PlayPlayerSound +.extern CreateActor +.extern PlayerProjectileShooting +.extern Actor_SearchByName +.extern SomeTable_802F5440 +.extern SomeTable_802F5580 +.extern SomeTable_802F56C0 +.extern BlahTable +.extern continuePlumberSetPowerupTexture +.extern doneSettingThePowerupTexture +.extern doneSettingThePowerupTexture2 + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +.set f1,1; .set f30,30; .set f31,31 +#endif + +.global GetInfoFromDumbTable +GetInfoFromDumbTable: + lis r3, SomeTable@h + ori r3, r3, SomeTable@l + + slwi r4, r4, 2 + slwi r0, r5, 6 + + lwzx r3, r3, r4 + add r3, r3, r0 + blr + + + + +.global FukidashiFix +FukidashiFix: + lis r7, ZeroFloat@h + ori r7, r7, ZeroFloat@l + + lis r8, FukidashiTable2@h + ori r8, r8, FukidashiTable2@l + + mulli r6, r4, 0x20 + slwi r0, r5, 2 + add r0, r0, r6 + + lfs f0, 0(r7) + lfsx f1, r8, r0 + + stfs f0, 0x1DC(r3) + stfs f1, 0x1E0(r3) + stfs f0, 0x1E4(r3) + + blr + + + + +.global PlayerGetHeight +PlayerGetHeight: + lwz r0, 0x14D4(r3) + + lwz r4, 0x1090(r3) + slwi r4, r4, 3 + + cmpwi r0, 0 + beq useNormal + cmpwi r0, 1 + bne useDucking + +useNormal: + lis r3, PlayerHeightsNormal@h + ori r3, r3, PlayerHeightsNormal@l + b gotOffset + +useDucking: + lis r3, PlayerHeightsDucking@h + ori r3, r3, PlayerHeightsDucking@l + +gotOffset: + lfsx f1, r3, r4 + blr + + + +.global WtfEver +WtfEver: + lis r3, WtfEverTable@h + ori r3, r3, WtfEverTable@l + lfsx f0, r3, r0 + blr + + + +.global YetAnother +YetAnother: + lis r3, YetAnotherTable@h + ori r3, r3, YetAnotherTable@l + lfsx f0, r3, r0 + blr + + + + +.global GetWeirdScaleTable +GetWeirdScaleTable: + lis r5, WeirdScaleTable@h + ori r5, r5, WeirdScaleTable@l + lfsx f1, r5, r0 + blr + + + + + +.global GetAsdfTable +GetAsdfTable: + extsb r0, r4 + cmpwi r0, -1 + bne dontGetThisOne + + lwz r0, 0x1090(r3) + extsb r4, r0 + +dontGetThisOne: + extsb r0, r4 + + lis r3, AsdfTable@h + ori r3, r3, AsdfTable@l + lbzx r3, r3, r0 + + blr + + + + + +.global GetBlahTableOffset +GetBlahTableOffset: + lis r5, BlahTableOffsets@h + ori r5, r5, BlahTableOffsets@l + lwzx r30, r5, r4 + blr + + +.global DealWithBlahTable +DealWithBlahTable: + lis r5, BlahTableOffsets@h + ori r5, r5, BlahTableOffsets@l + + # points to BlahTable + lis r4, BlahTable@h + ori r4, r4, BlahTable@l + + # get blahtableoffset entry based on powerup + lwz r0, 0x1090(r3) + slwi r0, r0, 2 + lwzx r0, r5, r0 + + # now get the entry from the blahtable + slwi r0, r0, 2 + lwzx r4, r4, r0 + + # do shit here + + lfs f3, 0(r4) + stfs f3, 0x14E4(r3) + stfs f3, 0x164(r3) + + lfs f1, 0x2A70(r3) + lfs f0, 0x2A74(r3) + + lfs f2, 4(r4) + fadds f1, f2, f1 + fadds f0, f0, f1 + stfs f0, 0x14E8(r3) + stfs f0, 0x168(r3) + + lfs f0, 0x8(r4) + lfs f1, 0xC(r4) + stfs f0, 0x16C(r3) + stfs f1, 0x170(r3) + + # hope I did this right + blr + + + + + +.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest +GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest: + lis r6, PowerupScaleFloats@h + ori r6, r6, PowerupScaleFloats@l + add r4, r6, r0 + blr + +.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest +GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest: + lis r6, PowerupScaleFloats@h + ori r6, r6, PowerupScaleFloats@l + add r3, r6, r0 + blr + +.global GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest +GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest: + lis r8, PowerupScaleFloats@h + ori r8, r8, PowerupScaleFloats@l + add r7, r8, r0 + blr + +.global GetPowerupScaleFloatAddr_fixForSixth +GetPowerupScaleFloatAddr_fixForSixth: + lis r5, PowerupScaleFloats@h + ori r5, r5, PowerupScaleFloats@l + add r4, r5, r4 + b returnFromGPSFASixth + + + +.global PlumberSetPowerupFix +PlumberSetPowerupFix: + lbz r0, 0x152(r31) # get powerup id + + cmpwi r0, 2 + beq doFireTex + + cmpwi r0, 6 + beq doIceTex + + cmpwi r0, 7 + beq doHammerTex + + li r4, 0 + b gotTexID + +doFireTex: + li r4, 1 + b gotTexID + +doIceTex: + li r4, 2 + b gotTexID + +doHammerTex: + li r4, 3 + +gotTexID: + lwz r12, 0(r31) + mr r3, r31 + lwz r12, 0x34(r12) + mtctr r12 + bctrl + + b doneSettingThePowerupTexture + + + +.global PlumberSetPowerupFix2 +PlumberSetPowerupFix2: + cmpwi r31, 2 + beq doFireTex2 + + cmpwi r31, 6 + beq doIceTex2 + + cmpwi r31, 7 + beq doHammerTex2 + + li r4, 0 + b gotTexID2 + +doFireTex2: + li r4, 1 + b gotTexID2 + +doIceTex2: + li r4, 2 + b gotTexID2 + +doHammerTex2: + li r4, 3 + +gotTexID2: + lwz r3, 0x2A64(r30) + lwz r12, 0(r3) + lwz r12, 0x34(r12) + mtctr r12 + bctrl + + b doneSettingThePowerupTexture2 + + + + +.global PlumberSetPowerupTextureDebug +.extern OSReport +.extern continuePlumberSetPowerupTextureDebug +PlumberSetPowerupTextureDebug: + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x34(sp) + stw r3, 0x20(sp) + stw r4, 0x24(sp) + + mr r6, r0 + mr r5, r4 + mr r4, r3 + lis r3, PowerupTexDebugStr@h + ori r3, r3, PowerupTexDebugStr@l + crclr 4*cr1+eq + bl OSReport + + lwz r3, 0x20(sp) + lwz r4, 0x24(sp) + lwz r0, 0x34(sp) + mtlr r0 + addi sp, sp, 0x30 + + stwu sp, -0x30(sp) + + b continuePlumberSetPowerupTextureDebug + + + + + +.global PlumberSetPowerupTextureFix +PlumberSetPowerupTextureFix: + stb r4, 0x153(r3) + + lis r5, PowerupTextures@h + ori r5, r5, PowerupTextures@l + + slwi r4, r4, 2 + lfsx f31, r5, r4 + + b continuePlumberSetPowerupTexture + + + +.global SetHammerToEnItemDCA +SetHammerToEnItemDCA: + bl daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot + cmpwi r3, 1 + bne DontSetHammer + + li r0, 5 + sth r0, 0xDCA(r31) + +DontSetHammer: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +#.global EnItem_BindAnimation_Fix +#EnItem_BindAnimation_Fix: +# lhz r0, 0xDCA(r3) +# cmpwi r0, 5 +# beqlr +# stwu sp, -0x20(sp) +# b EnItem_BindAnimation_Continued + + +.global WeirdAnimLoadHack +WeirdAnimLoadHack: + cmplwi r4, 5 #hammersuit + beqlr + cmplwi r4, 6 #1up + beqlr + # neither of those succeeded + crclr 4*cr0+eq + blr + + + +.global TryToGiveMarioHammerSuit +TryToGiveMarioHammerSuit: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + # check the obtained item number + cmplwi r3, 5 + bne IsntGettingHammerSuit + + # check the current player powerup + cmplwi r4, 7 + bne DontHaveHammerSuit + + li r28, 0 + li r29, 2 + b ReturnFromTTGMHS + +DontHaveHammerSuit: + mr r3, r30 + li r4, 7 + bl dAcPy_c__ChangePowerupWithAnimation + + cmpwi r3, 0 + beq ReturnFromTTGMHS + + li r29, 1 + +IsntGettingHammerSuit: +ReturnFromTTGMHS: + # end of function + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + + # leftover instruction from what we replaced to add the bl + cmpwi r29, 0 + blr + + + +.global ThrowHammer +ThrowHammer: + # continues on from PlayerProjectileShooting + + # get powerup + lwz r3, 0x1090(r30) + cmplwi r3, 7 + bne ReturnFromThrowHammer + + mr r3, r30 + li r4, 498 + li r5, 0 + bl PlayPlayerSound + + li r3, 0x73 # Hammer + li r4, 0 # Settings + addi r5, sp, 0x2C # Position + li r6, 0 # Rotation + lbz r7, 0x38F(r30) # Layer + bl CreateActor + + # Store player ID + lwz r4, 0(r30) + stw r4, 0x450(r3) + + # store player number, but add 0x100 to differentiate it from 0 + lbz r4, 0x38D(r30) + addi r4, r4, 0x100 + stw r4, 0x458(r3) + + # Fix scale + lis r4, OneFloat@h + ori r4, r4, OneFloat@l + lfs f0, 0(r4) + stfs f0, 0xDC(r3) + stfs f0, 0xE0(r3) + stfs f0, 0xE4(r3) + + mr r4, r30 + lwz r12, 0x60(r3) + lwz r12, 0x8C(r12) + mtctr r12 + bctrl + +ReturnFromThrowHammer: + lwz r0, 0xC4(sp) + psq_l f31, 0xB8(sp), 1, 0 + lfd f31, 0xB0(sp) + psq_l f30, 0xA8(sp), 1, 0 + lfd f30, 0xA0(sp) + lwz r31, 0x9C(sp) + lwz r30, 0x98(sp) + mtlr r0 + addi sp, sp, 0xC0 + blr + + + +.global MoreProjectileStuff_Fix +MoreProjectileStuff_Fix: + lwz r3, 0x1090(r31) + cmplwi r3, 7 + bne ReturnFromMPSFix + + mr r3, r31 + li r4, 1 + bl PlayerProjectileShooting + +ReturnFromMPSFix: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +.global ProjectileShootCheck_Fix +ProjectileShootCheck_Fix: + lwz r3, 0x1090(r31) + cmplwi r3, 7 + bne Return0fromPSCFix + + lbz r3, 0x38D(r31) + li r4, 0 + extsb r3, r3 + bl CheckHammerLimit + + cmpwi r3, 0 + beq Return0fromPSCFix + + b Return1fromPSCFix + +Return0fromPSCFix: + li r3, 0 + b ReturnFromPSCFix + +Return1fromPSCFix: + li r3, 1 + +ReturnFromPSCFix: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +.global CheckHammerLimit +CheckHammerLimit: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + stw r31, 0xC(sp) + stw r30, 0x8(sp) + + # r30 = player number + mr r30, r3 + addi r30, r30, 0x100 + + # r31 = hammer count so far + li r31, 0 + + # search for every Hammer + + li r3, 0 + b startOrContinueLoop +loop: + + lwz r4, 0x458(r3) + cmpw r4, r30 + bne startOrContinueLoop + + addi r31, r31, 1 + +startOrContinueLoop: + mr r4, r3 + li r3, 0x73 + bl Actor_SearchByName + + cmpwi r3, 0 + bne loop + + # now if the current count is >= 2, return 0 + # otherwise return 1 + cmpwi r31, 2 + bge tooManyHammers + + li r3, 1 + b gotHammerStatus + +tooManyHammers: + li r3, 0 + +gotHammerStatus: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + lwz r30, 0x8(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + + + + +.data + +SomeTable: + .long SomeTable_802F5580 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F5440 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + +ZeroFloat: + .float 0.0 + +OneFloat: + .float 1.0 + +FukidashiTable2: + .float 20.0, 32.0, 32.0, 12.0, 38.0, 33.0, 32.0, 32.0 + .float 20.0, 34.0, 34.0, 12.0, 39.0, 35.0, 34.0, 34.0 + .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0 + .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0 + +PlayerHeightsNormal: + .float 16.0, 27.0, 27.0, 12.0, 27.0, 27.0, 27.0, 27.0 + +PlayerHeightsDucking: + .float 13.0, 21.0, 21.0, 9.0, 21.0, 21.0, 21.0, 21.0 + +WtfEverTable: + .float 4.5, 10.0, 10.0, 1.0, 10.0, 9.0, 10.0, 10.0 + +YetAnotherTable: + .float 0.0, -4.0, -4.0, 4.0, -6.0, -2.0, -4.0, -4.0 + +WeirdScaleTable: + .float 16.0, 31.0, 31.0, 6.0, 34.0, 31.0, 31.0, 31.0 + +AsdfTable: + .byte 1, 2, 2, 0, 2, 2, 2, 2 + +BlahTableOffsets: + .long 1, 2, 2, 0, 3, 2, 2, 2 + +PowerupScaleFloats: + .long 0xDEADBEEF, 0xDEADBEEF # padding + .float 1.0 + .float 1.0 + .float 1.0 + .float 0.6 + .float 1.0 + .float 1.0 + .float 1.0 + .float 1.0 + +PowerupTextures: + .float 0.0 + .float 1.0 + .float 2.0 + .float 3.0 + +.global BrosArcFileName +BrosArcFileName: + .string "bros" + +.global I_hammerArcFilename +I_hammerArcFilename: + .string "I_hammer" + +.global I_hammerResFile +I_hammerResFile: +# .string "g3d/I_hammer.brres" + .string "g3d/I_fireflower.brres" + +.global I_hammerModelName +I_hammerModelName: +# .string "I_hammer" + .string "I_fireflower" + + +PowerupTexDebugStr: + .string "Plumber::SetPowerupTexture() called on class %p with texnum %d lr=%p\n" + +#.global BrosModelFilename +#BrosModelFilename: +# .string "g3d/bros.brres" + +#.global HammerModelName +#HammerModelName: +# .string "bros_hammer" -- cgit v1.2.3