- [NEW] Gestió dels events de cada finestra per separat
- [NEW] Symbols per a etiquetar adreces - [NEW] Mapa de memòria "tocada" - [NEW] En el mapa de memòria al passar el ratolí mostra l'adreça - [NEW] En el mapa de memòria es mostra en roig la posició del contador de programa - [NEW] Reemplaç en els opcodes de adreces conegudes per la seua etiqueta
This commit is contained in:
110
z80debug.cpp
110
z80debug.cpp
@@ -5,6 +5,10 @@
|
||||
#include "zx_ula.h"
|
||||
#include "zx_tape.h"
|
||||
#include "ui.h"
|
||||
#include "ui_window.h"
|
||||
#include "zx_screen.h"
|
||||
#include "z80analyze.h"
|
||||
|
||||
namespace z80debug
|
||||
{
|
||||
namespace history
|
||||
@@ -40,6 +44,85 @@ namespace z80debug
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool eventHandler(SDL_Event *e)
|
||||
{
|
||||
if (z80debug::debugging()) {
|
||||
if (e->type==SDL_WINDOWEVENT) {
|
||||
if ((e->window.event==SDL_WINDOWEVENT_SHOWN) || (e->window.event==SDL_WINDOWEVENT_EXPOSED)) {
|
||||
z80debug::refresh();
|
||||
zxscreen::redraw();
|
||||
} else if (e->window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
z80debug::history::gototop();
|
||||
const uint8_t dt = z80::step();
|
||||
z80debug::cont();
|
||||
zxscreen::refresh(dt);
|
||||
}
|
||||
}
|
||||
if (e->type == SDL_MOUSEWHEEL) {
|
||||
if (e->wheel.mouseX<46*CHR_W && e->wheel.mouseY<20*CHR_H) {
|
||||
if (e->wheel.y>0) {
|
||||
z80debug::cursorback();
|
||||
z80debug::refresh();
|
||||
} else if (e->wheel.y<0) {
|
||||
z80debug::cursorfwd();
|
||||
z80debug::refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e->type == SDL_KEYDOWN) {
|
||||
if (e->key.keysym.scancode==SDL_SCANCODE_ESCAPE) {
|
||||
return false;
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_F10) {
|
||||
z80debug::history::gototop();
|
||||
const uint8_t dt = z80::step();
|
||||
z80debug::refresh();
|
||||
zxscreen::refresh(dt);
|
||||
zxscreen::redraw();
|
||||
z80analyze::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_F11) {
|
||||
z80debug::history::gototop();
|
||||
const uint8_t dt = z80debug::next();
|
||||
zxscreen::refresh(dt);
|
||||
zxscreen::redraw();
|
||||
z80analyze::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_F1) {
|
||||
z80debug::history::gototop();
|
||||
z80debug::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_F2) {
|
||||
z80debug::history::goback();
|
||||
z80debug::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_F3) {
|
||||
z80debug::history::goforward();
|
||||
z80debug::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_F5) {
|
||||
z80debug::history::gototop();
|
||||
const uint8_t dt = z80::step();
|
||||
z80debug::cont();
|
||||
zxscreen::refresh(dt);
|
||||
/*} else if (e->key.keysym.scancode==SDL_SCANCODE_F6) {
|
||||
z80debug::history::gototop();
|
||||
const uint8_t dt = z80::step();
|
||||
z80debug::refresh();
|
||||
zxscreen::refresh(dt);*/
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_UP) {
|
||||
z80debug::cursorback();
|
||||
z80debug::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_DOWN) {
|
||||
z80debug::cursorfwd();
|
||||
z80debug::refresh();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_RETURN) {
|
||||
z80debug::executeConsole();
|
||||
} else if (e->key.keysym.scancode==SDL_SCANCODE_BACKSPACE) {
|
||||
z80debug::DeleteCharConsole();
|
||||
}
|
||||
}
|
||||
if (e->type == SDL_TEXTINPUT) {
|
||||
z80debug::sendToConsole(e->text.text);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void processCommand();
|
||||
|
||||
void init()
|
||||
@@ -54,12 +137,14 @@ namespace z80debug
|
||||
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);
|
||||
ui::window::registerWindow(SDL_GetWindowID(win), eventHandler);
|
||||
|
||||
z80debug::refresh();
|
||||
}
|
||||
|
||||
void hide()
|
||||
{
|
||||
ui::window::unregisterWindow(SDL_GetWindowID(win));
|
||||
if (ren) SDL_DestroyRenderer(ren);
|
||||
if (win) SDL_DestroyWindow(win);
|
||||
ren = NULL;
|
||||
@@ -140,6 +225,8 @@ namespace z80debug
|
||||
SDL_SetRenderDrawColor(ren, 30, 30, 30, 255);
|
||||
SDL_RenderClear(ren);
|
||||
|
||||
// DISSASSEBLY
|
||||
// ******************************************
|
||||
ui::setoffset(0, 0);
|
||||
|
||||
ui::box(0,0,46,20,COLOR_WHITE);
|
||||
@@ -166,6 +253,9 @@ namespace z80debug
|
||||
printDissasemblerLine(pos, i);
|
||||
}
|
||||
|
||||
// REGISTERS
|
||||
// ******************************************
|
||||
|
||||
ui::setoffset(0, 0);
|
||||
ui::box(46,0,25,8,COLOR_WHITE);
|
||||
ui::printrect(48,0, 12,1, COLOR_DARK);
|
||||
@@ -210,6 +300,10 @@ namespace z80debug
|
||||
ui::printtxt(6,5,"N", flags&0x02 ? (mod_flags&0x02 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x02 ? COLOR_BROWN : COLOR_GRAY) );
|
||||
ui::printtxt(7,5,"C", flags&0x01 ? (mod_flags&0x01 ? COLOR_RED : COLOR_WHITE) : (mod_flags&0x01 ? COLOR_BROWN : COLOR_GRAY) );
|
||||
|
||||
|
||||
// STACK
|
||||
// ******************************************
|
||||
|
||||
ui::setoffset(0, 0);
|
||||
ui::box(46,8,11,12,COLOR_WHITE);
|
||||
ui::printrect(48,8, 8,1, COLOR_DARK);
|
||||
@@ -227,6 +321,10 @@ namespace z80debug
|
||||
sp+=2;
|
||||
}
|
||||
|
||||
|
||||
// BREAKPOINTS
|
||||
// ******************************************
|
||||
|
||||
ui::setoffset(0, 0);
|
||||
ui::box(57,8,14,12,COLOR_WHITE);
|
||||
ui::printrect(59,8, 9,1, COLOR_DARK);
|
||||
@@ -245,6 +343,10 @@ namespace z80debug
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MEMORY
|
||||
// ******************************************
|
||||
|
||||
ui::setoffset(0, 0);
|
||||
ui::box(0,20,71,8,COLOR_WHITE);
|
||||
ui::printrect(2,20, 9,1, COLOR_DARK);
|
||||
@@ -264,6 +366,10 @@ namespace z80debug
|
||||
//printtxt(53,0, "0123456789AB\tDEF", COLOR_GRAY);
|
||||
}
|
||||
|
||||
|
||||
// CONSOLE
|
||||
// ******************************************
|
||||
|
||||
ui::setoffset(0, 0);
|
||||
ui::box(0,28,71,6,COLOR_WHITE);
|
||||
ui::printrect(2,28, 10,1, COLOR_DARK);
|
||||
@@ -355,7 +461,9 @@ namespace z80debug
|
||||
z80::step();
|
||||
z80debug::cont();
|
||||
} else if (strcmp(cmd, "r")==0 || strcmp(cmd, "reset")==0) {
|
||||
z80::reset(z80::getMem());
|
||||
uint8_t *mem = z80::getMem();
|
||||
for (int i=0; i<65536; ++i) mem[i]=0;
|
||||
z80::reset(mem);
|
||||
z80::connect_port(0xfe, zx_ula::port_in, zx_ula::port_out);
|
||||
//for (int i=0; i<65536; ++i) breakpoints[i]=0;
|
||||
z80debug::refresh();
|
||||
|
||||
Reference in New Issue
Block a user