int16_t TXTreadShort(struct TXTFILE * TXT) { static char buffer[9]; TXTread(TXT, buffer, NUMBER); buffer[8] = '\0'; return (int16_t) atoi(buffer); }
/*return FALSE if read End*/ Bool TXTreadTexDef(struct TXTFILE *TXT,char name[8],Int16 *szx,Int16 *szy) { if(TXTok!=TRUE) Bug("TR71", "TxtTxd"); if(TXTskipComment(TXT)==FALSE) return FALSE; /*End*/ if(TXTread(TXT,name,NAME|NUMBER)!=TRUE) ProgError("TR73", "%s(%ld): expecting identifier", fname (TXT->pathname), (long) TXT->Lines); Normalise(name,name); *szx=TXTreadShort(TXT); *szy=TXTreadShort(TXT); return TRUE; }
/*read a patch def. Return FALSE if could not find '*' */ Bool TXTreadPatchDef(struct TXTFILE *TXT,char name[8],Int16 *ofsx,Int16 *ofsy) { if(TXTok!=TRUE) Bug("TR81", "TxtRpd"); if(TXTskipComment(TXT)==FALSE) return FALSE; if(TXTcheckStartPatch(TXT)!=TRUE) return FALSE; /*not a patch line*/ if(TXTread(TXT,name,NAME|NUMBER)!=TRUE) ProgError("TR83", "%s(%ld): expecting identifier", fname (TXT->pathname), (long) TXT->Lines); Normalise(name,name); *ofsx=TXTreadShort(TXT); *ofsy=TXTreadShort(TXT); return TRUE; }
static Bool TXTreadIdent(struct TXTFILE *TXT,char name[8]) { if(TXTok!=TRUE) Bug("TR21", "%s: TxtRid", fname (TXT->pathname)); if(TXTskipComment(TXT)==FALSE) return FALSE; /*check end of section*/ if((TXT->Lines)>(TXT->SectionEnd)) { if(TXTboundSection(TXT)==FALSE) return FALSE; /*no other section*/ } if(TXTread(TXT,name,NAME|NUMBER)!=TRUE) ProgError("TR23", "%s(%ld): expected identifier or \"END:\"", TXT->pathname, (long) TXT->Lines); Normalise(name,name); return TRUE; }
/*return false if read End*/ bool TXTreadTexDef(struct TXTFILE * TXT, char name[8], int16_t * szx, int16_t * szy) { if (!TXTok) Bug("TR71", "TxtTxd"); if (!TXTskipComment(TXT)) return false; /*End */ if (!TXTread(TXT, name, NAME | NUMBER)) ProgError("TR73", "%s(%ld): expecting identifier", fname(TXT->pathname), (long) TXT->Lines); Normalise(name, name); *szx = TXTreadShort(TXT); *szy = TXTreadShort(TXT); return true; }
/*read a patch def. Return false if could not find '*' */ bool TXTreadPatchDef(struct TXTFILE * TXT, char name[8], int16_t * ofsx, int16_t * ofsy) { if (!TXTok) Bug("TR81", "TxtRpd"); if (!TXTskipComment(TXT)) return false; if (!TXTcheckStartPatch(TXT)) return false; /*not a patch line */ if (!TXTread(TXT, name, NAME | NUMBER)) ProgError("TR83", "%s(%ld): expecting identifier", fname(TXT->pathname), (long) TXT->Lines); Normalise(name, name); *ofsx = TXTreadShort(TXT); *ofsy = TXTreadShort(TXT); return true; }
/* ** STEQUAL is used to indicate alternate name */ static void TXTreadOptionalName(struct TXTFILE *TXT,char name[8]) { Int16 c=0,val=0; while(1) { if(TXTgetc(TXT,&c,&val)!=TRUE) return; if(!(val & NEWLINE)) { if(val & STEQUAL) continue; /*skip '='*/ if(val & SPACE) continue; /*skip space*/ if(val & (NAME&(~NUMBER))) break; } TXTungetc(TXT); return; /*name is NOT modified*/ } TXTungetc(TXT); if(TXTread(TXT,name,NAME|NUMBER)!=TRUE) { ProgError("TR32", "%s(%ld): invalid optional name", TXT->pathname, (long) TXT->Lines); } }