- [NEW] Se mostren les etiquetes en les adreces de la finestra de debug

- [FIX] En la finestra de desensamblat el cursor sempre anava una instrucció per darrere
- [ONGOING] 'Next' funciona intermitentment, no entenc perqué
This commit is contained in:
2024-12-09 22:06:17 +01:00
parent 2f4e79bc50
commit 68d53af1b4
4 changed files with 38 additions and 26 deletions

View File

@@ -11,6 +11,7 @@
namespace z80debug
{
#define midy 58
namespace history
{
uint16_t buffer[65536];
@@ -59,7 +60,7 @@ namespace z80debug
}
}
if (e->type == SDL_MOUSEWHEEL) {
if (e->wheel.mouseX<46*CHR_W && e->wheel.mouseY<20*CHR_H) {
if (e->wheel.mouseX<midy*CHR_W && e->wheel.mouseY<20*CHR_H) {
if (e->wheel.y>0) {
z80debug::cursorback();
z80debug::refresh();
@@ -82,6 +83,7 @@ namespace z80debug
} else if (e->key.keysym.scancode==SDL_SCANCODE_F11) {
z80debug::history::gototop();
const uint8_t dt = z80debug::next();
z80debug::refresh();
zxscreen::refresh(dt);
zxscreen::redraw();
z80analyze::refresh();
@@ -135,7 +137,7 @@ namespace z80debug
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);
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);
@@ -202,20 +204,24 @@ namespace z80debug
void printDissasemblerLine(const uint16_t address, const int line)
{
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_GRAY, COLOR_WHITE};
if (z80::getMemTouched(address)!=MEMTAG_INST) colors[3]=COLOR_GRAY;
if (is_debugging && (address == z80::getPC())) {
for (int i=0; i<4;++i) colors[i]=COLOR_YELLOW;
ui::printrect(0,line, 44,1, COLOR_BLUE);
ui::printrect(0,line, midy-2,1, COLOR_BLUE);
}
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) {
ui::printtxt(7,line, z80dis::getOpcode(address), colors[2]);
ui::printtxt(19,line, z80dis::getAsm(address), colors[3]);
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]);
ui::printtxt(31,line, z80dis::getAsm(address), colors[3]);
} else {
ui::printtxt(7,line, tohex(z80::getMem()[address],2), COLOR_GRAY);
ui::printtxt(19,line, "?????????", COLOR_GRAY);
ui::printtxt(19,line, tohex(z80::getMem()[address],2), COLOR_GRAY);
ui::printtxt(31,line, "?????????", COLOR_GRAY);
}
}
@@ -229,7 +235,7 @@ namespace z80debug
// ******************************************
ui::setoffset(0, 0);
ui::box(0,0,46,20,COLOR_WHITE);
ui::box(0,0,midy,20,COLOR_WHITE);
ui::printrect(2,0, 12,1, COLOR_DARK);
ui::printtxt(3,0, "ASSEMBLER:", COLOR_WHITE);
@@ -257,11 +263,11 @@ namespace z80debug
// ******************************************
ui::setoffset(0, 0);
ui::box(46,0,25,8,COLOR_WHITE);
ui::printrect(48,0, 12,1, COLOR_DARK);
ui::printtxt(49,0, "REGISTERS:", COLOR_WHITE);
ui::box(midy,0,25,8,COLOR_WHITE);
ui::printrect(midy+2,0, 12,1, COLOR_DARK);
ui::printtxt(midy+3,0, "REGISTERS:", COLOR_WHITE);
ui::setoffset(47, 1);
ui::setoffset(midy+1, 1);
ui::printtxt(0,0, "AF AF' IX ", COLOR_WHITE);
ui::printtxt(0,1, "BC BC' IY ", COLOR_WHITE);
ui::printtxt(0,2, "DE DE' SP ", COLOR_WHITE);
@@ -305,10 +311,10 @@ namespace z80debug
// ******************************************
ui::setoffset(0, 0);
ui::box(46,8,11,12,COLOR_WHITE);
ui::printrect(48,8, 8,1, COLOR_DARK);
ui::printtxt(49,8, "STACK:", COLOR_WHITE);
ui::setoffset(47, 9);
ui::box(midy,8,11,12,COLOR_WHITE);
ui::printrect(midy+2,8, 8,1, COLOR_DARK);
ui::printtxt(midy+3,8, "STACK:", COLOR_WHITE);
ui::setoffset(midy+1, 9);
uint16_t sp = z80::getSP()-8;
for (int i=0; i<10; ++i) {
uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY;
@@ -326,10 +332,10 @@ namespace z80debug
// ******************************************
ui::setoffset(0, 0);
ui::box(57,8,14,12,COLOR_WHITE);
ui::printrect(59,8, 9,1, COLOR_DARK);
ui::printtxt(60,8, "BREAKS:", COLOR_WHITE);
ui::setoffset(58, 9);
ui::box(midy+11,8,14,12,COLOR_WHITE);
ui::printrect(midy+13,8, 9,1, COLOR_DARK);
ui::printtxt(midy+14,8, "BREAKS:", COLOR_WHITE);
ui::setoffset(midy+12, 9);
int line=0;
for (int i=0; i<65536; ++i) {
@@ -348,7 +354,7 @@ namespace z80debug
// ******************************************
ui::setoffset(0, 0);
ui::box(0,20,71,8,COLOR_WHITE);
ui::box(0,20,83,8,COLOR_WHITE);
ui::printrect(2,20, 9,1, COLOR_DARK);
ui::printtxt(3,20, "MEMORY:", COLOR_WHITE);
@@ -356,10 +362,10 @@ namespace z80debug
uint16_t mem_viewer_cursor = mem_viewer_pos;
for (int i=0; i<6; ++i) {
ui::printtxt(0,i, tohex(mem_viewer_cursor, 4), COLOR_CYAN);
ui::printtxt(1,i, tohex(mem_viewer_cursor, 4), COLOR_CYAN);
for (int j=0; j<16; ++j) {
ui::printtxt(5+j*3, i, tohex(memory[mem_viewer_cursor],2), mem_modified[mem_viewer_cursor] ? COLOR_RED : COLOR_WHITE);
ui::printchar(53+j, i, memory[mem_viewer_cursor], mem_modified[mem_viewer_cursor] ? COLOR_BROWN : COLOR_GRAY);
ui::printtxt(6+j*3, i, tohex(memory[mem_viewer_cursor],2), mem_modified[mem_viewer_cursor] ? COLOR_RED : COLOR_WHITE);
ui::printchar(54+j, i, memory[mem_viewer_cursor], mem_modified[mem_viewer_cursor] ? COLOR_BROWN : COLOR_GRAY);
mem_viewer_cursor++;
}
//printtxt(5,0, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", COLOR_WHITE);
@@ -371,7 +377,7 @@ namespace z80debug
// ******************************************
ui::setoffset(0, 0);
ui::box(0,28,71,6,COLOR_WHITE);
ui::box(0,28,83,6,COLOR_WHITE);
ui::printrect(2,28, 10,1, COLOR_DARK);
ui::printtxt(3,28, "CONSOLE:", COLOR_WHITE);