diff --git a/stella/src/debugger/EquateList.cxx b/stella/src/debugger/EquateList.cxx index 9bdb0b961..3633b7511 100644 --- a/stella/src/debugger/EquateList.cxx +++ b/stella/src/debugger/EquateList.cxx @@ -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: EquateList.cxx,v 1.32 2008-05-06 16:39:10 stephena Exp $ +// $Id: EquateList.cxx,v 1.33 2008-05-11 21:18:34 stephena Exp $ //============================================================================ #include @@ -66,14 +66,21 @@ void EquateList::addEquate(const string& label, int address) // as well, and we don't yet have an infrastructure to determine that, // so the entire region is marked as read-write equate_t flags = EQF_READ; +#if 0 if(address >= 0x80 && address <= 0xff) flags = EQF_RW; else if((address & 0x1000) == 0x1000) flags = EQF_RW; else -//{ cerr << "label = " << label << ", address = " << hex << address << " discarded\n"; + { + cerr << "label = " << label << ", address = " << hex << address << " discarded\n"; return; // don't know what else to do for now -//} + } +#else + // The above section of code is deactivated until a better means of + // determining constants vs. addresses is found + flags = EQF_RW; +#endif removeEquate(label); diff --git a/stella/src/debugger/gui/RomListWidget.cxx b/stella/src/debugger/gui/RomListWidget.cxx index 85dbe0a16..7e4909098 100644 --- a/stella/src/debugger/gui/RomListWidget.cxx +++ b/stella/src/debugger/gui/RomListWidget.cxx @@ -13,12 +13,13 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: RomListWidget.cxx,v 1.11 2008-02-06 13:45:20 stephena Exp $ +// $Id: RomListWidget.cxx,v 1.12 2008-05-11 21:18:34 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project //============================================================================ +#include "bspf.hxx" #include "ContextMenu.hxx" #include "RomListWidget.hxx" @@ -40,8 +41,12 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font, myMenu->setList(l); - myLabelWidth = font.getMaxCharWidth() * 16; - myBytesWidth = font.getMaxCharWidth() * 12; + // Take advantage of a wide debugger window when possible + const int fontWidth = font.getMaxCharWidth(), + numchars = w / fontWidth; + + myLabelWidth = BSPF_max(20, int(0.35 * (numchars - 12))) * fontWidth; + myBytesWidth = 12 * fontWidth; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index dd2818a5b..14e8bcfd4 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.cxx @@ -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: Console.cxx,v 1.139 2008-05-08 20:23:31 stephena Exp $ +// $Id: Console.cxx,v 1.140 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #include @@ -634,7 +634,7 @@ void Console::setControllers() } else if(right == "ATARIVOX") { - string eepromfile = // fixme myOSystem->baseDir() + BSPF_PATH_SEPARATOR + + string eepromfile = myOSystem->baseDir() + BSPF_PATH_SEPARATOR + "atarivox_eeprom.dat"; myControllers[rightPort] = myAVox = new AtariVox(Controller::Right, *myEvent, *mySystem, myOSystem->serialPort(), @@ -642,7 +642,7 @@ void Console::setControllers() } else if(right == "SAVEKEY") { - string eepromfile = // fixme myOSystem->baseDir() + BSPF_PATH_SEPARATOR + + string eepromfile = myOSystem->baseDir() + BSPF_PATH_SEPARATOR + "savekey_eeprom.dat"; myControllers[rightPort] = new SaveKey(Controller::Right, *myEvent, *mySystem, eepromfile); diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 9e6279cf0..839f6e29c 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -1,4 +1,3 @@ - //============================================================================ // // SSSS tt lll lll @@ -14,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.221 2008-03-30 15:01:38 stephena Exp $ +// $Id: EventHandler.cxx,v 1.222 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #include @@ -31,6 +30,7 @@ #include "Launcher.hxx" #include "Menu.hxx" #include "OSystem.hxx" +#include "Joystick.hxx" #include "Paddles.hxx" #include "PropsSet.hxx" #include "ScrollBarWidget.hxx" @@ -55,8 +55,6 @@ } #endif -#define JOY_DEADZONE 3200 - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventHandler::EventHandler(OSystem* osystem) : myOSystem(osystem), @@ -144,6 +142,7 @@ void EventHandler::initialize() myGrabMouseFlag = myOSystem->settings().getBool("grabmouse"); + Joystick::setDeadZone(myOSystem->settings().getInt("joydeadzone")); Paddles::setDigitalSpeed(myOSystem->settings().getInt("pspeed")); // Set number of lines a mousewheel will scroll @@ -849,8 +848,10 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value) myEvent->set(Event::SARightAxis1Value, value); break; default: + { // Otherwise, we know the event is digital - if(value > -JOY_DEADZONE && value < JOY_DEADZONE) + int deadzone = Joystick::deadzone(); + if(value > -deadzone && value < deadzone) { // Turn off both events, since we don't know exactly which one // was previously activated. @@ -860,6 +861,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value) else handleEvent(value < 0 ? eventAxisNeg : eventAxisPos, 1); break; + } } #endif } diff --git a/stella/src/emucore/Joystick.cxx b/stella/src/emucore/Joystick.cxx index b7afffd70..661023050 100644 --- a/stella/src/emucore/Joystick.cxx +++ b/stella/src/emucore/Joystick.cxx @@ -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: Joystick.cxx,v 1.12 2008-04-13 23:43:14 stephena Exp $ +// $Id: Joystick.cxx,v 1.13 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #include "Event.hxx" @@ -85,3 +85,15 @@ void Joystick::update() if(yaxis < -16384) myDigitalPinState[One] = false; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Joystick::setDeadZone(int deadzone) +{ + if(deadzone < 0) deadzone = 0; + if(deadzone > 29) deadzone = 29; + + _DEAD_ZONE = 3200 + deadzone * 1000; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int Joystick::_DEAD_ZONE = 3200; diff --git a/stella/src/emucore/Joystick.hxx b/stella/src/emucore/Joystick.hxx index 5d8e2eb6a..278d6b60a 100644 --- a/stella/src/emucore/Joystick.hxx +++ b/stella/src/emucore/Joystick.hxx @@ -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: Joystick.hxx,v 1.10 2008-04-13 23:43:14 stephena Exp $ +// $Id: Joystick.hxx,v 1.11 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #ifndef JOYSTICK_HXX @@ -27,7 +27,7 @@ The standard Atari 2600 joystick controller. @author Bradford W. Mott - @version $Id: Joystick.hxx,v 1.10 2008-04-13 23:43:14 stephena Exp $ + @version $Id: Joystick.hxx,v 1.11 2008-05-11 21:18:35 stephena Exp $ */ class Joystick : public Controller { @@ -53,12 +53,22 @@ class Joystick : public Controller */ virtual void update(); + /** + Sets the deadzone amount for real analog joysticks. + Technically, this isn't really used by the Joystick class at all, + but it seemed like the best place to put it. + */ + static void setDeadZone(int deadzone); + inline static int deadzone() { return _DEAD_ZONE; } + private: // Pre-compute the events we care about based on given port // This will eliminate test for left or right port in update() Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myXAxisValue, myYAxisValue, myFireEvent; + + static int _DEAD_ZONE; }; #endif diff --git a/stella/src/emucore/MT24LC256.cxx b/stella/src/emucore/MT24LC256.cxx index 92569270a..c1c584d81 100644 --- a/stella/src/emucore/MT24LC256.cxx +++ b/stella/src/emucore/MT24LC256.cxx @@ -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: MT24LC256.cxx,v 1.9 2008-05-10 22:21:09 stephena Exp $ +// $Id: MT24LC256.cxx,v 1.10 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #include @@ -54,7 +54,9 @@ MT24LC256::MT24LC256(const string& filename, const System& system) myCyclesWhenTimerSet(0), myCyclesWhenSDASet(0), myCyclesWhenSCLSet(0), - myDataFile(filename) + myDataFile(filename), + myDataFileExists(false), + myDataChanged(false) { // First initialize the I2C state jpee_init(); @@ -70,21 +72,27 @@ MT24LC256::MT24LC256(const string& filename, const System& system) { in.seekg(0, ios::beg); in.read((char*)myData, 32768); + myDataFileExists = true; } in.close(); } + else + myDataFileExists = false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MT24LC256::~MT24LC256() { - // Save EEPROM data to external file - ofstream out; - out.open(myDataFile.c_str(), ios_base::binary); - if(out.is_open()) + // Save EEPROM data to external file only when necessary + if(!myDataFileExists || myDataChanged) { - out.write((char*)myData, 32768); - out.close(); + ofstream out; + out.open(myDataFile.c_str(), ios_base::binary); + if(out.is_open()) + { + out.write((char*)myData, 32768); + out.close(); + } } } @@ -208,6 +216,7 @@ void MT24LC256::jpee_data_stop() } for (i=3; i @@ -69,6 +69,7 @@ Settings::Settings(OSystem* osystem) setInternal("joymap", ""); setInternal("joyaxismap", ""); setInternal("joyhatmap", ""); + setInternal("joydeadzone", "0"); setInternal("pspeed", "6"); setInternal("sa1", "left"); setInternal("sa2", "right"); @@ -246,6 +247,12 @@ void Settings::validate() if(i < 1 || i > 10) setInternal("zoom_tia", "2"); + i = getInt("joydeadzone"); + if(i < 0) + setInternal("joydeadzone", "0"); + else if(i > 29) + setInternal("joydeadzone", "29"); + i = getInt("pspeed"); if(i < 1) setInternal("pspeed", "1"); @@ -312,6 +319,7 @@ void Settings::usage() #endif << " -cheat Use the specified cheatcode (see manual for description)\n" << " -showinfo <1|0> Shows some game info\n" + << " -joydeadzone Sets 'deadzone' area for analog joysticks (0-29)\n" << " -pspeed Speed of digital emulated paddle movement (1-15)\n" << " -sa1 Stelladaptor 1 emulates specified joystick port\n" << " -sa2 Stelladaptor 2 emulates specified joystick port\n" diff --git a/stella/src/gui/DialogContainer.cxx b/stella/src/gui/DialogContainer.cxx index 32ecc1eb8..bd1c33750 100644 --- a/stella/src/gui/DialogContainer.cxx +++ b/stella/src/gui/DialogContainer.cxx @@ -13,18 +13,17 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DialogContainer.cxx,v 1.41 2008-03-13 22:58:06 stephena Exp $ +// $Id: DialogContainer.cxx,v 1.42 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #include "OSystem.hxx" #include "Dialog.hxx" #include "Stack.hxx" #include "EventHandler.hxx" +#include "Joystick.hxx" #include "bspf.hxx" #include "DialogContainer.hxx" -#define JOY_DEADZONE 3200 - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DialogContainer::DialogContainer(OSystem* osystem) : myOSystem(osystem), @@ -290,10 +289,11 @@ void DialogContainer::handleJoyAxisEvent(int stick, int axis, int value) // Send the event to the dialog box on the top of the stack Dialog* activeDialog = myDialogStack.top(); - if(value > JOY_DEADZONE) - value -= JOY_DEADZONE; - else if(value < -JOY_DEADZONE ) - value += JOY_DEADZONE; + int deadzone = Joystick::deadzone(); + if(value > deadzone) + value -= deadzone; + else if(value < -deadzone ) + value += deadzone; else value = 0; diff --git a/stella/src/gui/GameInfoDialog.cxx b/stella/src/gui/GameInfoDialog.cxx index 31400aa45..b7814bd5d 100644 --- a/stella/src/gui/GameInfoDialog.cxx +++ b/stella/src/gui/GameInfoDialog.cxx @@ -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: GameInfoDialog.cxx,v 1.53 2008-04-11 17:56:34 stephena Exp $ +// $Id: GameInfoDialog.cxx,v 1.54 2008-05-11 21:18:35 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -552,7 +552,7 @@ void GameInfoDialog::saveConfig() // Controller properties tag = myP0Controller->getSelectedTag(); - for(i = 0; i < 5; ++i) + for(i = 0; i < kNumControllerTypes; ++i) { if(i == tag-1) { @@ -562,7 +562,7 @@ void GameInfoDialog::saveConfig() } tag = myP1Controller->getSelectedTag(); - for(i = 0; i < 5; ++i) + for(i = 0; i < kNumControllerTypes; ++i) { if(i == tag-1) { @@ -672,12 +672,13 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const char* GameInfoDialog::ourControllerList[kNumControllerTypes][2] = { - { "AtariVox", "ATARIVOX" }, + { "Joystick", "JOYSTICK" }, + { "Paddles", "PADDLES" }, { "Booster-Grip", "BOOSTER-GRIP" }, { "Driving", "DRIVING" }, { "Keyboard", "KEYBOARD" }, - { "Paddles", "PADDLES" }, - { "Joystick", "JOYSTICK" } + { "AtariVox", "ATARIVOX" }, + { "SaveKey", "SAVEKEY" } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/GameInfoDialog.hxx b/stella/src/gui/GameInfoDialog.hxx index 1735b5c59..5253d6018 100644 --- a/stella/src/gui/GameInfoDialog.hxx +++ b/stella/src/gui/GameInfoDialog.hxx @@ -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: GameInfoDialog.hxx,v 1.31 2008-04-11 17:56:34 stephena Exp $ +// $Id: GameInfoDialog.hxx,v 1.32 2008-05-11 21:18:35 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -99,7 +99,7 @@ class GameInfoDialog : public Dialog, public CommandSender kPhosphorChanged = 'PPch', kPPBlendChanged = 'PBch', kNumCartTypes = 25, - kNumControllerTypes = 6 + kNumControllerTypes = 7 }; /** Game properties for currently loaded ROM */ diff --git a/stella/src/gui/InputDialog.cxx b/stella/src/gui/InputDialog.cxx index bb8668850..c57a6efaf 100644 --- a/stella/src/gui/InputDialog.cxx +++ b/stella/src/gui/InputDialog.cxx @@ -13,13 +13,14 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: InputDialog.cxx,v 1.31 2008-04-11 17:56:34 stephena Exp $ +// $Id: InputDialog.cxx,v 1.32 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #include "bspf.hxx" #include "Array.hxx" #include "OSystem.hxx" +#include "Joystick.hxx" #include "Paddles.hxx" #include "Settings.hxx" #include "EventMappingWidget.hxx" @@ -119,10 +120,22 @@ void InputDialog::addVDeviceTab(const GUI::Font& font) myRightPort->appendEntry("right virtual port", 2); wid.push_back(myRightPort); - // Add 'mouse to paddle' mapping - ypos += 2*lineHeight; lwidth = font.getStringWidth("Paddle threshold: "); pwidth = font.getMaxCharWidth() * 5; + + // Add joystick deadzone setting + ypos += 2*lineHeight; + myDeadzone = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight, + "Joy deadzone: ", lwidth, kDeadzoneChanged); + myDeadzone->setMinValue(0); myDeadzone->setMaxValue(29); + xpos += myDeadzone->getWidth() + 5; + myDeadzoneLabel = new StaticTextWidget(myTab, font, xpos, ypos+1, 24, lineHeight, + "", kTextAlignLeft); + myDeadzoneLabel->setFlags(WIDGET_CLEARBG); + wid.push_back(myDeadzone); + + // Add 'mouse to paddle' mapping + xpos = 5; ypos += lineHeight + 3; myPaddleMode = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight, "Mouse is paddle: ", lwidth, kPaddleChanged); myPaddleMode->setMinValue(0); myPaddleMode->setMaxValue(3); @@ -168,6 +181,10 @@ void InputDialog::loadConfig() int rport = sa2 == "right" ? 2 : 1; myRightPort->setSelectedTag(rport); + // Joystick deadzone + myDeadzone->setValue(instance()->settings().getInt("joydeadzone")); + myDeadzoneLabel->setLabel(instance()->settings().getString("joydeadzone")); + // Paddle mode myPaddleMode->setValue(0); myPaddleModeLabel->setLabel("0"); @@ -190,6 +207,11 @@ void InputDialog::saveConfig() const string& sa2 = myRightPort->getSelectedTag() == 2 ? "right" : "left"; instance()->eventHandler().mapStelladaptors(sa1, sa2); + // Joystick deadzone + int deadzone = myDeadzone->getValue(); + instance()->settings().setInt("joydeadzone", deadzone); + Joystick::setDeadZone(deadzone); + // Paddle mode Paddles::setMouseIsPaddle(myPaddleMode->getValue()); @@ -276,6 +298,10 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd, myRightPort->getSelectedTag() == 2 ? 1 : 2); break; + case kDeadzoneChanged: + myDeadzoneLabel->setValue(myDeadzone->getValue()); + break; + case kPaddleChanged: myPaddleModeLabel->setValue(myPaddleMode->getValue()); break; diff --git a/stella/src/gui/InputDialog.hxx b/stella/src/gui/InputDialog.hxx index 77b94b0d7..2ad7350ef 100644 --- a/stella/src/gui/InputDialog.hxx +++ b/stella/src/gui/InputDialog.hxx @@ -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: InputDialog.hxx,v 1.17 2008-04-11 17:56:34 stephena Exp $ +// $Id: InputDialog.hxx,v 1.18 2008-05-11 21:18:35 stephena Exp $ //============================================================================ #ifndef INPUT_DIALOG_HXX @@ -54,10 +54,11 @@ class InputDialog : public Dialog private: enum { - kLeftChanged = 'LCch', - kRightChanged = 'RCch', - kPaddleChanged = 'PDch', - kPSpeedChanged = 'PSch' + kLeftChanged = 'LCch', + kRightChanged = 'RCch', + kDeadzoneChanged = 'DZch', + kPaddleChanged = 'PDch', + kPSpeedChanged = 'PSch' }; TabWidget* myTab; @@ -68,6 +69,8 @@ class InputDialog : public Dialog PopUpWidget* myLeftPort; PopUpWidget* myRightPort; + SliderWidget* myDeadzone; + StaticTextWidget* myDeadzoneLabel; SliderWidget* myPaddleMode; StaticTextWidget* myPaddleModeLabel; SliderWidget* myPaddleSpeed; diff --git a/stella/src/gui/Widget.hxx b/stella/src/gui/Widget.hxx index efea9532e..30f9c4a98 100644 --- a/stella/src/gui/Widget.hxx +++ b/stella/src/gui/Widget.hxx @@ -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: Widget.hxx,v 1.60 2008-04-29 15:13:16 stephena Exp $ +// $Id: Widget.hxx,v 1.61 2008-05-11 21:18:35 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -88,7 +88,7 @@ enum { This is the base class for all widgets. @author Stephen Anthony - @version $Id: Widget.hxx,v 1.60 2008-04-29 15:13:16 stephena Exp $ + @version $Id: Widget.hxx,v 1.61 2008-05-11 21:18:35 stephena Exp $ */ class Widget : public GuiObject { @@ -290,12 +290,12 @@ class SliderWidget : public ButtonWidget void setValue(int value); int getValue() const { return _value; } - void setMinValue(int value); - int getMinValue() const { return _valueMin; } - void setMaxValue(int value); - int getMaxValue() const { return _valueMax; } - void setStepValue(int value); - int getStepValue() const { return _stepValue; } + void setMinValue(int value); + int getMinValue() const { return _valueMin; } + void setMaxValue(int value); + int getMaxValue() const { return _valueMax; } + void setStepValue(int value); + int getStepValue() const { return _stepValue; } virtual void handleMouseMoved(int x, int y, int button); virtual void handleMouseDown(int x, int y, int button, int clickCount);