|
|
| version 1.1, 2003/11/28 08:01:32 | version 1.15, 2005/02/11 21:17:22 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "strres.h" | #include "strres.h" |
| #include "codecnv.h" | |
| #include "dosio.h" | #include "dosio.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "pccore.h" | #include "pccore.h" |
| Line 20 enum { | Line 19 enum { |
| DID_FILTER | DID_FILTER |
| }; | }; |
| static const BYTE str_dirname[] = { // ファイルの場所 | #if !defined(RESOURCE_US) && (!defined(CHARSET_OEM) || defined(OSLANG_SJIS)) |
| 0xcc,0xa7,0xb2,0xd9,0x82,0xcc,0x8f,0xea,0x8f,0x8a,0}; | static const OEMCHAR str_dirname[] = // ファイルの場所 |
| static const BYTE str_filename[] = { // ファイル名 | "\203\164\203\100\203\103\203\213\202\314\217\352\217\212"; |
| 0xcc,0xa7,0xb2,0xd9,0x96,0xbc,0}; | static const OEMCHAR str_filename[] = // ファイル名 |
| static const BYTE str_filetype[] = { // ファイルの種類 | "\203\164\203\100\203\103\203\213\226\274"; |
| 0xcc,0xa7,0xb2,0xd9,0x82,0xcc,0x8e,0xed,0x97,0xde,0}; | static const OEMCHAR str_filetype[] = // ファイルの種類 |
| static const BYTE str_open[] = { // 開く | "\203\164\203\100\203\103\203\213\202\314\216\355\227\336"; |
| 0x8a,0x4a,0x82,0xad,0}; | static const OEMCHAR str_open[] = // 開く |
| "\212\112\202\255"; | |
| #elif defined(OSLANG_EUC) && !defined(RESOURCE_US) | |
| static const OEMCHAR str_dirname[] = // ファイルの場所 | |
| "\245\325\245\241\245\244\245\353\244\316\276\354\275\352"; | |
| static const OEMCHAR str_filename[] = // ファイル名 | |
| "\245\325\245\241\245\244\245\353\314\276"; | |
| static const OEMCHAR str_filetype[] = // ファイルの種類 | |
| "\245\325\245\241\245\244\245\353\244\316\274\357\316\340"; | |
| static const OEMCHAR str_open[] = // 開く | |
| "\263\253\244\257"; | |
| #elif defined(OSLANG_UTF8) && !defined(RESOURCE_US) | |
| static const OEMCHAR str_dirname[] = // ファイルの場所 | |
| "\343\203\225\343\202\241\343\202\244\343\203\253\343\201\256" \ | |
| "\345\240\264\346\211\200"; | |
| static const OEMCHAR str_filename[] = // ファイル名 | |
| "\343\203\225\343\202\241\343\202\244\343\203\253\345\220\215"; | |
| static const OEMCHAR str_filetype[] = // ファイルの種類 | |
| "\343\203\225\343\202\241\343\202\244\343\203\253\343\201\256" \ | |
| "\347\250\256\351\241\236"; | |
| static const OEMCHAR str_open[] = // 開く | |
| "\351\226\213\343\201\217"; | |
| #else | |
| static const OEMCHAR str_dirname[] = OEMTEXT("Look in"); | |
| static const OEMCHAR str_filename[] = OEMTEXT("File name"); | |
| static const OEMCHAR str_filetype[] = OEMTEXT("Files of type"); | |
| static const OEMCHAR str_open[] = OEMTEXT("Open"); | |
| #endif | |
| #if defined(SIZE_QVGA) | #if defined(SIZE_QVGA) |
| enum { | enum { |
| Line 91 typedef struct _flist *FLIST; | Line 116 typedef struct _flist *FLIST; |
| struct _flist { | struct _flist { |
| FLIST next; | FLIST next; |
| UINT isdir; | UINT isdir; |
| char name[MAX_PATH]; | OEMCHAR name[MAX_PATH]; |
| }; | }; |
| typedef struct { | typedef struct { |
| const char *title; | const OEMCHAR *title; |
| const char *filter; | const OEMCHAR *filter; |
| const char *ext; | const OEMCHAR *ext; |
| } FSELPRM; | } FSELPRM; |
| typedef struct { | typedef struct { |
| BOOL result; | BOOL result; |
| LISTARRAY flist; | LISTARRAY flist; |
| FLIST fbase; | FLIST fbase; |
| const char *filter; | const OEMCHAR *filter; |
| const char *ext; | const OEMCHAR *ext; |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| } FILESEL; | } FILESEL; |
| static FILESEL filesel; | static FILESEL filesel; |
| Line 129 static FLIST getflist(int pos) { | Line 154 static FLIST getflist(int pos) { |
| return(ret); | return(ret); |
| } | } |
| static BOOL fappend(LISTARRAY flist, FILEFINDT *fft) { | static BRESULT fappend(LISTARRAY flist, FLINFO *fli) { |
| FLIST fl; | FLIST fl; |
| FLIST *st; | FLIST *st; |
| Line 139 static BOOL fappend(LISTARRAY flist, FIL | Line 164 static BOOL fappend(LISTARRAY flist, FIL |
| if (fl == NULL) { | if (fl == NULL) { |
| return(FAILURE); | return(FAILURE); |
| } | } |
| fl->isdir = (fft->attr & 0x10)?1:0; | fl->isdir = (fli->attr & 0x10)?1:0; |
| file_cpyname(fl->name, fft->path, sizeof(fl->name)); | file_cpyname(fl->name, fli->path, NELEMENTS(fl->name)); |
| st = &filesel.fbase; | st = &filesel.fbase; |
| while(1) { | while(1) { |
| cur = *st; | cur = *st; |
| Line 161 static BOOL fappend(LISTARRAY flist, FIL | Line 186 static BOOL fappend(LISTARRAY flist, FIL |
| return(SUCCESS); | return(SUCCESS); |
| } | } |
| static BOOL checkext(char *path, const char *ext) { | static BOOL checkext(OEMCHAR *path, const OEMCHAR *ext) { |
| const char *p; | const OEMCHAR *p; |
| if (ext == NULL) { | if (ext == NULL) { |
| return(TRUE); | return(TRUE); |
| Line 173 const char *p; | Line 198 const char *p; |
| if (!file_cmpname(p, ext)) { | if (!file_cmpname(p, ext)) { |
| return(TRUE); | return(TRUE); |
| } | } |
| ext += strlen(ext) + 1; | ext += OEMSTRLEN(ext) + 1; |
| } | } |
| return(FALSE); | return(FALSE); |
| } | } |
| Line 181 const char *p; | Line 206 const char *p; |
| static void dlgsetlist(void) { | static void dlgsetlist(void) { |
| LISTARRAY flist; | LISTARRAY flist; |
| FILEFINDH ffh; | FLISTH flh; |
| FILEFINDT fft; | FLINFO fli; |
| BOOL append; | BOOL append; |
| FLIST fl; | FLIST fl; |
| ITEMEXPRM prm; | ITEMEXPRM prm; |
| #if defined(OSLANG_EUC) | |
| char sjis[MAX_PATH]; | |
| #endif | |
| menudlg_itemreset(DID_FLIST); | menudlg_itemreset(DID_FLIST); |
| #if defined(OSLANG_EUC) | |
| codecnv_euc2sjis(sjis, sizeof(sjis), | |
| file_getname(filesel.path), (UINT)-1); | |
| menudlg_settext(DID_FOLDER, sjis); | |
| #else | |
| menudlg_settext(DID_FOLDER, file_getname(filesel.path)); | menudlg_settext(DID_FOLDER, file_getname(filesel.path)); |
| #endif | |
| listarray_destroy(filesel.flist); | listarray_destroy(filesel.flist); |
| flist = listarray_new(sizeof(_FLIST), 64); | flist = listarray_new(sizeof(_FLIST), 64); |
| filesel.flist = flist; | filesel.flist = flist; |
| filesel.fbase = NULL; | filesel.fbase = NULL; |
| ffh = file_find1st(filesel.path, &fft); | flh = file_list1st(filesel.path, &fli); |
| if (ffh != FILEFINDH_INVALID) { | if (flh != FLISTH_INVALID) { |
| do { | do { |
| append = FALSE; | append = FALSE; |
| if (fft.attr & 0x10) { | if (fli.attr & 0x10) { |
| #if defined(WIN32) && !defined(_WIN32_WCE) | |
| if ((file_cmpname(fft.path, ".")) && | |
| (file_cmpname(fft.path, ".."))) { | |
| append = TRUE; | |
| } | |
| #else | |
| append = TRUE; | append = TRUE; |
| #endif | |
| } | } |
| else if (!(fft.attr & 0x08)) { | else if (!(fli.attr & 0x08)) { |
| append = checkext(fft.path, filesel.ext); | append = checkext(fli.path, filesel.ext); |
| } | } |
| if (append) { | if (append) { |
| if (fappend(flist, &fft) != SUCCESS) { | if (fappend(flist, &fli) != SUCCESS) { |
| break; | break; |
| } | } |
| } | } |
| } while(file_findnext(ffh, &fft) == SUCCESS); | } while(file_listnext(flh, &fli) == SUCCESS); |
| file_findclose(ffh); | file_listclose(flh); |
| } | } |
| prm.pos = 0; | prm.pos = 0; |
| fl = filesel.fbase; | fl = filesel.fbase; |
| while(fl) { | while(fl) { |
| menudlg_itemappend(DID_FLIST, NULL); | menudlg_itemappend(DID_FLIST, NULL); |
| prm.icon = (fl->isdir)?MICON_FOLDER:MICON_FILE; | prm.icon = (fl->isdir)?MICON_FOLDER:MICON_FILE; |
| #if defined(OSLANG_EUC) | |
| codecnv_euc2sjis(sjis, sizeof(sjis), fl->name, (UINT)-1); | |
| prm.str = sjis; | |
| #else | |
| prm.str = fl->name; | prm.str = fl->name; |
| #endif | |
| menudlg_itemsetex(DID_FLIST, &prm); | menudlg_itemsetex(DID_FLIST, &prm); |
| fl = fl->next; | fl = fl->next; |
| prm.pos++; | prm.pos++; |
| Line 247 static void dlgsetlist(void) { | Line 250 static void dlgsetlist(void) { |
| static void dlginit(void) { | static void dlginit(void) { |
| #if defined(OSLANG_EUC) | menudlg_appends(res_fs, NELEMENTS(res_fs)); |
| char sjis[MAX_PATH]; | |
| #endif | |
| menudlg_appends(res_fs, sizeof(res_fs)/sizeof(MENUPRM)); | |
| menudlg_seticon(DID_PARENT, MICON_FOLDERPARENT); | menudlg_seticon(DID_PARENT, MICON_FOLDERPARENT); |
| #if defined(OSLANG_EUC) | |
| codecnv_euc2sjis(sjis, sizeof(sjis), | |
| file_getname(filesel.path), (UINT)-1); | |
| menudlg_settext(DID_FILE, sjis); | |
| #else | |
| menudlg_settext(DID_FILE, file_getname(filesel.path)); | menudlg_settext(DID_FILE, file_getname(filesel.path)); |
| #endif | |
| menudlg_settext(DID_FILTER, filesel.filter); | menudlg_settext(DID_FILTER, filesel.filter); |
| file_cutname(filesel.path); | file_cutname(filesel.path); |
| file_cutseparator(filesel.path); | file_cutseparator(filesel.path); |
| Line 274 static BOOL dlgupdate(void) { | Line 267 static BOOL dlgupdate(void) { |
| if (fl == NULL) { | if (fl == NULL) { |
| return(FALSE); | return(FALSE); |
| } | } |
| file_setseparator(filesel.path, sizeof(filesel.path)); | file_setseparator(filesel.path, NELEMENTS(filesel.path)); |
| file_catname(filesel.path, fl->name, sizeof(filesel.path)); | file_catname(filesel.path, fl->name, NELEMENTS(filesel.path)); |
| if (fl->isdir) { | if (fl->isdir) { |
| dlgsetlist(); | dlgsetlist(); |
| menudlg_settext(DID_FILE, NULL); | menudlg_settext(DID_FILE, NULL); |
| Line 290 static BOOL dlgupdate(void) { | Line 283 static BOOL dlgupdate(void) { |
| static void dlgflist(void) { | static void dlgflist(void) { |
| FLIST fl; | FLIST fl; |
| #if defined(OSLANG_EUC) | |
| char sjis[MAX_PATH]; | |
| #endif | |
| fl = getflist(menudlg_getval(DID_FLIST)); | fl = getflist(menudlg_getval(DID_FLIST)); |
| if ((fl != NULL) && (!fl->isdir)) { | if ((fl != NULL) && (!fl->isdir)) { |
| #if defined(OSLANG_EUC) | |
| codecnv_euc2sjis(sjis, sizeof(sjis), fl->name, (UINT)-1); | |
| menudlg_settext(DID_FILE, sjis); | |
| #else | |
| menudlg_settext(DID_FILE, fl->name); | menudlg_settext(DID_FILE, fl->name); |
| #endif | |
| } | } |
| } | } |
| Line 332 static int dlgcmd(int msg, MENUID id, lo | Line 317 static int dlgcmd(int msg, MENUID id, lo |
| break; | break; |
| case DID_FLIST: | case DID_FLIST: |
| dlgflist(); | if (param) { |
| return(dlgcmd(DLGMSG_COMMAND, DID_OK, 0)); | |
| } | |
| else { | |
| dlgflist(); | |
| } | |
| break; | break; |
| } | } |
| break; | break; |
| Line 350 static int dlgcmd(int msg, MENUID id, lo | Line 340 static int dlgcmd(int msg, MENUID id, lo |
| return(0); | return(0); |
| } | } |
| static BOOL selectfile(const FSELPRM *prm, char *path, int size, | static BOOL selectfile(const FSELPRM *prm, OEMCHAR *path, int size, |
| const char *def) { | const OEMCHAR *def) { |
| const char *title; | const OEMCHAR *title; |
| soundmng_stop(); | soundmng_stop(); |
| ZeroMemory(&filesel, sizeof(filesel)); | ZeroMemory(&filesel, sizeof(filesel)); |
| if ((def) && (def[0])) { | if ((def) && (def[0])) { |
| file_cpyname(filesel.path, def, sizeof(filesel.path)); | file_cpyname(filesel.path, def, NELEMENTS(filesel.path)); |
| } | } |
| else { | else { |
| file_cpyname(filesel.path, file_getcd(str_null), | file_cpyname(filesel.path, file_getcd(str_null), |
| sizeof(filesel.path)); | NELEMENTS(filesel.path)); |
| file_cutname(filesel.path); | file_cutname(filesel.path); |
| } | } |
| title = NULL; | title = NULL; |
| Line 386 const char *title; | Line 376 const char *title; |
| // ---- | // ---- |
| static const char diskfilter[] = "All supported Files"; | static const OEMCHAR diskfilter[] = OEMTEXT("All supported files"); |
| static const char fddtitle[] = "Select floppy image"; | static const OEMCHAR fddtitle[] = OEMTEXT("Select floppy image"); |
| static const char fddext[] = "d88\088d\0d98\098d\0xdf\0hdm\0dup\02hd\0tfd\0"; | static const OEMCHAR fddext[] = OEMTEXT("d88\00088d\0d98\00098d\0fdi\0xdf\0hdm\0dup\0002hd\0tfd\0"); |
| static const char hddtitle[] = "Select HDD image"; | static const OEMCHAR hddtitle[] = OEMTEXT("Select HDD image"); |
| static const char hddext[] = "thd\0hdi\0"; | static const OEMCHAR sasiext[] = OEMTEXT("thd\0nhd\0hdi\0"); |
| static const FSELPRM fddprm = {fddtitle, diskfilter, fddext}; | static const FSELPRM fddprm = {fddtitle, diskfilter, fddext}; |
| static const FSELPRM hddprm = {hddtitle, diskfilter, hddext}; | static const FSELPRM sasiprm = {hddtitle, diskfilter, sasiext}; |
| #if defined(SUPPORT_SCSI) | |
| static const OEMCHAR scsiext[] = OEMTEXT("hdd\0"); | |
| static const FSELPRM scsiprm = {hddtitle, diskfilter, scsiext}; | |
| #endif | |
| void filesel_fdd(BYTE drv) { | void filesel_fdd(REG8 drv) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| if (drv < 4) { | if (drv < 4) { |
| if (selectfile(&fddprm, path, sizeof(path), fdd_diskname(drv))) { | if (selectfile(&fddprm, path, NELEMENTS(path), fdd_diskname(drv))) { |
| diskdrv_setfdd(drv, path, 0); | diskdrv_setfdd(drv, path, 0); |
| } | } |
| } | } |
| } | } |
| void filesel_sasi(BYTE drv) { | void filesel_hdd(REG8 drv) { |
| char path[MAX_PATH]; | UINT num; |
| OEMCHAR *p; | |
| if (drv < 2) { | const FSELPRM *prm; |
| if (selectfile(&hddprm, path, sizeof(path), np2cfg.hddfile[drv])) { | OEMCHAR path[MAX_PATH]; |
| diskdrv_sethdd(drv, path); | |
| num = drv & 0x0f; | |
| p = NULL; | |
| prm = NULL; | |
| if (!(drv & 0x20)) { // SASI/IDE | |
| if (num < 2) { | |
| p = np2cfg.sasihdd[num]; | |
| prm = &sasiprm; | |
| } | } |
| } | } |
| #if defined(SUPPORT_SCSI) | |
| else { // SCSI | |
| if (num < 4) { | |
| p = np2cfg.scsihdd[num]; | |
| prm = &scsiprm; | |
| } | |
| } | |
| #endif | |
| if ((prm) && (selectfile(prm, path, NELEMENTS(path), p))) { | |
| diskdrv_sethdd(drv, path); | |
| } | |
| } | } |