//////////////////////////////////////////////////////////////////////////// // // LoadLIBShape() // int LoadLIBShape(char *SLIB_Filename, char *Filename,struct Shape *SHP) { #define CHUNK(Name) (*ptr == *Name) && \ (*(ptr+1) == *(Name+1)) && \ (*(ptr+2) == *(Name+2)) && \ (*(ptr+3) == *(Name+3)) int RT_CODE; FILE *fp; char CHUNK[5]; char far *ptr; memptr IFFfile = NULL; unsigned long FileLen, size, ChunkLen; int loop; RT_CODE = 1; // Decompress to ram and return ptr to data and return len of data in // passed variable... if (!LoadLIBFile(SLIB_Filename,Filename,&IFFfile)) Quit("Error Loading Compressed lib shape!"); // Evaluate the file // ptr = MK_FP(IFFfile,0); if (!CHUNK("FORM")) goto EXIT_FUNC; ptr += 4; FileLen = *(long far *)ptr; SwapLong((long far *)&FileLen); ptr += 4; if (!CHUNK("ILBM")) goto EXIT_FUNC; ptr += 4; FileLen += 4; while (FileLen) { ChunkLen = *(long far *)(ptr+4); SwapLong((long far *)&ChunkLen); ChunkLen = (ChunkLen+1) & 0xFFFFFFFE; if (CHUNK("BMHD")) { ptr += 8; SHP->bmHdr.w = ((struct BitMapHeader far *)ptr)->w; SHP->bmHdr.h = ((struct BitMapHeader far *)ptr)->h; SHP->bmHdr.x = ((struct BitMapHeader far *)ptr)->x; SHP->bmHdr.y = ((struct BitMapHeader far *)ptr)->y; SHP->bmHdr.d = ((struct BitMapHeader far *)ptr)->d; SHP->bmHdr.trans = ((struct BitMapHeader far *)ptr)->trans; SHP->bmHdr.comp = ((struct BitMapHeader far *)ptr)->comp; SHP->bmHdr.pad = ((struct BitMapHeader far *)ptr)->pad; SwapWord(&SHP->bmHdr.w); SwapWord(&SHP->bmHdr.h); SwapWord(&SHP->bmHdr.x); SwapWord(&SHP->bmHdr.y); ptr += ChunkLen; } else if (CHUNK("BODY")) { ptr += 4; size = *((long far *)ptr); ptr += 4; SwapLong((long far *)&size); SHP->BPR = (SHP->bmHdr.w+7) >> 3; MM_GetPtr(&SHP->Data,size); if (!SHP->Data) goto EXIT_FUNC; movedata(FP_SEG(ptr),FP_OFF(ptr),FP_SEG(SHP->Data),0,size); ptr += ChunkLen; break; } else
//////////////////////////////////////////////////////////////////////////// // // LoadLIBShape() // id0_int_t LoadLIBShape(const id0_char_t *SLIB_Filename, const id0_char_t *Filename,struct Shape *SHP) { #define CHUNK(Name) (*ptr == *Name) && \ (*(ptr+1) == *(Name+1)) && \ (*(ptr+2) == *(Name+2)) && \ (*(ptr+3) == *(Name+3)) id0_int_t RT_CODE; //FILE *fp; //id0_char_t CHUNK[5]; id0_char_t id0_far *ptr; memptr IFFfile = NULL; id0_unsigned_long_t FileLen, size, ChunkLen; //id0_int_t loop; RT_CODE = 1; // Decompress to ram and return ptr to data and return len of data in // passed variable... if (!LoadLIBFile(SLIB_Filename,Filename,&IFFfile)) Quit("Error Loading Compressed lib shape!"); // Evaluate the file // ptr = (id0_char_t *)IFFfile; //ptr = MK_FP(IFFfile,0); if (!CHUNK("FORM")) goto EXIT_FUNC; ptr += 4; memcpy(&FileLen, ptr, sizeof(id0_unsigned_long_t)); FileLen = BE_Cross_Swap32BE(FileLen); //FileLen = *(id0_long_t id0_far *)ptr; //SwapLong((id0_long_t id0_far *)&FileLen); ptr += 4; if (!CHUNK("ILBM")) goto EXIT_FUNC; ptr += 4; FileLen += 4; while (FileLen) { memcpy(&ChunkLen, (ptr+4), sizeof(id0_long_t)); ChunkLen = BE_Cross_Swap32BE(ChunkLen); //ChunkLen = *(id0_long_t id0_far *)(ptr+4); //SwapLong((id0_long_t id0_far *)&ChunkLen); ChunkLen = (ChunkLen+1) & 0xFFFFFFFE; if (CHUNK("BMHD")) { ptr += 8; SHP->bmHdr.w = BE_Cross_Swap16BE(((struct BitMapHeader id0_far *)ptr)->w); SHP->bmHdr.h = BE_Cross_Swap16BE(((struct BitMapHeader id0_far *)ptr)->h); SHP->bmHdr.x = BE_Cross_Swap16BE(((struct BitMapHeader id0_far *)ptr)->x); SHP->bmHdr.y = BE_Cross_Swap16BE(((struct BitMapHeader id0_far *)ptr)->y); #if 0 SHP->bmHdr.w = ((struct BitMapHeader id0_far *)ptr)->w; SHP->bmHdr.h = ((struct BitMapHeader id0_far *)ptr)->h; SHP->bmHdr.x = ((struct BitMapHeader id0_far *)ptr)->x; SHP->bmHdr.y = ((struct BitMapHeader id0_far *)ptr)->y; #endif SHP->bmHdr.d = ((struct BitMapHeader id0_far *)ptr)->d; SHP->bmHdr.trans = ((struct BitMapHeader id0_far *)ptr)->trans; SHP->bmHdr.comp = ((struct BitMapHeader id0_far *)ptr)->comp; SHP->bmHdr.pad = ((struct BitMapHeader id0_far *)ptr)->pad; #if 0 SwapWord(&SHP->bmHdr.w); SwapWord(&SHP->bmHdr.h); SwapWord(&SHP->bmHdr.x); SwapWord(&SHP->bmHdr.y); #endif ptr += ChunkLen; } else if (CHUNK("BODY")) { ptr += 4; memcpy(&size, ptr, sizeof(id0_long_t)); size = BE_Cross_Swap32BE(size); //size = *((id0_long_t id0_far *)ptr); ptr += 4; //SwapLong((id0_long_t id0_far *)&size); SHP->BPR = (SHP->bmHdr.w+7) >> 3; MM_GetPtr(&SHP->Data,size); if (!SHP->Data) goto EXIT_FUNC; //movedata(FP_SEG(ptr),FP_OFF(ptr),FP_SEG(SHP->Data),0,size); memcpy(SHP->Data,ptr,size); ptr += ChunkLen; break; } else