moved the assembly/disassembly code to the core code

improved docs a little
This commit is contained in:
zeromus 2006-08-01 04:33:12 +00:00
parent 530ce65fa6
commit 06536f226e
14 changed files with 108 additions and 569 deletions

View File

@ -1,3 +1,6 @@
/// \file
/// \brief Implements core debugging facilities
#include "types.h"
#include "x6502.h"
#include "fceu.h"
@ -79,7 +82,6 @@ char *cdlogfilename;
//char loadedcdfile[MAX_PATH];
static int indirectnext;
//records whether loggingCD is enabled
int debug_loggingCD;
//called by the cpu to perform logging if CDLogging is enabled
@ -166,14 +168,16 @@ void LogCDData(){
//-----------debugger stuff
watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over
int badopbreak;
int iaPC;
uint32 iapoffset; //mbg merge 7/18/06 changed from int
int step,stepout,jsrcount;
int u; //deleteme
int skipdebug; //deleteme
int numWPs;
static DebuggerState dbgstate;
DebuggerState &FCEUI_Debugger() { return dbgstate; }
void BreakHit() {
FCEUI_SetEmulationPaused(1); //mbg merge 7/19/06 changed to use EmulationPaused()
@ -320,34 +324,39 @@ int condition(watchpointinfo* wp)
// ################################## End of SP CODE ###########################
//extern int step;
//extern int stepout;
//extern int jsrcount;
///fires a breakpoint
void breakpoint() {
int i;
uint16 A=0;
uint8 brk_type,opcode[3] = {0};
//inspect the current opcode
opcode[0] = GetMem(_PC);
if(badopbreak && (opsize[opcode[0]] == 0))BreakHit();
//if the current instruction is bad, and we are breaking on bad opcodes, then hit the breakpoint
if(dbgstate.badopbreak && (opsize[opcode[0]] == 0)) BreakHit();
if (stepout) {
if (opcode[0] == 0x20) jsrcount++;
//if we're stepping out, track the nest level
if (dbgstate.stepout) {
if (opcode[0] == 0x20) dbgstate.jsrcount++;
else if (opcode[0] == 0x60) {
if (jsrcount) jsrcount--;
if (dbgstate.jsrcount) dbgstate.jsrcount--;
else {
stepout = 0;
step = 1;
dbgstate.stepout = false;
dbgstate.step = true;
return;
}
}
}
if (step) {
step = 0;
//if we're stepping, then we'll always want to break
if (dbgstate.step) {
dbgstate.step = false;
BreakHit();
return;
}
//check the step over address and break if we've hit it
if ((watchpoint[64].address == _PC) && (watchpoint[64].flags)) {
watchpoint[64].address = 0;
watchpoint[64].flags = 0;
@ -355,7 +364,6 @@ void breakpoint() {
return;
}
for (i = 1; i < opsize[opcode[0]]; i++) opcode[i] = GetMem(_PC+i);
brk_type = opbrktype[opcode[0]] | WP_X;
switch (optype[opcode[0]]) {
@ -414,8 +422,9 @@ void breakpoint() {
int debug_tracing;
void DebugCycle() {
if (numWPs | step | stepout | watchpoint[64].flags | badopbreak)
if (numWPs || dbgstate.step || dbgstate.stepout || watchpoint[64].flags || dbgstate.badopbreak)
breakpoint();
if(debug_loggingCD) LogCDData();
//mbg 6/30/06 - this was commented out when i got here. i dont understand it anyway

View File

@ -90,4 +90,31 @@ extern uint8 *vnapage[4],*VPage[8];
extern uint8 PPU[4],PALRAM[0x20],SPRAM[0x100],VRAMBuffer,PPUGenLatch,XOffset;
extern uint32 RefreshAddr;
extern int debug_loggingCD;
extern int numWPs;
///encapsulates the operational state of the debugger core
class DebuggerState {
public:
///indicates whether the debugger is stepping through a single instruction
bool step;
///indicates whether the debugger is stepping out of a function call
bool stepout;
///indicates whether the debugger should break on bad opcodes
bool badopbreak;
///counts the nest level of the call stack while stepping out
int jsrcount;
///resets the debugger state to an empty, non-debugging state
void reset() {
numWPs = 0;
step = false;
stepout = false;
jsrcount = 0;
}
};
///retrieves the core's DebuggerState
DebuggerState &FCEUI_Debugger();
#endif

View File

@ -329,5 +329,4 @@ void FCEUD_UpdateNTView(int scanline, int drawall);
//the driver might should update its PPUView (only used if debugging support is compiled in)
void FCEUD_UpdatePPUView(int scanline, int drawall);
#endif /* __DRIVER_H_ */

View File

@ -1,210 +0,0 @@
if (!strlen(astr)) {
//Implied instructions
if (!strcmp(ins,"BRK")) opcode[0] = 0x00;
else if (!strcmp(ins,"PHP")) opcode[0] = 0x08;
else if (!strcmp(ins,"ASL")) opcode[0] = 0x0A;
else if (!strcmp(ins,"CLC")) opcode[0] = 0x18;
else if (!strcmp(ins,"PLP")) opcode[0] = 0x28;
else if (!strcmp(ins,"ROL")) opcode[0] = 0x2A;
else if (!strcmp(ins,"SEC")) opcode[0] = 0x38;
else if (!strcmp(ins,"RTI")) opcode[0] = 0x40;
else if (!strcmp(ins,"PHA")) opcode[0] = 0x48;
else if (!strcmp(ins,"LSR")) opcode[0] = 0x4A;
else if (!strcmp(ins,"CLI")) opcode[0] = 0x58;
else if (!strcmp(ins,"RTS")) opcode[0] = 0x60;
else if (!strcmp(ins,"PLA")) opcode[0] = 0x68;
else if (!strcmp(ins,"ROR")) opcode[0] = 0x6A;
else if (!strcmp(ins,"SEI")) opcode[0] = 0x78;
else if (!strcmp(ins,"DEY")) opcode[0] = 0x88;
else if (!strcmp(ins,"TXA")) opcode[0] = 0x8A;
else if (!strcmp(ins,"TYA")) opcode[0] = 0x98;
else if (!strcmp(ins,"TXS")) opcode[0] = 0x9A;
else if (!strcmp(ins,"TAY")) opcode[0] = 0xA8;
else if (!strcmp(ins,"TAX")) opcode[0] = 0xAA;
else if (!strcmp(ins,"CLV")) opcode[0] = 0xB8;
else if (!strcmp(ins,"TSX")) opcode[0] = 0xBA;
else if (!strcmp(ins,"INY")) opcode[0] = 0xC8;
else if (!strcmp(ins,"DEX")) opcode[0] = 0xCA;
else if (!strcmp(ins,"CLD")) opcode[0] = 0xD8;
else if (!strcmp(ins,"INX")) opcode[0] = 0xE8;
else if (!strcmp(ins,"NOP")) opcode[0] = 0xEA;
else if (!strcmp(ins,"SED")) opcode[0] = 0xF8;
else return 1;
}
else {
//Instructions with Operands
if (!strcmp(ins,"ORA")) opcode[0] = 0x01;
else if (!strcmp(ins,"ASL")) opcode[0] = 0x06;
else if (!strcmp(ins,"BPL")) opcode[0] = 0x10;
else if (!strcmp(ins,"JSR")) opcode[0] = 0x20;
else if (!strcmp(ins,"AND")) opcode[0] = 0x21;
else if (!strcmp(ins,"BIT")) opcode[0] = 0x24;
else if (!strcmp(ins,"ROL")) opcode[0] = 0x26;
else if (!strcmp(ins,"BMI")) opcode[0] = 0x30;
else if (!strcmp(ins,"EOR")) opcode[0] = 0x41;
else if (!strcmp(ins,"LSR")) opcode[0] = 0x46;
else if (!strcmp(ins,"JMP")) opcode[0] = 0x4C;
else if (!strcmp(ins,"BVC")) opcode[0] = 0x50;
else if (!strcmp(ins,"ADC")) opcode[0] = 0x61;
else if (!strcmp(ins,"ROR")) opcode[0] = 0x66;
else if (!strcmp(ins,"BVS")) opcode[0] = 0x70;
else if (!strcmp(ins,"STA")) opcode[0] = 0x81;
else if (!strcmp(ins,"STY")) opcode[0] = 0x84;
else if (!strcmp(ins,"STX")) opcode[0] = 0x86;
else if (!strcmp(ins,"BCC")) opcode[0] = 0x90;
else if (!strcmp(ins,"LDY")) opcode[0] = 0xA0;
else if (!strcmp(ins,"LDA")) opcode[0] = 0xA1;
else if (!strcmp(ins,"LDX")) opcode[0] = 0xA2;
else if (!strcmp(ins,"BCS")) opcode[0] = 0xB0;
else if (!strcmp(ins,"CPY")) opcode[0] = 0xC0;
else if (!strcmp(ins,"CMP")) opcode[0] = 0xC1;
else if (!strcmp(ins,"DEC")) opcode[0] = 0xC6;
else if (!strcmp(ins,"BNE")) opcode[0] = 0xD0;
else if (!strcmp(ins,"CPX")) opcode[0] = 0xE0;
else if (!strcmp(ins,"SBC")) opcode[0] = 0xE1;
else if (!strcmp(ins,"INC")) opcode[0] = 0xE6;
else if (!strcmp(ins,"BEQ")) opcode[0] = 0xF0;
else return 1;
{
//Parse Operands
// It's not the sexiest thing ever, but it works well enough!
//TODO:
// Add branches.
// Fix certain instructions. (Setting bits is not 100% perfect.)
// Fix instruction/operand matching. (Instructions like "jmp ($94),Y" are no good!)
// Optimizations?
int tmpint;
char tmpchr,tmpstr[20];
if (sscanf(astr,"#$%2X%c",&tmpint,&tmpchr) == 1) { //#Immediate
switch (opcode[0]) {
case 0x20: case 0x4C: //Jumps
case 0x10: case 0x30: case 0x50: case 0x70: //Branches
case 0x90: case 0xB0: case 0xD0: case 0xF0:
case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of #Immediate
case 0x66: case 0x81: case 0x84: case 0x86:
case 0xC6: case 0xE6:
return 1;
default:
//cheap hack for certain instructions
switch (opcode[0]) {
case 0xA0: case 0xA2: case 0xC0: case 0xE0:
break;
default:
opcode[0] |= 0x08;
break;
}
opcode[1] = tmpint;
break;
}
}
else if (sscanf(astr,"$%4X%c",&tmpint,&tmpchr) == 1) { //Absolute, Zero Page, Branch, or Jump
switch (opcode[0]) {
case 0x20: case 0x4C: //Jumps
opcode[1] = (tmpint & 0xFF);
opcode[2] = (tmpint >> 8);
break;
case 0x10: case 0x30: case 0x50: case 0x70: //Branches
case 0x90: case 0xB0: case 0xD0: case 0xF0:
tmpint -= (addr+2);
if ((tmpint < -128) || (tmpint > 127)) return 1;
opcode[1] = (tmpint & 0xFF);
break;
//return 1; //FIX ME
default:
if (tmpint > 0xFF) { //Absolute
opcode[0] |= 0x0C;
opcode[1] = (tmpint & 0xFF);
opcode[2] = (tmpint >> 8);
}
else { //Zero Page
opcode[0] |= 0x04;
opcode[1] = (tmpint & 0xFF);
}
break;
}
}
else if (sscanf(astr,"$%4X%s",&tmpint,tmpstr) == 2) { //Absolute,X, Zero Page,X, Absolute,Y or Zero Page,Y
if (!strcmp(tmpstr,",X")) { //Absolute,X or Zero Page,X
switch (opcode[0]) {
case 0x20: case 0x4C: //Jumps
case 0x10: case 0x30: case 0x50: case 0x70: //Branches
case 0x90: case 0xB0: case 0xD0: case 0xF0:
case 0x24: case 0x86: case 0xA2: case 0xC0: //Other instructions incapable of Absolute,X or Zero Page,X
case 0xE0:
return 1;
default:
if (tmpint > 0xFF) { //Absolute
if (opcode[0] == 0x84) return 1; //No STY Absolute,X!
opcode[0] |= 0x1C;
opcode[1] = (tmpint & 0xFF);
opcode[2] = (tmpint >> 8);
}
else { //Zero Page
opcode[0] |= 0x14;
opcode[1] = (tmpint & 0xFF);
}
break;
}
}
else if (!strcmp(tmpstr,",Y")) { //Absolute,Y or Zero Page,Y
switch (opcode[0]) {
case 0x20: case 0x4C: //Jumps
case 0x10: case 0x30: case 0x50: case 0x70: //Branches
case 0x90: case 0xB0: case 0xD0: case 0xF0:
case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of Absolute,Y or Zero Page,Y
case 0x66: case 0x84: case 0x86: case 0xA0:
case 0xC0: case 0xC6: case 0xE0: case 0xE6:
return 1;
case 0xA2: //cheap hack for LDX
opcode[0] |= 0x04;
default:
if (tmpint > 0xFF) { //Absolute
if (opcode[0] == 0x86) return 1; //No STX Absolute,Y!
opcode[0] |= 0x18;
opcode[1] = (tmpint & 0xFF);
opcode[2] = (tmpint >> 8);
}
else { //Zero Page
if ((opcode[0] != 0x86) || (opcode[0] != 0xA2)) return 1; //only STX and LDX Absolute,Y!
opcode[0] |= 0x10;
opcode[1] = (tmpint & 0xFF);
}
break;
}
}
else return 1;
}
else if (sscanf(astr,"($%4X%s",&tmpint,tmpstr) == 2) { //Jump (Indirect), (Indirect,X) or (Indirect),Y
switch (opcode[0]) {
case 0x20: //Jumps
case 0x10: case 0x30: case 0x50: case 0x70: //Branches
case 0x90: case 0xB0: case 0xD0: case 0xF0:
case 0x06: case 0x24: case 0x26: case 0x46: //Other instructions incapable of Jump (Indirect), (Indirect,X) or (Indirect),Y
case 0x66: case 0x84: case 0x86: case 0xA0:
case 0xA2: case 0xC0: case 0xC6: case 0xE0:
case 0xE6:
return 1;
default:
if ((!strcmp(tmpstr,")")) && (opcode[0] == 0x4C)) { //Jump (Indirect)
opcode[0] = 0x6C;
opcode[1] = (tmpint & 0xFF);
opcode[2] = (tmpint >> 8);
}
else if ((!strcmp(tmpstr,",X)")) && (tmpint <= 0xFF) && (opcode[0] != 0x4C)) { //(Indirect,X)
opcode[1] = (tmpint & 0xFF);
}
else if ((!strcmp(tmpstr,"),Y")) && (tmpint <= 0xFF) && (opcode[0] != 0x4C)) { //(Indirect),Y
opcode[0] |= 0x10;
opcode[1] = (tmpint & 0xFF);
}
else return 1;
break;
}
}
else return 1;
}
}

View File

@ -1,252 +0,0 @@
#define relative(a) { \
if (((a)=opcode[1])&0x80) (a) = addr-(((a)-1)^0xFF); \
else (a)+=addr; \
}
#define absolute(a) { \
(a) = opcode[1] | opcode[2]<<8; \
}
#define zpIndex(a,i) { \
(a) = opcode[1]+(i); \
}
#define indirectX(a) { \
(a) = (opcode[1]+X.X)&0xFF; \
(a) = GetMem((a)) | (GetMem((a)+1))<<8; \
}
#define indirectY(a) { \
(a) = GetMem(opcode[1]) | (GetMem(opcode[1]+1))<<8; \
(a) += X.Y; \
}
//odd, 1-byte opcodes
case 0x00: strcpy(str,"BRK"); break;
case 0x08: strcpy(str,"PHP"); break;
case 0x0A: strcpy(str,"ASL"); break;
case 0x18: strcpy(str,"CLC"); break;
case 0x28: strcpy(str,"PLP"); break;
case 0x2A: strcpy(str,"ROL"); break;
case 0x38: strcpy(str,"SEC"); break;
case 0x40: strcpy(str,"RTI"); break;
case 0x48: strcpy(str,"PHA"); break;
case 0x4A: strcpy(str,"LSR"); break;
case 0x58: strcpy(str,"CLI"); break;
case 0x60: strcpy(str,"RTS"); break;
case 0x68: strcpy(str,"PLA"); break;
case 0x6A: strcpy(str,"ROR"); break;
case 0x78: strcpy(str,"SEI"); break;
case 0x88: strcpy(str,"DEY"); break;
case 0x8A: strcpy(str,"TXA"); break;
case 0x98: strcpy(str,"TYA"); break;
case 0x9A: strcpy(str,"TXS"); break;
case 0xA8: strcpy(str,"TAY"); break;
case 0xAA: strcpy(str,"TAX"); break;
case 0xB8: strcpy(str,"CLV"); break;
case 0xBA: strcpy(str,"TSX"); break;
case 0xC8: strcpy(str,"INY"); break;
case 0xCA: strcpy(str,"DEX"); break;
case 0xD8: strcpy(str,"CLD"); break;
case 0xE8: strcpy(str,"INX"); break;
case 0xEA: strcpy(str,"NOP"); break;
case 0xF8: strcpy(str,"SED"); break;
//(Indirect,X)
case 0x01: strcpy(chr,"ORA"); goto _indirectx;
case 0x21: strcpy(chr,"AND"); goto _indirectx;
case 0x41: strcpy(chr,"EOR"); goto _indirectx;
case 0x61: strcpy(chr,"ADC"); goto _indirectx;
case 0x81: strcpy(chr,"STA"); goto _indirectx;
case 0xA1: strcpy(chr,"LDA"); goto _indirectx;
case 0xC1: strcpy(chr,"CMP"); goto _indirectx;
case 0xE1: strcpy(chr,"SBC"); goto _indirectx;
_indirectx:
indirectX(tmp);
sprintf(str,"%s ($%02X,X) @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
break;
//Zero Page
case 0x05: strcpy(chr,"ORA"); goto _zeropage;
case 0x06: strcpy(chr,"ASL"); goto _zeropage;
case 0x24: strcpy(chr,"BIT"); goto _zeropage;
case 0x25: strcpy(chr,"AND"); goto _zeropage;
case 0x26: strcpy(chr,"ROL"); goto _zeropage;
case 0x45: strcpy(chr,"EOR"); goto _zeropage;
case 0x46: strcpy(chr,"LSR"); goto _zeropage;
case 0x65: strcpy(chr,"ADC"); goto _zeropage;
case 0x66: strcpy(chr,"ROR"); goto _zeropage;
case 0x84: strcpy(chr,"STY"); goto _zeropage;
case 0x85: strcpy(chr,"STA"); goto _zeropage;
case 0x86: strcpy(chr,"STX"); goto _zeropage;
case 0xA4: strcpy(chr,"LDY"); goto _zeropage;
case 0xA5: strcpy(chr,"LDA"); goto _zeropage;
case 0xA6: strcpy(chr,"LDX"); goto _zeropage;
case 0xC4: strcpy(chr,"CPY"); goto _zeropage;
case 0xC5: strcpy(chr,"CMP"); goto _zeropage;
case 0xC6: strcpy(chr,"DEC"); goto _zeropage;
case 0xE4: strcpy(chr,"CPX"); goto _zeropage;
case 0xE5: strcpy(chr,"SBC"); goto _zeropage;
case 0xE6: strcpy(chr,"INC"); goto _zeropage;
_zeropage:
// ################################## Start of SP CODE ###########################
// Change width to %04X
sprintf(str,"%s $%04X = #$%02X", chr,opcode[1],GetMem(opcode[1]));
// ################################## End of SP CODE ###########################
break;
//#Immediate
case 0x09: strcpy(chr,"ORA"); goto _immediate;
case 0x29: strcpy(chr,"AND"); goto _immediate;
case 0x49: strcpy(chr,"EOR"); goto _immediate;
case 0x69: strcpy(chr,"ADC"); goto _immediate;
//case 0x89: strcpy(chr,"STA"); goto _immediate; //baka, no STA #imm!!
case 0xA0: strcpy(chr,"LDY"); goto _immediate;
case 0xA2: strcpy(chr,"LDX"); goto _immediate;
case 0xA9: strcpy(chr,"LDA"); goto _immediate;
case 0xC0: strcpy(chr,"CPY"); goto _immediate;
case 0xC9: strcpy(chr,"CMP"); goto _immediate;
case 0xE0: strcpy(chr,"CPX"); goto _immediate;
case 0xE9: strcpy(chr,"SBC"); goto _immediate;
_immediate:
sprintf(str,"%s #$%02X", chr,opcode[1]);
break;
//Absolute
case 0x0D: strcpy(chr,"ORA"); goto _absolute;
case 0x0E: strcpy(chr,"ASL"); goto _absolute;
case 0x2C: strcpy(chr,"BIT"); goto _absolute;
case 0x2D: strcpy(chr,"AND"); goto _absolute;
case 0x2E: strcpy(chr,"ROL"); goto _absolute;
case 0x4D: strcpy(chr,"EOR"); goto _absolute;
case 0x4E: strcpy(chr,"LSR"); goto _absolute;
case 0x6D: strcpy(chr,"ADC"); goto _absolute;
case 0x6E: strcpy(chr,"ROR"); goto _absolute;
case 0x8C: strcpy(chr,"STY"); goto _absolute;
case 0x8D: strcpy(chr,"STA"); goto _absolute;
case 0x8E: strcpy(chr,"STX"); goto _absolute;
case 0xAC: strcpy(chr,"LDY"); goto _absolute;
case 0xAD: strcpy(chr,"LDA"); goto _absolute;
case 0xAE: strcpy(chr,"LDX"); goto _absolute;
case 0xCC: strcpy(chr,"CPY"); goto _absolute;
case 0xCD: strcpy(chr,"CMP"); goto _absolute;
case 0xCE: strcpy(chr,"DEC"); goto _absolute;
case 0xEC: strcpy(chr,"CPX"); goto _absolute;
case 0xED: strcpy(chr,"SBC"); goto _absolute;
case 0xEE: strcpy(chr,"INC"); goto _absolute;
_absolute:
absolute(tmp);
sprintf(str,"%s $%04X = #$%02X", chr,tmp,GetMem(tmp));
break;
//branches
case 0x10: strcpy(chr,"BPL"); goto _branch;
case 0x30: strcpy(chr,"BMI"); goto _branch;
case 0x50: strcpy(chr,"BVC"); goto _branch;
case 0x70: strcpy(chr,"BVS"); goto _branch;
case 0x90: strcpy(chr,"BCC"); goto _branch;
case 0xB0: strcpy(chr,"BCS"); goto _branch;
case 0xD0: strcpy(chr,"BNE"); goto _branch;
case 0xF0: strcpy(chr,"BEQ"); goto _branch;
_branch:
relative(tmp);
sprintf(str,"%s $%04X", chr,tmp);
break;
//(Indirect),Y
case 0x11: strcpy(chr,"ORA"); goto _indirecty;
case 0x31: strcpy(chr,"AND"); goto _indirecty;
case 0x51: strcpy(chr,"EOR"); goto _indirecty;
case 0x71: strcpy(chr,"ADC"); goto _indirecty;
case 0x91: strcpy(chr,"STA"); goto _indirecty;
case 0xB1: strcpy(chr,"LDA"); goto _indirecty;
case 0xD1: strcpy(chr,"CMP"); goto _indirecty;
case 0xF1: strcpy(chr,"SBC"); goto _indirecty;
_indirecty:
indirectY(tmp);
sprintf(str,"%s ($%02X),Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
break;
//Zero Page,X
case 0x15: strcpy(chr,"ORA"); goto _zeropagex;
case 0x16: strcpy(chr,"ASL"); goto _zeropagex;
case 0x35: strcpy(chr,"AND"); goto _zeropagex;
case 0x36: strcpy(chr,"ROL"); goto _zeropagex;
case 0x55: strcpy(chr,"EOR"); goto _zeropagex;
case 0x56: strcpy(chr,"LSR"); goto _zeropagex;
case 0x75: strcpy(chr,"ADC"); goto _zeropagex;
case 0x76: strcpy(chr,"ROR"); goto _zeropagex;
case 0x94: strcpy(chr,"STY"); goto _zeropagex;
case 0x95: strcpy(chr,"STA"); goto _zeropagex;
case 0xB4: strcpy(chr,"LDY"); goto _zeropagex;
case 0xB5: strcpy(chr,"LDA"); goto _zeropagex;
case 0xD5: strcpy(chr,"CMP"); goto _zeropagex;
case 0xD6: strcpy(chr,"DEC"); goto _zeropagex;
case 0xF5: strcpy(chr,"SBC"); goto _zeropagex;
case 0xF6: strcpy(chr,"INC"); goto _zeropagex;
_zeropagex:
zpIndex(tmp,X.X);
// ################################## Start of SP CODE ###########################
// Change width to %04X
sprintf(str,"%s $%02X,X @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
// ################################## End of SP CODE ###########################
break;
//Absolute,Y
case 0x19: strcpy(chr,"ORA"); goto _absolutey;
case 0x39: strcpy(chr,"AND"); goto _absolutey;
case 0x59: strcpy(chr,"EOR"); goto _absolutey;
case 0x79: strcpy(chr,"ADC"); goto _absolutey;
case 0x99: strcpy(chr,"STA"); goto _absolutey;
case 0xB9: strcpy(chr,"LDA"); goto _absolutey;
case 0xBE: strcpy(chr,"LDX"); goto _absolutey;
case 0xD9: strcpy(chr,"CMP"); goto _absolutey;
case 0xF9: strcpy(chr,"SBC"); goto _absolutey;
_absolutey:
absolute(tmp);
tmp2=(tmp+X.Y);
sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2));
break;
//Absolute,X
case 0x1D: strcpy(chr,"ORA"); goto _absolutex;
case 0x1E: strcpy(chr,"ASL"); goto _absolutex;
case 0x3D: strcpy(chr,"AND"); goto _absolutex;
case 0x3E: strcpy(chr,"ROL"); goto _absolutex;
case 0x5D: strcpy(chr,"EOR"); goto _absolutex;
case 0x5E: strcpy(chr,"LSR"); goto _absolutex;
case 0x7D: strcpy(chr,"ADC"); goto _absolutex;
case 0x7E: strcpy(chr,"ROR"); goto _absolutex;
case 0x9D: strcpy(chr,"STA"); goto _absolutex;
case 0xBC: strcpy(chr,"LDY"); goto _absolutex;
case 0xBD: strcpy(chr,"LDA"); goto _absolutex;
case 0xDD: strcpy(chr,"CMP"); goto _absolutex;
case 0xDE: strcpy(chr,"DEC"); goto _absolutex;
case 0xFD: strcpy(chr,"SBC"); goto _absolutex;
case 0xFE: strcpy(chr,"INC"); goto _absolutex;
_absolutex:
absolute(tmp);
tmp2=(tmp+X.X);
sprintf(str,"%s $%04X,X @ $%04X = #$%02X", chr,tmp,tmp2,GetMem(tmp2));
break;
//jumps
case 0x20: strcpy(chr,"JSR"); goto _jump;
case 0x4C: strcpy(chr,"JMP"); goto _jump;
case 0x6C: absolute(tmp); sprintf(str,"JMP ($%04X) = $%04X", tmp,GetMem(tmp)|GetMem(tmp+1)<<8); break;
_jump:
absolute(tmp);
sprintf(str,"%s $%04X", chr,tmp);
break;
//Zero Page,Y
case 0x96: strcpy(chr,"STX"); goto _zeropagey;
case 0xB6: strcpy(chr,"LDX"); goto _zeropagey;
_zeropagey:
zpIndex(tmp,X.Y);
// ################################## Start of SP CODE ###########################
// Change width to %04X
sprintf(str,"%s $%04X,Y @ $%04X = #$%02X", chr,opcode[1],tmp,GetMem(tmp));
// ################################## End of SP CODE ###########################
break;
//UNDEFINED
default: strcpy(str,"ERROR"); break;

View File

@ -27,6 +27,7 @@
#include "..\..\nsf.h"
#include "..\..\cart.h"
#include "..\..\ines.h"
#include "..\..\asm.h"
#include "tracer.h"
#include "memview.h"
#include "cheat.h"
@ -282,17 +283,6 @@ BOOL CALLBACK AddbpCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE; //TRUE;
}
char *BinToASM(int addr, uint8 *opcode) {
static char str[64]={0},chr[5]={0};
uint16 tmp,tmp2;
switch (opcode[0]) {
#include "dasm.inc"
}
return str;
}
void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// ################################## Start of SP CODE ###########################
@ -353,7 +343,7 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// ################################## Start of SP CODE ###########################
a = BinToASM(addr,opcode);
a = Disassemble(addr,opcode);
if (symbDebugEnabled)
{
@ -396,7 +386,7 @@ char *DisassembleLine(int addr) {
strcat(str," "); //pad output to align ASM
size++;
}
strcat(strcat(str," "),BinToASM(addr,opcode));
strcat(strcat(str," "),Disassemble(addr,opcode));
}
}
if ((c=strchr(str,'='))) *(c-1) = 0;
@ -429,7 +419,7 @@ char *DisassembleData(int addr, uint8 *opcode) {
strcat(str," "); //pad output to align ASM
size++;
}
strcat(strcat(str," "),BinToASM(addr,opcode));
strcat(strcat(str," "),Disassemble(addr,opcode));
}
}
if ((c=strchr(str,'='))) *(c-1) = 0;
@ -643,10 +633,7 @@ void DeleteBreak(int sel) {
void KillDebugger() {
SendDlgItemMessage(hDebug,302,LB_RESETCONTENT,0,0);
numWPs = 0;
step = 0;
stepout = 0;
jsrcount = 0;
FCEUI_Debugger().reset();
FCEUI_SetEmulationPaused(0); //mbg merge 7/18/06 changed from userpause
}
@ -661,40 +648,6 @@ int AddAsmHistory(HWND hwndDlg, int id, char *str) {
return 1;
}
int ParseASM(unsigned char *output, int addr, char *str) {
unsigned char opcode[3] = { 0,0,0 };
char astr[128],ins[4];
if ((!strlen(str)) || (strlen(str) > 0x127)) return 1;
strcpy(astr,str);
str_ucase(astr);
sscanf(astr,"%3s",ins); //get instruction
if (strlen(ins) != 3) return 1;
strcpy(astr,strstr(astr,ins)+3); //heheh, this is probably a bad idea, but let's do it anyway!
if ((astr[0] != ' ') && (astr[0] != 0)) return 1;
//remove all whitespace
str_strip(astr,STRIP_SP|STRIP_TAB|STRIP_CR|STRIP_LF);
//repair syntax
chr_replace(astr,'[','('); //brackets
chr_replace(astr,']',')');
chr_replace(astr,'{','(');
chr_replace(astr,'}',')');
chr_replace(astr,';',0); //comments
str_replace(astr,"0X","$"); //miscellaneous
//This does the following:
// 1) Sets opcode[0] on success, else returns 1.
// 2) Parses text in *astr to build the rest of the assembled
// data in 'opcode', else returns 1 on error.
#include "asm.inc"
memcpy(output,opcode,3);
return 0;
}
BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
int romaddr,count,i,j;
char str[128],*dasm;
@ -781,7 +734,7 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
count = 0;
for (i = 0; i < patchlen; i++) count += opsize[patchdata[i][0]];
GetDlgItemText(hwndDlg,100,str,21);
if (!ParseASM(patchdata[patchlen],(iaPC+count),str)) {
if (!Assemble(patchdata[patchlen],(iaPC+count),str)) {
count = iaPC;
for (i = 0; i <= patchlen; i++) count += opsize[patchdata[i][0]];
if (count > 0x10000) { //note: don't use 0xFFFF!
@ -967,7 +920,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
// ################################## End of SP CODE ###########################
badopbreak = 0;
FCEUI_Debugger().badopbreak = false;
debugger_open = 1;
FillBreakList(hwndDlg);
break;
@ -975,7 +928,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
case WM_CLOSE:
case WM_QUIT:
exitdebug:
badopbreak = 0;
FCEUI_Debugger().badopbreak = 0;
debugger_open = 0;
DeleteObject(hNewFont);
DestroyWindow(hwndDlg);
@ -1183,7 +1136,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
//mbg merge 7/18/06 changed pausing check and set
if (FCEUI_EmulationPaused()) {
UpdateRegs(hwndDlg);
step = 1;
FCEUI_Debugger().step = true;
FCEUI_SetEmulationPaused(0);
UpdateDebugger();
}
@ -1191,11 +1144,12 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
case 106: //Step Out
//mbg merge 7/18/06 changed pausing check and set
if (FCEUI_EmulationPaused() > 0) {
DebuggerState &dbgstate = FCEUI_Debugger();
UpdateRegs(hwndDlg);
if ((stepout) && (MessageBox(hwndDlg,"Step Out is currently in process. Cancel it and setup a new Step Out watch?","Step Out Already Active",MB_YESNO|MB_ICONINFORMATION) != IDYES)) break;
if (GetMem(X.PC) == 0x20) jsrcount = 1;
else jsrcount = 0;
stepout = 1;
if ((dbgstate.stepout) && (MessageBox(hwndDlg,"Step Out is currently in process. Cancel it and setup a new Step Out watch?","Step Out Already Active",MB_YESNO|MB_ICONINFORMATION) != IDYES)) break;
if (GetMem(X.PC) == 0x20) dbgstate.jsrcount = 1;
else dbgstate.jsrcount = 0;
dbgstate.stepout = 1;
FCEUI_SetEmulationPaused(0);
UpdateDebugger();
}
@ -1209,7 +1163,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
watchpoint[64].address = (tmp+3);
watchpoint[64].flags = WP_E|WP_X;
}
else step = 1;
else FCEUI_Debugger().step = true;
FCEUI_SetEmulationPaused(0);
}
break;
@ -1231,7 +1185,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
break;
case 110: //Break on bad opcode
badopbreak ^=1;
FCEUI_Debugger().badopbreak ^=1;
break;
case 200: X.P^=N_FLAG; UpdateDebugger(); break;
case 201: X.P^=V_FLAG; UpdateDebugger(); break;

View File

@ -7,10 +7,8 @@
//extern volatile int userpause; //mbg merge 7/18/06 removed for merging
extern int scanline; //current scanline! :D
extern int badopbreak;
extern HWND hDebug;
extern int step,stepout,jsrcount;
extern int childwnd,numWPs; //mbg merge 7/18/06 had to make extern
BOOL CenterWindow(HWND hwndDlg);
@ -20,8 +18,6 @@ int GetEditHex(HWND hwndDlg, int id);
extern void AddBreakList();
char *BinToASM(int addr, uint8 *opcode);
void UpdateDebugger();
void DoDebug(uint8 halt);

View File

@ -23,9 +23,10 @@
#include "..\..\x6502.h"
#include "..\..\fceu.h"
#include "..\..\cart.h" //mbg merge 7/19/06 moved after fceu.h
#include "cdlogger.h"
#include "..\..\file.h"
#include "..\..\debug.h"
#include "..\..\asm.h"
#include "cdlogger.h"
#include "tracer.h"
#include "memview.h"
@ -321,20 +322,20 @@ void FCEUD_TraceInstruction(){
case 1:
opcode[0]=GetMem(addr++);
sprintf(data, "%02X ", opcode[0]);
strcpy(disassembly,BinToASM(addr,opcode));
strcpy(disassembly,Disassemble(addr,opcode));
break;
case 2:
opcode[0]=GetMem(addr++);
opcode[1]=GetMem(addr++);
sprintf(data, "%02X %02X ", opcode[0],opcode[1]);
strcpy(disassembly,BinToASM(addr,opcode));
strcpy(disassembly,Disassemble(addr,opcode));
break;
case 3:
opcode[0]=GetMem(addr++);
opcode[1]=GetMem(addr++);
opcode[2]=GetMem(addr++);
sprintf(data, "%02X %02X %02X ", opcode[0],opcode[1],opcode[2]);
strcpy(disassembly,BinToASM(addr,opcode));
strcpy(disassembly,Disassemble(addr,opcode));
break;
}
}

View File

@ -779,16 +779,6 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
break; /* Hopefully this won't break DInput... */
}
}
/*
if(!(lParam&0x40000000))
switch( wParam )
{
case VK_F11:FCEUI_PowerNES();break;
case VK_F12:DoFCEUExit();break;
//case VK_F2:userpause^=1;break;
case VK_F3:ToggleHideMenu();break;
}
*/
goto proco;
case WM_CLOSE:
case WM_DESTROY:

