summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2007-03-25 19:06:31 +0000
committerIan C <ianc@noddybox.co.uk>2007-03-25 19:06:31 +0000
commit8746d4da5b8612560df2502ee8f6ebdcafa54262 (patch)
treec65ac8dff128b99476db10b3ecee77b96d9ae1c8 /source
parentdbc50517b6ec5ee9d166d560657a7a346bc65642 (diff)
Changed the monitor so it doesn't keep a history of PCs for the display, and added a seperate controllable disassembly display instead,
Diffstat (limited to 'source')
-rw-r--r--source/monitor.c91
1 files changed, 51 insertions, 40 deletions
diff --git a/source/monitor.c b/source/monitor.c
index 6f0fa05..773f7c2 100644
--- a/source/monitor.c
+++ b/source/monitor.c
@@ -41,9 +41,18 @@ typedef enum
DISPLAY_IY,
DISPLAY_BC,
DISPLAY_DE,
+ DISPLAY_PC,
DISPLAY_TYPE_COUNT
} MemDisplayType;
+typedef enum
+{
+ MODE_CPU_STATE,
+ MODE_HEX,
+ MODE_ASSEM,
+ MODE_TYPE_COUNT
+} DisplayModeType;
+
/* ---------------------------------------- STATIC INTERFACES
*/
@@ -107,41 +116,24 @@ static void DisplayRunningState(int running)
}
-static void DisplayCPU(Z80 *cpu, int stepped)
+static void DisplayCPU(Z80 *cpu)
{
static const char *flag_char = "SZ5H3PNC";
- static Z80Word prev_pc[8];
Z80Word tmp;
int f;
char flags[]="--------";
+ tmp = cpu->PC;
+
/* Display disassembly
*/
- for(f=0;f<8;f++)
+ for(f=0;f<17;f++)
{
- tmp = prev_pc[f];
-
/* These may seem a bit convuluted, but there's no point being at home
to Mr Undefined Behaviour
*/
- TM_printf(1,f,"%4.4x:",tmp);
+ TM_printf(0,f,"%c%4.4x:",f==0 ? '>':' ',tmp);
TM_Put(7,f,Z80Disassemble(cpu,&tmp));
-
- if (stepped && f)
- {
- prev_pc[f-1] = prev_pc[f];
- }
- }
-
- prev_pc[7] = tmp = cpu->PC;
-
- TM_printf(0,8,">%4.4x:",tmp);
- TM_Put(7,8,Z80Disassemble(cpu,&tmp));
-
- for(f=0;f<8;f++)
- {
- TM_printf(1,9+f,"%4.4x:",tmp);
- TM_Put(7,9+f,Z80Disassemble(cpu,&tmp));
}
/* Display process state
@@ -170,7 +162,7 @@ static void DisplayCPU(Z80 *cpu, int stepped)
}
-static void DisplayMem(Z80 *cpu, MemDisplayType disp, Z80Word addr)
+static void DisplayMem(Z80 *cpu, MemDisplayType disp, Z80Word addr, int as_hex)
{
static const char *label[]=
{
@@ -180,7 +172,8 @@ static void DisplayMem(Z80 *cpu, MemDisplayType disp, Z80Word addr)
"SP",
"IY",
"BC",
- "DE"
+ "DE",
+ "PC"
};
int x,y;
@@ -211,19 +204,34 @@ static void DisplayMem(Z80 *cpu, MemDisplayType disp, Z80Word addr)
addr = cpu->DE.w;
break;
+ case DISPLAY_PC:
+ addr = cpu->PC;
+ break;
+
default:
break;
}
TM_printf(0,0,"%s: %4.4x",label[disp],addr);
- for(y=0;y<18;y++)
+ if (as_hex)
{
- TM_printf(0,y+2,"%4.4x:",addr);
+ for(y=0;y<20;y++)
+ {
+ TM_printf(0,y+2,"%4.4x:",addr);
- for(x=0;x<8;x++)
+ for(x=0;x<8;x++)
+ {
+ TM_printf(6+x*3,y+2,"%2.2x",ZX81ReadDisassem(cpu,addr++));
+ }
+ }
+ }
+ else
+ {
+ for(y=0;y<20;y++)
{
- TM_printf(6+x*3,y+2,"%2.2x",ZX81ReadDisassem(cpu,addr++));
+ TM_printf(0,y+2,"%4.4x:",addr);
+ TM_Put(7,y+2,Z80Disassemble(cpu,&addr));
}
}
}
@@ -237,8 +245,7 @@ void MachineCodeMonitor(Z80 *cpu)
static MemDisplayType mem_display = DISPLAY_ADDR;
int done = FALSE;
int running = FALSE;
- int cpu_display = TRUE;
- int stepped = FALSE;
+ DisplayModeType display_mode = MODE_CPU_STATE;
int key;
SoftKey soft_key;
@@ -255,16 +262,21 @@ void MachineCodeMonitor(Z80 *cpu)
TM_Cls();
DisplayRunningState(running);
- if (cpu_display)
+ switch(display_mode)
{
- DisplayCPU(cpu,stepped);
+ case MODE_CPU_STATE:
+ DisplayCPU(cpu);
+ break;
+ case MODE_HEX:
+ DisplayMem(cpu,mem_display,display_address,TRUE);
+ break;
+ case MODE_ASSEM:
+ DisplayMem(cpu,mem_display,display_address,FALSE);
+ break;
+ default:
+ TM_Put(0,0,"Oops!");
+ break;
}
- else
- {
- DisplayMem(cpu,mem_display,display_address);
- }
-
- stepped = FALSE;
do
{
@@ -298,7 +310,7 @@ void MachineCodeMonitor(Z80 *cpu)
if (key & KEY_SELECT)
{
- cpu_display = !cpu_display;
+ display_mode = (display_mode+1) % MODE_TYPE_COUNT;
}
if (key & KEY_L)
@@ -333,7 +345,6 @@ void MachineCodeMonitor(Z80 *cpu)
if (running || (key & KEY_A))
{
Z80SingleStep(cpu);
- stepped = TRUE;
}
}