|
|
| version 1.19, 2004/08/10 08:28:48 | version 1.27, 2004/08/12 20:31:35 |
|---|---|
| Line 8 | Line 8 |
| #include "z80core.h" | #include "z80core.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "nevent.h" | |
| #include "ievent.h" | |
| #include "timing.h" | #include "timing.h" |
| #include "calendar.h" | #include "calendar.h" |
| #include "keystat.h" | #include "keystat.h" |
| Line 22 | Line 24 |
| const OEMCHAR xmilversion[] = OEMTEXT(XMILVER_CORE); | const OEMCHAR xmilversion[] = OEMTEXT(XMILVER_CORE); |
| XMILCFG xmilcfg = { 2, 0, 1, | XMILCFG xmilcfg = { 2, 1, 0x03, |
| 1, 0, 0, 0, | 1, 0, 0, 0, |
| 22050, 500, 0, 0, 80, | 22050, 500, 0, 0, 80, |
| 0, 0, 0, 0}; | 0, 0, 0, 0}; |
| PCCORE pccore = {250, 0, 1, 0}; | PCCORE pccore; |
| CORESTAT corestat; | CORESTAT corestat; |
| BYTE mMAIN[0x10000]; | UINT8 mMAIN[0x10000]; |
| BYTE mBIOS[0x8000]; | UINT8 mBIOS[0x8000]; |
| #if defined(SUPPORT_BANKMEM) | #if defined(SUPPORT_BANKMEM) |
| UINT8 mBANK[16][0x8000]; | UINT8 mBANK[16][0x8000]; |
| #endif | #endif |
| UINT v_cnt; | |
| UINT s_cnt; | |
| BYTE *RAM0r; | BYTE *RAM0r; |
| BYTE *RAM0w; | BYTE *RAM0w; |
| DWORD h_cntbase; | |
| /*********************************************************************** | // ---- |
| IPL-ROM LOAD | |
| ***********************************************************************/ | |
| static void ipl_load(void) { | static void ipl_load(void) { |
| Line 69 static void ipl_load(void) { | Line 64 static void ipl_load(void) { |
| } | } |
| /*********************************************************************** | // ---- |
| 初期化 | |
| ***********************************************************************/ | |
| static BRESULT reset_x1(BYTE ROM_TYPE, BYTE SOUND_SW, BYTE DIP_SW) { | |
| pccore.HSYNC_CLK = 250; | |
| pccore.ROM_TYPE = ROM_TYPE; | |
| pccore.SOUND_SW = SOUND_SW; | |
| pccore.DIP_SW = DIP_SW; | |
| // スクリーンモードの変更... | |
| if (pccore.ROM_TYPE >= 3) { | |
| if (scrnmng_setcolormode(TRUE) != SUCCESS) { | |
| pccore.ROM_TYPE = 2; | |
| } | |
| } | |
| else { | |
| scrnmng_setcolormode(FALSE); | |
| } | |
| ipl_load(); | |
| Z80_RESET(); | |
| iocore_reset(); | |
| RAM0r = mBIOS; | |
| RAM0w = mMAIN; | |
| h_cntbase = 0; | |
| sysmng_cpureset(); | |
| calendar_initialize(); | |
| 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(); | |
| pal_reset(); | |
| makescrn_reset(); | |
| timing_reset(); | |
| return(SUCCESS); | |
| } | |
| /*********************************************************************** | |
| 実行/終了 | |
| ***********************************************************************/ | |
| static BYTE keyintcnt = 0; | |
| void pccore_initialize(void) { | void pccore_initialize(void) { |
| Line 143 void pccore_initialize(void) { | Line 79 void pccore_initialize(void) { |
| ppi_initialize(); | ppi_initialize(); |
| } | } |
| void pccore_deinitialize(void) { | |
| sndctrl_deinitialize(); | |
| fddfile_eject(0); | |
| fddfile_eject(1); | |
| fddfile_eject(2); | |
| fddfile_eject(3); | |
| } | |
| void pccore_reset(void) { | void pccore_reset(void) { |
| soundmng_stop(); | soundmng_stop(); |
| Line 151 void pccore_reset(void) { | Line 97 void pccore_reset(void) { |
| sndctrl_deinitialize(); | sndctrl_deinitialize(); |
| sndctrl_initialize(); | sndctrl_initialize(); |
| } | } |
| pccore.baseclock = 2000000; | |
| pccore.multiple = 2; | |
| pccore.realclock = pccore.baseclock * pccore.multiple; | |
| pccore.ROM_TYPE = xmilcfg.ROM_TYPE; | |
| pccore.SOUND_SW = xmilcfg.SOUND_SW; | |
| pccore.DIP_SW = xmilcfg.DIP_SW; | |
| // スクリーンモードの変更... | |
| if (pccore.ROM_TYPE >= 3) { | |
| if (scrnmng_setcolormode(TRUE) != SUCCESS) { | |
| pccore.ROM_TYPE = 2; | |
| } | |
| } | |
| else { | |
| scrnmng_setcolormode(FALSE); | |
| } | |
| sysmng_cpureset(); | |
| sound_changeclock(); | |
| sound_reset(); | sound_reset(); |
| reset_x1(xmilcfg.ROM_TYPE, xmilcfg.SOUND_SW, xmilcfg.DIP_SW); | Z80_RESET(); |
| soundmng_play(); | nevent_allreset(); |
| } | ievent_reset(); |
| calendar_reset(); | |
| iocore_reset(); | |
| void pccore_deinitialize(void) { | ipl_load(); |
| sndctrl_deinitialize(); | RAM0r = mBIOS; |
| RAM0w = mMAIN; | |
| // keyboard_term(); | pal_reset(); |
| makescrn_reset(); | |
| timing_reset(); | |
| fddfile_eject(0); | soundmng_play(); |
| fddfile_eject(1); | |
| fddfile_eject(2); | |
| fddfile_eject(3); | |
| } | } |
| Line 203 void iptrace_out(void) { | Line 173 void iptrace_out(void) { |
| } | } |
| #endif | #endif |
| void neitem_disp(UINT id) { | |
| corestat.vsync = 1; | |
| pcg.r.vsync = 1; | |
| if (xmilcfg.DISPSYNC & 1) { | |
| scrnupdate(); | |
| } | |
| nevent_set(id, corestat.syncclock, neitem_vsync, NEVENT_RELATIVE); | |
| } | |
| void neitem_vsync(UINT id) { | |
| corestat.vsync = 2; | |
| (void)id; | |
| } | |
| // #define SINGLESTEPONLY | |
| void pccore_exec(BRESULT draw) { | void pccore_exec(BRESULT draw) { |
| REG8 inttiming; | SINT32 frameclock; |
| SINT32 dispclock; | |
| corestat.drawframe = draw; | corestat.drawframe = draw; |
| soundmng_sync(); | soundmng_sync(); |
| v_cnt = 0; | frameclock = 266 * RASTER_CLOCK * pccore.multiple / 2; |
| s_cnt = 0; | dispclock = min(frameclock, crtc.e.dispclock); |
| inttiming = xmilcfg.CPU8MHz & 1; | corestat.dispclock = dispclock; |
| corestat.syncclock = frameclock - dispclock; | |
| while(s_cnt < 266) { | corestat.vsync = 0; |
| while(h_cnt < pccore.HSYNC_CLK) { | nevent_set(NEVENT_FRAMES, dispclock, neitem_disp, NEVENT_RELATIVE); |
| do { | |
| #if !defined(SINGLESTEPONLY) | |
| if (CPU_REMCLOCK > 0) { | |
| Z80_EXECUTE(); | |
| } | |
| #else | |
| while(CPU_REMCLOCK > 0) { | |
| TRACEOUT(("%.4x", Z80_PC)); | |
| #if defined(TRACE) && IPTRACE | #if defined(TRACE) && IPTRACE |
| treip[trpos & (IPTRACE - 1)] = Z80_PC; | treip[trpos & (IPTRACE - 1)] = Z80_PC; |
| trpos++; | trpos++; |
| #endif | #endif |
| Z80_EXECUTE(); | Z80_STEP(); |
| z80dmap(); | |
| } | } |
| fdcisbusy(); | #endif |
| h_cnt -= pccore.HSYNC_CLK; | nevent_progress(); |
| h_cntbase += pccore.HSYNC_CLK; | ievent_progress(); |
| inttiming ^= 2; | } while(corestat.vsync < 2); |
| if (inttiming != 3) { | |
| sound_makesample(pcmbufsize[s_cnt]); | |
| // if (xmilcfg.SOUNDPLY) { | |
| // juliet2_exec(); | |
| // } | |
| s_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(); | |
| } | |
| } | |
| } | |
| scrnupdate(); | scrnupdate(); |
| calendar_inc(); | |
| sound_sync(); | sound_sync(); |
| } | } |