##### Ninja Library - Binary Function

# njReadBinary

Reads data from binary file

### FORMAT

`

  void *njReadBinary( *wbuff, *fpos, *ptype )
  Sint8 *wbuff
  Uint32 *fpos
  Uint32 *ptype

`

### PARAMETER

  `*wbuff` | Pointer to buffer that has read binary files such as NJ, NJM, etc.
  `*fpos` | Number of bytes for file read start
  `*ptype` | Returns type of data that have been read

### RETURN

  NULL | Data type is unknown |
  besides NULL | Pointer to read data |

### DESCRIPTION

  Returns the pointer after retrieving texture list and model data from NJ, NJM and other data read from the GD-ROM via the buffer. The data output source is the buffer secured internally. The syFree function is used to release the buffer.

### EXAMPLE

      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);

### NOTE

  The value of parameter fpos is updated to the next read start position after data have been read. Parameter ptype is returned as '****' if data type is unknown. Currently defined data types are listed below. (Defined by NiDef.h) #define iff_NJINFO 'NJIN' /* data infomation */ #define iff_NJCM 'NJCM' /* ninja chunk model tree */ #define iff_NJBM 'NJBM' /* ninja basic model tree */ #define iff_NJTL 'NJTL' /* ninja texlist */ #define iff_NJLI 'NJLI' /* ninja light */ #define iff_NJCA 'NJCA' /* ninja camera */ #define iff_NMDM 'NMDM' /* ninja model motion */ #define iff_NLIM 'NLIM' /* ninja light motion */ #define iff_NCAM 'NCAM' /* ninja camera motion */ #define iff_NSSM 'NSSM' /* ninja simple shape motion */

### REFERENCE

  `njOpenBinary()
  njCloseBinary()
  `

njReadBinary

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999