# Every button mask the C_PAD_DECODER's update function applies, sub_8220B8C0 # (0x8220B8C0..0x8220CFA0, 1400 instructions). Two sources, both listed: # * pure masks -- rlwinm rA,rS,0,MB,ME, the PPC idiom for 'test these bits' # * immediates -- andi. / cmpli operands # Bit values are XINPUT_GAMEPAD's, in their NATIVE positions: the decoder reads # a 32-bit word at +12 of the C_PAD_RINGBUF (this+76) and masks its low 16 bits, # verified 7/7 against /image/sylpheed.pe. There is no shift and no remap. ## SINGLE-BIT masks -- one XINPUT button each 0x0001 DPAD_UP rlwinm x21 0x8220BB9C 0x8220BC14 0x8220BE48 0x8220BEA8 0x8220BEEC 0x8220C28C andi./cmpli x2 0x0002 DPAD_DOWN rlwinm x2 0x8220BC64 0x8220C864 0x0004 DPAD_LEFT rlwinm x3 0x8220B8E4 0x8220C858 0x8220C8D8 0x0008 DPAD_RIGHT rlwinm x1 0x8220BC50 0x0010 START rlwinm x5 0x8220BE64 0x8220C47C 0x8220C594 0x8220C6B0 0x8220C920 0x0020 BACK rlwinm x4 0x8220C498 0x8220C5A0 0x8220C6C8 0x8220C93C 0x0040 LEFT_THUMB rlwinm x2 0x8220BF98 0x8220C444 0x0080 RIGHT_THUMB rlwinm x2 0x8220C08C 0x8220C460 0x0100 LEFT_SHOULDER rlwinm x0 0x0200 RIGHT_SHOULDER rlwinm x0 0x0400 (0x0400) rlwinm x1 0x8220CBAC 0x0800 (0x0800) rlwinm x0 0x1000 A rlwinm x2 0x8220C584 0x8220C608 0x2000 B rlwinm x1 0x8220C694 0x4000 X rlwinm x1 0x8220C66C 0x8000 Y rlwinm x1 0x8220C680 ## GROUP masks -- the XINPUT groupings, which is what identifies these as buttons 0x0003 x1 DPAD_UP,DPAD_DOWN 0x000F x1 DPAD_UP,DPAD_DOWN,DPAD_LEFT,DPAD_RIGHT 0x0030 x1 START,BACK 0x0060 x1 BACK,LEFT_THUMB 0x00FF x5 DPAD_UP,DPAD_DOWN,DPAD_LEFT,DPAD_RIGHT,START,BACK,LEFT_THUMB,RIGHT_THUMB 0xE000 x18 B,X,Y 0xF000 x1 A,B,X,Y ## Verified against the image (database used only as an index) 0x8220C558 image=0x554A0426 expect=0x554A0426 OK rlwinm r10,r10,0,16,19 mask A|B|X|Y ("any face button") 0x8220C680 image=0x556A0420 expect=0x556A0420 OK rlwinm r10,r11,0,16,16 mask Y 0x8220C66C image=0x556A0462 expect=0x556A0462 OK rlwinm r10,r11,0,17,17 mask X 0x8220C694 image=0x556B04A4 expect=0x556B04A4 OK rlwinm r11,r11,0,18,18 mask B 0x8220BB80 image=0x556B0424 expect=0x556B0424 OK rlwinm r11,r11,0,16,18 mask B|X|Y 0x8220C550 image=0x815F004C expect=0x815F004C OK lwz r10,76(r31) this+76 = the C_PAD_RINGBUF 0x8220C554 image=0x814A000C expect=0x814A000C OK lwz r10,12(r10) +12 inside it = the button word