From 9b4e5be3b4525a47126fe341c09e65360d51b859 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 31 Jan 2017 19:59:34 +0100 Subject: [PATCH] Debugger STEP and BIGSTEP. --- debug.cpp | 4 ++++ debug.h | 3 ++- main.cpp | 4 +++- vm.cpp | 6 ++++++ vm.h | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/debug.cpp b/debug.cpp index 634aa52..58e1c72 100644 --- a/debug.cpp +++ b/debug.cpp @@ -203,6 +203,10 @@ void debug_init(unsigned char* mem) { fclose(f); program[fsize] = 0; + debug_update(); +} + +void debug_update() { debug_set_paper(128, 128, 128); debug_clear(); diff --git a/debug.h b/debug.h index c920568..48b72e7 100644 --- a/debug.h +++ b/debug.h @@ -1,3 +1,4 @@ #pragma once -void debug_init(unsigned char* mem); \ No newline at end of file +void debug_init(unsigned char* mem); +void debug_update(); diff --git a/main.cpp b/main.cpp index a74edda..fe4bd0d 100644 --- a/main.cpp +++ b/main.cpp @@ -45,6 +45,7 @@ int main(int argc, char** argv) { vm_register_in_port(21, input_data_out); debug_init(vm_get_memory()); + static bool should_quit = false; static SDL_Event sdlEvent; SDL_Scancode just_pressed; @@ -59,9 +60,10 @@ int main(int argc, char** argv) { anykey = true; just_pressed = sdlEvent.key.keysym.scancode; if (sdlEvent.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { should_quit = true; } + if (sdlEvent.key.keysym.scancode == SDL_SCANCODE_RETURN) { vm_big_step(); debug_update(); } } } - vm_step(); + //vm_step(); //if (SDL_GetTicks() - ticks >= 15) { vdp_flip(); ticks = SDL_GetTicks(); } } diff --git a/vm.cpp b/vm.cpp index 2be2fd0..9fee05e 100644 --- a/vm.cpp +++ b/vm.cpp @@ -241,6 +241,12 @@ const int vm_step() { return vm_cycles; } +const int vm_big_step() { + word* lines = parser_get_lines(); + word current_line = lines[vm_pc]; + while (vm_pc > 32768 || lines[vm_pc] == current_line) { vm_step(); } + return 0; +} /*void vm_register_call(void(*callback)(t_stack&)) { external_calls[numcallbacks++] = callback; }*/ diff --git a/vm.h b/vm.h index 61004f1..4898e78 100644 --- a/vm.h +++ b/vm.h @@ -3,6 +3,7 @@ void vm_init(const char* filename); const int vm_step(); +const int vm_big_step(); void vm_register_in_port(const unsigned char port, unsigned char(*callback)(void)); void vm_register_out_port(const unsigned char port, void(*callback)(const unsigned char&)); void vm_call_interrupt(const char num);