--- xmil/pccore.c 2004/08/12 11:03:08 1.22 +++ xmil/pccore.c 2004/08/20 23:01:13 1.35 @@ -24,20 +24,13 @@ const OEMCHAR xmilversion[] = OEMTEXT(XMILVER_CORE); - XMILCFG xmilcfg = { 2, 0, 1, + XMILCFG xmilcfg = { 2, 1, 0x03, 1, 0, 0, 0, - 22050, 500, 0, 0, 80, + 22050, 500, 0, 64, 64, 0, 80, 0, 0, 0, 0}; PCCORE pccore; CORESTAT corestat; - BYTE mMAIN[0x10000]; - BYTE mBIOS[0x8000]; -#if defined(SUPPORT_BANKMEM) - UINT8 mBANK[16][0x8000]; -#endif - BYTE *RAM0r; - BYTE *RAM0w; // ---- @@ -46,18 +39,18 @@ static void ipl_load(void) { FILEH hdl; - ZeroMemory(mBIOS, sizeof(mBIOS)); - CopyMemory(mBIOS, DEFROM, sizeof(DEFROM)); + ZeroMemory(biosmem, 0x8000); + CopyMemory(biosmem, DEFROM, sizeof(DEFROM)); if (pccore.ROM_TYPE >= 2) { if ((hdl = file_open_c(OEMTEXT("IPLROM.X1T"))) != FILEH_INVALID) { - file_read(hdl, mBIOS, 0x8000); + file_read(hdl, biosmem, 0x8000); file_close(hdl); } } else if (pccore.ROM_TYPE == 1) { if ((hdl = file_open_c(OEMTEXT("IPLROM.X1"))) != FILEH_INVALID) { - file_read(hdl, mBIOS, 0x8000); + file_read(hdl, biosmem, 0x8000); file_close(hdl); } } @@ -68,6 +61,7 @@ static void ipl_load(void) { void pccore_initialize(void) { + Z80_INITIALIZE(); fddfile_initialize(); sndctrl_initialize(); makescrn_initialize(); @@ -97,8 +91,6 @@ void pccore_reset(void) { sndctrl_deinitialize(); sndctrl_initialize(); } - sound_reset(); - pccore.baseclock = 2000000; pccore.multiple = 2; @@ -118,34 +110,19 @@ void pccore_reset(void) { scrnmng_setcolormode(FALSE); } - sound_changeclock(); sysmng_cpureset(); + sound_changeclock(); + sound_reset(); + Z80_RESET(); nevent_allreset(); ievent_reset(); + calendar_reset(); iocore_reset(); ipl_load(); - RAM0r = mBIOS; - RAM0w = mMAIN; - - cgrom_reset(); - cmt_reset(); - crtc_reset(); - ctc_reset(); - dmac_reset(); - fdc_reset(); - memio_reset(); - pcg_reset(); - ppi_reset(); - sio_reset(); - sndboard_reset(); - subcpu_reset(); - vramio_reset(); - - calendar_initialize(); pal_reset(); makescrn_reset(); timing_reset(); @@ -188,74 +165,43 @@ void iptrace_out(void) { #endif -#if 0 -void nvitem_raster(UINT id) { - - nevent_repeat(id); - sound_makesample(pcmbufsize[v_cnt]); -// x1_ctc_int(); - if (!((++keyintcnt) & 15)) { - x1_sub_int(); - if (xmilcfg.MOUSE_SW) { - sio_int(); - } - } - v_cnt++; - if (crtc.s.CRT_YL == v_cnt) { - pcg.r.vsync = 1; - if (xmilcfg.DISPSYNC & 1) { - scrnupdate(); - } - } -} -#endif - -UINT pccore_getraster(UINT *h) { - - SINT32 work; - UINT vl; - - work = nevent_getwork(NEVENT_FRAMES); - vl = work / 250; - if (h) { - *h = work - (vl * 250); - } - if (corestat.vsync) { - vl += corestat.vl; - } - return(vl); -} - -void nvitem_vdisp(UINT id) { +void neitem_disp(UINT id) { corestat.vsync = 1; - pcg.r.vsync = 1; if (xmilcfg.DISPSYNC & 1) { scrnupdate(); } - nevent_set(id, (corestat.tl - corestat.vl) * 250, - nvitem_vsync, NEVENT_RELATIVE); + nevent_set(id, corestat.syncclock, neitem_vsync, NEVENT_RELATIVE); } -void nvitem_vsync(UINT id) { +void neitem_vsync(UINT id) { corestat.vsync = 2; (void)id; } +// ---- + // #define SINGLESTEPONLY + void pccore_exec(BRESULT draw) { + SINT32 frameclock; + SINT32 dispclock; + corestat.drawframe = draw; + pal_eventclear(); soundmng_sync(); - corestat.tl = 266 * pccore.multiple / 2; - corestat.vl = min(corestat.tl, crtc.s.CRT_YL); + timing_setrate(crtc.e.frameclock); + frameclock = crtc.e.frameclock * pccore.multiple / 2; + dispclock = min(frameclock, crtc.e.dispclock); + corestat.dispclock = dispclock; + corestat.syncclock = frameclock - dispclock; corestat.vsync = 0; - nevent_set(NEVENT_FRAMES, corestat.vl * 250, - nvitem_vdisp, NEVENT_RELATIVE); + nevent_set(NEVENT_FRAMES, dispclock, neitem_disp, NEVENT_RELATIVE); do { #if !defined(SINGLESTEPONLY) if (CPU_REMCLOCK > 0) { @@ -263,7 +209,7 @@ void pccore_exec(BRESULT draw) { } #else while(CPU_REMCLOCK > 0) { - TRACEOUT(("%.4x", Z80_PC)); + // TRACEOUT(("%.4x", Z80_PC)); #if defined(TRACE) && IPTRACE treip[trpos & (IPTRACE - 1)] = Z80_PC; trpos++; @@ -276,7 +222,7 @@ void pccore_exec(BRESULT draw) { } while(corestat.vsync < 2); scrnupdate(); - calendar_inc(); sound_sync(); + fdc_callback(); }