Some bugfixes right across the board. We're on a rampage to get

the next release done, and this sucker is being finished soon.

Readded printing of watches to prompt.

Fixed issues with keypad buttons not being recognized in GUI mode.

Fixed bug in internal _select and _reset debugger functions, which
were reversed.

Toggling stereo/mono mode now updates the 'Cartridge.Sound' property,
so if the properties are later saved/merged, the modified sound
settings will be used for that game on next launch/reload.

Fixed a bug where selecting a new romdir in BrowserDialog would
sometimes cause a segfault.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@791 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-09-23 23:35:02 +00:00
parent 5c1c2fe30c
commit 9ae4f66e36
19 changed files with 191 additions and 726 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: Debugger.cxx,v 1.94 2005-09-23 17:38:26 stephena Exp $
// $Id: Debugger.cxx,v 1.95 2005-09-23 23:35:02 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -71,8 +71,8 @@ static const string builtin_functions[][3] = {
{ "_joy1button", "!(*INPT5 & $80)", "Right joystick button pressed" },
// console switches:
{ "_select", "!(*SWCHB & $01)", "Game Select pressed" },
{ "_reset", "!(*SWCHB & $02)", "Game Reset pressed" },
{ "_select", "!(*SWCHB & $02)", "Game Select pressed" },
{ "_reset", "!(*SWCHB & $01)", "Game Reset pressed" },
{ "_color", "*SWCHB & $08", "Color/BW set to Color" },
{ "_bw", "!(*SWCHB & $08)", "Color/BW set to BW" },
{ "_diff0a", "!(*SWCHB & $40)", "Right difficulty set to A (easy)" },

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: DebuggerParser.cxx,v 1.79 2005-09-23 17:38:26 stephena Exp $
// $Id: DebuggerParser.cxx,v 1.80 2005-09-23 23:35:02 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -926,7 +926,7 @@ string DebuggerParser::eval() {
}
string DebuggerParser::showWatches() {
string ret = "\n";
string ret;
char buf[10];
for(unsigned int i=0; i<watches.size(); i++) {
@ -944,14 +944,12 @@ string DebuggerParser::showWatches() {
ret += buf;
ret += ": " + argStrings[0] + "\n";
} else {
ret += " watch #";
ret += " watch #";
ret += buf;
ret += " (" + argStrings[0] + ") -> " + eval() + "\n";
}
}
}
// get rid of trailing \n
ret.erase(ret.length()-1, 1);
return ret;
}

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: ContextMenu.cxx,v 1.2 2005-09-13 18:27:42 stephena Exp $
// $Id: ContextMenu.cxx,v 1.3 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -110,7 +110,7 @@ void ContextMenu::handleMouseMoved(int x, int y, int button)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleKeyDown(int ascii, int keycode, int modifiers)
{
switch(keycode)
switch(ascii)
{
case 27: // escape
parent()->removeDialog();

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: DataGridWidget.cxx,v 1.1 2005-08-30 17:51:26 stephena Exp $
// $Id: DataGridWidget.cxx,v 1.2 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -241,7 +241,7 @@ bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
else
{
// not editmode
switch (keycode)
switch(ascii)
{
case '\n': // enter/return
case '\r':

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: PromptWidget.cxx,v 1.1 2005-08-30 17:51:26 stephena Exp $
// $Id: PromptWidget.cxx,v 1.2 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -139,7 +139,7 @@ void PromptWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
cerr << "PromptWidget::handleMouseDown\n";
// cerr << "PromptWidget::handleMouseDown\n";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -151,13 +151,10 @@ void PromptWidget::handleMouseWheel(int x, int y, int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::printPrompt()
{
// FIXME - the following will probably be permanantly removed
// since it's always shown in the main dialog area
/*
print( instance()->debugger().showWatches() );
print( instance()->debugger().cpuState() );
print("\n");
*/
string watches = instance()->debugger().showWatches();
if(watches.length() > 0)
print(watches);
print(PROMPT);
_promptStartPos = _promptEndPos = _currentPos;
}
@ -169,7 +166,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
bool handled = true;
bool dirty = false;
switch (keycode)
switch(ascii)
{
case '\n': // enter/return
case '\r':
@ -205,92 +202,92 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
}
case 9: // tab
{
// Tab completion: we complete either commands or labels, but not
// both at once.
case '\t': // tab
{
// Tab completion: we complete either commands or labels, but not
// both at once.
if(_currentPos <= _promptStartPos)
break;
if(_currentPos <= _promptStartPos)
break;
scrollToCurrent();
int len = _promptEndPos - _promptStartPos;
scrollToCurrent();
int len = _promptEndPos - _promptStartPos;
int lastDelimPos = -1;
char delimiter = '\0';
int lastDelimPos = -1;
char delimiter = '\0';
char *str = new char[len + 1];
for (i = 0; i < len; i++) {
str[i] = buffer(_promptStartPos + i) & 0x7f;
if(strchr("*@<> ", str[i]) != NULL ) {
lastDelimPos = i;
delimiter = str[i];
}
}
str[len] = '\0';
char *str = new char[len + 1];
for (i = 0; i < len; i++) {
str[i] = buffer(_promptStartPos + i) & 0x7f;
if(strchr("*@<> ", str[i]) != NULL ) {
lastDelimPos = i;
delimiter = str[i];
}
}
str[len] = '\0';
const char *completionList;
const char *prefix;
int possibilities;
const char *completionList;
const char *prefix;
int possibilities;
if(lastDelimPos < 0) {
// no delimiters, do command completion:
DebuggerParser *parser = instance()->debugger().parser();
possibilities = parser->countCompletions(str);
if(lastDelimPos < 0) {
// no delimiters, do command completion:
DebuggerParser *parser = instance()->debugger().parser();
possibilities = parser->countCompletions(str);
if(possibilities < 1) {
delete[] str;
break;
}
if(possibilities < 1) {
delete[] str;
break;
}
completionList = parser->getCompletions();
prefix = parser->getCompletionPrefix();
} else {
// we got a delimiter, so this must be a label:
EquateList *equates = instance()->debugger().equates();
possibilities = equates->countCompletions(str + lastDelimPos + 1);
completionList = parser->getCompletions();
prefix = parser->getCompletionPrefix();
} else {
// we got a delimiter, so this must be a label:
EquateList *equates = instance()->debugger().equates();
possibilities = equates->countCompletions(str + lastDelimPos + 1);
if(possibilities < 1) {
delete[] str;
break;
}
if(possibilities < 1) {
delete[] str;
break;
}
completionList = equates->getCompletions();
prefix = equates->getCompletionPrefix();
}
completionList = equates->getCompletions();
prefix = equates->getCompletionPrefix();
}
if(possibilities == 1) {
// add to buffer as though user typed it (plus a space)
_currentPos = _promptStartPos + lastDelimPos + 1;
while(*completionList != '\0') {
putcharIntern(*completionList++);
}
putcharIntern(' ');
_promptEndPos = _currentPos;
} else {
nextLine();
// add to buffer as-is, then add PROMPT plus whatever we have so far
_currentPos = _promptStartPos + lastDelimPos + 1;
if(possibilities == 1) {
// add to buffer as though user typed it (plus a space)
_currentPos = _promptStartPos + lastDelimPos + 1;
while(*completionList != '\0') {
putcharIntern(*completionList++);
}
putcharIntern(' ');
_promptEndPos = _currentPos;
} else {
nextLine();
// add to buffer as-is, then add PROMPT plus whatever we have so far
_currentPos = _promptStartPos + lastDelimPos + 1;
print("\n");
print(completionList);
print("\n");
print(PROMPT);
print("\n");
print(completionList);
print("\n");
print(PROMPT);
_promptStartPos = _currentPos;
_promptStartPos = _currentPos;
for(i=0; i<lastDelimPos; i++)
putcharIntern(str[i]);
for(i=0; i<lastDelimPos; i++)
putcharIntern(str[i]);
if(lastDelimPos > 0)
putcharIntern(delimiter);
if(lastDelimPos > 0)
putcharIntern(delimiter);
print(prefix);
_promptEndPos = _currentPos;
}
delete[] str;
dirty = true;
break;
print(prefix);
_promptEndPos = _currentPos;
}
delete[] str;
dirty = true;
break;
}
case 8: // backspace

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: RomWidget.cxx,v 1.6 2005-09-23 17:38:27 stephena Exp $
// $Id: RomWidget.cxx,v 1.7 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -109,7 +109,8 @@ void RomWidget::loadConfig()
myCurrentBank = dbg.getBank();
// Update romlist to point to current PC
int pc = dbg.cpuDebug().pc();
// Take mirroring of PC into account
int pc = dbg.cpuDebug().pc() | 0xe000;
AddrToLine::iterator iter = myLineList.find(pc);
if(iter != myLineList.end())
myRomList->setHighlighted(iter->second);
@ -133,7 +134,7 @@ void RomWidget::initialUpdate()
StringList label, data, disasm;
BoolArray state;
// Disassemble entire bank (up to 4096 lines) and invalidate all lines
// Disassemble entire bank (up to 4096 lines) and reset breakpoints
dbg.disassemble(myAddrList, label, data, disasm, 0xf000, 4096);
for(unsigned int i = 0; i < data.size(); ++i)
{

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: TiaZoomWidget.cxx,v 1.4 2005-09-06 22:25:40 stephena Exp $
// $Id: TiaZoomWidget.cxx,v 1.5 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -145,7 +145,7 @@ bool TiaZoomWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
bool handled = false;
switch (keycode)
switch(ascii)
{
case 256+17: // up arrow
myYCenter -= 4;

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: ToggleWidget.cxx,v 1.1 2005-08-30 17:51:26 stephena Exp $
// $Id: ToggleWidget.cxx,v 1.2 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -100,7 +100,7 @@ bool ToggleWidget::handleKeyDown(int ascii, int keycode, int modifiers)
bool handled = true;
bool dirty = false, toggle = false;
switch (keycode)
switch(ascii)
{
case '\n': // enter/return
case '\r':

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.71 2005-09-22 22:10:57 stephena Exp $
// $Id: Console.cxx,v 1.72 2005-09-23 23:35:02 stephena Exp $
//============================================================================
#include <assert.h>
@ -377,6 +377,16 @@ void Console::setPalette()
myOSystem->frameBuffer().setPalette(myMediaSource->palette());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::setChannels(int channels)
{
myOSystem->sound().setChannels(channels);
// Save to properties
string sound = channels == 2 ? "Stereo" : "Mono";
myProperties.set("Cartridge.Sound", sound);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* Original frying research and code by Fred Quimby.
I've tried the following variations on this code:

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.hxx,v 1.38 2005-08-24 22:54:30 stephena Exp $
// $Id: Console.hxx,v 1.39 2005-09-23 23:35:02 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -37,7 +37,7 @@ class System;
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.38 2005-08-24 22:54:30 stephena Exp $
@version $Id: Console.hxx,v 1.39 2005-09-23 23:35:02 stephena Exp $
*/
class Console
{
@ -167,6 +167,13 @@ class Console
*/
void setPalette();
/**
Sets the number of sound channels
@param channels Number of channels (indicates stereo or mono)
*/
void setChannels(int channels);
/**
"Fry" the Atari (mangle memory/TIA contents)
*/

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.96 2005-09-15 19:43:36 stephena Exp $
// $Id: EventHandler.cxx,v 1.97 2005-09-23 23:35:02 stephena Exp $
//============================================================================
#include <algorithm>
@ -674,71 +674,76 @@ void EventHandler::poll(uInt32 time)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 state)
{
// Determine which mode we're in, then send the event to the appropriate place
switch(myState)
if(myState == S_EMULATE)
{
case S_EMULATE:
if(myKeyTable[key] == Event::MenuMode && state == 1 && !myPauseFlag)
{
enterMenuMode();
return;
}
else if(myKeyTable[key] == Event::CmdMenuMode && state == 1 && !myPauseFlag)
{
enterCmdMenuMode();
return;
}
else if(myKeyTable[key] == Event::DebuggerMode && state == 1 && !myPauseFlag)
{
enterDebugMode();
return;
}
else if(myKeyTable[key] == Event::Fry)
{
myFryingFlag = bool(state);
}
else
handleEvent(myKeyTable[key], state);
if(myKeyTable[key] == Event::MenuMode && state == 1 && !myPauseFlag)
{
enterMenuMode();
return;
}
else if(myKeyTable[key] == Event::CmdMenuMode && state == 1 && !myPauseFlag)
{
enterCmdMenuMode();
return;
}
else if(myKeyTable[key] == Event::DebuggerMode && state == 1 && !myPauseFlag)
{
enterDebugMode();
return;
}
else if(myKeyTable[key] == Event::Fry)
{
myFryingFlag = bool(state);
}
else
handleEvent(myKeyTable[key], state);
}
else // Determine which dialog to send events to
{
// Make sure the unicode field is valid
if (key >= SDLK_F1 && key <= SDLK_F9)
unicode = key - SDLK_F1 + 315;
else if (key >= SDLK_KP0 && key <= SDLK_KP9)
unicode = key - SDLK_KP0 + '0';
else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN)
unicode = key;
break; // S_EMULATE
switch((int)myState)
{
case S_MENU:
if(myKeyTable[key] == Event::MenuMode && state == 1)
{
leaveMenuMode();
return;
}
myOSystem->menu().handleKeyEvent(unicode, key, mod, state);
break;
case S_MENU:
if(myKeyTable[key] == Event::MenuMode && state == 1)
{
leaveMenuMode();
return;
}
myOSystem->menu().handleKeyEvent(unicode, key, mod, state);
break;
case S_CMDMENU:
if(myKeyTable[key] == Event::CmdMenuMode && state == 1)
{
leaveCmdMenuMode();
return;
}
myOSystem->commandMenu().handleKeyEvent(unicode, key, mod, state);
break;
case S_CMDMENU:
if(myKeyTable[key] == Event::CmdMenuMode && state == 1)
{
leaveCmdMenuMode();
return;
}
myOSystem->commandMenu().handleKeyEvent(unicode, key, mod, state);
break;
case S_LAUNCHER:
myOSystem->launcher().handleKeyEvent(unicode, key, mod, state);
break;
case S_LAUNCHER:
myOSystem->launcher().handleKeyEvent(unicode, key, mod, state);
break;
#ifdef DEVELOPER_SUPPORT
case S_DEBUGGER:
if(myKeyTable[key] == Event::DebuggerMode && state == 1 &&
!(kbdAlt(mod) || kbdControl(mod) || kbdShift(mod)))
{
leaveDebugMode();
return;
}
myOSystem->debugger().handleKeyEvent(unicode, key, mod, state);
break;
case S_DEBUGGER:
if(myKeyTable[key] == Event::DebuggerMode && state == 1 &&
!(kbdAlt(mod) || kbdControl(mod) || kbdShift(mod)))
{
leaveDebugMode();
return;
}
myOSystem->debugger().handleKeyEvent(unicode, key, mod, state);
break;
#endif
default:
return;
break;
}
}
}

View File

@ -1,443 +0,0 @@
//============================================================================
//
// 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 and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: AddrValueWidget.cxx,v 1.11 2005-08-11 19:12:39 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#include <cctype>
#include <algorithm>
#include "OSystem.hxx"
#include "Widget.hxx"
#include "ScrollBarWidget.hxx"
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "AddrValueWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AddrValueWidget::AddrValueWidget(GuiObject* boss, int x, int y, int w, int h,
int range, BaseFormat base)
: EditableWidget(boss, x, y, w, h),
_range(range),
_base(base)
{
_w = w - kScrollBarWidth;
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kListWidget; // we're just a slightly modified listwidget
_editMode = false;
_entriesPerPage = (_h - 2) / kLineHeight;
_currentPos = 0;
_selectedItem = -1;
_scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kScrollBarWidth, _h);
_scrollBar->setTarget(this);
_currentKeyDown = 0;
_quickSelectTime = 0;
// The item is selected, thus _bgcolor is used to draw the caret and
// _textcolorhi to erase it
_caretInverse = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AddrValueWidget::~AddrValueWidget()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::setList(const AddrList& alist, const ValueList& vlist)
{
_addrList.clear();
_valueList.clear();
_addrStringList.clear();
_valueStringList.clear();
_addrList = alist;
_valueList = vlist;
int size = _addrList.size(); // assume vlist is the same size
// An efficiency thing
char temp[10];
string str;
for(unsigned int i = 0; i < (unsigned int)size; ++i)
{
sprintf(temp, "%.4x:", _addrList[i]);
_addrStringList.push_back(temp);
str = instance()->debugger().valueToString(_valueList[i], _base);
_valueStringList.push_back(str);
}
if (_currentPos >= size)
_currentPos = size - 1;
if (_currentPos < 0)
_currentPos = 0;
_selectedItem = -1;
_editMode = false;
scrollBarRecalc();
// The list should now be redrawn
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::scrollTo(int item)
{
int size = _valueList.size();
if (item >= size)
item = size - 1;
if (item < 0)
item = 0;
if (_currentPos != item)
{
_currentPos = item;
scrollBarRecalc();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::scrollBarRecalc()
{
_scrollBar->_numEntries = _valueList.size();
_scrollBar->_entriesPerPage = _entriesPerPage;
_scrollBar->_currentPos = _currentPos;
_scrollBar->recalc();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
if (!isEnabled())
return;
// First check whether the selection changed
int newSelectedItem;
newSelectedItem = findItem(x, y);
if (newSelectedItem > (int)_valueList.size() - 1)
newSelectedItem = -1;
if (_selectedItem != newSelectedItem)
{
if (_editMode)
abortEditMode();
_selectedItem = newSelectedItem;
sendCommand(kAVSelectionChangedCmd, _selectedItem, _id);
setDirty(); draw();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::handleMouseUp(int x, int y, int button, int clickCount)
{
// If this was a double click and the mouse is still over the selected item,
// send the double click command
if (clickCount == 2 && (_selectedItem == findItem(x, y)))
{
sendCommand(kAVItemDoubleClickedCmd, _selectedItem, _id);
// Start edit mode
if(_editable && !_editMode)
startEditMode();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::handleMouseWheel(int x, int y, int direction)
{
_scrollBar->handleMouseWheel(x, y, direction);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int AddrValueWidget::findItem(int x, int y) const
{
return (y - 1) / kLineHeight + _currentPos;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AddrValueWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
// Ignore all mod keys
if(instance()->eventHandler().kbdControl(modifiers) ||
instance()->eventHandler().kbdAlt(modifiers))
return true;
bool handled = true;
bool dirty = false;
int oldSelectedItem = _selectedItem;
if (_editMode)
{
// Class EditableWidget handles all text editing related key presses for us
handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers);
if(handled)
setDirty(); draw();
}
else
{
// not editmode
switch (keycode)
{
case '\n': // enter/return
case '\r':
if (_selectedItem >= 0)
{
// override continuous enter keydown
if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r'))
{
dirty = true;
startEditMode();
}
else
sendCommand(kAVItemActivatedCmd, _selectedItem, _id);
}
break;
case 256+17: // up arrow
if (_selectedItem > 0)
_selectedItem--;
break;
case 256+18: // down arrow
if (_selectedItem < (int)_valueList.size() - 1)
_selectedItem++;
break;
case 256+24: // pageup
_selectedItem -= _entriesPerPage - 1;
if (_selectedItem < 0)
_selectedItem = 0;
break;
case 256+25: // pagedown
_selectedItem += _entriesPerPage - 1;
if (_selectedItem >= (int)_valueList.size() )
_selectedItem = _valueList.size() - 1;
break;
case 256+22: // home
_selectedItem = 0;
break;
case 256+23: // end
_selectedItem = _valueList.size() - 1;
break;
default:
handled = false;
}
scrollToCurrent();
}
if (dirty || _selectedItem != oldSelectedItem)
{
sendCommand(kAVSelectionChangedCmd, _selectedItem, _id);
// also draw scrollbar
_scrollBar->draw();
setDirty(); draw();
}
_currentKeyDown = keycode;
return handled;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AddrValueWidget::handleKeyUp(int ascii, int keycode, int modifiers)
{
if (keycode == _currentKeyDown)
_currentKeyDown = 0;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::lostFocusWidget()
{
_editMode = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch (cmd)
{
case kSetPositionCmd:
if (_currentPos != (int)data)
{
_currentPos = data;
setDirty(); draw();
}
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::drawWidget(bool hilite)
{
cerr << "AddrValueWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
int i, pos, len = _valueList.size();
string buffer;
int deltax;
// Draw a thin frame around the list.
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor);
// Draw the list items
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++)
{
const OverlayColor textColor = (_selectedItem == pos && _editMode)
? kColor : kTextColor;
const int y = _y + 2 + kLineHeight * i;
// Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos)
{
if (_hasFocus && !_editMode)
fb.fillRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, kTextColorHi);
else
fb.frameRect(_x + 1, _y + 1 + kLineHeight * i, _w - 2, kLineHeight, kTextColorHi);
}
// Print the address
fb.drawString(_font, _addrStringList[pos], _x + 2, y, _w - 4, textColor);
GUI::Rect r(getEditRect());
if (_selectedItem == pos && _editMode)
{
buffer = _editString;
adjustOffset();
deltax = -_editScrollOffset;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
}
else
{
buffer = _valueStringList[pos];
deltax = 0;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
}
}
// Only draw the caret while editing, and if it's in the current viewport
if(_editMode && (_selectedItem >= _scrollBar->_currentPos) &&
(_selectedItem < _scrollBar->_currentPos + _entriesPerPage))
drawCaret();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Rect AddrValueWidget::getEditRect() const
{
GUI::Rect r(2, 1, _w - 3 , kLineHeight);
const int offset = (_selectedItem - _currentPos) * kLineHeight;
r.top += offset;
r.bottom += offset;
r.left += 9 * _font->getMaxCharWidth(); // address takes 9 characters
return r;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::scrollToCurrent()
{
// Only do something if the current item is not in our view port
if (_selectedItem < _currentPos)
{
// it's above our view
_currentPos = _selectedItem;
}
else if (_selectedItem >= _currentPos + _entriesPerPage )
{
// it's below our view
_currentPos = _selectedItem - _entriesPerPage + 1;
}
if (_currentPos < 0 || _entriesPerPage > (int)_valueList.size())
_currentPos = 0;
else if (_currentPos + _entriesPerPage > (int)_valueList.size())
_currentPos = _valueList.size() - _entriesPerPage;
_scrollBar->_currentPos = _currentPos;
_scrollBar->recalc();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::startEditMode()
{
if (_editable && !_editMode && _selectedItem >= 0)
{
_editMode = true;
setEditString(""); // Erase current entry when starting editing
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::endEditMode()
{
if (!_editMode)
return;
// send a message that editing finished with a return/enter key press
_editMode = false;
// Update the both the string representation and the real data
int value = instance()->debugger().stringToValue(_editString);
if(value < 0 || value > _range)
{
abortEditMode();
return;
}
// Correctly format the data for viewing
_editString = instance()->debugger().valueToString(value, _base);
_valueStringList[_selectedItem] = _editString;
_valueList[_selectedItem] = value;
sendCommand(kAVItemDataChangedCmd, _selectedItem, _id);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AddrValueWidget::abortEditMode()
{
// undo any changes made
assert(_selectedItem >= 0);
_editMode = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AddrValueWidget::tryInsertChar(char c, int pos)
{
// Not sure how efficient this is, or should we even care?
c = tolower(c);
if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
c == '%' || c == '#' || c == '$')
{
_editString.insert(pos, 1, c);
return true;
}
else
return false;
}

View File

@ -1,110 +0,0 @@
//============================================================================
//
// 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 and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: AddrValueWidget.hxx,v 1.7 2005-08-11 19:12:39 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#ifndef ADDR_VALUE_WIDGET_HXX
#define ADDR_VALUE_WIDGET_HXX
#include "GuiObject.hxx"
#include "Widget.hxx"
#include "Command.hxx"
#include "Debugger.hxx"
#include "StringList.hxx"
#include "EditableWidget.hxx"
#include "Array.hxx"
#include "Rect.hxx"
class ScrollBarWidget;
typedef GUI::Array<int> AddrList;
typedef GUI::Array<int> ValueList;
enum {
kAVItemDoubleClickedCmd = 'AVdb',
kAVItemActivatedCmd = 'AVac',
kAVItemDataChangedCmd = 'AVch',
kAVSelectionChangedCmd = 'AVsc'
};
/* AddrValueWidget */
class AddrValueWidget : public EditableWidget
{
public:
AddrValueWidget(GuiObject* boss, int x, int y, int w, int h,
int range, BaseFormat base = kBASE_DEFAULT);
virtual ~AddrValueWidget();
void setList(const StringList& list);
void setList(const AddrList& alist, const ValueList& vlist);
int getSelectedAddr() const { return _addrList[_selectedItem]; }
int getSelectedValue() const { return _valueList[_selectedItem]; }
void scrollTo(int item);
virtual void handleMouseDown(int x, int y, int button, int clickCount);
virtual void handleMouseUp(int x, int y, int button, int clickCount);
virtual void handleMouseWheel(int x, int y, int direction);
virtual bool handleKeyDown(int ascii, int keycode, int modifiers);
virtual bool handleKeyUp(int ascii, int keycode, int modifiers);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual bool wantsFocus() { return true; }
void startEditMode();
void endEditMode();
protected:
void drawWidget(bool hilite);
int findItem(int x, int y) const;
void scrollBarRecalc();
void abortEditMode();
GUI::Rect getEditRect() const;
void lostFocusWidget();
void scrollToCurrent();
bool tryInsertChar(char c, int pos);
protected:
AddrList _addrList;
ValueList _valueList;
StringList _addrStringList;
StringList _valueStringList;
int _range;
BaseFormat _base;
bool _editMode;
int _currentPos;
int _entriesPerPage;
int _selectedItem;
ScrollBarWidget* _scrollBar;
int _currentKeyDown;
string _backupString;
string _quickSelectStr;
int _quickSelectTime;
};
#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: AudioDialog.cxx,v 1.16 2005-09-11 22:55:51 stephena Exp $
// $Id: AudioDialog.cxx,v 1.17 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -151,7 +151,7 @@ void AudioDialog::saveConfig()
b = mySoundTypeCheckbox->getState();
if((instance()->settings().getInt("channels") == 2) != b)
{
instance()->sound().setChannels(b ? 2 : 1);
instance()->console().setChannels(b ? 2 : 1);
restart = true;
}

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: BrowserDialog.cxx,v 1.11 2005-09-15 19:43:36 stephena Exp $
// $Id: BrowserDialog.cxx,v 1.12 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -101,7 +101,7 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd,
// If nothing is selected in the list widget, choose the current dir.
// Else, choose the dir that is selected.
int selection = _fileList->getSelected();
if (selection >= 0)
if (selection >= 0 && selection < (int)_nodeContent.size())
_choice = _nodeContent[selection];
else
_choice = _node;

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: EditableWidget.cxx,v 1.10 2005-08-11 19:12:39 stephena Exp $
// $Id: EditableWidget.cxx,v 1.11 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -83,7 +83,7 @@ bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers)
bool handled = true;
bool dirty = false;
switch (keycode)
switch (ascii)
{
case '\n': // enter/return
case '\r':

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: ListWidget.cxx,v 1.32 2005-09-20 19:09:10 stephena Exp $
// $Id: ListWidget.cxx,v 1.33 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -265,7 +265,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
else
{
// not editmode
switch (keycode)
switch (ascii)
{
case ' ': // space
// Snap list back to currently highlighted line

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: PopUpWidget.cxx,v 1.18 2005-09-15 19:43:36 stephena Exp $
// $Id: PopUpWidget.cxx,v 1.19 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -157,7 +157,7 @@ void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
if(isMouseDown())
return;
switch(keycode)
switch (ascii)
{
case '\n': // enter/return
case '\r':

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: Widget.cxx,v 1.35 2005-09-16 18:15:44 stephena Exp $
// $Id: Widget.cxx,v 1.36 2005-09-23 23:35:02 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -427,7 +427,7 @@ bool CheckboxWidget::handleKeyDown(int ascii, int keycode, int modifiers)
bool handled = false;
// (De)activate with space or return
switch(keycode)
switch(ascii)
{
case '\n': // enter/return
case '\r':