- [NEW] Configuració per a compilar i depurar des de vscode
- [FIX] Meimades per a que es calle el compilaor al dir-li -Wall - [NEW] Reestructurats els simbols, 6502dis probablement acabe desapareguent - [NEW] Reactivats els breakpoints i next (pas a pas sense entrar en subrutines) - [NEW] Nou motor de desensamblat - [NEW] Ja es mostren tots els simbols en el desensamblat - [NEW] Syntax colorets en el desensamblat
This commit is contained in:
Vendored
+16
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/atari2600_debug",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"preLaunchTask": "Build Debug",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build Debug",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "lagueirto",
|
||||||
|
"args": [
|
||||||
|
"linux_debug"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$gcc"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+79
-17
@@ -269,8 +269,8 @@ namespace m6502debugger
|
|||||||
|
|
||||||
if (chrx>=midx+2 && chry>=sym_y+1) {
|
if (chrx>=midx+2 && chry>=sym_y+1) {
|
||||||
const int line = chry-(sym_y+1);
|
const int line = chry-(sym_y+1);
|
||||||
if (line<m6502dis::getNumSymbols()) {
|
if (line<m6502dis::symbols::count()) {
|
||||||
cursor = m6502dis::getSymbolAddress(line);
|
cursor = m6502dis::symbols::address(line);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,6 +312,12 @@ namespace m6502debugger
|
|||||||
|
|
||||||
setcursor(address);
|
setcursor(address);
|
||||||
history::store();
|
history::store();
|
||||||
|
|
||||||
|
if (!atari2600::is_paused() && isbreak(address, BREAKPOINT_EXECUTE | BREAKPOINT_NEXT)) {
|
||||||
|
atari2600::pause();
|
||||||
|
m6502debugger::show();
|
||||||
|
breakpoints[address] = breakpoints[address] & ~BREAKPOINT_NEXT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onMemRead(uint16_t address, bool code)
|
void onMemRead(uint16_t address, bool code)
|
||||||
@@ -434,13 +440,67 @@ namespace m6502debugger
|
|||||||
//return pc;
|
//return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printAssemblerLine(const uint16_t address, const int line, const bool confirmed)
|
||||||
|
{
|
||||||
|
uint8_t column = 31;
|
||||||
|
uint8_t colors[4] = {COLOR_PURPLE, COLOR_TEAL, COLOR_GRAY, COLOR_ORANGE};
|
||||||
|
if (confirmed) for (int i=0; i<4; ++i) colors[i] += 8; //{COLOR_MAGENTA, COLOR_BLUE, COLOR_WHITE, COLOR_YELLOW};
|
||||||
|
m6502::opcodes::opcodeProperties op = m6502::opcodes::opcodeDescriptors[mem::read(address)];
|
||||||
|
const char *opcode_name = m6502::opcodes::instructions[op.instr].name;
|
||||||
|
ui::printtxt(column,line, opcode_name, colors[0]);
|
||||||
|
column += strlen(opcode_name)+1;
|
||||||
|
const char *opcode_prefix = m6502::opcodes::addressingModes[op.addrMode].preText;
|
||||||
|
const char *opcode_postfix = m6502::opcodes::addressingModes[op.addrMode].postText;
|
||||||
|
if (strlen(opcode_prefix)>0) {
|
||||||
|
ui::printtxt(column,line, opcode_prefix, colors[1]);
|
||||||
|
column += strlen(opcode_prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[256];
|
||||||
|
uint16_t value = 0;
|
||||||
|
const uint8_t len = m6502::opcodes::addressingModes[op.addrMode].length;
|
||||||
|
if (len>1) {
|
||||||
|
value = mem::read(address+1);
|
||||||
|
if (len>2) value |= (mem::read(address+2) << 8);
|
||||||
|
|
||||||
|
if (op.addrMode != m6502::opcodes::amImmediate && op.addrMode != m6502::opcodes::amRelative &&
|
||||||
|
( m6502::opcodes::instructions[op.instr].group == m6502::opcodes::fgLoadStore || m6502::opcodes::instructions[op.instr].group == m6502::opcodes::fgJumpCall )) {
|
||||||
|
if (m6502dis::symbols::get(value)[0]!=0) {
|
||||||
|
sprintf(buffer, "%s", m6502dis::symbols::get(value));
|
||||||
|
ui::printtxt(column,line, buffer, colors[2]);
|
||||||
|
column += strlen(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buffer[0] == 0) {
|
||||||
|
if (len==3) {
|
||||||
|
value |= (mem::read(address+2) << 8);
|
||||||
|
sprintf(buffer, "$%04x", value);
|
||||||
|
} else if (len==2) {
|
||||||
|
if (op.addrMode == m6502::opcodes::amRelative) {
|
||||||
|
sprintf(buffer, "%hhd", value);
|
||||||
|
} else {
|
||||||
|
sprintf(buffer, "$%02x", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui::printtxt(column,line, buffer, colors[3]);
|
||||||
|
column += strlen(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(opcode_postfix)>0) {
|
||||||
|
ui::printtxt(column,line, opcode_postfix, colors[1]);
|
||||||
|
//column += strlen(opcode_prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
||||||
{
|
{
|
||||||
const bool isMemory = mem::debug::getInfo(address).memType & mdtMemory;
|
const bool isMemory = mem::debug::getInfo(address).memType & mdtMemory;
|
||||||
|
bool isConfirmedInstruction = true;
|
||||||
|
|
||||||
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_WHITE, COLOR_WHITE};
|
uint8_t colors[4] = { COLOR_RED, COLOR_CYAN, COLOR_WHITE, COLOR_WHITE};
|
||||||
const uint8_t tag = tags[address];
|
const uint8_t tag = tags[address];
|
||||||
if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) colors[3]=COLOR_GRAY;
|
if ( !(tag & (MEMTAG_TINST | MEMTAG_TREPEAT)) ) { colors[3]=COLOR_GRAY; isConfirmedInstruction = false; }
|
||||||
if ( !(tag & MEMTAG_TOUCHED) ) colors[1]=COLOR_GRAY;
|
if ( !(tag & MEMTAG_TOUCHED) ) colors[1]=COLOR_GRAY;
|
||||||
|
|
||||||
if (atari2600::is_paused() && (address == m6502::getPC())) {
|
if (atari2600::is_paused() && (address == m6502::getPC())) {
|
||||||
@@ -454,7 +514,7 @@ namespace m6502debugger
|
|||||||
if (!isMemory) return;
|
if (!isMemory) return;
|
||||||
|
|
||||||
if ( (tag & MEMTAG_INST) || heuristics ) {
|
if ( (tag & MEMTAG_INST) || heuristics ) {
|
||||||
const char *sym = m6502dis::getSymbol(address);
|
const char *sym = m6502dis::symbols::get(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 = m6502dis::getOpcodeSize(address);
|
const int opcodesize = m6502dis::getOpcodeSize(address);
|
||||||
@@ -465,7 +525,8 @@ namespace m6502debugger
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui::printtxt(19,line, m6502dis::getOpcode(address), colors[2]);
|
ui::printtxt(19,line, m6502dis::getOpcode(address), colors[2]);
|
||||||
ui::printtxt(31,line, m6502dis::getAsm(address), colors[3]);
|
//ui::printtxt(31,line, m6502dis::getAsm(address), colors[3]);
|
||||||
|
printAssemblerLine(address, line, isConfirmedInstruction);
|
||||||
} else {
|
} else {
|
||||||
ui::printrect(19,line,2,1,COLOR_GRAY);
|
ui::printrect(19,line,2,1,COLOR_GRAY);
|
||||||
ui::printtxt(19,line, tohex(mem::read(address),2), COLOR_WHITE);
|
ui::printtxt(19,line, tohex(mem::read(address),2), COLOR_WHITE);
|
||||||
@@ -719,18 +780,18 @@ namespace m6502debugger
|
|||||||
ui::printtxt(midx+3,sym_y, "SYMBOLS:", COLOR_WHITE);
|
ui::printtxt(midx+3,sym_y, "SYMBOLS:", COLOR_WHITE);
|
||||||
|
|
||||||
ui::setoffset(midx+1, sym_y+1);
|
ui::setoffset(midx+1, sym_y+1);
|
||||||
const int num_symbols = m6502dis::getNumSymbols();
|
const int num_symbols = m6502dis::symbols::count();
|
||||||
for (int i=0;i<num_symbols;++i) {
|
for (int i=0;i<num_symbols;++i) {
|
||||||
if (i>=sym_h-2) break;
|
if (i>=sym_h-2) break;
|
||||||
uint8_t colors[2] = {COLOR_GRAY, COLOR_WHITE};
|
uint8_t colors[2] = {COLOR_GRAY, COLOR_WHITE};
|
||||||
const uint16_t address = m6502dis::getSymbolAddress(i);
|
const uint16_t address = m6502dis::symbols::address(i);
|
||||||
if (address==cursor) {
|
if (address==cursor) {
|
||||||
ui::printrect(0,line,23,1,COLOR_BLUE);
|
ui::printrect(0,line,23,1,COLOR_BLUE);
|
||||||
colors[0]=colors[1]=COLOR_YELLOW;
|
colors[0]=colors[1]=COLOR_YELLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui::printtxt(1, i, tohex(address,4), colors[0]);
|
ui::printtxt(1, i, tohex(address,4), colors[0]);
|
||||||
ui::printtxt(6, i, m6502dis::getSymbol(address), colors[1]);
|
ui::printtxt(6, i, m6502dis::symbols::get(address), colors[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -864,11 +925,11 @@ namespace m6502debugger
|
|||||||
uint8_t break_type = 1;
|
uint8_t break_type = 1;
|
||||||
if (cmd[0]!=0) {
|
if (cmd[0]!=0) {
|
||||||
if (strcmp(cmd, "x")==0 || strcmp(cmd, "exec")==0) {
|
if (strcmp(cmd, "x")==0 || strcmp(cmd, "exec")==0) {
|
||||||
break_type = 1;
|
break_type = BREAKPOINT_EXECUTE;
|
||||||
} else if (strcmp(cmd, "r")==0 || strcmp(cmd, "read")==0) {
|
} else if (strcmp(cmd, "r")==0 || strcmp(cmd, "read")==0) {
|
||||||
break_type = 2;
|
break_type = BREAKPOINT_READ;
|
||||||
} else if (strcmp(cmd, "w")==0 || strcmp(cmd, "write")==0) {
|
} else if (strcmp(cmd, "w")==0 || strcmp(cmd, "write")==0) {
|
||||||
break_type = 4;
|
break_type = BREAKPOINT_WRITE;
|
||||||
} else {
|
} else {
|
||||||
sendToConsoleLog("Illegal break type");
|
sendToConsoleLog("Illegal break type");
|
||||||
return;
|
return;
|
||||||
@@ -955,19 +1016,19 @@ namespace m6502debugger
|
|||||||
char tmp[12]; strcpy(tmp, cmd);
|
char tmp[12]; strcpy(tmp, cmd);
|
||||||
getcmd();
|
getcmd();
|
||||||
if (cmd[0]==0) {
|
if (cmd[0]==0) {
|
||||||
m6502dis::setSymbol(m6502::getPC(), tmp);
|
m6502dis::symbols::set(m6502::getPC(), tmp);
|
||||||
} else {
|
} else {
|
||||||
int value = getnum(cmd);
|
int value = getnum(cmd);
|
||||||
m6502dis::setSymbol(value, tmp);
|
m6502dis::symbols::set(value, tmp);
|
||||||
}
|
}
|
||||||
sendToConsoleLog("Symbol added");
|
sendToConsoleLog("Symbol added");
|
||||||
} else if (strcmp(cmd, "del")==0) {
|
} else if (strcmp(cmd, "del")==0) {
|
||||||
getcmd();
|
getcmd();
|
||||||
if (cmd[0]==0) {
|
if (cmd[0]==0) {
|
||||||
m6502dis::setSymbol(m6502::getPC(), NULL);
|
m6502dis::symbols::set(m6502::getPC(), NULL);
|
||||||
} else {
|
} else {
|
||||||
int value = getnum(cmd);
|
int value = getnum(cmd);
|
||||||
m6502dis::setSymbol(value, NULL);
|
m6502dis::symbols::set(value, NULL);
|
||||||
}
|
}
|
||||||
sendToConsoleLog("Symbol removed");
|
sendToConsoleLog("Symbol removed");
|
||||||
}
|
}
|
||||||
@@ -1025,9 +1086,10 @@ namespace m6502debugger
|
|||||||
|
|
||||||
uint32_t next()
|
uint32_t next()
|
||||||
{
|
{
|
||||||
breakpoints[m6502::getPC()+m6502dis::getOpcodeSize(m6502::getPC())] |= 8;
|
breakpoints[m6502::getPC()+m6502dis::getOpcodeSize(m6502::getPC())] |= BREAKPOINT_NEXT;
|
||||||
//const uint32_t t = m6502::step();
|
//const uint32_t t = m6502::step();
|
||||||
cont();
|
atari2600::resume();
|
||||||
|
//cont();
|
||||||
return 0; //t;
|
return 0; //t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ namespace m6502debugger
|
|||||||
#define MEMTAG_KNOWN 0x07
|
#define MEMTAG_KNOWN 0x07
|
||||||
#define MEMTAG_TOUCHED 0x70
|
#define MEMTAG_TOUCHED 0x70
|
||||||
|
|
||||||
|
#define BREAKPOINT_EXECUTE 0x01
|
||||||
|
#define BREAKPOINT_READ 0x02
|
||||||
|
#define BREAKPOINT_WRITE 0x04
|
||||||
|
#define BREAKPOINT_NEXT 0x08
|
||||||
|
|
||||||
uint8_t getTag(uint16_t address);
|
uint8_t getTag(uint16_t address);
|
||||||
void setTag(uint16_t address, uint8_t value);
|
void setTag(uint16_t address, uint8_t value);
|
||||||
|
|
||||||
|
|||||||
+69
-94
File diff suppressed because one or more lines are too long
+11
-6
@@ -4,14 +4,19 @@
|
|||||||
|
|
||||||
namespace m6502dis
|
namespace m6502dis
|
||||||
{
|
{
|
||||||
void loadSymbols();
|
|
||||||
void saveSymbols();
|
|
||||||
const char *getAsm(const uint16_t pos);
|
const char *getAsm(const uint16_t pos);
|
||||||
const char *getOpcode(const uint16_t pos);
|
const char *getOpcode(const uint16_t pos);
|
||||||
const int getOpcodeSize(const uint16_t pos);
|
const int getOpcodeSize(const uint16_t pos);
|
||||||
const char *getSymbol(const uint16_t pos);
|
|
||||||
void setSymbol(const uint16_t pos, const char *sym);
|
|
||||||
|
|
||||||
const int getNumSymbols();
|
namespace symbols
|
||||||
const uint16_t getSymbolAddress(const int pos);
|
{
|
||||||
|
void load();
|
||||||
|
void save();
|
||||||
|
|
||||||
|
const char *get(const uint16_t pos);
|
||||||
|
void set(const uint16_t pos, const char *sym);
|
||||||
|
|
||||||
|
const int count();
|
||||||
|
const uint16_t address(const int pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
|
|||||||
} else {
|
} else {
|
||||||
rom::load("combat.bin");
|
rom::load("combat.bin");
|
||||||
}
|
}
|
||||||
m6502dis::loadSymbols();
|
m6502dis::symbols::load();
|
||||||
atari2600::init();
|
atari2600::init();
|
||||||
atari2600::pause();
|
atari2600::pause();
|
||||||
m6502debugger::show();
|
m6502debugger::show();
|
||||||
@@ -34,6 +34,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (atari2600::is_paused()) {
|
if (atari2600::is_paused()) {
|
||||||
switch (e.key.scancode) {
|
switch (e.key.scancode) {
|
||||||
case SDL_SCANCODE_F10: atari2600::step(); m6502debugger::refresh(); break;
|
case SDL_SCANCODE_F10: atari2600::step(); m6502debugger::refresh(); break;
|
||||||
|
case SDL_SCANCODE_F11: m6502debugger::next(); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -130,7 +130,7 @@ namespace pia
|
|||||||
if (address & 0x200) {
|
if (address & 0x200) {
|
||||||
return {"PIA", mdtRegister, address};
|
return {"PIA", mdtRegister, address};
|
||||||
} else {
|
} else {
|
||||||
return {"RAM", mdtRAM, address & 0xff};
|
return {"RAM", mdtRAM, uint16_t(address & 0xff)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ namespace rom
|
|||||||
{
|
{
|
||||||
const memDebugInfo getInfo(uint16_t address)
|
const memDebugInfo getInfo(uint16_t address)
|
||||||
{
|
{
|
||||||
return {"ROM", mdtROM, 0x1000 | (address & mask)};
|
return {"ROM", mdtROM, uint16_t(0x1000 | (address & mask))};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user