Atari 7800 support (initial RAM and Pause key) added

currently only available in debugger UI and via command line
TODO: make available in future developer dialog
This commit is contained in:
thrust26 2017-10-18 22:03:52 +02:00
parent 23cac0538c
commit eceb647953
10 changed files with 111 additions and 23 deletions

View File

@ -199,28 +199,48 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
myTVType->setTarget(this);
addFocusWidget(myTVType);
// 2600/7800 mode
items.clear();
VarList::push_back(items, "Atari 2600", "2600");
VarList::push_back(items, "Atari 7800", "7800");
lwidth = lfont.getStringWidth("Console") + 29;
pwidth = lfont.getStringWidth("Atari 2600");
new StaticTextWidget(boss, lfont, 10, ypos+1, "Console");
myConsole = new PopUpWidget(boss, lfont, 10, ypos, pwidth, lineHeight, items,
"", lwidth, kConsoleChanged);
myConsole->setTarget(this);
addFocusWidget(myConsole);
// Select and Reset
xpos += myP0Diff->getWidth() + 20; ypos = col2_ypos + lineHeight;
xpos += myP0Diff->getWidth() + 20; ypos = col2_ypos + 1;
mySelect = new CheckboxWidget(boss, lfont, xpos, ypos, "Select",
CheckboxWidget::kCheckActionCmd);
mySelect->setID(kSelectID);
mySelect->setTarget(this);
addFocusWidget(mySelect);
ypos += mySelect->getHeight() + 5;
ypos += myP0Diff->getHeight() + 5;
myReset = new CheckboxWidget(boss, lfont, xpos, ypos, "Reset",
CheckboxWidget::kCheckActionCmd);
myReset->setID(kResetID);
myReset->setTarget(this);
addFocusWidget(myReset);
ypos += myP0Diff->getHeight() + 5;
myPause = new CheckboxWidget(boss, lfont, xpos, ypos, "Pause",
CheckboxWidget::kCheckActionCmd);
myPause->setID(kPauseID);
myPause->setTarget(this);
addFocusWidget(myPause);
// Randomize items
xpos = 10; ypos += 3*lineHeight;
xpos = 10; ypos += 3 * lineHeight;
new StaticTextWidget(boss, lfont, xpos, ypos,
lfont.getStringWidth("When loading a ROM:"), fontHeight,
"When loading a ROM:", kTextAlignLeft);
// Randomize RAM
xpos += 30; ypos += lineHeight + 4;
xpos += 16; ypos += lineHeight + 4;
myRandomizeRAM = new CheckboxWidget(boss, lfont, xpos, ypos+1,
"Randomize zero-page and extended RAM", CheckboxWidget::kCheckActionCmd);
myRandomizeRAM->setID(kRandRAMID);
@ -333,6 +353,7 @@ void RiotWidget::loadConfig()
// means 'grounded' in the system)
myP0Diff->setSelectedIndex(riot.diffP0());
myP1Diff->setSelectedIndex(riot.diffP1());
myConsole->setSelectedIndex(instance().settings().getString("console") == "7800" ? 1 : 0);
myTVType->setSelectedIndex(riot.tvType());
mySelect->setState(!riot.select());
myReset->setState(!riot.reset());
@ -346,6 +367,8 @@ void RiotWidget::loadConfig()
const char* const cpuregs[] = { "S", "A", "X", "Y", "P" };
for(int i = 0; i < 5; ++i)
myRandomizeCPU[i]->setState(BSPF::containsIgnoreCase(cpurandom, cpuregs[i]));
handleConsole();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -424,6 +447,9 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kResetID:
riot.reset(!myReset->getState());
break;
case kPauseID:
handleConsole();
break;
case kRandRAMID:
instance().settings().setValue("ramrandom", myRandomizeRAM->getState());
break;
@ -442,7 +468,8 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
break;
case kTVTypeChanged:
riot.tvType(myTVType->getSelected());
case kConsoleChanged:
handleConsole();
break;
}
}
@ -482,6 +509,29 @@ ControllerWidget* RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font&
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RiotWidget::handleConsole()
{
RiotDebug& riot = instance().debugger().riotDebug();
bool is7800 = myConsole->getSelected() == 1;
instance().settings().setValue("console", is7800 ? "7800" : "2600");
myTVType->setEnabled(!is7800);
myPause->setEnabled(is7800);
myRandomizeRAM->setEnabled(!is7800);
if(is7800)
{
myTVType->setSelectedIndex(myPause->getState() ? 0 : 1);
myRandomizeRAM->setState(false);
instance().settings().setValue("ramrandom", 0);
}
else
{
myPause->setState(myTVType->getSelected() == 0);
}
riot.tvType(myTVType->getSelected());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RiotWidget::handleRandomCPU()
{

View File

@ -39,6 +39,7 @@ class RiotWidget : public Widget, public CommandSender
ControllerWidget* addControlWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, Controller& controller);
void handleConsole();
void handleRandomCPU();
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
@ -65,9 +66,11 @@ class RiotWidget : public Widget, public CommandSender
PopUpWidget *myTVType;
CheckboxWidget* mySelect;
CheckboxWidget* myReset;
CheckboxWidget* myPause;
CheckboxWidget* myRandomizeCPU[5];
CheckboxWidget* myRandomizeRAM;
PopUpWidget* myConsole;
// ID's for the various widgets
// We need ID's, since there are more than one of several types of widgets
@ -75,7 +78,7 @@ class RiotWidget : public Widget, public CommandSender
kTim1TID, kTim8TID, kTim64TID, kTim1024TID, kTimWriteID,
kSWCHABitsID, kSWACNTBitsID, kSWCHBBitsID, kSWBCNTBitsID,
kP0DiffChanged, kP1DiffChanged, kTVTypeChanged, kSelectID, kResetID,
kRandCPUID, kRandRAMID, kSWCHARBitsID
kRandCPUID, kRandRAMID, kSWCHARBitsID, kConsoleChanged, kPauseID
};
private:

