|
|
| version 1.12, 2003/10/24 10:58:47 | version 1.15, 2003/11/08 21:43:00 |
|---|---|
| Line 12 | Line 12 |
| #include "pc9861k.h" | #include "pc9861k.h" |
| #include "mpu98ii.h" | #include "mpu98ii.h" |
| #include "board14.h" | #include "board14.h" |
| #include "amd98.h" | |
| #include "bios.h" | #include "bios.h" |
| #include "vram.h" | #include "vram.h" |
| #include "palettes.h" | #include "palettes.h" |
| Line 50 enum { | Line 51 enum { |
| NP2FLAG_EVT, | NP2FLAG_EVT, |
| NP2FLAG_GIJ, | NP2FLAG_GIJ, |
| NP2FLAG_FM, | NP2FLAG_FM, |
| NP2FLAG_MIDI, | NP2FLAG_COM, |
| NP2FLAG_DISK | NP2FLAG_DISK |
| }; | }; |
| Line 654 enum { | Line 655 enum { |
| FLAG_FM2B = 0x0010, | FLAG_FM2B = 0x0010, |
| FLAG_PSG1 = 0x0020, | FLAG_PSG1 = 0x0020, |
| FLAG_PSG2 = 0x0040, | FLAG_PSG2 = 0x0040, |
| FLAG_RHYTHM = 0x0080, | FLAG_PSG3 = 0x0080, |
| FLAG_ADPCM = 0x0100, | FLAG_RHYTHM = 0x0100, |
| FLAG_PCM86 = 0x0200, | FLAG_ADPCM = 0x0200, |
| FLAG_CS4231 = 0x0400 | FLAG_PCM86 = 0x0400, |
| FLAG_CS4231 = 0x0800 | |
| }; | }; |
| typedef struct { | typedef struct { |
| Line 710 static int flagsave_fm(NP2FFILE f, const | Line 712 static int flagsave_fm(NP2FFILE f, const |
| FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; | FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; |
| break; | break; |
| case 0x80: | |
| saveflg = FLAG_PSG1 | FLAG_PSG2 | FLAG_PSG3; | |
| break; | |
| default: | default: |
| saveflg = 0; | saveflg = 0; |
| break; | break; |
| Line 738 static int flagsave_fm(NP2FFILE f, const | Line 744 static int flagsave_fm(NP2FFILE f, const |
| if (saveflg & FLAG_PSG2) { | if (saveflg & FLAG_PSG2) { |
| ret |= flagsave_save(f, &psg2.reg, sizeof(PSGREG)); | ret |= flagsave_save(f, &psg2.reg, sizeof(PSGREG)); |
| } | } |
| if (saveflg & FLAG_PSG3) { | |
| ret |= flagsave_save(f, &psg3.reg, sizeof(PSGREG)); | |
| } | |
| if (saveflg & FLAG_ADPCM) { | if (saveflg & FLAG_ADPCM) { |
| ret |= flagsave_save(f, &adpcm, sizeof(adpcm)); | ret |= flagsave_save(f, &adpcm, sizeof(adpcm)); |
| } | } |
| Line 752 static int flagsave_fm(NP2FFILE f, const | Line 761 static int flagsave_fm(NP2FFILE f, const |
| return(ret); | return(ret); |
| } | } |
| static void play_fmreg(BYTE num) { | static void play_fmreg(BYTE num, UINT reg) { |
| UINT chbase; | UINT chbase; |
| UINT reg; | |
| UINT i; | UINT i; |
| chbase = num * 3; | chbase = num * 3; |
| reg = num * 0x100; | |
| for (i=0x30; i<0xa0; i++) { | for (i=0x30; i<0xa0; i++) { |
| opngen_setreg((BYTE)chbase, (BYTE)i, opn.reg[reg + i]); | opngen_setreg((BYTE)chbase, (BYTE)i, opn.reg[reg + i]); |
| } | } |
| Line 785 static int flagload_fm(NP2FFILE f, const | Line 792 static int flagload_fm(NP2FFILE f, const |
| int ret; | int ret; |
| UINT saveflg; | UINT saveflg; |
| OPNKEY opnkey; | OPNKEY opnkey; |
| UINT fmreg1a; | |
| UINT fmreg1b; | |
| UINT fmreg2a; | |
| UINT fmreg2b; | |
| opngen_reset(); | opngen_reset(); |
| psggen_reset(&psg1); | psggen_reset(&psg1); |
| Line 798 static int flagload_fm(NP2FFILE f, const | Line 809 static int flagload_fm(NP2FFILE f, const |
| ret = flagload_load(f, &usesound, sizeof(usesound)); | ret = flagload_load(f, &usesound, sizeof(usesound)); |
| fmboard_reset((BYTE)usesound); | fmboard_reset((BYTE)usesound); |
| fmreg1a = 0x000; | |
| fmreg1b = 0x100; | |
| fmreg2a = 0x200; | |
| fmreg2b = 0x300; | |
| switch(usesound) { | switch(usesound) { |
| case 0x01: | case 0x01: |
| saveflg = FLAG_MG; | saveflg = FLAG_MG; |
| Line 815 static int flagload_fm(NP2FFILE f, const | Line 830 static int flagload_fm(NP2FFILE f, const |
| case 0x06: | case 0x06: |
| saveflg = FLAG_FM1A | FLAG_FM1B | FLAG_FM2A | FLAG_PSG1 | | saveflg = FLAG_FM1A | FLAG_FM1B | FLAG_FM2A | FLAG_PSG1 | |
| FLAG_PSG2 | FLAG_RHYTHM | FLAG_PCM86; | FLAG_PSG2 | FLAG_RHYTHM | FLAG_PCM86; |
| fmreg1a = 0x200; // 逆転してるのん… | |
| fmreg1b = 0x000; | |
| fmreg2a = 0x100; | |
| break; | break; |
| case 0x08: | case 0x08: |
| Line 837 static int flagload_fm(NP2FFILE f, const | Line 855 static int flagload_fm(NP2FFILE f, const |
| FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; | FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; |
| break; | break; |
| case 0x80: | |
| saveflg = FLAG_PSG1 | FLAG_PSG2 | FLAG_PSG3; | |
| break; | |
| default: | default: |
| saveflg = 0; | saveflg = 0; |
| break; | break; |
| Line 863 static int flagload_fm(NP2FFILE f, const | Line 885 static int flagload_fm(NP2FFILE f, const |
| if (saveflg & FLAG_PSG2) { | if (saveflg & FLAG_PSG2) { |
| ret |= flagload_load(f, &psg2.reg, sizeof(PSGREG)); | ret |= flagload_load(f, &psg2.reg, sizeof(PSGREG)); |
| } | } |
| if (saveflg & FLAG_PSG3) { | |
| ret |= flagload_load(f, &psg3.reg, sizeof(PSGREG)); | |
| } | |
| if (saveflg & FLAG_ADPCM) { | if (saveflg & FLAG_ADPCM) { |
| ret |= flagload_load(f, &adpcm, sizeof(adpcm)); | ret |= flagload_load(f, &adpcm, sizeof(adpcm)); |
| } | } |
| Line 886 static int flagload_fm(NP2FFILE f, const | Line 911 static int flagload_fm(NP2FFILE f, const |
| } | } |
| if (saveflg & FLAG_FM1A) { | if (saveflg & FLAG_FM1A) { |
| play_fmreg(0); | play_fmreg(0, fmreg1a); |
| } | } |
| if (saveflg & FLAG_FM1B) { | if (saveflg & FLAG_FM1B) { |
| play_fmreg(1); | play_fmreg(1, fmreg1b); |
| } | } |
| if (saveflg & FLAG_FM2A) { | if (saveflg & FLAG_FM2A) { |
| play_fmreg(2); | play_fmreg(2, fmreg2a); |
| } | } |
| if (saveflg & FLAG_FM2B) { | if (saveflg & FLAG_FM2B) { |
| play_fmreg(3); | play_fmreg(3, fmreg2b); |
| } | } |
| if (saveflg & FLAG_PSG1) { | if (saveflg & FLAG_PSG1) { |
| play_psgreg(&psg1); | play_psgreg(&psg1); |
| Line 903 static int flagload_fm(NP2FFILE f, const | Line 928 static int flagload_fm(NP2FFILE f, const |
| if (saveflg & FLAG_PSG2) { | if (saveflg & FLAG_PSG2) { |
| play_psgreg(&psg2); | play_psgreg(&psg2); |
| } | } |
| if (saveflg & FLAG_PSG3) { | |
| play_psgreg(&psg3); | |
| } | |
| (void)t; | (void)t; |
| return(ret); | return(ret); |
| } | } |
| Line 1047 static int flagload_disk(NP2FFILE f, con | Line 1075 static int flagload_disk(NP2FFILE f, con |
| // ----- | // ----- |
| #ifdef _MIDICH | static int flagsave_com(NP2FFILE f, const STENTRY *t) { |
| static int flagsave_midi(NP2FFILE f, const STENTRY *t) { | |
| UINT device; | UINT device; |
| COMMNG cm; | COMMNG cm; |
| int ret; | int ret; |
| _MIDICH mch[16]; | COMFLAG flag; |
| device = (UINT)t->arg1; | device = (UINT)t->arg1; |
| switch(device) { | switch(device) { |
| Line 1070 static int flagsave_midi(NP2FFILE f, con | Line 1097 static int flagsave_midi(NP2FFILE f, con |
| break; | break; |
| } | } |
| ret = NP2FLAG_SUCCESS; | ret = NP2FLAG_SUCCESS; |
| if ((cm != NULL) && (cm->msg(cm, COMMSG_MIDISTATGET, (long)mch))) { | if (cm) { |
| ret = flagsave_create(f, t); | flag = (COMFLAG)cm->msg(cm, COMMSG_GETFLAG, 0); |
| if (ret != NP2FLAG_FAILURE) { | if (flag) { |
| ret |= flagsave_save(f, mch, sizeof(mch)); | ret = flagsave_create(f, t); |
| ret |= flagsave_close(f); | if (ret != NP2FLAG_FAILURE) { |
| ret |= flagsave_save(f, flag, flag->size); | |
| ret |= flagsave_close(f); | |
| } | |
| _MFREE(flag); | |
| } | } |
| } | } |
| return(ret); | return(ret); |
| } | } |
| static int flagload_midi(NP2FFILE f, const STENTRY *t) { | static int flagload_com(NP2FFILE f, const STENTRY *t) { |
| _MIDICH mch[16]; | UINT device; |
| UINT device; | COMMNG cm; |
| COMMNG cm; | int ret; |
| int ret; | _COMFLAG fhdr; |
| COMFLAG flag; | |
| ret = flagload_load(f, mch, sizeof(mch)); | ret = flagload_load(f, &fhdr, sizeof(fhdr)); |
| if (ret != NP2FLAG_FAILURE) { | if (ret != NP2FLAG_SUCCESS) { |
| device = (UINT)t->arg1; | goto flcom_err1; |
| switch(device) { | } |
| case 0: | if (fhdr.size < sizeof(fhdr)) { |
| commng_destroy(cm_mpu98); | goto flcom_err1; |
| cm = commng_create(COMCREATE_MPU98II); | } |
| cm_mpu98 = cm; | flag = (COMFLAG)_MALLOC(fhdr.size, "com stat flag"); |
| break; | if (flag == NULL) { |
| goto flcom_err1; | |
| } | |
| CopyMemory(flag, &fhdr, sizeof(fhdr)); | |
| ret |= flagload_load(f, flag + 1, fhdr.size - sizeof(fhdr)); | |
| if (ret != NP2FLAG_SUCCESS) { | |
| goto flcom_err2; | |
| } | |
| case 1: | device = (UINT)t->arg1; |
| commng_destroy(cm_rs232c); | switch(device) { |
| cm = commng_create(COMCREATE_SERIAL); | case 0: |
| cm_rs232c = cm; | commng_destroy(cm_mpu98); |
| break; | cm = commng_create(COMCREATE_MPU98II); |
| cm_mpu98 = cm; | |
| break; | |
| default: | case 1: |
| cm = NULL; | commng_destroy(cm_rs232c); |
| break; | cm = commng_create(COMCREATE_SERIAL); |
| } | cm_rs232c = cm; |
| if (cm) { | break; |
| cm->msg(cm, COMMSG_MIDISTATSET, (long)mch); | |
| } | default: |
| cm = NULL; | |
| break; | |
| } | |
| if (cm) { | |
| cm->msg(cm, COMMSG_SETFLAG, (long)flag); | |
| } | } |
| flcom_err2: | |
| _MFREE(flag); | |
| flcom_err1: | |
| return(ret); | return(ret); |
| } | } |
| #endif | |
| // ---- | // ---- |
| Line 1194 int statsave_save(const char *filename) | Line 1244 int statsave_save(const char *filename) |
| ret |= flagsave_disk(&f, &np2tbl[i]); | ret |= flagsave_disk(&f, &np2tbl[i]); |
| break; | break; |
| #if defined(MIDICH) | case NP2FLAG_COM: |
| case NP2FLAG_MIDI: | ret |= flagsave_com(&f, &np2tbl[i]); |
| ret |= flagsave_midi(&f, &np2tbl[i]); | |
| break; | break; |
| #endif | |
| } | } |
| } | } |
| flagclose(&f); | flagclose(&f); |
| Line 1254 int statsave_check(const char *filename, | Line 1302 int statsave_check(const char *filename, |
| case NP2FLAG_EXT: | case NP2FLAG_EXT: |
| case NP2FLAG_EVT: | case NP2FLAG_EVT: |
| case NP2FLAG_GIJ: | case NP2FLAG_GIJ: |
| #if defined(MIDICH) | case NP2FLAG_COM: |
| case NP2FLAG_MIDI: | |
| #endif | |
| ret |= flagcheck_veronly(&f, &np2tbl[i], &e); | ret |= flagcheck_veronly(&f, &np2tbl[i], &e); |
| break; | break; |
| Line 1357 int statsave_load(const char *filename) | Line 1403 int statsave_load(const char *filename) |
| ret |= flagload_disk(&f, &np2tbl[i]); | ret |= flagload_disk(&f, &np2tbl[i]); |
| break; | break; |
| #if defined(MIDICH) | case NP2FLAG_COM: |
| case NP2FLAG_MIDI: | ret |= flagload_com(&f, &np2tbl[i]); |
| ret |= flagload_midi(&f, &np2tbl[i]); | |
| break; | break; |
| #endif | |
| default: | default: |
| ret |= NP2FLAG_WARNING; | ret |= NP2FLAG_WARNING; |