New name. Minor corrections. Includes PONG.
This commit is contained in:
32
debug.cpp
32
debug.cpp
@@ -8,10 +8,11 @@ typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
||||
static SDL_Window* debug_window = nullptr;
|
||||
static Uint32 debug_window_id;
|
||||
static Uint32 debug_window_id = 0;
|
||||
static SDL_Renderer* debug_renderer = nullptr;
|
||||
static SDL_Texture* debug_texture = nullptr;
|
||||
static SDL_Rect src, dst;
|
||||
static bool visible = false;
|
||||
static Uint8 ink[4];
|
||||
static Uint8 paper[4];
|
||||
static unsigned char* debug_mem = nullptr;
|
||||
@@ -289,15 +290,7 @@ void debug_print_asm(byte offset) {
|
||||
|
||||
}
|
||||
|
||||
void debug_init(unsigned char* mem) {
|
||||
debug_mem = mem;
|
||||
lines = parser_get_lines();
|
||||
|
||||
rX = (unsigned short*)&debug_mem[0xFFFA];
|
||||
rY = &debug_mem[0xFFFC];
|
||||
rZ = &debug_mem[0xFFFD];
|
||||
pc = (unsigned short*)&debug_mem[0xFFFE];
|
||||
|
||||
void debug_show_window() {
|
||||
debug_window = SDL_CreateWindow("Definitely PaCo Debugger", 1120, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
|
||||
debug_renderer = SDL_CreateRenderer(debug_window, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||
debug_window_id = SDL_GetWindowID(debug_window);
|
||||
@@ -311,8 +304,20 @@ void debug_init(unsigned char* mem) {
|
||||
SDL_SetTextureBlendMode(debug_texture, SDL_BLENDMODE_BLEND);
|
||||
stbi_image_free(buffer);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
f = fopen("test.bas", "rb");
|
||||
void debug_init(unsigned char* mem, const bool window_shown) {
|
||||
debug_mem = mem;
|
||||
lines = parser_get_lines();
|
||||
|
||||
rX = (unsigned short*)&debug_mem[0xFFFA];
|
||||
rY = &debug_mem[0xFFFC];
|
||||
rZ = &debug_mem[0xFFFD];
|
||||
pc = (unsigned short*)&debug_mem[0xFFFE];
|
||||
|
||||
if (window_shown) debug_show_window();
|
||||
|
||||
FILE* f = fopen("test.bas", "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET); //same as rewind(f);
|
||||
@@ -321,10 +326,11 @@ void debug_init(unsigned char* mem) {
|
||||
fclose(f);
|
||||
program[fsize] = 0;
|
||||
|
||||
debug_update();
|
||||
if (window_shown) debug_update();
|
||||
}
|
||||
|
||||
void debug_update() {
|
||||
if (!visible) debug_show_window();
|
||||
debug_set_paper(128, 128, 128);
|
||||
debug_clear();
|
||||
|
||||
@@ -339,12 +345,14 @@ void debug_update() {
|
||||
}
|
||||
|
||||
void debug_hide() {
|
||||
if (!visible) return;
|
||||
debug_set_paper(128, 128, 128);
|
||||
debug_clear();
|
||||
SDL_RenderPresent(debug_renderer);
|
||||
}
|
||||
|
||||
void debug_mouse_event(SDL_Event& event) {
|
||||
if (!visible) return;
|
||||
if (event.window.windowID != debug_window_id) return;
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
int x, y;
|
||||
|
||||
Reference in New Issue
Block a user