diff --git a/stella/src/build/makefile b/stella/src/build/makefile index c89af2447..3e87411c5 100644 --- a/stella/src/build/makefile +++ b/stella/src/build/makefile @@ -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: makefile,v 1.66 2005-03-14 04:08:12 stephena Exp $ +## $Id: makefile,v 1.67 2005-03-26 19:26:47 stephena Exp $ ##============================================================================ ##============================================================================ @@ -146,6 +146,9 @@ win32-gl: ############################################################################### M6502_OBJS = D6502.o Device.o M6502.o M6502Low.o M6502Hi.o NullDev.o System.o +GUI_OBJS = StellaFont.o Menu.o Widget.o PopUpWidget.o Dialog.o \ + OptionsDialog.o VideoDialog.o AudioDialog.o + CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \ CartF8.o CartF8SC.o CartFASC.o CartFE.o CartMC.o CartCV.o \ @@ -153,9 +156,8 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \ Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \ Serializer.o Deserializer.o TIASound.o EventHandler.o FrameBuffer.o \ - OSystem.o StellaFont.o Menu.o Widget.o PopUpWidget.o Dialog.o \ - OptionsDialog.o VideoDialog.o \ - $(M6502_OBJS) + OSystem.o \ + $(M6502_OBJS) $(GUI_OBJS) stella: $(CORE_OBJS) $(OBJS) $(LD) -o $(EXE_NAME) $(CORE_OBJS) $(OBJS) $(LDFLAGS) $(LDLIBS) @@ -373,3 +375,6 @@ OptionsDialog.o: $(GUI)/OptionsDialog.cxx $(GUI)/OptionsDialog.hxx VideoDialog.o: $(GUI)/VideoDialog.cxx $(GUI)/VideoDialog.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/VideoDialog.cxx + +AudioDialog.o: $(GUI)/AudioDialog.cxx $(GUI)/AudioDialog.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/AudioDialog.cxx diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index 49cb4a4a9..4d74a0391 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.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: FrameBufferSoft.cxx,v 1.12 2005-03-14 04:08:13 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.13 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #include @@ -430,6 +430,32 @@ void FrameBufferSoft::drawChar(uInt8 chr, uInt32 xorig, uInt32 yorig, } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferSoft::drawBitmap(uInt32* bitmap, Int32 xorig, Int32 yorig, + OverlayColor color, Int32 h) +{ + SDL_Rect rect; + for(int y = 0; y < h; y++) + { + uInt32 mask = 0xF0000000; +// if(ty + y < 0 || ty + y >= _screen.h) +// continue; + + for(int x = 0; x < 8; x++, mask >>= 4) + { +// if(tx + x < 0 || tx + x >= _screen.w) +// continue; + if(bitmap[y] & mask) + { + rect.x = (x + xorig) * theZoomLevel; + rect.y = (y + yorig) * theZoomLevel; + rect.w = rect.h = theZoomLevel; + SDL_FillRect(myScreen, &rect, myGUIPalette[color]); + } + } + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RectList::RectList(Uint32 size) { diff --git a/stella/src/common/FrameBufferSoft.hxx b/stella/src/common/FrameBufferSoft.hxx index bc9262eac..c388808c6 100644 --- a/stella/src/common/FrameBufferSoft.hxx +++ b/stella/src/common/FrameBufferSoft.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: FrameBufferSoft.hxx,v 1.9 2005-03-13 03:38:39 stephena Exp $ +// $Id: FrameBufferSoft.hxx,v 1.10 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_SOFT_HXX @@ -34,7 +34,7 @@ class RectList; This class implements an SDL software framebuffer. @author Stephen Anthony - @version $Id: FrameBufferSoft.hxx,v 1.9 2005-03-13 03:38:39 stephena Exp $ + @version $Id: FrameBufferSoft.hxx,v 1.10 2005-03-26 19:26:47 stephena Exp $ */ class FrameBufferSoft : public FrameBuffer { @@ -171,6 +171,18 @@ class FrameBufferSoft : public FrameBuffer */ virtual void drawChar(uInt8 c, uInt32 x, uInt32 y, OverlayColor color); + /** + This routine is called to draw the bitmap image. + + @param bitmap The data to draw + @param x The x coordinate + @param y The y coordinate + @param color The color of the character + @param h The height of the data image + */ + virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, + Int32 h = 8); + private: // Used in the dirty update of the SDL surface RectList* myRectList; diff --git a/stella/src/common/SoundSDL.cxx b/stella/src/common/SoundSDL.cxx index 1336f3e51..73dcf7539 100644 --- a/stella/src/common/SoundSDL.cxx +++ b/stella/src/common/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.11 2005-02-22 18:40:55 stephena Exp $ +// $Id: SoundSDL.cxx,v 1.12 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #include @@ -37,72 +37,7 @@ SoundSDL::SoundSDL(OSystem* osystem) myFragmentSizeLogBase2(0), myIsMuted(false) { - if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) - { - cerr << "WARNING: Couldn't initialize SDL audio system! " << endl; - cerr << " " << SDL_GetError() << endl; - return; - } - else - { - uInt32 fragsize = myOSystem->settings().getInt("fragsize"); - - SDL_AudioSpec desired; - desired.freq = 31400; - desired.format = AUDIO_U8; - desired.channels = 1; - desired.samples = fragsize; - desired.callback = callback; - desired.userdata = (void*)this; - - if(SDL_OpenAudio(&desired, &myHardwareSpec) < 0) - { - cerr << "WARNING: Couldn't open SDL audio system! " << endl; - cerr << " " << SDL_GetError() << endl; - return; - } - - // Make sure the sample buffer isn't to big (if it is the sound code - // will not work so we'll need to disable the audio support) - if(((float)myHardwareSpec.samples / (float)myHardwareSpec.freq) >= 0.25) - { - cerr << "WARNING: Sound device doesn't support realtime audio! Make "; - cerr << "sure a sound" << endl; - cerr << " server isn't running. Audio is disabled." << endl; - - SDL_CloseAudio(); - return; - } - - myIsInitializedFlag = true; - myIsMuted = false; - myFragmentSizeLogBase2 = log((double)myHardwareSpec.samples) / log(2.0); - -/* - cerr << "Freq: " << (int)myHardwareSpec.freq << endl; - cerr << "Format: " << (int)myHardwareSpec.format << endl; - cerr << "Channels: " << (int)myHardwareSpec.channels << endl; - cerr << "Silence: " << (int)myHardwareSpec.silence << endl; - cerr << "Samples: " << (int)myHardwareSpec.samples << endl; - cerr << "Size: " << (int)myHardwareSpec.size << endl; -*/ - - // Now initialize the TIASound object which will actually generate sound - Tia_sound_init(31400, myHardwareSpec.freq); - - // And start the SDL sound subsystem ... - SDL_PauseAudio(0); - - // Adjust volume to that defined in settings - myVolume = myOSystem->settings().getInt("volume"); - setVolume(myVolume); - - // Show some info - if(myOSystem->settings().getBool("showinfo")) - cout << "Sound enabled:" << endl - << " Volume : " << myVolume << endl - << " Frag size: " << fragsize << endl << endl; - } + initialize(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -118,6 +53,95 @@ SoundSDL::~SoundSDL() myIsInitializedFlag = false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void SoundSDL::initialize(bool forcerestart) +{ + if(forcerestart && myIsInitializedFlag) + { + SDL_PauseAudio(1); + SDL_CloseAudio(); + myIsInitializedFlag = false; + } + + bool isAlreadyInitialized = (SDL_WasInit(SDL_INIT_AUDIO) & SDL_INIT_AUDIO) > 0; + + if(!isAlreadyInitialized) + { + myIsInitializedFlag = false; + myIsMuted = false; + myLastRegisterSetCycle = 0; + + if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) + { + cerr << "WARNING: Couldn't initialize SDL audio system! " << endl; + cerr << " " << SDL_GetError() << endl; + return; + } + else + { + uInt32 fragsize = myOSystem->settings().getInt("fragsize"); + + SDL_AudioSpec desired; + desired.freq = 31400; + desired.format = AUDIO_U8; + desired.channels = 1; + desired.samples = fragsize; + desired.callback = callback; + desired.userdata = (void*)this; + + if(SDL_OpenAudio(&desired, &myHardwareSpec) < 0) + { + cerr << "WARNING: Couldn't open SDL audio system! " << endl; + cerr << " " << SDL_GetError() << endl; + return; + } + + // Make sure the sample buffer isn't to big (if it is the sound code + // will not work so we'll need to disable the audio support) + if(((float)myHardwareSpec.samples / (float)myHardwareSpec.freq) >= 0.25) + { + cerr << "WARNING: Sound device doesn't support realtime audio! Make "; + cerr << "sure a sound" << endl; + cerr << " server isn't running. Audio is disabled." << endl; + + SDL_CloseAudio(); + return; + } + + myIsInitializedFlag = true; + myIsMuted = false; + myFragmentSizeLogBase2 = log((double)myHardwareSpec.samples) / log(2.0); + + /* + cerr << "Freq: " << (int)myHardwareSpec.freq << endl; + cerr << "Format: " << (int)myHardwareSpec.format << endl; + cerr << "Channels: " << (int)myHardwareSpec.channels << endl; + cerr << "Silence: " << (int)myHardwareSpec.silence << endl; + cerr << "Samples: " << (int)myHardwareSpec.samples << endl; + cerr << "Size: " << (int)myHardwareSpec.size << endl; + */ + + // Now initialize the TIASound object which will actually generate sound + Tia_sound_init(31400, myHardwareSpec.freq); + + // And start the SDL sound subsystem ... + SDL_PauseAudio(0); + + // Adjust volume to that defined in settings + myVolume = myOSystem->settings().getInt("volume"); + setVolume(myVolume); + + // Show some info + if(myOSystem->settings().getBool("showinfo")) + cout << "Sound enabled:" << endl + << " Volume : " << myVolume << endl + << " Frag size: " << fragsize << endl << endl; + } + } + + +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool SoundSDL::isSuccessfullyInitialized() const { diff --git a/stella/src/common/SoundSDL.hxx b/stella/src/common/SoundSDL.hxx index e8c4510dd..04fb0b895 100644 --- a/stella/src/common/SoundSDL.hxx +++ b/stella/src/common/SoundSDL.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: SoundSDL.hxx,v 1.8 2005-02-22 02:59:53 stephena Exp $ +// $Id: SoundSDL.hxx,v 1.9 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #ifndef SOUNDSDL_HXX @@ -31,7 +31,7 @@ class OSystem; This class implements the sound API for SDL. @author Stephen Anthony and Bradford W. Mott - @version $Id: SoundSDL.hxx,v 1.8 2005-02-22 02:59:53 stephena Exp $ + @version $Id: SoundSDL.hxx,v 1.9 2005-03-26 19:26:47 stephena Exp $ */ class SoundSDL : public Sound { @@ -48,6 +48,14 @@ class SoundSDL : public Sound virtual ~SoundSDL(); public: + /** + Initializes the sound device. This must be called before any + calls are made to derived methods. + + @param forcerestart Do a soft or hard reset of the sound subsystem + */ + virtual void initialize(bool forcerestart = false); + /** Return true iff the sound device was successfully initialized. diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index 8a28ed639..a152849b0 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.43 2005-03-14 04:08:13 stephena Exp $ +// $Id: Console.cxx,v 1.44 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #include @@ -182,7 +182,8 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem) // Initialize the sound interface. uInt32 soundFrameRate = (myProperties.get("Display.Format") == "PAL") ? 50 : 60; - myOSystem->sound().initialize(soundFrameRate); + myOSystem->sound().setFrameRate(soundFrameRate); + myOSystem->sound().initialize(); // Initialize the menuing system with updated values from the framebuffer myOSystem->menu().initialize(); diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 22e29638c..e4b8b489f 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.21 2005-03-14 04:08:15 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.22 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #include @@ -112,7 +112,7 @@ FrameBuffer::~FrameBuffer(void) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::initialize(const string title, uInt32 width, uInt32 height) +void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height) { bool isAlreadyInitialized = (SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO) > 0; @@ -220,14 +220,14 @@ void FrameBuffer::update() if(myMessageTime > 0) { uInt32 w = myFont->getStringWidth(myMessageText) + 10; - uInt32 h = myFont->getFontHeight() + 5; + uInt32 h = myFont->getFontHeight() + 8; uInt32 x = (myWidth >> 1) - (w >> 1); uInt32 y = myHeight - h - LINEOFFSET/2; // Draw the bounded box and text - fillRect(x+1, y+2, w-2, h-4, kBGColor); // FIXME - possibly change this to blended rect + blendRect(x+1, y+2, w-2, h-4, kBGColor); box(x, y+1, w, h-2, kColor, kColor); - myFont->drawString(myMessageText, x, y, w, kTextColor, kTextAlignCenter); + myFont->drawString(myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter); myMessageTime--; // Erase this message on next update @@ -880,9 +880,17 @@ void FrameBuffer::setupPalette() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::toggleFullscreen() +void FrameBuffer::toggleFullscreen(bool given, bool toggle) { - bool isFullscreen = !myOSystem->settings().getBool("fullscreen"); + bool isFullscreen; + if(given) + { + if(myOSystem->settings().getBool("fullscreen") == toggle) + return; + isFullscreen = toggle; + } + else + isFullscreen = !myOSystem->settings().getBool("fullscreen"); // Update the settings myOSystem->settings().setBool("fullscreen", isFullscreen); @@ -899,34 +907,51 @@ void FrameBuffer::toggleFullscreen() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::resize(int mode) +void FrameBuffer::resize(Int8 mode, Int8 zoom) { - // reset size to that given in properties - // this is a special case of allowing a resize while in fullscreen mode - if(mode == 0) + // Use the specific zoom level if one is given + // Otherwise use 'mode' to pick the next zoom level + if(zoom != 0) { - myWidth = 1;//FIXME myMediaSource->width() << 1; - myHeight = 1;//FIXME myMediaSource->height(); - } - else if(mode == 1) // increase size - { - if(myOSystem->settings().getBool("fullscreen")) - return; +// if(myOSystem->settings().getBool("fullscreen")) +// return; - if(theZoomLevel == theMaxZoomLevel) + if(zoom < 1) theZoomLevel = 1; - else - theZoomLevel++; - } - else if(mode == -1) // decrease size - { - if(myOSystem->settings().getBool("fullscreen")) - return; - - if(theZoomLevel == 1) + else if((uInt32)zoom > theMaxZoomLevel) theZoomLevel = theMaxZoomLevel; else - theZoomLevel--; + theZoomLevel = zoom; + } + else + { + // reset size to that given in properties + // this is a special case of allowing a resize while in fullscreen mode + if(mode == 0) + { + myWidth = 1;//FIXME myMediaSource->width() << 1; + myHeight = 1;//FIXME myMediaSource->height(); + } + else if(mode == 1) // increase size + { + if(myOSystem->settings().getBool("fullscreen")) + return; + + if(theZoomLevel == theMaxZoomLevel) + theZoomLevel = 1; + else + theZoomLevel++; + } + else if(mode == -1) // decrease size + { + if(myOSystem->settings().getBool("fullscreen")) + return; + + if(theZoomLevel == 1) + theZoomLevel = theMaxZoomLevel; + else + theZoomLevel--; + } } if(!createScreen()) @@ -1068,7 +1093,7 @@ uInt32 FrameBuffer::screenHeight() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::setWindowTitle(const string title) +void FrameBuffer::setWindowTitle(const string& title) { SDL_WM_SetCaption(title.c_str(), "stella"); } diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index 87994f25a..77050617f 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.hxx,v 1.21 2005-03-14 04:08:15 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.22 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -41,7 +41,7 @@ class OSystem; All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.21 2005-03-14 04:08:15 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.22 2005-03-26 19:26:47 stephena Exp $ */ class FrameBuffer { @@ -71,7 +71,7 @@ class FrameBuffer @param width The width of the framebuffer @param height The height of the framebuffer */ - void initialize(const string title, uInt32 width, uInt32 height); + void initialize(const string& title, uInt32 width, uInt32 height); /** Updates the display, which depending on the current mode could mean @@ -149,20 +149,25 @@ FIXME } /** - Toggles between fullscreen and window mode. Grabmouse and hidecursor - activated when in fullscreen mode. + Toggles between fullscreen and window mode. either automatically + or based on the given flag. Grabmouse activated when in fullscreen mode. + + @param given Indicates whether to use the specified 'toggle' or + decide based on current status + @param toggle Set the fullscreen mode to this value */ - void toggleFullscreen(); + void toggleFullscreen(bool given = false, bool toggle = false); /** This routine is called when the user wants to resize the window. - A '1' argument indicates that the window should increase in size, while '-1' - indicates that the windows should decrease in size. A '0' indicates that - the window should be sized according to the current properties. - Can't resize in fullscreen mode. Will only resize up to the maximum size - of the screen. + Mode = '1' means window should increase in size + Mode = '-1' means window should decrease in size + Mode = '0' means window should be resized to defaults + + @param mode How the window should be resized + @param zoom The zoom level to use if something other than 0 */ - void resize(int mode); + void resize(Int8 mode, Int8 zoom = 0); /** Sets the state of the cursor (hidden or grabbed) based on the @@ -199,7 +204,7 @@ FIXME /** Set the title for the main SDL window. */ - void setWindowTitle(const string title); + void setWindowTitle(const string& title); /** Set up the palette for a screen of any depth > 8. @@ -347,9 +352,17 @@ FIXME */ virtual void drawChar(uInt8 c, uInt32 x, uInt32 y, OverlayColor color) = 0; -/* FIXME -void drawBitmap(uint32 *bitmap, int x, int y, OverlayColor color, int h = 8); -*/ + /** + This routine should be called to draw the bitmap image. + + @param bitmap The data to draw + @param x The x coordinate + @param y The y coordinate + @param color The color of the character + @param h The height of the data image + */ + virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, + Int32 h = 8) = 0; #if 0 FIXME diff --git a/stella/src/emucore/Sound.cxx b/stella/src/emucore/Sound.cxx index e41f2d245..5eea4a9cd 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.17 2005-02-22 18:41:15 stephena Exp $ +// $Id: Sound.cxx,v 1.18 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #include "Serializer.hxx" @@ -51,16 +51,22 @@ void Sound::adjustCycleCounter(Int32 amount) myLastRegisterSetCycle += amount; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Sound::setFrameRate(uInt32 framerate) +{ + myDisplayFrameRate = framerate; + myLastRegisterSetCycle = 0; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Sound::mute(bool state) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Sound::initialize(double displayframerate) +void Sound::initialize(bool forcerestart) { myLastRegisterSetCycle = 0; - myDisplayFrameRate = displayframerate; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/Sound.hxx b/stella/src/emucore/Sound.hxx index 70b4bbd54..c0ee6b8fa 100644 --- a/stella/src/emucore/Sound.hxx +++ b/stella/src/emucore/Sound.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: Sound.hxx,v 1.15 2005-02-22 02:59:54 stephena Exp $ +// $Id: Sound.hxx,v 1.16 2005-03-26 19:26:47 stephena Exp $ //============================================================================ #ifndef SOUND_HXX @@ -31,7 +31,7 @@ class Deserializer; to compile Stella with no sound support whatsoever. @author Stephen Anthony and Bradford W. Mott - @version $Id: Sound.hxx,v 1.15 2005-02-22 02:59:54 stephena Exp $ + @version $Id: Sound.hxx,v 1.16 2005-03-26 19:26:47 stephena Exp $ */ class Sound { @@ -57,12 +57,20 @@ class Sound virtual void adjustCycleCounter(Int32 amount); /** - Initializes the sound device. This must be called before any - calls are made to derived methods. + Sets the display framerate. Sound generation for NTSC and PAL games + depends on the framerate, so we need to set it here. @param framerate The base framerate depending on NTSC or PAL ROM */ - virtual void initialize(double displayframerate); + virtual void setFrameRate(uInt32 framerate); + + /** + Initializes the sound device. This must be called before any + calls are made to derived methods. + + @param forcerestart Do a soft or hard reset of the sound subsystem + */ + virtual void initialize(bool forcerestart = false); /** Return true iff the sound device was successfully initialized. @@ -137,7 +145,7 @@ public: Int32 myLastRegisterSetCycle; // Indicates the base framerate depending on whether the ROM is NTSC or PAL - double myDisplayFrameRate; + uInt32 myDisplayFrameRate; }; #endif diff --git a/stella/src/gui/AudioDialog.cxx b/stella/src/gui/AudioDialog.cxx new file mode 100644 index 000000000..a952a5341 --- /dev/null +++ b/stella/src/gui/AudioDialog.cxx @@ -0,0 +1,212 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: AudioDialog.cxx,v 1.1 2005-03-26 19:26:47 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include + +#include "OSystem.hxx" +#include "Sound.hxx" +#include "Settings.hxx" +#include "Menu.hxx" +#include "Control.hxx" +#include "Widget.hxx" +#include "PopUpWidget.hxx" +#include "Dialog.hxx" +#include "AudioDialog.hxx" +#include "GuiUtils.hxx" + +#include "bspf.hxx" + +enum { + kAudioRowHeight = 12, + kAudioWidth = 200, + kAudioHeight = 100 +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AudioDialog::AudioDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 h) + : Dialog(osystem, x, y, w, h) +{ + int yoff = 10, + xoff = 10, + woff = _w - 100, + labelWidth = 70; + + // Volume + myVolumeSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight, + "Volume: ", labelWidth, kVolumeChanged); + myVolumeSlider->setMinValue(1); myVolumeSlider->setMaxValue(100); + myVolumeLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 24, kLineHeight, + "", kTextAlignLeft); + myVolumeLabel->setFlags(WIDGET_CLEARBG); + yoff += kAudioRowHeight + 4; + + // Fragment size + myFragsizePopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, + "Fragment size: ", labelWidth); + myFragsizePopup->appendEntry("256", 1); + myFragsizePopup->appendEntry("512", 2); + myFragsizePopup->appendEntry("1024", 3); + myFragsizePopup->appendEntry("2048", 4); + myFragsizePopup->appendEntry("4096", 5); + yoff += kAudioRowHeight + 4; + + // Enable sound + new StaticTextWidget(this, xoff+8, yoff+3, 20, kLineHeight, + "(*)", kTextAlignLeft); + mySoundEnableCheckbox = new CheckboxWidget(this, xoff+28, yoff, woff - 14, kLineHeight, + "Enable sound", kSoundEnableChanged); + yoff += kAudioRowHeight + 12; + + // Add a short message about options that need a restart + new StaticTextWidget(this, xoff+30, yoff, 170, kLineHeight, + "* Note that these options take effect", kTextAlignLeft); + yoff += kAudioRowHeight; + new StaticTextWidget(this, xoff+30, yoff, 170, kLineHeight, + "the next time you restart Stella.", kTextAlignLeft); + + // Add Defaults, OK and Cancel buttons + addButton( 10, _h - 24, "Defaults", kDefaultsCmd, 0); +#ifndef MAC_OSX + addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0); + addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0); +#else + addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0); + addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0); +#endif + + setDefaults(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +AudioDialog::~AudioDialog() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioDialog::loadConfig() +{ + bool b; + uInt32 i; + + // Volume + myVolumeSlider->setValue(instance()->settings().getInt("volume")); + myVolumeLabel->setLabel(instance()->settings().getString("volume")); + + // Fragsize + i = instance()->settings().getInt("fragsize"); + if(i == 256) i = 1; + else if(i == 512) i = 2; + else if(i == 1024) i = 3; + else if(i == 2048) i = 4; + else if(i == 4096) i = 5; + myFragsizePopup->setSelectedTag(i); + + // Enable sound + b = instance()->settings().getBool("sound"); + mySoundEnableCheckbox->setState(b); + + // Make sure that mutually-exclusive items are not enabled at the same time + handleSoundEnableChange(b); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioDialog::saveConfig() +{ + string s; + uInt32 i; + bool b; + + // Volume + i = myVolumeSlider->getValue(); + instance()->settings().setInt("volume", i); + instance()->sound().setVolume(i); + + // Fragsize + // This one requires a complete re-initialization of the sound subsystem, + // so we only do it if the fragsize really has changed + i = 1; + i <<= (myFragsizePopup->getSelectedTag() + 7); + if(instance()->settings().getInt("fragsize") != (Int32)i) + { + instance()->settings().setInt("fragsize", i); + instance()->sound().initialize(true); // force a re-initialization + } + + // Enable sound (requires a restart to take effect) // FIXME - let this work without a restart + b = mySoundEnableCheckbox->getState(); + instance()->settings().setBool("sound", b); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioDialog::setDefaults() +{ + myVolumeSlider->setValue(100); + myVolumeLabel->setLabel("100"); + +#ifdef WIN32 + myFragsizePopup->setSelectedTag(4); +#else + myFragsizePopup->setSelectedTag(2); +#endif + + mySoundEnableCheckbox->setState(true); + + // Make sure that mutually-exclusive items are not enabled at the same time + handleSoundEnableChange(true); + + instance()->frameBuffer().refresh(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioDialog::handleSoundEnableChange(bool active) +{ + myVolumeSlider->setEnabled(active); + myVolumeLabel->setEnabled(active); + myFragsizePopup->setEnabled(active); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void AudioDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data) +{ + switch(cmd) + { + case kOKCmd: + saveConfig(); + close(); + break; + + case kDefaultsCmd: + setDefaults(); + break; + + case kVolumeChanged: + myVolumeLabel->setValue(myVolumeSlider->getValue()); + break; + + case kSoundEnableChanged: + handleSoundEnableChange(data == 1); + break; + + default: + Dialog::handleCommand(sender, cmd, data); + break; + } +} diff --git a/stella/src/gui/AudioDialog.hxx b/stella/src/gui/AudioDialog.hxx new file mode 100644 index 000000000..453706aef --- /dev/null +++ b/stella/src/gui/AudioDialog.hxx @@ -0,0 +1,56 @@ +//============================================================================ +// +// 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-2005 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: AudioDialog.hxx,v 1.1 2005-03-26 19:26:47 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef AUDIO_DIALOG_HXX +#define AUDIO_DIALOG_HXX + +class CommandSender; +class Dialog; +class PopUpWidget; +class SliderWidget; +class StaticTextWidget; +class CheckboxWidget; + +#include "OSystem.hxx" +#include "bspf.hxx" + +class AudioDialog : public Dialog +{ + public: + AudioDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 h); + ~AudioDialog(); + + protected: + SliderWidget* myVolumeSlider; + StaticTextWidget* myVolumeLabel; + PopUpWidget* myFragsizePopup; + CheckboxWidget* mySoundEnableCheckbox; + + private: + void loadConfig(); + void saveConfig(); + void setDefaults(); + + void handleSoundEnableChange(bool active); + virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data); +}; + +#endif diff --git a/stella/src/gui/Dialog.hxx b/stella/src/gui/Dialog.hxx index 036c5608f..5ae35b389 100644 --- a/stella/src/gui/Dialog.hxx +++ b/stella/src/gui/Dialog.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: Dialog.hxx,v 1.6 2005-03-15 22:28:05 stephena Exp $ +// $Id: Dialog.hxx,v 1.7 2005-03-26 19:26:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -35,7 +35,7 @@ class Menu; This is the base class for all dialog boxes. @author Stephen Anthony - @version $Id: Dialog.hxx,v 1.6 2005-03-15 22:28:05 stephena Exp $ + @version $Id: Dialog.hxx,v 1.7 2005-03-26 19:26:47 stephena Exp $ */ class Dialog : public GuiObject { @@ -55,6 +55,7 @@ class Dialog : public GuiObject virtual void drawDialog(); virtual void loadConfig() {} virtual void saveConfig() {} + virtual void setDefaults() {} protected: virtual void draw(); diff --git a/stella/src/gui/GuiUtils.hxx b/stella/src/gui/GuiUtils.hxx index 11d248fe4..6d026f590 100644 --- a/stella/src/gui/GuiUtils.hxx +++ b/stella/src/gui/GuiUtils.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: GuiUtils.hxx,v 1.3 2005-03-26 04:19:56 stephena Exp $ +// $Id: GuiUtils.hxx,v 1.4 2005-03-26 19:26:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,9 +29,11 @@ Probably not very neat, but at least it works ... @author Stephen Anthony - @version $Id: GuiUtils.hxx,v 1.3 2005-03-26 04:19:56 stephena Exp $ + @version $Id: GuiUtils.hxx,v 1.4 2005-03-26 19:26:47 stephena Exp $ */ +#define kLineHeight 12 + // Colors indices to use for the various GUI elements enum OverlayColor { kColor, @@ -47,14 +49,18 @@ enum { kCloseCmd = 'clos', kDefaultsCmd, kRendererChanged, - kVolumeChanged, kAspectRatioChanged, kFrameRateChanged, - kZoomChanged + kZoomChanged, + kVolumeChanged, + kSoundEnableChanged }; static const string EmptyString(""); -#define kLineHeight 12 +template inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; } +template inline T ABS (T x) { return (x>=0) ? x : -x; } + +#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0]))) #endif diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index f7f5ef1dc..31e3b6eeb 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.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: OptionsDialog.cxx,v 1.5 2005-03-14 04:08:15 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.6 2005-03-26 19:26:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,6 +25,7 @@ #include "Widget.hxx" #include "Control.hxx" #include "VideoDialog.hxx" +#include "AudioDialog.hxx" #include "OptionsDialog.hxx" #include "bspf.hxx" @@ -48,6 +49,7 @@ enum { #define addBigButton(label, cmd, hotkey) \ new ButtonWidget(this, xoffset, yoffset, kBigButtonWidth, 18, label, cmd, hotkey); yoffset += kRowHeight +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OptionsDialog::OptionsDialog(OSystem* osystem) : Dialog(osystem, (osystem->frameBuffer().width() - kMainMenuWidth) / 2, (osystem->frameBuffer().height() - kMainMenuHeight)/2, @@ -71,17 +73,14 @@ OptionsDialog::OptionsDialog(OSystem* osystem) // Now create all the dialogs attached to each menu button w = 250; h = 150; - if(w > fbWidth) w = fbWidth; - if(h > fbHeight) h = fbHeight; - x = (fbWidth - w) / 2; - y = (fbHeight - h) / 2; - - myVideoDialog = new VideoDialog(myOSystem, x, y, w, h); - + checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); + myVideoDialog = new VideoDialog(myOSystem, x, y, w, h); + w = 220; h = 120; + checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); + myAudioDialog = new AudioDialog(myOSystem, x, y, w, h); /* - myAudioDialog = new AudioDialog(myOSystem); myEventMappingDialog = new EventMappingDialog(myOSystem); myMiscDialog = new MiscDialog(myOSystem); myGameInfoDialog = new GameInfoDialog(myOSystem); @@ -89,11 +88,12 @@ OptionsDialog::OptionsDialog(OSystem* osystem) */ } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OptionsDialog::~OptionsDialog() { delete myVideoDialog; -/* FIXME delete myAudioDialog; +/* FIXME delete myEventMappingDialog; delete myMiscDialog; delete myGameInfoDialog; @@ -101,6 +101,17 @@ OptionsDialog::~OptionsDialog() */ } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OptionsDialog::checkBounds(uInt32 width, uInt32 height, + uInt16* x, uInt16* y, uInt16* w, uInt16* h) +{ + if(*w > width) *w = width; + if(*h > height) *h = height; + *x = (width - *w) / 2; + *y = (height - *h) / 2; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OptionsDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data) { switch(cmd) @@ -110,8 +121,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data break; case kAudCmd: -// instance()->menu().addDialog(myAudioDialog); -cerr << "push AudioDialog to top of stack\n"; + instance()->menu().addDialog(myAudioDialog); break; case kEMapCmd: diff --git a/stella/src/gui/OptionsDialog.hxx b/stella/src/gui/OptionsDialog.hxx index 3aced7525..4e31b3b06 100644 --- a/stella/src/gui/OptionsDialog.hxx +++ b/stella/src/gui/OptionsDialog.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: OptionsDialog.hxx,v 1.1 2005-03-10 22:59:40 stephena Exp $ +// $Id: OptionsDialog.hxx,v 1.2 2005-03-26 19:26:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -49,6 +49,10 @@ class OptionsDialog : public Dialog MiscDialog* myMiscDialog; GameInfoDialog* myGameInfoDialog; HelpDialog* myHelpDialog; + + private: + void checkBounds(uInt32 width, uInt32 height, + uInt16* x, uInt16* y, uInt16* w, uInt16* h); }; #endif diff --git a/stella/src/gui/PopUpWidget.cxx b/stella/src/gui/PopUpWidget.cxx index 3d8b80426..bff65307a 100644 --- a/stella/src/gui/PopUpWidget.cxx +++ b/stella/src/gui/PopUpWidget.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: PopUpWidget.cxx,v 1.2 2005-03-26 04:19:56 stephena Exp $ +// $Id: PopUpWidget.cxx,v 1.3 2005-03-26 19:26:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -353,8 +353,8 @@ void PopUpWidget::drawWidget(bool hilite) fb.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor); // Draw an arrow pointing down at the right end to signal this is a dropdown/popup -// fb.drawBitmap(up_down_arrows, x+w - 10, _y+2, -// FIXME !isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor); + fb.drawBitmap(up_down_arrows, x+w - 10, _y+2, + !isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor); // Draw the selected entry, if any if(_selectedItem >= 0) diff --git a/stella/src/gui/PopUpWidget.hxx b/stella/src/gui/PopUpWidget.hxx index 1ab5d14f5..ffd9f729c 100644 --- a/stella/src/gui/PopUpWidget.hxx +++ b/stella/src/gui/PopUpWidget.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: PopUpWidget.hxx,v 1.2 2005-03-26 04:19:56 stephena Exp $ +// $Id: PopUpWidget.hxx,v 1.3 2005-03-26 19:26:48 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -34,10 +34,6 @@ class PopUpDialog; #include "bspf.hxx" -enum { - kPopUpItemSelectedCmd = 'POPs' -}; - /** * Popup or dropdown widget which, when clicked, "pop up" a list of items and * lets the user pick on of them. diff --git a/stella/src/gui/VideoDialog.cxx b/stella/src/gui/VideoDialog.cxx index 99d2879c1..55745aca4 100644 --- a/stella/src/gui/VideoDialog.cxx +++ b/stella/src/gui/VideoDialog.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: VideoDialog.cxx,v 1.3 2005-03-26 04:19:56 stephena Exp $ +// $Id: VideoDialog.cxx,v 1.4 2005-03-26 19:26:48 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -51,10 +51,16 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 // Video driver (query OSystem for what's supported) myDriverPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "(*)Driver: ", labelWidth); - myDriverPopup->appendEntry("First one", 1); - myDriverPopup->appendEntry("Another one", 2); +// myDriverPopup->appendEntry("First one", 1); +// myDriverPopup->appendEntry("Another one", 2); yoff += kVideoRowHeight + 4; +// FIXME - get list of video drivers from OSystem +// const Common::LanguageDescription *l = Common::g_languages; +// for (; l->code; ++l) { +// _langPopUp->appendEntry(l->description, l->id); +// } + // Video renderer myRendererPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "(*)Renderer: ", labelWidth, kRendererChanged); @@ -105,8 +111,23 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 myZoomLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 20, kLineHeight, "", kTextAlignLeft); myZoomLabel->setFlags(WIDGET_CLEARBG); + yoff += kVideoRowHeight + 10; + + myFullscreenCheckbox = new CheckboxWidget(this, xoff + 25, yoff, woff - 14, kLineHeight, + "Fullscreen mode"); yoff += kVideoRowHeight + 4; + myUseDeskResCheckbox = new CheckboxWidget(this, xoff + 25, yoff, woff - 14, kLineHeight, + "Desktop Res in FS"); + yoff += kVideoRowHeight + 20; + + // Add a short message about options that need a restart + new StaticTextWidget(this, xoff-40, yoff, 170, kLineHeight, + "* Note that these options take effect", kTextAlignLeft); + yoff += kVideoRowHeight; + new StaticTextWidget(this, xoff-40, yoff, 170, kLineHeight, + "the next time you restart Stella.", kTextAlignLeft); + // Add Defaults, OK and Cancel buttons addButton( 10, _h - 24, "Defaults", kDefaultsCmd, 0); #ifndef MAC_OSX @@ -117,12 +138,6 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0); #endif -// FIXME - get list of video drivers from OSystem -// const Common::LanguageDescription *l = Common::g_languages; -// for (; l->code; ++l) { -// _langPopUp->appendEntry(l->description, l->id); -// } - setDefaults(); } @@ -196,6 +211,14 @@ void VideoDialog::loadConfig() myZoomSlider->setValue(i); myZoomLabel->setLabel(instance()->settings().getString("zoom")); + // Fullscreen + b = instance()->settings().getBool("fullscreen"); + myFullscreenCheckbox->setState(b); + + // Use desktop resolution in fullscreen mode + b = instance()->settings().getBool("gl_fsmax"); + myUseDeskResCheckbox->setState(b); + // Make sure that mutually-exclusive items are not enabled at the same time i = myRendererPopup->getSelectedTag() - 1; handleRendererChange(i); @@ -206,9 +229,11 @@ void VideoDialog::saveConfig() { string s; uInt32 i; + bool b; // Driver setting - instance()->settings().setString("video_driver", ""); // FIXME + s = myDriverPopup->getSelectedString(); + instance()->settings().setString("video_driver", s); // Renderer setting i = myRendererPopup->getSelectedTag(); @@ -249,13 +274,25 @@ void VideoDialog::saveConfig() // Zoom i = (myZoomSlider->getValue() / 10) + 1; instance()->settings().setInt("zoom", i); -// FIXME - immediately change the zoom + instance()->frameBuffer().resize(0, i); + + // Fullscreen (the toggleFullscreen function takes care of updating settings) + b = myFullscreenCheckbox->getState(); + instance()->frameBuffer().toggleFullscreen(true, b); + + // Use desktop resolution in fullscreen mode + b = myUseDeskResCheckbox->getState(); + instance()->settings().setBool("gl_fsmax", b); +// FIXME - immediately toggle gl_fsmax } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::setDefaults() { + // FIXME - for now, this option isn't available myDriverPopup->setSelectedTag(0); + myDriverPopup->setEnabled(false); + myRendererPopup->setSelectedTag(1); myFilterPopup->setSelectedTag(1); myPalettePopup->setSelectedTag(1); @@ -269,6 +306,9 @@ void VideoDialog::setDefaults() myAspectRatioSlider->setValue(100); myAspectRatioLabel->setLabel("2.0"); + myFullscreenCheckbox->setState(false); + myUseDeskResCheckbox->setState(true); + // Make sure that mutually-exclusive items are not enabled at the same time handleRendererChange(0); // 0 indicates software mode @@ -284,6 +324,7 @@ void VideoDialog::handleRendererChange(uInt32 item) myFilterPopup->setEnabled(active); myAspectRatioSlider->setEnabled(active); myAspectRatioLabel->setEnabled(active); + myUseDeskResCheckbox->setEnabled(active); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/VideoDialog.hxx b/stella/src/gui/VideoDialog.hxx index 357be600f..fc640b8c1 100644 --- a/stella/src/gui/VideoDialog.hxx +++ b/stella/src/gui/VideoDialog.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: VideoDialog.hxx,v 1.2 2005-03-26 04:19:56 stephena Exp $ +// $Id: VideoDialog.hxx,v 1.3 2005-03-26 19:26:48 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,6 +27,7 @@ class Dialog; class PopUpWidget; class SliderWidget; class StaticTextWidget; +class CheckboxWidget; #include "OSystem.hxx" #include "bspf.hxx" @@ -37,8 +38,6 @@ class VideoDialog : public Dialog VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 h); ~VideoDialog(); - virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data); - protected: PopUpWidget* myDriverPopup; PopUpWidget* myRendererPopup; @@ -50,13 +49,16 @@ class VideoDialog : public Dialog StaticTextWidget* myFrameRateLabel; SliderWidget* myZoomSlider; StaticTextWidget* myZoomLabel; + CheckboxWidget* myFullscreenCheckbox; + CheckboxWidget* myUseDeskResCheckbox; private: void loadConfig(); void saveConfig(); - void setDefaults(); + void handleRendererChange(uInt32 item); + virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data); }; #endif diff --git a/stella/src/gui/Widget.cxx b/stella/src/gui/Widget.cxx index 7afdde3f7..ca626c98b 100644 --- a/stella/src/gui/Widget.cxx +++ b/stella/src/gui/Widget.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: Widget.cxx,v 1.5 2005-03-14 04:08:15 stephena Exp $ +// $Id: Widget.cxx,v 1.6 2005-03-26 19:26:48 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -73,7 +73,7 @@ void Widget::draw() OverlayColor colorA = kColor; OverlayColor colorB = kShadowColor; if((_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER) - ; //FIXME - add swap function SWAP(colorA, colorB); + SWAP(colorA, colorB); fb.box(_x, _y, _w, _h, colorA, colorB); _x += 4; _y += 4; @@ -232,9 +232,8 @@ void CheckboxWidget::drawWidget(bool hilite) // If checked, draw cross inside the box if(_state) -; // FIXME - change bitmap to be a character in the font set, then draw that -// fb.drawBitmap(checked_img, _x + 3, _y + 3, -// isEnabled() ? fb.textcolor : fb.color); + fb.drawBitmap(checked_img, _x + 3, _y + 3, + isEnabled() ? kTextColor : kColor); else fb.fillRect(_x + 2, _y + 2, 10, 10, kBGColor); @@ -276,7 +275,7 @@ void SliderWidget::handleMouseMoved(Int32 x, Int32 y, Int32 button) { _value = newValue; draw(); - sendCommand(_cmd, _value); // FIXME - hack to allow for "live update" in sound dialog + sendCommand(_cmd, _value); } } }