View File

@ -39,7 +39,7 @@ class Event
ConsoleLeftDiffA, ConsoleLeftDiffB,
ConsoleRightDiffA, ConsoleRightDiffB,
ConsoleSelect, ConsoleReset,
ConsoleLeftDiffToggle, ConsoleRightDiffToggle, ConsoleColorToggle,
ConsoleLeftDiffToggle, ConsoleRightDiffToggle, ConsoleColorToggle, Console7800Pause,
JoystickZeroUp, JoystickZeroDown, JoystickZeroLeft, JoystickZeroRight,
JoystickZeroFire, JoystickZeroFire5, JoystickZeroFire9,

View File

@ -889,6 +889,8 @@ void EventHandler::handleEvent(Event::Type event, int state)
{
// Take care of special events that aren't part of the emulation core
// or need to be preprocessed before passing them on
bool is7800 = (myOSystem.settings().getString("console") == "7800");
switch(event)
{
////////////////////////////////////////////////////////////////////////
@ -1012,21 +1014,21 @@ void EventHandler::handleEvent(Event::Type event, int state)
////////////////////////////////////////////////////////////////////////
// Events which relate to switches()
case Event::ConsoleColor:
if(state)
if(state && !is7800)
{
myEvent.set(Event::ConsoleBlackWhite, 0);
myOSystem.frameBuffer().showMessage("Color Mode");
}
break;
case Event::ConsoleBlackWhite:
if(state)
if(state && !is7800)
{
myEvent.set(Event::ConsoleColor, 0);
myOSystem.frameBuffer().showMessage("BW Mode");
}
break;
case Event::ConsoleColorToggle:
if(state)
if(state && !is7800)
{
if(myOSystem.console().switches().tvColor())
{
@ -1040,7 +1042,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
myEvent.set(Event::ConsoleColor, 1);
myOSystem.frameBuffer().showMessage("Color Mode");
}
myOSystem.console().switches().update();
myOSystem.console().switches().update(myOSystem.settings());
}
return;
@ -1073,7 +1075,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage("Left Difficulty A");
}
myOSystem.console().switches().update();
myOSystem.console().switches().update(myOSystem.settings());
}
return;
@ -1106,7 +1108,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage("Right Difficulty A");
}
myOSystem.console().switches().update();
myOSystem.console().switches().update(myOSystem.settings());
}
return;
////////////////////////////////////////////////////////////////////////
@ -2168,6 +2170,7 @@ EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] =
{ Event::ConsoleColor, "Color TV", "", true },
{ Event::ConsoleBlackWhite, "Black & White TV", "", true },
{ Event::ConsoleColorToggle, "Swap Color / B&W TV", "", true },
{ Event::Console7800Pause, "7800 Pause Key", "", true },
{ Event::ConsoleLeftDiffA, "P0 Difficulty A", "", true },
{ Event::ConsoleLeftDiffB, "P0 Difficulty B", "", true },
{ Event::ConsoleLeftDiffToggle, "P0 Swap Difficulty", "", true },

