MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / JoyReadButton

Function JoyReadButton

source/Joystick.cpp:599–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597}
598
599BYTE __stdcall JoyReadButton(WORD pc, WORD address, BYTE, BYTE, ULONG nExecutedCycles)
600{
601 address &= 0xFF;
602
603 if(joyinfo[joytype[0]] == DEVICE_JOYSTICK)
604 CheckJoystick0();
605 if((joyinfo[joytype[1]] == DEVICE_JOYSTICK) || (joyinfo[joytype[1]] == DEVICE_JOYSTICK_THUMBSTICK2))
606 CheckJoystick1();
607
608 if (g_bJoyportEnabled)
609 {
610 // Some extra logic to stop the Joyport forcing a self-test at CTRL+RESET
611 if ((address != 0x62) || (address == 0x62 && pc != 0xC242 && pc != 0xC2BE)) // Original //e ($C242), Enhanced //e ($C2BE)
612 return JoyportReadButton(address, nExecutedCycles);
613 }
614
615 const bool swapButtons0and1 = GetPropertySheet().GetButtonsSwapState();
616
617 BOOL pressed = FALSE;
618 switch (address)
619 {
620 case 0x61:
621 {
622 pressed = !swapButtons0and1 ? CheckButton0Pressed() : CheckButton1Pressed();
623 const UINT button0 = !swapButtons0and1 ? 0 : 1;
624 DoAutofire(button0, pressed);
625 if (CopyProtectionDonglePB0() >= 0) //If a copy protection dongle needs PB0, this overrides the joystick
626 pressed = CopyProtectionDonglePB0();
627 }
628 break;
629
630 case 0x62:
631 {
632 pressed = !swapButtons0and1 ? CheckButton1Pressed() : CheckButton0Pressed();
633 const UINT button1 = !swapButtons0and1 ? 1 : 0;
634 DoAutofire(button1, pressed);
635 if (CopyProtectionDonglePB1() >= 0) //If a copy protection dongle needs PB1, this overrides the joystick
636 pressed = CopyProtectionDonglePB1();
637 }
638 break;
639
640 case 0x63:
641 if (CopyProtectionDonglePB2() >= 0) //If a copy protection dongle needs PB2, this overrides the joystick
642 pressed = CopyProtectionDonglePB2();
643 else if (IS_APPLE2 && (joyinfo[joytype[1]] == DEVICE_NONE))
644 {
645 // Apple II/II+ with no joystick has the "SHIFT key mod"
646 // See Sather's Understanding The Apple II p7-36
647 pressed = !(GetKeyState(VK_SHIFT) < 0);
648 }
649 else
650 {
651 pressed = (joybutton[2] || setbutton[2]);
652 DoAutofire(2, pressed);
653 }
654 break;
655 }
656

Callers 1

IORead_C06xFunction · 0.85

Calls 11

CheckJoystick0Function · 0.85
CheckJoystick1Function · 0.85
JoyportReadButtonFunction · 0.85
CheckButton0PressedFunction · 0.85
CheckButton1PressedFunction · 0.85
DoAutofireFunction · 0.85
CopyProtectionDonglePB0Function · 0.85
CopyProtectionDonglePB1Function · 0.85
CopyProtectionDonglePB2Function · 0.85
MemReadFloatingBusFunction · 0.70
GetButtonsSwapStateMethod · 0.45

Tested by

no test coverage detected