- [FIX] Corregit el acces als port amb OUT
- [NEW] Nou model de gestió de memòria
This commit is contained in:
54
z80debug.cpp
54
z80debug.cpp
@@ -2,7 +2,7 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include "z80.h"
|
||||
#include "z80dis.h"
|
||||
#include "z80mem.h"
|
||||
#include "zx_mem.h"
|
||||
#include "z80analyze.h"
|
||||
#include "zx_ula.h"
|
||||
#include "zx_tape.h"
|
||||
@@ -198,7 +198,7 @@ namespace z80debug
|
||||
const int opcodesize = z80dis::getOpcodeSize(address);
|
||||
const int byte = (chrx-19)/3;
|
||||
if (byte < opcodesize) {
|
||||
inspected_value = z80mem::get()->readMem(address+byte);
|
||||
inspected_value = mem::readMem(address+byte);
|
||||
refresh();
|
||||
}
|
||||
// Si pasa per damunt de l'adreça en el visor de memòria
|
||||
@@ -208,7 +208,7 @@ namespace z80debug
|
||||
// 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 = z80mem::get()->readMem(address);
|
||||
inspected_value = mem::readMem(address);
|
||||
refresh();
|
||||
// Si pasa per damunt d'un registre
|
||||
} else if ((chrx>=midx+4) && (chrx<midx+8) && (chry==1)) { inspected_value = z80::getAF(); refresh();
|
||||
@@ -224,9 +224,9 @@ namespace z80debug
|
||||
} 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 = z80mem::get()->readMem(z80::getBC()); refresh();
|
||||
} else if ((chrx>=midx+14) && (chrx<midx+16) && (chry==5)) { inspected_value = z80mem::get()->readMem(z80::getDE()); refresh();
|
||||
} else if ((chrx>=midx+22) && (chrx<midx+24) && (chry==5)) { inspected_value = z80mem::get()->readMem(z80::getHL()); refresh();
|
||||
} else if ((chrx>=midx+6) && (chrx<midx+8) && (chry==5)) { inspected_value = mem::readMem(z80::getBC()); refresh();
|
||||
} else if ((chrx>=midx+14) && (chrx<midx+16) && (chry==5)) { inspected_value = mem::readMem(z80::getDE()); refresh();
|
||||
} else if ((chrx>=midx+22) && (chrx<midx+24) && (chry==5)) { inspected_value = mem::readMem(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();
|
||||
@@ -393,10 +393,10 @@ namespace z80debug
|
||||
uint16_t find_previous_opcode(uint16_t pc)
|
||||
{
|
||||
pc--;
|
||||
uint8_t tag = z80mem::get()->getTag(pc);
|
||||
uint8_t tag = mem::getTag(pc);
|
||||
if ( !(tag & (MEMTAG_CODE | MEMTAG_INST) ) ) return pc;
|
||||
|
||||
while ( !(z80mem::get()->getTag(pc) & MEMTAG_INST) ) pc--;
|
||||
while ( !(mem::getTag(pc) & MEMTAG_INST) ) pc--;
|
||||
|
||||
return pc;
|
||||
/*
|
||||
@@ -416,7 +416,7 @@ namespace z80debug
|
||||
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
||||
{
|
||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_WHITE, COLOR_WHITE};
|
||||
const uint8_t tag = z80mem::get()->getTag(address);
|
||||
const uint8_t tag = mem::getTag(address);
|
||||
if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) colors[3]=COLOR_GRAY;
|
||||
if ( !(tag & MEMTAG_TOUCHED) ) colors[1]=COLOR_GRAY;
|
||||
|
||||
@@ -434,7 +434,7 @@ namespace z80debug
|
||||
|
||||
const int opcodesize = z80dis::getOpcodeSize(address);
|
||||
for (int i=0; i<opcodesize; ++i) {
|
||||
const uint8_t tag = z80mem::get()->getTag(address+i);
|
||||
const uint8_t tag = mem::getTag(address+i);
|
||||
const uint32_t color = !(tag & MEMTAG_KNOWN) ? COLOR_GRAY : (tag & MEMTAG_DATA) ? ( (tag & (MEMTAG_CODE|MEMTAG_INST)) ? COLOR_MAGENTA : COLOR_BLUE ) : COLOR_GREEN;
|
||||
ui::printrect(19+i*3,line,2,1,color);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ namespace z80debug
|
||||
ui::printtxt(31,line, z80dis::getAsm(address), colors[3]);
|
||||
} else {
|
||||
ui::printrect(19,line,2,1,COLOR_GRAY);
|
||||
ui::printtxt(19,line, tohex(z80mem::get()->readMem(address),2), COLOR_WHITE);
|
||||
ui::printtxt(19,line, tohex(mem::readMem(address),2), COLOR_WHITE);
|
||||
ui::printtxt(31,line, "?????????", COLOR_GRAY);
|
||||
}
|
||||
}
|
||||
@@ -517,9 +517,9 @@ namespace z80debug
|
||||
ui::printtxt(16,5, tohex(z80::getI(), 2), oI != z80::getI() ? COLOR_RED : COLOR_GRAY);
|
||||
ui::printtxt(21,5, tohex(z80::getR(), 2), oR != z80::getR() ? COLOR_RED : COLOR_GRAY);
|
||||
|
||||
ui::printtxt(5,4, tohex(z80mem::get()->readMem(z80::getBC()), 2), COLOR_GRAY);
|
||||
ui::printtxt(13,4, tohex(z80mem::get()->readMem(z80::getDE()), 2), COLOR_GRAY);
|
||||
ui::printtxt(21,4, tohex(z80mem::get()->readMem(z80::getHL()), 2), COLOR_GRAY);
|
||||
ui::printtxt(5,4, tohex(mem::readMem(z80::getBC()), 2), COLOR_GRAY);
|
||||
ui::printtxt(13,4, tohex(mem::readMem(z80::getDE()), 2), COLOR_GRAY);
|
||||
ui::printtxt(21,4, tohex(mem::readMem(z80::getHL()), 2), COLOR_GRAY);
|
||||
|
||||
const uint8_t flags = (z80::getAF() & 0xFF);
|
||||
const uint8_t mod_flags = flags ^ (oAF & 0xFF);
|
||||
@@ -548,7 +548,7 @@ namespace z80debug
|
||||
c1 = c2 = COLOR_YELLOW;
|
||||
}
|
||||
ui::printtxt(0,i, tohex(sp, 4), c1);
|
||||
uint16_t value = z80mem::get()->readMem(sp) + (z80mem::get()->readMem(sp+1)<<8);
|
||||
uint16_t value = mem::readMem(sp) + (mem::readMem(sp+1)<<8);
|
||||
ui::printtxt(5,i, tohex(value, 4), c2);
|
||||
sp+=2;
|
||||
}
|
||||
@@ -622,12 +622,12 @@ namespace z80debug
|
||||
ui::printtxt(1,i, tohex(mem_viewer_cursor, 4), COLOR_CYAN);
|
||||
for (int j=0; j<16; ++j) {
|
||||
|
||||
const uint8_t tag = z80mem::get()->getTag(mem_viewer_cursor);
|
||||
const uint8_t tag = mem::getTag(mem_viewer_cursor);
|
||||
const uint32_t color = !(tag & MEMTAG_KNOWN) ? COLOR_GRAY : (tag & MEMTAG_DATA) ? ( (tag & (MEMTAG_CODE|MEMTAG_INST)) ? COLOR_MAGENTA : COLOR_BLUE ) : 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(z80mem::get()->readMem(mem_viewer_cursor), 2), ( tag & MEMTAG_MODIFIED) ? COLOR_RED : COLOR_WHITE);
|
||||
ui::printchar(54+j, i, z80mem::get()->readMem(mem_viewer_cursor), ( tag & MEMTAG_MODIFIED) ? COLOR_BROWN : COLOR_GRAY);
|
||||
ui::printtxt(6+j*3, i, tohex(mem::readMem(mem_viewer_cursor), 2), ( tag & MEMTAG_MODIFIED) ? COLOR_RED : COLOR_WHITE);
|
||||
ui::printchar(54+j, i, mem::readMem(mem_viewer_cursor), ( tag & MEMTAG_MODIFIED) ? 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);
|
||||
@@ -881,11 +881,11 @@ namespace z80debug
|
||||
int address = getnum(cmd);
|
||||
getcmd();
|
||||
int value = getnum(cmd);
|
||||
z80mem::get()->writeMem(address, value);
|
||||
mem::writeMem(address, value);
|
||||
} else if (strcmp(cmd, "peek")==0) {
|
||||
getcmd();
|
||||
int address = getnum(cmd);
|
||||
int value = z80mem::get()->readMem(address);
|
||||
int value = mem::readMem(address);
|
||||
char tmp[10];
|
||||
sendToConsoleLog(SDL_itoa(value, tmp, 10));
|
||||
} else if (strcmp(cmd, "reg")==0) {
|
||||
@@ -904,7 +904,7 @@ namespace z80debug
|
||||
getcmd();
|
||||
int address = getnum(cmd);
|
||||
if (address<0 || address>=65536) { sendToConsoleLog("Illegal address"); return; }
|
||||
if ( !(z80mem::get()->getTag(address) & MEMTAG_INST) ) address = find_previous_opcode(address);
|
||||
if ( !(mem::getTag(address) & MEMTAG_INST) ) address = find_previous_opcode(address);
|
||||
z80debug::setcursor(address);
|
||||
} else if (strcmp(cmd, "sym")==0 || strcmp(cmd, "symbol")==0) {
|
||||
getcmd();
|
||||
@@ -956,7 +956,7 @@ namespace z80debug
|
||||
} else if (strcmp(cmd, "ignore")==0) {
|
||||
getcmd();
|
||||
const int address = getnum(cmd);
|
||||
z80mem::get()->setTag(address, z80mem::get()->getTag(address) | MEMTAG_IGNORE);
|
||||
mem::setTag(address, mem::getTag(address) | MEMTAG_IGNORE);
|
||||
} else if (strcmp(cmd, "search")==0) {
|
||||
getcmd();
|
||||
if (strcmp(cmd, "next")==0) {
|
||||
@@ -1013,7 +1013,7 @@ namespace z80debug
|
||||
int size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
uint32_t memsize;
|
||||
uint8_t *memory = z80mem::get()->getRawPointer(&memsize);
|
||||
uint8_t *memory = mem::getRawPointer(&memsize);
|
||||
fread(memory+address, size, 1, f);
|
||||
fclose(f);
|
||||
z80::setPC(address);
|
||||
@@ -1026,7 +1026,7 @@ namespace z80debug
|
||||
uint8_t *regs = z80::getRegs();
|
||||
FILE *f = fopen(filename, "wb");
|
||||
fwrite(regs, 31, 1, f);
|
||||
z80mem::get()->saveState(f);
|
||||
mem::saveState(f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -1035,7 +1035,7 @@ namespace z80debug
|
||||
uint8_t *regs = z80::getRegs();
|
||||
FILE *f = fopen(filename, "rb");
|
||||
fread(regs, 31, 1, f);
|
||||
z80mem::get()->loadState(f);
|
||||
mem::loadState(f);
|
||||
fclose(f);
|
||||
history::store();
|
||||
history::gototop();
|
||||
@@ -1044,7 +1044,7 @@ namespace z80debug
|
||||
void setcursor(const uint16_t address)
|
||||
{
|
||||
//if (!debugging()) return;
|
||||
if ( !(z80mem::get()->getTag(address) & MEMTAG_INST) )
|
||||
if ( !(mem::getTag(address) & MEMTAG_INST) )
|
||||
cursor = find_previous_opcode(address);
|
||||
else
|
||||
cursor = address;
|
||||
@@ -1135,7 +1135,7 @@ namespace z80debug
|
||||
}
|
||||
int num_found=0;
|
||||
while (search_pos<65536) {
|
||||
if (search_sequence[num_found] == z80mem::get()->readMem(search_pos)) {
|
||||
if (search_sequence[num_found] == mem::readMem(search_pos)) {
|
||||
num_found++; search_pos++;
|
||||
if (num_found==search_sequence_len) {
|
||||
mem_viewer_pos=search_pos-search_sequence_len;
|
||||
|
||||
Reference in New Issue
Block a user