- [FIX] Al anar de 10 en 10 steps de vegades se botaba breakpoints
- [FIX] Ara cada renderer te la seua textura de font - [CHG] Continuar l'execució ja no tanca el debugger - [NEW] En la memòria no tocada actual o en avanç, se "adivina" quina es la instrucció - [FIX] Resetejar el spectrum borrava la ROM - [NEW] Anar avant o arrere en el temps mou el cursor del desensamblador
This commit is contained in:
28
z80debug.cpp
28
z80debug.cpp
@@ -26,6 +26,7 @@ namespace z80debug
|
||||
|
||||
SDL_Window *win = nullptr;
|
||||
SDL_Renderer *ren = nullptr;
|
||||
SDL_Texture *tex = nullptr;
|
||||
|
||||
bool is_debugging=false;
|
||||
bool is_paused=false;
|
||||
@@ -140,6 +141,7 @@ namespace z80debug
|
||||
win = SDL_CreateWindow("Z80 Debugger", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 83*CHR_W, 34*CHR_H, SDL_WINDOW_RESIZABLE);
|
||||
ren = SDL_CreateRenderer(win, -1, 0);
|
||||
ui::window::registerWindow(SDL_GetWindowID(win), eventHandler);
|
||||
tex = ui::createtexture(ren);
|
||||
|
||||
z80debug::refresh();
|
||||
}
|
||||
@@ -147,8 +149,10 @@ namespace z80debug
|
||||
void hide()
|
||||
{
|
||||
ui::window::unregisterWindow(SDL_GetWindowID(win));
|
||||
if (tex) SDL_DestroyTexture(tex);
|
||||
if (ren) SDL_DestroyRenderer(ren);
|
||||
if (win) SDL_DestroyWindow(win);
|
||||
tex = NULL;
|
||||
ren = NULL;
|
||||
win = NULL;
|
||||
}
|
||||
@@ -170,8 +174,8 @@ namespace z80debug
|
||||
|
||||
void cont() {
|
||||
is_debugging = is_paused = false;
|
||||
hide();
|
||||
/*refresh();*/
|
||||
//hide();
|
||||
refresh();
|
||||
zx_ula::sound_enable();
|
||||
}
|
||||
|
||||
@@ -201,10 +205,11 @@ namespace z80debug
|
||||
*/
|
||||
}
|
||||
|
||||
void printDissasemblerLine(const uint16_t address, const int line)
|
||||
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
||||
{
|
||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_GRAY, COLOR_WHITE};
|
||||
if (z80::getMemTouched(address)!=MEMTAG_INST) colors[3]=COLOR_GRAY;
|
||||
if (z80::getMemTouched(address)==MEMTAG_NONE) colors[1]=COLOR_GRAY;
|
||||
|
||||
if (is_debugging && (address == z80::getPC())) {
|
||||
for (int i=0; i<4;++i) colors[i]=COLOR_YELLOW;
|
||||
@@ -214,7 +219,7 @@ namespace z80debug
|
||||
if (breakpoints[address]&9) ui::printtxt(0,line,"*", colors[0]);
|
||||
ui::printtxt(1,line,tohex(address,4), colors[1]);
|
||||
|
||||
if (z80::getMemTag(address)==MEMTAG_INST) {
|
||||
if ( (z80::getMemTag(address)==MEMTAG_INST) || heuristics ) {
|
||||
const char *sym = z80dis::getSymbol(address);
|
||||
if (sym[0]!=0) ui::printtxt(7,line, sym, COLOR_YELLOW);
|
||||
ui::printtxt(19,line, z80dis::getOpcode(address), colors[2]);
|
||||
@@ -227,7 +232,7 @@ namespace z80debug
|
||||
|
||||
void refresh()
|
||||
{
|
||||
ui::setrenderer(ren);
|
||||
ui::setrenderer(ren, tex);
|
||||
SDL_SetRenderDrawColor(ren, 30, 30, 30, 255);
|
||||
SDL_RenderClear(ren);
|
||||
|
||||
@@ -246,11 +251,11 @@ namespace z80debug
|
||||
uint16_t pc = cursor; //z80::getPC();
|
||||
uint16_t pos = pc;
|
||||
|
||||
printDissasemblerLine(pc, 8);
|
||||
printDissasemblerLine(pc, 8, true);
|
||||
|
||||
for (int i=9;i<18;++i) {
|
||||
pos += z80dis::getOpcodeSize(pos);
|
||||
printDissasemblerLine(pos, i);
|
||||
printDissasemblerLine(pos, i, true);
|
||||
}
|
||||
|
||||
pos = pc;
|
||||
@@ -468,7 +473,7 @@ namespace z80debug
|
||||
z80debug::cont();
|
||||
} else if (strcmp(cmd, "r")==0 || strcmp(cmd, "reset")==0) {
|
||||
uint8_t *mem = z80::getMem();
|
||||
for (int i=0; i<65536; ++i) mem[i]=0;
|
||||
for (int i=0x4000; i<=0xffff; ++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;
|
||||
@@ -616,7 +621,7 @@ namespace z80debug
|
||||
uint8_t *memory = z80::getMem();
|
||||
FILE *f = fopen(filename, "wb");
|
||||
fwrite(regs, 31, 1, f);
|
||||
fwrite(&memory[16*1024], 48*1024, 1, f);
|
||||
fwrite(&memory[0x4000], 0xc000, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -626,7 +631,7 @@ namespace z80debug
|
||||
uint8_t *memory = z80::getMem();
|
||||
FILE *f = fopen(filename, "rb");
|
||||
fread(regs, 31, 1, f);
|
||||
fread(&memory[16*1024], 48*1024, 1, f);
|
||||
fread(&memory[0x4000], 0xc000, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -658,18 +663,21 @@ namespace z80debug
|
||||
{
|
||||
pos = top;
|
||||
z80::setPC(buffer[pos]);
|
||||
cursor = z80::getPC();
|
||||
}
|
||||
|
||||
void goforward()
|
||||
{
|
||||
if (pos == top) return;
|
||||
z80::setPC(buffer[++pos]);
|
||||
cursor = z80::getPC();
|
||||
}
|
||||
|
||||
void goback()
|
||||
{
|
||||
if (uint8_t(pos-1) == top) return;
|
||||
z80::setPC(buffer[--pos]);
|
||||
cursor = z80::getPC();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user