Add latched input.

This commit is contained in:
Christian Speckner 2016-11-26 00:08:32 +01:00
parent e786b3307e
commit 2bd5074828
5 changed files with 133 additions and 3 deletions

View File

@ -0,0 +1,60 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// 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
//
// Copyright (c) 1995-2016 by Bradford W. Mott, Stephen Anthony
// 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.
//
// $Id$
//============================================================================
#include "LatchedInput.hxx"
namespace TIA6502tsCore {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LatchedInput::LatchedInput()
{
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LatchedInput::reset()
{
myModeLatched = false;
myLatchedValue = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LatchedInput::vblank(uInt8 value)
{
if (value & 0x40) myModeLatched = true;
else {
myModeLatched = false;
myLatchedValue = 0x80;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 LatchedInput::inpt(bool pinState)
{
uInt8 value = pinState ? 0 : 0x80;
if (myModeLatched) {
myLatchedValue &= value;
value = myLatchedValue;
}
return value;
}
} // namespace TIA6502tsCore {

View File

@ -0,0 +1,57 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// 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
//
// Copyright (c) 1995-2016 by Bradford W. Mott, Stephen Anthony
// 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.
//
// $Id$
//============================================================================
#ifndef TIA_6502TS_CORE_LATCHED_INPUT
#define TIA_6502TS_CORE_LATCHED_INPUT
#include "bspf.hxx"
namespace TIA6502tsCore {
class LatchedInput
{
public:
LatchedInput();
public:
void reset();
void vblank(uInt8 value);
uInt8 inpt(bool pinState);
private:
bool myModeLatched;
uInt8 myLatchedValue;
private:
LatchedInput(const LatchedInput&) = delete;
LatchedInput(LatchedInput&&) = delete;
LatchedInput& operator=(const LatchedInput&) = delete;
LatchedInput& operator=(LatchedInput&&) = delete;
};
} // namespace TIA6502tsCore
#endif // TIA_6502TS_CORE_LATCHED_INPUT

View File

@ -105,6 +105,9 @@ void TIA::reset()
myPlayer1.reset();
myBall.reset();
myInput0.reset();
myInput1.reset();
mySound.reset();
myDelayQueue.reset();
myFrameManager.reset();
@ -265,11 +268,11 @@ uInt8 TIA::peek(uInt16 address)
break;
case INPT4:
result = myConsole.leftController().read(Controller::Six) ? 0x80 : 0x00;
result = myInput0.inpt(!myConsole.leftController().read(Controller::Six));
break;
case INPT5:
result = myConsole.rightController().read(Controller::Six) ? 0x80 : 0x00;
result = myInput0.inpt(!myConsole.rightController().read(Controller::Six));
break;
default:
@ -300,6 +303,10 @@ bool TIA::poke(uInt16 address, uInt8 value)
case VBLANK:
myLinesSinceChange = 0;
myInput0.vblank(value);
myInput1.vblank(value);
myFrameManager.setVblank(value & 0x02);
break;

View File

@ -31,6 +31,7 @@
#include "Missile.hxx"
#include "Player.hxx"
#include "Ball.hxx"
#include "LatchedInput.hxx"
class Console;
@ -218,6 +219,9 @@ class TIA : public AbstractTIA
Player myPlayer1;
Ball myBall;
LatchedInput myInput0;
LatchedInput myInput1;
private:
TIA() = delete;
TIA(const TIA&) = delete;

View File

@ -9,7 +9,9 @@ MODULE_OBJS := \
src/emucore/tia/core_6502ts/DrawCounterDecodes.o \
src/emucore/tia/core_6502ts/Missile.o \
src/emucore/tia/core_6502ts/Player.o \
src/emucore/tia/core_6502ts/Ball.o
src/emucore/tia/core_6502ts/Ball.o \
src/emucore/tia/core_6502ts/LatchedInput.o
MODULE_DIRS += \
src/emucore/tia/core_6502ts