--- np2/statsave.c 2003/10/29 10:09:37 1.14 +++ np2/statsave.c 2003/11/15 07:10:02 1.17 @@ -12,6 +12,7 @@ #include "pc9861k.h" #include "mpu98ii.h" #include "board14.h" +#include "amd98.h" #include "bios.h" #include "vram.h" #include "palettes.h" @@ -28,6 +29,18 @@ #include "keydisp.h" +#if defined(MACOS) +#define CRLITERAL "\r" +#define CRCONST str_cr +#elif defined(WIN32) || defined(X11) || defined(SLZAURUS) +#define CRLITERAL "\n" +#define CRCONST str_lf +#else +#define CRLITERAL "\r\n" +#define CRCONST str_crlf +#endif + + typedef struct { char name[16]; char vername[28]; @@ -89,9 +102,10 @@ typedef struct { static void err_append(ERR_BUF *e, char *buf) { + int len; + if ((e) && (buf)) { if (e->buf) { - int len; len = strlen(buf); if (e->remain >= len) { CopyMemory(e->buf, buf, len); @@ -613,7 +627,7 @@ static int flagsave_gij(NP2FFILE f, cons ret = flagsave_create(f, t); if (ret != NP2FLAG_FAILURE) { for (i=0; i<2; i++) { - fnt = font + ((0x56 + (i << 7)) << 4); + fnt = fontrom + ((0x56 + (i << 7)) << 4); for (j=0; j<0x80; j++) { ret |= flagsave_save(f, fnt, 32); fnt += 0x1000; @@ -633,7 +647,7 @@ static int flagload_gij(NP2FFILE f, cons ret = 0; for (i=0; i<2; i++) { - fnt = font + ((0x56 + (i << 7)) << 4); + fnt = fontrom + ((0x56 + (i << 7)) << 4); for (j=0; j<0x80; j++) { ret |= flagload_load(f, fnt, 32); fnt += 0x1000; @@ -654,10 +668,11 @@ enum { FLAG_FM2B = 0x0010, FLAG_PSG1 = 0x0020, FLAG_PSG2 = 0x0040, - FLAG_RHYTHM = 0x0080, - FLAG_ADPCM = 0x0100, - FLAG_PCM86 = 0x0200, - FLAG_CS4231 = 0x0400 + FLAG_PSG3 = 0x0080, + FLAG_RHYTHM = 0x0100, + FLAG_ADPCM = 0x0200, + FLAG_PCM86 = 0x0400, + FLAG_CS4231 = 0x0800 }; typedef struct { @@ -710,6 +725,10 @@ static int flagsave_fm(NP2FFILE f, const FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; break; + case 0x80: + saveflg = FLAG_PSG1 | FLAG_PSG2 | FLAG_PSG3; + break; + default: saveflg = 0; break; @@ -738,6 +757,9 @@ static int flagsave_fm(NP2FFILE f, const if (saveflg & FLAG_PSG2) { ret |= flagsave_save(f, &psg2.reg, sizeof(PSGREG)); } + if (saveflg & FLAG_PSG3) { + ret |= flagsave_save(f, &psg3.reg, sizeof(PSGREG)); + } if (saveflg & FLAG_ADPCM) { ret |= flagsave_save(f, &adpcm, sizeof(adpcm)); } @@ -846,6 +868,10 @@ static int flagload_fm(NP2FFILE f, const FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; break; + case 0x80: + saveflg = FLAG_PSG1 | FLAG_PSG2 | FLAG_PSG3; + break; + default: saveflg = 0; break; @@ -872,6 +898,9 @@ static int flagload_fm(NP2FFILE f, const if (saveflg & FLAG_PSG2) { ret |= flagload_load(f, &psg2.reg, sizeof(PSGREG)); } + if (saveflg & FLAG_PSG3) { + ret |= flagload_load(f, &psg3.reg, sizeof(PSGREG)); + } if (saveflg & FLAG_ADPCM) { ret |= flagload_load(f, &adpcm, sizeof(adpcm)); } @@ -912,6 +941,9 @@ static int flagload_fm(NP2FFILE f, const if (saveflg & FLAG_PSG2) { play_psgreg(&psg2); } + if (saveflg & FLAG_PSG3) { + play_psgreg(&psg3); + } (void)t; return(ret); } @@ -926,6 +958,12 @@ typedef struct { DOSTIME time; } STATDISK; +static const char str_fddx[] = "FDD%u"; +static const char str_sasix[] = "SASI%u"; +static const char str_scsix[] = "SCSI%u"; +static const char str_updated[] = "%s: updated" CRLITERAL; +static const char str_notfound[] = "%s: not found" CRLITERAL; + static int disksave(NP2FFILE f, const char *path, int readonly) { STATDISK st; @@ -984,13 +1022,13 @@ static int diskcheck(NP2FFILE f, const c if ((memcmp(&st.date, &date, sizeof(date))) || (memcmp(&st.time, &time, sizeof(time)))) { ret |= NP2FLAG_DISKCHG; - SPRINTF(buf, "%s: updated\n", name); + SPRINTF(buf, str_updated, name); err_append(e, buf); } } else { ret |= NP2FLAG_DISKCHG; - SPRINTF(buf, "%s: not found\n", name); + SPRINTF(buf, str_notfound, name); err_append(e, buf); } } @@ -1005,16 +1043,16 @@ static int flagcheck_disk(NP2FFILE f, co ret = 0; for (i=0; i<4; i++) { - SPRINTF(buf, "FDD%d", i+1); + SPRINTF(buf, str_fddx, i+1); ret |= diskcheck(f, buf, e); } sxsi_flash(); for (i=0; i<2; i++) { - SPRINTF(buf, "SASI%u", i+1); + SPRINTF(buf, str_sasix, i+1); ret |= diskcheck(f, buf, e); } for (i=0; i<2; i++) { - SPRINTF(buf, "SCSI%d", i+1); + SPRINTF(buf, str_scsix, i+1); ret |= diskcheck(f, buf, e); } (void)t;