2012-01-02 16:37:17 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-14 20:02:52 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2012-01-02 16:37:17 +00:00
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2019-01-01 15:05:51 +00:00
|
|
|
// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
|
2012-01-02 16:37:17 +00:00
|
|
|
// and the Stella Team
|
|
|
|
//
|
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
2012-03-14 01:19:23 +00:00
|
|
|
#include "Control.hxx"
|
2012-03-15 15:22:57 +00:00
|
|
|
#include "StellaKeys.hxx"
|
2012-01-02 16:37:17 +00:00
|
|
|
#include "CompuMate.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2018-09-21 00:21:10 +00:00
|
|
|
CompuMate::CompuMate(const Console& console, const Event& event,
|
2012-03-14 22:24:54 +00:00
|
|
|
const System& system)
|
2014-11-04 00:34:56 +00:00
|
|
|
: myConsole(console),
|
2015-12-05 01:30:17 +00:00
|
|
|
myColumn(0),
|
2018-09-19 20:05:59 +00:00
|
|
|
myKeyTable(event.getKeys())
|
2012-01-02 16:37:17 +00:00
|
|
|
{
|
2014-11-04 00:34:56 +00:00
|
|
|
// These controller pointers will be retrieved by the Console, which will
|
|
|
|
// also take ownership of them
|
2017-07-21 23:40:13 +00:00
|
|
|
myLeftController = make_unique<CMControl>(*this, Controller::Left, event, system);
|
|
|
|
myRightController = make_unique<CMControl>(*this, Controller::Right, event, system);
|
2012-03-15 15:22:57 +00:00
|
|
|
|
2018-06-12 21:37:31 +00:00
|
|
|
myLeftController->updateAnalogPin(Controller::Nine, Controller::MAX_RESISTANCE);
|
|
|
|
myLeftController->updateAnalogPin(Controller::Five, Controller::MIN_RESISTANCE);
|
|
|
|
myRightController->updateAnalogPin(Controller::Nine, Controller::MIN_RESISTANCE);
|
|
|
|
myRightController->updateAnalogPin(Controller::Five, Controller::MAX_RESISTANCE);
|
2016-12-14 20:02:52 +00:00
|
|
|
|
|
|
|
enableKeyHandling(false);
|
2013-04-23 15:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CompuMate::enableKeyHandling(bool enable)
|
|
|
|
{
|
2018-09-19 20:05:59 +00:00
|
|
|
myKeyTable.enable(enable);
|
2012-01-02 16:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2012-03-14 01:19:23 +00:00
|
|
|
void CompuMate::update()
|
2012-01-02 16:37:17 +00:00
|
|
|
{
|
2012-03-14 22:24:54 +00:00
|
|
|
// Handle SWCHA changes - the following comes almost directly from z26
|
2014-11-04 00:34:56 +00:00
|
|
|
Controller& lp = myConsole.leftController();
|
|
|
|
Controller& rp = myConsole.rightController();
|
2012-03-14 22:24:54 +00:00
|
|
|
|
2018-06-12 21:37:31 +00:00
|
|
|
lp.myAnalogPinValue[Controller::Nine] = Controller::MAX_RESISTANCE;
|
|
|
|
lp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-14 22:24:54 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = true;
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Nine] = Controller::MIN_RESISTANCE;
|
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MAX_RESISTANCE;
|
2012-03-14 22:24:54 +00:00
|
|
|
rp.myDigitalPinState[Controller::Six] = true;
|
|
|
|
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT])
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_LCTRL] || myKeyTable[KBDK_RCTRL])
|
2018-06-12 21:37:31 +00:00
|
|
|
lp.myAnalogPinValue[Controller::Nine] = Controller::MIN_RESISTANCE;
|
2012-03-14 22:24:54 +00:00
|
|
|
|
2012-03-16 17:57:23 +00:00
|
|
|
rp.myDigitalPinState[Controller::Three] = true;
|
|
|
|
rp.myDigitalPinState[Controller::Four] = true;
|
2014-11-04 00:34:56 +00:00
|
|
|
|
2017-07-20 13:26:17 +00:00
|
|
|
switch(myColumn) // This is updated inside CartCM class
|
2012-03-14 22:24:54 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_7]) lp.myDigitalPinState[Controller::Six] = false;
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_U]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_J]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_M]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_6]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the '?' character (Shift-6) with the actual question key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_SLASH] && (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_Y]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_H]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_N]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_8]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the '[' character (Shift-8) with the actual key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_LEFTBRACKET] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_I]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_K]) rp.myDigitalPinState[Controller::Six] = false;
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_COMMA]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_2]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the '-' character (Shift-2) with the actual minus key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_MINUS] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_W]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_S]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_X]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_3]) lp.myDigitalPinState[Controller::Six] = false;
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_E]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_D]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_C]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_0]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the quote character (Shift-0) with the actual quote key
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_APOSTROPHE] && (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_P]) rp.myDigitalPinState[Controller::Three] = false;
|
TIA position counters (POSP0, POSM0, etc) in the debugger now show values
in decimal, not hex.
All DataGridWidgets (ie, most of the inputs in the debugger) have more
strict input filtering, allowing to use $,#,\ specifiers for different
bases, as well as restricting input based on the specifier used (ie, if
you've entered a '\', only '0' and '1' are allowed, etc).
Updated libpng to latest version.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2767 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2013-07-19 13:43:42 +00:00
|
|
|
if (myKeyTable[KBDK_RETURN] || myKeyTable[KBDK_KP_ENTER])
|
|
|
|
rp.myDigitalPinState[Controller::Six] = false;
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_SPACE]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-16 17:57:23 +00:00
|
|
|
// Emulate Ctrl-space (aka backspace) with the actual Backspace key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_BACKSPACE])
|
2012-03-16 17:57:23 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
lp.myAnalogPinValue[Controller::Nine] = Controller::MIN_RESISTANCE;
|
2012-03-16 17:57:23 +00:00
|
|
|
rp.myDigitalPinState[Controller::Four] = false;
|
|
|
|
}
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_9]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the ']' character (Shift-9) with the actual key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_RIGHTBRACKET] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_O]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_L]) rp.myDigitalPinState[Controller::Six] = false;
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_PERIOD]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_5]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the '=' character (Shift-5) with the actual equals key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_EQUALS] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_T]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_G]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_B]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_1]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the '+' character (Shift-1) with the actual plus key (Shift-=)
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_EQUALS] && (myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_Q]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_A]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_Z]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_4]) lp.myDigitalPinState[Controller::Six] = false;
|
2012-03-18 01:40:27 +00:00
|
|
|
// Emulate the '/' character (Shift-4) with the actual slash key
|
2012-04-19 15:25:09 +00:00
|
|
|
if (myKeyTable[KBDK_SLASH] && !(myKeyTable[KBDK_LSHIFT] || myKeyTable[KBDK_RSHIFT]))
|
2012-03-18 01:40:27 +00:00
|
|
|
{
|
2018-06-12 21:37:31 +00:00
|
|
|
rp.myAnalogPinValue[Controller::Five] = Controller::MIN_RESISTANCE;
|
2012-03-18 01:40:27 +00:00
|
|
|
lp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
}
|
2014-03-09 19:22:04 +00:00
|
|
|
if (myKeyTable[KBDK_R]) rp.myDigitalPinState[Controller::Three] = false;
|
|
|
|
if (myKeyTable[KBDK_F]) rp.myDigitalPinState[Controller::Six] = false;
|
|
|
|
if (myKeyTable[KBDK_V]) rp.myDigitalPinState[Controller::Four] = false;
|
2012-03-14 22:24:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-07-21 22:35:55 +00:00
|
|
|
|
|
|
|
if (lp.myOnAnalogPinUpdateCallback) {
|
|
|
|
lp.myOnAnalogPinUpdateCallback(Controller::Five);
|
|
|
|
lp.myOnAnalogPinUpdateCallback(Controller::Nine);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rp.myOnAnalogPinUpdateCallback) {
|
|
|
|
rp.myOnAnalogPinUpdateCallback(Controller::Five);
|
|
|
|
rp.myOnAnalogPinUpdateCallback(Controller::Nine);
|
|
|
|
}
|
2012-01-02 16:37:17 +00:00
|
|
|
}
|