| 96 | } |
| 97 | |
| 98 | BYTE __stdcall SNESMAXCard::IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG nExecutedCycles) |
| 99 | { |
| 100 | const UINT slot = ((addr & 0xff) >> 4) - 8; |
| 101 | SNESMAXCard* pCard = (SNESMAXCard*)MemGetSlotParameters(slot); |
| 102 | |
| 103 | UINT xAxis = 0; |
| 104 | UINT yAxis = 0; |
| 105 | |
| 106 | JOYINFOEX infoEx; |
| 107 | infoEx.dwSize = sizeof(infoEx); |
| 108 | infoEx.dwFlags = JOY_RETURNPOV | JOY_RETURNBUTTONS; |
| 109 | |
| 110 | UINT& controller1Buttons = pCard->m_controller1Buttons; // ref to object's controller1Buttons |
| 111 | UINT& controller2Buttons = pCard->m_controller2Buttons; // ref to object's controller2Buttons |
| 112 | |
| 113 | switch (addr & 0xF) |
| 114 | { |
| 115 | case 0: // Latch |
| 116 | pCard->m_buttonIndex = 0; |
| 117 | controller1Buttons = 0; |
| 118 | controller2Buttons = 0; |
| 119 | |
| 120 | if (GetJoystick1() >= 0 && joyGetPosEx(GetJoystick1(), &infoEx) == JOYERR_NOERROR) |
| 121 | controller1Buttons = pCard->GetControllerButtons(JOYSTICKID1, infoEx, pCard->m_altControllerType[0]); |
| 122 | |
| 123 | controller1Buttons = ~controller1Buttons; |
| 124 | |
| 125 | if (GetJoystick2() >= 0 && joyGetPosEx(GetJoystick2(), &infoEx) == JOYERR_NOERROR) |
| 126 | controller2Buttons = pCard->GetControllerButtons(JOYSTICKID2, infoEx, pCard->m_altControllerType[1]); |
| 127 | |
| 128 | controller2Buttons = ~controller2Buttons; |
| 129 | |
| 130 | break; |
| 131 | case 1: // Clock |
| 132 | if (pCard->m_buttonIndex <= NUM_BUTTONS) // NB. 17 bits (where last bit is: Controller plugged in status) |
| 133 | { |
| 134 | pCard->m_buttonIndex++; |
| 135 | controller1Buttons = controller1Buttons >> 1; |
| 136 | controller2Buttons = controller2Buttons >> 1; |
| 137 | } |
| 138 | break; |
| 139 | default: |
| 140 | break; |
| 141 | } |
| 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | UINT SNESMAXCard::GetControllerButtons(UINT joyNum, JOYINFOEX& infoEx, bool altControllerType) |
| 147 | { |
nothing calls this directly
no test coverage detected