diff --git a/z80debug.cpp b/z80debug.cpp index f5e8478..d15aa15 100644 --- a/z80debug.cpp +++ b/z80debug.cpp @@ -20,7 +20,7 @@ namespace z80debug int midx = 58; int mem_y = 20; int con_y = 28; - int sym_y = 20; + int sym_y = 24; int win_h = 44; int mem_h = 8; int con_h = 6; @@ -73,6 +73,8 @@ namespace z80debug int search_sequence_len=0; uint16_t search_pos=0; + uint16_t inspected_value = 255; + char temp[256]; const char *tohex(int value, int numdigits) { @@ -80,6 +82,14 @@ namespace z80debug else if (numdigits==4) sprintf(temp, "%04X", value); return temp; } + const char *todec(int value, bool sign) + { + if (sign) + sprintf(temp, "%i", int8_t(value)); + else + sprintf(temp, "%u", value); + return temp; + } bool eventHandler(SDL_Event *e) { @@ -92,7 +102,7 @@ namespace z80debug win_h = (h/CHR_H); mem_y = win_h - mem_h - con_h; con_y = win_h - con_h; - sym_y = win_h - sym_h; + sym_h = win_h - sym_y; z80debug::refresh(); zxscreen::redraw(); } else if (e->window.event == SDL_WINDOWEVENT_CLOSE) { @@ -111,10 +121,10 @@ namespace z80debug } } else if (e->wheel.mouseXwheel.mouseY>=mem_y*CHR_H && e->wheel.mouseYwheel.y>0) { - mem_viewer_pos+=0x10; + mem_viewer_pos-=0x10; z80debug::refresh(); } else if (e->wheel.y<0) { - mem_viewer_pos-=0x10; + mem_viewer_pos+=0x10; z80debug::refresh(); } } @@ -169,6 +179,55 @@ namespace z80debug if (resizing_type != RESIZING_NONE) SDL_SetCursor(cur_df); resizing_type = RESIZING_NONE; } + + const int chrx = e->motion.x/CHR_W; + const int chry = e->motion.y/CHR_H; + //printf("%ix%i\n", chrx, chry); + // Si pasa per damunt de l'adreça en el desensamblador + if ( (chrx>1) && (chrx<6) && (chry0) ) { + inspected_value = line_address[chry-1]; + refresh(); + // Si pasa per damunt dels bytes que formen el opcode en el desensamblador + } else if ((chrx>=19) && (chrx<30) && (chry0)) { + const uint16_t address = line_address[chry-1]; + const int opcodesize = z80dis::getOpcodeSize(address); + const int byte = (chrx-19)/3; + if (byte < opcodesize) { + inspected_value = z80::getMem()[address+byte]; + refresh(); + } + // Si pasa per damunt de l'adreça en el visor de memòria + } else if ((chrx>1) && (chrx<6) && (chry>mem_y) && (chry6) && (chrx<55) && (chry>mem_y) && (chry=midx+4) && (chrx=midx+4) && (chrx=midx+4) && (chrx=midx+4) && (chrx=midx+12) && (chrx=midx+12) && (chrx=midx+12) && (chrx=midx+12) && (chrx=midx+20) && (chrx=midx+20) && (chrx=midx+20) && (chrx=midx+20) && (chrx=midx+6) && (chrx=midx+14) && (chrx=midx+22) && (chrx=midx+17) && (chrx=midx+22) && (chrxmotion.y/CHR_H; @@ -473,12 +532,12 @@ namespace z80debug // TODO: Save if stack element was introduced by a call, push or data // TODO: Click goes to address ui::setoffset(0, 0); - ui::box(midx,8,11,sym_y-8,COLOR_WHITE); + ui::box(midx,8,11,12,COLOR_WHITE); ui::printrect(midx+2,8, 8,1, COLOR_DARK); ui::printtxt(midx+3,8, "STACK:", COLOR_WHITE); ui::setoffset(midx+1, 9); - uint16_t sp = z80::getSP()-(((sym_y-12)>>1)<<1); - for (int i=0; i>1)<<1); + for (int i=0; i<10; ++i) { uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY; if (sp == z80::getSP()) { ui::printrect(0,i,9,1,COLOR_BLUE); @@ -494,7 +553,7 @@ namespace z80debug // ****************************************** ui::setoffset(0, 0); - ui::box(midx+11,8,14,sym_y-8,COLOR_WHITE); + ui::box(midx+11,8,14,12,COLOR_WHITE); ui::printrect(midx+13,8, 9,1, COLOR_DARK); ui::printtxt(midx+14,8, "BREAKS:", COLOR_WHITE); ui::setoffset(midx+12, 9); @@ -520,6 +579,26 @@ namespace z80debug } + // INSPECTOR + // ****************************************** + + ui::setoffset(0, 0); + ui::box(midx,20,25,4,COLOR_WHITE); + ui::printrect(midx+2,20,12,1, COLOR_DARK); + ui::printtxt(midx+3,20, "INSPECTOR:", COLOR_WHITE); + ui::setoffset(midx+1, 21); + + ui::printtxt(1,0,"VALUE:", COLOR_GRAY); ui::printtxt(8,0,"$", COLOR_CYAN); + ui::printtxt(9,0,tohex(inspected_value,4), COLOR_CYAN); + ui::printtxt(14,0,todec(inspected_value,false), COLOR_WHITE); + ui::printtxt(20,0,todec(inspected_value,true), COLOR_WHITE); + ui::printtxt(1,1,"H:", COLOR_GRAY); ui::printtxt(4,1,"$", COLOR_CYAN); + ui::printtxt(5,1,tohex(inspected_value>>8,2), COLOR_CYAN); + ui::printtxt(8,1,todec(inspected_value>>8,false), COLOR_WHITE); + ui::printtxt(12,1,"L:", COLOR_GRAY); ui::printtxt(15,1,"$", COLOR_CYAN); + ui::printtxt(16,1,tohex(inspected_value&0xff,2), COLOR_CYAN); + ui::printtxt(19,1,todec(inspected_value&0xff,false), COLOR_WHITE); + // MEMORY // ******************************************