- [NEW] Més opcions de control del etiquetat de la memòria
- [FIX] Les instruccions DD34 i DD35 no pillaven un byte signed, sino unsigned. Han de haber-ne més. REPASAR. - [ONGOING] Preparant el analyzer per a tindre diverses visualitzacions de la memòria - [NEW] El debugger ara mostra el etiquetat de la memòria en el desensamblador - [FIX] El cursor ja se torna a vore en el debugger
This commit is contained in:
53
z80.cpp
53
z80.cpp
@@ -144,24 +144,48 @@ namespace z80
|
|||||||
|
|
||||||
#define EX(a,b) {auto temp=a;a=b;b=temp;}
|
#define EX(a,b) {auto temp=a;a=b;b=temp;}
|
||||||
|
|
||||||
uint8_t READ_MEM_8(const uint16_t addr)
|
bool reading_m1 = false;
|
||||||
|
|
||||||
|
uint8_t READ_MEM_8(const uint16_t addr, const bool code=false)
|
||||||
{
|
{
|
||||||
if (z80debug::isbreak(addr, 2)) z80debug::stop();
|
if (z80debug::isbreak(addr, 2)) z80debug::stop();
|
||||||
t+=3;
|
t+=3;
|
||||||
memtag[addr] = MEMTAG_DATA;
|
if (memtag[addr] != MEMTAG_IGNORE) {
|
||||||
|
if (!code) {
|
||||||
|
if ( memtag[addr] == MEMTAG_INST ) {
|
||||||
|
printf("WARNING! READING DATA FROM CODE!!! $%4X\n", addr);
|
||||||
|
z80debug::stop();
|
||||||
|
} else {
|
||||||
|
memtag[addr] = MEMTAG_DATA;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( (reading_m1) && (memtag[addr] == MEMTAG_DATA) ) {
|
||||||
|
printf("WARNING! EXECUTING DATA AS CODE!!! $%4X\n", addr);
|
||||||
|
z80debug::stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reading_m1 = false;
|
||||||
return memory[addr];
|
return memory[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t READ_MEM_8()
|
uint8_t READ_MEM_8()
|
||||||
{
|
{
|
||||||
uint8_t data = READ_MEM_8(rPC);
|
uint8_t data = READ_MEM_8(rPC, true);
|
||||||
memtag[rPC++] = MEMTAG_CODE;
|
if ( (memtag[rPC] != MEMTAG_IGNORE) && (memtag[rPC] != MEMTAG_MIXED) ) {
|
||||||
|
if (memtag[rPC] == MEMTAG_DATA)
|
||||||
|
memtag[rPC] = MEMTAG_MIXED;
|
||||||
|
else
|
||||||
|
memtag[rPC] = MEMTAG_CODE;
|
||||||
|
}
|
||||||
|
rPC++;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t READ_M1()
|
uint8_t READ_M1()
|
||||||
{
|
{
|
||||||
t+=1;
|
t+=1;
|
||||||
|
reading_m1 = true;
|
||||||
return READ_MEM_8();
|
return READ_MEM_8();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +208,16 @@ namespace z80
|
|||||||
if (z80debug::isbreak(addr, 4)) z80debug::stop();
|
if (z80debug::isbreak(addr, 4)) z80debug::stop();
|
||||||
//if (z80debug::debugging())
|
//if (z80debug::debugging())
|
||||||
z80debug::setmemmodified(addr);
|
z80debug::setmemmodified(addr);
|
||||||
memtag[addr] = MEMTAG_DATA;
|
if ( (memtag[addr] != MEMTAG_IGNORE) && (memtag[addr] != MEMTAG_MIXED) ) {
|
||||||
|
if (memtag[addr]==MEMTAG_INST) {
|
||||||
|
printf("WARNING! WRITING DATA OVER CODE!!! $%4X\n", addr);
|
||||||
|
z80debug::stop();
|
||||||
|
} else if (memtag[addr] == MEMTAG_CODE) {
|
||||||
|
memtag[addr] = MEMTAG_MIXED;
|
||||||
|
} else {
|
||||||
|
memtag[addr] = MEMTAG_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -1082,7 +1115,7 @@ namespace z80
|
|||||||
current_opcode_address = rPC;
|
current_opcode_address = rPC;
|
||||||
t = 0;
|
t = 0;
|
||||||
const uint8_t opcode = READ_M1();
|
const uint8_t opcode = READ_M1();
|
||||||
memtag[current_opcode_address] = MEMTAG_INST;
|
if (memtag[current_opcode_address] != MEMTAG_IGNORE) memtag[current_opcode_address] = MEMTAG_INST;
|
||||||
memtouched[current_opcode_address] = memtouched[current_opcode_address] != MEMTAG_NONE ? MEMTAG_REPEAT : MEMTAG_INST;
|
memtouched[current_opcode_address] = memtouched[current_opcode_address] != MEMTAG_NONE ? MEMTAG_REPEAT : MEMTAG_INST;
|
||||||
uint16_t tmp;
|
uint16_t tmp;
|
||||||
|
|
||||||
@@ -1717,8 +1750,8 @@ namespace z80
|
|||||||
case 0x31: INVALID(opcode); break;
|
case 0x31: INVALID(opcode); break;
|
||||||
case 0x32: INVALID(opcode); break;
|
case 0x32: INVALID(opcode); break;
|
||||||
case 0x33: INVALID(opcode); break;
|
case 0x33: INVALID(opcode); break;
|
||||||
case 0x34: INCMEM8(rIX+READ_MEM_8());t+=2; break;
|
case 0x34: d=READ_MEM_8(); INCMEM8(rIX+d);t+=2; break;
|
||||||
case 0x35: DECMEM8(rIX+READ_MEM_8());t+=2; break;
|
case 0x35: d=READ_MEM_8(); DECMEM8(rIX+d);t+=2; break;
|
||||||
case 0x36: d=READ_MEM_8(); WRITE_MEM_8(rIX+d, READ_MEM_8()); t+=2; break;
|
case 0x36: d=READ_MEM_8(); WRITE_MEM_8(rIX+d, READ_MEM_8()); t+=2; break;
|
||||||
case 0x37: INVALID(opcode); break;
|
case 0x37: INVALID(opcode); break;
|
||||||
case 0x38: INVALID(opcode); break;
|
case 0x38: INVALID(opcode); break;
|
||||||
@@ -2768,7 +2801,9 @@ namespace z80
|
|||||||
|
|
||||||
void setPC(const uint16_t addr) { rPC = addr; }
|
void setPC(const uint16_t addr) { rPC = addr; }
|
||||||
|
|
||||||
uint8_t getMemTag(const uint16_t addr) { return memtag[addr]; };
|
uint8_t getMemTag(const uint16_t addr) { return memtag[addr]; }
|
||||||
|
|
||||||
|
void setMemTag(const uint16_t addr, const uint8_t value) { memtag[addr] = value; }
|
||||||
|
|
||||||
void clearMemTag()
|
void clearMemTag()
|
||||||
{
|
{
|
||||||
|
|||||||
3
z80.h
3
z80.h
@@ -9,6 +9,8 @@ namespace z80
|
|||||||
#define MEMTAG_CODE 2
|
#define MEMTAG_CODE 2
|
||||||
#define MEMTAG_DATA 3
|
#define MEMTAG_DATA 3
|
||||||
#define MEMTAG_REPEAT 4
|
#define MEMTAG_REPEAT 4
|
||||||
|
#define MEMTAG_MIXED 5
|
||||||
|
#define MEMTAG_IGNORE 6
|
||||||
|
|
||||||
#define Z80_OPTION_STOP_ON_INVALID 0
|
#define Z80_OPTION_STOP_ON_INVALID 0
|
||||||
#define Z80_OPTION_BREAK_ON_INTERRUPT 1
|
#define Z80_OPTION_BREAK_ON_INTERRUPT 1
|
||||||
@@ -39,6 +41,7 @@ namespace z80
|
|||||||
|
|
||||||
void setPC(const uint16_t addr);
|
void setPC(const uint16_t addr);
|
||||||
uint8_t getMemTag(const uint16_t addr);
|
uint8_t getMemTag(const uint16_t addr);
|
||||||
|
void setMemTag(const uint16_t addr, const uint8_t value);
|
||||||
void clearMemTag();
|
void clearMemTag();
|
||||||
|
|
||||||
uint8_t getMemTouched(const uint16_t addr);
|
uint8_t getMemTouched(const uint16_t addr);
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ namespace z80analyze
|
|||||||
if (e->type == SDL_MOUSEBUTTONUP)
|
if (e->type == SDL_MOUSEBUTTONUP)
|
||||||
{
|
{
|
||||||
if (e->button.button == 1)
|
if (e->button.button == 1)
|
||||||
z80::clearMemTouched();
|
//z80::clearMemTouched();
|
||||||
|
z80::clearMemTag();
|
||||||
else
|
else
|
||||||
z80::fixMemTouched();
|
z80::fixMemTouched();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
if (e->type == SDL_MOUSEMOTION)
|
if (e->type == SDL_MOUSEMOTION)
|
||||||
{
|
{
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
refreshTitle();
|
refreshTitle();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@@ -35,7 +37,6 @@ namespace z80analyze
|
|||||||
{
|
{
|
||||||
if (!win)
|
if (!win)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
|
||||||
win = SDL_CreateWindow("Z80 Analyzer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 512, 512, SDL_WINDOW_SHOWN);
|
win = SDL_CreateWindow("Z80 Analyzer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 512, 512, SDL_WINDOW_SHOWN);
|
||||||
ren = SDL_CreateRenderer(win, -1, 0);
|
ren = SDL_CreateRenderer(win, -1, 0);
|
||||||
tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 256, 256);
|
tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 256, 256);
|
||||||
@@ -64,8 +65,11 @@ namespace z80analyze
|
|||||||
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
||||||
for (int i=0; i<65536; ++i)
|
for (int i=0; i<65536; ++i)
|
||||||
{
|
{
|
||||||
uint8_t tag = z80::getMemTouched(i);
|
uint8_t tag = z80::getMemTag(i);
|
||||||
pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_REPEAT ? 0xFF0000 : 0x00FF00;
|
pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_MIXED ? 0xFF00FF : 0x00FF00;
|
||||||
|
|
||||||
|
//uint8_t tag = z80::getMemTouched(i);
|
||||||
|
//pixels[i] = tag==MEMTAG_NONE ? 0x808080 : tag==MEMTAG_DATA ? 0x0000FF : tag==MEMTAG_REPEAT ? 0xFF0000 : 0x00FF00;
|
||||||
}
|
}
|
||||||
pixels[z80::getPC()] = 0xFFFFFF;
|
pixels[z80::getPC()] = 0xFFFFFF;
|
||||||
|
|
||||||
|
|||||||
13
z80debug.cpp
13
z80debug.cpp
@@ -137,6 +137,7 @@ namespace z80debug
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e->type == SDL_MOUSEMOTION) {
|
if (e->type == SDL_MOUSEMOTION) {
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
if (!resizing) {
|
if (!resizing) {
|
||||||
if ( (e->motion.y > (mem_y*CHR_H)-8) && (e->motion.y < (mem_y*CHR_H)+8) && ( e->motion.x < midx*CHR_W ) ) {
|
if ( (e->motion.y > (mem_y*CHR_H)-8) && (e->motion.y < (mem_y*CHR_H)+8) && ( e->motion.x < midx*CHR_W ) ) {
|
||||||
if (resizing_type != RESIZING_MEMORY) SDL_SetCursor(cur_ns);
|
if (resizing_type != RESIZING_MEMORY) SDL_SetCursor(cur_ns);
|
||||||
@@ -313,6 +314,14 @@ namespace z80debug
|
|||||||
if ( (z80::getMemTag(address)==MEMTAG_INST) || heuristics ) {
|
if ( (z80::getMemTag(address)==MEMTAG_INST) || heuristics ) {
|
||||||
const char *sym = z80dis::getSymbol(address);
|
const char *sym = z80dis::getSymbol(address);
|
||||||
if (sym[0]!=0) ui::printtxt(7,line, sym, COLOR_YELLOW);
|
if (sym[0]!=0) ui::printtxt(7,line, sym, COLOR_YELLOW);
|
||||||
|
|
||||||
|
const int opcodesize = z80dis::getOpcodeSize(address);
|
||||||
|
for (int i=0; i<opcodesize; ++i) {
|
||||||
|
const uint8_t tag = z80::getMemTag(address+i);
|
||||||
|
const uint32_t color = tag==MEMTAG_NONE ? COLOR_GRAY : tag==MEMTAG_DATA ? COLOR_BLUE : tag==MEMTAG_MIXED ? COLOR_MAGENTA : COLOR_GREEN;
|
||||||
|
ui::printrect(19+i*3,line,2,1,color);
|
||||||
|
}
|
||||||
|
|
||||||
ui::printtxt(19,line, z80dis::getOpcode(address), colors[2]);
|
ui::printtxt(19,line, z80dis::getOpcode(address), colors[2]);
|
||||||
ui::printtxt(31,line, z80dis::getAsm(address), colors[3]);
|
ui::printtxt(31,line, z80dis::getAsm(address), colors[3]);
|
||||||
} else {
|
} else {
|
||||||
@@ -780,6 +789,10 @@ namespace z80debug
|
|||||||
} else if (strcmp(cmd, "print")==0) {
|
} else if (strcmp(cmd, "print")==0) {
|
||||||
printOpcodesUsed();
|
printOpcodesUsed();
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(cmd, "ignore")==0) {
|
||||||
|
getcmd();
|
||||||
|
int value = getnum(cmd);
|
||||||
|
z80::setMemTag(value, MEMTAG_IGNORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user