summaryrefslogtreecommitdiff
path: root/src/classic_controller.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/classic_controller.S')
-rw-r--r--src/classic_controller.S175
1 files changed, 118 insertions, 57 deletions
diff --git a/src/classic_controller.S b/src/classic_controller.S
index 6084c05..a1af772 100644
--- a/src/classic_controller.S
+++ b/src/classic_controller.S
@@ -24,17 +24,17 @@
#define WPAD_CLASSIC_BUTTON_UP 0x0001
#define WPAD_CLASSIC_BUTTON_LEFT 0x0002
-#define WPAD_CLASSIC_BUTTON_ZR 0x0004
+#define WPAD_CLASSIC_BUTTON_R 0x0004
#define WPAD_CLASSIC_BUTTON_X 0x0008
#define WPAD_CLASSIC_BUTTON_A 0x0010
#define WPAD_CLASSIC_BUTTON_Y 0x0020
#define WPAD_CLASSIC_BUTTON_B 0x0040
-#define WPAD_CLASSIC_BUTTON_ZL 0x0080
-#define WPAD_CLASSIC_BUTTON_FULL_R 0x0200
+#define WPAD_CLASSIC_BUTTON_L 0x0080
+#define WPAD_CLASSIC_BUTTON_ZR 0x0200
#define WPAD_CLASSIC_BUTTON_PLUS 0x0400
#define WPAD_CLASSIC_BUTTON_HOME 0x0800
#define WPAD_CLASSIC_BUTTON_MINUS 0x1000
-#define WPAD_CLASSIC_BUTTON_FULL_L 0x2000
+#define WPAD_CLASSIC_BUTTON_ZL 0x2000
#define WPAD_CLASSIC_BUTTON_DOWN 0x4000
#define WPAD_CLASSIC_BUTTON_RIGHT 0x8000
@@ -51,9 +51,30 @@
.text
.align 4
-;TODO - check that classic controller is attached
-;TODO - add tilt to right analog
-;TODO - add R/L to be full tilt
+
+
+
+
+.global waggleAdjust
+waggleAdjust:
+
+ lbz r5, 0x5C(r3) # wiimote extension type
+ cmpwi r5, 2 # classic controller
+
+ beq ClassicControllerWaggle
+
+ stfs f0, 0(r4)
+ blr
+
+ClassicControllerWaggle:
+
+ li r12, 0
+ stw r12, 0(r4)
+ blr
+
+
+
+
.global _switch_buttons
_switch_buttons:
addi r1,r1,0x50 # replaced instruction
@@ -71,8 +92,38 @@ _switch_buttons:
lbz r5,0x5C(r26) # wiimote extension type
cmpwi r5, 2 # classic controller
- beq cleanup
+ bne cleanup
+
+ lwz r5, 0x60(r26)
+Tilt:
+
+ lwz r5, 0x80(r26)
+ cmpwi r5, 0
+ beq TiltLeftSkip
+
+ lfs f11, 0x80(r26)
+
+ lis r5, 0
+ stw r5, 0x80(r26)
+ lfs f10, 0x80(r26)
+
+ fsubs f11, f10, f11
+
+ stfs f11, 0x58(r26)
+ li r5, 0
+ stw r5, 0x54(r26)
+
+TiltLeftSkip:
+
+ lwz r5, 0x7C(r26)
+ cmpwi r5, 0
+ beq TiltRightSkip
+ stw r5, 0x58(r26)
+ li r5, 0
+ stw r5, 0x54(r26)
+
+TiltRightSkip:
lwz r5,0x60(r26) # wiimote cc data ; KPADInsideStatus->KPADEXStatus_bl->hold
bl map_buttons
lwz r4,0(r26) # wiimote ; KPADInsideStatus->hold
@@ -102,56 +153,58 @@ cleanup:
addi r1,r1,stackSize
blr
-; r5 == CC data
-; r5 returns the wpad data
+# r5 == CC data
+# r5 returns the wpad data
+
+
map_buttons:
- andi. r4,r5,0x10 // WPAD_CLASSIC_BUTTON_A
- cmpwi r4,0
- beq- skip_waggle
- lis r6,0x7fc0 // float
- stw r6,0x10(r26) // set waggle ; KPADInsideStatus->acc->y
-skip_waggle:
li r6,0
+ andi. r4,r5,0x10 // WPAD_CLASSIC_BUTTON_A
+ beq- skip_A
+ ori r6,r6,0x100 // WPAD_BUTTON_2
+skip_A:
andi. r4,r5,0x800 // WPAD_CLASSIC_BUTTON_HOME
beq- skip_home
ori r6,r6,0x8000 // WPAD_BUTTON_HOME
skip_home:
andi. r4,r5,0x20 // WPAD_CLASSIC_BUTTON_Y
- beq- skip_run_one
- ori r6,r6,0x200 // WPAD_BUTTON_1
-skip_run_one:
+ beq- skip_Y
+ ori r6,r6,0x800 // WPAD_BUTTON_A
+skip_Y:
andi. r4,r5,0x8 // WPAD_CLASSIC_BUTTON_X
- beq- skip_run_two
- ori r6,r6,0x200 // WPAD_BUTTON_1
-skip_run_two:
+ beq- skip_X
+ lis r6,0x7fc0 // float
+ stw r6,0x10(r26) // set waggle ; KPADInsideStatus->acc->y
+skip_X:
andi. r4,r5,0x40 // WPAD_CLASSIC_BUTTON_B
- beq- skip_jump
- ori r6,r6,0x100 // WPAD_BUTTON_2
-skip_jump:
+ beq- skip_B
+ ori r6,r6,0x200 // WPAD_BUTTON_1
+skip_B:
andi. r4,r5,0x80 // WPAD_CLASSIC_BUTTON_ZL
- beq- skip_bubble1
- ori r6,r6,0x8 // WPAD_BUTTON_A
-skip_bubble1:
+ beq- skip_ZL
+ ori r6,r6,0x200 // WPAD_BUTTON_1
+skip_ZL:
andi. r4,r5,0x4 // WPAD_CLASSIC_BUTTON_ZR
- beq- skip_bubble2
- ori r6,r6,0x8 // WPAD_BUTTON_A
-skip_bubble2:
+ beq- skip_ZR
+ lis r6,0x7fc0 // float
+ stw r6,0x10(r26) // set waggle ; KPADInsideStatus->acc->y
+skip_ZR:
andi. r4,r5,1 // WPAD_CLASSIC_BUTTON_UP
- beq- skip_right
+ beq- skip_up
ori r6,r6,2 // WPAD_BUTTON_RIGHT
-skip_right:
+skip_up:
andi. r4,r5,2 // WPAD_CLASSIC_BUTTON_LEFT
- beq- skip_up
+ beq- skip_left
ori r6,r6,8 // WPAD_BUTTON_UP
-skip_up:
+skip_left:
andi. r4,r5,0x8000 // WPAD_CLASSIC_BUTTON_RIGHT
- beq- skip_down
+ beq- skip_right
ori r6,r6,4 // WPAD_BUTTON_DOWN
-skip_down:
+skip_right:
andi. r4,r5,0x4000 // WPAD_CLASSIC_BUTTON_DOWN
- beq- skip_left
+ beq- skip_down
ori r6,r6,1 // WPAD_BUTTON_LEFT
-skip_left:
+skip_down:
andi. r4,r5,0x400 // WPAD_CLASSIC_BUTTON_PLUS
beq- skip_plus
ori r6,r6,0x10 // WPAD_BUTTON_PLUS
@@ -162,33 +215,41 @@ skip_plus:
skip_minus:
lfs f8,0x6c(r26) // left analog x ; KPADInsideStatus->KPADEXStatus_cl->lstick
lfs f9,0x70(r26) // left analog y ; KPADInsideStatus->KPADEXStatus_cl->rstick
+
lis r5,float_one@ha
lfs f10,float_one@l(r5)
+
+ lis r5,float_neg_one@ha
lfs f11,float_neg_one@l(r5)
-; 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:
+
+ fcmpu cr0,f8,f10 // WPAD_R_ANALOG_RIGHT
+ blt skip_right_analog
+ ori r6,r6,4 // WPAD_BUTTON_DOWN
+skip_right_analog:
+ fcmpu cr0,f9,f10 // WPAD_R_ANALOG_UP
+ blt skip_up_analog
+ ori r6,r6,2 // WPAD_BUTTON_RIGHT
+skip_up_analog:
+ fcmpu cr0,f8,f11 // WPAD_R_ANALOG_LEFT
+ bge skip_down_analog
+ ori r6,r6,8 // WPAD_BUTTON_UP
+skip_down_analog:
+ fcmpu cr0,f9,f11 // WPAD_R_ANALOG_DOWN
+ bge skip_left_analog
+ ori r6,r6,1 // WPAD_BUTTON_LEFT
+skip_left_analog:
mr r5,r6
blr
+
+
+
+
.data
float_one:
-.float 1.0
+.float 0.5
float_neg_one:
-.float -1.0
+.float -0.5
float_zero:
.float 0.0