- [FIX] el cursor del debugger sempre anava una instrucció per darrere de PC
- [NEW] El desensamblador sí que pot determinar opcodes cap enrere en el 6502 - [FIX] Fer wrap correcte dels uint16_t per a evitar desbordaments - [FIX] La pila ací va al reves, pintar com toca en el debugger - [FIX] arreglats (supostament) opcodes: PHP, JSR, PLP, RTI, JMP i RTS
This commit is contained in:
+15
-13
@@ -309,7 +309,7 @@ namespace m6502debugger
|
||||
if ( !(tag & MEMTAG_IGNORE) ) tag |= MEMTAG_INST;
|
||||
tag |= (!(tag&MEMTAG_TOUCHED) ? MEMTAG_TREPEAT : MEMTAG_TINST);
|
||||
|
||||
setcursor(m6502::getPC());
|
||||
setcursor(address);
|
||||
history::store();
|
||||
}
|
||||
|
||||
@@ -418,12 +418,14 @@ namespace m6502debugger
|
||||
|
||||
uint16_t find_previous_opcode(uint16_t pc)
|
||||
{
|
||||
pc--;
|
||||
if ( !(tags[pc] & (MEMTAG_CODE | MEMTAG_INST) ) ) return pc;
|
||||
|
||||
while ( !(tags[pc] & MEMTAG_INST) ) pc--;
|
||||
|
||||
return pc;
|
||||
if (m6502dis::getOpcodeSize(uint16_t(pc-3))==3) return uint16_t(pc-3);
|
||||
if (m6502dis::getOpcodeSize(uint16_t(pc-2))==2) return uint16_t(pc-2);
|
||||
return uint16_t(pc-1);
|
||||
//if ( !(tags[pc] & (MEMTAG_CODE | MEMTAG_INST) ) ) return pc;
|
||||
//
|
||||
//while ( !(tags[pc] & MEMTAG_INST) ) pc--;
|
||||
//
|
||||
//return pc;
|
||||
}
|
||||
|
||||
void printDissasemblerLine(const uint16_t address, const int line, const bool heuristics=false)
|
||||
@@ -447,7 +449,7 @@ namespace m6502debugger
|
||||
|
||||
const int opcodesize = m6502dis::getOpcodeSize(address);
|
||||
for (int i=0; i<opcodesize; ++i) {
|
||||
const uint8_t tag = tags[address+i];
|
||||
const uint8_t tag = tags[uint16_t(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);
|
||||
}
|
||||
@@ -495,7 +497,7 @@ namespace m6502debugger
|
||||
for (int i=(num_lines/2)-2;i>=0;--i) {
|
||||
pos = find_previous_opcode(pos);
|
||||
line_address[i] = pos;
|
||||
printDissasemblerLine(pos, i);
|
||||
printDissasemblerLine(pos, i, true);
|
||||
}
|
||||
|
||||
// REGISTERS
|
||||
@@ -540,17 +542,17 @@ namespace m6502debugger
|
||||
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 = 0x0100 | m6502::getS();//-(((sym_y-12)>>1)<<1);
|
||||
uint16_t sp = m6502::getS()+8;//-(((sym_y-12)>>1)<<1);
|
||||
for (int i=0; i<10; ++i) {
|
||||
uint8_t c1=COLOR_CYAN, c2=COLOR_GRAY;
|
||||
if ((sp & 0xff) == m6502::getS()) {
|
||||
if (sp == m6502::getS()) {
|
||||
ui::printrect(0,i,9,1,COLOR_BLUE);
|
||||
c1 = c2 = COLOR_YELLOW;
|
||||
}
|
||||
ui::printtxt(0,i, tohex(0x0100 | sp, 4), c1);
|
||||
uint16_t value = mem::read(0x0100 | sp) + (mem::read(0x0100 | (sp-1))<<8);
|
||||
uint16_t value = mem::read(0x0100 | sp-1) + (mem::read(0x0100 | (sp))<<8);
|
||||
ui::printtxt(5,i, tohex(value, 4), c2);
|
||||
sp+=2;
|
||||
sp-=2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10
-8
@@ -89,6 +89,7 @@ namespace m6502
|
||||
miIncrementPC,
|
||||
miFetchAddressHiToPC,
|
||||
miIndexY,
|
||||
miFetchOperandHiToPC,
|
||||
miNumMicroinstructions
|
||||
};
|
||||
|
||||
@@ -102,7 +103,7 @@ namespace m6502
|
||||
/* 0x05 ORA zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
|
||||
/* 0x06 ASL zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
|
||||
/* 0x07 --- */ { miFetchOpcode },
|
||||
/* 0x08 PHP */ { miFetchOperandLo, miPushP, miFetchOpcode },
|
||||
/* 0x08 PHP */ { miFakeFetchOperand, miPushP, miFetchOpcode },
|
||||
/* 0x09 ORA imm */ { miFetchOperandLo, miFetchOpcode },
|
||||
/* 0x0A ASL A */ { miFakeFetchOperand, miFetchOpcode },
|
||||
/* 0x0B --- */ { miFetchOpcode },
|
||||
@@ -128,7 +129,7 @@ namespace m6502
|
||||
/* 0x1E ASL abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddress, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
|
||||
/* 0x1F --- */ { miFetchOpcode },
|
||||
|
||||
/* 0x20 JSR abs */ { miFetchAddressLo, miFakeFetchOperand, miPushPCHi, miPushPCLo, miFetchAddressHi, miFetchOpcode },
|
||||
/* 0x20 JSR abs */ { miFetchOperandLo, miFakeFetchOperand, miPushPCHi, miPushPCLo, miFetchOperandHiToPC, miFetchOpcode },
|
||||
/* 0x21 AND X,ind */ { miFetchOperandLo, miIndexX, miFetchAddressLo, miFetchAddressHi, miReadAddress, miFetchOpcode },
|
||||
/* 0x22 --- */ { miFetchOpcode },
|
||||
/* 0x23 --- */ { miFetchOpcode },
|
||||
@@ -136,7 +137,7 @@ namespace m6502
|
||||
/* 0x25 AND zpg */ { miFetchOperandLo, miReadAddress, miFetchOpcode },
|
||||
/* 0x26 ROL zpg */ { miFetchOperandLo, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
|
||||
/* 0x27 --- */ { miFetchOpcode },
|
||||
/* 0x28 PLP */ { miFetchOperandLo, miPullP, miFetchOpcode },
|
||||
/* 0x28 PLP */ { miFakeFetchOperand, miFakeFetchOperand, miPullP, miFetchOpcode },
|
||||
/* 0x29 AND imm */ { miFetchOperandLo, miFetchOpcode },
|
||||
/* 0x2A ROL A */ { miFakeFetchOperand, miFetchOpcode },
|
||||
/* 0x2B --- */ { miFetchOpcode },
|
||||
@@ -162,7 +163,7 @@ namespace m6502
|
||||
/* 0x3E ROL abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddress, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
|
||||
/* 0x3F --- */ { miFetchOpcode },
|
||||
|
||||
/* 0x40 RTI */ { miFetchOperandLo, miFakeFetchOperand, miPullP, miPullPCLo, miPullPCHi, miFetchOpcode },
|
||||
/* 0x40 RTI */ { miFakeFetchOperand, miFakeFetchOperand, miPullP, miPullPCLo, miPullPCHi, miFetchOpcode },
|
||||
/* 0x41 EOR X,ind */ { miFetchOperandLo, miIndexX, miFetchAddressLo, miFetchAddressHi, miReadAddress, miFetchOpcode },
|
||||
/* 0x42 --- */ { miFetchOpcode },
|
||||
/* 0x43 --- */ { miFetchOpcode },
|
||||
@@ -174,7 +175,7 @@ namespace m6502
|
||||
/* 0x49 EOR imm */ { miFetchOperandLo, miFetchOpcode },
|
||||
/* 0x4A LSR A */ { miFakeFetchOperand, miFetchOpcode },
|
||||
/* 0x4B --- */ { miFetchOpcode },
|
||||
/* 0x4C JMP abs */ { miFetchAddressLo, miFetchAddressHi, miFetchOpcode },
|
||||
/* 0x4C JMP abs */ { miFetchOperandLo, miFetchOperandHi, miFetchOpcode },
|
||||
/* 0x4D EOR abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miFetchOpcode },
|
||||
/* 0x4E LSR abs */ { miFetchOperandLo, miFetchOperandHi, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
|
||||
/* 0x4F --- */ { miFetchOpcode },
|
||||
@@ -196,7 +197,7 @@ namespace m6502
|
||||
/* 0x5E LSR abs,X */ { miFetchOperandLo, miFetchOperandHiAndIndexX, miReadAddress, miReadAddress, miWriteAddress, miWriteAddress, miFetchOpcode },
|
||||
/* 0x5F --- */ { miFetchOpcode },
|
||||
|
||||
/* 0x60 RTS */ { miFetchOperandLo, miFakeFetchOperand, miPullPCLo, miPullPCHi, miIncrementPC, miFetchOpcode },
|
||||
/* 0x60 RTS */ { miFakeFetchOperand, miFakeFetchOperand, miPullPCLo, miPullPCHi, miIncrementPC, miFetchOpcode },
|
||||
/* 0x61 ADC X,ind */ { miFetchOperandLo, miIndexX, miFetchAddressLo, miFetchAddressHi, miReadAddress, miFetchOpcode },
|
||||
/* 0x62 --- */ { miFetchOpcode },
|
||||
/* 0x63 --- */ { miFetchOpcode },
|
||||
@@ -535,9 +536,10 @@ namespace m6502
|
||||
int i=0; do { microcode[microcode_last++] = instructions[rI][i++]; } while (instructions[rI][i-1] != miFetchOpcode);
|
||||
}
|
||||
|
||||
void FakeFetchOperand() { rAD_lo = mem::read(get_PC()); }
|
||||
void FakeFetchOperand() { uint8_t dummy = mem::read(get_PC()); (void)dummy; }
|
||||
void FetchOperandLo() { rAD_lo = rB = mem::read(get_PC()); inc_PC(); set_TEMP(rB); }
|
||||
void FetchOperandHi() { rAD_hi = mem::read(get_PC()); inc_PC(); }
|
||||
void FetchOperandHiToPC() { rAD_hi = mem::read(get_PC()); set_PC(get_AD()); }
|
||||
void FetchOperandHiAndIndexX() { rAD_hi = mem::read(get_PC()); inc_PC(); set_TEMP(rAD_lo + rX); rAD_lo = rTEMP_lo; }
|
||||
void FetchOperandHiAndIndexY() { rAD_hi = mem::read(get_PC()); inc_PC(); set_TEMP(rAD_lo + rY); rAD_lo = rTEMP_lo; }
|
||||
|
||||
@@ -599,7 +601,7 @@ namespace m6502
|
||||
IndexX, FetchAddressLo, FetchAddressHi, FetchAddressHiAndIndex, ReadAddress,
|
||||
ReadAddressAndSkip, WriteRegister, WriteAddress, PushA, FetchOperandAndCheckBranch,
|
||||
CheckIfPageCrossed, PullPCHi, PullPCLo, PullP, PullA,
|
||||
IncrementPC, FetchAddressHiToPC, IndexY };
|
||||
IncrementPC, FetchAddressHiToPC, IndexY, FetchOperandHiToPC };
|
||||
|
||||
void reset()
|
||||
{
|
||||
|
||||
@@ -37,13 +37,9 @@ namespace atari2600
|
||||
should_exit = true;
|
||||
}
|
||||
|
||||
int ppc = 0;
|
||||
void step()
|
||||
{
|
||||
//uint8_t t_states;
|
||||
uint16_t pc = m6502::getPC();
|
||||
ppc += pc;
|
||||
m6502debugger::onInstructionExecute(pc);
|
||||
uint8_t t_states;
|
||||
// if (z80debugger::isbreak(pc, 9)) {
|
||||
// msx::pause();
|
||||
// z80debugger::show();
|
||||
@@ -60,9 +56,11 @@ namespace atari2600
|
||||
tia::tick();
|
||||
tia::tick();
|
||||
pia::tick();
|
||||
//t_states++;
|
||||
t_states++;
|
||||
}
|
||||
//speaker::update(t_states);
|
||||
uint16_t pc = m6502::getPC();
|
||||
m6502debugger::onInstructionExecute(pc);
|
||||
speaker::update(t_states);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user