X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fjaguar.cpp;h=0cd84112cace49ef9b8aba93d3df11951e05278a;hb=253f7b2713969c4982a3149c55e378db51d7791d;hp=268befde8a1066121820e6219c06a47cbf6bbde1;hpb=e285d9bb9ae73f64443fa4add30119dc422c4d08;p=virtualjaguar diff --git a/src/jaguar.cpp b/src/jaguar.cpp index 268befd..0cd8411 100644 --- a/src/jaguar.cpp +++ b/src/jaguar.cpp @@ -88,6 +88,37 @@ static bool start = false; void M68KInstructionHook(void) { uint32 m68kPC = m68k_get_reg(NULL, M68K_REG_PC); +// Temp, for comparing... +{ +/* static char buffer[2048];//, mem[64]; + m68k_disassemble(buffer, m68kPC, M68K_CPU_TYPE_68000); + printf("%08X: %s\n", m68kPC, buffer);//*/ +} +//JaguarDasm(m68kPC, 1); +//Testing Hover Strike... +#if 0 +//Dasm(regs.pc, 1); +static int hitCount = 0; +static int inRoutine = 0; +static int instSeen; + +//if (regs.pc == 0x80340A) +if (m68kPC == 0x803416) +{ + hitCount++; + inRoutine = 1; + instSeen = 0; + printf("%i: $80340A start. A0=%08X, A1=%08X ", hitCount, m68k_get_reg(NULL, M68K_REG_A0), m68k_get_reg(NULL, M68K_REG_A1)); +} +else if (m68kPC == 0x803422) +{ + inRoutine = 0; + printf("(%i instructions)\n", instSeen); +} + +if (inRoutine) + instSeen++; +#endif // For tracebacks... // Ideally, we'd save all the registers as well... @@ -854,7 +885,7 @@ int irq_ack_handler(int level) // Tracing the IPL lines on the Jaguar schematic yields the following: // IPL1 is connected to INTL on TOM (OUT to 68K) // IPL0-2 are also tied to Vcc via 4.7K resistors! - // (DINT on TOM goes into DINT on JERRY (IN from Jerry)) + // (DINT on TOM goes into DINT on JERRY (IN Tom from Jerry)) // There doesn't seem to be any other path to IPL0 or 2 on the schematic, which means // that *all* IRQs to the 68K are routed thru TOM at level 2. Which means they're all maskable. @@ -1054,6 +1085,9 @@ void m68k_write_memory_8(unsigned int address, unsigned int value) /*if (effect_start) if (address >= 0x18FA70 && address < (0x18FA70 + 8000)) WriteLog("M68K: Byte %02X written at %08X by 68K\n", value, address);//*/ +//$53D0 +/*if (address >= 0x53D0 && address <= 0x53FF) + printf("M68K: Writing byte $%02X at $%08X, PC=$%08X\n", value, address, m68k_get_reg(NULL, M68K_REG_PC));//*/ #ifndef USE_NEW_MMU if ((address >= 0x000000) && (address <= 0x3FFFFF)) @@ -1117,6 +1151,9 @@ if (address == 0xF02110) /* if (address == 0x51136 || address == 0x51138 || address == 0xFB074 || address == 0xFB076 || address == 0x1AF05E) WriteLog("[WM16 PC=%08X] Addr: %08X, val: %04X\n", m68k_get_reg(NULL, M68K_REG_PC), address, value);//*/ +//$53D0 +/*if (address >= 0x53D0 && address <= 0x53FF) + printf("M68K: Writing word $%04X at $%08X, PC=$%08X\n", value, address, m68k_get_reg(NULL, M68K_REG_PC));//*/ #ifndef USE_NEW_MMU if ((address >= 0x000000) && (address <= 0x3FFFFE)) @@ -1777,8 +1814,8 @@ void JaguarDone(void) JaguarDasm(0x802000, 6000); WriteLog("\n");//*/ #endif -/* WriteLog("\n\nM68000 disassembly at $080000...\n"); - JaguarDasm(0x080000, 10000); +/* WriteLog("\n\nM68000 disassembly at $4000...\n"); + JaguarDasm(0x4000, 10000); WriteLog("\n");//*/ } @@ -1806,6 +1843,8 @@ void JaguarExecute(uint32 * backbuffer, bool render) //seem to indicate the refresh rate is *half* the above... // uint16 refreshRate = (vjs.hardwareTypeNTSC ? 30 : 25); // Should these be hardwired or read from VP? Yes, from VP! + // Err, actually, they should be hardwired, and hardwired to a set # of + // lines as well... uint32 M68KCyclesPerScanline = m68kClockRate / (vp * refreshRate); uint32 RISCCyclesPerScanline = m68kClockRate / (vp * refreshRate); @@ -1914,15 +1953,68 @@ void JaguarExecuteNew(void) while (!frameDone); } +/* +BIG NOTE: NEED TO FIX THIS TO RUN ON ABSOLUTE TIMINGS BASED ON SCANLINES, + *NOT* ON THE VERTICAL PERIOD!!! + + scanlines are 64 µs in PAL + and 63.5555... µs in NTSC + +Also: 625 lines per frame in PAL, 525 in NTSC + +So... can use +#define RISC_CYCLE_IN_USEC 0.03760684198 +#define M68K_CYCLE_IN_USEC (RISC_CYCLE_IN_USEC * 2) + +#define HORIZ_PERIOD_IN_USEC_NTSC 63.555555555 +#define HORIZ_PERIOD_IN_USEC_PAL 64.0 + +#define USEC_TO_RISC_CYCLES(u) (uint32)(((u) / RISC_CYCLE_IN_USEC) + 0.5) +#define USEC_TO_M68K_CYCLES(u) (uint32)(((u) / M68K_CYCLE_IN_USEC) + 0.5) + +to figure cycles per half-line... + +USEC_TO_RISC_CYCLES(HORIZ_PERIOD_IN_USEC_NTSC) / 2 +USEC_TO_M68K_CYCLES(HORIZ_PERIOD_IN_USEC_NTSC) / 2 +USEC_TO_RISC_CYCLES(HORIZ_PERIOD_IN_USEC_PAL) / 2 +USEC_TO_M68K_CYCLES(HORIZ_PERIOD_IN_USEC_PAL) / 2 + +// Full lines here, divide by two for half-lines... +which gives the following: 1690, 845 (NTSC), 1702, 851 (PAL) +So, for a full frame, that would yield: +887250 (NTSC), 1063750 (PAL) +one second: +26617500 (NTSC), 26593750 (PAL) + +Which is off a little bit for NTSC... +#define M68K_CLOCK_RATE_PAL 13296950 +#define M68K_CLOCK_RATE_NTSC 13295453 +#define RISC_CLOCK_RATE_PAL 26593900 +#define RISC_CLOCK_RATE_NTSC 26590906 + +*/ + +#define USE_CORRECT_PAL_TIMINGS void ScanlineCallback(void) { +//OK, this is hardwired to run in NTSC, and for who knows how long. +//Need to fix this so that it does a half-line in the correct amount of time +//and number of lines, depending on which mode we're in. [FIXED] uint16 vc = TOMReadWord(0xF00006, JAGUAR); uint16 vp = TOMReadWord(0xF0003E, JAGUAR) + 1; uint16 vi = TOMReadWord(0xF0004E, JAGUAR); // uint16 vbb = TOMReadWord(0xF00040, JAGUAR); vc++; +#ifdef USE_CORRECT_PAL_TIMINGS + // Each # of lines is for a full frame == 1/30s (NTSC), 1/25s (PAL). + // So we cut the number of half-lines in a frame in half. :-P + uint16 numHalfLines = ((vjs.hardwareTypeNTSC ? 525 : 625) * 2) / 2; + + if (vc >= numHalfLines) +#else if (vc >= vp) +#endif vc = 0; //WriteLog("SLC: Currently on line %u (VP=%u)...\n", vc, vp); @@ -1949,8 +2041,12 @@ void ScanlineCallback(void) frameDone = true; }//*/ +#ifdef USE_CORRECT_PAL_TIMINGS + SetCallbackTime(ScanlineCallback, (vjs.hardwareTypeNTSC ? 31.777777777 : 32.0)); +#else // SetCallbackTime(ScanlineCallback, 63.5555); SetCallbackTime(ScanlineCallback, 31.77775); +#endif } // This isn't currently used, but maybe it should be...