- [NEW] En el debugger, en el visor de memòria, tambe es veu cada byte del color del seu tag

- [NEW] En el debugger, en el visor de breakpoints, se marca uno si estem en eixe breakpoint
- [NEW] Opció per a sincronitzar el cursor del visor de memòria amb el cursor del desensamblador
- [NEW] Click on breakpoint to goto its address
- [FIX] IX, IX bit, IY i IY bit opcodes with displacement wher shown wrong on the disassembler
- [NEW] Symbols module shows a symbol highlighted if the cursor is on its address
- [NEW] Click on a symbol to move the cursor to its address
This commit is contained in:
2024-12-14 12:22:30 +01:00
parent 6768c01c81
commit 14d047cbb9
3 changed files with 66 additions and 17 deletions

View File

@@ -1,2 +1 @@
0xf72d MAINLOOP 0xfed5 COUNT500
0xf864 CHK_KEYB

View File

@@ -65,6 +65,9 @@ namespace z80debug
uint8_t use[7][256]; uint8_t use[7][256];
uint16_t line_address[256]; uint16_t line_address[256];
uint16_t line_breakpoint_address[256];
int num_breakpoint_lines=0;
bool sync_mem_with_cursor = false;
char temp[256]; char temp[256];
const char *tohex(int value, int numdigits) const char *tohex(int value, int numdigits)
@@ -185,6 +188,9 @@ namespace z80debug
} }
} }
if (e->type == SDL_MOUSEBUTTONDOWN) { if (e->type == SDL_MOUSEBUTTONDOWN) {
const int chrx = e->button.x/CHR_W;
const int chry = e->button.y/CHR_H;
//printf("%ix%i\n", chrx, chry);
if ( (e->button.x<midx*CHR_W) && (e->button.y<(mem_y-1)*CHR_H) && (e->button.y>CHR_H) ) { if ( (e->button.x<midx*CHR_W) && (e->button.y<(mem_y-1)*CHR_H) && (e->button.y>CHR_H) ) {
const uint16_t address = ((e->button.y)/CHR_H)-1; const uint16_t address = ((e->button.y)/CHR_H)-1;
if (breakpoints[line_address[address]]==0) if (breakpoints[line_address[address]]==0)
@@ -193,6 +199,26 @@ namespace z80debug
breakpoints[line_address[address]]=0; breakpoints[line_address[address]]=0;
refresh(); refresh();
} }
if (chrx>=midx+12 && chry>=9 && chry<sym_y-1) {
const int breakpoint_selected = chry-9;
if (num_breakpoint_lines>breakpoint_selected) {
cursor = line_breakpoint_address[breakpoint_selected];
refresh();
}
}
if (chrx>=10 && chrx<=12 && chry==mem_y) {
sync_mem_with_cursor = ! sync_mem_with_cursor;
refresh();
}
if (chrx>=midx+2 && chry>=sym_y+1) {
const int line = chry-(sym_y+1);
if (line<z80dis::getNumSymbols()) {
cursor = z80dis::getSymbolAddress(line);
refresh();
}
}
if (!resizing && resizing_type != RESIZING_NONE) { if (!resizing && resizing_type != RESIZING_NONE) {
resizing = true; resizing = true;
@@ -361,6 +387,7 @@ namespace z80debug
uint8_t *memory = z80::getMem(); uint8_t *memory = z80::getMem();
uint16_t pc = cursor; //z80::getPC(); uint16_t pc = cursor; //z80::getPC();
if (sync_mem_with_cursor) mem_viewer_pos = cursor;
uint16_t pos = pc; uint16_t pos = pc;
int num_lines = mem_y-2; int num_lines = mem_y-2;
line_address[(num_lines/2)-1] = pos; line_address[(num_lines/2)-1] = pos;
@@ -430,7 +457,8 @@ namespace z80debug
// STACK // STACK
// ****************************************** // ******************************************
// TODO: Save if stack element was introduced by a call, push or data
// TODO: Click goes to address
ui::setoffset(0, 0); ui::setoffset(0, 0);
ui::box(midx,8,11,sym_y-8,COLOR_WHITE); ui::box(midx,8,11,sym_y-8,COLOR_WHITE);
ui::printrect(midx+2,8, 8,1, COLOR_DARK); ui::printrect(midx+2,8, 8,1, COLOR_DARK);
@@ -457,14 +485,22 @@ namespace z80debug
ui::printrect(midx+13,8, 9,1, COLOR_DARK); ui::printrect(midx+13,8, 9,1, COLOR_DARK);
ui::printtxt(midx+14,8, "BREAKS:", COLOR_WHITE); ui::printtxt(midx+14,8, "BREAKS:", COLOR_WHITE);
ui::setoffset(midx+12, 9); ui::setoffset(midx+12, 9);
int line=0; int line=0;
num_breakpoint_lines=0;
for (int i=0; i<65536; ++i) { for (int i=0; i<65536; ++i) {
if (breakpoints[i]&7) { if (breakpoints[i]&7) {
ui::printtxt(2,line, tohex(i,4), COLOR_WHITE); line_breakpoint_address[line] = i;
ui::printtxt(7,line, breakpoints[i]&1?"x":"-", COLOR_GRAY); num_breakpoint_lines++;
ui::printtxt(8,line, breakpoints[i]&2?"r":"-", COLOR_GRAY); uint8_t colors[2] = {COLOR_WHITE, COLOR_GRAY};
ui::printtxt(9,line, breakpoints[i]&4?"w":"-", COLOR_GRAY); if (i==cursor) {
ui::printrect(1,line,10,1,COLOR_BLUE);
colors[0]=colors[1]=COLOR_YELLOW;
}
ui::printtxt(2,line, tohex(i,4), colors[0]);
ui::printtxt(7,line, breakpoints[i]&1?"x":"-", colors[1]);
ui::printtxt(8,line, breakpoints[i]&2?"r":"-", colors[1]);
ui::printtxt(9,line, breakpoints[i]&4?"w":"-", colors[1]);
line++; line++;
if (line>9) break; if (line>9) break;
} }
@@ -476,15 +512,23 @@ namespace z80debug
ui::setoffset(0, 0); ui::setoffset(0, 0);
ui::box(0,mem_y,midx,mem_h,COLOR_WHITE); ui::box(0,mem_y,midx,mem_h,COLOR_WHITE);
ui::printrect(2,mem_y, 9,1, COLOR_DARK); ui::printrect(2,mem_y, 11,1, COLOR_DARK);
ui::printtxt(3,mem_y, "MEMORY:", COLOR_WHITE); ui::printtxt(3,mem_y, "MEMORY:", COLOR_WHITE);
ui::printvoidrect(10,mem_y,3,1,COLOR_WHITE);
if (sync_mem_with_cursor) ui::printchar(11,mem_y,'X',COLOR_WHITE);
ui::setoffset(1, mem_y+1); ui::setoffset(1, mem_y+1);
uint16_t mem_viewer_cursor = mem_viewer_pos; uint16_t mem_viewer_cursor = mem_viewer_pos;
for (int i=0; i<mem_h-2; ++i) { for (int i=0; i<mem_h-2; ++i) {
ui::printtxt(1,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) { for (int j=0; j<16; ++j) {
const uint8_t tag = z80::getMemTag(mem_viewer_cursor);
const uint32_t color = tag==MEMTAG_NONE ? COLOR_GRAY : tag==MEMTAG_DATA ? COLOR_BLUE : tag==MEMTAG_MIXED ? COLOR_MAGENTA : COLOR_GREEN;
ui::printrect(6+j*3,i,2,1,color);
ui::printrect(54+j,i,1,1,color);
ui::printtxt(6+j*3, i, tohex(memory[mem_viewer_cursor],2), mem_modified[mem_viewer_cursor] ? COLOR_RED : COLOR_WHITE); 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); ui::printchar(54+j, i, memory[mem_viewer_cursor], mem_modified[mem_viewer_cursor] ? COLOR_BROWN : COLOR_GRAY);
mem_viewer_cursor++; mem_viewer_cursor++;
@@ -526,11 +570,18 @@ namespace z80debug
ui::setoffset(midx+1, sym_y+1); ui::setoffset(midx+1, sym_y+1);
const int num_symbols = z80dis::getNumSymbols(); const int num_symbols = z80dis::getNumSymbols();
for (int i=0;i<num_symbols;++i) { for (int i=0;i<num_symbols;++i) {
uint8_t colors[2] = {COLOR_GRAY, COLOR_WHITE};
const uint16_t address = z80dis::getSymbolAddress(i); const uint16_t address = z80dis::getSymbolAddress(i);
ui::printtxt(1, i, tohex(address,4), COLOR_GRAY); if (address==cursor) {
ui::printtxt(6, i, z80dis::getSymbol(address), COLOR_WHITE); ui::printrect(0,line,23,1,COLOR_BLUE);
colors[0]=colors[1]=COLOR_YELLOW;
}
ui::printtxt(1, i, tohex(address,4), colors[0]);
ui::printtxt(6, i, z80dis::getSymbol(address), colors[1]);
} }
if (!is_debugging) { if (!is_debugging) {
SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(ren, 0, 0, 0, 128); SDL_SetRenderDrawColor(ren, 0, 0, 0, 128);

View File

@@ -173,12 +173,11 @@ namespace z80dis
opcode_size+=1; opcode_size+=1;
strcpy(base, buffer); strcpy(base, buffer);
if (opcode_size>4) { if (opcode_size>4) opcode_size=4;
opcode_size=4; sprintf(buffer, base, (int8_t)*(memory+3));
sprintf(buffer, base, (int8_t)*(memory+2)); //} else {
} else { // sprintf(buffer, base, (int8_t)*(memory+1));
sprintf(buffer, base, (int8_t)*(memory+1)); //}
}
} }
return buffer; return buffer;