From 63d9a470f3e508097741522f899a3da0b5c67e12 Mon Sep 17 00:00:00 2001 From: Stephen Simpson Date: Wed, 28 Sep 2011 18:23:55 -0500 Subject: fixed region offsets in classic_controller.yaml fixed branch type from bl to b in classic_controller.yaml still missing analog sticks and tilt --- classic_controller.yaml | 18 +++++++------- src/classic_controller.S | 62 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/classic_controller.yaml b/classic_controller.yaml index 08354c2..8165c7d 100644 --- a/classic_controller.yaml +++ b/classic_controller.yaml @@ -3,38 +3,38 @@ source_files: [../src/classic_controller.S] hooks: - name: AddClassicController type: branch_insn - branch_type: bl + branch_type: b src_addr_pal: 0x801eb6f8 - #src_addr_ntsc: 0x801eb5b8 + src_addr_ntsc: 0x801eb5b8 target_func: '_switch_buttons' - name: Patch1 type: patch addr_pal: 0x801EAF70 - #addr_ntsc: 0x801EAE30 + addr_ntsc: 0x801EAE30 data: '39800000 91840000' - name: PatchExtensionScall type: patch addr_pal: 0x80019EE0 - #addr_ntsc: 0x80019EE0 + addr_ntsc: 0x80019EE0 data: '38000000' - name: Patch3 type: patch addr_pal: 0x800B3B30 - #addr_ntsc: 0x800B3B30 + addr_ntsc: 0x800B3B30 data: '38000000' - name: Patch4 type: patch - addr_pal: 0x8076DB98 - #addr_ntsc: 0x8076DBA8 + addr_pal: 0x8076DB68 + addr_ntsc: 0x8076DBA8 data: '38000004' - name: Patch5 type: patch - addr_pal: 0x8076DBd8 - #addr_ntsc: 0x8076DBE8 + addr_pal: 0x8076DBa8 + addr_ntsc: 0x8076DBE8 data: '38000000' diff --git a/src/classic_controller.S b/src/classic_controller.S index 86be34f..2ba7a9e 100644 --- a/src/classic_controller.S +++ b/src/classic_controller.S @@ -10,6 +10,16 @@ .set f30,30; .set f31,31 #endif +.set stackSize,0x30; +.set r4Place,0x10; +.set r5Place,0x14; +.set r6Place,0x18; +.set r26Place,0x1c; +.set f8Place,0x20; +.set f9Place,0x24; +.set f10Place,0x28; +.set f11Place,0x2c; + .text .align 4 @@ -17,7 +27,17 @@ _switch_buttons: addi r1,r1,0x50 # replaced instruction + stwu r1,-stackSize(r1) # provide new stack for saving regs mflr r0 + stw r4,r4Place(r1) + stw r5,r5Place(r1) + stw r6,r6Place(r1) + stw r26,r26Place(r1) + stfs f8,f8Place(r1) + stfs f9,f9Place(r1) + stfs f10,f10Place(r1) + stfs f11,f11Place(r1) + lwz r5,0x60(r26) # wiimote cc data bl map_buttons lwz r4,0(r26) @@ -33,7 +53,17 @@ _switch_buttons: lwz r4,8(r26) or r5,r5,r4 stw r5,8(r26) + + lwz r4,r4Place(r1) + lwz r5,r5Place(r1) + lwz r6,r6Place(r1) + lwz r26,r26Place(r1) + lfs f8,f8Place(r1) + lfs f9,f9Place(r1) + lfs f10,f10Place(r1) + lfs f11,f11Place(r1) mtlr r0 + addi r1,r1,stackSize blr map_buttons: @@ -88,22 +118,22 @@ skip_minus: lis r5,float_one@h lfs f10,float_one@l(r5) lfs f11,float_neg_one@l(r5) - fcmpu cr1,f8,f10 - bne cr1,skip_right_analog - ori r6,r6,4 // WPAD_BUTTON_DOWN -skip_right_analog: - fcmpu cr1,f9,f10 - bne cr1,skip_right_analog - ori r6,r6,2 // WPAD_BUTTON_RIGHT -skip_up_analog: - fcmpu cr1,f9,f11 - bne cr1,skip_right_analog - ori r6,r6,1 // WPAD_BUTTON_LEFT -skip_down_analog: - fcmpu cr1,f8,f11 - bne cr1,skip_right_analog - ori r6,r6,8 // WPAD_BUTTON_UP -skip_left_analog: +# fcmpu cr0,f8,f10 +# bne skip_right_analog +# ori r6,r6,4 // WPAD_BUTTON_DOWN +#skip_right_analog: +# fcmpu cr0,f9,f10 +# bne skip_right_analog +# ori r6,r6,2 // WPAD_BUTTON_RIGHT +#skip_up_analog: +# fcmpu cr0,f9,f11 +# bne skip_right_analog +# ori r6,r6,1 // WPAD_BUTTON_LEFT +#skip_down_analog: +# fcmpu cr0,f8,f11 +# bne skip_right_analog +# ori r6,r6,8 // WPAD_BUTTON_UP +#skip_left_analog: mr r5,r6 blr -- cgit v1.2.3