View File

@ -508,7 +508,7 @@ class EventHandler
enum {
kComboSize = 16,
kEventsPerCombo = 8,
kEmulActionListSize = 78 + kComboSize,
kEmulActionListSize = 79 + kComboSize,
kMenuActionListSize = 14
};

View File

@ -47,8 +47,22 @@ M6532::M6532(const Console& console, const Settings& settings)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::reset()
{
static constexpr uInt8 RAM_7800[128] = {
0xA9, 0x00, 0xAA, 0x85, 0x01, 0x95, 0x03, 0xE8, 0xE0, 0x2A, 0xD0, 0xF9, 0x85, 0x02, 0xA9, 0x04,
0xEA, 0x30, 0x23, 0xA2, 0x04, 0xCA, 0x10, 0xFD, 0x9A, 0x8D, 0x10, 0x01, 0x20, 0xCB, 0x04, 0x20,
0xCB, 0x04, 0x85, 0x11, 0x85, 0x1B, 0x85, 0x1C, 0x85, 0x0F, 0xEA, 0x85, 0x02, 0xA9, 0x00, 0xEA,
0x30, 0x04, 0x24, 0x03, 0x30, 0x09, 0xA9, 0x02, 0x85, 0x09, 0x8D, 0x12, 0xF1, 0xD0, 0x1E, 0x24,
0x02, 0x30, 0x0C, 0xA9, 0x02, 0x85, 0x06, 0x8D, 0x18, 0xF1, 0x8D, 0x60, 0xF4, 0xD0, 0x0E, 0x85,
0x2C, 0xA9, 0x08, 0x85, 0x1B, 0x20, 0xCB, 0x04, 0xEA, 0x24, 0x02, 0x30, 0xD9, 0xA9, 0xFD, 0x85,
0x08, 0x6C, 0xFC, 0xFF, 0xEA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
// Initialize the 128 bytes of memory
if(mySettings.getBool("ramrandom"))
if(mySettings.getString("console") == "7800")
for(uInt32 t = 0; t < 128; ++t)
myRAM[t] = RAM_7800[t];
else if(mySettings.getBool("ramrandom"))
for(uInt32 t = 0; t < 128; ++t)
myRAM[t] = mySystem->randGenerator().next();
else
@ -95,7 +109,7 @@ void M6532::update()
// Update entire port state
port0.update();
port1.update();
myConsole.switches().update();
myConsole.switches().update(mySettings);
// Get new PA7 state
bool currPA7 = port0.myDigitalPinState[Controller::Four];

View File

@ -134,6 +134,7 @@ Settings::Settings(OSystem& osystem)
setInternal("loglevel", "1");
setInternal("logtoconsole", "0");
setInternal("tiadriven", "false");
setInternal("console", "2600"); // 7800
setInternal("cpurandom", "");
setInternal("ramrandom", "true");
setInternal("avoxport", "");

View File

@ -53,15 +53,31 @@ Switches::Switches(const Event& event, const Properties& properties)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Switches::update()
void Switches::update(const Settings& settings)
{
if(myEvent.get(Event::ConsoleColor) != 0)
bool is7800 = (settings.getString("console") == "7800");
if(is7800)
{
mySwitches |= 0x08;
if(myEvent.get(Event::Console7800Pause) != 0)
{
mySwitches &= ~0x08;
}
else
{
mySwitches |= 0x08;
}
}
else if(myEvent.get(Event::ConsoleBlackWhite) != 0)
else
{
mySwitches &= ~0x08;
if(myEvent.get(Event::ConsoleColor) != 0)
{
mySwitches |= 0x08;
}
else if(myEvent.get(Event::ConsoleBlackWhite) != 0)
{
mySwitches &= ~0x08;
}
}
if(myEvent.get(Event::ConsoleRightDiffA) != 0)

View File

@ -23,6 +23,7 @@ class Properties;
#include "Serializable.hxx"
#include "bspf.hxx"
#include "Settings.hxx"
/**
This class represents the console switches of the game console.
@ -57,7 +58,7 @@ class Switches : public Serializable
/**
Update the switches variable
*/
void update();
void update(const Settings& settings);
/**
Save the current state of the switches to the given Serializer.

View File

@ -184,7 +184,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
{
instance().eventHandler().leaveMenuMode();
instance().eventHandler().handleEvent(event, 1);
instance().console().switches().update();
instance().console().switches().update(instance().settings());
instance().console().tia().update();
instance().eventHandler().handleEvent(event, 0);
}