1 /* $Id: segment.c,v 1.4 2005-06-22 09:08:21 chris Exp $ */
5 * Segment Loading Stuff
18 static char rcsid[] = "$Id: segment.c,v 1.4 2005-06-22 09:08:21 chris Exp $";
23 * reads a segment2 structure from a CFILE
25 void segment2_read(segment2 *s2, CFILE *fp)
27 s2->special = cfile_read_byte(fp);
28 s2->matcen_num = cfile_read_byte(fp);
29 s2->value = cfile_read_byte(fp);
30 s2->s2_flags = cfile_read_byte(fp);
31 s2->static_light = cfile_read_fix(fp);
35 * reads a delta_light structure from a CFILE
37 void delta_light_read(delta_light *dl, CFILE *fp)
39 dl->segnum = cfile_read_short(fp);
40 dl->sidenum = cfile_read_byte(fp);
41 dl->dummy = cfile_read_byte(fp);
42 dl->vert_light[0] = cfile_read_byte(fp);
43 dl->vert_light[1] = cfile_read_byte(fp);
44 dl->vert_light[2] = cfile_read_byte(fp);
45 dl->vert_light[3] = cfile_read_byte(fp);
50 * reads a dl_index structure from a CFILE
52 void dl_index_read(dl_index *di, CFILE *fp)
54 di->segnum = cfile_read_short(fp);
55 di->sidenum = cfile_read_byte(fp);
56 di->count = cfile_read_byte(fp);
57 di->index = cfile_read_short(fp);
61 void segment2_write(segment2 *s2, PHYSFS_file *fp)
63 PHYSFSX_writeU8(fp, s2->special);
64 PHYSFSX_writeU8(fp, s2->matcen_num);
65 PHYSFSX_writeU8(fp, s2->value);
66 PHYSFSX_writeU8(fp, s2->s2_flags);
67 PHYSFSX_writeFix(fp, s2->static_light);
70 void delta_light_write(delta_light *dl, PHYSFS_file *fp)
72 PHYSFS_writeSLE16(fp, dl->segnum);
73 PHYSFSX_writeU8(fp, dl->sidenum);
74 PHYSFSX_writeU8(fp, dl->dummy);
75 PHYSFSX_writeU8(fp, dl->vert_light[0]);
76 PHYSFSX_writeU8(fp, dl->vert_light[1]);
77 PHYSFSX_writeU8(fp, dl->vert_light[2]);
78 PHYSFSX_writeU8(fp, dl->vert_light[3]);
81 void dl_index_write(dl_index *di, PHYSFS_file *fp)
83 PHYSFS_writeSLE16(fp, di->segnum);
84 PHYSFSX_writeU8(fp, di->sidenum);
85 PHYSFSX_writeU8(fp, di->count);
86 PHYSFS_writeSLE16(fp, di->index);