summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2004-01-20 01:10:45 +0000
committerIan C <ianc@noddybox.co.uk>2004-01-20 01:10:45 +0000
commit0a6f1fcdf13e5d4518b8605dd7a55f49db6b1a70 (patch)
tree08912b4f18c914d7a5e9d97c8f463676e07f19fa
parent7392aae19593563dd6557af76df0d6b965d6e4c5 (diff)
Added monitor; Various fixes
-rw-r--r--src/Makefile4
-rw-r--r--src/main.c4
-rw-r--r--src/memmenu.c168
-rw-r--r--src/spec.c45
-rw-r--r--src/spec.h2
5 files changed, 200 insertions, 23 deletions
diff --git a/src/Makefile b/src/Makefile
index ffb9c8f..5ec781c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -18,7 +18,7 @@
#
# -------------------------------------------------------------------------
#
-# $Id: Makefile,v 1.7 2004-01-15 18:53:51 ianc Exp $
+# $Id: Makefile,v 1.8 2004-01-20 01:10:45 ianc Exp $
#
@@ -94,7 +94,7 @@ main.o: /usr/local/include/SDL/SDL_keysym.h
main.o: /usr/local/include/SDL/SDL_mouse.h /usr/local/include/SDL/SDL_video.h
main.o: /usr/local/include/SDL/SDL_mutex.h /usr/local/include/SDL/SDL_quit.h
main.o: /usr/local/include/SDL/SDL_version.h z80/z80.h spec.h gfx.h gui.h
-main.o: memmenu.h config.h exit.h
+main.o: memmenu.h config.h exit.h util.h
spec.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h
spec.o: /usr/include/sys/_types.h /usr/include/machine/_types.h
spec.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h
diff --git a/src/main.c b/src/main.c
index 587e657..b89d8c7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -115,10 +115,9 @@ int main(int argc, char *argv[])
Z80SingleStep(z80);
Z80GetState(z80,&s2);
- /* TODO: Remove debug */
if (s2.PC==0)
{
- printf("PC zero - prev %4.4x\n",s1.PC);
+ Debug("PC zero - prev %4.4x\n",s1.PC);
}
if (trace)
@@ -216,7 +215,6 @@ int main(int argc, char *argv[])
case SDLK_F11:
if (e->key.state==SDL_PRESSED)
quit=MemoryMenu(z80);
- Debug("quit=%d\n");
break;
case SDLK_F12:
diff --git a/src/memmenu.c b/src/memmenu.c
index 0d5053f..ccb065c 100644
--- a/src/memmenu.c
+++ b/src/memmenu.c
@@ -137,6 +137,12 @@ static void Centre(const char *p, int y, Uint32 col)
}
+static void CentrePaper(const char *p, int y, Uint32 pen, Uint32 paper)
+{
+ GFXPrintPaper((GFX_WIDTH-strlen(p)*8)/2,y,pen,paper,"%s",p);
+}
+
+
static void DisplayMenu(void)
{
static const char *menu[]=
@@ -149,6 +155,7 @@ static void DisplayMenu(void)
"6 - Set active breakpoints",
"7 - Remove a breakpoint ",
"8 - Clear all breakpoints ",
+ "9 - Monitor ",
"R - Reset ",
"X - Exit (without confirm)",
"ESC - Return ",
@@ -735,17 +742,12 @@ static void DoAddBreakpoint(Z80 *z80)
}
else
{
- int f;
-
- for(f=0;f<50;f++)
- {
bpoint.no++;
bpoint.expr=Realloc(bpoint.expr,bpoint.no * sizeof(*bpoint.expr));
bpoint.active=Realloc(bpoint.active,bpoint.no * sizeof(*bpoint.active));
bpoint.expr[bpoint.no-1]=StrCopy(expr);
bpoint.active[bpoint.no-1]=TRUE;
- }
SetCallback(z80);
}
@@ -834,6 +836,158 @@ static void DoClearBreakpoint(Z80 *z80)
}
+static void DoMonitor(Z80 *z80)
+{
+ static int overlay=FALSE;
+ int quit=FALSE;
+ int running=FALSE;
+ int step=FALSE;
+
+ SPECEnableScreen(FALSE);
+
+ while(!quit)
+ {
+ MemTrace mt[TRACEMEM_WIN];
+ const char *brk;
+ SDL_Event *e;
+ Z80State s;
+ int f;
+
+ step=FALSE;
+
+ if (overlay)
+ SPECShowScreen();
+ else
+ GFXClear(BLACK);
+
+ CentrePaper("MONITOR",0,WHITE,BLACK);
+ CentrePaper("Press F1 for help",9,RED,BLACK);
+
+ Z80GetState(z80,&s);
+
+ DisplayZ80State(&s,136,WHITE);
+
+ GetMemTrace(z80,mt,s.SP-(TRACEMEM_WIN/2+1),TRACEMEM_WIN);
+ DisplayTraceMem(0,192,"MEM (SP)",mt,s.SP);
+ GetMemTrace(z80,mt,s.HL-(TRACEMEM_WIN/2+1),TRACEMEM_WIN);
+ DisplayTraceMem(100,192,"MEM (HL)",mt,s.HL);
+ GetMemTrace(z80,mt,s.DE-(TRACEMEM_WIN/2+1),TRACEMEM_WIN);
+ DisplayTraceMem(200,192,"MEM (DE)",mt,s.DE);
+
+ for(f=0;f<10;f++)
+ {
+ char str[80];
+ char *p;
+ int paper;
+ int y;
+
+ y=24+f*8;
+
+ if (f==0)
+ paper=RED;
+ else
+ paper=BLACK;
+
+ GFXPrintPaper(0,y,GREEN,paper,"%4.4x ",s.PC);
+
+ strcpy(str,Z80Disassemble(z80,&s.PC));
+ p=strtok(str,";");
+ GFXPrintPaper(40,y,WHITE,paper,"%s",str);
+ }
+
+ GFXEndFrame(FALSE);
+
+ if (running)
+ {
+ e=GFXGetKey();
+
+ if (e && e->key.state!=SDL_PRESSED)
+ e=NULL;
+ }
+ else
+ e=GFXWaitKey();
+
+ if (e)
+ {
+ switch(e->key.keysym.sym)
+ {
+ case SDLK_F1:
+ GUIMessage
+ (eMessageBox,"PLAYBACK HELP","%s",
+ "ESC - Exit \n"
+ "ENTER - Single step processor \n"
+ "R - Run till break or stop \n"
+ "SPACE - Stop running \n"
+ "O - Toggle overlay mode \n"
+ "5 - Add a new breakpoint \n"
+ "6 - Set active breakpoints \n"
+ "7 - Remove a breakpoint \n"
+ "8 - Clear all breakpoints \n"
+ "S - Display current screen ");
+ break;
+
+ case SDLK_RETURN:
+ case SDLK_KP_ENTER:
+ step=TRUE;
+ break;
+
+ case SDLK_ESCAPE:
+ quit=TRUE;
+ break;
+
+ case SDLK_r:
+ running=TRUE;
+ break;
+
+ case SDLK_SPACE:
+ running=FALSE;
+ break;
+
+ case SDLK_o:
+ overlay=!overlay;
+ break;
+
+ case SDLK_5:
+ DoAddBreakpoint(z80);
+ break;
+
+ case SDLK_6:
+ DoActiveBreakpoint(z80);
+ break;
+
+ case SDLK_7:
+ DoRemoveBreakpoint(z80);
+ break;
+
+ case SDLK_8:
+ DoClearBreakpoint(z80);
+ break;
+
+ case SDLK_s:
+ SPECShowScreen();
+ GFXEndFrame(FALSE);
+ GFXWaitKey();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (running || step)
+ Z80SingleStep(z80);
+
+ if (running && (brk=Break()))
+ {
+ GUIMessage(eMessageBox,"BREAKPOINT","%s",brk);
+ running=FALSE;
+ }
+ }
+
+ SPECEnableScreen(TRUE);
+}
+
+
/* ---------------------------------------- EXPORTED INTERFACES
*/
int MemoryMenu(Z80 *z80)
@@ -893,6 +1047,10 @@ int MemoryMenu(Z80 *z80)
DoClearBreakpoint(z80);
break;
+ case SDLK_9:
+ DoMonitor(z80);
+ break;
+
case SDLK_r:
if (GUIMessage(eYesNoBox,"RESET","Sure?"))
{
diff --git a/src/spec.c b/src/spec.c
index b0dc155..b094126 100644
--- a/src/spec.c
+++ b/src/spec.c
@@ -84,6 +84,7 @@ static Z80Byte mem[0x10000];
*/
static Z80Val SCAN_CYCLES=224;
static int scanline=0;
+static int enable_screen=TRUE;
/* GFX vars
@@ -244,7 +245,7 @@ static void DumpZ80(Z80 *z80)
/* ---------------------------------------- PRIVATE FUNCTIONS
*/
-void DrawScanline(int y)
+void DrawScanlineAt(int y, int sline)
{
int aline;
int f,r;
@@ -253,7 +254,7 @@ void DrawScanline(int y)
Z80Byte b;
Z80Byte att;
- aline=scanline-TOPL;
+ aline=sline-TOPL;
GFXHLine(0,GFX_WIDTH-1,y,coltable[border].col);
@@ -284,7 +285,7 @@ void DrawScanline(int y)
}
for(r=0,b=*scr++;r<8;r++)
- if (b&(1<<(8-r)))
+ if (b&(1<<(7-r)))
GFXFastPlot(f*8+r+OFF_X,y,coltable[ink].col);
else
GFXFastPlot(f*8+r+OFF_X,y,coltable[paper].col);
@@ -294,6 +295,7 @@ void DrawScanline(int y)
}
}
+#define DrawScanline(y) DrawScanlineAt(y,scanline)
static void RomPatch(void)
{
@@ -403,15 +405,18 @@ static int CheckTimers(Z80 *z80, Z80Val val)
Z80Interrupt(z80,0xff);
- GFXEndFrame(TRUE);
- GFXStartFrame();
+ if (enable_screen)
+ {
+ GFXEndFrame(TRUE);
+ GFXStartFrame();
+ }
}
/* Draw scanline
*/
y=scanline-TOPL+OFF_Y;
- if (y>=0 && y<GFX_HEIGHT)
+ if (y>=0 && y<GFX_HEIGHT && enable_screen)
DrawScanline(y);
/* TODO: Process sound emulation */
@@ -546,13 +551,6 @@ Z80Word SPECReadWord(Z80 *z80, Z80Word addr)
void SPECWriteWord(Z80 *z80, Z80Word addr, Z80Word val)
{
- if (addr==0xff4e && val==0)
- {
- Z80State s;
- Z80GetState(z80,&s);
- Debug("Wrote %4.4x to %4.4x @%4.4x\n",val,addr,s.PC);
- }
-
if (addr>=ROMLEN)
mem[addr]=val&0xff;
@@ -830,6 +828,27 @@ const char *SPECInfo(Z80 *z80)
}
+void SPECEnableScreen(int enable)
+{
+ enable_screen=enable;
+}
+
+
+void SPECShowScreen(void)
+{
+ int f;
+ int y;
+
+ for(f=0;f<TOTL;f++)
+ {
+ y=f-TOPL+OFF_Y;
+
+ if (y>=0 && y<GFX_HEIGHT)
+ DrawScanlineAt(y,f);
+ }
+}
+
+
void SPECReset(Z80 *z80)
{
}
diff --git a/src/spec.h b/src/spec.h
index 69a19d1..a508bdb 100644
--- a/src/spec.h
+++ b/src/spec.h
@@ -56,6 +56,8 @@ const Z80Label *SPECGetLabel(void);
/* Interfaces for memory menu
*/
const char *SPECInfo(Z80 *z80);
+void SPECEnableScreen(int enable);
+void SPECShowScreen(void);
/* Called when the machine is reset
*/