; read_kpad_button
; 801EAD34 for USA (Rev 1/Rev 2)
; 801EAE74 for EUR (Rev 2)
; 801EAB44 for JPN (Rev 2)
; 801EB274 for KOR/ASN
; r4 holds extType
; r6 holds wiimote bitfield
; r7 holds wiimote+nunchuk bitfield
; r8 holds classic bitfield
CLASSIC:
cmpwi r4, 0x2
bne- RETURN
li r4, 0x0 ; standalone wiimote
CLASSIC_HOME:
andi. r9, r8, 0x800
beq- CLASSIC_UP
ori r6, r6, 0x8000 ; home
CLASSIC_UP:
andi. r9, r8, 0x1
beq- CLASSIC_DOWN
ori r6, r6, 0x2 ; right (v) / up (h)
CLASSIC_DOWN:
andi. r9, r8, 0x4000
beq- CLASSIC_LEFT
ori r6, r6, 0x1 ; left (v) / down (h)
CLASSIC_LEFT:
andi. r9, r8, 0x2
beq- CLASSIC_RIGHT
ori r6, r6, 0x8 ; up (v) / left (h)
CLASSIC_RIGHT:
andi. r9, r8, 0x8000
beq- CLASSIC_A
ori r6, r6, 0x4 ; down (v) / right (h)
CLASSIC_A:
andi. r9, r8, 0x10
beq- CLASSIC_B
ori r6, r6, 0x800 ; a
CLASSIC_B:
andi. r9, r8, 0x40
beq- CLASSIC_X
ori r6, r6, 0x100 ; 2
CLASSIC_X:
andi. r9, r8, 0x8
beq- CLASSIC_Y
ori r6, r6, 0x80 ; shake
CLASSIC_Y:
andi. r9, r8, 0x20
beq- REVISION
ori r6, r6, 0x200 ; 1
REVISION:
lwz r9, 0x64(r3)
cmpwi r9, 0x1
beq- CLASSIC_PRO_L
CLASSIC_L:
andi. r9, r8, 0x2000
beq- CLASSIC_R
ori r6, r6, 0x20 ; tilt left
CLASSIC_R:
andi. r9, r8, 0x200
beq- CLASSIC_ZL
ori r6, r6, 0x40 ; tilt right
CLASSIC_ZL:
andi. r9, r8, 0x80
beq- CLASSIC_ZR
ori r6, r6, 0x80 ; shake
CLASSIC_ZR:
andi. r9, r8, 0x4
beq- CLASSIC_PLUS
ori r6, r6, 0x80 ; shake
b CLASSIC_PLUS
; alternate setup for Pro controllers
CLASSIC_PRO_L:
andi. r9, r8, 0x2000
beq- CLASSIC_PRO_R
ori r6, r6, 0x80 ; shake
CLASSIC_PRO_R:
andi. r9, r8, 0x200
beq- CLASSIC_PRO_ZL
ori r6, r6, 0x80 ; shake
CLASSIC_PRO_ZL:
andi. r9, r8, 0x80
beq- CLASSIC_PRO_ZR
ori r6, r6, 0x20 ; tilt left
CLASSIC_PRO_ZR:
andi. r9, r8, 0x4
beq- CLASSIC_PLUS
ori r6, r6, 0x40 ; tilt right
CLASSIC_PLUS:
andi. r9, r8, 0x400
beq- CLASSIC_MINUS
ori r6, r6, 0x10 ; plus
CLASSIC_MINUS:
andi. r9, r8, 0x1000
beq- RETURN
ori r6, r6, 0x1000 ; minus
RETURN:
andi. r9, r6, 0x9FFF