diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index 29c257ea3..7938ea237 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.26 2004-04-26 17:27:31 stephena Exp $ +// $Id: Console.cxx,v 1.27 2004-04-27 00:50:51 stephena Exp $ //============================================================================ #include @@ -207,7 +207,6 @@ Console::~Console() void Console::update() { myFrameBuffer.update(); -//FIXME mySound.update(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 187f14373..a2ed3982b 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.cxx,v 1.7 2003-11-24 14:51:06 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.8 2004-04-27 00:50:51 stephena Exp $ //============================================================================ #include @@ -409,9 +409,9 @@ void FrameBuffer::sendJoyEvent(StellaEvent::JoyStick stick, case MAIN_MENU: // if(key == StellaEvent::KCODE_RETURN) // myCurrentWidget = currentSelectedWidget(); - if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_UP) + if(code == StellaEvent::JAXIS_UP) moveCursorUp(1); - else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_DOWN) + else if(code == StellaEvent::JAXIS_DOWN) moveCursorDown(1); break; // MAIN_MENU @@ -422,9 +422,9 @@ void FrameBuffer::sendJoyEvent(StellaEvent::JoyStick stick, addJoyBinding(mySelectedEvent, stick, code); myRemapEventSelectedFlag = false; } - else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_UP) + else if(code == StellaEvent::JAXIS_UP) moveCursorUp(1); - else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_DOWN) + else if(code == StellaEvent::JAXIS_DOWN) moveCursorDown(1); // else if(key == StellaEvent::KCODE_PAGEUP) // movePageUp(); diff --git a/stella/src/emucore/Settings.cxx b/stella/src/emucore/Settings.cxx index cb9610100..af1a39ab3 100644 --- a/stella/src/emucore/Settings.cxx +++ b/stella/src/emucore/Settings.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: Settings.cxx,v 1.18 2004-04-04 02:03:15 stephena Exp $ +// $Id: Settings.cxx,v 1.19 2004-04-27 00:50:51 stephena Exp $ //============================================================================ #include @@ -53,8 +53,6 @@ Settings::Settings() set("hidecursor", "false"); set("volume", "-1"); set("accurate", "true"); - set("joyleft", "0"); - set("joyright", "1"); set("framerate", "60"); set("keymap", ""); set("joymap", ""); diff --git a/stella/src/emucore/Sound.cxx b/stella/src/emucore/Sound.cxx index 412b2e599..1b515f508 100644 --- a/stella/src/emucore/Sound.cxx +++ b/stella/src/emucore/Sound.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: Sound.cxx,v 1.10 2004-04-26 17:27:31 stephena Exp $ +// $Id: Sound.cxx,v 1.11 2004-04-27 00:50:51 stephena Exp $ //============================================================================ #include "Serializer.hxx" @@ -75,6 +75,8 @@ bool Sound::save(Serializer& out) out.putLong(reg); out.putLong(reg); + out.putLong(myLastSoundUpdateCycle); + return true; } @@ -93,5 +95,7 @@ bool Sound::load(Deserializer& in) reg = (uInt8) in.getLong(); reg = (uInt8) in.getLong(); + myLastSoundUpdateCycle = (Int32) in.getLong(); + return true; } diff --git a/stella/src/emucore/StellaEvent.hxx b/stella/src/emucore/StellaEvent.hxx index 115e8697e..fe12d6621 100644 --- a/stella/src/emucore/StellaEvent.hxx +++ b/stella/src/emucore/StellaEvent.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: StellaEvent.hxx,v 1.7 2003-09-30 18:46:12 stephena Exp $ +// $Id: StellaEvent.hxx,v 1.8 2004-04-27 00:50:51 stephena Exp $ //============================================================================ #ifndef STELLAEVENT_HXX @@ -28,7 +28,7 @@ by the frontends directly. @author Stephen Anthony - @version $Id: StellaEvent.hxx,v 1.7 2003-09-30 18:46:12 stephena Exp $ + @version $Id: StellaEvent.hxx,v 1.8 2004-04-27 00:50:51 stephena Exp $ */ class StellaEvent { @@ -80,7 +80,6 @@ class StellaEvent enum JoyStick { JSTICK_0, JSTICK_1, JSTICK_2, JSTICK_3, - JSTICK_4, JSTICK_5, JSTICK_6, JSTICK_7, LastJSTICK }; diff --git a/stella/src/emucore/TIA.cxx b/stella/src/emucore/TIA.cxx index 9e64ed2b6..ed21b6008 100644 --- a/stella/src/emucore/TIA.cxx +++ b/stella/src/emucore/TIA.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: TIA.cxx,v 1.31 2004-04-26 17:27:31 stephena Exp $ +// $Id: TIA.cxx,v 1.32 2004-04-27 00:50:51 stephena Exp $ //============================================================================ #include @@ -288,7 +288,6 @@ bool TIA::save(Serializer& out) { out.putString(device); -//FIXME out.putLong(myLastSoundUpdateCycle); out.putLong(myClockWhenFrameStarted); out.putLong(myClockStartDisplay); out.putLong(myClockStopDisplay); @@ -385,7 +384,6 @@ bool TIA::load(Deserializer& in) if(in.getString() != device) return false; -//FIXME myLastSoundUpdateCycle = (Int32) in.getLong(); myClockWhenFrameStarted = (Int32) in.getLong(); myClockStartDisplay = (Int32) in.getLong(); myClockStopDisplay = (Int32) in.getLong(); diff --git a/stella/src/ui/sdl/FrameBufferGL.cxx b/stella/src/ui/sdl/FrameBufferGL.cxx index 522a08b97..fe1b8e482 100644 --- a/stella/src/ui/sdl/FrameBufferGL.cxx +++ b/stella/src/ui/sdl/FrameBufferGL.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: FrameBufferGL.cxx,v 1.18 2004-04-26 12:49:46 stephena Exp $ +// $Id: FrameBufferGL.cxx,v 1.19 2004-04-27 00:50:52 stephena Exp $ //============================================================================ #include @@ -229,7 +229,7 @@ bool FrameBufferGL::init() << "Vendor : " << glGetString(GL_VENDOR) << endl << "Renderer: " << glGetString(GL_RENDERER) << endl << "Version : " << glGetString(GL_VERSION) << endl - << colormode.str() << endl; + << colormode.str() << endl << endl; } // Make sure that theUseFullScreenFlag sets up fullscreen mode correctly diff --git a/stella/src/ui/sdl/SettingsUNIX.cxx b/stella/src/ui/sdl/SettingsUNIX.cxx index 7051cff30..37f68b780 100644 --- a/stella/src/ui/sdl/SettingsUNIX.cxx +++ b/stella/src/ui/sdl/SettingsUNIX.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: SettingsUNIX.cxx,v 1.8 2004-04-04 02:03:15 stephena Exp $ +// $Id: SettingsUNIX.cxx,v 1.9 2004-04-27 00:50:52 stephena Exp $ //============================================================================ #include @@ -98,8 +98,6 @@ void SettingsUNIX::usage(string& message) #ifdef JOYSTICK_SUPPORT << " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n" << " or that real Atari 2600 paddles are being used\n" - << " -joyleft The joystick number representing the left controller\n" - << " -joyright The joystick number representing the right controller\n" #else << " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n" #endif diff --git a/stella/src/ui/sdl/SettingsWin32.cxx b/stella/src/ui/sdl/SettingsWin32.cxx index 521d6ed5a..d707093f3 100644 --- a/stella/src/ui/sdl/SettingsWin32.cxx +++ b/stella/src/ui/sdl/SettingsWin32.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: SettingsWin32.cxx,v 1.3 2004-04-04 02:03:15 stephena Exp $ +// $Id: SettingsWin32.cxx,v 1.4 2004-04-27 00:50:52 stephena Exp $ //============================================================================ #include @@ -104,8 +104,6 @@ void SettingsWin32::usage(string& message) #ifdef JOYSTICK_SUPPORT << " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n" << " or that real Atari 2600 paddles are being used\n" - << " -joyleft The joystick number representing the left controller\n" - << " -joyright The joystick number representing the right controller\n" #else << " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n" #endif diff --git a/stella/src/ui/sdl/mainSDL.cxx b/stella/src/ui/sdl/mainSDL.cxx index 153911d96..0f6642f86 100644 --- a/stella/src/ui/sdl/mainSDL.cxx +++ b/stella/src/ui/sdl/mainSDL.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: mainSDL.cxx,v 1.72 2004-04-26 12:49:46 stephena Exp $ +// $Id: mainSDL.cxx,v 1.73 2004-04-27 00:50:52 stephena Exp $ //============================================================================ #include @@ -64,11 +64,20 @@ static uInt32 getTicks(); static bool setupProperties(PropertiesSet& set); #ifdef JOYSTICK_SUPPORT - static SDL_Joystick* theLeftJoystick = (SDL_Joystick*) NULL; - static SDL_Joystick* theRightJoystick = (SDL_Joystick*) NULL; - static uInt32 theLeftJoystickNumber; - static uInt32 theRightJoystickNumber; + static SDL_Joystick* theJoysticks[StellaEvent::LastJSTICK]; // static uInt32 thePaddleNumber; + + // Lookup table for joystick numbers and events + StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK] = { + StellaEvent::JSTICK_0, StellaEvent::JSTICK_1, + StellaEvent::JSTICK_2, StellaEvent::JSTICK_3 + }; + StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE] = { + StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2, + StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5, + StellaEvent::JBUTTON_6, StellaEvent::JBUTTON_7, StellaEvent::JBUTTON_8, + StellaEvent::JBUTTON_9 + }; #endif // Pointer to the console object or the null pointer @@ -221,19 +230,6 @@ static Switches keyList[] = { { SDLK_PAGEDOWN, StellaEvent::KCODE_PAGEDOWN } }; -// Lookup table for joystick numbers and events -StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK] = { - StellaEvent::JSTICK_0, StellaEvent::JSTICK_1, - StellaEvent::JSTICK_2, StellaEvent::JSTICK_3 -}; -StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE] = { - StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2, - StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5, - StellaEvent::JBUTTON_6, StellaEvent::JBUTTON_7, StellaEvent::JBUTTON_8, - StellaEvent::JBUTTON_9 -}; - - /** Returns number of ticks in microseconds */ @@ -260,41 +256,31 @@ inline uInt32 getTicks() bool setupJoystick() { #ifdef JOYSTICK_SUPPORT + // First clear the joystick array + for(uInt32 i = 0; i < StellaEvent::LastJSTICK; i++) + theJoysticks[i] = (SDL_Joystick*) NULL; + // Initialize the joystick subsystem if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) || (SDL_NumJoysticks() <= 0)) { if(theShowInfoFlag) cout << "No joysticks present, use the keyboard.\n"; - theLeftJoystick = theRightJoystick = 0; + return true; } - theLeftJoystickNumber = (uInt32) theConsole->settings().getInt("joyleft"); - if((theLeftJoystick = SDL_JoystickOpen(theLeftJoystickNumber)) != NULL) + // Try to open as many joysticks as possible (up to 4) + // Let the user decide how to map them + uInt32 limit = SDL_NumJoysticks() <= StellaEvent::LastJSTICK ? + SDL_NumJoysticks() : StellaEvent::LastJSTICK; + for(uInt32 i = 0; i < limit; i++) { - if(theShowInfoFlag) - cout << "Left joystick is a " - << SDL_JoystickName(theLeftJoystickNumber) - << " with " << SDL_JoystickNumButtons(theLeftJoystick) << " buttons.\n"; - } - else - { - if(theShowInfoFlag) - cout << "Left joystick not present, use keyboard instead.\n"; - } - - theRightJoystickNumber = theConsole->settings().getInt("joyright"); - if((theRightJoystick = SDL_JoystickOpen(theRightJoystickNumber)) != NULL) - { - if(theShowInfoFlag) - cout << "Right joystick is a " - << SDL_JoystickName(theRightJoystickNumber) - << " with " << SDL_JoystickNumButtons(theRightJoystick) << " buttons.\n"; - } - else - { - if(theShowInfoFlag) - cout << "Right joystick not present, use keyboard instead.\n"; + theJoysticks[i] = SDL_JoystickOpen(i); + if(theJoysticks[i] != NULL && theShowInfoFlag) + { + cout << "Joystick " << i << ": " << SDL_JoystickName(i) + << " with " << SDL_JoystickNumButtons(theJoysticks[i]) << " buttons.\n"; + } } #endif @@ -540,6 +526,7 @@ void handleEvents() if(event.jbutton.which >= StellaEvent::LastJSTICK) return; + stick = joyList[event.jbutton.which]; if((event.type == SDL_JOYBUTTONDOWN) || (event.type == SDL_JOYBUTTONUP)) @@ -644,10 +631,11 @@ void cleanup() if(SDL_WasInit(SDL_INIT_EVERYTHING)) { #ifdef JOYSTICK_SUPPORT - if(SDL_JoystickOpened(theLeftJoystickNumber)) - SDL_JoystickClose(theLeftJoystick); - if(SDL_JoystickOpened(theRightJoystickNumber)) - SDL_JoystickClose(theRightJoystick); + for(uInt32 i = 0; i < StellaEvent::LastJSTICK; i++) + { + if(SDL_JoystickOpened(i)) + SDL_JoystickClose(theJoysticks[i]); + } #endif SDL_Quit(); diff --git a/stella/src/ui/sound/SoundSDL.cxx b/stella/src/ui/sound/SoundSDL.cxx index 61f9a3101..f8e456e84 100644 --- a/stella/src/ui/sound/SoundSDL.cxx +++ b/stella/src/ui/sound/SoundSDL.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: SoundSDL.cxx,v 1.9 2004-04-26 17:27:32 stephena Exp $ +// $Id: SoundSDL.cxx,v 1.10 2004-04-27 00:50:52 stephena Exp $ //============================================================================ #include @@ -25,7 +25,7 @@ #include "SoundSDL.hxx" -#define DIGITAL_SOUND +//#define DIGITAL_SOUND // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SoundSDL::SoundSDL(uInt32 fragsize, uInt32 queuesize) @@ -235,6 +235,8 @@ bool SoundSDL::save(Serializer& out) out.putLong(reg4); out.putLong(reg5); out.putLong(reg6); + + out.putLong(myLastSoundUpdateCycle); } catch(char *msg) { @@ -268,6 +270,8 @@ bool SoundSDL::load(Deserializer& in) reg5 = (uInt8) in.getLong(); reg6 = (uInt8) in.getLong(); + myLastSoundUpdateCycle = (Int32) in.getLong(); + // Only update the TIA sound registers if sound is enabled if(myIsInitializedFlag) Tia_set_registers(reg1, reg2, reg3, reg4, reg5, reg6);