summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Simpson <megazig@gmail.com>2011-09-28 10:20:20 -0500
committerStephen Simpson <megazig@gmail.com>2011-09-28 10:20:20 -0500
commit7bb50c1714a74ba7e8468ead8f92b1f1ccceef6d (patch)
treeeb645c82f8ad6da9f2786224563c787214f123bb
parentf35befab481e013d76631baf6abec5f69ff703a6 (diff)
downloadkamek-7bb50c1714a74ba7e8468ead8f92b1f1ccceef6d.tar.gz
kamek-7bb50c1714a74ba7e8468ead8f92b1f1ccceef6d.zip
started adding classic controller
analog not yet implemented tilt not yet implemented
Diffstat (limited to '')
-rw-r--r--NewerProject.yaml1
-rw-r--r--classic_controller.yaml34
-rw-r--r--src/classic_controller.S84
3 files changed, 119 insertions, 0 deletions
diff --git a/NewerProject.yaml b/NewerProject.yaml
index 46d1259..e3806e7 100644
--- a/NewerProject.yaml
+++ b/NewerProject.yaml
@@ -29,3 +29,4 @@ modules:
- processed/compression.yaml
# - processed/crowdclapper.yaml
- processed/blocksnake.yaml
+ - processed/classic_controller.yaml
diff --git a/classic_controller.yaml b/classic_controller.yaml
new file mode 100644
index 0000000..eb02398
--- /dev/null
+++ b/classic_controller.yaml
@@ -0,0 +1,34 @@
+---
+source_files: [../src/classic_controller.S]
+hooks:
+ - name: AddClassicController
+ type: branch_insn
+ branch_type: bl
+ src_addr_ntsc: 0xdeadbeef
+ target_func: '_switch_buttons'
+
+ - name: Patch1
+ type: patch
+ addr_ntsc: 0x801EAE30
+ data: '39800000 91840000'
+
+ - name: PatchExtensionScall
+ type: patch
+ addr_ntsc: 0x80019EE0
+ data: '38000000'
+
+ - name: Patch3
+ type: patch
+ addr_ntsc: 0x800B3B30
+ data: '38000000'
+
+ - name: Patch4
+ type: patch
+ addr_ntsc: 0x8076DBA8
+ data: '38000000'
+
+ - name: Patch5
+ type: patch
+ addr_ntsc: 0x8076DBE8
+ data: '38000000'
+
diff --git a/src/classic_controller.S b/src/classic_controller.S
new file mode 100644
index 0000000..2ae5ed7
--- /dev/null
+++ b/src/classic_controller.S
@@ -0,0 +1,84 @@
+#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 _switch_buttons
+_switch_buttons:
+ addi r1,r1,0x50 # replaced instruction
+
+ mflr r0
+ lwz r5,0x60(r26) # wiimote cc data
+ bl map_buttons
+ lwz r4,0(r26)
+ or r5,r5,r4
+ stw r5,0(r26)
+ lwz r5,0x64(r26)
+ bl map_buttons
+ lwz r4,4(r26)
+ or r5,r5,r4
+ stw r5,4(r26)
+ lwz r5,0x68(r26)
+ bl map_buttons
+ lwz r4,8(r26)
+ or r5,r5,r4
+ stw r5,8(r26)
+ mtlr r0
+ blr
+
+map_buttons:
+ andi. r4,r5,0x200 // WPAD_CLASSIC_BUTTON_FULL_R
+ beq- skip_waggle
+ lis r6,0x7fc0 // float
+skip_waggle:
+ stw r6,0x10(r26) // set waggle
+ li r6,0
+ 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:
+ andi. r4,r5,0x8 // WPAD_CLASSIC_BUTTON_X
+ beq- skip_run_two
+ ori r6,r6,0x200 // WPAD_BUTTON_1
+skip_run_two:
+ andi. r4,r5,0x40 // WPAD_CLASSIC_BUTTON_B
+ beq- skip_jump
+ ori r6,r6,0x100 // WPAD_BUTTON_2
+skip_jump:
+ andi. r4,r5,1 // WPAD_CLASSIC_BUTTON_UP
+ beq- skip_right
+ ori r6,r6,2 // WPAD_BUTTON_RIGHT
+skip_right:
+ andi. r4,r5,2 // WPAD_CLASSIC_BUTTON_LEFT
+ beq- skip_up
+ ori r6,r6,8 // WPAD_BUTTON_UP
+skip_up:
+ andi. r4,r5,0x8000 // WPAD_CLASSIC_BUTTON_RIGHT
+ beq- skip_down
+ ori r6,r6,4 // WPAD_BUTTON_DOWN
+skip_down:
+ andi. r4,r5,0x4000 // WPAD_CLASSIC_BUTTON_DOWN
+ beq- skip_left
+ ori r6,r6,1 // WPAD_BUTTON_LEFT
+skip_left:
+ andi. r4,r5,0x400 // WPAD_CLASSIC_BUTTON_PLUS
+ beq- skip_plus
+ ori r6,r6,0x10 // WPAD_BUTTON_PLUS
+skip_plus:
+ andi. r4,r5,0x1000 // WPAD_CLASSIC_BUTTON_MINUS
+ beq- skip_minus
+ ori r6,r6,0x1000 // WPAD_BUTTON_MINUS
+skip_minus:
+ mr r5,r6
+ blr
+