|
|
| version 1.1, 2004/08/12 17:57:36 | version 1.7, 2005/02/04 06:42:07 |
|---|---|
| Line 108 typedef struct { | Line 108 typedef struct { |
| NP2FHDR f; | NP2FHDR f; |
| } _SFFILEH, *SFFILEH; | } _SFFILEH, *SFFILEH; |
| static SFFILEH statflag_open(const char *filename, char *err, int errlen) { | static SFFILEH statflag_open(const OEMCHAR *filename, |
| OEMCHAR *err, UINT errlen) { | |
| FILEH fh; | FILEH fh; |
| SFFILEH ret; | SFFILEH ret; |
| Line 145 sfo_err1: | Line 146 sfo_err1: |
| static int statflag_closesection(SFFILEH sffh) { | static int statflag_closesection(SFFILEH sffh) { |
| UINT leng; | UINT leng; |
| BYTE zero[16]; | UINT8 zero[16]; |
| if (sffh == NULL) { | if (sffh == NULL) { |
| goto sfcs_err1; | goto sfcs_err1; |
| Line 220 sfr_err: | Line 221 sfr_err: |
| return(STATFLAG_FAILURE); | return(STATFLAG_FAILURE); |
| } | } |
| static SFFILEH statflag_create(const char *filename) { | static SFFILEH statflag_create(const OEMCHAR *filename) { |
| SFFILEH ret; | SFFILEH ret; |
| FILEH fh; | FILEH fh; |
| Line 314 static void statflag_close(SFFILEH sffh) | Line 315 static void statflag_close(SFFILEH sffh) |
| } | } |
| } | } |
| void statflag_seterr(STFLAGH sfh, const char *str) { | void statflag_seterr(STFLAGH sfh, const OEMCHAR *str) { |
| if ((sfh) && (sfh->errlen)) { | if ((sfh) && (sfh->errlen)) { |
| milstr_ncat(sfh->err, str, sfh->errlen); | milstr_ncat(sfh->err, str, sfh->errlen); |
| Line 339 static int flagload_common(STFLAGH sfh, | Line 340 static int flagload_common(STFLAGH sfh, |
| // ---- event | // ---- event |
| typedef struct { | typedef struct { |
| UINT32 next; | |
| SINT32 clock; | SINT32 clock; |
| SINT32 base; | SINT32 baseclock; |
| UINT32 param; | |
| UINT32 proc; | UINT32 proc; |
| } NEVTITEM; | } NEVTITEM; |
| typedef struct { | typedef struct { |
| UINT readys; | NEVTITEM item[NEVENT_MAXEVENTS]; |
| UINT events; | UINT32 first; |
| UINT32 ready[NEVENT_MAXEVENTS]; | |
| UINT32 event[NEVENT_MAXEVENTS]; | |
| } NEVTSAVE; | } NEVTSAVE; |
| static UINT32 evt2id(UINT evt) { | static UINT32 evt2id(NEVENTITEM next) { |
| UINT i; | if (next == NEVENTITEM_NONE) { |
| return((UINT32)-2); | |
| for (i=0; i<sizeof(evtnum)/sizeof(ENUMTBL); i++) { | } |
| if (evtnum[i].evt == evt) { | else if (next == NEVENTITEM_TERM) { |
| return(evtnum[i].id); | return((UINT32)-1); |
| } | } |
| else { | |
| return(next - nevent.item); | |
| } | } |
| return(0); | |
| } | } |
| static int nevent_write(STFLAGH sfh, const _NEVENTITEM *ne) { | static NEVENTITEM id2evt(UINT32 n) { |
| NEVTITEM nit; | |
| nit.clock = ne->clock; | if (n == (UINT32)-2) { |
| nit.base = ne->baseclock; | return(NEVENTITEM_NONE); |
| nit.proc = proc2id((INTPTR)ne->proc, evtproc, NELEMENTS(evtproc)); | } |
| nit.param = ne->param; | else if (n == (UINT32)-1) { |
| return(statflag_write(sfh, &nit, sizeof(nit))); | return(NEVENTITEM_TERM); |
| } | |
| else if (n < NEVENT_MAXEVENTS) { | |
| return(nevent.item + n); | |
| } | |
| else { | |
| // error! | |
| return(NEVENTITEM_TERM); | |
| } | |
| } | } |
| static int flagsave_evt(STFLAGH sfh, const SFENTRY *tbl) { | static int flagsave_evt(STFLAGH sfh, const SFENTRY *tbl) { |
| NEVTSAVE nevt; | NEVTSAVE nevt; |
| UINT i; | UINT i; |
| UINT32 id; | |
| UINT eventid[NEVENT_MAXEVENTS]; | |
| int ret; | |
| ZeroMemory(&nevt, sizeof(nevt)); | |
| for (i=0; i<nevent.readyevents; i++) { | |
| id = evt2id(nevent.level[i]); | |
| if (id) { | |
| nevt.ready[nevt.readys++] = id; | |
| } | |
| } | |
| for (i=0; i<NEVENT_MAXEVENTS; i++) { | for (i=0; i<NEVENT_MAXEVENTS; i++) { |
| id = evt2id(i); | nevt.item[i].next = evt2id(nevent.item[i].next); |
| if (id) { | nevt.item[i].clock = nevent.item[i].clock; |
| eventid[i] = i; | nevt.item[i].baseclock = nevent.item[i].baseclock; |
| nevt.event[nevt.events++] = id; | nevt.item[i].proc = proc2id((INTPTR)nevent.item[i].proc, |
| } | evtproc, NELEMENTS(evtproc)); |
| } | |
| ret = statflag_write(sfh, &nevt, sizeof(nevt)); | |
| for (i=0; i<nevt.events; i++) { | |
| ret |= nevent_write(sfh, nevent.item + eventid[i]); | |
| } | } |
| nevt.first = evt2id(nevent.first); | |
| (void)tbl; | (void)tbl; |
| return(ret); | return(statflag_write(sfh, &nevt, sizeof(nevt))); |
| } | |
| static UINT id2evt(UINT32 id) { | |
| UINT i; | |
| for (i=0; i<sizeof(evtnum)/sizeof(ENUMTBL); i++) { | |
| if (evtnum[i].id == id) { | |
| return(evtnum[i].evt); | |
| } | |
| } | |
| return(NEVENT_MAXEVENTS); | |
| } | |
| static int nevent_read(STFLAGH sfh, UINT32 id) { | |
| int ret; | |
| NEVTITEM nit; | |
| UINT evt; | |
| _NEVENTITEM *ne; | |
| ret = statflag_read(sfh, &nit, sizeof(nit)); | |
| evt = id2evt(id); | |
| if (evt >= NEVENT_MAXEVENTS) { | |
| return(STATFLAG_FAILURE); | |
| } | |
| ne = nevent.item + evt; | |
| ne->clock = nit.clock; | |
| ne->baseclock = nit.base; | |
| ne->proc = (NEVENTCB)id2proc(nit.proc, evtproc, NELEMENTS(evtproc)); | |
| ne->param = nit.param; | |
| return(ret); | |
| } | } |
| static int flagload_evt(STFLAGH sfh, const SFENTRY *tbl) { | static int flagload_evt(STFLAGH sfh, const SFENTRY *tbl) { |
| int ret; | |
| NEVTSAVE nevt; | NEVTSAVE nevt; |
| int ret; | |
| UINT i; | UINT i; |
| UINT evt; | |
| UINT readyevents; | |
| ret = statflag_read(sfh, &nevt, sizeof(nevt)); | ret = statflag_read(sfh, &nevt, sizeof(nevt)); |
| readyevents = 0; | for (i=0; i<NEVENT_MAXEVENTS; i++) { |
| for (i=0; i<nevt.readys; i++) { | nevent.item[i].next = id2evt(nevt.item[i].next); |
| evt = id2evt(nevt.ready[i]); | nevent.item[i].clock = nevt.item[i].clock; |
| if (evt < NEVENT_MAXEVENTS) { | nevent.item[i].baseclock = nevt.item[i].baseclock; |
| nevent.level[readyevents++] = evt; | nevent.item[i].proc = (NEVENTCB)id2proc(nevt.item[i].proc, |
| } | evtproc, NELEMENTS(evtproc)); |
| } | |
| nevent.readyevents = readyevents; | |
| for (i=0; i<nevt.events; i++) { | |
| ret |= nevent_read(sfh, nevt.event[i]); | |
| } | } |
| nevent.first = id2evt(nevt.first); | |
| (void)tbl; | (void)tbl; |
| return(ret); | return(ret); |
| } | } |
| Line 466 static int flagload_evt(STFLAGH sfh, con | Line 422 static int flagload_evt(STFLAGH sfh, con |
| // ---- disk | // ---- disk |
| typedef struct { | typedef struct { |
| OEMCHAR path[MAX_PATH]; | OEMCHAR fname[MAX_PATH]; |
| int readonly; | UINT32 ftype; |
| UINT readonly; | |
| DOSDATE date; | DOSDATE date; |
| DOSTIME time; | DOSTIME time; |
| } STATDISK; | } STATDISK; |
| Line 476 static const OEMCHAR str_fddx[] = OEMTEX | Line 433 static const OEMCHAR str_fddx[] = OEMTEX |
| static const OEMCHAR str_updated[] = OEMTEXT("%s: updated"); | static const OEMCHAR str_updated[] = OEMTEXT("%s: updated"); |
| static const OEMCHAR str_notfound[] = OEMTEXT("%s: not found"); | static const OEMCHAR str_notfound[] = OEMTEXT("%s: not found"); |
| static int disksave(STFLAGH sfh, const OEMCHAR *path, int readonly) { | static int disksave(STFLAGH sfh, const _FDDFILE *fdd) { |
| STATDISK st; | STATDISK st; |
| FILEH fh; | FILEH fh; |
| ZeroMemory(&st, sizeof(st)); | ZeroMemory(&st, sizeof(st)); |
| if ((path) && (path[0])) { | if (fdd->type != DISKTYPE_NOTREADY) { |
| file_cpyname(st.path, path, sizeof(st.path)); | file_cpyname(st.fname, fdd->fname, NELEMENTS(st.fname)); |
| st.readonly = readonly; | st.ftype = fdd->ftype; |
| fh = file_open_rb(path); | st.readonly = fdd->protect; |
| fh = file_open_rb(st.fname); | |
| if (fh != FILEH_INVALID) { | if (fh != FILEH_INVALID) { |
| file_getdatetime(fh, &st.date, &st.time); | file_getdatetime(fh, &st.date, &st.time); |
| file_close(fh); | file_close(fh); |
| Line 500 static int flagsave_disk(STFLAGH sfh, co | Line 458 static int flagsave_disk(STFLAGH sfh, co |
| REG8 i; | REG8 i; |
| ret = STATFLAG_SUCCESS; | ret = STATFLAG_SUCCESS; |
| for (i=0; i<4; i++) { | for (i=0; i<MAX_FDDFILE; i++) { |
| ret |= disksave(sfh, fddfile_diskname(i), fddfile_diskprotect(i)); | ret |= disksave(sfh, fddfile + i); |
| } | } |
| (void)tbl; | (void)tbl; |
| return(ret); | return(ret); |
| Line 517 static int diskcheck(STFLAGH sfh, const | Line 475 static int diskcheck(STFLAGH sfh, const |
| DOSTIME time; | DOSTIME time; |
| ret = statflag_read(sfh, &st, sizeof(st)); | ret = statflag_read(sfh, &st, sizeof(st)); |
| if (st.path[0]) { | if (st.fname[0]) { |
| fh = file_open_rb(st.path); | fh = file_open_rb(st.fname); |
| if (fh != FILEH_INVALID) { | if (fh != FILEH_INVALID) { |
| file_getdatetime(fh, &date, &time); | file_getdatetime(fh, &date, &time); |
| file_close(fh); | file_close(fh); |
| Line 545 static int flagcheck_disk(STFLAGH sfh, c | Line 503 static int flagcheck_disk(STFLAGH sfh, c |
| OEMCHAR buf[8]; | OEMCHAR buf[8]; |
| ret = 0; | ret = 0; |
| for (i=0; i<4; i++) { | for (i=0; i<MAX_FDDFILE; i++) { |
| OEMSPRINTF(buf, str_fddx, i+1); | OEMSPRINTF(buf, str_fddx, i+1); |
| ret |= diskcheck(sfh, buf); | ret |= diskcheck(sfh, buf); |
| } | } |
| Line 560 static int flagload_disk(STFLAGH sfh, co | Line 518 static int flagload_disk(STFLAGH sfh, co |
| STATDISK st; | STATDISK st; |
| ret = STATFLAG_SUCCESS; | ret = STATFLAG_SUCCESS; |
| for (i=0; i<4; i++) { | for (i=0; i<MAX_FDDFILE; i++) { |
| ret |= statflag_read(sfh, &st, sizeof(st)); | ret |= statflag_read(sfh, &st, sizeof(st)); |
| if (st.path[0]) { | if (st.fname[0]) { |
| fddfile_set(i, st.path, FTYPE_NONE, st.readonly); | fddfile_set(i, st.fname, st.ftype, st.readonly); |
| } | } |
| } | } |
| (void)tbl; | (void)tbl; |
| Line 592 static int flagcheck_veronly(STFLAGH sfh | Line 550 static int flagcheck_veronly(STFLAGH sfh |
| // ---- | // ---- |
| int statsave_save(const char *filename) { | int statsave_save(const OEMCHAR *filename) { |
| SFFILEH sffh; | SFFILEH sffh; |
| int ret; | int ret; |
| Line 629 const SFENTRY *tblterm; | Line 587 const SFENTRY *tblterm; |
| return(ret); | return(ret); |
| } | } |
| int statsave_check(const char *filename, char *buf, int size) { | int statsave_check(const OEMCHAR *filename, OEMCHAR *buf, UINT size) { |
| SFFILEH sffh; | SFFILEH sffh; |
| int ret; | int ret; |
| BOOL done; | BRESULT done; |
| const SFENTRY *tbl; | const SFENTRY *tbl; |
| const SFENTRY *tblterm; | const SFENTRY *tblterm; |
| Line 685 const SFENTRY *tblterm; | Line 643 const SFENTRY *tblterm; |
| return(ret); | return(ret); |
| } | } |
| int statsave_load(const char *filename) { | int statsave_load(const OEMCHAR *filename) { |
| SFFILEH sffh; | SFFILEH sffh; |
| int ret; | int ret; |
| BOOL done; | BRESULT done; |
| const SFENTRY *tbl; | const SFENTRY *tbl; |
| const SFENTRY *tblterm; | const SFENTRY *tblterm; |
| Line 759 const SFENTRY *tblterm; | Line 717 const SFENTRY *tblterm; |
| statflag_close(sffh); | statflag_close(sffh); |
| memio_update(); | memio_update(); |
| crtc_bankupdate(); | crtc_update(); |
| crtc_regupdate(); | |
| sndboard_update(); | sndboard_update(); |
| pal_reset(); | pal_reset(); |