mirror of https://github.com/stella-emu/stella.git
Improved the keyboard controller emulation so that several other games
works (i.e., Alpha Beam with Ernie, Oscar's Trash Race, and Magicard). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1278 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e02603ec02
commit
309fbe2e94
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Keyboard.cxx,v 1.7 2007-01-05 17:54:23 stephena Exp $
|
||||
// $Id: Keyboard.cxx,v 1.8 2007-01-13 20:39:48 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "Event.hxx"
|
||||
|
@ -34,28 +34,42 @@ Keyboard::~Keyboard()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Keyboard::read(DigitalPin pin)
|
||||
{
|
||||
if(pin == Six)
|
||||
switch(pin)
|
||||
{
|
||||
if((myPinState & 0x01) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero3) == 0) :
|
||||
(myEvent.get(Event::KeyboardOne3) == 0);
|
||||
}
|
||||
else if((myPinState & 0x02) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero6) == 0) :
|
||||
(myEvent.get(Event::KeyboardOne6) == 0);
|
||||
}
|
||||
else if((myPinState & 0x04) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero9) == 0) :
|
||||
(myEvent.get(Event::KeyboardOne9) == 0);
|
||||
}
|
||||
else if((myPinState & 0x08) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZeroPound) == 0) :
|
||||
(myEvent.get(Event::KeyboardOnePound) == 0);
|
||||
}
|
||||
case One:
|
||||
return (myPinState & 0x01);
|
||||
|
||||
case Two:
|
||||
return (myPinState & 0x02);
|
||||
|
||||
case Three:
|
||||
return (myPinState & 0x04);
|
||||
|
||||
case Four:
|
||||
return (myPinState & 0x08);
|
||||
|
||||
case Six:
|
||||
if((myPinState & 0x01) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero3) == 0) :
|
||||
(myEvent.get(Event::KeyboardOne3) == 0);
|
||||
}
|
||||
else if((myPinState & 0x02) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero6) == 0) :
|
||||
(myEvent.get(Event::KeyboardOne6) == 0);
|
||||
}
|
||||
else if((myPinState & 0x04) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZero9) == 0) :
|
||||
(myEvent.get(Event::KeyboardOne9) == 0);
|
||||
}
|
||||
else if((myPinState & 0x08) == 0)
|
||||
{
|
||||
return (myJack == Left) ? (myEvent.get(Event::KeyboardZeroPound) == 0) :
|
||||
(myEvent.get(Event::KeyboardOnePound) == 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -64,118 +78,108 @@ bool Keyboard::read(DigitalPin pin)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Int32 Keyboard::read(AnalogPin pin)
|
||||
{
|
||||
// NOTE: maximumResistance = GND, while minimumResistance = +5V
|
||||
|
||||
if(pin == Nine)
|
||||
{
|
||||
if((myPinState & 0x01) == 0)
|
||||
if(myJack == Left)
|
||||
{
|
||||
if(myJack == Left)
|
||||
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardZero1) != 0))
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero1) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardZero4) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardZero7) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardZeroStar) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne1) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return minimumResistance;
|
||||
}
|
||||
}
|
||||
else if((myPinState & 0x02) == 0)
|
||||
else
|
||||
{
|
||||
if(myJack == Left)
|
||||
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardOne1) != 0))
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero4) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardOne4) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardOne7) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardOneStar) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne4) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
}
|
||||
else if((myPinState & 0x04) == 0)
|
||||
{
|
||||
if(myJack == Left)
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero7) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne7) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
}
|
||||
else if((myPinState & 0x08) == 0)
|
||||
{
|
||||
if(myJack == Left)
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZeroStar) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOneStar) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return minimumResistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((myPinState & 0x01) == 0)
|
||||
if(myJack == Left)
|
||||
{
|
||||
if(myJack == Left)
|
||||
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardZero2) != 0))
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero2) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardZero5) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardZero8) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardZero0) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne2) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return minimumResistance;
|
||||
}
|
||||
}
|
||||
else if((myPinState & 0x02) == 0)
|
||||
else
|
||||
{
|
||||
if(myJack == Left)
|
||||
if(!(myPinState & 0x01) && (myEvent.get(Event::KeyboardOne2) != 0))
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero5) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x02) && (myEvent.get(Event::KeyboardOne5) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x04) && (myEvent.get(Event::KeyboardOne8) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else if(!(myPinState & 0x08) && (myEvent.get(Event::KeyboardOne0) != 0))
|
||||
{
|
||||
return maximumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne5) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
}
|
||||
else if((myPinState & 0x04) == 0)
|
||||
{
|
||||
if(myJack == Left)
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero8) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne8) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
}
|
||||
else if((myPinState & 0x08) == 0)
|
||||
{
|
||||
if(myJack == Left)
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardZero0) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (myEvent.get(Event::KeyboardOne0) != 0) ?
|
||||
maximumResistance : minimumResistance;
|
||||
return minimumResistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maximumResistance;
|
||||
return minimumResistance;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
Loading…
Reference in New Issue