|
|
| version 1.2, 2003/10/21 11:22:05 | version 1.9, 2005/03/19 20:46:07 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "strres.h" | |
| #include "np2.h" | #include "np2.h" |
| #include "scrnmng.h" | |
| #include "sysmng.h" | #include "sysmng.h" |
| #include "sstp.h" | #include "sstp.h" |
| #include "sstpres.h" | #include "sstpres.h" |
| #include "np2info.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | |
| #include "sound.h" | |
| #include "fmboard.h" | |
| #include "np2info.h" | |
| #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) | |
| #include "oemtext.h" | |
| #endif | |
| static const OEMCHAR cr[] = OEMTEXT("\\n"); | |
| // ---- np2info extend | |
| static const OEMCHAR str_jwinclr[] = | |
| OEMTEXT("256色\0ハイカラー\0フルカラー\0トゥルーカラー"); | |
| static const OEMCHAR str_jwinmode[] = | |
| OEMTEXT(" (窓モード)\0 (フルスクリーン)"); | |
| static void info_progtitle(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { | |
| milstr_ncpy(str, np2oscfg.titles, maxlen); | |
| } | |
| static void info_jsound(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { | |
| const OEMCHAR *p; | |
| switch(usesound) { | |
| case 0x01: | |
| p = OEMTEXT("14ボード"); | |
| break; | |
| case 0x02: | |
| p = OEMTEXT("26音源"); | |
| break; | |
| case 0x04: | |
| p = OEMTEXT("86音源"); | |
| break; | |
| case 0x06: | |
| p = OEMTEXT("2枚刺し"); | |
| break; | |
| case 0x08: | |
| p = OEMTEXT("118音源"); | |
| break; | |
| case 0x14: | |
| p = OEMTEXT("86音源(ちびおと付)"); | |
| break; | |
| case 0x20: | |
| p = OEMTEXT("スピークボード"); | |
| break; | |
| case 0x40: | |
| p = OEMTEXT("スパークボード"); | |
| break; | |
| case 0x80: | |
| p = OEMTEXT("AMD-98"); | |
| break; | |
| default: | |
| p = OEMTEXT("なし"); | |
| break; | |
| } | |
| milstr_ncpy(str, p, maxlen); | |
| } | |
| static char cr[] = "\\n"; | static void info_jdisp(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { |
| static const BYTE prs2[] = {0xaa,0xac,0xae,0xb0,0xb2,0xbe,0xf0,0x9f, | UINT bpp; |
| 0xa1,0xa3,0xa5,0xa7,0xe1,0xe3,0xe5,0xc1, | |
| 0xb8,0xa0,0xa2,0xa4,0xa6,0xa8,0xa9,0xab, | |
| 0xad,0xaf,0xb1,0xb3,0xb5,0xb7,0xb9,0xbb, | |
| 0xbd,0xbf,0xc2,0xc4,0xc6,0xc8,0xc9,0xca, | |
| 0xcb,0xcc,0xcd,0xd0,0xd3,0xd6,0xd9,0xdc, | |
| 0xdd,0xde,0xdf,0xe0,0xe2,0xe4,0xe6,0xe7, | |
| 0xe8,0xe9,0xea,0xeb,0xed,0xf1,0xb4,0xb8}; | |
| bpp = scrnmng_getbpp(); | |
| milstr_ncpy(str, milstr_list(str_jwinclr, ((bpp >> 3) - 1) & 3), maxlen); | |
| milstr_ncat(str, milstr_list(str_jwinmode, (scrnmng_isfullscreen())?1:0), | |
| maxlen); | |
| (void)ex; | |
| } | |
| static void info_jbios(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { | |
| str[0] = '\0'; | |
| if (pccore.rom & PCROM_BIOS) { | |
| milstr_ncat(str, str_biosrom, maxlen); | |
| } | |
| if (soundrom.name[0]) { | |
| if (str[0]) { | |
| milstr_ncat(str, OEMTEXT("と"), maxlen); | |
| } | |
| milstr_ncat(str, soundrom.name, maxlen); | |
| } | |
| if (str[0] == '\0') { | |
| milstr_ncat(str, OEMTEXT("なし"), maxlen); | |
| } | |
| } | |
| static void info_jrhythm(OEMCHAR *str, int maxlen, const NP2INFOEX *ex) { | |
| const OEMCHAR *p; | |
| OEMCHAR jrhythmstr[16]; | |
| UINT exist; | |
| UINT i; | |
| if (!(usesound & 0x6c)) { | |
| p = OEMTEXT("不要やで"); | |
| } | |
| else { | |
| exist = rhythm_getcaps(); | |
| if (exist == 0) { | |
| p = OEMTEXT("用意されてないんか…"); | |
| } | |
| else if (exist == 0x3f) { | |
| p = OEMTEXT("全部あるで"); | |
| } | |
| else { | |
| milstr_ncpy(jrhythmstr, OEMTEXT("BSCHTRや"), NELEMENTS(jrhythmstr)); | |
| for (i=0; i<6; i++) { | |
| if (!(exist & (1 << i))) { | |
| jrhythmstr[i] = '_'; | |
| } | |
| } | |
| p = jrhythmstr; | |
| } | |
| } | |
| milstr_ncpy(str, p, maxlen); | |
| } | |
| typedef struct { | |
| OEMCHAR key[8]; | |
| void (*proc)(OEMCHAR *str, int maxlen, const NP2INFOEX *ex); | |
| } INFOPROC; | |
| static const INFOPROC infoproc[] = { | |
| {OEMTEXT("PROG"), info_progtitle}, | |
| {OEMTEXT("JSND"), info_jsound}, | |
| {OEMTEXT("JBIOS"), info_jbios}, | |
| {OEMTEXT("JDISP"), info_jdisp}, | |
| {OEMTEXT("JRHYTHM"), info_jrhythm}}; | |
| static BOOL sstpext(OEMCHAR *dst, const OEMCHAR *key, int maxlen, | |
| const NP2INFOEX *ex) { | |
| const INFOPROC *inf; | |
| const INFOPROC *infterm; | |
| inf = infoproc; | |
| infterm = infoproc + NELEMENTS(infoproc); | |
| while(inf < infterm) { | |
| if (!milstr_cmp(key, inf->key)) { | |
| inf->proc(dst, maxlen, ex); | |
| return(TRUE); | |
| } | |
| inf++; | |
| } | |
| return(FALSE); | |
| } | |
| static const NP2INFOEX sstpex = {OEMTEXT("\\n"), sstpext}; | |
| // ---- | |
| static const UINT8 prs2[] = {0xaa,0xac,0xae,0xb0,0xb2,0xbe,0xf0,0x9f, | |
| 0xa1,0xa3,0xa5,0xa7,0xe1,0xe3,0xe5,0xc1, | |
| 0xb8,0xa0,0xa2,0xa4,0xa6,0xa8,0xa9,0xab, | |
| 0xad,0xaf,0xb1,0xb3,0xb5,0xb7,0xb9,0xbb, | |
| 0xbd,0xbf,0xc2,0xc4,0xc6,0xc8,0xc9,0xca, | |
| 0xcb,0xcc,0xcd,0xd0,0xd3,0xd6,0xd9,0xdc, | |
| 0xdd,0xde,0xdf,0xe0,0xe2,0xe4,0xe6,0xe7, | |
| 0xe8,0xe9,0xea,0xeb,0xed,0xf1,0xb4,0xb8}; | |
| #define GETSSTPDAT1(a) { \ | #define GETSSTPDAT1(a) { \ |
| (a) = last; \ | (a) = last; \ |
| Line 27 static const BYTE prs2[] = {0xaa,0xac,0x | Line 189 static const BYTE prs2[] = {0xaa,0xac,0x |
| (a) = ((a) << 2) | ((a) >> 6); \ | (a) = ((a) << 2) | ((a) >> 6); \ |
| } | } |
| static char *sstpsolve(char *buf, const unsigned char *dat) { | static OEMCHAR *sstpsolve(OEMCHAR *buf, const UINT8 *dat) { |
| BYTE c; | UINT8 c; |
| BYTE last; | UINT8 last; |
| #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) | |
| char sjis[4]; | |
| #endif | |
| last = 0x80; | last = 0x80; |
| while(1) { | while(1) { |
| Line 58 static char *sstpsolve(char *buf, const | Line 223 static char *sstpsolve(char *buf, const |
| *buf++ = c; | *buf++ = c; |
| } | } |
| else if (c == 0x7f) { | else if (c == 0x7f) { |
| BYTE ms; | UINT8 ms; |
| GETSSTPDAT1(ms); | GETSSTPDAT1(ms); |
| if (!ms) { | if (!ms) { |
| break; | break; |
| } | } |
| while(ms > 10) { | while(ms > 10) { |
| CopyMemory(buf, "\\w9", 3); | CopyMemory(buf, OEMTEXT("\\w9"), 3 * sizeof(OEMCHAR)); |
| buf += 3; | buf += 3; |
| ms -= 10; | ms -= 10; |
| } | } |
| if (ms) { | if (ms) { |
| wsprintf(buf, "\\w%u", ms); | OEMSPRINTF(buf, OEMTEXT("\\w%1u"), ms); |
| buf += 3; | buf += 3; |
| } | } |
| } | } |
| else if (c == 0x80) { | else if (c == 0x80) { |
| BYTE c2; | UINT8 c2; |
| GETSSTPDAT1(c2); | GETSSTPDAT1(c2); |
| if (c2) { | if (c2) { |
| #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) | |
| sjis[0] = c2; | |
| sjis[1] = '\0'; | |
| oemtext_sjistooem(buf, 4, sjis, 1); | |
| buf += OEMSTRLEN(buf); | |
| #else | |
| *buf++ = c2; | *buf++ = c2; |
| #endif | |
| } | } |
| else { | else { |
| break; | break; |
| Line 85 static char *sstpsolve(char *buf, const | Line 257 static char *sstpsolve(char *buf, const |
| } | } |
| else if (c >= 0xf0) { | else if (c >= 0xf0) { |
| int i; | int i; |
| const BYTE *p; | const UINT8 *p; |
| i = c - 0xf0; | i = c - 0xf0; |
| if (c == 0xff) { | if (c == 0xff) { |
| BYTE c2; | UINT8 c2; |
| GETSSTPDAT1(c2); | GETSSTPDAT1(c2); |
| if (!c2) { | if (!c2) { |
| break; | break; |
| Line 102 static char *sstpsolve(char *buf, const | Line 274 static char *sstpsolve(char *buf, const |
| buf = sstpsolve(buf, p); | buf = sstpsolve(buf, p); |
| } | } |
| else if ((c >= 0xa0) && (c < 0xe0)) { | else if ((c >= 0xa0) && (c < 0xe0)) { |
| *buf++ = (BYTE)0x82; | #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) |
| *buf++ = prs2[c-0xa0]; | sjis[0] = (UINT8)0x82; |
| sjis[1] = prs2[c-0xa0]; | |
| sjis[2] = '\0'; | |
| oemtext_sjistooem(buf, 4, sjis, 2); | |
| buf += OEMSTRLEN(buf); | |
| #else | |
| buf[0] = (UINT8)0x82; | |
| buf[1] = prs2[c-0xa0]; | |
| buf += 2; | |
| #endif | |
| } | } |
| else { | else { |
| BYTE c2; | UINT8 c2; |
| GETSSTPDAT1(c2); | GETSSTPDAT1(c2); |
| if (c2) { | if (c2) { |
| *buf++ = c; | #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) |
| *buf++ = c2; | sjis[0] = c; |
| sjis[1] = c2; | |
| sjis[2] = '\0'; | |
| oemtext_sjistooem(buf, 4, sjis, 2); | |
| buf += OEMSTRLEN(buf); | |
| #else | |
| buf[0] = c; | |
| buf[1] = c2; | |
| buf += 2; | |
| #endif | |
| } | } |
| else { | else { |
| break; | break; |
| Line 121 static char *sstpsolve(char *buf, const | Line 311 static char *sstpsolve(char *buf, const |
| return(buf); | return(buf); |
| } | } |
| // ------------------------------- | // ------------------------------- |
| static int check_keropi(void) { | static int check_keropi(void) { |
| char buf[64]; | OEMCHAR buf[64]; |
| sstpsolve(buf, k_keropi); | sstpsolve(buf, k_keropi); |
| if (FindWindow(buf, NULL)) { | if (FindWindow(buf, NULL)) { |
| Line 152 static int check_keropi(void) { | Line 343 static int check_keropi(void) { |
| void sstpmsg_welcome(void) { | void sstpmsg_welcome(void) { |
| int kero; | int kero; |
| char *p; | OEMCHAR *p; |
| char buf[512]; | OEMCHAR buf[512]; |
| p = buf; | p = buf; |
| kero = check_keropi(); | kero = check_keropi(); |
| if (!kero) { | if (!kero) { |
| switch(rand() & 15) { | switch(rand() & 15) { |
| Line 207 void sstpmsg_welcome(void) { | Line 397 void sstpmsg_welcome(void) { |
| break; | break; |
| } | } |
| break; | break; |
| case 2: | case 2: |
| p = sstpsolve(p, s_winx68k); | p = sstpsolve(p, s_winx68k); |
| break; | break; |
| case 3: | case 3: |
| p = sstpsolve(p, s_t98next); | p = sstpsolve(p, s_t98next); |
| break; | break; |
| case 4: | case 4: |
| p = sstpsolve(p, s_anex86); | p = sstpsolve(p, s_anex86); |
| break; | break; |
| default: | default: |
| p = sstpsolve(p, s_error); | p = sstpsolve(p, s_error); |
| break; | break; |
| Line 226 void sstpmsg_welcome(void) { | Line 420 void sstpmsg_welcome(void) { |
| void sstpmsg_reset(void) { | void sstpmsg_reset(void) { |
| char str[1024]; | OEMCHAR str[1024]; |
| UINT update; | UINT update; |
| str[0] = '\0'; | str[0] = '\0'; |
| update = sys_updates; | update = sys_updates; |
| if (update & SYS_UPDATECLOCK) { | if (update & SYS_UPDATECLOCK) { |
| strcat(str, "CPUクロックを !CLOCKに"); | milstr_ncat(str, OEMTEXT("CPUクロックを %CLOCK%に"), NELEMENTS(str)); |
| } | } |
| if (update & SYS_UPDATEMEMORY) { | if (update & SYS_UPDATEMEMORY) { |
| if (str[0]) { | if (str[0]) { |
| strcat(str, cr); | milstr_ncat(str, cr, NELEMENTS(str)); |
| } | } |
| strcat(str, "メモリを !MEM3に"); | milstr_ncat(str, OEMTEXT("メモリを %MEM3%に"), NELEMENTS(str)); |
| } | } |
| if (update & SYS_UPDATESBOARD) { | if (update & SYS_UPDATESBOARD) { |
| if (str[0]) { | if (str[0]) { |
| strcat(str, cr); | milstr_ncat(str, cr, NELEMENTS(str)); |
| } | } |
| strcat(str, "音源を !JSNDに"); | milstr_ncat(str, OEMTEXT("音源を %JSND%に"), NELEMENTS(str)); |
| } | } |
| if (update & (SYS_UPDATERATE | SYS_UPDATESBUF | SYS_UPDATEMIDI | | if (update & (SYS_UPDATERATE | SYS_UPDATESBUF | SYS_UPDATEMIDI | |
| SYS_UPDATEHDD | SYS_UPDATESERIAL1)) { | SYS_UPDATEHDD | SYS_UPDATESERIAL1)) { |
| BOOL hit = FALSE; | BOOL hit = FALSE; |
| if (str[0]) { | if (str[0]) { |
| strcat(str, "\\nあと…\\w5"); | milstr_ncat(str, OEMTEXT("\\nあと…\\w5"), NELEMENTS(str)); |
| } | } |
| if (update & SYS_UPDATEMIDI) { | if (update & SYS_UPDATEMIDI) { |
| hit = TRUE; | hit = TRUE; |
| strcat(str, "MIDI"); | milstr_ncat(str, OEMTEXT("MIDI"), NELEMENTS(str)); |
| } | } |
| if (update & (SYS_UPDATERATE | SYS_UPDATESBUF)) { | if (update & (SYS_UPDATERATE | SYS_UPDATESBUF)) { |
| if (hit) { | if (hit) { |
| strcat(str, " "); | milstr_ncat(str, str_space, NELEMENTS(str)); |
| } | } |
| hit = TRUE; | hit = TRUE; |
| strcat(str, "サウンド設定"); | milstr_ncat(str, OEMTEXT("サウンド設定"), NELEMENTS(str)); |
| } | } |
| if (update & SYS_UPDATEHDD) { | if (update & SYS_UPDATEHDD) { |
| if (hit) { | if (hit) { |
| strcat(str, " "); | milstr_ncat(str, str_space, NELEMENTS(str)); |
| } | } |
| hit = TRUE; | hit = TRUE; |
| strcat(str, "ハードディスク"); | milstr_ncat(str, OEMTEXT("ハードディスク"), NELEMENTS(str)); |
| } | } |
| if (update & SYS_UPDATESERIAL1) { | if (update & SYS_UPDATESERIAL1) { |
| if (hit) { | if (hit) { |
| strcat(str, " "); | milstr_ncat(str, str_space, NELEMENTS(str)); |
| } | } |
| hit = TRUE; | hit = TRUE; |
| strcat(str, "シリアル"); | milstr_ncat(str, OEMTEXT("シリアル"), NELEMENTS(str)); |
| } | } |
| strcat(str, "の設定を"); | milstr_ncat(str, OEMTEXT("の設定を"), NELEMENTS(str)); |
| } | } |
| if (str[0]) { | if (str[0]) { |
| char out[1024]; | OEMCHAR out[1024]; |
| strcat(str, "変更しました。"); | milstr_ncat(str, OEMTEXT("変更しました。"), NELEMENTS(str)); |
| np2info(out, str, sizeof(out)); | np2info(out, str, NELEMENTS(out), &sstpex); |
| sstp_send(out, NULL); | sstp_send(out, NULL); |
| } | } |
| } | } |
| void sstpmsg_about(void) { | void sstpmsg_about(void) { |
| char str[2048]; | OEMCHAR str[1024]; |
| char out[2048]; | OEMCHAR out[1024]; |
| char *p; | OEMCHAR *p; |
| int nostat = FALSE; | int nostat = FALSE; |
| p = str; | p = str; |
| Line 309 void sstpmsg_about(void) { | Line 501 void sstpmsg_about(void) { |
| case 5: | case 5: |
| p = sstpsolve(p, s_ver1); | p = sstpsolve(p, s_ver1); |
| break; | break; |
| case 6: | case 6: |
| p = sstpsolve(p, s_ver2); | p = sstpsolve(p, s_ver2); |
| break; | break; |
| Line 321 void sstpmsg_about(void) { | Line 514 void sstpmsg_about(void) { |
| if (!nostat) { | if (!nostat) { |
| p = sstpsolve(p, s_info); | p = sstpsolve(p, s_info); |
| } | } |
| np2info(out, str, sizeof(out)); | np2info(out, str, NELEMENTS(out), &sstpex); |
| sstp_send(out, NULL); | sstp_send(out, NULL); |
| } | } |
| void sstpmsg_config(void) { | void sstpmsg_config(void) { |
| char str[1024]; | OEMCHAR str[1024]; |
| char *p; | OEMCHAR *p; |
| p = sstpsolve(str, s_config0); | p = sstpsolve(str, s_config0); |
| switch(rand() & 7) { | switch(rand() & 7) { |
| case 0: | case 0: |
| p = sstpsolve(p, s_config1); | p = sstpsolve(p, s_config1); |
| break; | break; |
| case 1: | case 1: |
| p = sstpsolve(p, s_config2); | p = sstpsolve(p, s_config2); |
| break; | break; |
| case 2: | case 2: |
| case 3: | case 3: |
| p = sstpsolve(p, s_config3); | p = sstpsolve(p, s_config3); |
| break; | break; |
| default: | default: |
| p = sstpsolve(p, s_config4); | p = sstpsolve(p, s_config4); |
| break; | break; |
| Line 350 void sstpmsg_config(void) { | Line 546 void sstpmsg_config(void) { |
| sstp_send(str, NULL); | sstp_send(str, NULL); |
| } | } |
| // ----------------------------------------------------------- | |
| // ---- | |
| static char *get_code(char *buf, int *ret) { | static char *get_code(char *buf, int *ret) { |
| int stat; | int stat; |
| stat = 0; | stat = 0; |
| if (!memcmp(buf, "SSTP", 4)) { | if (!memcmp(buf, "SSTP", 4)) { |
| Line 394 static void e_sstpreset(HWND hWnd, char | Line 591 static void e_sstpreset(HWND hWnd, char |
| BOOL sstpconfirm_reset(void) { | BOOL sstpconfirm_reset(void) { |
| char str[256]; | OEMCHAR str[256]; |
| sstpsolve(str, s_reset); | sstpsolve(str, s_reset); |
| return(sstp_send(str, e_sstpreset)); | return(sstp_send(str, e_sstpreset)); |
| Line 413 static void e_sstpexit(HWND hWnd, char * | Line 610 static void e_sstpexit(HWND hWnd, char * |
| } | } |
| } | } |
| #if 0 | |
| static void e_sstpexit2(HWND hWnd, char *buf) { | |
| char *p; | |
| int ret; | |
| p = get_code(buf, &ret); | |
| if (ret == 200) { | |
| if (!memcmp(p, "いい", 4)) { | |
| SendMessage(hWnd, WM_NP2CMD, 0, NP2CMD_EXIT2); | |
| } | |
| } | |
| } | |
| #endif | |
| BOOL sstpconfirm_exit(void) { | BOOL sstpconfirm_exit(void) { |
| char str[512]; | OEMCHAR str[512]; |
| #if 1 | |
| sstpsolve(str, s_exit); | sstpsolve(str, s_exit); |
| return(sstp_send(str, e_sstpexit)); | return(sstp_send(str, e_sstpexit)); |
| #else | |
| if (rand() & 3) { | |
| sstpsolve(str, s_exit); | |
| return(sstp_send(str, e_sstpexit)); | |
| } | |
| else { | |
| sstpsolve(str, s_exit2); | |
| return(sstp_send(str, e_sstpexit2)); | |
| } | |
| #endif | |
| } | } |
| Line 452 BOOL sstpconfirm_exit(void) { | Line 623 BOOL sstpconfirm_exit(void) { |
| BOOL sstpmsg_running(void) { | BOOL sstpmsg_running(void) { |
| char buf[256]; | OEMCHAR buf[256]; |
| char *p; | OEMCHAR *p; |
| p = buf; | p = buf; |
| switch(rand() & 7) { | switch(rand() & 7) { |
| case 0: | case 0: |
| p = sstpsolve(p, s_running1); | p = sstpsolve(p, s_running1); |
| break; | break; |
| case 1: | case 1: |
| p = sstpsolve(p, s_running2); | p = sstpsolve(p, s_running2); |
| break; | break; |
| case 2: | case 2: |
| p = sstpsolve(p, s_running3); | p = sstpsolve(p, s_running3); |
| break; | break; |
| default: | default: |
| p = sstpsolve(p, s_running4); | p = sstpsolve(p, s_running4); |
| break; | break; |
| Line 476 BOOL sstpmsg_running(void) { | Line 650 BOOL sstpmsg_running(void) { |
| BOOL sstpmsg_dxerror(void) { | BOOL sstpmsg_dxerror(void) { |
| char buf[256]; | OEMCHAR buf[256]; |
| sstpsolve(buf, s_dxerror); | sstpsolve(buf, s_dxerror); |
| return(sstp_sendonly(buf)); | return(sstp_sendonly(buf)); |