From 9f59b995258f7350137ce6326bffaf938c9d8e56 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sun, 4 Aug 2019 12:25:33 +0200 Subject: [PATCH] enhanced keyboard detection for "Laser Keyboard" game --- src/emucore/ControllerDetector.cxx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/emucore/ControllerDetector.cxx b/src/emucore/ControllerDetector.cxx index 136fa3038..ee1a02dd3 100644 --- a/src/emucore/ControllerDetector.cxx +++ b/src/emucore/ControllerDetector.cxx @@ -112,7 +112,7 @@ bool ControllerDetector::usesJoystickButton(const uInt8* image, uInt32 size, Con if(port == Controller::Jack::Left) { // check for INPT4 access - const int NUM_SIGS_0 = 22; + const int NUM_SIGS_0 = 23; const int SIG_SIZE_0 = 3; uInt8 signature_0[NUM_SIGS_0][SIG_SIZE_0] = { { 0x24, 0x0c, 0x10 }, // bit INPT4; bpl (joystick games only) @@ -135,7 +135,8 @@ bool ControllerDetector::usesJoystickButton(const uInt8* image, uInt32 size, Con { 0xa4, 0x0c, 0x30 }, // ldy INPT4|; bmi (only Game of Concentration) { 0xa4, 0x3c, 0x30 }, // ldy INPT4|$30; bmi (only Game of Concentration) { 0xa5, 0x0c, 0x25 }, // lda INPT4; and (joystick games only) - { 0xa6, 0x3c, 0x30 }, // ldx INPT4; bmi (joystick games only) + { 0xa6, 0x3c, 0x30 }, // ldx INPT4|$30; bmi (joystick games only) + { 0xa6, 0x0c, 0x30 }, // ldx INPT4; bmi { 0xa5, 0x0c, 0x0a }, // lda INPT4; asl (joystick games only) }; const int NUM_SIGS_1 = 9; @@ -180,7 +181,7 @@ bool ControllerDetector::usesJoystickButton(const uInt8* image, uInt32 size, Con else if(port == Controller::Jack::Right) { // check for INPT5 and indexed INPT4 access - const int NUM_SIGS_0 = 15; + const int NUM_SIGS_0 = 16; const int SIG_SIZE_0 = 3; uInt8 signature_0[NUM_SIGS_0][SIG_SIZE_0] = { { 0x24, 0x0d, 0x10 }, // bit INPT5; bpl (joystick games only) @@ -196,8 +197,9 @@ bool ControllerDetector::usesJoystickButton(const uInt8* image, uInt32 size, Con { 0xb5, 0x3c, 0x10 }, // lda INPT4|$30,x; bpl (joystick, keyboard and driving games) { 0xb5, 0x3c, 0x30 }, // lda INPT4|$30,x; bmi (joystick and keyboard games) { 0xa4, 0x3d, 0x30 }, // ldy INPT5; bmi (only Game of Concentration) - { 0xa5, 0x0d, 0x25 }, // lda INPT4; and (joystick games only) - { 0xa6, 0x3d, 0x30 }, // ldx INPT4; bmi (joystick games only) + { 0xa5, 0x0d, 0x25 }, // lda INPT5; and (joystick games only) + { 0xa6, 0x3d, 0x30 }, // ldx INPT5|$30; bmi (joystick games only) + { 0xa6, 0x0d, 0x30 }, // ldx INPT5; bmi }; const int NUM_SIGS_1 = 7; const int SIG_SIZE_1 = 4; @@ -239,7 +241,7 @@ bool ControllerDetector::usesKeyboard(const uInt8* image, uInt32 size, Controlle if(port == Controller::Jack::Left) { // check for INPT0 *AND* INPT1 access - const int NUM_SIGS_0_0 = 5; + const int NUM_SIGS_0_0 = 6; const int SIG_SIZE_0_0 = 3; uInt8 signature_0_0[NUM_SIGS_0_0][SIG_SIZE_0_0] = { { 0x24, 0x38, 0x30 }, // bit INPT0|$30; bmi @@ -247,6 +249,7 @@ bool ControllerDetector::usesKeyboard(const uInt8* image, uInt32 size, Controlle { 0xa4, 0x38, 0x30 }, // ldy INPT0|$30; bmi { 0xb5, 0x38, 0x30 }, // lda INPT0|$30,x; bmi { 0x24, 0x08, 0x30 }, // bit INPT0; bmi + { 0xa6, 0x08, 0x30 }, // ldx INPT0; bmi }; const int NUM_SIGS_0_2 = 1; const int SIG_SIZE_0_2 = 5; @@ -254,7 +257,7 @@ bool ControllerDetector::usesKeyboard(const uInt8* image, uInt32 size, Controlle { 0xb5, 0x38, 0x29, 0x80, 0xd0 }, // lda INPT0,x; and #80; bne }; - const int NUM_SIGS_1_0 = 6; + const int NUM_SIGS_1_0 = 7; const int SIG_SIZE_1_0 = 3; uInt8 signature_1_0[NUM_SIGS_1_0][SIG_SIZE_1_0] = { { 0x24, 0x39, 0x10 }, // bit INPT1|$30; bpl @@ -263,6 +266,7 @@ bool ControllerDetector::usesKeyboard(const uInt8* image, uInt32 size, Controlle { 0xa4, 0x39, 0x30 }, // ldy INPT1|$30; bmi { 0xb5, 0x38, 0x30 }, // lda INPT0|$30,x; bmi { 0x24, 0x09, 0x30 }, // bit INPT1; bmi + { 0xa6, 0x09, 0x30 }, // ldx INPT1; bmi }; const int NUM_SIGS_1_2 = 1; const int SIG_SIZE_1_2 = 5; @@ -303,13 +307,14 @@ bool ControllerDetector::usesKeyboard(const uInt8* image, uInt32 size, Controlle else if(port == Controller::Jack::Right) { // check for INPT2 *AND* INPT3 access - const int NUM_SIGS_0_0 = 4; + const int NUM_SIGS_0_0 = 5; const int SIG_SIZE_0_0 = 3; uInt8 signature_0_0[NUM_SIGS_0_0][SIG_SIZE_0_0] = { { 0x24, 0x3a, 0x30 }, // bit INPT2|$30; bmi { 0xa5, 0x3a, 0x10 }, // lda INPT2|$30; bpl { 0xa4, 0x3a, 0x30 }, // ldy INPT2|$30; bmi { 0x24, 0x0a, 0x30 }, // bit INPT2; bmi + { 0xa6, 0x0a, 0x30 }, // ldx INPT2; bmi }; const int NUM_SIGS_0_2 = 1; const int SIG_SIZE_0_2 = 5; @@ -317,13 +322,14 @@ bool ControllerDetector::usesKeyboard(const uInt8* image, uInt32 size, Controlle { 0xb5, 0x38, 0x29, 0x80, 0xd0 }, // lda INPT2,x; and #80; bne }; - const int NUM_SIGS_1_0 = 4; + const int NUM_SIGS_1_0 = 5; const int SIG_SIZE_1_0 = 3; uInt8 signature_1_0[NUM_SIGS_1_0][SIG_SIZE_1_0] = { { 0x24, 0x3b, 0x30 }, // bit INPT3|$30; bmi { 0xa5, 0x3b, 0x10 }, // lda INPT3|$30; bpl { 0xa4, 0x3b, 0x30 }, // ldy INPT3|$30; bmi { 0x24, 0x0b, 0x30 }, // bit INPT3; bmi + { 0xa6, 0x0b, 0x30 }, // ldx INPT3; bmi }; const int NUM_SIGS_1_2 = 1; const int SIG_SIZE_1_2 = 5;