1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-10-13 02:23:39 +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.
*/
bool paused;
/*
* If this is true, then we will disassemble opcodes as we execute.
*/
bool disasm;
};
extern apple2 *apple2_create(int, int);

View File

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

View File

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

View File

@ -15,6 +15,7 @@ apple2_reflect_init()
ref->cpu_info = apple2_reflect_cpu_info;
ref->machine_info = apple2_reflect_machine_info;
ref->pause = apple2_reflect_pause;
ref->disasm = apple2_reflect_disasm;
}
REFLECT(apple2_reflect_cpu_info)
@ -49,3 +50,9 @@ REFLECT(apple2_reflect_pause)
apple2 *mach = (apple2 *)vm_di_get(VM_MACHINE);
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':
vm_reflect_pause(NULL);
break;
case 'd':
vm_reflect_disasm(NULL);
break;
}
}
}