X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fv65c02.cpp;h=0ddf25143011ef8bc8158b1ac13180bb105c9c1f;hb=c0001155bc0909da61f6c849c0be9b16e9b7f4b6;hp=5ef1709eed6a5fd91def85c06ca01443c79138cc;hpb=c0bc82a6324c65aefd62cc3eb33c09a14db638bf;p=apple2 diff --git a/src/v65c02.cpp b/src/v65c02.cpp index 5ef1709..0ddf251 100755 --- a/src/v65c02.cpp +++ b/src/v65c02.cpp @@ -1142,7 +1142,6 @@ static void Op90(void) // BCC if (!(regs.cc & FLAG_C)) HANDLE_BRANCH_TAKEN(m) -// regs.pc += m; } static void OpB0(void) // BCS @@ -1151,7 +1150,6 @@ static void OpB0(void) // BCS if (regs.cc & FLAG_C) HANDLE_BRANCH_TAKEN(m) -// regs.pc += m; } static void OpF0(void) // BEQ @@ -1160,7 +1158,6 @@ static void OpF0(void) // BEQ if (regs.cc & FLAG_Z) HANDLE_BRANCH_TAKEN(m) -// regs.pc += m; } /* @@ -2606,7 +2603,9 @@ static void Op86(void) static void Op96(void) { - regs.WrMem(EA_ZP_X, regs.x); +// BUG!!! [FIXED] +//WAS: regs.WrMem(EA_ZP_X, regs.x); + regs.WrMem(EA_ZP_Y, regs.x); } static void Op8E(void) @@ -2807,6 +2806,7 @@ void (* exec_op[256])() = { OpF0, OpF1, OpF2, Op__, Op__, OpF5, OpF6, OpF7, OpF8, OpF9, OpFA, Op__, Op__, OpFD, OpFE, OpFF }; + // // Internal "memcpy" (so we don't have to link with any external libraries!) // @@ -2843,12 +2843,27 @@ FBEF: 60 602 RTS2B RTS //int instCount[256]; #ifdef __DEBUG__ bool dumpDis = false; +//bool dumpDis = true; #endif +/* +On //e, $FCAA is the delay routine. (seems to not have changed from ][+) +*/ + + //Note: could enforce regs.clock to zero on starting the CPU with an Init() function... //bleh. //static uint32_t limit = 0; - +// Or, we could just say that initializing the CPU struct is the responsibility +// of the caller. :-) + +#define DO_BACKTRACE +#ifdef DO_BACKTRACE +#define BACKTRACE_SIZE 16384 +uint32_t btQueuePtr = 0; +V65C02REGS btQueue[BACKTRACE_SIZE]; +uint8_t btQueueInst[BACKTRACE_SIZE][4]; +#endif // // Function to execute 65C02 for "cycles" cycles // @@ -2857,24 +2872,7 @@ void Execute65C02(V65C02REGS * context, uint32_t cycles) myMemcpy(®s, context, sizeof(V65C02REGS)); // Execute here... -// NOTE: There *must* be some way of doing this without requiring the caller to subtract out -// the previous run's cycles. !!! FIX !!! -// Could try: -// while (regs.clock < regs.clock + cycles) <-- won't work -/* - // This isn't as accurate as subtracting out cycles from regs.clock... - // Unless limit is a static variable, adding cycles to it each time through... - uint32_t limit = regs.clock + cycles; - while (regs.clock < limit) -*/ -// but have wraparound to deal with. :-/ -/* -Let's see... - - if (regs.clock + cycles > 0xFFFFFFFF) - wraparound = true; -*/ - uint64_t endCycles = regs.clock + (uint64_t)cycles; + uint64_t endCycles = regs.clock + (uint64_t)cycles - regs.overflow; while (regs.clock < endCycles) { @@ -2894,7 +2892,67 @@ if (regs.pc == 0x444E) dumpDis = false; }//*/ #endif +/*if (regs.pc == 0xBF4C) +{ + dumpDis = true; +}//*/ + +#if 0 +/*if (regs.pc == 0x0801) +{ + WriteLog("\n*** DISK BOOT subroutine...\n\n"); + dumpDis = true; +}//*/ +if (regs.pc == 0xE000) +{ +#if 0 + WriteLog("\n*** Dump of $E000 routine ***\n\n"); + for(uint32_t addr=0xE000; addr<0xF000;) + { + addr += Decode65C02(addr); + WriteLog("\n"); + } +#endif + WriteLog("\n*** DISK part II subroutine...\n\n"); + dumpDis = true; +}//*/ +if (regs.pc == 0xD000) +{ + WriteLog("\n*** CUSTOM DISK READ subroutine...\n\n"); + dumpDis = false; +}//*/ +if (regs.pc == 0xD1BE) +{ +// WriteLog("\n*** DISK part II subroutine...\n\n"); + dumpDis = true; +}//*/ +if (regs.pc == 0xD200) +{ + WriteLog("\n*** CUSTOM SCREEN subroutine...\n\n"); + dumpDis = false; +}//*/ +if (regs.pc == 0xD269) +{ +// WriteLog("\n*** DISK part II subroutine...\n\n"); + dumpDis = true; +}//*/ +#endif +//if (regs.pc == 0xE08E) +/*if (regs.pc == 0xAD33) +{ + WriteLog("\n*** After loader ***\n\n"); + dumpDis = true; +}//*/ +/*if (regs.pc == 0x0418) +{ + WriteLog("\n*** CUSTOM DISK READ subroutine...\n\n"); + dumpDis = false; +} +if (regs.pc == 0x0) +{ + dumpDis = true; +}//*/ #ifdef __DEBUGMON__ //WAIT is commented out here because it's called by BELL1... if (regs.pc == 0xFCA8) @@ -2925,8 +2983,12 @@ if (regs.pc == 0x2000) #endif #ifdef __DEBUG__ +static char disbuf[80]; if (dumpDis) - Decode65C02(regs.pc); +{ + Decode65C02(disbuf, regs.pc); + WriteLog("%s", disbuf); +} #endif uint8_t opcode = regs.RdMem(regs.pc++); @@ -3019,14 +3081,16 @@ WriteLog("\n*** IRQ ***\n\n"); } } -//This is a lame way of doing it, but in the end the simplest--however, it destroys any -//record of elasped CPU time. Not sure that it's important to keep track, but there it is. -// Now we use a 64-bit integer, so it won't wrap for about 500 millenia. ;-) -// regs.clock -= cycles; + // If we went longer than the passed in cycles, make a note of it so we can + // subtract it out from a subsequent run. It's guaranteed to be positive, + // because the condition that exits the main loop above is written such + // that regs.clock has to be larger than endCycles to exit from it. + regs.overflow = regs.clock - endCycles; myMemcpy(context, ®s, sizeof(V65C02REGS)); } + // // Get the clock of the currently executing CPU // @@ -3034,3 +3098,4 @@ uint64_t GetCurrentV65C02Clock(void) { return regs.clock; } +