asm core fix for Flintstones
[fceu.git] / x6502.c
diff --git a/x6502.c b/x6502.c
index c8c0032..57f8a00 100644 (file)
--- a/x6502.c
+++ b/x6502.c
@@ -26,6 +26,8 @@
 #include "sound.h"
 #include "cart.h"
 
+#include "dprintf.h"
+
 #ifdef DEBUG_ASM_6502
 #include <stdio.h>
 #include <stdlib.h>
@@ -61,31 +63,21 @@ 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);
+ /*if (A >= 0x2000)*/ _DB=_DB1;
 #ifdef DEBUG_ASM_6502
  //printf("a == %x, pc == %x\n", A, _PC);
  if (A >= 0x2000 && A != _PC && A != _PC - 1 && A != _PC + 1) {
-  dreads[dread_count_c++] = _DB;
+  dreads[dread_count_c++] = _DB1;
   if (dread_count_c > 4) { printf("dread_count out of range\n"); exit(1); }
  }
 #endif
- return _DB;
+ return _DB1;
 }
 
 static INLINE void WrMem(unsigned int A, uint8 V)
 {
+ //printf("w [%04x] %02x\n", A, V);
  if ((A&0xe000) == 0) { // RAM area (always 0-0x1fff)
   RAM[A&0x7FF] = V;
   return;
@@ -99,6 +91,7 @@ static INLINE void WrMem(unsigned int A, uint8 V)
 
 static INLINE uint8 RdRAM(unsigned int A)
 {
+ //return((_DB=RAM[A]));
  return((_DB=RAM[A]));
 }
 
@@ -394,11 +387,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;
 }
 
@@ -425,6 +420,7 @@ static void TriggerNMIReal(void)
 {
  if(!_jammed)
  {
+  dprintf("NMI");
   ADDCYC(7);
   PUSH(_PC>>8);
   PUSH(_PC);
@@ -443,6 +439,7 @@ void TriggerIRQReal(void)
 {
  if(!(_PI&I_FLAG) && !_jammed)
  {
+  dprintf("IRQ");
   ADDCYC(7);
   PUSH(_PC>>8);
   PUSH(_PC);
@@ -462,7 +459,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;
 }