| version 1.10, 2006/12/16 12:11:07 | version 1.14, 2011/02/04 01:10:14 | 
| Line 380  static BRESULT VERMOUTHCL cfgfile_load(M | Line 380  static BRESULT VERMOUTHCL cfgfile_load(M | 
 | (midimod_getfile(mod, filename, buf, NELEMENTS(buf)) != SUCCESS)) { | (midimod_getfile(mod, filename, buf, NELEMENTS(buf)) != SUCCESS)) { | 
 | goto cfl_err; | goto cfl_err; | 
 | } | } | 
| //      TRACEOUT(("open: %s", buf)); | // TRACEOUT(("open: %s", buf)); | 
 | tfh = textfile_open(buf, 0x1000); | tfh = textfile_open(buf, 0x1000); | 
 | if (tfh == NULL) { | if (tfh == NULL) { | 
 | goto cfl_err; | goto cfl_err; | 
| Line 486  mmcre_err1: | Line 486  mmcre_err1: | 
 | return(NULL); | return(NULL); | 
 | } | } | 
 |  |  | 
| void VERMOUTHCL midimod_lock(MIDIMOD hdl) { | void VERMOUTHCL midimod_lock(MIDIMOD mod) { | 
 |  |  | 
| hdl->lockcount++; | mod->lockcount++; | 
 | } | } | 
 |  |  | 
| void VERMOUTHCL midimod_unlock(MIDIMOD hdl) { | void VERMOUTHCL midimod_unlock(MIDIMOD mod) { | 
 |  |  | 
 | UINT    r; | UINT    r; | 
 | TONECFG bank; | TONECFG bank; | 
 |  |  | 
| if (!hdl->lockcount) { | if (!mod->lockcount) { | 
 | return; | return; | 
 | } | } | 
| hdl->lockcount--; | mod->lockcount--; | 
| if (hdl->lockcount) { | if (mod->lockcount) { | 
 | return; | return; | 
 | } | } | 
 |  |  | 
 | r = 128; | r = 128; | 
 | do { | do { | 
 | r--; | r--; | 
| inst_bankfree(hdl, r); | inst_bankfree(mod, r); | 
 | } while(r > 0); | } while(r > 0); | 
 | for (r=2; r<(MIDI_BANKS*2); r++) { | for (r=2; r<(MIDI_BANKS*2); r++) { | 
| bank = hdl->tonecfg[r]; | bank = mod->tonecfg[r]; | 
 | if (bank) { | if (bank) { | 
 | _MFREE(bank); | _MFREE(bank); | 
 | } | } | 
 | } | } | 
| listarray_destroy(hdl->namelist); | listarray_destroy(mod->namelist); | 
| listarray_destroy(hdl->pathtbl); | listarray_destroy(mod->pathtbl); | 
| _MFREE(hdl); | _MFREE(mod); | 
 | } | } | 
 |  |  | 
| VEXTERN void VEXPORT midimod_destroy(MIDIMOD hdl) { | VEXTERN void VEXPORT midimod_destroy(MIDIMOD mod) { | 
 |  |  | 
| if (hdl) { | if (mod) { | 
| midimod_unlock(hdl); | midimod_unlock(mod); | 
 | } | } | 
 | } | } | 
 |  |  | 
| VEXTERN BRESULT VEXPORT midimod_cfgload(MIDIMOD hdl, | VEXTERN BRESULT VEXPORT midimod_cfgload(MIDIMOD mod, | 
 | const OEMCHAR *filename) { | const OEMCHAR *filename) { | 
 |  |  | 
| return(cfgfile_load(hdl, filename, 0)); | return(cfgfile_load(mod, filename, 0)); | 
 | } | } | 
 |  |  | 
