Cleaned up the LauncherDialog a little.

Removed the saving of TIAbit on/off into the state files.  These
are debugging tools, and aren't really part of a state file (and hence
shouldn't be saved with a state file).  Now, whenever a state is
(re)loaded, the TIABits are all turned back on.  That means the state
files are still compatible with Stella 1.4.2.

Added "Enter/exit menu mode" and "Enter launcher mode" to the remappable
events.  They default to 'Tab' and 'Escape', respectively.  While you
can add new mappings for these events, those defaults can't be removed
(otherwise, it would be possible for a user to disable menu mode, and
never be able to get back into the menu to fix the problem).

Fixed some problems with the overall state machine.  Sometimes the cursor
was hidden when it shouldn't have been, and vice versa.

Fixed crash when toggling between software and OpenGL while in ROM
launcher mode.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@413 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-05-06 22:50:15 +00:00
parent b27b595a78
commit cf08dc29cd
13 changed files with 117 additions and 91 deletions

View File

@ -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.21 2005-05-05 00:10:43 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.22 2005-05-06 22:50:14 stephena Exp $
//============================================================================
#include <SDL.h>
@ -58,8 +58,13 @@ bool FrameBufferGL::initSubsystem()
// Get the aspect ratio for the display
// Since the display is already doubled horizontally, we half the
// ratio that is provided
theAspectRatio = myOSystem->settings().getFloat("gl_aspect") / 2;
if(theAspectRatio <= 0.0)
if(theUseAspectRatioFlag)
{
theAspectRatio = myOSystem->settings().getFloat("gl_aspect") / 2;
if(theAspectRatio <= 0.0)
theAspectRatio = 1.0;
}
else
theAspectRatio = 1.0;
// Set up the OpenGL attributes

View File

@ -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.50 2005-05-05 00:10:46 stephena Exp $
// $Id: Console.cxx,v 1.51 2005-05-06 22:50:14 stephena Exp $
//============================================================================
#include <assert.h>
@ -62,9 +62,6 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
mySystem = 0;
myEvent = 0;
// Indicate that emulation should start now
myOSystem->eventHandler().reset(EventHandler::S_EMULATE);
// Attach the event subsystem to the current console
myEvent = myOSystem->eventHandler().event();

View File

@ -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: Event.hxx,v 1.7 2005-05-05 00:10:47 stephena Exp $
// $Id: Event.hxx,v 1.8 2005-05-06 22:50:14 stephena Exp $
//============================================================================
#ifndef EVENT_HXX
@ -25,7 +25,7 @@ class Event;
/**
@author Bradford W. Mott
@version $Id: Event.hxx,v 1.7 2005-05-05 00:10:47 stephena Exp $
@version $Id: Event.hxx,v 1.8 2005-05-06 22:50:14 stephena Exp $
*/
class Event
{
@ -71,8 +71,8 @@ class Event
DrivingOneClockwise, DrivingOneCounterClockwise, DrivingOneValue,
DrivingOneFire,
ChangeState, LoadState, SaveState, TakeSnapshot, Pause, Quit, ExitGame,
ReloadRom,
ChangeState, LoadState, SaveState, TakeSnapshot, Pause, Quit,
MenuMode, LauncherMode,
LastType
};

View File

