- [NEW] Inspector de memòria. Pasar per damunt d'un valor per a vore'l en 16bits, les dos parts de 8 bits, i amb signe.
This commit is contained in:
95
z80debug.cpp
95
z80debug.cpp
@@ -20,7 +20,7 @@ namespace z80debug
|
|||||||
int midx = 58;
|
int midx = 58;
|
||||||
int mem_y = 20;
|
int mem_y = 20;
|
||||||
int con_y = 28;
|
int con_y = 28;
|
||||||
int sym_y = 20;
|
int sym_y = 24;
|
||||||
int win_h = 44;
|
int win_h = 44;
|
||||||
int mem_h = 8;
|
int mem_h = 8;
|
||||||
int con_h = 6;
|
int con_h = 6;
|
||||||
@@ -73,6 +73,8 @@ namespace z80debug
|
|||||||
int search_sequence_len=0;
|
int search_sequence_len=0;
|
||||||
uint16_t search_pos=0;
|
uint16_t search_pos=0;
|
||||||
|
|
||||||
|
uint16_t inspected_value = 255;
|
||||||
|
|
||||||
char temp[256];
|
char temp[256];
|
||||||
const char *tohex(int value, int numdigits)
|
const char *tohex(int value, int numdigits)
|
||||||
{
|
{
|
||||||
@@ -80,6 +82,14 @@ namespace z80debug
|
|||||||
else if (numdigits==4) sprintf(temp, "%04X", value);
|
else if (numdigits==4) sprintf(temp, "%04X", value);
|
||||||
return temp;
|
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)
|
bool eventHandler(SDL_Event *e)
|
||||||
{
|
{
|
||||||
@@ -92,7 +102,7 @@ namespace z80debug
|
|||||||
win_h = (h/CHR_H);
|
win_h = (h/CHR_H);
|
||||||
mem_y = win_h - mem_h - con_h;
|
mem_y = win_h - mem_h - con_h;
|
||||||
con_y = win_h - con_h;
|
con_y = win_h - con_h;
|
||||||
sym_y = win_h - sym_h;
|
sym_h = win_h - sym_y;
|
||||||
z80debug::refresh();
|
z80debug::refresh();
|
||||||
zxscreen::redraw();
|
zxscreen::redraw();
|
||||||
} else if (e->window.event == SDL_WINDOWEVENT_CLOSE) {
|
} else if (e->window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||||
@@ -111,10 +121,10 @@ namespace z80debug
|
|||||||
}
|
}
|
||||||
} else if (e->wheel.mouseX<midx*CHR_W && e->wheel.mouseY>=mem_y*CHR_H && e->wheel.mouseY<con_y*CHR_H) {
|
} else if (e->wheel.mouseX<midx*CHR_W && e->wheel.mouseY>=mem_y*CHR_H && e->wheel.mouseY<con_y*CHR_H) {
|
||||||
if (e->wheel.y>0) {
|
if (e->wheel.y>0) {
|
||||||
mem_viewer_pos+=0x10;
|
mem_viewer_pos-=0x10;
|
||||||
z80debug::refresh();
|
z80debug::refresh();
|
||||||
} else if (e->wheel.y<0) {
|
} else if (e->wheel.y<0) {
|
||||||
mem_viewer_pos-=0x10;
|
mem_viewer_pos+=0x10;
|
||||||
z80debug::refresh();
|
z80debug::refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,6 +179,55 @@ namespace z80debug
|
|||||||
if (resizing_type != RESIZING_NONE) SDL_SetCursor(cur_df);
|
if (resizing_type != RESIZING_NONE) SDL_SetCursor(cur_df);
|
||||||
resizing_type = RESIZING_NONE;
|
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) && (chry<mem_y-1) && (chry>0) ) {
|
||||||
|
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) && (chry<mem_y-1) && (chry>0)) {
|
||||||
|
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) && (chry<mem_y+mem_h-1)) {
|
||||||
|
inspected_value = mem_viewer_pos + (chry-mem_y-1)*16;
|
||||||
|
refresh();
|
||||||
|
// Si pasa per damunt d'un byte en el visor de memòria
|
||||||
|
} else if ((chrx>6) && (chrx<55) && (chry>mem_y) && (chry<mem_y+mem_h-1)) {
|
||||||
|
const uint16_t address = mem_viewer_pos + (chry-mem_y-1)*16 + (chrx-7)/3;
|
||||||
|
inspected_value = z80::getMem()[address];
|
||||||
|
refresh();
|
||||||
|
// Si pasa per damunt d'un registre
|
||||||
|
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==1)) { inspected_value = z80::getAF(); refresh();
|
||||||
|
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==2)) { inspected_value = z80::getBC(); refresh();
|
||||||
|
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==3)) { inspected_value = z80::getDE(); refresh();
|
||||||
|
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==4)) { inspected_value = z80::getHL(); refresh();
|
||||||
|
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==1)) { inspected_value = z80::getAF(true); refresh();
|
||||||
|
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==2)) { inspected_value = z80::getBC(true); refresh();
|
||||||
|
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==3)) { inspected_value = z80::getDE(true); refresh();
|
||||||
|
} else if ((chrx>=midx+12) && (chrx<midx+16) && (chry==4)) { inspected_value = z80::getHL(true); refresh();
|
||||||
|
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==1)) { inspected_value = z80::getIX(); refresh();
|
||||||
|
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==2)) { inspected_value = z80::getIY(); refresh();
|
||||||
|
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==3)) { inspected_value = z80::getSP(); refresh();
|
||||||
|
} else if ((chrx>=midx+20) && (chrx<midx+24) && (chry==4)) { inspected_value = z80::getPC(); refresh();
|
||||||
|
|
||||||
|
} else if ((chrx>=midx+6) && (chrx<midx+8) && (chry==5)) { inspected_value = z80::getMem()[z80::getBC()]; refresh();
|
||||||
|
} else if ((chrx>=midx+14) && (chrx<midx+16) && (chry==5)) { inspected_value = z80::getMem()[z80::getDE()]; refresh();
|
||||||
|
} else if ((chrx>=midx+22) && (chrx<midx+24) && (chry==5)) { inspected_value = z80::getMem()[z80::getHL()]; refresh();
|
||||||
|
|
||||||
|
} else if ((chrx>=midx+17) && (chrx<midx+19) && (chry==6)) { inspected_value = z80::getI(); refresh();
|
||||||
|
} else if ((chrx>=midx+22) && (chrx<midx+24) && (chry==6)) { inspected_value = z80::getR(); refresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (resizing_type==RESIZING_MEMORY) {
|
if (resizing_type==RESIZING_MEMORY) {
|
||||||
const int new_mem_y = e->motion.y/CHR_H;
|
const int new_mem_y = e->motion.y/CHR_H;
|
||||||
@@ -473,12 +532,12 @@ namespace z80debug
|
|||||||
// TODO: Save if stack element was introduced by a call, push or data
|
// TODO: Save if stack element was introduced by a call, push or data
|
||||||
// TODO: Click goes to address
|
// 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,12,COLOR_WHITE);
|
||||||
ui::printrect(midx+2,8, 8,1, COLOR_DARK);
|
ui::printrect(midx+2,8, 8,1, COLOR_DARK);
|
||||||
ui::printtxt(midx+3,8, "STACK:", COLOR_WHITE);
|
ui::printtxt(midx+3,8, "STACK:", COLOR_WHITE);
|
||||||
ui::setoffset(midx+1, 9);
|
ui::setoffset(midx+1, 9);
|
||||||
uint16_t sp = z80::getSP()-(((sym_y-12)>>1)<<1);
|
uint16_t sp = z80::getSP();//-(((sym_y-12)>>1)<<1);
|
||||||
for (int i=0; i<sym_y-10; ++i) {
|
for (int i=0; i<10; ++i) {
|
||||||
uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY;
|
uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY;
|
||||||
if (sp == z80::getSP()) {
|
if (sp == z80::getSP()) {
|
||||||
ui::printrect(0,i,9,1,COLOR_BLUE);
|
ui::printrect(0,i,9,1,COLOR_BLUE);
|
||||||
@@ -494,7 +553,7 @@ namespace z80debug
|
|||||||
// ******************************************
|
// ******************************************
|
||||||
|
|
||||||
ui::setoffset(0, 0);
|
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::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);
|
||||||
@@ -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
|
// MEMORY
|
||||||
// ******************************************
|
// ******************************************
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user