| version 1.8, 2006/12/10 11:14:31 | version 1.11, 2006/12/16 22:23:24 | 
| Line 42  static const OEMCHAR file_timiditycfg[] | Line 42  static const OEMCHAR file_timiditycfg[] | 
 | static const OEMCHAR str_basedir[] = OEMTEXT("${basedir}"); | static const OEMCHAR str_basedir[] = OEMTEXT("${basedir}"); | 
 |  |  | 
 |  |  | 
| static void pathadd(MIDIMOD mod, const OEMCHAR *path) { | static void VERMOUTHCL pathadd(MIDIMOD mod, const OEMCHAR *path) { | 
 |  |  | 
 | _PATHLIST       pl; | _PATHLIST       pl; | 
 | PATHLIST        p; | PATHLIST        p; | 
| Line 74  static void pathadd(MIDIMOD mod, const O | Line 74  static void pathadd(MIDIMOD mod, const O | 
 | } | } | 
 | } | } | 
 |  |  | 
| static void pathaddex(MIDIMOD mod, const OEMCHAR *path) { | static void VERMOUTHCL pathaddex(MIDIMOD mod, const OEMCHAR *path) { | 
 |  |  | 
 | OEMCHAR _path[MAX_PATH]; | OEMCHAR _path[MAX_PATH]; | 
 |  |  | 
| Line 89  static void pathaddex(MIDIMOD mod, const | Line 89  static void pathaddex(MIDIMOD mod, const | 
 | } | } | 
 | } | } | 
 |  |  | 
