1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-10 14:29:30 +00:00

Add hidump, hires_dump commands

This commit is contained in:
Peter Evans 2018-03-25 19:39:00 -05:00
parent 64afcb2040
commit 64306fa5a6
4 changed files with 66 additions and 7 deletions

View File

@ -5,5 +5,6 @@
#include "vm_bits.h"
extern void apple2_hires_draw(apple2 *, int);
extern void apple2_hires_dump(apple2 *, FILE *);
#endif

View File

@ -82,6 +82,7 @@ extern DEBUG_CMD(dblock);
extern DEBUG_CMD(disasm);
extern DEBUG_CMD(hdump);
extern DEBUG_CMD(help);
extern DEBUG_CMD(hidump);
extern DEBUG_CMD(jump);
extern DEBUG_CMD(printaddr);
extern DEBUG_CMD(printstate);

View File

@ -705,3 +705,47 @@ apple2_hires_draw(apple2 *mach, int row)
prev = curr;
}
}
void
apple2_hires_dump(apple2 *mach, FILE *stream)
{
int row, col, base, bit;
char dotsym;
vm_8bit byte;
fprintf(stream, "HIRES DUMP\n\nBytes:\n");
for (row = 0; row < 192; row++) {
base = addresses[row];
fprintf(stream, "%3d [", row);
for (col = 0; col < 40; col++) {
fprintf(stream, "%02X", mos6502_get(mach->cpu, base + col));
if (col < 39) {
fprintf(stream, " ");
}
}
fprintf(stream, "]\n");
}
fprintf(stream, "\nDots:\n");
for (row = 0; row < 192; row++) {
base = addresses[row];
fprintf(stream, "%3d [", row);
for (col = 0; col < 40; col++) {
byte = mos6502_get(mach->cpu, base + col);
dotsym = (byte & 0x80) ? '#' : '%';
for (bit = 0; bit < 7; bit++) {
fprintf(stream, "%c", ((byte >> bit) & 1) ? dotsym : '_');
}
}
fprintf(stream, "]\n");
}
}

View File

@ -10,6 +10,7 @@
#include <strings.h>
#include "apple2.h"
#include "apple2.hires.h"
#include "mos6502.h"
#include "mos6502.dis.h"
#include "vm_debug.h"
@ -43,6 +44,8 @@ vm_debug_cmd cmdtable[] = {
"Print out this list of commands", },
{ "hdump", "hd", vm_debug_cmd_hdump, 2, "<from> <to>",
"Hex dump memory in a given region", },
{ "hidump", "hid", vm_debug_cmd_hidump, 1, "<file>",
"Dump hires graphics memory to file", },
{ "jump", "j", vm_debug_cmd_jump, 1, "<addr>",
"Jump to <addr> for next execution", },
{ "printaddr", "pa", vm_debug_cmd_printaddr, 1, "<addr>",
@ -245,13 +248,8 @@ vm_debug_execute(const char *str)
break;
case 1:
args.addr1 = vm_debug_addr(vm_debug_next_arg(&ebuf));
// Oh no
if (args.addr1 == -1) {
free(orig);
return;
}
args.target = vm_debug_next_arg(&ebuf);
args.addr1 = vm_debug_addr(args.target);
break;
@ -471,3 +469,18 @@ DEBUG_CMD(hdump)
vm_segment_hexdump(cpu->rmem, stream, args->addr1, args->addr2);
}
DEBUG_CMD(hidump)
{
FILE *stream;
stream = fopen(args->target, "w");
if (stream == NULL) {
return;
}
apple2 *mach = (apple2 *)vm_di_get(VM_MACHINE);
apple2_hires_dump(mach, stream);
fclose(stream);
}