1
0
mirror of https://github.com/pevans/erc-c.git synced 2025-01-17 19:30:13 +00:00

Enable disassembly toggle (ALT+D)

This commit is contained in:
Peter Evans 2018-02-07 15:24:02 -06:00
parent fa938470d3
commit 3223fe6110
5 changed files with 36 additions and 7 deletions

View File

@ -338,6 +338,11 @@ struct apple2 {
* If paused is true, then execution of opcodes is suspended. * If paused is true, then execution of opcodes is suspended.
*/ */
bool paused; bool paused;
/*
* If this is true, then we will disassemble opcodes as we execute.
*/
bool disasm;
}; };
extern apple2 *apple2_create(int, int); extern apple2 *apple2_create(int, int);

View File

@ -6,6 +6,7 @@
extern void apple2_reflect_init(); extern void apple2_reflect_init();
extern REFLECT(apple2_reflect_cpu_info); extern REFLECT(apple2_reflect_cpu_info);
extern REFLECT(apple2_reflect_disasm);
extern REFLECT(apple2_reflect_machine_info); extern REFLECT(apple2_reflect_machine_info);
extern REFLECT(apple2_reflect_pause); extern REFLECT(apple2_reflect_pause);

View File

@ -14,6 +14,7 @@
#include "mos6502.dis.h" #include "mos6502.dis.h"
#include "objstore.h" #include "objstore.h"
#include "option.h" #include "option.h"
#include "vm_di.h"
#include "vm_segment.h" #include "vm_segment.h"
/* /*
@ -51,6 +52,9 @@ apple2_create(int width, int height)
// Yes, please do execute opcodes to begin with // Yes, please do execute opcodes to begin with
mach->paused = false; mach->paused = false;
// Don't print opcodes by default
mach->disasm = false;
// Forward set these to NULL in case we fail to build the machine // Forward set these to NULL in case we fail to build the machine
// properly; that way, we won't try to free garbage data // properly; that way, we won't try to free garbage data
mach->rom = NULL; mach->rom = NULL;
@ -334,10 +338,14 @@ apple2_free(apple2 *mach)
void void
apple2_run_loop(apple2 *mach) apple2_run_loop(apple2 *mach)
{ {
FILE *out;
if (option_flag(OPTION_DISASSEMBLE)) { if (option_flag(OPTION_DISASSEMBLE)) {
return; return;
} }
out = (FILE *)vm_di_get(VM_OUTPUT);
while (vm_screen_active(mach->screen)) { while (vm_screen_active(mach->screen)) {
// If we're paused, then just re-loop until we're not // If we're paused, then just re-loop until we're not
if (mach->paused) { if (mach->paused) {
@ -345,13 +353,17 @@ apple2_run_loop(apple2 *mach)
continue; continue;
} }
#if 0 if (mach->disasm) {
mach->drive1->locked = true; if (mach->selected_drive) {
mach->drive2->locked = true; mach->selected_drive->locked = true;
mos6502_dis_opcode(mach->cpu, stdout, mach->cpu->PC); }
mach->drive1->locked = false;
mach->drive2->locked = false; mos6502_dis_opcode(mach->cpu, out, mach->cpu->PC);
#endif
if (mach->selected_drive) {
mach->selected_drive->locked = false;
}
}
mos6502_execute(mach->cpu); mos6502_execute(mach->cpu);

View File

@ -15,6 +15,7 @@ apple2_reflect_init()
ref->cpu_info = apple2_reflect_cpu_info; ref->cpu_info = apple2_reflect_cpu_info;
ref->machine_info = apple2_reflect_machine_info; ref->machine_info = apple2_reflect_machine_info;
ref->pause = apple2_reflect_pause; ref->pause = apple2_reflect_pause;
ref->disasm = apple2_reflect_disasm;
} }
REFLECT(apple2_reflect_cpu_info) REFLECT(apple2_reflect_cpu_info)
@ -49,3 +50,9 @@ REFLECT(apple2_reflect_pause)
apple2 *mach = (apple2 *)vm_di_get(VM_MACHINE); apple2 *mach = (apple2 *)vm_di_get(VM_MACHINE);
mach->paused = !mach->paused; mach->paused = !mach->paused;
} }
REFLECT(apple2_reflect_disasm)
{
apple2 *mach = (apple2 *)vm_di_get(VM_MACHINE);
mach->disasm = !mach->disasm;
}

View File

@ -110,6 +110,10 @@ vm_event_keyboard_special(vm_event *ev, char ch)
case 'p': case 'p':
vm_reflect_pause(NULL); vm_reflect_pause(NULL);
break; break;
case 'd':
vm_reflect_disasm(NULL);
break;
} }
} }
} }