mirror of
https://github.com/trudnai/Steve2.git
synced 2024-06-12 18:45:22 +00:00
m6502_Debug() moved to m6502_debugger.c
This commit is contained in:
parent
52cdd84aad
commit
a04df3c1b2
108
src/cpu/6502.c
108
src/cpu/6502.c
|
@ -415,114 +415,6 @@ void m6502_Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void m6502_Debug(void) {
|
|
||||||
m6502.clktime += m6502.clkfrm;
|
|
||||||
// m6502.clkfrm = 0;
|
|
||||||
m6502.lastIO = 0;
|
|
||||||
m6502.interrupt = NO_INT; // TODO: This should be taken care by the interrupt handler
|
|
||||||
|
|
||||||
m6502_dbg_on();
|
|
||||||
|
|
||||||
if( diskAccelerator_count ) {
|
|
||||||
if( --diskAccelerator_count <= 0 ) {
|
|
||||||
// make sure we only adjust clock once to get back to normal
|
|
||||||
diskAccelerator_count = 0;
|
|
||||||
clk_6502_per_frm = clk_6502_per_frm_set;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clk_6502_per_frm_max = clk_6502_per_frm;
|
|
||||||
|
|
||||||
for ( m6502.clkfrm = m6502_Step(); m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Step() ) {
|
|
||||||
switch (m6502.interrupt) {
|
|
||||||
case HALT:
|
|
||||||
if (m6502.debugger.mask.hlt) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BREAK:
|
|
||||||
if (m6502.debugger.mask.brk) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IRQ:
|
|
||||||
if (m6502.debugger.mask.irq) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NMI:
|
|
||||||
if (m6502.debugger.mask.nmi) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INV:
|
|
||||||
if (m6502.debugger.mask.inv) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RET:
|
|
||||||
// Step_Out & Step_Over: Return to caller
|
|
||||||
if (m6502.debugger.mask.out) {
|
|
||||||
if ( m6502.SP >= m6502.debugger.SP ) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HARDRESET:
|
|
||||||
hardReset();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SOFTRESET:
|
|
||||||
softReset();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Step_Out: If there was a POP (PLA, PLX, PLY, PLP), then we should update the monitoring stack pointer
|
|
||||||
// (so we can return to the caller, not stopping at the POP)
|
|
||||||
if ( m6502.SP > m6502.debugger.SP ) {
|
|
||||||
m6502.debugger.SP = m6502.SP;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
m6502.interrupt = NO_INT;
|
|
||||||
|
|
||||||
if ( m6502_dbg_bp_is_exists(m6502.PC) ) {
|
|
||||||
cpuState = cpuState_halted;
|
|
||||||
// m6502.debugger.wMask = 0;
|
|
||||||
// m6502.debugger.on = 0;
|
|
||||||
m6502.interrupt = BREAKPOINT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// play the entire sound buffer for this frame
|
|
||||||
spkr_update();
|
|
||||||
// this will take care of turning off disk motor sound when time is up
|
|
||||||
spkr_update_disk_sfx();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, const uint16_t addr, const uint16_t size ) {
|
void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, const uint16_t addr, const uint16_t size ) {
|
||||||
|
|
||||||
char fullPath[256];
|
char fullPath[256];
|
||||||
|
|
|
@ -242,7 +242,6 @@ extern void rom_loadFile( const char * bundlePath, const char * filename );
|
||||||
extern void tst6502(void);
|
extern void tst6502(void);
|
||||||
extern void m6502_ColdReset( const char * bundlePath, const char * romFilePath );
|
extern void m6502_ColdReset( const char * bundlePath, const char * romFilePath );
|
||||||
extern void m6502_Run(void);
|
extern void m6502_Run(void);
|
||||||
extern void m6502_Debug(void);
|
|
||||||
INLINE int m6502_Step(void);
|
INLINE int m6502_Step(void);
|
||||||
|
|
||||||
extern void interrupt_IRQ(void);
|
extern void interrupt_IRQ(void);
|
||||||
|
|
|
@ -97,6 +97,115 @@ INLINE int m6502_Disass_1_Instr(void) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void m6502_Debug(void) {
|
||||||
|
m6502.clktime += m6502.clkfrm;
|
||||||
|
// m6502.clkfrm = 0;
|
||||||
|
m6502.lastIO = 0;
|
||||||
|
m6502.interrupt = NO_INT; // TODO: This should be taken care by the interrupt handler
|
||||||
|
|
||||||
|
m6502_dbg_on();
|
||||||
|
|
||||||
|
if( diskAccelerator_count ) {
|
||||||
|
if( --diskAccelerator_count <= 0 ) {
|
||||||
|
// make sure we only adjust clock once to get back to normal
|
||||||
|
diskAccelerator_count = 0;
|
||||||
|
clk_6502_per_frm = clk_6502_per_frm_set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clk_6502_per_frm_max = clk_6502_per_frm;
|
||||||
|
|
||||||
|
for ( m6502.clkfrm = m6502_Step(); m6502.clkfrm < clk_6502_per_frm_max ; m6502.clkfrm += m6502_Step() ) {
|
||||||
|
switch (m6502.interrupt) {
|
||||||
|
case HALT:
|
||||||
|
if (m6502.debugger.mask.hlt) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BREAK:
|
||||||
|
if (m6502.debugger.mask.brk) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IRQ:
|
||||||
|
if (m6502.debugger.mask.irq) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NMI:
|
||||||
|
if (m6502.debugger.mask.nmi) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INV:
|
||||||
|
if (m6502.debugger.mask.inv) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RET:
|
||||||
|
// Step_Out & Step_Over: Return to caller
|
||||||
|
if (m6502.debugger.mask.out) {
|
||||||
|
if ( m6502.SP >= m6502.debugger.SP ) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HARDRESET:
|
||||||
|
hardReset();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOFTRESET:
|
||||||
|
softReset();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Step_Out: If there was a POP (PLA, PLX, PLY, PLP), then we should update the monitoring stack pointer
|
||||||
|
// (so we can return to the caller, not stopping at the POP)
|
||||||
|
if ( m6502.SP > m6502.debugger.SP ) {
|
||||||
|
m6502.debugger.SP = m6502.SP;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m6502.interrupt = NO_INT;
|
||||||
|
|
||||||
|
if ( m6502_dbg_bp_is_exists(m6502.PC) ) {
|
||||||
|
cpuState = cpuState_halted;
|
||||||
|
// m6502.debugger.wMask = 0;
|
||||||
|
// m6502.debugger.on = 0;
|
||||||
|
m6502.interrupt = BREAKPOINT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// play the entire sound buffer for this frame
|
||||||
|
spkr_update();
|
||||||
|
// this will take care of turning off disk motor sound when time is up
|
||||||
|
spkr_update_disk_sfx();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Turn On Debugger
|
/// Turn On Debugger
|
||||||
void m6502_dbg_on(void) {
|
void m6502_dbg_on(void) {
|
||||||
m6502.debugger.on = 1;
|
m6502.debugger.on = 1;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
extern uint16_t disass_addr;
|
extern uint16_t disass_addr;
|
||||||
extern int m6502_Disass_1_Instr(void);
|
extern int m6502_Disass_1_Instr(void);
|
||||||
|
extern void m6502_Debug(void);
|
||||||
extern void m6502_dbg_on(void);
|
extern void m6502_dbg_on(void);
|
||||||
extern void m6502_dbg_off(void);
|
extern void m6502_dbg_off(void);
|
||||||
extern void m6502_dbg_init(void);
|
extern void m6502_dbg_init(void);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user