cdlogger: fixed bug preventing correct interrupt vectors logging (there is no IRQ loggead at all)
cdlogger: various code refactoring and cleanup
This commit is contained in:
parent
892758907d
commit
f1f21bb00e
150
src/debug.cpp
150
src/debug.cpp
|
@ -195,10 +195,10 @@ unsigned int NewBreak(const char* name, int start, int end, unsigned int type, c
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPRGAddress(int A){
|
int GetPRGAddress(int A){
|
||||||
unsigned int result;
|
int result;
|
||||||
if((A < 0x8000) || (A > 0xFFFF))return -1;
|
if((A < 0x8000) || (A > 0xFFFF))return -1;
|
||||||
result = &Page[A>>11][A]-PRGptr[0];
|
result = &Page[A>>11][A]-PRGptr[0];
|
||||||
if((result > PRGsize[0]) || (result < 0))return -1;
|
if((result > (int)PRGsize[0]) || (result < 0))return -1;
|
||||||
else return result;
|
else return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,93 +360,94 @@ int condition(watchpointinfo* wp)
|
||||||
//---------------------
|
//---------------------
|
||||||
|
|
||||||
volatile int codecount, datacount, undefinedcount;
|
volatile int codecount, datacount, undefinedcount;
|
||||||
//HWND hCDLogger=0;
|
|
||||||
unsigned char *cdloggerdata;
|
unsigned char *cdloggerdata;
|
||||||
char *cdlogfilename;
|
char *cdlogfilename;
|
||||||
//char loadedcdfile[MAX_PATH];
|
|
||||||
static int indirectnext;
|
static int indirectnext;
|
||||||
|
|
||||||
int debug_loggingCD;
|
int debug_loggingCD;
|
||||||
|
|
||||||
//called by the cpu to perform logging if CDLogging is enabled
|
//called by the cpu to perform logging if CDLogging is enabled
|
||||||
void LogCDVectors(int which){
|
void LogCDVectors(int which){
|
||||||
int i = 0xFFFA+(which*2);
|
|
||||||
int j;
|
int j;
|
||||||
j = GetPRGAddress(i);
|
j = GetPRGAddress(which);
|
||||||
if(j == -1){
|
if(j == -1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cdloggerdata[j] == 0){
|
if(!(cdloggerdata[j] & 2)){
|
||||||
cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need
|
cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need
|
||||||
datacount++;
|
datacount++;
|
||||||
undefinedcount--;
|
if(!(cdloggerdata[j] & 1))undefinedcount--;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
if(cdloggerdata[j] == 0){
|
if(!(cdloggerdata[j] & 2)){
|
||||||
cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need
|
cdloggerdata[j] |= 0x0E;
|
||||||
datacount++;
|
datacount++;
|
||||||
undefinedcount--;
|
if(!(cdloggerdata[j] & 1))undefinedcount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogCDData(){
|
void LogCDData(){
|
||||||
int i, j;
|
int i, j;
|
||||||
uint16 A=0;
|
uint16 A = 0;
|
||||||
uint8 opcode[3] = {0};
|
uint8 opcode[3] = {0}, memop = 0;
|
||||||
|
|
||||||
j = GetPRGAddress(_PC);
|
j = GetPRGAddress(_PC);
|
||||||
|
|
||||||
opcode[0] = GetMem(_PC);
|
if(j != -1) {
|
||||||
for (i = 1; i < opsize[opcode[0]]; i++) opcode[i] = GetMem(_PC+i);
|
opcode[0] = GetMem(_PC);
|
||||||
|
switch (opsize[opcode[0]]) {
|
||||||
|
case 2:
|
||||||
|
opcode[1] = GetMem(_PC + 1);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
opcode[1] = GetMem(_PC + 1);
|
||||||
|
opcode[2] = GetMem(_PC + 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(j != -1){
|
|
||||||
for (i = 0; i < opsize[opcode[0]]; i++){
|
for (i = 0; i < opsize[opcode[0]]; i++){
|
||||||
if(cdloggerdata[j+i] & 1)continue; //this has been logged so skip
|
if(cdloggerdata[j+i] & 1)continue; //this has been logged so skip
|
||||||
cdloggerdata[j+i] |= 1;
|
cdloggerdata[j+i] |= 1;
|
||||||
cdloggerdata[j+i] |=((_PC+i)>>11)&12;
|
cdloggerdata[j+i] |=((_PC+i)>>11)&0x0c;
|
||||||
if(indirectnext)cdloggerdata[j+i] |= 0x10;
|
if(indirectnext)cdloggerdata[j+i] |= 0x10;
|
||||||
codecount++;
|
codecount++;
|
||||||
if(!(cdloggerdata[j+i] & 0x42))undefinedcount--;
|
if(!(cdloggerdata[j+i] & 2))undefinedcount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
//log instruction jumped to in an indirect jump
|
||||||
|
if(opcode[0] == 0x6c) indirectnext = 1; else indirectnext = 0;
|
||||||
|
|
||||||
|
switch (optype[opcode[0]]) {
|
||||||
|
case 0: break;
|
||||||
|
case 1:
|
||||||
|
A = (opcode[1]+_X) & 0xFF;
|
||||||
|
A = GetMem(A) | (GetMem(A+1)<<8);
|
||||||
|
memop = 0x20;
|
||||||
|
break;
|
||||||
|
case 2: A = opcode[1]; break;
|
||||||
|
case 3: A = opcode[1] | opcode[2]<<8; break;
|
||||||
|
case 4:
|
||||||
|
A = (GetMem(opcode[1]) | (GetMem(opcode[1]+1)<<8))+_Y;
|
||||||
|
memop = 0x20;
|
||||||
|
break;
|
||||||
|
case 5: A = opcode[1]+_X; break;
|
||||||
|
case 6: A = (opcode[1] | (opcode[2]<<8))+_Y; break;
|
||||||
|
case 7: A = (opcode[1] | (opcode[2]<<8))+_X; break;
|
||||||
|
case 8: A = opcode[1]+_Y; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((j = GetPRGAddress(A)) != -1) {
|
||||||
|
if(!(cdloggerdata[j] & 2)) {
|
||||||
|
cdloggerdata[j] |= 2;
|
||||||
|
cdloggerdata[j] |=(A>>11)&0x0c;
|
||||||
|
cdloggerdata[j] |= memop;
|
||||||
|
datacount++;
|
||||||
|
if(!(cdloggerdata[j] & 1))undefinedcount--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
indirectnext = 0;
|
|
||||||
//log instruction jumped to in an indirect jump
|
|
||||||
if(opcode[0] == 0x6c){
|
|
||||||
indirectnext = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (optype[opcode[0]]) {
|
|
||||||
case 0: break;
|
|
||||||
case 1:
|
|
||||||
A = (opcode[1]+_X) & 0xFF;
|
|
||||||
A = GetMem(A) | (GetMem(A+1))<<8;
|
|
||||||
break;
|
|
||||||
case 2: A = opcode[1]; break;
|
|
||||||
case 3: A = opcode[1] | opcode[2]<<8; break;
|
|
||||||
case 4: A = (GetMem(opcode[1]) | (GetMem(opcode[1]+1))<<8)+_Y; break;
|
|
||||||
case 5: A = opcode[1]+_X; break;
|
|
||||||
case 6: A = (opcode[1] | opcode[2]<<8)+_Y; break;
|
|
||||||
case 7: A = (opcode[1] | opcode[2]<<8)+_X; break;
|
|
||||||
case 8: A = opcode[1]+_Y; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if(opbrktype[opcode[0]] != WP_R)return; //we only want reads
|
|
||||||
|
|
||||||
if((j = GetPRGAddress(A)) == -1)return;
|
|
||||||
//if(j == 0)BreakHit();
|
|
||||||
|
|
||||||
|
|
||||||
if(cdloggerdata[j] & 2)return;
|
|
||||||
cdloggerdata[j] |= 2;
|
|
||||||
cdloggerdata[j] |=((A/*+i*/)>>11)&12;
|
|
||||||
if((optype[opcode[0]] == 1) || (optype[opcode[0]] == 4))cdloggerdata[j] |= 0x20;
|
|
||||||
datacount++;
|
|
||||||
if(!(cdloggerdata[j+i] & 1))undefinedcount--;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------debugger stuff
|
//-----------debugger stuff
|
||||||
|
@ -492,41 +493,6 @@ void BreakHit(bool force = false) {
|
||||||
|
|
||||||
FCEUD_DebugBreakpoint();
|
FCEUD_DebugBreakpoint();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
//very ineffecient, but this shouldn't get executed THAT much
|
|
||||||
if(!(cdloggerdata[GetPRGAddress(0xFFFA)] & 2)){
|
|
||||||
cdloggerdata[GetPRGAddress(0xFFFA)]|=2;
|
|
||||||
codecount++;
|
|
||||||
undefinedcount--;
|
|
||||||
}
|
|
||||||
if(!(cdloggerdata[GetPRGAddress(0xFFFB)] & 2)){
|
|
||||||
cdloggerdata[GetPRGAddress(0xFFFB)]|=2;
|
|
||||||
codecount++;
|
|
||||||
undefinedcount--;
|
|
||||||
}
|
|
||||||
if(!(cdloggerdata[GetPRGAddress(0xFFFC)] & 2)){
|
|
||||||
cdloggerdata[GetPRGAddress(0xFFFC)]|=2;
|
|
||||||
codecount++;
|
|
||||||
undefinedcount--;
|
|
||||||
}
|
|
||||||
if(!(cdloggerdata[GetPRGAddress(0xFFFD)] & 2)){
|
|
||||||
cdloggerdata[GetPRGAddress(0xFFFD)]|=2;
|
|
||||||
codecount++;
|
|
||||||
undefinedcount--;
|
|
||||||
}
|
|
||||||
if(!(cdloggerdata[GetPRGAddress(0xFFFE)] & 2)){
|
|
||||||
cdloggerdata[GetPRGAddress(0xFFFE)]|=2;
|
|
||||||
codecount++;
|
|
||||||
undefinedcount--;
|
|
||||||
}
|
|
||||||
if(!(cdloggerdata[GetPRGAddress(0xFFFF)] & 2)){
|
|
||||||
cdloggerdata[GetPRGAddress(0xFFFF)]|=2;
|
|
||||||
codecount++;
|
|
||||||
undefinedcount--;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
///fires a breakpoint
|
///fires a breakpoint
|
||||||
void breakpoint() {
|
void breakpoint() {
|
||||||
|
|
|
@ -693,7 +693,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//These Windows only dialogs need to be updated only once per frame so they are included here
|
//These Windows only dialogs need to be updated only once per frame so they are included here
|
||||||
UpdateCheatList();
|
// UpdateCheatList(); // can't see why, this is only cause problems with selection
|
||||||
UpdateTextHooker();
|
UpdateTextHooker();
|
||||||
Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
Update_RAM_Search(); // Update_RAM_Watch() is also called.
|
||||||
RamChange();
|
RamChange();
|
||||||
|
|
|
@ -841,10 +841,10 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
FCEU_printf(" Mapper #: %d\n Mapper name: %s\n Mirroring: %s\n",
|
FCEU_printf(" Mapper #: %d\n Mapper name: %s\n Mirroring: %s\n",
|
||||||
MapperNo, mappername, Mirroring==2?"None(Four-screen)":Mirroring?"Vertical":"Horizontal");
|
MapperNo, mappername, Mirroring==2?"None (Four-screen)":Mirroring?"Vertical":"Horizontal");
|
||||||
|
|
||||||
FCEU_printf(" Battery-backed: %s\n", (head.ROM_type&2)?"True":"False");
|
FCEU_printf(" Battery-backed: %s\n", (head.ROM_type&2)?"Yes":"No");
|
||||||
FCEU_printf(" Trained: %s\n", (head.ROM_type&4)?"True":"False");
|
FCEU_printf(" Trained: %s\n", (head.ROM_type&4)?"Yes":"No");
|
||||||
// (head.ROM_type&8) = Mirroring: None(Four-screen)
|
// (head.ROM_type&8) = Mirroring: None(Four-screen)
|
||||||
|
|
||||||
SetInput();
|
SetInput();
|
||||||
|
|
|
@ -428,7 +428,7 @@ extern int test; test++;
|
||||||
{
|
{
|
||||||
if(_IRQlow&FCEU_IQRESET)
|
if(_IRQlow&FCEU_IQRESET)
|
||||||
{
|
{
|
||||||
if(debug_loggingCD) LogCDVectors(0);
|
DEBUG( if(debug_loggingCD) LogCDVectors(0xFFFC); )
|
||||||
_PC=RdMem(0xFFFC);
|
_PC=RdMem(0xFFFC);
|
||||||
_PC|=RdMem(0xFFFD)<<8;
|
_PC|=RdMem(0xFFFD)<<8;
|
||||||
_jammed=0;
|
_jammed=0;
|
||||||
|
@ -449,7 +449,7 @@ extern int test; test++;
|
||||||
PUSH(_PC);
|
PUSH(_PC);
|
||||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
_P|=I_FLAG;
|
_P|=I_FLAG;
|
||||||
DEBUG( if(debug_loggingCD) LogCDVectors(1) );
|
DEBUG( if(debug_loggingCD) LogCDVectors(0xFFFA) );
|
||||||
_PC=RdMem(0xFFFA);
|
_PC=RdMem(0xFFFA);
|
||||||
_PC|=RdMem(0xFFFB)<<8;
|
_PC|=RdMem(0xFFFB)<<8;
|
||||||
_IRQlow&=~FCEU_IQNMI;
|
_IRQlow&=~FCEU_IQNMI;
|
||||||
|
@ -464,7 +464,7 @@ extern int test; test++;
|
||||||
PUSH(_PC);
|
PUSH(_PC);
|
||||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
_P|=I_FLAG;
|
_P|=I_FLAG;
|
||||||
DEBUG( if(debug_loggingCD) LogCDVectors(1) );
|
DEBUG( if(debug_loggingCD) LogCDVectors(0xFFFE) );
|
||||||
_PC=RdMem(0xFFFE);
|
_PC=RdMem(0xFFFE);
|
||||||
_PC|=RdMem(0xFFFF)<<8;
|
_PC|=RdMem(0xFFFF)<<8;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue