X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=x6502.c;h=c20edf9dc7a65ac3526f9b73dea9f5572c69665b;hp=dc6aab0e7d835e47292e2ca88e17bc6330e52d80;hb=6244011fd85a10400accd6d8e7d941144f92aa5b;hpb=13a7da558887ad47a9f21b4c86cc4d7fd797cf42 diff --git a/x6502.c b/x6502.c index dc6aab0..c20edf9 100644 --- a/x6502.c +++ b/x6502.c @@ -26,6 +26,8 @@ #include "sound.h" #include "cart.h" +#include "dprintf.h" + #ifdef DEBUG_ASM_6502 #include #include @@ -61,27 +63,24 @@ uint32 timestamp; static INLINE uint8 RdMem(unsigned int A) { - // notaz: try to avoid lookup of every address at least for ROM and RAM areas - // I've verified that if ARead[0xfff0] points to CartBR, it is always normal ROM read. -#if 0 - if ((A&0x8000)/* && ARead[0xfff0] == CartBR*/) { - return (_DB=Page[A>>11][A]); - } -#endif -#if 0 // enabling this causes 4fps slowdown. Why? - if ((A&0xe000) == 0) { // RAM area (always 0-0x1fff) - return (_DB=RAM[A&0x7FF]); - } -#endif - _DB=ARead[A](A); + int _DB1=ARead[A](A); #ifdef DEBUG_ASM_6502 + //_DB=_DB1; //printf("a == %x, pc == %x\n", A, _PC); - if (A >= 0x2000 && A != _PC && A != _PC - 1 && A != _PC + 1) { - dreads[dread_count_c++] = _DB; + if (A >= 0x2000) { + if (A == _PC || A == _PC - 1 || A == _PC + 1) { + //printf("fr: %02x\n", _DB1); + } + _DB=_DB1; + } + if (A >= 0x2000 && A != _PC - 1) { + dreads[dread_count_c++] = _DB1; if (dread_count_c > 4) { printf("dread_count out of range\n"); exit(1); } } +#else + _DB=_DB1; #endif - return _DB; + return _DB1; } static INLINE void WrMem(unsigned int A, uint8 V) @@ -100,7 +99,12 @@ static INLINE void WrMem(unsigned int A, uint8 V) static INLINE uint8 RdRAM(unsigned int A) { - return((_DB=RAM[A])); + //return((_DB=RAM[A])); + int _DB1=RAM[A]; +#ifndef DEBUG_ASM_6502 + _DB=_DB1; +#endif + return _DB1; } static INLINE void WrRAM(unsigned int A, uint8 V) @@ -375,6 +379,7 @@ static uint8 ZNTable[256] = { static uint8 CycTable[256] = { +/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ /*0x00*/ 7,6,2,8,3,3,5,5,3,2,2,2,4,4,6,6, /*0x10*/ 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7, /*0x20*/ 6,6,2,8,3,3,5,5,4,2,2,2,4,4,6,6, @@ -395,11 +400,13 @@ static uint8 CycTable[256] = void FASTAPASS(1) X6502_IRQBegin_c(int w) { + dprintf("IRQB %02x",w); _IRQlow|=w; } void FASTAPASS(1) X6502_IRQEnd_c(int w) { + dprintf("IRQE %02x",w); _IRQlow&=~w; } @@ -408,15 +415,6 @@ void TriggerIRQ_c(void) /* This function should probably be phased out. */ _IRQlow|=FCEU_IQTEMP; } -void TriggerNMINSF_c(void) -{ - ADDCYC(7); - PUSH(_PC>>8); - PUSH(_PC); - PUSH((_P&~B_FLAG)|(U_FLAG)); - _PC=0x3800; -} - void TriggerNMI_c(void) { _IRQlow|=FCEU_IQNMI; @@ -426,6 +424,7 @@ static void TriggerNMIReal(void) { if(!_jammed) { + dprintf("NMI"); ADDCYC(7); PUSH(_PC>>8); PUSH(_PC); @@ -444,6 +443,7 @@ void TriggerIRQReal(void) { if(!(_PI&I_FLAG) && !_jammed) { + dprintf("IRQ"); ADDCYC(7); PUSH(_PC>>8); PUSH(_PC); @@ -463,7 +463,6 @@ void X6502_Reset_c(void) { _PC=RdMem(0xFFFC); _PC|=RdMem(0xFFFD)<<8; - if(FCEUGameInfo.type==GIT_NSF) _PC=0x3830; _jammed=0; _PI=_P=I_FLAG; } @@ -513,7 +512,11 @@ void X6502_Run_c(void/*int32 cycles*/) } } _PI=_P; +#ifdef DEBUG_ASM_6502 + b1=RdMem(_PC++); _PC--; +#else b1=RdMem(_PC); +#endif ADDCYC(CycTable[b1]); temp=_tcount; @@ -536,7 +539,7 @@ void X6502_Run_c(void/*int32 cycles*/) { extern uint8 SIRQStat; SIRQStat|=0x80; - X6502_IRQBegin_c(FCEU_IQDPCM); + X6502_IRQBegin(FCEU_IQDPCM); } } }