- Ja es pot tancar la finestra amb el botó de tancar finestra normal

- Ara la finestra de debug nomes es mostra mentre s'està debugant
- [NEW] "peek address" i "poke address value" des de la consola, per a modificar o consultar la memòria
This commit is contained in:
2024-12-02 21:55:04 +01:00
parent 810cdf4ecb
commit bb947f25b5
3 changed files with 39 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ int main(int argc, char *argv[])
z80::connect_port(0xfe, zx_ula::port_in, zx_ula::port_out);
SDL_Init(SDL_INIT_EVERYTHING);
z80debug::show();
z80debug::init();
zxscreen::init();
zx_ula::sound_init();
@@ -43,6 +43,10 @@ int main(int argc, char *argv[])
while (SDL_PollEvent(&e))
{
if (e.type == SDL_QUIT) { should_exit=true; break; }
if ((e.type==SDL_WINDOWEVENT) && (e.window.event==SDL_WINDOWEVENT_CLOSE)) {
should_exit=true; break;
}
if (z80debug::debugging()) {
if ((e.type==SDL_WINDOWEVENT) && ((e.window.event==SDL_WINDOWEVENT_SHOWN) || (e.window.event==SDL_WINDOWEVENT_EXPOSED))) {
z80debug::refresh();

View File

@@ -73,22 +73,36 @@ namespace z80debug
void processCommand();
void show()
void init()
{
is_debugging = false;
for (int i=0; i<65536; ++i) breakpoints[i]=0;
//show();
}
void show()
{
if (win) return;
win = SDL_CreateWindow("Z80 Debugger", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 71*CHR_W, 34*CHR_H, SDL_WINDOW_RESIZABLE);
ren = SDL_CreateRenderer(win, -1, 0);
tex = SDL_CreateTextureFromSurface(ren, SDL_LoadBMP("font.bmp"));
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
for (int i=0; i<65536; ++i) breakpoints[i]=0;
z80debug::refresh();
}
void stop() { zx_ula::sound_disable(); is_debugging = true; breakpoints[z80::getPC()] &= ~8; refresh(); }
void cont() { is_debugging = false; refresh(); zx_ula::sound_enable(); }
void hide()
{
if (tex) SDL_DestroyTexture(tex);
if (ren) SDL_DestroyRenderer(ren);
if (win) SDL_DestroyWindow(win);
tex = NULL;
ren = NULL;
win = NULL;
}
void stop() { zx_ula::sound_disable(); is_debugging = true; breakpoints[z80::getPC()] &= ~8; show(); /*refresh();*/ }
void cont() { is_debugging = false; hide();/*refresh()*/; zx_ula::sound_enable(); }
const bool debugging() { return is_debugging; }
void box(int x, int y, int w, int h, uint8_t color)
@@ -446,7 +460,19 @@ namespace z80debug
} else if (strcmp(cmd, "play")==0) {
zx_tape::play();
}
} else if (strcmp(cmd, "poke")==0) {
getcmd();
int address = getnum(cmd);
getcmd();
int value = getnum(cmd);
uint8_t *mem = z80::getMem();
mem[address] = value;
} else if (strcmp(cmd, "peek")==0) {
getcmd();
int address = getnum(cmd);
uint8_t *mem = z80::getMem();
int value = mem[address];
SDL_itoa(value, console_error, 10);
}
}

View File

@@ -3,7 +3,9 @@
namespace z80debug
{
void init();
void show();
void hide();
void stop();
void cont();