@ -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: EventHandler.cxx,v 1.52 2005-05-06 18:38:59 stephena Exp $
// $Id: EventHandler.cxx,v 1.53 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#include <algorithm>
@ -111,6 +111,9 @@ void EventHandler::reset(State state)
myQuitFlag = false;
myPaddleMode = 0;
myOSystem->frameBuffer().pause(myPauseFlag);
myOSystem->sound().mute(myPauseFlag);
switch(myState)
{
case S_EMULATE:
@ -236,30 +239,6 @@ void EventHandler::poll() // FIXME - add modifiers for OSX
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
{
// Handle keys here that are accessible no matter which mode we're in
// Toggle menu mode
if(key == SDLK_TAB && state == 1 && !myPauseFlag) // FIXME - add remappable 'enter menu mode key here'
{
if(myState == S_EMULATE)
{
myState = S_MENU;
myOSystem->menu().reStack();
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(true);
return;
}
else if(myState == S_MENU)
{
myState = S_EMULATE;
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(false);
return;
}
}
// Determine which mode we're in, then send the event to the appropriate place
switch(myState)
{
@ -393,12 +372,29 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
break;
}
}
else if(myKeyTable[key] == Event::MenuMode && state == 1 && !myPauseFlag)
{
myState = S_MENU;
myOSystem->menu().reStack();
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(true);
return;
}
else
handleEvent(myKeyTable[key], state);
break; // S_EMULATE
case S_MENU:
if(myKeyTable[key] == Event::MenuMode && state == 1 && !myPauseFlag)
{
myState = S_EMULATE;
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(false);
return;
}
myOSystem->menu().handleKeyEvent((uInt16) key, (Int32) mod, state);
break;
@ -595,7 +591,18 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
myOSystem->sound().mute(myPauseFlag);
return;
}
else if(event == Event::ExitGame)
else if(event == Event::MenuMode)
{
// ExitGame will only work when we've launched stella using the ROM
// launcher. Otherwise, the only way to exit the main loop is to Quit.
if(myState == S_EMULATE && myUseLauncherFlag)
{
myOSystem->settings().saveConfig();
myOSystem->createLauncher();
return;
}
}
else if(event == Event::LauncherMode)
{
// ExitGame will only work when we've launched stella using the ROM
// launcher. Otherwise, the only way to exit the main loop is to Quit.
@ -625,7 +632,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
void EventHandler::setActionMappings()
{
// Fill the ActionList with the current key and joystick mappings
for(Int32 i = 0; i < 58; ++i)
for(Int32 i = 0; i < 60; ++i)
{
Event::Type event = ourActionList[i].event;
ourActionList[i].key = "None";
@ -748,6 +755,10 @@ void EventHandler::setJoymap()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::addKeyMapping(Event::Type event, uInt16 key)
{
// These keys cannot be remapped.
if(key == SDLK_TAB || key == SDLK_ESCAPE)
return;
myKeyTable[key] = event;
setActionMappings();
@ -771,12 +782,12 @@ void EventHandler::eraseMapping(Event::Type event)
{
// Erase the KeyEvent arrays
for(Int32 i = 0; i < SDLK_LAST; ++i)
if(myKeyTable[i] == event)
if(myKeyTable[i] == event && i != SDLK_TAB && i != SDLK_ESCAPE)
myKeyTable[i] = Event::NoType;
// Erase the JoyEvent array
for(Int32 i = 0; i < StellaEvent::LastJSTICK*StellaEvent::LastJCODE; ++i)
if(myJoyTable[i] == event)
if(myJoyTable[i] == event && i != SDLK_TAB && i != SDLK_ESCAPE)
myJoyTable[i] = Event::NoType;
setActionMappings();
@ -863,9 +874,8 @@ void EventHandler::setDefaultKeymap()
myKeyTable[ SDLK_F11 ] = Event::LoadState;
myKeyTable[ SDLK_F12 ] = Event::TakeSnapshot;
myKeyTable[ SDLK_PAUSE ] = Event::Pause;
#ifndef MAC_OSX
myKeyTable[ SDLK_ESCAPE ] = Event::ExitGame;
#endif
myKeyTable[ SDLK_TAB ] = Event::MenuMode;
myKeyTable[ SDLK_ESCAPE ] = Event::LauncherMode;
saveMappings();
}
@ -1281,7 +1291,7 @@ void EventHandler::setSDLMappings()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ActionList EventHandler::ourActionList[58] = {
ActionList EventHandler::ourActionList[60] = {
{ Event::ConsoleSelect, "Select", "" },
{ Event::ConsoleReset, "Reset", "" },
{ Event::ConsoleColor, "Color TV", "" },
@ -1295,6 +1305,8 @@ ActionList EventHandler::ourActionList[58] = {
{ Event::LoadState, "Load State", "" },
{ Event::TakeSnapshot, "Snapshot", "" },
{ Event::Pause, "Pause", "" },
{ Event::MenuMode, "Enter/exit menu mode", "" },
{ Event::LauncherMode, "Enter ROM launcher", "" },
{ Event::Quit, "Quit", "" },
{ Event::JoystickZeroUp, "Left Joystick Up Direction", "" },

View File

@ -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: EventHandler.hxx,v 1.26 2005-05-06 18:38:59 stephena Exp $
// $Id: EventHandler.hxx,v 1.27 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -57,7 +57,7 @@ struct ActionList {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.26 2005-05-06 18:38:59 stephena Exp $
@version $Id: EventHandler.hxx,v 1.27 2005-05-06 22:50:15 stephena Exp $
*/
class EventHandler
{
@ -143,7 +143,7 @@ class EventHandler
inline void quit() { handleEvent(Event::Quit, 1); }
// Holds static strings for the remap menu
static ActionList ourActionList[58];
static ActionList ourActionList[60];
private:
/**

View File

@ -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.32 2005-05-06 18:38:59 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.33 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#include <sstream>
@ -41,6 +41,7 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
theZoomLevel(1),
theMaxZoomLevel(1),
theAspectRatio(1.0),
theUseAspectRatioFlag(true),
myFrameRate(0),
myPauseStatus(false),
theMenuChangedIndicator(false),
@ -78,7 +79,8 @@ FrameBuffer::~FrameBuffer(void)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height)
void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
bool aspect)
{
bool isAlreadyInitialized = (SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO) > 0;
@ -129,6 +131,9 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height)
// Set window title
setWindowTitle(title);
// Indicate whether we want to use aspect ratio correction
theUseAspectRatioFlag = aspect;
// Get the maximum size of a window for the current desktop
theMaxZoomLevel = maxWindowSizeForScreen();
@ -140,9 +145,6 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height)
// Initialize video subsystem
initSubsystem();
// Show or hide the cursor based on the current state
setCursorState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -350,22 +352,16 @@ void FrameBuffer::resize(Size size, Int8 zoom)
void FrameBuffer::setCursorState()
{
bool isFullscreen = myOSystem->settings().getBool("fullscreen");
if(isFullscreen)
grabMouse(true);
else
grabMouse(myOSystem->settings().getBool("grabmouse"));
switch(myOSystem->eventHandler().state())
{
case EventHandler::S_EMULATE:
if(isFullscreen)
showCursor(false);
else
{
// Keep mouse in game window if grabmouse is selected
grabMouse(myOSystem->settings().getBool("grabmouse"));
// Never show cursor in normal emulation mode
showCursor(false);
}
showCursor(false);
break;
default:

View File

@ -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.28 2005-05-05 00:10:48 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.29 2005-05-06 22:50:15 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.28 2005-05-05 00:10:48 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.29 2005-05-06 22:50:15 stephena Exp $
*/
class FrameBuffer
{
@ -67,11 +67,13 @@ class FrameBuffer
(Re)initializes the framebuffer display. This must be called before any
calls are made to derived methods.
@param title The title of the window
@param width The width of the framebuffer
@param height The height of the framebuffer
@param title The title of the window
@param width The width of the framebuffer
@param height The height of the framebuffer
@param aspect Whether to use the aspect ratio setting
*/
void initialize(const string& title, uInt32 width, uInt32 height);
void initialize(const string& title, uInt32 width, uInt32 height,
bool aspect = true);
/**
Updates the display, which depending on the current mode could mean
@ -431,6 +433,9 @@ FIXME
// The aspect ratio of the window
float theAspectRatio;
// Indicates whether to use aspect ratio correction
bool theUseAspectRatioFlag;
// The font object to use
StellaFont* myFont;

View File

@ -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: OSystem.cxx,v 1.11 2005-05-06 18:38:59 stephena Exp $
// $Id: OSystem.cxx,v 1.12 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#include <cassert>
@ -160,6 +160,7 @@ bool OSystem::createFrameBuffer(bool showmessage)
break; // S_EMULATE, S_MENU
case EventHandler::S_LAUNCHER:
myLauncher->initializeVideo();
break; // S_LAUNCHER
case EventHandler::S_DEBUGGER:
@ -270,6 +271,8 @@ bool OSystem::createConsole(const string& romfile)
cout << "Game console created: " << myRomFile << endl;
retval = true;
myEventHandler->reset(EventHandler::S_EMULATE);
myFrameBuffer->setCursorState();
}
return retval;
@ -281,8 +284,7 @@ void OSystem::createLauncher()
myEventHandler->reset(EventHandler::S_LAUNCHER);
// Create the window
string title = "Stella: ROM Launcher"; // FIXME - include version of Stella
myFrameBuffer->initialize(title, kLauncherWidth, kLauncherHeight);
myLauncher->initializeVideo();
// And start the base dialog
myLauncher->initialize();

View File

@ -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.40 2005-05-01 18:57:21 stephena Exp $
// $Id: TIA.cxx,v 1.41 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#include <cassert>
@ -236,6 +236,8 @@ void TIA::reset()
myColorLossEnabled = false;
myMaximumNumberOfScanlines = 290;
}
enableBits(true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -363,11 +365,6 @@ bool TIA::save(Serializer& out)
out.putBool(myM0CosmicArkMotionEnabled);
out.putLong(myM0CosmicArkCounter);
// There are currently six bits defined in TIABit
out.putLong(6);
for(uInt32 i = 0; i < 6; ++i)
out.putBool(myBitEnabled[i]);
out.putBool(myDumpEnabled);
out.putLong(myDumpDisabledCycle);
@ -464,16 +461,14 @@ bool TIA::load(Deserializer& in)
myM0CosmicArkMotionEnabled = in.getBool();
myM0CosmicArkCounter = (uInt32) in.getLong();
// We abuse the concept of 'enum' here
uInt32 limit = (uInt32) in.getLong();
for(uInt32 i = 0; i < limit; ++i)
myBitEnabled[i] = in.getBool();
myDumpEnabled = in.getBool();
myDumpDisabledCycle = (Int32) in.getLong();
// Load the sound sample stuff ...
mySound->load(in);
// Reset TIA bits to be on
enableBits(true);
}
catch(char *msg)
{

View File

@ -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: EventMappingDialog.cxx,v 1.6 2005-04-24 20:36:36 stephena Exp $
// $Id: EventMappingDialog.cxx,v 1.7 2005-05-06 22:50:15 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -58,7 +58,7 @@ EventMappingDialog::EventMappingDialog(OSystem* osystem, uInt16 x, uInt16 y,
// Get actions names
StringList l;
for(int i = 0; i < 58; ++i) // FIXME - create a size() method
for(int i = 0; i < 60; ++i) // FIXME - create a size() method
l.push_back(EventHandler::ourActionList[i].action);
myActionsList->setList(l);

View File

@ -13,9 +13,11 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Launcher.cxx,v 1.1 2005-05-06 18:39:00 stephena Exp $
// $Id: Launcher.cxx,v 1.2 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "LauncherDialog.hxx"
#include "bspf.hxx"
#include "Launcher.hxx"
@ -37,3 +39,10 @@ void Launcher::initialize()
delete myBaseDialog;
myBaseDialog = new LauncherDialog(myOSystem, 0, 0, kLauncherWidth, kLauncherHeight);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Launcher::initializeVideo()
{
string title = "Stella: ROM Launcher"; // FIXME - include version of Stella
myOSystem->frameBuffer().initialize(title, kLauncherWidth, kLauncherHeight, false);
}

View File

@ -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: Launcher.hxx,v 1.1 2005-05-06 18:39:00 stephena Exp $
// $Id: Launcher.hxx,v 1.2 2005-05-06 22:50:15 stephena Exp $
//============================================================================
#ifndef LAUNCHER_HXX
@ -32,7 +32,7 @@ enum {
The base dialog for the ROM launcher in Stella.
@author Stephen Anthony
@version $Id: Launcher.hxx,v 1.1 2005-05-06 18:39:00 stephena Exp $
@version $Id: Launcher.hxx,v 1.2 2005-05-06 22:50:15 stephena Exp $
*/
class Launcher : public DialogContainer
{
@ -52,6 +52,11 @@ class Launcher : public DialogContainer
Updates the basedialog to be of the type defined for this derived class.
*/
void initialize();
/**
Initialize the video subsystem wrt this class.
*/
void initializeVideo();
};
#endif

View File

@ -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: LauncherDialog.cxx,v 1.1 2005-05-06 18:39:00 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.2 2005-05-06 22:50:15 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -52,8 +52,8 @@ LauncherDialog::LauncherDialog(OSystem* osystem, uInt16 x, uInt16 y,
: Dialog(osystem, x, y, w, h)
{
// Show game name
new StaticTextWidget(this, 10, 8, 300, kLineHeight, "Select a game from the list ...",
kTextAlignCenter);
new StaticTextWidget(this, 10, 8, _w - 20, kLineHeight,
"Select a game from the list ...", kTextAlignCenter);
// Add three buttons at the bottom
const int border = 10;
@ -72,7 +72,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, uInt16 x, uInt16 y,
xpos += space + width;
// Add list with game titles
myList = new ListWidget(this, 10, 24, 300, 142);
myList = new ListWidget(this, 10, 24, _w - 20, _h - 24 - 26 - 10);
myList->setEditable(false);
myList->setNumberingMode(kListNumberingOff);