|
|
| version 1.3, 2004/02/19 11:32:12 | version 1.10, 2011/01/15 18:04:43 |
|---|---|
| Line 4 | Line 4 |
| #include "cpucore.h" | #include "cpucore.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "bios.h" | |
| #include "sound.h" | #include "sound.h" |
| #include "fmboard.h" | #include "fmboard.h" |
| #include "np2info.h" | #include "np2info.h" |
| static const char str_comma[] = ", "; | static const OEMCHAR str_comma[] = OEMTEXT(", "); |
| static const char str_2halfMHz[] = "2.5MHz"; | static const OEMCHAR str_2halfMHz[] = OEMTEXT("2.5MHz"); |
| #define str_5MHz (str_2halfMHz + 2) | #define str_5MHz (str_2halfMHz + 2) |
| static const char str_8MHz[] = "8MHz"; | static const OEMCHAR str_8MHz[] = OEMTEXT("8MHz"); |
| static const char str_notexist[] = "not exist"; | static const OEMCHAR str_notexist[] = OEMTEXT("not exist"); |
| static const char str_disable[] = "disable"; | static const OEMCHAR str_disable[] = OEMTEXT("disable"); |
| static const char str_winclr[] = | static const OEMCHAR str_cpu[] = OEMTEXT("8086-2\00070116\00080286\00080386\00080486\0Pentium\0PentiumPro"); |
| "256-colors\065536-colors\0full color\0true color"; | static const OEMCHAR str_winclr[] = OEMTEXT("256-colors\00065536-colors\0full color\0true color"); |
| static const char str_winmode[] = | static const OEMCHAR str_winmode[] = OEMTEXT(" (window)\0 (fullscreen)"); |
| " (window)\0 (fullscreen)"; | static const OEMCHAR str_grcgchip[] = OEMTEXT("\0GRCG \0GRCG CG-Window \0EGC CG-Window "); |
| static const char str_grcgchip[] = | static const OEMCHAR str_vrammode[] = OEMTEXT("Digital\0Analog\000256colors"); |
| "\0GRCG \0GRCG CG-Window \0EGC CG-Window "; | static const OEMCHAR str_vrampage[] = OEMTEXT(" page-0\0 page-1\0 page-all"); |
| static const char str_clrmode[] = | static const OEMCHAR str_chpan[] = OEMTEXT("none\0Mono-R\0Mono-L\0Stereo"); |
| "(Digital)\0(Analog)"; | static const OEMCHAR str_fmboard[] = OEMTEXT("none\0PC-9801-14\0PC-9801-26\0PC-9801-86\0PC-9801-26 + 86\0PC-9801-118\0PC-9801-86 + Chibi-oto\0Speak board\0Spark board\0AMD-98"); |
| static const char str_chpan[] = | |
| "none\0Mono-R\0Mono-L\0Stereo"; | static const OEMCHAR str_clockfmt[] = OEMTEXT("%d.%1dMHz"); |
| static const OEMCHAR str_memfmt[] = OEMTEXT("%3uKB"); | |
| static const char str_fmboard[] = | static const OEMCHAR str_memfmt2[] = OEMTEXT("%3uKB + %uKB"); |
| "none\0PC-9801-14\0PC-9801-26\0PC-9801-86\0" \ | static const OEMCHAR str_memfmt3[] = OEMTEXT("%d.%1dMB"); |
| "PC-9801-26 + 86\0PC-9801-118\0" \ | static const OEMCHAR str_twidth[] = OEMTEXT("width-%u"); |
| "PC-9801-86 + Chibi-oto\0" \ | static const OEMCHAR str_dispclock[] = OEMTEXT("%u.%.2ukHz / %u.%uHz"); |
| "Speak board\0Spark board\0AMD-98"; | |
| static const OEMCHAR str_pcm86a[] = OEMTEXT(" PCM: %dHz %dbit %s"); | |
| static const OEMCHAR str_pcm86b[] = OEMTEXT(" %d / %d / 32768"); | |
| static const char str_V30[] = "V30"; | static const OEMCHAR str_rhythm[] = OEMTEXT("BSCHTR"); |
| static const char str_i286[] = "i286"; | |
| static const char str_clockfmt[] = "%d.%1dMHz"; | |
| static const char str_memfmt[] = "%3uKB"; | |
| static const char str_memfmt2[] = "%3uKB + %uKB"; | |
| static const char str_memfmt3[] = "%d.%1dMB"; | |
| static const char str_width[] = "width-%u"; | |
| static const char str_gdcpage[] = "page-%u %s"; | |
| static const char str_pcm86a[] = " PCM: %dHz %dbit %s"; | |
| static const char str_pcm86b[] = " %d / %d / 32768"; | |
| static const char str_rhythm[] = "BSCHTR"; | |
| // ---- common | // ---- common |
| static void info_ver(char *str, int maxlen, NP2INFOEX *ex) { | static void info_ver(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| milstr_ncpy(str, np2version, maxlen); | milstr_ncpy(str, np2version, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_cpu(char *str, int maxlen, NP2INFOEX *ex) { | static void info_cpu(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| milstr_ncpy(str, (CPU_TYPE & CPUTYPE_V30)?str_V30:str_i286, maxlen); | UINT family; |
| #if defined(CPU_FAMILY) | |
| family = min(CPU_FAMILY, 6); | |
| #else | |
| family = (CPU_TYPE & CPUTYPE_V30)?1:2; | |
| #endif | |
| milstr_ncpy(str, milstr_list(str_cpu, family), maxlen); | |
| (void)ex; | (void)ex; |
| } | } |
| static void info_clock(char *str, int maxlen, NP2INFOEX *ex) { | static void info_clock(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| UINT32 clock; | UINT32 clk; |
| char clockstr[16]; | OEMCHAR clockstr[16]; |
| clock = (pccore.realclock + 50000) / 100000; | clk = (pccore.realclock + 50000) / 100000; |
| SPRINTF(clockstr, str_clockfmt, clock/10, clock % 10); | OEMSPRINTF(clockstr, str_clockfmt, clk/10, clk % 10); |
| milstr_ncpy(str, clockstr, maxlen); | milstr_ncpy(str, clockstr, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_base(char *str, int maxlen, NP2INFOEX *ex) { | static void info_base(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| milstr_ncpy(str, | milstr_ncpy(str, |
| (pccore.cpumode & CPUMODE_8MHZ)?str_8MHz:str_5MHz, maxlen); | (pccore.cpumode & CPUMODE_8MHZ)?str_8MHz:str_5MHz, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_mem1(char *str, int maxlen, NP2INFOEX *ex) { | static void info_mem1(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| UINT memsize; | UINT memsize; |
| char memstr[32]; | OEMCHAR memstr[32]; |
| memsize = np2cfg.memsw[2] & 7; | memsize = np2cfg.memsw[2] & 7; |
| if (memsize < 6) { | if (memsize < 6) { |
| Line 95 static void info_mem1(char *str, int max | Line 89 static void info_mem1(char *str, int max |
| memsize = 640; | memsize = 640; |
| } | } |
| if (pccore.extmem) { | if (pccore.extmem) { |
| SPRINTF(memstr, str_memfmt2, memsize, pccore.extmem * 1024); | OEMSPRINTF(memstr, str_memfmt2, memsize, pccore.extmem * 1024); |
| } | } |
| else { | else { |
| SPRINTF(memstr, str_memfmt, memsize); | OEMSPRINTF(memstr, str_memfmt, memsize); |
| } | } |
| milstr_ncpy(str, memstr, maxlen); | milstr_ncpy(str, memstr, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_mem2(char *str, int maxlen, NP2INFOEX *ex) { | static void info_mem2(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| UINT memsize; | UINT memsize; |
| char memstr[16]; | OEMCHAR memstr[16]; |
| memsize = np2cfg.memsw[2] & 7; | memsize = np2cfg.memsw[2] & 7; |
| if (memsize < 6) { | if (memsize < 6) { |
| Line 117 static void info_mem2(char *str, int max | Line 111 static void info_mem2(char *str, int max |
| memsize = 640; | memsize = 640; |
| } | } |
| memsize += pccore.extmem * 1024; | memsize += pccore.extmem * 1024; |
| SPRINTF(memstr, str_memfmt, memsize); | OEMSPRINTF(memstr, str_memfmt, memsize); |
| milstr_ncpy(str, memstr, maxlen); | milstr_ncpy(str, memstr, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_mem3(char *str, int maxlen, NP2INFOEX *ex) { | static void info_mem3(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| UINT memsize; | UINT memsize; |
| char memstr[16]; | OEMCHAR memstr[16]; |
| memsize = np2cfg.memsw[2] & 7; | memsize = np2cfg.memsw[2] & 7; |
| if (memsize < 6) { | if (memsize < 6) { |
| Line 135 static void info_mem3(char *str, int max | Line 129 static void info_mem3(char *str, int max |
| memsize = 640; | memsize = 640; |
| } | } |
| if (pccore.extmem > 1) { | if (pccore.extmem > 1) { |
| SPRINTF(memstr, str_memfmt3, pccore.extmem, memsize / 100); | OEMSPRINTF(memstr, str_memfmt3, pccore.extmem, memsize / 100); |
| } | } |
| else { | else { |
| SPRINTF(memstr, str_memfmt, memsize); | OEMSPRINTF(memstr, str_memfmt, memsize); |
| } | } |
| milstr_ncpy(str, memstr, maxlen); | milstr_ncpy(str, memstr, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_gdc(char *str, int maxlen, NP2INFOEX *ex) { | static void info_gdc(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| milstr_ncpy(str, milstr_list(str_grcgchip, grcg.chip & 3), maxlen); | milstr_ncpy(str, milstr_list(str_grcgchip, grcg.chip & 3), maxlen); |
| milstr_ncat(str, str_2halfMHz + ((gdc.clock & 0x80)?2:0), maxlen); | milstr_ncat(str, str_2halfMHz + ((gdc.clock & 0x80)?2:0), maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_text(char *str, int maxlen, NP2INFOEX *ex) { | static void info_gdc2(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| OEMCHAR textstr[32]; | |
| OEMSPRINTF(textstr, str_dispclock, | |
| gdc.hclock / 1000, (gdc.hclock / 10) % 100, | |
| gdc.vclock / 10, gdc.vclock % 10); | |
| milstr_ncpy(str, textstr, maxlen); | |
| (void)ex; | |
| } | |
| static void info_text(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { | |
| const char *p; | const OEMCHAR *p; |
| char textstr[64]; | OEMCHAR textstr[64]; |
| if (!(gdcs.textdisp & GDCSCRN_ENABLE)) { | if (!(gdcs.textdisp & GDCSCRN_ENABLE)) { |
| p = str_disable; | p = str_disable; |
| } | } |
| else { | else { |
| SPRINTF(textstr, str_width, ((gdc.mode1 & 0x4)?40:80)); | OEMSPRINTF(textstr, str_twidth, ((gdc.mode1 & 0x4)?40:80)); |
| p = textstr; | p = textstr; |
| } | } |
| milstr_ncpy(str, p, maxlen); | milstr_ncpy(str, p, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_grph(char *str, int maxlen, NP2INFOEX *ex) { | static void info_grph(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| const char *p; | const OEMCHAR *p; |
| char grphstr[32]; | UINT md; |
| UINT pg; | |
| OEMCHAR work[32]; | |
| if (!(gdcs.grphdisp & GDCSCRN_ENABLE)) { | if (!(gdcs.grphdisp & GDCSCRN_ENABLE)) { |
| p = str_disable; | p = str_disable; |
| } | } |
| else { | else { |
| SPRINTF(grphstr, str_gdcpage, gdcs.access, | md = (gdc.analog & (1 << GDCANALOG_16))?1:0; |
| milstr_list(str_clrmode, (gdc.analog)?1:0)); | pg = gdcs.access; |
| p = grphstr; | #if defined(SUPPORT_PC9821) |
| if (gdc.analog & (1 << (GDCANALOG_256))) { | |
| md = 2; | |
| if (gdc.analog & (1 << (GDCANALOG_256E))) { | |
| pg = 2; | |
| } | |
| } | |
| #endif | |
| milstr_ncpy(work, milstr_list(str_vrammode, md), NELEMENTS(work)); | |
| milstr_ncat(work, milstr_list(str_vrampage, pg), NELEMENTS(work)); | |
| p = work; | |
| } | } |
| milstr_ncpy(str, p, maxlen); | milstr_ncpy(str, p, maxlen); |
| (void)ex; | (void)ex; |
| } | } |
| static void info_sound(char *str, int maxlen, NP2INFOEX *ex) { | static void info_sound(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| UINT type; | UINT type; |
| Line 230 static void info_sound(char *str, int ma | Line 247 static void info_sound(char *str, int ma |
| (void)ex; | (void)ex; |
| } | } |
| static void info_extsnd(char *str, int maxlen, NP2INFOEX *ex) { | static void info_extsnd(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| char buf[64]; | OEMCHAR buf[64]; |
| info_sound(str, maxlen, ex); | info_sound(str, maxlen, ex); |
| if (usesound & 4) { | if (usesound & 4) { |
| milstr_ncat(str, ex->cr, maxlen); | milstr_ncat(str, ex->cr, maxlen); |
| SPRINTF(buf, str_pcm86a, | OEMSPRINTF(buf, str_pcm86a, |
| pcm86rate8[pcm86.fifo & 7] >> 3, | pcm86rate8[pcm86.fifo & 7] >> 3, |
| (16 - ((pcm86.dactrl >> 3) & 8)), | (16 - ((pcm86.dactrl >> 3) & 8)), |
| milstr_list(str_chpan, (pcm86.dactrl >> 4) & 3)); | milstr_list(str_chpan, (pcm86.dactrl >> 4) & 3)); |
| milstr_ncat(str, buf, maxlen); | milstr_ncat(str, buf, maxlen); |
| milstr_ncat(str, ex->cr, maxlen); | milstr_ncat(str, ex->cr, maxlen); |
| SPRINTF(buf, str_pcm86b, pcm86.virbuf, pcm86.fifosize); | OEMSPRINTF(buf, str_pcm86b, pcm86.virbuf, pcm86.fifosize); |
| milstr_ncat(str, buf, maxlen); | milstr_ncat(str, buf, maxlen); |
| } | } |
| } | } |
| static void info_bios(char *str, int maxlen, NP2INFOEX *ex) { | static void info_bios(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| str[0] = '\0'; | str[0] = '\0'; |
| if (biosrom) { | if (pccore.rom & PCROM_BIOS) { |
| milstr_ncat(str, str_biosrom, maxlen); | milstr_ncat(str, str_biosrom, maxlen); |
| } | } |
| if (soundrom.name[0]) { | if (soundrom.name[0]) { |
| Line 266 static void info_bios(char *str, int max | Line 283 static void info_bios(char *str, int max |
| (void)ex; | (void)ex; |
| } | } |
| static void info_rhythm(char *str, int maxlen, NP2INFOEX *ex) { | static void info_rhythm(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| char rhythmstr[8]; | OEMCHAR rhythmstr[8]; |
| UINT exist; | UINT exist; |
| UINT i; | UINT i; |
| exist = rhythm_getcaps(); | exist = rhythm_getcaps(); |
| milstr_ncpy(rhythmstr, str_rhythm, sizeof(rhythmstr)); | milstr_ncpy(rhythmstr, str_rhythm, NELEMENTS(rhythmstr)); |
| for (i=0; i<6; i++) { | for (i=0; i<6; i++) { |
| if (!(exist & (1 << i))) { | if (!(exist & (1 << i))) { |
| rhythmstr[i] = '_'; | rhythmstr[i] = '_'; |
| Line 283 static void info_rhythm(char *str, int m | Line 300 static void info_rhythm(char *str, int m |
| (void)ex; | (void)ex; |
| } | } |
| static void info_display(char *str, int maxlen, NP2INFOEX *ex) { | static void info_display(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| UINT bpp; | UINT bpp; |
| Line 298 static void info_display(char *str, int | Line 315 static void info_display(char *str, int |
| // ---- make string | // ---- make string |
| typedef struct { | typedef struct { |
| char key[8]; | OEMCHAR key[8]; |
| void (*proc)(char *str, int maxlen, NP2INFOEX *ex); | void (*proc)(OEMCHAR *str, int maxlen, const NP2INFOEX *ex); |
| } INFOPROC; | } INFOPROC; |
| static const INFOPROC infoproc[] = { | static const INFOPROC infoproc[] = { |
| {"VER", info_ver}, | {OEMTEXT("VER"), info_ver}, |
| {"CPU", info_cpu}, | {OEMTEXT("CPU"), info_cpu}, |
| {"CLOCK", info_clock}, | {OEMTEXT("CLOCK"), info_clock}, |
| {"BASE", info_base}, | {OEMTEXT("BASE"), info_base}, |
| {"MEM1", info_mem1}, | {OEMTEXT("MEM1"), info_mem1}, |
| {"MEM2", info_mem2}, | {OEMTEXT("MEM2"), info_mem2}, |
| {"MEM3", info_mem3}, | {OEMTEXT("MEM3"), info_mem3}, |
| {"GDC", info_gdc}, | {OEMTEXT("GDC"), info_gdc}, |
| {"TEXT", info_text}, | {OEMTEXT("GDC2"), info_gdc2}, |
| {"GRPH", info_grph}, | {OEMTEXT("TEXT"), info_text}, |
| {"SND", info_sound}, | {OEMTEXT("GRPH"), info_grph}, |
| {"EXSND", info_extsnd}, | {OEMTEXT("SND"), info_sound}, |
| {"BIOS", info_bios}, | {OEMTEXT("EXSND"), info_extsnd}, |
| {"RHYTHM", info_rhythm}, | {OEMTEXT("BIOS"), info_bios}, |
| {"DISP", info_display}}; | {OEMTEXT("RHYTHM"), info_rhythm}, |
| {OEMTEXT("DISP"), info_display}}; | |
| static BOOL defext(char *dst, const char *key, int maxlen, NP2INFOEX *ex) { | static BOOL defext(OEMCHAR *dst, const OEMCHAR *key, int maxlen, |
| const NP2INFOEX *ex) { | |
| milstr_ncpy(dst, key, maxlen); | milstr_ncpy(dst, key, maxlen); |
| (void)ex; | (void)ex; |
| return(TRUE); | return(TRUE); |
| } | } |
| void np2info(char *dst, const char *src, int maxlen, const NP2INFOEX *ex) { | void np2info(OEMCHAR *dst, const OEMCHAR *src, int maxlen, |
| const NP2INFOEX *ex) { | |
| NP2INFOEX statex; | NP2INFOEX statex; |
| char c; | OEMCHAR c; |
| int leng; | int leng; |
| char infwork[12]; | OEMCHAR infwork[12]; |
| const INFOPROC *inf; | const INFOPROC *inf; |
| const INFOPROC *infterm; | const INFOPROC *infterm; |
| Line 340 const INFOPROC *infterm; | Line 360 const INFOPROC *infterm; |
| return; | return; |
| } | } |
| if (ex == NULL) { | if (ex == NULL) { |
| milstr_ncpy(statex.cr, str_oscr, sizeof(statex.cr)); | milstr_ncpy(statex.cr, str_oscr, NELEMENTS(statex.cr)); |
| statex.ext = NULL; | statex.ext = NULL; |
| } | } |
| else { | else { |
| Line 379 const INFOPROC *infterm; | Line 399 const INFOPROC *infterm; |
| if (c == '%') { | if (c == '%') { |
| break; | break; |
| } | } |
| if (leng < (int)(sizeof(infwork) - 1)) { | if (leng < (int)(NELEMENTS(infwork) - 1)) { |
| infwork[leng++] = c; | infwork[leng++] = c; |
| } | } |
| } | } |
| infwork[leng] = '\0'; | infwork[leng] = '\0'; |
| inf = infoproc; | inf = infoproc; |
| infterm = infoproc + (sizeof(infoproc) / sizeof(INFOPROC)); | infterm = infoproc + NELEMENTS(infoproc); |
| while(inf < infterm) { | while(inf < infterm) { |
| if (!milstr_cmp(infwork, inf->key)) { | if (!milstr_cmp(infwork, inf->key)) { |
| inf->proc(dst, maxlen, &statex); | inf->proc(dst, maxlen, &statex); |
| Line 399 const INFOPROC *infterm; | Line 419 const INFOPROC *infterm; |
| } | } |
| } | } |
| } | } |
| leng = strlen(dst); | leng = OEMSTRLEN(dst); |
| dst += leng; | dst += leng; |
| maxlen -= leng; | maxlen -= leng; |
| } | } |