static UINT16 m68000_read_pcrelative_16(UINT32 offset) { if (offset >= m68k_encrypt_start && offset <= m68k_encrypt_end) return *(UINT16 *)&m68k_decrypted_rom[offset]; else return Memory_ReadW(offset); }
void m68000_execute2(UINT32 start, UINT32 break_point) { int nest_counter = 0; UINT32 pc, old_pc, opcode; c68k_struc C68K_temp; old_pc = C68k_Get_Reg(&C68K, M68K_PC); memcpy(&C68K_temp, &C68K, sizeof(c68k_struc)); C68k_Set_Reg(&C68K_temp, C68K_PC, start); C68K_temp.A[5] = 0x108000; C68K_temp.A[7] -= 4 * 8 * 2; while ((pc = C68k_Get_Reg(&C68K_temp, M68K_PC)) != break_point) { opcode = Memory_ReadW(pc); if (opcode == 0x4e75) { // rts nest_counter--; if (nest_counter < 0) break; } else if (opcode == 0x6100) { // bsr 16 nest_counter++; } else if ((opcode & 0xff00) == 0x6100) { // bsr 8 nest_counter++; } else if ((opcode & 0xffc0) == 0x4e80) { // jsr nest_counter++; } C68k_Exec(&C68K_temp, 1); } C68k_Set_Reg(&C68K, C68K_PC, old_pc); }
// ----------------------------------------------------------------------------------- // �����Τᤤ��롼�� // ----------------------------------------------------------------------------------- void WinX68k_Exec(void) { if(!(Memory_ReadD(0xed0008)==ram_size)){ Memory_WriteB(0xe8e00d, 0x31); // SRAM write permission Memory_WriteD(0xed0008, ram_size); // Define RAM amount } //char *test = NULL; int clk_total, clkdiv, usedclk, hsync, clk_next, clk_count, clk_line=0; int KeyIntCnt = 0, MouseIntCnt = 0; DWORD t_start = timeGetTime(), t_end; if ( Config.FrameRate == 0) Config.FrameRate = 7; if ( Config.FrameRate != 7 ) { DispFrame = (DispFrame+1)%Config.FrameRate; } else { // Auto Frame Skip if ( FrameSkipQueue ) { if ( FrameSkipCount>15 ) { FrameSkipCount = 0; FrameSkipQueue++; DispFrame = 0; } else { FrameSkipCount++; FrameSkipQueue--; DispFrame = 1; } } else { FrameSkipCount = 0; DispFrame = 0; } } vline = 0; clk_count = -ICount; clk_total = (CRTC_Regs[0x29] & 0x10) ? VSYNC_HIGH : VSYNC_NORM; clk_total = (clk_total*clockmhz)/10; clkdiv = clockmhz; /*if (Config.XVIMode == 1) { clk_total = (clk_total*16)/10; clkdiv = 16; } else if (Config.XVIMode == 2) { clk_total = (clk_total*24)/10; clkdiv = 24; } else { clkdiv = 10; }*/ if(clkdiv != old_clkdiv || ram_size != old_ram_size){ printf("CPU Clock: %d%s\n",clkdiv,"MHz"); printf("RAM Size: %ld%s\n",ram_size/1000000,"MB"); old_clkdiv = clkdiv; old_ram_size = ram_size; } ICount += clk_total; clk_next = (clk_total/VLINE_TOTAL); hsync = 1; do { int m, n = (ICount>CLOCK_SLICE)?CLOCK_SLICE:ICount; //C68K.ICount = m68000_ICountBk = 0; // ������ȯ������Ϳ���Ƥ����ʤ��ȥ����CARAT�� if ( hsync ) { hsync = 0; clk_line = 0; MFP_Int(0); if ( (vline>=CRTC_VSTART)&&(vline<CRTC_VEND) ) VLINE = ((vline-CRTC_VSTART)*CRTC_VStep)/2; else VLINE = (DWORD)-1; if ( (!(MFP[MFP_AER]&0x40))&&(vline==CRTC_IntLine) ) MFP_Int(1); if ( MFP[MFP_AER]&0x10 ) { if ( vline==CRTC_VSTART ) MFP_Int(9); } else { if ( CRTC_VEND>=VLINE_TOTAL ) { if ( (long)vline==(CRTC_VEND-VLINE_TOTAL) ) MFP_Int(9); // ���������ƥ�����Ȥ���TOTAL<VEND�� } else { if ( (long)vline==(VLINE_TOTAL-1) ) MFP_Int(9); // ���쥤�������饤�ޡ��ϥ���Ǥʤ��ȥ��ᡩ } } } #ifdef WIN68DEBUG if (traceflag/*&&fdctrace*/) { FILE *fp; static DWORD oldpc; int i; char buf[200]; fp=fopen("_trace68.txt", "a"); for (i=0; i<HSYNC_CLK; i++) { m68k_disassemble(buf, C68k_Get_Reg(&C68K, C68K_PC)); // if (MEM[0xa84c0]) /**test=1; */tracing=1000; // if (regs.pc==0x9d2a) tracing=5000; // if ((regs.pc>=0x2000)&&((regs.pc<=0x8e0e0))) tracing=50000; // if (regs.pc<0x10000) tracing=1; // if ( (regs.pc&1) ) // fp=fopen("_trace68.txt", "a"); // if ( (regs.pc==0x7176) /*&& (Memory_ReadW(oldpc)==0xff1a)*/ ) tracing=100; // if ( (/*((regs.pc>=0x27000) && (regs.pc<=0x29000))||*/((regs.pc>=0x27000) && (regs.pc<=0x29000))) && (oldpc!=regs.pc)) if (/*fdctrace&&*/(oldpc != C68k_Get_Reg(&C68K, C68K_PC))) { // //tracing--; fprintf(fp, "D0:%08X D1:%08X D2:%08X D3:%08X D4:%08X D5:%08X D6:%08X D7:%08X CR:%04X\n", C68K.D[0], C68K.D[1], C68K.D[2], C68K.D[3], C68K.D[4], C68K.D[5], C68K.D[6], C68K.D[7], 0/* xxx �Ȥꤢ����0 C68K.ccr */); fprintf(fp, "A0:%08X A1:%08X A2:%08X A3:%08X A4:%08X A5:%08X A6:%08X A7:%08X SR:%04X\n", C68K.A[0], C68K.A[1], C68K.A[2], C68K.A[3], C68K.A[4], C68K.A[5], C68K.A[6], C68K.A[7], C68k_Get_Reg(&C68K, C68K_SR) >> 8/* regs.sr_high*/); fprintf(fp, "<%04X> (%08X ->) %08X : %s\n", Memory_ReadW(C68k_Get_Reg(&C68K, C68K_PC)), oldpc, C68k_Get_Reg(&C68K, C68K_PC), buf); } #ifdef CYCLONE oldpc = m68000_get_reg(M68K_PC); // * C68KICount = 1; m68000_execute(1); #else oldpc = C68k_Get_Reg(&C68K, C68K_PC); //C68K.ICount = 1; //C68k_Exec(&C68K, C68K.ICount); C68k_Exec(&C68K, 1); #endif } fclose(fp); usedclk = clk_line = HSYNC_CLK; clk_count = clk_next; } else #endif { //C68K.ICount = n; #ifdef CYCLONE m68000_execute(n); #else C68k_Exec(&C68K, n); #endif m = (n-m68000_ICountBk); //m = (n-C68K.ICount-m68000_ICountBk); // clockspeed progress ClkUsed += m*10; usedclk = ClkUsed/clkdiv; clk_line += usedclk; ClkUsed -= usedclk*clkdiv; ICount -= m; clk_count += m; //C68K.ICount = m68000_ICountBk = 0; } MFP_Timer(usedclk); RTC_Timer(usedclk); DMA_Exec(0); DMA_Exec(1); DMA_Exec(2); if ( clk_count>=clk_next ) { //OPM_RomeoOut(Config.BufferSize*5); //MIDI_DelayOut((Config.MIDIAutoDelay)?(Config.BufferSize*5):Config.MIDIDelay); MFP_TimerA(); if ( (MFP[MFP_AER]&0x40)&&(vline==CRTC_IntLine) ) MFP_Int(1); if ( (!DispFrame)&&(vline>=CRTC_VSTART)&&(vline<CRTC_VEND) ) { if ( CRTC_VStep==1 ) { // HighReso 256dot��2���ɤߡ� if ( vline%2 ) WinDraw_DrawLine(); } else if ( CRTC_VStep==4 ) { // LowReso 512dot WinDraw_DrawLine(); // 1��������2�������ʥ����졼���� VLINE++; WinDraw_DrawLine(); } else { // High 512dot / Low 256dot WinDraw_DrawLine(); } } ADPCM_PreUpdate(clk_line); OPM_Timer(clk_line); MIDI_Timer(clk_line); #ifndef NO_MERCURY Mcry_PreUpdate(clk_line); #endif KeyIntCnt++; if ( KeyIntCnt>(VLINE_TOTAL/4) ) { KeyIntCnt = 0; Keyboard_Int(); } MouseIntCnt++; if ( MouseIntCnt>(VLINE_TOTAL/8) ) { MouseIntCnt = 0; SCC_IntCheck(); } DSound_Send0(clk_line); vline++; clk_next = (clk_total*(vline+1))/VLINE_TOTAL; hsync = 1; } } while ( vline<VLINE_TOTAL );