The following opens NJ file on GD-ROM and reads texture list and model data.
GDFS fid;
Sint32 sn;
NJS_TEXLIST *tlist;
NJS_OBJECT *obj;
Sint8 *w_buff;
Uint32 rtype, rpos = 0;
/* Open binary file */
fid = gdFsOpen("sample.nj", NULL);
/* Determine the file size of the sector unit and secure the necessary buffer space required to read it */
gdFsGetFileSctSize(fid, &sn);
w_buff = (Sint8 *)syMalloc(sn*2048+8);
/* Read the binary file to the secured buffer and close the file */
gdFsRead(fid, sn, w_buff);
gdFsClose(fid);
/* Output the texture list and objects from the binary data read into the buffer */
tlist = (NJS_TEXLIST *)njReadBinary(w_buff, &rpos, &rtype);
obj = (NJS_OBJECT *)njReadBinary(w_buff, &rpos, &rtype);
:
:
/* Management when binary data is no longer needed */
/* (Release data in reverse order, do not remove the open region of syMalloc.) */
syFree(obj);
syFree(tlist);
syFree(w_buff);