We're getting closer to a simple user interface. The framework

is basically there.  All I need to do now is create methods that
actually draws text, boxes, cursors, etc.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@190 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-09-26 00:32:00 +00:00
parent 1359d7a14f
commit 267a9edf25
6 changed files with 148 additions and 98 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.40 2003-09-20 13:41:36 stephena Exp $
## $Id: makefile,v 1.41 2003-09-26 00:32:00 stephena Exp $
##============================================================================
##============================================================================
@ -30,9 +30,9 @@ OPTIMIZATIONS = $(CXXFLAGS) -Wall -Wno-unused
### SDL sound not yet supported in the X11 version
### comment out all lines to completely disable sound
###
SOUND_ALSA = 1
SOUND_OSS = 1
SOUND_SDL = 1
#SOUND_ALSA = 1
#SOUND_OSS = 1
#SOUND_SDL = 1
### if your C++ compiler doesn't support the bool type
# BSPF_BOOL = 1
@ -89,7 +89,7 @@ SRC = ..
CORE = $(SRC)/emucore
UI = $(SRC)/ui
INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src -I$(CORE)/m6502/src/bspf/src -I$(UI)/common -I$(UI)/frontend
INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src -I$(CORE)/m6502/src/bspf/src -I$(UI)/common
FLAGS = $(OPTIMIZATIONS) $(INCLUDES) $(SYS_INCLUDES)
@ -238,7 +238,7 @@ bsdi-x:
LDFLAGS+="$(CFLAGS.X11)" \
LDLIBS="-lX11 -lXext" \
LDLIBS+="$(LIBS.X11)" \
OBJS="mainX11.o FrontendUNIX.o SettingsUNIX.o"
OBJS="mainX11.o SettingsUNIX.o"
OBJS+="$(OBJS.X11)"
solaris-x:
@ -251,7 +251,7 @@ solaris-x:
LDFLAGS+="$(CFLAGS.X11)" \
LDLIBS="-lX11 -lXext" \
LDLIBS+="$(LIBS.X11)" \
OBJS="mainX11.o FrontendUNIX.o SettingsUNIX.o"
OBJS="mainX11.o SettingsUNIX.o"
OBJS+="$(OBJS.X11)"
###############################################################################
@ -265,7 +265,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
CartMB.o Console.o Control.o Driving.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 \
Serializer.o Deserializer.o TIASound.o EventHandler.o UserInterface.o \
$(M6502_OBJS)
stella.exe: $(CORE_OBJS) $(OBJS)
@ -313,9 +313,6 @@ Event.o: $(CORE)/Event.cxx $(CORE)/Event.hxx
EventHandler.o: $(CORE)/EventHandler.cxx $(CORE)/EventHandler.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/EventHandler.cxx
Frontend.o: $(CORE)/Frontend.cxx $(CORE)/Frontend.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Frontend.cxx
Control.o: $(CORE)/Control.cxx $(CORE)/Control.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Control.cxx
@ -394,6 +391,9 @@ M6532.o: $(CORE)/M6532.cxx $(CORE)/M6532.hxx
TIA.o: $(CORE)/TIA.cxx $(CORE)/TIA.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/TIA.cxx
UserInterface.o: $(CORE)/UserInterface.cxx $(CORE)/UserInterface.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/UserInterface.cxx
TIASound.o: $(CORE)/TIASound.c $(CORE)/TIASound.h
$(CXX) -c -DWIN32 $(FLAGS) $(OPTIONS) $(CORE)/TIASound.c
@ -460,9 +460,6 @@ SoundOSS.o: $(UI)/sound/SoundOSS.cxx $(UI)/sound/SoundOSS.hxx
SoundSDL.o: $(UI)/sound/SoundSDL.cxx $(UI)/sound/SoundSDL.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundSDL.cxx
FrontendUNIX.o: $(UI)/frontend/FrontendUNIX.cxx $(UI)/frontend/FrontendUNIX.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/frontend/FrontendUNIX.cxx
mainX11.o: $(UI)/x11/mainX11.cxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/x11/mainX11.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: EventHandler.cxx,v 1.10 2003-09-25 16:20:34 stephena Exp $
// $Id: EventHandler.cxx,v 1.11 2003-09-26 00:32:00 stephena Exp $
//============================================================================
#include <algorithm>
@ -94,9 +94,15 @@ void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
if(key == StellaEvent::KCODE_TAB && state == 1)
{
myMenuStatus = !myMenuStatus;
myConsole->gui().showMainMenu(myMenuStatus);
if(!myMenuStatus)
if(myMenuStatus)
{
myConsole->gui().showMenu(UserInterface::MENU_MAIN);
}
else
{
myConsole->gui().showMenu(UserInterface::MENU_NONE);
myReturnPressedFlag = myRemapModeFlag = myEventSelectedFlag = false;
}
return;
}
@ -138,20 +144,23 @@ void EventHandler::processMenuEvent(StellaEvent::KeyCode key)
}
else if(myReturnPressedFlag)
{
// FIXME - get selected menu
if(1)//menu == REMAP)
UserInterface::MenuType menu = myConsole->gui().currentSelectedMenu();
if(menu == UserInterface::MENU_REMAP)
{
// draw remap menu
cerr << "entering remap mode\n";
myConsole->gui().showMenu(UserInterface::MENU_REMAP);
myRemapModeFlag = true;
}
/* else if(1)//menu == INFO)
else if(menu == UserInterface::MENU_INFO)
{
// draw info menu
myConsole->gui().showMenu(UserInterface::MENU_INFO);
}
*/
myReturnPressedFlag = false;
}
else if(key == StellaEvent::KCODE_UP)
myConsole->gui().moveCursorUp();
else if(key == StellaEvent::KCODE_DOWN)
myConsole->gui().moveCursorDown();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -161,7 +170,7 @@ void EventHandler::sendJoyEvent(StellaEvent::JoyStick stick,
// Determine where the event should be sent
if(myMenuStatus && state == 1)
{
cerr << "send joy event to remap class\n";
cerr << "send joy event to remap class\nstick = " << stick << ", button = " << code << endl;
}
else
{
@ -369,6 +378,7 @@ void EventHandler::setDefaultKeymap()
void EventHandler::setDefaultJoymap()
{
// Left joystick
myJoyTable[StellaEvent::JSTICK_0][StellaEvent::JBUTTON_9 ] = Event::ConsoleSelect;
myJoyTable[StellaEvent::JSTICK_0][StellaEvent::JAXIS_UP] = Event::JoystickZeroUp;
myJoyTable[StellaEvent::JSTICK_0][StellaEvent::JAXIS_DOWN] = Event::JoystickZeroDown;
myJoyTable[StellaEvent::JSTICK_0][StellaEvent::JAXIS_LEFT] = Event::JoystickZeroLeft;

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: StellaEvent.hxx,v 1.3 2003-09-25 16:20:34 stephena Exp $
// $Id: StellaEvent.hxx,v 1.4 2003-09-26 00:32:00 stephena Exp $
//============================================================================
#ifndef STELLAEVENT_HXX
@ -28,7 +28,7 @@
by the frontends directly.
@author Stephen Anthony
@version $Id: StellaEvent.hxx,v 1.3 2003-09-25 16:20:34 stephena Exp $
@version $Id: StellaEvent.hxx,v 1.4 2003-09-26 00:32:00 stephena Exp $
*/
class StellaEvent
{
@ -38,7 +38,6 @@ class StellaEvent
*/
enum KeyCode
{
KCODE_NONE,
KCODE_a, KCODE_b, KCODE_c, KCODE_d, KCODE_e, KCODE_f, KCODE_g, KCODE_h,
KCODE_i, KCODE_j, KCODE_k, KCODE_l, KCODE_m, KCODE_n, KCODE_o, KCODE_p,
KCODE_q, KCODE_r, KCODE_s, KCODE_t, KCODE_u, KCODE_v, KCODE_w, KCODE_x,
@ -70,14 +69,12 @@ class StellaEvent
*/
enum JoyStick
{
JSTICK_NONE,
JSTICK_0, JSTICK_1, JSTICK_2, JSTICK_3,
LastJSTICK
};
enum JoyCode
{
JCODE_NONE,
JAXIS_UP, JAXIS_DOWN, JAXIS_LEFT, JAXIS_RIGHT,
JBUTTON_0, JBUTTON_1, JBUTTON_2, JBUTTON_3, JBUTTON_4,
JBUTTON_5, JBUTTON_6, JBUTTON_7, JBUTTON_8, JBUTTON_9,

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.20 2003-09-21 14:33:33 stephena Exp $
// $Id: TIA.cxx,v 1.21 2003-09-26 00:32:00 stephena Exp $
//============================================================================
#include <cassert>
@ -28,6 +28,7 @@
#include "TIA.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "UserInterface.hxx"
#include "TIASound.h"
#define HBLANK 68
@ -573,12 +574,9 @@ void TIA::update()
uInt32 totalClocks = (mySystem->cycles() * 3) - myClockWhenFrameStarted;
myScanlineCountForLastFrame = totalClocks / 228;
// Draw any pending messages to the framebuffer
if(myMessageTime > 0)
{
drawMessageText();
--myMessageTime;
}
// Draw any pending user interface elements to the framebuffer
if(myConsole.gui().drawPending())
myConsole.gui().update();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,11 +13,12 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: UserInterface.cxx,v 1.1 2003-09-25 16:20:34 stephena Exp $
// $Id: UserInterface.cxx,v 1.2 2003-09-26 00:32:00 stephena Exp $
//============================================================================
#include "bspf.hxx"
#include "Console.hxx"
#include "Event.hxx"
#include "Settings.hxx"
#include "MediaSrc.hxx"
#include "UserInterface.hxx"
@ -26,28 +27,28 @@
UserInterface::UserInterface(Console* console, MediaSource* mediasrc)
: myConsole(console),
myMediaSource(mediasrc),
myIsBufferDirtyFlag(true)
myBufferSize(160*300),
myBufferDirtyFlag(true),
myCurrentMenu(MENU_NONE)
{
myMenuBuffer = new uInt8[160 * 300];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UserInterface::~UserInterface(void)
{
// FIXME
cerr << "UserInterface::~UserInterface called\n";
delete[] myMenuBuffer;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::showMainMenu(bool show)
void UserInterface::showMenu(MenuType type)
{
if(show)
cerr << "Menu entered ...\n";
else
cerr << "Menu exit.\n";
if(myCurrentMenu != type)
myBufferDirtyFlag = true;
myCurrentMenu = type;
// if(myBufferDirtyFlag)
// cls();
return;
/* uInt8* frontbuffer = myMediaSource->currentFrameBuffer();
uInt8* backbuffer = myMediaSource->previousFrameBuffer();
@ -67,40 +68,83 @@ void UserInterface::showMainMenu(bool show)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::setXStart(uInt32 value)
{
myXStart = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::setYStart(uInt32 value)
{
myYStart = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::setWidth(uInt32 value)
{
myWidth = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::setHeight(uInt32 value)
{
myHeight = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*void UserInterface::cls()
void UserInterface::cls()
{
cerr << "UserInterface::cls() called\n";
uInt8* frontbuffer = myMediaSource->currentFrameBuffer();
uInt8* backbuffer = myMediaSource->previousFrameBuffer();
for(uInt32 i = 0; i < 160*300; ++i)
frontbuffer[i] = backbuffer[i] = (uInt8) 0;
// Initialize buffer to -1, which represents an 'opaque' color
// When the buffer is overlaid onto the TIA, all pixels with a
// color of -1 will be use the underlying color, like a color mask
for(uInt32 i = 0; i < myBufferSize; ++i)
myBuffer[i] = -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::update()
{
uInt8* frontbuffer = myMediaSource->currentFrameBuffer();
if(myCurrentMenu == MENU_NONE)
{
myCurrentMenu = MENU_NONE;
}
else if(myCurrentMenu == MENU_MAIN)
{
cerr << "draw main menu\n";
}
else if(myCurrentMenu == MENU_REMAP)
{
cerr << "draw remap menu\n";
}
else if(myCurrentMenu == MENU_INFO)
{
cerr << "draw info menu\n";
// FIXME - this will disappear soon ...
// First, draw the surrounding box
for(uInt32 x = 10; x < 100; ++x)
{
for(uInt32 y = 10; y < 200; ++y)
{
uInt32 position = ((20 + y) * 160) + x + 20;
if((x == 0) || (x == 200 - 1) || (y == 0) || (y == 200 - 1))
frontbuffer[position] = 10;
else
frontbuffer[position] = 0;
}
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UserInterface::MenuType UserInterface::currentSelectedMenu()
{
return MENU_INFO; // FIXME
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type UserInterface::currentSelectedItem()
{
return Event::NoType; // FIXME
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::moveCursorUp()
{
cerr << "cursor up\n";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::moveCursorDown()
{
cerr << "cursor down\n";
}
/*
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::drawMessageText(string& message)
{

View File

@ -13,13 +13,14 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: UserInterface.hxx,v 1.1 2003-09-25 16:20:34 stephena Exp $
// $Id: UserInterface.hxx,v 1.2 2003-09-26 00:32:00 stephena Exp $
//============================================================================
#ifndef USERINTERFACE_HXX
#define USERINTERFACE_HXX
#include "bspf.hxx"
#include "Event.hxx"
class Console;
class MediaSource;
@ -29,7 +30,7 @@ class MediaSource;
can be changed.
@author Stephen Anthony
@version $Id: UserInterface.hxx,v 1.1 2003-09-25 16:20:34 stephena Exp $
@version $Id: UserInterface.hxx,v 1.2 2003-09-26 00:32:00 stephena Exp $
*/
class UserInterface
{
@ -47,25 +48,22 @@ class UserInterface
*/
virtual ~UserInterface(void);
// @param key The key of the property to lookup
// @return The value of the property
// Enumeration representing the different types of menus
enum MenuType { MENU_NONE, MENU_MAIN, MENU_REMAP, MENU_INFO };
public:
void setXStart(uInt32 value);
void setYStart(uInt32 value);
void setWidth(uInt32 value);
void setHeight(uInt32 value);
MenuType currentSelectedMenu();
Event::Type currentSelectedItem();
// void drawMessageText(string& message);
void showMainMenu(bool show);
void showRemapMenu(bool show);
void showInfoMenu(bool show);
bool drawPending() { return myCurrentMenu != MENU_NONE; }
void showMenu(MenuType type);
void update();
void moveCursorUp();
void moveCursorDown();
private:
// Enumerations representing the different types of menus
enum MenuType { MENU_REMAP, MENU_INFO };
// Clears the internal framebuffer
void cls();
private:
// The Console for the system
@ -74,8 +72,11 @@ class UserInterface
// The Mediasource for the system
MediaSource* myMediaSource;
// A buffer containing the current menu to be drawn
uInt8* myMenuBuffer;
// A buffer containing the current interface element to be drawn
Int16* myBuffer;
// Indicates the size of the framebuffer
uInt32 myBufferSize;
// Bounds for the window frame
uInt32 myXStart, myYStart, myWidth, myHeight;
@ -84,7 +85,10 @@ class UserInterface
static const uInt32 ourFontData[36];
// Indicates if buffers are dirty (have been modified)
bool myIsBufferDirtyFlag;
bool myBufferDirtyFlag;
// Menu type currently slated for redraw
MenuType myCurrentMenu;
};
#endif