enhanced keyboard controller detection (except MagiCard) (fixes #908)

This commit is contained in:
Thomas Jentzsch 2022-06-29 23:40:13 +02:00
parent 08db05d198
commit e01d49e485
4 changed files with 48 additions and 8 deletions

View File

@ -71,7 +71,7 @@ Controller::Type ControllerDetector::autodetectPort(
type = Controller::Type::AtariMouse;
else if(isProbablyAmigaMouse(image, size))
type = Controller::Type::AmigaMouse;
else if(usesKeyboard(image, size, port))
else if(usesKeyboard(image, size, port) && !usesJoystickDirections(image, size))
type = Controller::Type::Keyboard;
else if(usesGenesisButton(image, size, port))
type = Controller::Type::Genesis;
@ -248,6 +248,31 @@ bool ControllerDetector::usesJoystickButton(const ByteBuffer& image, size_t size
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Returns true if the port's joystick direction access code is found.
bool ControllerDetector::usesJoystickDirections(const ByteBuffer& image, size_t size)
{
// check for SWCHA access (both ports)
static constexpr int NUM_SIGS = 8;
static constexpr int SIG_SIZE = 3;
static constexpr uInt8 signature[NUM_SIGS][SIG_SIZE] = {
{ 0xad, 0x80, 0x02 }, // lda SWCHA (also found in MagiCard, so this needs properties now!)
{ 0xae, 0x80, 0x02 }, // ldx SWCHA
{ 0xac, 0x80, 0x02 }, // ldy SWCHA
{ 0x2c, 0x80, 0x02 }, // bit SWCHA
{ 0x0d, 0x80, 0x02 }, // ora SWCHA (Official Frogger)
{ 0x2d, 0x80, 0x02 }, // and SWCHA (Crypts of Chaos, some paddle games)
{ 0x4d, 0x80, 0x02 }, // eor SWCHA (Chopper Command)
{ 0xad, 0x88, 0x02 }, // lda SWCHA|8 (Jawbreaker)
};
for(uInt32 i = 0; i < NUM_SIGS; ++i)
if(searchForBytes(image, size, signature[i], SIG_SIZE))
return true;
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size,
Controller::Jack port)
@ -255,7 +280,7 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size,
if(port == Controller::Jack::Left)
{
// check for INPT0 *AND* INPT1 access
static constexpr int NUM_SIGS_0_0 = 6;
static constexpr int NUM_SIGS_0_0 = 7;
static constexpr int SIG_SIZE_0_0 = 3;
static constexpr uInt8 signature_0_0[NUM_SIGS_0_0][SIG_SIZE_0_0] = {
{ 0x24, 0x38, 0x30 }, // bit INPT0|$30; bmi
@ -263,6 +288,7 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size,
{ 0xa4, 0x38, 0x30 }, // ldy INPT0|$30; bmi
{ 0xb5, 0x38, 0x30 }, // lda INPT0|$30,x; bmi
{ 0x24, 0x08, 0x30 }, // bit INPT0; bmi
{ 0x24, 0x08, 0x10 }, // bit INPT0; bpl (Tap-A-Mole, also e.g. Chopper Command, Secret Quest, River Raid II)
{ 0xa6, 0x08, 0x30 } // ldx INPT0; bmi
};
static constexpr int NUM_SIGS_0_2 = 1;
@ -271,7 +297,7 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size,
{ 0xb5, 0x38, 0x29, 0x80, 0xd0 } // lda INPT0,x; and #80; bne
};
static constexpr int NUM_SIGS_1_0 = 7;
static constexpr int NUM_SIGS_1_0 = 8;
static constexpr int SIG_SIZE_1_0 = 3;
static constexpr uInt8 signature_1_0[NUM_SIGS_1_0][SIG_SIZE_1_0] = {
{ 0x24, 0x39, 0x10 }, // bit INPT1|$30; bpl
@ -280,6 +306,7 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size,
{ 0xa4, 0x39, 0x30 }, // ldy INPT1|$30; bmi
{ 0xb5, 0x38, 0x30 }, // lda INPT0|$30,x; bmi
{ 0x24, 0x09, 0x30 }, // bit INPT1; bmi
{ 0x24, 0x09, 0x10 }, // bit INPT1; bpl (Tap-A-Mole and some Genesis games)
{ 0xa6, 0x09, 0x30 } // ldx INPT1; bmi
};
static constexpr int NUM_SIGS_1_2 = 1;

View File

@ -92,6 +92,9 @@ class ControllerDetector
static bool usesJoystickButton(const ByteBuffer& image, size_t size,
Controller::Jack port);
// Returns true if joystick direction access code is found.
static bool usesJoystickDirections(const ByteBuffer& image, size_t size);
// Returns true if the port's keyboard access code is found.
static bool usesKeyboard(const ByteBuffer& image, size_t size,
Controller::Jack port);

View File

@ -840,7 +840,7 @@ static constexpr BSPF::array2D<const char*, DEF_PROPS_SIZE, 29> DefProps = {{
{ "393e41ca8bdd35b52bf6256a968a9b89", "U.S. Games Corporation - Western Technologies, John Hall", "VC1012", "M.A.D. (1983) (U.S. Games)", "AKA Missile Intercept, Mutually Assured Destruction", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "3947eb7305b0c904256cdbc5c5956c0f", "Jone Yuan Telephonic Enterprise Co", "", "Lilly Adventure (Jone Yuan)", "2600 Screen Search Console", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "396f7bc90ab4fa4975f8c74abe4e81f0", "Atari, Larry Kaplan - Sears", "CX2612 - 99804, 49-75103", "Street Racer (1977) (Atari)", "Uses the Paddle Controllers (swapped)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "", "AUTO 60", "", "", "", "" },
{ "3974e2d1f614fbd3a092533ecae2e84d", "Alessandro Ciceri", "", "MagiCard+ (alex_79) WIP_20150118", "MagiCard hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "3974e2d1f614fbd3a092533ecae2e84d", "Alessandro Ciceri", "", "MagiCard+ (alex_79) WIP_20150118", "MagiCard hack", "", "", "", "", "", "", "", "", "", "", "KEYBOARD", "", "", "KEYBOARD", "", "", "", "", "", "", "", "", "", "" },
{ "39790a2e9030751d7db414e13f1b6960", "", "", "Robotfindskitten2600 (26-04-2003) (Jeremy Penner) [a1]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "39a6a5a2e1f6297cceaa48bb03af02e9", "", "", "Pitfall 2 Plus (Hack)", "Hack of Pitfall 2", "Hack", "", "", "", "{\"score_addresses\":[\"0xc7\",\"0xc8\",\"0xc9\"],\"score_digits\":6,\"variations_count\":1}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "39b94d41bd3b01c12b4054c1a8733783", "SOLID Corp. (D. Scott Williamson)", "CX2655-016", "Star Castle 2600 (SolidCorp) [016]", "", "Homebrew", "", "", "", "", "http://starcastle2600.blogspot.com/p/star-castle-2600-story.html", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" },
@ -1751,7 +1751,7 @@ static constexpr BSPF::array2D<const char*, DEF_PROPS_SIZE, 29> DefProps = {{
{ "78297db7f416af3052dd793b53ff014e", "", "", "Poker Squares (V0.17) (2001) (B. Watson)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7836794b79e8060c2b8326a2db74eef0", "", "", "RIOT RAM Test (26-11-2002) (Dennis Debro)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "784176346e9422733d55c427230e5bad", "Activision, Alex DeMeo", "", "Title Match Pro Wrestling (1989) (Activision)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "784abfdb31d5341e5bd404d8d2a71c3b", "Alessandro Ciceri", "", "MagiCard (TV format conversion) (alex_79) (PAL)", "MagiCard PAL conversion hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "784abfdb31d5341e5bd404d8d2a71c3b", "Alessandro Ciceri", "", "MagiCard (TV format conversion) (alex_79) (PAL)", "MagiCard PAL conversion hack", "", "", "", "", "", "", "", "", "", "", "KEYBOARD", "", "", "KEYBOARD", "", "", "", "", "", "", "", "", "", "" },
{ "7860716fa5dbc0fffab93fb9a4cb4132", "", "", "Hangman Monkey Wordlist (Hack)", "Hack of Hangman", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7867ee819b53d69cfcfe740f7ddca574", "Arcadia Corporation, Dennis Caswell", "1 AR-4000, AR-4100", "Phaser Patrol (1982) (Arcadia) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" },
{ "787ebc2609a31eb5c57c4a18837d1aee", "Brian Prescott", "", "Vault Assault (19xx) (Brian Prescott)", "", "", "", "", "", "", "https://atariage.com/store/index.php?l=product_detail&p=113", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
@ -1833,7 +1833,7 @@ static constexpr BSPF::array2D<const char*, DEF_PROPS_SIZE, 29> DefProps = {{
{ "7d93071b3e3616093a6b5a98b0315751", "", "", "Gunfight 2600 - Music & Bugfixes 2 (2001) (Manuel Rotschkar)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7d940d749e55b96b7b746519fa06f2de", "Arcadia Corporation, Dennis Caswell", "AR-4302", "Party Mix (Preview) (1983) (Arcadia) (PAL)", "Uses the Paddle Controllers", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7d9c96b215d1941e87b6fb412eb9204f", "", "", "Othello (Unknown) (PAL) (4K)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7da9de8d62fcdd3a2c545b2e720c2a61", "CommaVid, John Bronstein", "CM-001", "MagiCard (1981) (CommaVid) (4K)", "Uses the Keyboard Controllers", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7da9de8d62fcdd3a2c545b2e720c2a61", "CommaVid, John Bronstein", "CM-001", "MagiCard (1981) (CommaVid) (4K)", "Uses the Keyboard Controllers", "", "", "", "", "", "", "", "", "", "", "KEYBOARD", "", "", "KEYBOARD", "", "", "", "", "", "", "", "", "", "" },
{ "7dbc8fa2e488e3f6b87fbe0f76c5b89f", "Ed Federmeyer", "", "Sound X (1996) (Ed Federmeyer)", "", "Extremely Rare", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7dc03a1f56d0e6a8aae3e3e50d654a08", "", "", "Hozer Video Demo (PD)", "", "New Release", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "7dcbfd2acc013e817f011309c7504daa", "Arcadia Corporation, Dennis Caswell", "AR-4000, AR-4100", "Phaser Patrol (1982) (Arcadia)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" },
@ -2903,7 +2903,7 @@ static constexpr BSPF::array2D<const char*, DEF_PROPS_SIZE, 29> DefProps = {{
{ "cdb81bf33d830ee4ee0606ee99e84dba", "Arcadia Corporation, Scott Nelson", "AR-4300", "Fireball (1982) (Arcadia) (PAL)", "Uses the Paddle Controllers", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "15", "15", "01", "", "", "", "" },
{ "cdc1a5c61d7488eadc9aba36166b253d", "Retroactive", "", "Qb (V0.12) (Stella) (2001) (Retroactive)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "" },
{ "cdd4a538c420358ab64767d326921bf6", "", "", "4 in 1 (Logitachi)", "", "", "", "", "4IN1", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "cddabfd68363a76cd30bee4e8094c646", "Computer Magic - CommaVid, John Bronstein", "CM-001", "MagiCard (1981) (CommaVid)", "Uses the Keyboard Controllers", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "cddabfd68363a76cd30bee4e8094c646", "Computer Magic - CommaVid, John Bronstein", "CM-001", "MagiCard (1981) (CommaVid)", "Uses the Keyboard Controllers", "", "", "", "", "", "", "", "", "", "", "KEYBOARD", "", "", "KEYBOARD", "", "", "", "", "", "", "", "", "", "" },
{ "ce17325834bf8b0a0d0d8de08478d436", "", "", "Boring Freeway (Hack)", "Hack of Freeway", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "ce1cbe159b9ae5992dacf09371de5e13", "Atari - GCC, Kevin Osborn", "CX2689", "Kangaroo (01-19-1983) (Atari) (Prototype)", "", "Prototype", "", "", "", "", "http://www.atariprotos.com/2600/software/kangaroo/kangaroo.htm", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "ce243747bf34a2de366f846b3f4ca772", "Home Vision - Gem International Corp. - VDI", "", "Jacky Jump (1983) (Home Vision) (PAL)", "AKA Bobby Is Going Home", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
@ -3265,7 +3265,7 @@ static constexpr BSPF::array2D<const char*, DEF_PROPS_SIZE, 29> DefProps = {{
{ "e556e07cc06c803f2955986f53ef63ed", "Coleco - Individeo, Ed Temple", "2665", "Front Line (1984) (Coleco)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "e558be88eef569f33716e8e330d2f5bc", "Shock Vision", "", "Keystone Kapers (Shock Vision)", "", "", "", "", "", "{\"score_addresses\":[\"0x9a\",\"0x9b\",\"0x9c\"],\"score_digits\":6,\"variations_count\":1}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "e56da674188ba2f02c7a0a343a01236f", "", "", "This Planet Sucks Demo 4 (Greg Troutman) (PD)", "", "New Release", "", "", "", "", "https://atariage.com/store/index.php?l=product_detail&p=102", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "e59d022d524d05acc19515598c831e4d", "Alessandro Ciceri", "", "MagiCard+ (alex_79) WIP_20150118 (PAL)", "MagiCard hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "e59d022d524d05acc19515598c831e4d", "Alessandro Ciceri", "", "MagiCard+ (alex_79) WIP_20150118 (PAL)", "MagiCard hack", "", "", "", "", "", "", "", "", "", "", "KEYBOARD", "", "", "KEYBOARD", "", "", "", "", "", "", "", "", "", "" },
{ "e5a6e0bb7d56e2f08b237e15076e5699", "", "", "Color Table Display Helper (PD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "e5bacf526036d3c8c99db5b030cf00e7", "", "", "Starmaster (Genesis)", "Genesis controller (C switches to map mode)", "Hack of Starmaster", "", "", "", "{\"notes\":\"Score only calculated when game is over\",\"score_addresses\":[\"0xc1\",\"0xc2\"],\"variations_address\":\"0x80\",\"variations_count\":4,\"variations_zero_based\":true}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "e5d5085123a98c1e61818caa2971e999", "", "", "Euchre (PAL) (Erik Eid) (PD)", "", "", "", "", "", "", "https://atariage.com/store/index.php?l=product_detail&p=126", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },

View File

@ -5187,6 +5187,8 @@
"Cart.Manufacturer" "Alessandro Ciceri"
"Cart.Name" "MagiCard+ (alex_79) WIP_20150118"
"Cart.Note" "MagiCard hack"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cart.MD5" "39790a2e9030751d7db414e13f1b6960"
@ -10936,6 +10938,8 @@
"Cart.Manufacturer" "Alessandro Ciceri"
"Cart.Name" "MagiCard (TV format conversion) (alex_79) (PAL)"
"Cart.Note" "MagiCard PAL conversion hack"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cart.MD5" "7860716fa5dbc0fffab93fb9a4cb4132"
@ -11459,6 +11463,8 @@
"Cart.ModelNo" "CM-001"
"Cart.Name" "MagiCard (1981) (CommaVid) (4K)"
"Cart.Note" "Uses the Keyboard Controllers"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cart.MD5" "7dbc8fa2e488e3f6b87fbe0f76c5b89f"
@ -18264,6 +18270,8 @@
"Cart.ModelNo" "CM-001"
"Cart.Name" "MagiCard (1981) (CommaVid)"
"Cart.Note" "Uses the Keyboard Controllers"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cart.MD5" "ce17325834bf8b0a0d0d8de08478d436"
@ -20527,6 +20535,8 @@
"Cart.Manufacturer" "Alessandro Ciceri"
"Cart.Name" "MagiCard+ (alex_79) WIP_20150118 (PAL)"
"Cart.Note" "MagiCard hack"
"Controller.Left" "KEYBOARD"
"Controller.Right" "KEYBOARD"
""
"Cart.MD5" "e5a6e0bb7d56e2f08b237e15076e5699"