mirror of https://github.com/stella-emu/stella.git
DebuggerParser now uses TIA color 0x34 for error messages (which is a
light red color). Inverse video in the PromptWidget is supported, without having to rewrite any FrameBuffer code. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@589 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
bd03f7d80f
commit
31708d4a7f
|
@ -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.43 2005-07-01 04:22:27 urchlay Exp $
|
||||
// $Id: DebuggerParser.cxx,v 1.44 2005-07-02 14:58:45 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -88,6 +88,14 @@ Command DebuggerParser::commands[] = {
|
|||
&DebuggerParser::executeClearwatches
|
||||
},
|
||||
|
||||
{
|
||||
"colortest",
|
||||
"Color Test",
|
||||
true,
|
||||
{ kARG_BYTE, kARG_END_ARGS },
|
||||
&DebuggerParser::executeColortest
|
||||
},
|
||||
|
||||
{
|
||||
"d",
|
||||
"Decimal Flag: set (to 0 or 1), or toggle (no arg)",
|
||||
|
@ -775,7 +783,7 @@ bool DebuggerParser::validateArgs(int cmd) {
|
|||
|
||||
if(argCount == 0) {
|
||||
if(required) {
|
||||
commandResult = "missing required argument(s)";
|
||||
commandResult = red("missing required argument(s)");
|
||||
return false; // needed args. didn't get 'em.
|
||||
} else {
|
||||
return true; // no args needed, no args got
|
||||
|
@ -795,21 +803,21 @@ bool DebuggerParser::validateArgs(int cmd) {
|
|||
switch(*p) {
|
||||
case kARG_WORD:
|
||||
if(curArgInt < 0 || curArgInt > 0xffff) {
|
||||
commandResult = "invalid word argument (must be 0-$ffff)";
|
||||
commandResult = red("invalid word argument (must be 0-$ffff)");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case kARG_BYTE:
|
||||
if(curArgInt < 0 || curArgInt > 0xff) {
|
||||
commandResult = "invalid byte argument (must be 0-$ff)";
|
||||
commandResult = red("invalid byte argument (must be 0-$ff)");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case kARG_BOOL:
|
||||
if(curArgInt != 0 && curArgInt != 1) {
|
||||
commandResult = "invalid boolean argument (must be 0 or 1)";
|
||||
commandResult = red("invalid boolean argument (must be 0 or 1)");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -818,7 +826,7 @@ bool DebuggerParser::validateArgs(int cmd) {
|
|||
if(curArgInt != 2 && curArgInt != 10 && curArgInt != 16
|
||||
&& curArgStr != "hex" && curArgStr != "dec" && curArgStr != "bin")
|
||||
{
|
||||
commandResult = "invalid base (must be #2, #10, #16, \"bin\", \"dec\", or \"hex\")";
|
||||
commandResult = red("invalid base (must be #2, #10, #16, \"bin\", \"dec\", or \"hex\")");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -832,7 +840,7 @@ bool DebuggerParser::validateArgs(int cmd) {
|
|||
break; // FIXME: implement!
|
||||
|
||||
default:
|
||||
commandResult = "too many arguments";
|
||||
commandResult = red("too many arguments");
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -842,7 +850,7 @@ bool DebuggerParser::validateArgs(int cmd) {
|
|||
} while(*p++ != kARG_END_ARGS);
|
||||
|
||||
if(curCount < argCount) {
|
||||
commandResult = "too many arguments";
|
||||
commandResult = red("too many arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -934,7 +942,7 @@ void DebuggerParser::executeBank() {
|
|||
commandResult += debugger->getCartType();
|
||||
commandResult += ": ";
|
||||
if(banks < 2)
|
||||
commandResult += "bankswitching not supported by this cartridge";
|
||||
commandResult += red("bankswitching not supported by this cartridge");
|
||||
else {
|
||||
commandResult += debugger->valueToString(debugger->getBank());
|
||||
commandResult += "/";
|
||||
|
@ -942,13 +950,13 @@ void DebuggerParser::executeBank() {
|
|||
}
|
||||
} else {
|
||||
if(args[0] >= banks) {
|
||||
commandResult += "invalid bank number (must be 0 to ";
|
||||
commandResult += red("invalid bank number (must be 0 to ");
|
||||
commandResult += debugger->valueToString(banks - 1);
|
||||
commandResult += ")";
|
||||
} else if(debugger->setBank(args[0])) {
|
||||
commandResult += "switched bank OK";
|
||||
} else {
|
||||
commandResult += "unknown error switching banks";
|
||||
commandResult += red("unknown error switching banks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -977,7 +985,7 @@ void DebuggerParser::executeBase() {
|
|||
break;
|
||||
|
||||
default:
|
||||
commandResult += "UNKNOWN";
|
||||
commandResult += red("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1027,6 +1035,13 @@ void DebuggerParser::executeClearwatches() {
|
|||
commandResult = "all watches cleared";
|
||||
}
|
||||
|
||||
// "colortest"
|
||||
void DebuggerParser::executeColortest() {
|
||||
commandResult = "test color: ";
|
||||
//commandResult += char(args[0] | 0x80);
|
||||
commandResult += inverse("LA LA LA");
|
||||
}
|
||||
|
||||
// "d"
|
||||
void DebuggerParser::executeD() {
|
||||
if(argCount == 0)
|
||||
|
@ -1094,7 +1109,7 @@ void DebuggerParser::executeListtraps() {
|
|||
// "listwatches"
|
||||
void DebuggerParser::executeListwatches() {
|
||||
// commandResult = listWatches();
|
||||
commandResult = "command not yet implemented (sorry)";
|
||||
commandResult = red("command not yet implemented (sorry)");
|
||||
}
|
||||
|
||||
// "loadstate"
|
||||
|
@ -1103,7 +1118,7 @@ void DebuggerParser::executeLoadstate() {
|
|||
debugger->loadState(args[0]);
|
||||
commandResult = "state loaded";
|
||||
} else {
|
||||
commandResult = "invalid slot (must be 0-9)";
|
||||
commandResult = red("invalid slot (must be 0-9)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1171,7 @@ void DebuggerParser::executeRom() {
|
|||
int addr = args[0];
|
||||
for(int i=1; i<argCount; i++) {
|
||||
if( !(debugger->patchROM(addr++, args[i])) ) {
|
||||
commandResult = "patching ROM unsupported for this cart type";
|
||||
commandResult = red("patching ROM unsupported for this cart type");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1182,7 +1197,7 @@ void DebuggerParser::executeSaveses() {
|
|||
if(debugger->prompt()->saveBuffer(argStrings[0]))
|
||||
commandResult = "saved session to file " + argStrings[0];
|
||||
else
|
||||
commandResult = "I/O error";
|
||||
commandResult = red("I/O error");
|
||||
}
|
||||
|
||||
// "savestate"
|
||||
|
@ -1191,7 +1206,7 @@ void DebuggerParser::executeSavestate() {
|
|||
debugger->saveState(args[0]);
|
||||
commandResult = "state saved";
|
||||
} else {
|
||||
commandResult = "invalid slot (must be 0-9)";
|
||||
commandResult = red("invalid slot (must be 0-9)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1215,7 @@ void DebuggerParser::executeSavesym() {
|
|||
if(debugger->equateList->saveFile(argStrings[0]))
|
||||
commandResult = "saved symbols to file " + argStrings[0];
|
||||
else
|
||||
commandResult = "I/O error";
|
||||
commandResult = red("I/O error");
|
||||
}
|
||||
|
||||
// "step"
|
||||
|
@ -1248,7 +1263,7 @@ void DebuggerParser::executeUndef() {
|
|||
if(debugger->equateList->undefine(argStrings[0]))
|
||||
commandResult = argStrings[0] + " now undefined";
|
||||
else
|
||||
commandResult = "no such label";
|
||||
commandResult = red("no such label");
|
||||
}
|
||||
|
||||
// "v"
|
||||
|
|
|
@ -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.hxx,v 1.23 2005-06-29 00:31:48 urchlay Exp $
|
||||
// $Id: DebuggerParser.hxx,v 1.24 2005-07-02 14:58:45 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_PARSER_HXX
|
||||
|
@ -55,6 +55,15 @@ class DebuggerParser
|
|||
const char *getCompletions();
|
||||
const char *getCompletionPrefix();
|
||||
|
||||
static inline string red(string msg) {
|
||||
// This is TIA color 0x34. The octal value is 0x80+(0x34>>1).
|
||||
return "\232" + msg;
|
||||
}
|
||||
|
||||
static inline string inverse(string msg) {
|
||||
// ASCII DEL char, decimal 127
|
||||
return "\177" + msg;
|
||||
}
|
||||
|
||||
private:
|
||||
bool getArgs(const string& command);
|
||||
|
@ -94,6 +103,7 @@ class DebuggerParser
|
|||
void executeClearbreaks();
|
||||
void executeCleartraps();
|
||||
void executeClearwatches();
|
||||
void executeColortest();
|
||||
void executeD();
|
||||
void executeDefine();
|
||||
void executeDelwatch();
|
||||
|
|
|
@ -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.20 2005-06-27 03:32:51 urchlay Exp $
|
||||
// $Id: PromptWidget.cxx,v 1.21 2005-07-02 14:58:45 urchlay Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -58,7 +58,7 @@ PromptWidget::PromptWidget(GuiObject* boss, int x, int y, int w, int h)
|
|||
_lineWidth = (_w - kScrollBarWidth - 2) / _kConsoleCharWidth;
|
||||
_linesPerPage = (_h - 2) / _kConsoleLineHeight;
|
||||
|
||||
memset(_buffer, ' ', kBufferSize);
|
||||
memset(_buffer, 0, kBufferSize * sizeof(int));
|
||||
_linesInBuffer = kBufferSize / _lineWidth;
|
||||
|
||||
_currentPos = 0;
|
||||
|
@ -70,6 +70,13 @@ PromptWidget::PromptWidget(GuiObject* boss, int x, int y, int w, int h)
|
|||
|
||||
_scrollBar->setTarget(this);
|
||||
|
||||
// Init colors
|
||||
defaultTextColor = kTextColor;
|
||||
defaultBGColor = kBGColor;
|
||||
textColor = defaultTextColor;
|
||||
bgColor = defaultBGColor;
|
||||
_inverse = false;
|
||||
|
||||
// Init History
|
||||
_historyIndex = 0;
|
||||
_historyLine = 0;
|
||||
|
@ -96,6 +103,8 @@ PromptWidget::~PromptWidget()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PromptWidget::drawWidget(bool hilite)
|
||||
{
|
||||
OverlayColor fgcolor, bgcolor;
|
||||
|
||||
FrameBuffer& fb = _boss->instance()->frameBuffer();
|
||||
|
||||
// Fill the background
|
||||
|
@ -113,9 +122,17 @@ void PromptWidget::drawWidget(bool hilite)
|
|||
int l = (start + line) % _linesInBuffer;
|
||||
char c = buffer(l * _lineWidth + column);
|
||||
#else
|
||||
char c = buffer((start + line) * _lineWidth + column);
|
||||
int c = buffer((start + line) * _lineWidth + column);
|
||||
#endif
|
||||
fb.drawChar(&instance()->consoleFont(), c, x, y, kTextColor);
|
||||
if(c & (1 << 17)) { // inverse video flag
|
||||
fgcolor = bgColor;
|
||||
bgcolor = (OverlayColor)((c & 0x1ffff) >> 8);
|
||||
fb.fillRect(x, y, _kConsoleCharWidth, _kConsoleLineHeight, bgcolor);
|
||||
} else {
|
||||
fgcolor = (OverlayColor)(c >> 8);
|
||||
bgcolor = bgColor;
|
||||
}
|
||||
fb.drawChar(&instance()->consoleFont(), c & 0x7f, x, y, fgcolor);
|
||||
x += _kConsoleCharWidth;
|
||||
}
|
||||
y += _kConsoleLineHeight;
|
||||
|
@ -174,7 +191,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
|
||||
// Copy the user input to str
|
||||
for (i = 0; i < len; i++)
|
||||
str[i] = buffer(_promptStartPos + i);
|
||||
str[i] = buffer(_promptStartPos + i) & 0x7f;
|
||||
str[len] = '\0';
|
||||
|
||||
// Add the input to the history
|
||||
|
@ -210,7 +227,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
|
||||
char *str = new char[len + 1];
|
||||
for (i = 0; i < len; i++) {
|
||||
str[i] = buffer(_promptStartPos + i);
|
||||
str[i] = buffer(_promptStartPos + i) & 0x7f;
|
||||
if(strchr("*@<> ", str[i]) != NULL ) {
|
||||
lastDelimPos = i;
|
||||
delimiter = str[i];
|
||||
|
@ -646,6 +663,11 @@ void PromptWidget::historyScroll(int direction)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PromptWidget::nextLine()
|
||||
{
|
||||
// reset colors every line, so I don't have to remember to do it myself
|
||||
textColor = defaultTextColor;
|
||||
bgColor = defaultBGColor;
|
||||
_inverse = false;
|
||||
|
||||
int line = _currentPos / _lineWidth;
|
||||
if (line == _scrollLine)
|
||||
_scrollLine++;
|
||||
|
@ -720,9 +742,21 @@ void PromptWidget::putcharIntern(int c)
|
|||
{
|
||||
if (c == '\n')
|
||||
nextLine();
|
||||
else if(c & 0x80) { // set foreground color to TIA color
|
||||
// don't print or advance cursor
|
||||
// there are only 128 TIA colors, but
|
||||
// OverlayColor contains 256 of them
|
||||
textColor = (OverlayColor) ((c & 0x7f) << 1);
|
||||
}
|
||||
else if(c < ' ') { // More colors (the regular GUI ones)
|
||||
textColor = (OverlayColor) (c);
|
||||
}
|
||||
else if(c == 0x7f) { // toggle inverse video (DEL char)
|
||||
_inverse = !_inverse;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer(_currentPos) = (char)c;
|
||||
buffer(_currentPos) = c | (textColor << 8) | (_inverse << 17);
|
||||
_currentPos++;
|
||||
if ((_scrollLine + 1) * _lineWidth == _currentPos)
|
||||
{
|
||||
|
|
|
@ -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.hxx,v 1.4 2005-06-23 01:10:26 urchlay Exp $
|
||||
// $Id: PromptWidget.hxx,v 1.5 2005-07-02 14:58:45 urchlay Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -55,7 +55,7 @@ class PromptWidget : public Widget, public CommandSender
|
|||
bool saveBuffer(string& filename);
|
||||
|
||||
protected:
|
||||
inline char &buffer(int idx) { return _buffer[idx % kBufferSize]; }
|
||||
inline int &buffer(int idx) { return _buffer[idx % kBufferSize]; }
|
||||
|
||||
void drawWidget(bool hilite);
|
||||
void drawCaret();
|
||||
|
@ -81,7 +81,7 @@ class PromptWidget : public Widget, public CommandSender
|
|||
void handleCommand(CommandSender* sender, int cmd, int data);
|
||||
|
||||
protected:
|
||||
char _buffer[kBufferSize];
|
||||
int _buffer[kBufferSize];
|
||||
int _linesInBuffer;
|
||||
|
||||
int _lineWidth;
|
||||
|
@ -102,6 +102,12 @@ class PromptWidget : public Widget, public CommandSender
|
|||
int _historyLine;
|
||||
|
||||
int _kConsoleCharWidth, _kConsoleLineHeight;
|
||||
|
||||
OverlayColor defaultTextColor;
|
||||
OverlayColor defaultBGColor;
|
||||
OverlayColor textColor;
|
||||
OverlayColor bgColor;
|
||||
bool _inverse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue