--- np2/pccore.c 2003/11/22 12:49:48 1.20 +++ np2/pccore.c 2003/12/13 19:59:40 1.30 @@ -1,9 +1,9 @@ #include "compiler.h" +#include "dosio.h" #include "soundmng.h" #include "sysmng.h" #include "timemng.h" -#include "i286.h" -#include "memory.h" +#include "cpucore.h" #include "np2ver.h" #include "pccore.h" #include "iocore.h" @@ -22,6 +22,7 @@ #include "sound.h" #include "fmboard.h" #include "beep.h" +#include "s98.h" #include "font.h" #include "diskdrv.h" #include "fddfile.h" @@ -31,7 +32,6 @@ #include "timing.h" //#include "hostdrv.h" #include "debugsub.h" -#include "dosio.h" const char np2version[] = NP2VER_CORE; @@ -51,7 +51,7 @@ 1, 0x82, 0, {0x17, 0x04, 0x1f}, {0x0c, 0x0c, 0x02, 0x10, 0x3f, 0x3f}, 1, 80, 0, - {"", ""}, ""}; + {"", ""}, "", ""}; PCCORE pc = { PCBASECLOCK25, 4, @@ -75,11 +75,29 @@ static const BYTE msw_default[8] = BOOL drawframe; UINT drawcount = 0; - BYTE mem[0x200000]; - // --------------------------------------------------------------------------- +void getbiospath(char *path, const char *fname, int maxlen) { + +const char *p; + + p = np2cfg.biospath; + + p = np2cfg.biospath; + if (p[0]) { + file_cpyname(path, p, maxlen); + file_setseparator(path, maxlen); + file_catname(path, fname, maxlen); + } + else { + file_cpyname(path, file_getcd(fname), maxlen); + } +} + + +// ---- + static void setvsyncclock(void) { UINT vfp; @@ -184,6 +202,8 @@ static void sound_term(void) { void pccore_init(void) { + CPU_INITIALIZE(); + pal_initlcdtable(); pal_makelcdpal(); pal_makeskiptable(); @@ -255,10 +275,10 @@ void pccore_reset(void) { ZeroMemory(mem + VRAM1_E, 0x08000); ZeroMemory(mem + FONT_ADRS, 0x08000); - i286_reset(); - CPUTYPE = 0; + CPU_RESET(); + CPU_TYPE = 0; if (np2cfg.dipsw[2] & 0x80) { - CPUTYPE = CPUTYPE_V30; + CPU_TYPE = CPUTYPE_V30; } //メモリスイッチ @@ -304,18 +324,18 @@ void pccore_reset(void) { if (np2cfg.ITF_WORK) { CS_BASE = 0xf0000; - I286_CS = 0xf000; - I286_IP = 0xfff0; + CPU_CS = 0xf000; + CPU_IP = 0xfff0; } else { for (i=0; i<8; i++) { mem[0xa3fe2 + i*4] = msw_default[i]; } CS_BASE = 0xfd800; - I286_CS = 0xfd80; - I286_IP = 0x0002; + CPU_CS = 0xfd80; + CPU_IP = 0x0002; } - i286_resetprefetch(); + CPU_CLEARPREFETCH(); sysmng_cpureset(); soundmng_play(); @@ -488,8 +508,15 @@ void screenvsync(NEVENTITEM item) { (void)item; } + // --------------------------------------------------------------------------- +#if defined(TRACE) +static int resetcnt = 0; +static int execcnt = 0; +int piccnt = 0; +#endif + void pccore_exec(BOOL draw) { drawframe = draw; @@ -508,29 +535,33 @@ void pccore_exec(BOOL draw) { // nevent_get1stevent(); while(screendispflag) { +#if defined(TRACE) + resetcnt++; +#endif pic_irq(); - if (cpuio.reset_req) { - cpuio.reset_req = 0; - I286_CS = 0xf000; + if (CPU_RESETREQ) { + CPU_RESETREQ = 0; + CPU_CS = 0xf000; CS_BASE = 0xf0000; - I286_IP = 0xfff0; -#ifdef CPU386 // defineを変えてね - I286_DX = 0x0300; + CPU_IP = 0xfff0; +#if defined(CPUCORE_IA32) + CPU_DX = 0x0300; #endif - i286_resetprefetch(); + CPU_CLEARPREFETCH(); } -#ifndef TRACE - if (I286_REMCLOCK > 0) { - if (!(CPUTYPE & CPUTYPE_V30)) { - i286(); +#if 1 // ndef TRACE + if (CPU_REMCLOCK > 0) { + if (!(CPU_TYPE & CPUTYPE_V30)) { + CPU_EXEC(); } else { - v30(); + CPU_EXECV30(); } } #else - while(I286_REMCLOCK > 0) { + while(CPU_REMCLOCK > 0) { + TRACEOUT(("%.4x:%.4x", CPU_CS, CPU_IP)); i286_step(); } #endif @@ -540,6 +571,17 @@ void pccore_exec(BOOL draw) { mpu98ii_callback(); diskdrv_callback(); calendar_inc(); + S98_sync(); sound_sync(); // happy! + +#if defined(TRACE) + execcnt++; + if (execcnt >= 60) { + TRACEOUT(("resetcnt = %d / pic %d", resetcnt, piccnt)); + execcnt = 0; + resetcnt = 0; + piccnt = 0; + } +#endif }