|
|
| version 1.17, 2005/03/05 12:19:53 | version 1.20, 2005/04/05 09:12:24 |
|---|---|
| Line 15 | Line 15 |
| // ---- | // ---- |
| static BRESULT nc_reopen(SXSIDEV sxsi) { | |
| (void)sxsi; | |
| return(FAILURE); | |
| } | |
| static REG8 nc_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { | static REG8 nc_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { |
| (void)sxsi; | (void)sxsi; |
| Line 40 static REG8 nc_format(SXSIDEV sxsi, long | Line 46 static REG8 nc_format(SXSIDEV sxsi, long |
| return(0x60); | return(0x60); |
| } | } |
| static void sxsi_disconnect(SXSIDEV sxsi) { | static void nc_close(SXSIDEV sxsi) { |
| FILEH fh; | (void)sxsi; |
| } | |
| static void nc_destroy(SXSIDEV sxsi) { | |
| (void)sxsi; | |
| } | |
| static void sxsi_disconnect(SXSIDEV sxsi) { | |
| if (sxsi) { | if (sxsi) { |
| #if defined(SUPPORT_IDEIO) | #if defined(SUPPORT_IDEIO) |
| ideio_notify(sxsi->drv, 0); | ideio_notify(sxsi->drv, 0); |
| #endif | #endif |
| fh = (FILEH)sxsi->fh; | if (sxsi->flag & SXSIFLAG_FILEOPENED) { |
| (*sxsi->close)(sxsi); | |
| } | |
| if (sxsi->flag & SXSIFLAG_READY) { | |
| (*sxsi->destroy)(sxsi); | |
| } | |
| sxsi->flag = 0; | sxsi->flag = 0; |
| sxsi->fh = (INTPTR)FILEH_INVALID; | sxsi->reopen = nc_reopen; |
| sxsi->read = nc_read; | sxsi->read = nc_read; |
| sxsi->write = nc_write; | sxsi->write = nc_write; |
| sxsi->format = nc_format; | sxsi->format = nc_format; |
| if (fh != FILEH_INVALID) { | sxsi->close = nc_close; |
| file_close(fh); | sxsi->destroy = nc_destroy; |
| } | |
| } | } |
| } | } |
| Line 77 void sxsi_initialize(void) { | Line 96 void sxsi_initialize(void) { |
| } | } |
| #endif | #endif |
| for (i=0; i<NELEMENTS(sxsi_dev); i++) { | for (i=0; i<NELEMENTS(sxsi_dev); i++) { |
| sxsi_dev[i].fh = (INTPTR)FILEH_INVALID; | |
| sxsi_disconnect(sxsi_dev + i); | sxsi_disconnect(sxsi_dev + i); |
| } | } |
| } | } |
| Line 86 void sxsi_allflash(void) { | Line 104 void sxsi_allflash(void) { |
| SXSIDEV sxsi; | SXSIDEV sxsi; |
| SXSIDEV sxsiterm; | SXSIDEV sxsiterm; |
| FILEH fh; | |
| sxsi = sxsi_dev; | sxsi = sxsi_dev; |
| sxsiterm = sxsi + NELEMENTS(sxsi_dev); | sxsiterm = sxsi + NELEMENTS(sxsi_dev); |
| while(sxsi < sxsiterm) { | while(sxsi < sxsiterm) { |
| fh = (FILEH)sxsi->fh; | if (sxsi->flag & SXSIFLAG_FILEOPENED) { |
| sxsi->fh = (INTPTR)FILEH_INVALID; | sxsi->flag &= ~SXSIFLAG_FILEOPENED; |
| if (fh != FILEH_INVALID) { | (*sxsi->close)(sxsi); |
| file_close(fh); | |
| } | } |
| sxsi++; | sxsi++; |
| } | } |
| Line 132 BOOL sxsi_isconnect(SXSIDEV sxsi) { | Line 148 BOOL sxsi_isconnect(SXSIDEV sxsi) { |
| BRESULT sxsi_prepare(SXSIDEV sxsi) { | BRESULT sxsi_prepare(SXSIDEV sxsi) { |
| FILEH fh; | |
| if ((sxsi == NULL) || (!(sxsi->flag & SXSIFLAG_READY))) { | if ((sxsi == NULL) || (!(sxsi->flag & SXSIFLAG_READY))) { |
| return(FAILURE); | return(FAILURE); |
| } | } |
| fh = (FILEH)sxsi->fh; | if (!(sxsi->flag & SXSIFLAG_FILEOPENED)) { |
| if (fh == FILEH_INVALID) { | if ((*sxsi->reopen)(sxsi) == SUCCESS) { |
| fh = file_open(sxsi->filename); | sxsi->flag |= SXSIFLAG_FILEOPENED; |
| sxsi->fh = (INTPTR)fh; | } |
| if (fh == FILEH_INVALID) { | else { |
| sxsi->flag = 0; | |
| return(FAILURE); | return(FAILURE); |
| } | } |
| } | } |
| Line 173 SXSIDEV sxsi_getptr(REG8 drv) { | Line 186 SXSIDEV sxsi_getptr(REG8 drv) { |
| return(NULL); | return(NULL); |
| } | } |
| const OEMCHAR *sxsi_getfilename(REG8 drv) { | OEMCHAR *sxsi_getfilename(REG8 drv) { |
| SXSIDEV sxsi; | SXSIDEV sxsi; |
| sxsi = sxsi_getptr(drv); | sxsi = sxsi_getptr(drv); |
| if ((sxsi) && (sxsi->flag & SXSIFLAG_READY)) { | if ((sxsi) && (sxsi->flag & SXSIFLAG_READY)) { |
| return(sxsi->filename); | return(sxsi->fname); |
| } | } |
| return(NULL); | return(NULL); |
| } | } |
| Line 201 BRESULT sxsi_setdevtype(REG8 drv, UINT8 | Line 214 BRESULT sxsi_setdevtype(REG8 drv, UINT8 |
| } | } |
| } | } |
| BRESULT sxsi_devopen(REG8 drv, const OEMCHAR *file) { | UINT8 sxsi_getdevtype(REG8 drv) { |
| SXSIDEV sxsi; | |
| sxsi = sxsi_getptr(drv); | |
| if (sxsi) { | |
| return(sxsi->devtype); | |
| } | |
| else { | |
| return(SXSIDEV_NC); | |
| } | |
| } | |
| BRESULT sxsi_devopen(REG8 drv, const OEMCHAR *fname) { | |
| SXSIDEV sxsi; | SXSIDEV sxsi; |
| BRESULT r; | BRESULT r; |
| if ((file == NULL) || (file[0] == '\0')) { | if ((fname == NULL) || (fname[0] == '\0')) { |
| goto sxsiope_err; | goto sxsiope_err; |
| } | } |
| sxsi = sxsi_getptr(drv); | sxsi = sxsi_getptr(drv); |
| Line 215 BRESULT sxsi_devopen(REG8 drv, const OEM | Line 241 BRESULT sxsi_devopen(REG8 drv, const OEM |
| } | } |
| switch(sxsi->devtype) { | switch(sxsi->devtype) { |
| case SXSIDEV_HDD: | case SXSIDEV_HDD: |
| r = sxsihdd_open(sxsi, file); | r = sxsihdd_open(sxsi, fname); |
| break; | break; |
| case SXSIDEV_CDROM: | case SXSIDEV_CDROM: |
| r = sxsicd_open(sxsi, file); | r = sxsicd_open(sxsi, fname); |
| break; | break; |
| default: | default: |
| Line 229 BRESULT sxsi_devopen(REG8 drv, const OEM | Line 255 BRESULT sxsi_devopen(REG8 drv, const OEM |
| if (r != SUCCESS) { | if (r != SUCCESS) { |
| goto sxsiope_err; | goto sxsiope_err; |
| } | } |
| file_cpyname(sxsi->filename, file, NELEMENTS(sxsi->filename)); | file_cpyname(sxsi->fname, fname, NELEMENTS(sxsi->fname)); |
| sxsi->flag = SXSIFLAG_READY; | sxsi->flag = SXSIFLAG_READY | SXSIFLAG_FILEOPENED; |
| #if defined(SUPPORT_IDEIO) | #if defined(SUPPORT_IDEIO) |
| ideio_notify(sxsi->drv, 1); | ideio_notify(sxsi->drv, 1); |
| #endif | #endif |
| Line 258 BOOL sxsi_issasi(void) { | Line 284 BOOL sxsi_issasi(void) { |
| for (drv=0x00; drv<0x04; drv++) { | for (drv=0x00; drv<0x04; drv++) { |
| sxsi = sxsi_getptr(drv); | sxsi = sxsi_getptr(drv); |
| if (sxsi) { | if (sxsi) { |
| if (sxsi->devtype == SXSIDEV_HDD) { | if ((drv < 0x02) && (sxsi->devtype == SXSIDEV_HDD)) { |
| if (sxsi->flag & SXSIFLAG_READY) { | if (sxsi->flag & SXSIFLAG_READY) { |
| if (sxsi->mediatype & SXSIMEDIA_INVSASI) { | if (sxsi->mediatype & SXSIMEDIA_INVSASI) { |
| return(FALSE); | return(FALSE); |