And so it begins ... Very rudimentary support for the integrated debugger

has started.  The debugger can only be launched when in emulation mode, and
is toggled by the ` (backquote) key.  Right now, I'm still fine-tuning the
infrastructure.  When you press `, the SDL window resizes itself to 510x382
pixels (large enough at single zoom for 800x600 and under, and at double
zoom for 1024x768 and above).  The emulation is moved to the upper left
corner, and the remaining space will be filled with debugger widgets (making
extensive use of the TabWidget to squeeze as much as possible into the
limited screen real-estate).  It's my intention for at least _minimal_
debugger functionality to be included in the next release.

Removed 10% gap around framebuffer in fullscreen OpenGL mode.  I'm moving
Stella towards a totally unified codebase, so if a feature can't be added
to both types of framebuffers, it won't be added at all.  The one exception
is gl_aspect; I still want to keep that one around.  And I eventually may
add aspect correction to the software mode as well, ala ScummVM.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@444 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-05-27 18:00:49 +00:00
parent ec27cb2b1c
commit 8a0432af80
14 changed files with 268 additions and 46 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: makefile,v 1.84 2005-05-21 19:55:17 stephena Exp $
## $Id: makefile,v 1.85 2005-05-27 18:00:46 stephena Exp $
##============================================================================
##============================================================================
@ -154,7 +154,7 @@ win32-gl:
###############################################################################
M6502_OBJS = D6502.o Device.o M6502.o M6502Low.o M6502Hi.o NullDev.o System.o
GUI_OBJS = StellaFont.o Menu.o Launcher.o \
GUI_OBJS = StellaFont.o Menu.o Launcher.o Debugger.o \
Widget.o PopUpWidget.o ScrollBarWidget.o ListWidget.o TabWidget.o \
Dialog.o DialogContainer.o OptionsDialog.o VideoDialog.o AudioDialog.o \
EventMappingDialog.o GameInfoDialog.o HelpDialog.o AboutDialog.o \
@ -388,6 +388,9 @@ Menu.o: $(GUI)/Menu.cxx $(GUI)/Menu.hxx
Launcher.o: $(GUI)/Launcher.cxx $(GUI)/Launcher.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Launcher.cxx
Debugger.o: $(GUI)/Debugger.cxx $(GUI)/Debugger.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Debugger.cxx
Widget.o: $(GUI)/Widget.cxx $(GUI)/Widget.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Widget.cxx

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.23 2005-05-16 00:02:31 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.24 2005-05-27 18:00:47 stephena Exp $
//============================================================================
#include <SDL.h>
@ -513,9 +513,9 @@ void FrameBufferGL::setDimensions(GLdouble* orthoWidth, GLdouble* orthoHeight)
// Figure out which dimension is closest to the 10% mark,
// and calculate the scaling required to bring it to exactly 10%
if(scaleX > scaleY)
myFSScaleFactor = float(myScreenDim.w * 0.9) / myImageDim.w;
myFSScaleFactor = float(myScreenDim.w) / myImageDim.w;
else
myFSScaleFactor = float(myScreenDim.h * 0.9) / myImageDim.h;
myFSScaleFactor = float(myScreenDim.h) / myImageDim.h;
myImageDim.w = (Uint16) (myFSScaleFactor * myImageDim.w);
myImageDim.h = (Uint16) (myFSScaleFactor * myImageDim.h);
@ -530,12 +530,10 @@ void FrameBufferGL::setDimensions(GLdouble* orthoWidth, GLdouble* orthoHeight)
scaleX = float(myImageDim.w) / myScreenDim.w;
scaleY = float(myImageDim.h) / myScreenDim.h;
// Figure out which dimension is closest to the 10% mark,
// and calculate the scaling required to bring it to exactly 10%
if(scaleX > scaleY)
myFSScaleFactor = (myScreenDim.w * 0.9) / myImageDim.w;
myFSScaleFactor = float(myScreenDim.w) / myImageDim.w;
else
myFSScaleFactor = (myScreenDim.h * 0.9) / myImageDim.h;
myFSScaleFactor = float(myScreenDim.h) / myImageDim.h;
myImageDim.w = (Uint16) (myFSScaleFactor * myImageDim.w);
myImageDim.h = (Uint16) (myFSScaleFactor * myImageDim.h);

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.53 2005-05-12 18:45:20 stephena Exp $
// $Id: Console.cxx,v 1.54 2005-05-27 18:00:47 stephena Exp $
//============================================================================
#include <assert.h>
@ -46,6 +46,7 @@
#include "FrameBuffer.hxx"
#include "OSystem.hxx"
#include "Menu.hxx"
#include "Debugger.hxx"
#ifdef SNAPSHOT_SUPPORT
#include "Snapshot.hxx"
@ -187,6 +188,10 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
// Initialize the menuing system with updated values from the framebuffer
myOSystem->menu().initialize();
myOSystem->menu().setGameProfile(myProperties);
// Finally, initialize the debugging system, since it depends on the current ROM
myOSystem->debugger().initialize();
// myOSystem->menu().setGameProfile(myProperties);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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.62 2005-05-26 15:43:43 stephena Exp $
// $Id: EventHandler.cxx,v 1.63 2005-05-27 18:00:47 stephena Exp $
//============================================================================
#include <algorithm>
@ -30,6 +30,7 @@
#include "OSystem.hxx"
#include "Menu.hxx"
#include "Launcher.hxx"
#include "Debugger.hxx"
#include "GuiUtils.hxx"
#include "bspf.hxx"
@ -463,6 +464,10 @@ void EventHandler::poll(uInt32 time)
myOSystem->launcher().updateTime(time);
break;
case S_DEBUGGER:
myOSystem->debugger().updateTime(time);
break;
default:
break;
}
@ -615,12 +620,12 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
}
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);
myEvent->clear();
enterMenuMode();
return;
}
else if(myKeyTable[key] == Event::DebuggerMode && state == 1 && !myPauseFlag)
{
enterDebugMode();
return;
}
else
@ -629,13 +634,9 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
break; // S_EMULATE
case S_MENU:
if(myKeyTable[key] == Event::MenuMode && state == 1 && !myPauseFlag)
if(myKeyTable[key] == Event::MenuMode && state == 1)
{
myState = S_EMULATE;
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(false);
myEvent->clear();
leaveMenuMode();
return;
}
myOSystem->menu().handleKeyEvent(key, mod, state);
@ -646,7 +647,12 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
break;
case S_DEBUGGER:
// Not yet implemented
if(myKeyTable[key] == Event::DebuggerMode && state == 1)
{
leaveDebugMode();
return;
}
myOSystem->debugger().handleKeyEvent(key, mod, state);
break;
case S_NONE:
@ -1102,6 +1108,7 @@ void EventHandler::setDefaultKeymap()
myKeyTable[ SDLK_F12 ] = Event::TakeSnapshot;
myKeyTable[ SDLK_PAUSE ] = Event::Pause;
myKeyTable[ SDLK_TAB ] = Event::MenuMode;
myKeyTable[ SDLK_BACKQUOTE ] = Event::DebuggerMode;
myKeyTable[ SDLK_ESCAPE ] = Event::LauncherMode;
saveMappings();
@ -1288,6 +1295,57 @@ void EventHandler::setPaddleMode(uInt32 num, bool showmessage)
myOSystem->settings().setInt("paddle", myPaddleMode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::enterMenuMode()
{
myState = S_MENU;
myOSystem->menu().reStack();
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(true);
myEvent->clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::leaveMenuMode()
{
myState = S_EMULATE;
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myOSystem->sound().mute(false);
myEvent->clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::enterDebugMode()
{
cerr << "S_DEBUGGER entered\n";
myState = S_DEBUGGER;
myOSystem->createFrameBuffer();
myOSystem->debugger().reStack();
myOSystem->frameBuffer().refresh(); // FIXME - theRedrawEntireFrameIndicator not properly set
myOSystem->frameBuffer().setCursorState();
myEvent->clear();
if(!myPauseFlag) // Pause when entering debugger mode
handleEvent(Event::Pause, 1);
cerr << "S_DEBUGGER entered done\n";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::leaveDebugMode()
{
cerr << "S_DEBUGGER left\n";
myState = S_EMULATE;
myOSystem->createFrameBuffer();
myOSystem->frameBuffer().refresh();
myOSystem->frameBuffer().setCursorState();
myEvent->clear();
if(myPauseFlag) // Un-Pause when leaving debugger mode
handleEvent(Event::Pause, 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setSDLMappings()
{

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.32 2005-05-26 15:43:44 stephena Exp $
// $Id: EventHandler.hxx,v 1.33 2005-05-27 18:00:48 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -74,7 +74,7 @@ struct Stella_Joystick {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.32 2005-05-26 15:43:44 stephena Exp $
@version $Id: EventHandler.hxx,v 1.33 2005-05-27 18:00:48 stephena Exp $
*/
class EventHandler
{
@ -253,6 +253,11 @@ class EventHandler
void loadState();
void takeSnapshot();
void enterMenuMode();
void leaveMenuMode();
void enterDebugMode();
void leaveDebugMode();
private:
// Global OSystem object
OSystem* myOSystem;

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.38 2005-05-25 23:22:11 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.39 2005-05-27 18:00:48 stephena Exp $
//============================================================================
#include <sstream>
@ -29,6 +29,7 @@
#include "GuiUtils.hxx"
#include "Menu.hxx"
#include "Launcher.hxx"
#include "Debugger.hxx"
#include "OSystem.hxx"
#include "stella.xpm" // The Stella icon
@ -242,8 +243,31 @@ void FrameBuffer::update()
}
case EventHandler::S_DEBUGGER:
// Not yet implemented
break;
// Draw changes to the mediasource
if(!myPauseStatus)
myOSystem->console().mediaSource().update();
// We always draw the screen, even if the core is paused
drawMediaSource();
// Only update the screen if it's been invalidated or the menus have changed
if(theRedrawEntireFrameIndicator || theMenuChangedIndicator)
{
// Overlay the ROM launcher
myOSystem->debugger().draw();
// Now the screen is up to date
theRedrawEntireFrameIndicator = false;
// This is a performance hack to only draw the menus when necessary
// Software mode is single-buffered, so we don't have to worry
// However, OpenGL mode is double-buffered, so we need to draw the
// menus at least twice (so they'll be in both buffers)
// Otherwise, we get horrible flickering
myMenuRedraws--;
theMenuChangedIndicator = (myMenuRedraws != 0);
}
break; // S_DEBUGGER
case EventHandler::S_NONE:
return;

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.21 2005-05-26 18:56:58 stephena Exp $
// $Id: OSystem.cxx,v 1.22 2005-05-27 18:00:48 stephena Exp $
//============================================================================
#include <cassert>
@ -40,6 +40,7 @@
#include "EventHandler.hxx"
#include "Menu.hxx"
#include "Launcher.hxx"
#include "Debugger.hxx"
#include "bspf.hxx"
#include "OSystem.hxx"
@ -53,12 +54,14 @@ OSystem::OSystem()
myConsole(NULL),
myMenu(NULL),
myLauncher(NULL),
myDebugger(NULL),
myRomFile(""),
myFeatures("")
{
// Create menu and launcher GUI objects
myMenu = new Menu(this);
myLauncher = new Launcher(this);
myDebugger = new Debugger(this);
// Determine which features were conditionally compiled into Stella
#ifdef DISPLAY_OPENGL
@ -85,6 +88,7 @@ OSystem::~OSystem()
delete myMenu;
delete myLauncher;
delete myDebugger;
// Remove any game console that is currently attached
delete myConsole;
@ -199,7 +203,8 @@ bool OSystem::createFrameBuffer(bool showmessage)
break; // S_LAUNCHER
case EventHandler::S_DEBUGGER:
break;
myDebugger->initializeVideo();
break; // S_DEBUGGER
case EventHandler::S_NONE:
break;
@ -239,20 +244,18 @@ void OSystem::createSound()
mySound = new SoundNull(this);
#endif
// Re-initialize the framebuffer to current settings
// Re-initialize the sound object to current settings
switch(myEventHandler->state())
{
case EventHandler::S_EMULATE:
case EventHandler::S_MENU:
case EventHandler::S_DEBUGGER:
myConsole->initializeAudio();
break; // S_EMULATE, S_MENU
break; // S_EMULATE, S_MENU, S_DEBUGGER
case EventHandler::S_LAUNCHER:
break; // S_LAUNCHER
case EventHandler::S_DEBUGGER:
break;
case EventHandler::S_NONE:
break;
}

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.hxx,v 1.18 2005-05-26 18:56:58 stephena Exp $
// $Id: OSystem.hxx,v 1.19 2005-05-27 18:00:48 stephena Exp $
//============================================================================
#ifndef OSYSTEM_HXX
@ -23,6 +23,7 @@ class PropertiesSet;
class Menu;
class Launcher;
class Debugger;
#include "EventHandler.hxx"
#include "FrameBuffer.hxx"
@ -39,7 +40,7 @@ class Launcher;
other objects belong.
@author Stephen Anthony
@version $Id: OSystem.hxx,v 1.18 2005-05-26 18:56:58 stephena Exp $
@version $Id: OSystem.hxx,v 1.19 2005-05-27 18:00:48 stephena Exp $
*/
class OSystem
{
@ -132,6 +133,13 @@ class OSystem
*/
Launcher& launcher(void) const { return *myLauncher; }
/**
Get the ROM debugger of the system.
@return The debugger object
*/
Debugger& debugger(void) const { return *myDebugger; }
/**
Set the framerate for the video system. It's placed in this class since
the mainLoop() method is defined here.
@ -326,6 +334,9 @@ class OSystem
// Pointer to the Launcher object
Launcher* myLauncher;
// Pointer to the Debugger object
Debugger* myDebugger;
// Number of times per second to iterate through the main loop
uInt32 myDisplayFrameRate;

View File

@ -0,0 +1,52 @@
//============================================================================
//
// 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: Debugger.cxx,v 1.1 2005-05-27 18:00:49 stephena Exp $
//============================================================================
#include "Version.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "VideoDialog.hxx"
#include "bspf.hxx"
#include "Debugger.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Debugger::Debugger(OSystem* osystem)
: DialogContainer(osystem)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Debugger::~Debugger()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::initialize()
{
// We only create one instance of this dialog, since each time we do so,
// the ROM listing is read from disk. This can be very expensive.
if(myBaseDialog == NULL)
myBaseDialog = new VideoDialog(myOSystem, this,
0, 0, kDebuggerWidth, kDebuggerHeight);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::initializeVideo()
{
string title = string("Stella version ") + STELLA_VERSION + ": Debugger mode";
myOSystem->frameBuffer().initialize(title, kDebuggerWidth, kDebuggerHeight, false);
}

View File

@ -0,0 +1,62 @@
//============================================================================
//
// 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: Debugger.hxx,v 1.1 2005-05-27 18:00:49 stephena Exp $
//============================================================================
#ifndef DEBUGGER_HXX
#define DEBUGGER_HXX
class OSystem;
#include "DialogContainer.hxx"
enum {
kDebuggerWidth = 510,
kDebuggerHeight = 382
};
/**
The base dialog for the ROM launcher in Stella.
@author Stephen Anthony
@version $Id: Debugger.hxx,v 1.1 2005-05-27 18:00:49 stephena Exp $
*/
class Debugger : public DialogContainer
{
public:
/**
Create a new menu stack
*/
Debugger(OSystem* osystem);
/**
Destructor
*/
virtual ~Debugger();
public:
/**
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: FontData.hxx,v 1.1 2005-03-13 03:38:40 stephena Exp $
// $Id: FontData.hxx,v 1.2 2005-05-27 18:00:49 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -334,9 +334,9 @@ static const uInt16 _font_bits[] = {
| |
| |
| |
| * |
| |
| * |
| * |
|* |
| |
+---+
@ -346,9 +346,9 @@ static const uInt16 _font_bits[] = {
0x0000,
0x0000,
0x0000,
0x4000,
0x0000,
0x4000,
0x4000,
0x8000,
0x0000,

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: GameInfoDialog.hxx,v 1.4 2005-05-13 18:28:05 stephena Exp $
// $Id: GameInfoDialog.hxx,v 1.5 2005-05-27 18:00:49 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,6 +34,7 @@ class StaticTextWidget;
#define LINES_PER_PAGE 10
#include "OSystem.hxx"
#include "Dialog.hxx"
#include "Props.hxx"
#include "bspf.hxx"

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: OptionsDialog.hxx,v 1.8 2005-05-16 15:37:30 stephena Exp $
// $Id: OptionsDialog.hxx,v 1.9 2005-05-27 18:00:49 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -24,7 +24,6 @@
class Properties;
class CommandSender;
class Dialog;
class DialogContainer;
class VideoDialog;
class AudioDialog;
@ -33,6 +32,7 @@ class HelpDialog;
class AboutDialog;
#include "OSystem.hxx"
#include "Dialog.hxx"
#include "GameInfoDialog.hxx"
#include "bspf.hxx"

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: VideoDialog.hxx,v 1.5 2005-05-13 18:28:06 stephena Exp $
// $Id: VideoDialog.hxx,v 1.6 2005-05-27 18:00:49 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -23,7 +23,6 @@
#define VIDEO_DIALOG_HXX
class CommandSender;
class Dialog;
class DialogContainer;
class PopUpWidget;
class SliderWidget;
@ -31,6 +30,7 @@ class StaticTextWidget;
class CheckboxWidget;
#include "OSystem.hxx"
#include "Dialog.hxx"
#include "bspf.hxx"
class VideoDialog : public Dialog