]> icculus.org git repositories - btb/d2x.git/blob - main/segment.c
add ui_checkbox_check
[btb/d2x.git] / main / segment.c
1 /* $Id: segment.c,v 1.4 2005-06-22 09:08:21 chris Exp $ */
2
3 /*
4  *
5  * Segment Loading Stuff
6  *
7  */
8
9
10 #ifdef HAVE_CONFIG_H
11 #include <conf.h>
12 #endif
13
14 #include "segment.h"
15 #include "cfile.h"
16
17 #ifdef RCS
18 static char rcsid[] = "$Id: segment.c,v 1.4 2005-06-22 09:08:21 chris Exp $";
19 #endif
20
21 #ifndef FAST_FILE_IO
22 /*
23  * reads a segment2 structure from a CFILE
24  */
25 void segment2_read(segment2 *s2, CFILE *fp)
26 {
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);
32 }
33
34 /*
35  * reads a delta_light structure from a CFILE
36  */
37 void delta_light_read(delta_light *dl, CFILE *fp)
38 {
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);
46 }
47
48
49 /*
50  * reads a dl_index structure from a CFILE
51  */
52 void dl_index_read(dl_index *di, CFILE *fp)
53 {
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);
58 }
59 #endif
60
61 void segment2_write(segment2 *s2, PHYSFS_file *fp)
62 {
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);
68 }
69
70 void delta_light_write(delta_light *dl, PHYSFS_file *fp)
71 {
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]);
79 }
80
81 void dl_index_write(dl_index *di, PHYSFS_file *fp)
82 {
83         PHYSFS_writeSLE16(fp, di->segnum);
84         PHYSFSX_writeU8(fp, di->sidenum);
85         PHYSFSX_writeU8(fp, di->count);
86         PHYSFS_writeSLE16(fp, di->index);
87 }