little stuff, release build brought up to date
[[Split portion of a mixed commit.]]
This commit is contained in:
parent
e4675d9616
commit
c0958be02c
608
x6502.c
608
x6502.c
|
@ -24,12 +24,18 @@
|
||||||
#include "x6502.h"
|
#include "x6502.h"
|
||||||
#include "fceu.h"
|
#include "fceu.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
//mbg merge 6/29/06
|
||||||
|
#include "debugger.h" //bbit edited: line added
|
||||||
|
#include "tracer.h" //bbit edited: line added
|
||||||
|
#include "memview.h" //bbit edited: line added
|
||||||
|
#include "cdlogger.h"
|
||||||
|
|
||||||
X6502 X;
|
X6502 X;
|
||||||
|
|
||||||
#ifdef FCEUDEF_DEBUGGER
|
//mbg merge 7/19/06
|
||||||
void (*X6502_Run)(int32 cycles);
|
//#ifdef FCEUDEF_DEBUGGER
|
||||||
#endif
|
//void (*X6502_Run)(int32 cycles);
|
||||||
|
//#endif
|
||||||
|
|
||||||
uint32 timestamp;
|
uint32 timestamp;
|
||||||
void FP_FASTAPASS(1) (*MapIRQHook)(int a);
|
void FP_FASTAPASS(1) (*MapIRQHook)(int a);
|
||||||
|
@ -47,6 +53,338 @@ void FP_FASTAPASS(1) (*MapIRQHook)(int a);
|
||||||
#define _IRQlow X.IRQlow
|
#define _IRQlow X.IRQlow
|
||||||
#define _jammed X.jammed
|
#define _jammed X.jammed
|
||||||
|
|
||||||
|
|
||||||
|
//-------
|
||||||
|
//mbg merge 6/29/06
|
||||||
|
//bbit edited: a large portion of code was inserted from here on down
|
||||||
|
extern uint8 *XBuf;
|
||||||
|
//extern void FCEUD_BlitScreen(uint8 *XBuf);
|
||||||
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); //mbg merge 6/30/06 - do this instead
|
||||||
|
static int indirectnext;
|
||||||
|
|
||||||
|
static INLINE void BreakHit() {
|
||||||
|
DoDebug(1);
|
||||||
|
FCEUI_SetEmulationPaused(1); //mbg merge 7/19/06 changed to use EmulationPaused()
|
||||||
|
//if((!logtofile) && (logging))PauseLoggingSequence();
|
||||||
|
UpdateLogWindow();
|
||||||
|
if(hMemView)UpdateMemoryView(0);
|
||||||
|
|
||||||
|
//mbg merge 6/30/06 - this architecture has changed
|
||||||
|
FCEUD_Update(0,0,0);
|
||||||
|
//FCEUD_BlitScreen(XBuf+8); //this looks odd, I know. but the pause routine is in here!!
|
||||||
|
//if(logging)LogInstruction(); //logging might have been started while we were paused
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE void LogCDVectors(int which){
|
||||||
|
int i = 0xFFFA+(which*2);
|
||||||
|
int j;
|
||||||
|
j = GetPRGAddress(i);
|
||||||
|
if(j == -1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cdloggerdata[j] == 0){
|
||||||
|
cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need
|
||||||
|
datacount++;
|
||||||
|
undefinedcount--;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
|
||||||
|
if(cdloggerdata[j] == 0){
|
||||||
|
cdloggerdata[j] |= 0x0E; // we're in the last bank and recording it as data so 0x1110 or 0xE should be what we need
|
||||||
|
datacount++;
|
||||||
|
undefinedcount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
static INLINE void LogCDData(){
|
||||||
|
int i, j;
|
||||||
|
uint16 A=0;
|
||||||
|
uint8 opcode[3] = {0};
|
||||||
|
|
||||||
|
j = GetPRGAddress(_PC);
|
||||||
|
|
||||||
|
opcode[0] = GetMem(_PC);
|
||||||
|
for (i = 1; i < opsize[opcode[0]]; i++) opcode[i] = GetMem(_PC+i);
|
||||||
|
|
||||||
|
if(j != -1){
|
||||||
|
for (i = 0; i < opsize[opcode[0]]; i++){
|
||||||
|
if(cdloggerdata[j+i] & 1)continue; //this has been logged so skip
|
||||||
|
cdloggerdata[j+i] |= 1;
|
||||||
|
cdloggerdata[j+i] |=((_PC+i)>>11)&12;
|
||||||
|
if(indirectnext)cdloggerdata[j+i] |= 0x10;
|
||||||
|
codecount++;
|
||||||
|
if(!(cdloggerdata[j+i] & 0x42))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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ################################## Start of SP CODE ###########################
|
||||||
|
|
||||||
|
// Returns the value of a given type or register
|
||||||
|
|
||||||
|
int getValue(int type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 'A': return _A;
|
||||||
|
case 'X': return _X;
|
||||||
|
case 'Y': return _Y;
|
||||||
|
case 'N': return _P & N_FLAG ? 1 : 0;
|
||||||
|
case 'V': return _P & V_FLAG ? 1 : 0;
|
||||||
|
case 'U': return _P & U_FLAG ? 1 : 0;
|
||||||
|
case 'B': return _P & B_FLAG ? 1 : 0;
|
||||||
|
case 'D': return _P & D_FLAG ? 1 : 0;
|
||||||
|
case 'I': return _P & I_FLAG ? 1 : 0;
|
||||||
|
case 'Z': return _P & Z_FLAG ? 1 : 0;
|
||||||
|
case 'C': return _P & C_FLAG ? 1 : 0;
|
||||||
|
case 'P': return _PC;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Evaluates a condition
|
||||||
|
int evaluate(Condition* c)
|
||||||
|
{
|
||||||
|
int f = 0;
|
||||||
|
|
||||||
|
int value1, value2;
|
||||||
|
|
||||||
|
if (c->lhs)
|
||||||
|
{
|
||||||
|
value1 = evaluate(c->lhs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch(c->type1)
|
||||||
|
{
|
||||||
|
case TYPE_ADDR:
|
||||||
|
case TYPE_NUM: value1 = c->value1; break;
|
||||||
|
default: value1 = getValue(c->value1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->type1 == TYPE_ADDR)
|
||||||
|
{
|
||||||
|
value1 = GetMem(value1);
|
||||||
|
}
|
||||||
|
|
||||||
|
f = value1;
|
||||||
|
|
||||||
|
if (c->op)
|
||||||
|
{
|
||||||
|
if (c->rhs)
|
||||||
|
{
|
||||||
|
value2 = evaluate(c->rhs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch(c->type2)
|
||||||
|
{
|
||||||
|
case TYPE_ADDR:
|
||||||
|
case TYPE_NUM: value2 = c->value2; break;
|
||||||
|
default: value2 = getValue(c->type2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->type2 == TYPE_ADDR)
|
||||||
|
{
|
||||||
|
value2 = GetMem(value2);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c->op)
|
||||||
|
{
|
||||||
|
case OP_EQ: f = value1 == value2; break;
|
||||||
|
case OP_NE: f = value1 != value2; break;
|
||||||
|
case OP_GE: f = value1 >= value2; break;
|
||||||
|
case OP_LE: f = value1 <= value2; break;
|
||||||
|
case OP_G: f = value1 > value2; break;
|
||||||
|
case OP_L: f = value1 < value2; break;
|
||||||
|
case OP_MULT: f = value1 * value2; break;
|
||||||
|
case OP_DIV: f = value1 / value2; break;
|
||||||
|
case OP_PLUS: f = value1 + value2; break;
|
||||||
|
case OP_MINUS: f = value1 - value2; break;
|
||||||
|
case OP_OR: f = value1 || value2; break;
|
||||||
|
case OP_AND: f = value1 && value2; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int condition(watchpointinfo* wp)
|
||||||
|
{
|
||||||
|
return wp->cond == 0 || evaluate(wp->cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ################################## End of SP CODE ###########################
|
||||||
|
|
||||||
|
//extern int step;
|
||||||
|
//extern int stepout;
|
||||||
|
//extern int jsrcount;
|
||||||
|
void breakpoint() {
|
||||||
|
int i;
|
||||||
|
uint16 A=0;
|
||||||
|
uint8 brk_type,opcode[3] = {0};
|
||||||
|
|
||||||
|
opcode[0] = GetMem(_PC);
|
||||||
|
|
||||||
|
if(badopbreak && (opsize[opcode[0]] == 0))BreakHit();
|
||||||
|
|
||||||
|
if (stepout) {
|
||||||
|
if (opcode[0] == 0x20) jsrcount++;
|
||||||
|
else if (opcode[0] == 0x60) {
|
||||||
|
if (jsrcount) jsrcount--;
|
||||||
|
else {
|
||||||
|
stepout = 0;
|
||||||
|
step = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (step) {
|
||||||
|
step = 0;
|
||||||
|
BreakHit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((watchpoint[64].address == _PC) && (watchpoint[64].flags)) {
|
||||||
|
watchpoint[64].address = 0;
|
||||||
|
watchpoint[64].flags = 0;
|
||||||
|
BreakHit();
|
||||||
|
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]]) {
|
||||||
|
case 0: /*A = _PC;*/ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < numWPs; i++) {
|
||||||
|
// ################################## Start of SP CODE ###########################
|
||||||
|
if (condition(&watchpoint[i]))
|
||||||
|
{
|
||||||
|
// ################################## End of SP CODE ###########################
|
||||||
|
if (watchpoint[i].flags & BT_P) { //PPU Mem breaks
|
||||||
|
if ((watchpoint[i].flags & WP_E) && (watchpoint[i].flags & brk_type) && ((A >= 0x2000) && (A < 0x4000)) && ((A&7) == 7)) {
|
||||||
|
if (watchpoint[i].endaddress) {
|
||||||
|
if ((watchpoint[i].address <= RefreshAddr) && (watchpoint[i].endaddress >= RefreshAddr)) BreakHit();
|
||||||
|
}
|
||||||
|
else if (watchpoint[i].address == RefreshAddr) BreakHit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (watchpoint[i].flags & BT_S) { //Sprite Mem breaks
|
||||||
|
if ((watchpoint[i].flags & WP_E) && (watchpoint[i].flags & brk_type) && ((A >= 0x2000) && (A < 0x4000)) && ((A&7) == 4)) {
|
||||||
|
if (watchpoint[i].endaddress) {
|
||||||
|
if ((watchpoint[i].address <= PPU[3]) && (watchpoint[i].endaddress >= PPU[3])) BreakHit();
|
||||||
|
}
|
||||||
|
else if (watchpoint[i].address == PPU[3]) BreakHit();
|
||||||
|
}
|
||||||
|
else if ((watchpoint[i].flags & WP_E) && (watchpoint[i].flags & WP_W) && (A == 0x4014)) BreakHit(); //Sprite DMA! :P
|
||||||
|
}
|
||||||
|
else { //CPU mem breaks
|
||||||
|
if ((watchpoint[i].flags & WP_E) && (watchpoint[i].flags & brk_type)) {
|
||||||
|
if (watchpoint[i].endaddress) {
|
||||||
|
if (((!(watchpoint[i].flags & WP_X)) && (watchpoint[i].address <= A) && (watchpoint[i].endaddress >= A)) ||
|
||||||
|
((watchpoint[i].flags & WP_X) && (watchpoint[i].address <= _PC) && (watchpoint[i].endaddress >= _PC))) BreakHit();
|
||||||
|
}
|
||||||
|
else if (((!(watchpoint[i].flags & WP_X)) && (watchpoint[i].address == A)) ||
|
||||||
|
((watchpoint[i].flags & WP_X) && (watchpoint[i].address == _PC))) BreakHit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ################################## Start of SP CODE ###########################
|
||||||
|
}
|
||||||
|
// ################################## End of SP CODE ###########################
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//bbit edited: this is the end of the inserted code
|
||||||
|
|
||||||
#define ADDCYC(x) \
|
#define ADDCYC(x) \
|
||||||
{ \
|
{ \
|
||||||
int __x=x; \
|
int __x=x; \
|
||||||
|
@ -55,47 +393,49 @@ void FP_FASTAPASS(1) (*MapIRQHook)(int a);
|
||||||
timestamp+=__x; \
|
timestamp+=__x; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//mbg 6/30/06 - hooked functions arent being used right now
|
||||||
|
////hooked memory read
|
||||||
|
//static INLINE uint8 RdMemHook(unsigned int A)
|
||||||
|
//{
|
||||||
|
// if(X.ReadHook)
|
||||||
|
// return(_DB = X.ReadHook(&X,A) );
|
||||||
|
// else
|
||||||
|
// return(_DB=ARead[A](A));
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////hooked memory write
|
||||||
|
//static INLINE void WrMemHook(unsigned int A, uint8 V)
|
||||||
|
//{
|
||||||
|
// if(X.WriteHook)
|
||||||
|
// X.WriteHook(&X,A,V);
|
||||||
|
// else
|
||||||
|
// BWrite[A](A,V);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//#define RdRAMFast(A) (_DB=RAM[(A)])
|
||||||
|
//#define WrRAMFast(A,V) RAM[(A)]=(V)
|
||||||
|
|
||||||
|
//normal memory read
|
||||||
static INLINE uint8 RdMemNorm(unsigned int A)
|
static INLINE uint8 RdMemNorm(unsigned int A)
|
||||||
{
|
{
|
||||||
return(_DB=ARead[A](A));
|
return(_DB=ARead[A](A));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//normal memory write
|
||||||
static INLINE void WrMemNorm(unsigned int A, uint8 V)
|
static INLINE void WrMemNorm(unsigned int A, uint8 V)
|
||||||
{
|
{
|
||||||
BWrite[A](A,V);
|
BWrite[A](A,V);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FCEUDEF_DEBUGGER
|
static INLINE uint8 RdRAMNorm(unsigned int A)
|
||||||
X6502 XSave; /* This is getting ugly. */
|
|
||||||
//#define RdMemHook(A) ( X.ReadHook?(_DB=X.ReadHook(&X,A)):(_DB=ARead[A](A)) )
|
|
||||||
//#define WrMemHook(A,V) { if(X.WriteHook) X.WriteHook(&X,A,V); else BWrite[A](A,V); }
|
|
||||||
|
|
||||||
static INLINE uint8 RdMemHook(unsigned int A)
|
|
||||||
{
|
{
|
||||||
if(X.ReadHook)
|
//bbit edited: this was changed so cheat substituion would work
|
||||||
return(_DB = X.ReadHook(&X,A) );
|
|
||||||
else
|
|
||||||
return(_DB=ARead[A](A));
|
return(_DB=ARead[A](A));
|
||||||
|
// return(_DB=RAM[A]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void WrMemHook(unsigned int A, uint8 V)
|
static INLINE void WrRAMNorm(unsigned int A, uint8 V)
|
||||||
{
|
|
||||||
if(X.WriteHook)
|
|
||||||
X.WriteHook(&X,A,V);
|
|
||||||
else
|
|
||||||
BWrite[A](A,V);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define RdRAMFast(A) (_DB=RAM[(A)])
|
|
||||||
//#define WrRAMFast(A,V) RAM[(A)]=(V)
|
|
||||||
|
|
||||||
static INLINE uint8 RdRAMFast(unsigned int A)
|
|
||||||
{
|
|
||||||
return(_DB=RAM[A]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE void WrRAMFast(unsigned int A, uint8 V)
|
|
||||||
{
|
{
|
||||||
RAM[A]=V;
|
RAM[A]=V;
|
||||||
}
|
}
|
||||||
|
@ -451,6 +791,138 @@ void X6502_Power(void)
|
||||||
X6502_Reset();
|
X6502_Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mbg 6/30/06 merge - this function reworked significantly for merge
|
||||||
|
void X6502_Run(int32 cycles)
|
||||||
|
{
|
||||||
|
#define RdRAM RdRAMNorm
|
||||||
|
#define WrRAM WrRAMNorm
|
||||||
|
#define RdMem RdMemNorm
|
||||||
|
#define WrMem WrMemNorm
|
||||||
|
|
||||||
|
if(PAL)
|
||||||
|
cycles*=15; // 15*4=60
|
||||||
|
else
|
||||||
|
cycles*=16; // 16*4=64
|
||||||
|
|
||||||
|
_count+=cycles;
|
||||||
|
|
||||||
|
while(_count>0)
|
||||||
|
{
|
||||||
|
int32 temp;
|
||||||
|
uint8 b1;
|
||||||
|
|
||||||
|
if(_IRQlow)
|
||||||
|
{
|
||||||
|
if(_IRQlow&FCEU_IQRESET)
|
||||||
|
{
|
||||||
|
if(loggingcodedata)LogCDVectors(0);
|
||||||
|
_PC=RdMem(0xFFFC);
|
||||||
|
_PC|=RdMem(0xFFFD)<<8;
|
||||||
|
_jammed=0;
|
||||||
|
_PI=_P=I_FLAG;
|
||||||
|
_IRQlow&=~FCEU_IQRESET;
|
||||||
|
}
|
||||||
|
else if(_IRQlow&FCEU_IQNMI2)
|
||||||
|
{
|
||||||
|
_IRQlow&=~FCEU_IQNMI2;
|
||||||
|
_IRQlow|=FCEU_IQNMI;
|
||||||
|
}
|
||||||
|
else if(_IRQlow&FCEU_IQNMI)
|
||||||
|
{
|
||||||
|
if(!_jammed)
|
||||||
|
{
|
||||||
|
ADDCYC(7);
|
||||||
|
PUSH(_PC>>8);
|
||||||
|
PUSH(_PC);
|
||||||
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
|
_P|=I_FLAG;
|
||||||
|
if(loggingcodedata)LogCDVectors(1);
|
||||||
|
_PC=RdMem(0xFFFA);
|
||||||
|
_PC|=RdMem(0xFFFB)<<8;
|
||||||
|
_IRQlow&=~FCEU_IQNMI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!(_PI&I_FLAG) && !_jammed)
|
||||||
|
{
|
||||||
|
ADDCYC(7);
|
||||||
|
PUSH(_PC>>8);
|
||||||
|
PUSH(_PC);
|
||||||
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
|
_P|=I_FLAG;
|
||||||
|
if(loggingcodedata)LogCDVectors(1);
|
||||||
|
_PC=RdMem(0xFFFE);
|
||||||
|
_PC|=RdMem(0xFFFF)<<8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_IRQlow&=~(FCEU_IQTEMP);
|
||||||
|
if(_count<=0)
|
||||||
|
{
|
||||||
|
_PI=_P;
|
||||||
|
return;
|
||||||
|
} //Should increase accuracy without a
|
||||||
|
//major speed hit.
|
||||||
|
}
|
||||||
|
|
||||||
|
//will probably cause a major speed decrease on low-end systems
|
||||||
|
//bbit edited: this line added
|
||||||
|
if (numWPs | step | stepout | watchpoint[64].flags | badopbreak)
|
||||||
|
breakpoint();
|
||||||
|
if(loggingcodedata)LogCDData();
|
||||||
|
//mbg 6/30/06 - this was commented out when i got here. i dont understand it anyway
|
||||||
|
//if(logging || (hMemView && (EditingMode == 2))) LogInstruction();
|
||||||
|
if(logging) LogInstruction();
|
||||||
|
//---
|
||||||
|
|
||||||
|
_PI=_P;
|
||||||
|
b1=RdMem(_PC);
|
||||||
|
|
||||||
|
ADDCYC(CycTable[b1]);
|
||||||
|
|
||||||
|
temp=_tcount;
|
||||||
|
_tcount=0;
|
||||||
|
if(MapIRQHook) MapIRQHook(temp);
|
||||||
|
FCEU_SoundCPUHook(temp);
|
||||||
|
_PC++;
|
||||||
|
switch(b1)
|
||||||
|
{
|
||||||
|
#include "ops.h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef RdRAM
|
||||||
|
#undef WrRAM
|
||||||
|
#undef RdMem
|
||||||
|
#undef WrMem
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void X6502_Debug(void (*CPUHook)(X6502 *),
|
||||||
|
uint8 (*ReadHook)(X6502 *, unsigned int),
|
||||||
|
void (*WriteHook)(X6502 *, unsigned int, uint8))
|
||||||
|
{
|
||||||
|
//mbg 6/30/06 - stubbed out because we don't support the hooked cpu
|
||||||
|
//debugmode=(ReadHook || WriteHook || CPUHook)?1:0;
|
||||||
|
//X.ReadHook=ReadHook;
|
||||||
|
//X.WriteHook=WriteHook;
|
||||||
|
//X.CPUHook=CPUHook;
|
||||||
|
}
|
||||||
|
|
||||||
|
//mbg 6/30/06 - the non-hooked cpu core and core switching has been removed to mimic XD.
|
||||||
|
//this could be put back in later
|
||||||
|
/*
|
||||||
|
|
||||||
|
//#ifdef FCEUDEF_DEBUGGER
|
||||||
|
//X6502 XSave; // This is getting ugly.
|
||||||
|
//#define RdMemHook(A) ( X.ReadHook?(_DB=X.ReadHook(&X,A)):(_DB=ARead[A](A)) )
|
||||||
|
//#define WrMemHook(A,V) { if(X.WriteHook) X.WriteHook(&X,A,V); else BWrite[A](A,V); }
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef FCEUDEF_DEBUGGER
|
||||||
|
void (*X6502_Run)(int32 cycles);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FCEUDEF_DEBUGGER
|
#ifdef FCEUDEF_DEBUGGER
|
||||||
static void X6502_RunDebug(int32 cycles)
|
static void X6502_RunDebug(int32 cycles)
|
||||||
{
|
{
|
||||||
|
@ -495,6 +967,7 @@ static void X6502_RunDebug(int32 cycles)
|
||||||
PUSH(_PC);
|
PUSH(_PC);
|
||||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
_P|=I_FLAG;
|
_P|=I_FLAG;
|
||||||
|
if(loggingcodedata)LogCDVectors(1); //mbg 6/29/06
|
||||||
_PC=RdMem(0xFFFA);
|
_PC=RdMem(0xFFFA);
|
||||||
_PC|=RdMem(0xFFFB)<<8;
|
_PC|=RdMem(0xFFFB)<<8;
|
||||||
_IRQlow&=~FCEU_IQNMI;
|
_IRQlow&=~FCEU_IQNMI;
|
||||||
|
@ -509,6 +982,7 @@ static void X6502_RunDebug(int32 cycles)
|
||||||
PUSH(_PC);
|
PUSH(_PC);
|
||||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
_P|=I_FLAG;
|
_P|=I_FLAG;
|
||||||
|
if(loggingcodedata)LogCDVectors(1); //mbg 6/29/06
|
||||||
_PC=RdMem(0xFFFE);
|
_PC=RdMem(0xFFFE);
|
||||||
_PC|=RdMem(0xFFFF)<<8;
|
_PC|=RdMem(0xFFFF)<<8;
|
||||||
}
|
}
|
||||||
|
@ -518,13 +992,23 @@ static void X6502_RunDebug(int32 cycles)
|
||||||
{
|
{
|
||||||
_PI=_P;
|
_PI=_P;
|
||||||
return;
|
return;
|
||||||
} /* Should increase accuracy without a */
|
} //Should increase accuracy without a
|
||||||
/* major speed hit. */
|
//major speed hit.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---
|
||||||
|
//mbg merge 6/29/06
|
||||||
|
//will probably cause a major speed decrease on low-end systems
|
||||||
|
if (numWPs | step | stepout | watchpoint[64].flags | badopbreak) breakpoint(); //bbit edited: this line added
|
||||||
|
if(loggingcodedata)LogCDData();
|
||||||
|
if(logging
|
||||||
|
//|| (hMemView && (EditingMode == 2))
|
||||||
|
)LogInstruction();
|
||||||
|
//---
|
||||||
|
|
||||||
if(X.CPUHook) X.CPUHook(&X);
|
if(X.CPUHook) X.CPUHook(&X);
|
||||||
/* Ok, now the real fun starts. */
|
//Ok, now the real fun starts.
|
||||||
/* Do the pre-exec voodoo. */
|
//Do the pre-exec voodoo.
|
||||||
if(X.ReadHook || X.WriteHook)
|
if(X.ReadHook || X.WriteHook)
|
||||||
{
|
{
|
||||||
uint32 tsave=timestamp;
|
uint32 tsave=timestamp;
|
||||||
|
@ -541,8 +1025,8 @@ static void X6502_RunDebug(int32 cycles)
|
||||||
|
|
||||||
timestamp=tsave;
|
timestamp=tsave;
|
||||||
|
|
||||||
/* In case an NMI/IRQ/RESET was triggered by the debugger. */
|
//In case an NMI/IRQ/RESET was triggered by the debugger.
|
||||||
/* Should we also copy over the other hook variables? */
|
//Should we also copy over the other hook variables?
|
||||||
XSave.IRQlow=X.IRQlow;
|
XSave.IRQlow=X.IRQlow;
|
||||||
XSave.ReadHook=X.ReadHook;
|
XSave.ReadHook=X.ReadHook;
|
||||||
XSave.WriteHook=X.WriteHook;
|
XSave.WriteHook=X.WriteHook;
|
||||||
|
@ -574,6 +1058,7 @@ static void X6502_RunDebug(int32 cycles)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void X6502_RunNormal(int32 cycles)
|
static void X6502_RunNormal(int32 cycles)
|
||||||
#else
|
#else
|
||||||
void X6502_Run(int32 cycles)
|
void X6502_Run(int32 cycles)
|
||||||
|
@ -584,17 +1069,17 @@ void X6502_Run(int32 cycles)
|
||||||
#define RdMem RdMemNorm
|
#define RdMem RdMemNorm
|
||||||
#define WrMem WrMemNorm
|
#define WrMem WrMemNorm
|
||||||
|
|
||||||
#if(defined(C80x86) && defined(__GNUC__))
|
//#if(defined(C80x86) && defined(__GNUC__))
|
||||||
/* Gives a nice little speed boost. */
|
//// Gives a nice little speed boost.
|
||||||
register uint16 pbackus asm ("edi");
|
//register uint16 pbackus asm ("edi");
|
||||||
#else
|
//#else
|
||||||
uint16 pbackus;
|
//uint16 pbackus;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
pbackus=_PC;
|
//pbackus=_PC;
|
||||||
|
|
||||||
#undef _PC
|
//#undef _PC
|
||||||
#define _PC pbackus
|
//#define _PC pbackus
|
||||||
|
|
||||||
if(PAL)
|
if(PAL)
|
||||||
cycles*=15; // 15*4=60
|
cycles*=15; // 15*4=60
|
||||||
|
@ -633,6 +1118,7 @@ void X6502_Run(int32 cycles)
|
||||||
PUSH(_PC);
|
PUSH(_PC);
|
||||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
_P|=I_FLAG;
|
_P|=I_FLAG;
|
||||||
|
if(loggingcodedata)LogCDVectors(1); //mbg 6/29/06
|
||||||
_PC=RdMem(0xFFFA);
|
_PC=RdMem(0xFFFA);
|
||||||
_PC|=RdMem(0xFFFB)<<8;
|
_PC|=RdMem(0xFFFB)<<8;
|
||||||
_IRQlow&=~FCEU_IQNMI;
|
_IRQlow&=~FCEU_IQNMI;
|
||||||
|
@ -647,6 +1133,7 @@ void X6502_Run(int32 cycles)
|
||||||
PUSH(_PC);
|
PUSH(_PC);
|
||||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||||
_P|=I_FLAG;
|
_P|=I_FLAG;
|
||||||
|
if(loggingcodedata)LogCDVectors(1); //mbg 6/29/06
|
||||||
_PC=RdMem(0xFFFE);
|
_PC=RdMem(0xFFFE);
|
||||||
_PC|=RdMem(0xFFFF)<<8;
|
_PC|=RdMem(0xFFFF)<<8;
|
||||||
}
|
}
|
||||||
|
@ -655,12 +1142,24 @@ void X6502_Run(int32 cycles)
|
||||||
if(_count<=0)
|
if(_count<=0)
|
||||||
{
|
{
|
||||||
_PI=_P;
|
_PI=_P;
|
||||||
X.PC=pbackus;
|
//X.PC=pbackus;
|
||||||
return;
|
return;
|
||||||
} /* Should increase accuracy without a */
|
} //Should increase accuracy without a
|
||||||
/* major speed hit. */
|
//major speed hit.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---
|
||||||
|
//mbg merge 6/29/06
|
||||||
|
//will probably cause a major speed decrease on low-end systems
|
||||||
|
if (numWPs | step | stepout | watchpoint[64].flags | badopbreak)
|
||||||
|
breakpoint(); //bbit edited: this line added
|
||||||
|
if(loggingcodedata)LogCDData();
|
||||||
|
if(logging
|
||||||
|
// || (hMemView && (EditingMode == 2))
|
||||||
|
)
|
||||||
|
LogInstruction();
|
||||||
|
//---
|
||||||
|
|
||||||
_PI=_P;
|
_PI=_P;
|
||||||
b1=RdMem(_PC);
|
b1=RdMem(_PC);
|
||||||
|
|
||||||
|
@ -670,8 +1169,7 @@ void X6502_Run(int32 cycles)
|
||||||
_tcount=0;
|
_tcount=0;
|
||||||
if(MapIRQHook) MapIRQHook(temp);
|
if(MapIRQHook) MapIRQHook(temp);
|
||||||
FCEU_SoundCPUHook(temp);
|
FCEU_SoundCPUHook(temp);
|
||||||
//printf("%04x\n",X.PC);
|
//X.PC=pbackus;
|
||||||
X.PC=pbackus;
|
|
||||||
_PC++;
|
_PC++;
|
||||||
switch(b1)
|
switch(b1)
|
||||||
{
|
{
|
||||||
|
@ -679,10 +1177,10 @@ void X6502_Run(int32 cycles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef _PC
|
//#undef _PC
|
||||||
#define _PC X.PC
|
//#define _PC X.PC
|
||||||
_PC=pbackus;
|
//_PC=pbackus;
|
||||||
#undef RdRAM
|
//#undef RdRAM
|
||||||
#undef WrRAM
|
#undef WrRAM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,4 +1200,4 @@ void X6502_Debug(void (*CPUHook)(X6502 *),
|
||||||
X6502_Run=X6502_RunDebug;
|
X6502_Run=X6502_RunDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif*/
|
||||||
|
|
15
x6502.h
15
x6502.h
|
@ -22,15 +22,20 @@
|
||||||
|
|
||||||
#include "x6502struct.h"
|
#include "x6502struct.h"
|
||||||
|
|
||||||
#ifdef FCEUDEF_DEBUGGER
|
//-----------
|
||||||
|
//mbg 6/30/06 - some of this was removed to mimic XD
|
||||||
|
//#ifdef FCEUDEF_DEBUGGER
|
||||||
void X6502_Debug(void (*CPUHook)(X6502 *),
|
void X6502_Debug(void (*CPUHook)(X6502 *),
|
||||||
uint8 (*ReadHook)(X6502 *, unsigned int),
|
uint8 (*ReadHook)(X6502 *, unsigned int),
|
||||||
void (*WriteHook)(X6502 *, unsigned int, uint8));
|
void (*WriteHook)(X6502 *, unsigned int, uint8));
|
||||||
|
|
||||||
extern void (*X6502_Run)(int32 cycles);
|
//extern void (*X6502_Run)(int32 cycles);
|
||||||
#else
|
//#else
|
||||||
void X6502_Run(int32 cycles);
|
//void X6502_Run(int32 cycles);
|
||||||
#endif
|
//#endif
|
||||||
|
void X6502_RunDebug(int32 cycles);
|
||||||
|
#define X6502_Run(x) X6502_RunDebug(x)
|
||||||
|
//------------
|
||||||
|
|
||||||
extern uint32 timestamp;
|
extern uint32 timestamp;
|
||||||
extern X6502 X;
|
extern X6502 X;
|
||||||
|
|
Loading…
Reference in New Issue