| static int cfggetarg(OEMCHAR *str, OEMCHAR *arg[], int maxarg) { | static int VERMOUTHCL cfggetarg(OEMCHAR *str, OEMCHAR *arg[], int maxarg) { | 
 |  |  | 
 | int             ret; | int             ret; | 
 | BOOL    quot; | BOOL    quot; | 
| Line 141  cga_done: | Line 141  cga_done: | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
| static OEMCHAR *seachr(const OEMCHAR *str, OEMCHAR sepa) { | static OEMCHAR *VERMOUTHCL seachr(const OEMCHAR *str, OEMCHAR sepa) { | 
 |  |  | 
 | OEMCHAR c; | OEMCHAR c; | 
 |  |  | 
| Line 163  enum { | Line 163  enum { | 
 | VAL_SIGN        = 2 | VAL_SIGN        = 2 | 
 | }; | }; | 
 |  |  | 
| static BRESULT cfggetval(const OEMCHAR *str, int *val) { | static BRESULT VERMOUTHCL cfggetval(const OEMCHAR *str, int *val) { | 
 |  |  | 
 | int             ret; | int             ret; | 
 | int             flag; | int             flag; | 
| Line 208  static BRESULT cfggetval(const OEMCHAR * | Line 208  static BRESULT cfggetval(const OEMCHAR * | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static void settone(MIDIMOD mod, int bank, int argc, OEMCHAR *argv[]) { | static void VERMOUTHCL settone(MIDIMOD mod, int bank, int argc, | 
|  | OEMCHAR *argv[]) { | 
 |  |  | 
 | int             val; | int             val; | 
 | TONECFG tone; | TONECFG tone; | 
| Line 332  static void settone(MIDIMOD mod, int ban | Line 333  static void settone(MIDIMOD mod, int ban | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| BRESULT cfgfile_getfile(MIDIMOD mod, const OEMCHAR *filename, | BRESULT VERMOUTHCL midimod_getfile(MIDIMOD mod, const OEMCHAR *filename, | 
 | OEMCHAR *path, int size) { | OEMCHAR *path, int size) { | 
 |  |  | 
 | PATHLIST        p; | PATHLIST        p; | 
| Line 361  fpgf_exit: | Line 362  fpgf_exit: | 
 | return(FAILURE); | return(FAILURE); | 
 | } | } | 
 |  |  | 
| BRESULT cfgfile_load(MIDIMOD mod, const OEMCHAR *filename, int depth) { | static BRESULT VERMOUTHCL cfgfile_load(MIDIMOD mod, const OEMCHAR *filename, | 
|  | int depth) { | 
 |  |  | 
 | TEXTFILEH       tfh; | TEXTFILEH       tfh; | 
 | OEMCHAR         buf[1024]; | OEMCHAR         buf[1024]; | 
| Line 375  BRESULT cfgfile_load(MIDIMOD mod, const | Line 377  BRESULT cfgfile_load(MIDIMOD mod, const | 
 | bank = -1; | bank = -1; | 
 |  |  | 
 | if ((depth >= 16) || | if ((depth >= 16) || | 
| (cfgfile_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)); | 
| Line 459  VEXTERN MIDIMOD VEXPORT midimod_create(U | Line 461  VEXTERN MIDIMOD VEXPORT midimod_create(U | 
 | ret->tone[1] = ret->tone[0] + 128; | ret->tone[1] = ret->tone[0] + 128; | 
 | ret->tonecfg[0] = (TONECFG)(ret->tone[1] + 128); | ret->tonecfg[0] = (TONECFG)(ret->tone[1] + 128); | 
 | ret->tonecfg[1] = ret->tonecfg[0] + 128; | ret->tonecfg[1] = ret->tonecfg[0] + 128; | 
| ret->pathtbl = listarray_new(sizeof(_PATHLIST), 64); | ret->pathtbl = listarray_new(sizeof(_PATHLIST), 16); | 
 | pathadd(ret, NULL); | pathadd(ret, NULL); | 
 | pathadd(ret, file_getcd(str_null)); | pathadd(ret, file_getcd(str_null)); | 
 | ret->namelist = listarray_new(MAX_NAME, 128); | ret->namelist = listarray_new(MAX_NAME, 128); | 
| Line 472  VEXTERN MIDIMOD VEXPORT midimod_create(U | Line 474  VEXTERN MIDIMOD VEXPORT midimod_create(U | 
 | if (r != SUCCESS) { | if (r != SUCCESS) { | 
 | goto mmcre_err2; | goto mmcre_err2; | 
 | } | } | 
 |  | midimod_lock(ret); | 
 | return(ret); | return(ret); | 
 |  |  | 
 | mmcre_err2: | mmcre_err2: | 
| Line 483  mmcre_err1: | Line 486  mmcre_err1: | 
 | return(NULL); | return(NULL); | 
 | } | } | 
 |  |  | 
| VEXTERN void VEXPORT midimod_destroy(MIDIMOD hdl) { | void VERMOUTHCL midimod_lock(MIDIMOD mod) { | 
|  |  | 
|  | mod->lockcount++; | 
|  | } | 
|  |  | 
|  | void VERMOUTHCL midimod_unlock(MIDIMOD mod) { | 
 |  |  | 
 | UINT    r; | UINT    r; | 
 | TONECFG bank; | TONECFG bank; | 
 |  |  | 
| if (hdl) { | if (!mod->lockcount) { | 
| r = 128; | return; | 
| do { | } | 
| r--; | mod->lockcount--; | 
| inst_bankfree(hdl, r); | if (mod->lockcount) { | 
| } while(r > 0); | return; | 
| for (r=2; r<(MIDI_BANKS*2); r++) { | } | 
| bank = hdl->tonecfg[r]; |  | 
| if (bank) { | r = 128; | 
| _MFREE(bank); | do { | 
| } | r--; | 
|  | inst_bankfree(mod, r); | 
|  | } while(r > 0); | 
|  | for (r=2; r<(MIDI_BANKS*2); r++) { | 
|  | bank = mod->tonecfg[r]; | 
|  | if (bank) { | 
|  | _MFREE(bank); | 
 | } | } | 
 | listarray_destroy(hdl->namelist); |  | 
 | listarray_destroy(hdl->pathtbl); |  | 
 | _MFREE(hdl); |  | 
 | } | } | 
 |  | listarray_destroy(mod->namelist); | 
 |  | listarray_destroy(mod->pathtbl); | 
 |  | _MFREE(mod); | 
 |  | } | 
 |  |  | 
 |  | VEXTERN void VEXPORT midimod_destroy(MIDIMOD mod) { | 
 |  |  | 
 |  | if (mod) { | 
 |  | midimod_unlock(mod); | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | VEXTERN BRESULT VEXPORT midimod_cfgload(MIDIMOD mod, | 
 |  | const OEMCHAR *filename) { | 
 |  |  | 
 |  | 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); | 
 | } | } | 
 | } | } | 
 | } | } |