| VEXTERN void VEXPORT midimod_loadprogram(MIDIMOD hdl, UINT num) { | VEXTERN void VEXPORT midimod_loadprogram(MIDIMOD mod, UINT num) { | 
 |  |  | 
 | UINT    bank; | UINT    bank; | 
 |  |  | 
| if (hdl != NULL) { | if (mod != NULL) { | 
 | bank = (num >> 8) & 0x7f; | bank = (num >> 8) & 0x7f; | 
 | num &= 0x7f; | num &= 0x7f; | 
| if (inst_singleload(hdl, bank << 1, num) != MIDIOUT_SUCCESS) { | if (inst_singleload(mod, bank << 1, num) != MIDIOUT_SUCCESS) { | 
| inst_singleload(hdl, 0, num); | inst_singleload(mod, 0, num); | 
 | } | } | 
 | } | } | 
 | } | } | 
 |  |  | 
| VEXTERN void VEXPORT midimod_loadrhythm(MIDIMOD hdl, UINT num) { | VEXTERN void VEXPORT midimod_loadrhythm(MIDIMOD mod, UINT num) { | 
 |  |  | 
 | UINT    bank; | UINT    bank; | 
 |  |  | 
| if (hdl != NULL) { | if (mod != NULL) { | 
 | bank = (num >> 8) & 0x7f; | bank = (num >> 8) & 0x7f; | 
 | num &= 0x7f; | num &= 0x7f; | 
| if (inst_singleload(hdl, (bank << 1) + 1, num) != MIDIOUT_SUCCESS) { | if (inst_singleload(mod, (bank << 1) + 1, num) != MIDIOUT_SUCCESS) { | 
| inst_singleload(hdl, 1, num); | inst_singleload(mod, 1, num); | 
 | } | } | 
 | } | } | 
 | } | } | 
 |  |  | 
| VEXTERN void VEXPORT midimod_loadgm(MIDIMOD hdl) { | VEXTERN void VEXPORT midimod_loadgm(MIDIMOD mod) { | 
 |  |  | 
| if (hdl) { | if (mod) { | 
| inst_bankload(hdl, 0); | inst_bankload(mod, 0); | 
| inst_bankload(hdl, 1); | inst_bankload(mod, 1); | 
 | } | } | 
 | } | } | 
 |  |  | 
| VEXTERN void VEXPORT midimod_loadall(MIDIMOD hdl) { | VEXTERN void VEXPORT midimod_loadall(MIDIMOD mod) { | 
 |  |  | 
 | UINT    b; | UINT    b; | 
 |  |  | 
| if (hdl) { | if (mod) { | 
 | for (b=0; b<(MIDI_BANKS*2); b++) { | for (b=0; b<(MIDI_BANKS*2); b++) { | 
| inst_bankload(hdl, b); | inst_bankload(mod, b); | 
 | } | } | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  |  | 
| VEXTERN void VEXPORT midimod_loadallex(MIDIMOD hdl, FNMIDIOUTLAEXCB cb, void *userdata) { | VEXTERN void VEXPORT midimod_loadallex(MIDIMOD mod, FNMIDIOUTLAEXCB cb, | 
|  | void *userdata) { | 
 |  |  | 
 | MIDIOUTLAEXPARAM param; | MIDIOUTLAEXPARAM param; | 
 | UINT    b; | UINT    b; | 
 |  |  | 
| if (hdl) { | if (mod) { | 
 | ZeroMemory(¶m, sizeof(param)); | ZeroMemory(¶m, sizeof(param)); | 
 | param.userdata = userdata; | param.userdata = userdata; | 
 | for (b=0; b<(MIDI_BANKS*2); b++) { | for (b=0; b<(MIDI_BANKS*2); b++) { | 
| param.totaltones += inst_gettones(hdl, b); | param.totaltones += inst_gettones(mod, b); | 
 | } | } | 
 | for (b=0; b<(MIDI_BANKS*2); b++) { | for (b=0; b<(MIDI_BANKS*2); b++) { | 
 | param.bank = b; | param.bank = b; | 
| inst_bankloadex(hdl, b, cb, ¶m); | inst_bankloadex(mod, b, cb, ¶m); | 
 | } | } | 
 | } | } | 
 | } | } |