View File

@ -689,12 +689,12 @@ void FCEUI_SetEmulationPaused(int val) {
void FCEUI_ToggleEmulationPause(void)
{
EmulationPaused = (EmulationPaused&1)^1;
EmulationPaused = (EmulationPaused&1)^1;
}
void FCEUI_FrameAdvance(void)
{
EmulationPaused |= 1|2;
EmulationPaused |= 1|2;
}
static int RewindCounter = 0;

View File

@ -1,5 +1,5 @@
/// \file
/// brief RFC 1321 compliant MD5 implementation,
/// \brief RFC 1321 compliant MD5 implementation,
/// RFC 1321 compliant MD5 implementation,
/// by Christophe Devine <devine@cr0.net>;
/// this program is licensed under the GPL.

View File

@ -51,6 +51,27 @@ static DECLFR(NSF_read);
static int vismode=1;
//mbg 7/31/06 todo - no reason this couldnt be assembled on the fly from actual asm source code. thatd be less obscure.
//here it is disassembled, for reference
/*
00:8000:8D F4 3F STA $3FF4 = #$00
00:8003:A2 FF LDX #$FF
00:8005:9A TXS
00:8006:AD F0 3F LDA $3FF0 = #$00
00:8009:F0 09 BEQ $8014
00:800B:AD F1 3F LDA $3FF1 = #$00
00:800E:AE F3 3F LDX $3FF3 = #$00
00:8011:20 00 00 JSR $0000
00:8014:A9 00 LDA #$00
00:8016:AA TAX
00:8017:A8 TAY
00:8018:20 00 00 JSR $0000
00:801B:8D F5 EF STA $EFF5 = #$FF
00:801E:90 FE BCC $801E
00:8020:8D F3 3F STA $3FF3 = #$00
00:8023:18 CLC
00:8024:90 FE BCC $8024
*/
static uint8 NSFROM[0x30+6]=
{
/* 0x00 - NMI */

View File

@ -25,15 +25,11 @@
#include <stdlib.h>
#define FCEU_VERSION_NUMERIC 9816
#define FCEU_NAME "FCEUX"
#define FCEU_VERSION_STRING "1.07"
#define FCEU_NAME "FCE Ultra"
#define FCEU_VERSION_STRING "1.9.9"
#define FCEU_NAME_AND_VERSION FCEU_NAME " " FCEU_VERSION_STRING
//#define FCEU_VERSION_STRING "1.07"
//#define FCEU_VERSION "0.98.17"
//#define FCEUXD_VERSION_STRING "1.0a"
//#define FCEUXDSP_VERSION_STRING "1.07"
//causes the code fragment argument to be compiled in if the build includes debugging
///causes the code fragment argument to be compiled in if the build includes debugging
#ifdef FCEUDEF_DEBUGGER
#define DEBUG(X) X;
#else

View File

@ -355,6 +355,10 @@
<Filter
Name="src"
>
<File
RelativePath="..\src\asm.cpp"
>
</File>
<File
RelativePath="..\src\cart.cpp"
>
@ -1386,6 +1390,10 @@
<Filter
Name="win"
>
<File
RelativePath="..\src\asm.h"
>
</File>
<File
RelativePath="..\src\drivers\win\aviout.cpp"
>