| version 1.1.1.1, 2003/10/16 17:58:43 | version 1.6, 2005/02/09 20:11:35 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 |  | #include        "np2.h" | 
 | #include        "dosio.h" | #include        "dosio.h" | 
 | #include        "extromio.h" | #include        "extromio.h" | 
 |  |  | 
 |  |  | 
| extern  HINSTANCE       hInst; | static const OEMCHAR str_extrom[] = OEMTEXT("EXTROM"); | 
 |  |  | 
 | static const char str_extrom[] = "EXTROM"; |  | 
 |  |  | 
|  | EXTROMH extromio_open(const OEMCHAR *filename, UINT type) { | 
| EXTROMH extromio_open(const char *filename, UINT type) { |  | 
 |  |  | 
 | EXTROMH ret; | EXTROMH ret; | 
 | HRSRC   hrsrc; | HRSRC   hrsrc; | 
 |  | HGLOBAL hg; | 
 |  |  | 
 | ret = (EXTROMH)_MALLOC(sizeof(_EXTROMH), filename); | ret = (EXTROMH)_MALLOC(sizeof(_EXTROMH), filename); | 
 | if (ret == NULL) { | if (ret == NULL) { | 
| Line 27  EXTROMH extromio_open(const char *filena | Line 27  EXTROMH extromio_open(const char *filena | 
 | else if (type == EXTROMIO_RES) { | else if (type == EXTROMIO_RES) { | 
 | hrsrc = FindResource(hInst, filename, str_extrom); | hrsrc = FindResource(hInst, filename, str_extrom); | 
 | if (hrsrc) { | if (hrsrc) { | 
| ret->fh = (void *)LoadResource(hInst, hrsrc); | hg = LoadResource(hInst, hrsrc); | 
|  | ret->fh = (void *)LockResource(hg); | 
 | ret->pos = 0; | ret->pos = 0; | 
 | ret->size = SizeofResource(hInst, hrsrc); | ret->size = SizeofResource(hInst, hrsrc); | 
 | return(ret); | return(ret); | 
| Line 41  erope_err1: | Line 42  erope_err1: | 
 |  |  | 
 | UINT extromio_read(EXTROMH erh, void *buf, UINT size) { | UINT extromio_read(EXTROMH erh, void *buf, UINT size) { | 
 |  |  | 
 | const char      *p; |  | 
 |  |  | 
 | if (erh) { | if (erh) { | 
 | if (erh->type == EXTROMIO_FILE) { | if (erh->type == EXTROMIO_FILE) { | 
 | return(file_read((FILEH)erh->fh, buf, size)); | return(file_read((FILEH)erh->fh, buf, size)); | 
| Line 50  const char *p; | Line 49  const char *p; | 
 | else if (erh->type == EXTROMIO_RES) { | else if (erh->type == EXTROMIO_RES) { | 
 | size = min(size, (UINT)(erh->size - erh->pos)); | size = min(size, (UINT)(erh->size - erh->pos)); | 
 | if (size) { | if (size) { | 
| p = (char *)LockResource((HGLOBAL)erh->fh); | CopyMemory(buf, ((UINT8 *)erh->fh) + erh->pos, size); | 
| CopyMemory(buf, p + erh->pos, size); |  | 
 | erh->pos += size; | erh->pos += size; | 
 | UnlockResource((HGLOBAL)erh->fh); |  | 
 | } | } | 
 | return(size); | return(size); | 
 | } | } | 
| Line 96  void extromio_close(EXTROMH erh) { | Line 93  void extromio_close(EXTROMH erh) { | 
 | if (erh->type == EXTROMIO_FILE) { | if (erh->type == EXTROMIO_FILE) { | 
 | file_close((FILEH)erh->fh); | file_close((FILEH)erh->fh); | 
 | } | } | 
 | else if (erh->type == EXTROMIO_RES) { |  | 
 | FreeResource((HGLOBAL)erh->fh); |  | 
 | } |  | 
 | _MFREE(erh); | _MFREE(erh); | 
 | } | } | 
 | } | } |