Fixed exception with fullscreen. Improved debugger BASIC window.

This commit is contained in:
2017-02-03 20:07:55 +01:00
parent 88c0288931
commit 1391368c4c
4 changed files with 36 additions and 23 deletions

View File

@@ -140,21 +140,28 @@ static void debug_print_callstack(byte offset) {
}
}
static void debug_print_basic(byte offset) {
static int basic_line = 0;
static void debug_print_basic(const bool force) {
debug_draw_space(1, 2, 70, 35, "CODE:");
debug_set_ink(255, 255, 255);
if (*pc >= 0x8000) {
debug_print(17, 17, "No source code for this memory region");
return;
}
int line = offset;
int line = basic_line;
int l = 0;
if (lines[*pc] >= 35) line = lines[*pc] + 30;
int row = 0;
if (force) {
if (lines[*pc] >= basic_line + 35) line = basic_line = lines[*pc] - 30;
if (lines[*pc] < basic_line) line = basic_line = lines[*pc] - 5;
if (line < 0) line = basic_line = 0;
}
int row = 0; int cline = 0;
char* prog = program;
while (cline < line) { if (*prog == '\n') cline++; prog++; }
if (lines[*pc] == line) { debug_set_ink(0, 0, 0); debug_fill_rect(1, 2 + l, 70, 1); debug_set_ink(255, 255, 0); }
else debug_set_ink(255, 255, 255);
while (line < 35 && *prog != 0) {
while (l < 35 && *prog != 0) {
if (*prog == '\t') {
row += 4;
} else if (*prog == '\n') {
@@ -304,6 +311,7 @@ void debug_show_window() {
SDL_SetTextureBlendMode(debug_texture, SDL_BLENDMODE_BLEND);
stbi_image_free(buffer);
fclose(f);
visible = true;
}
void debug_init(unsigned char* mem, const bool window_shown) {
@@ -329,7 +337,7 @@ void debug_init(unsigned char* mem, const bool window_shown) {
if (window_shown) debug_update();
}
void debug_update() {
void debug_update(const bool force) {
if (!visible) debug_show_window();
debug_set_paper(128, 128, 128);
debug_clear();
@@ -339,7 +347,7 @@ void debug_update() {
debug_print_datastack(0);
debug_print_callstack(0);
debug_print_registers();
debug_print_basic(0);
debug_print_basic(force);
SDL_RenderPresent(debug_renderer);
}
@@ -358,11 +366,19 @@ void debug_mouse_event(SDL_Event& event) {
int x, y;
Uint32 buttons = SDL_GetMouseState(&x, &y);
if (x >= 8 && x <= 568 && y >= 16 && y <= 296) {
int l = (y - 16) >> 3;
int l = basic_line + ((y - 16) >> 3);
int bm = 0; while (lines[bm] < l) { bm++; }
breakpoints[bm] = !breakpoints[bm];
}
debug_update();
debug_update(false);
}
if (event.type == SDL_MOUSEWHEEL) {
int x, y;
Uint32 buttons = SDL_GetMouseState(&x, &y);
if (x >= 8 && x <= 568 && y >= 16 && y <= 296) {
basic_line -= event.wheel.y*3; if (basic_line < 0) basic_line = 0;
debug_update(false);
}
}
}