1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef _MIP_HH_
|
---|
10 | #define _MIP_HH_
|
---|
11 |
|
---|
12 | #define R1_MAX_MIP_LEVELS 8
|
---|
13 |
|
---|
14 | #include "arch.hh"
|
---|
15 | #include "file/file.hh"
|
---|
16 | #include <stdio.h>
|
---|
17 |
|
---|
18 | typedef void *r1_vram_handle_type;
|
---|
19 |
|
---|
20 | inline int r1_mip_header_disk_size() { return 4 * R1_MAX_MIP_LEVELS + 4 +32+2+2+1+1; }
|
---|
21 |
|
---|
22 | struct mipheader_t
|
---|
23 | {
|
---|
24 | sw32 offsets[R1_MAX_MIP_LEVELS];
|
---|
25 | w32 average_color;
|
---|
26 | char tname[32];
|
---|
27 | sw16 base_width,base_height;
|
---|
28 | w8 flags;
|
---|
29 | sw8 num_mip_levels;
|
---|
30 |
|
---|
31 | void write(i4_file_class *fp)
|
---|
32 | {
|
---|
33 | for (int i=0; i<R1_MAX_MIP_LEVELS; i++)
|
---|
34 | fp->write_32(offsets[i]);
|
---|
35 | fp->write_32(average_color);
|
---|
36 | fp->write(tname, 32);
|
---|
37 | fp->write_16(base_width);
|
---|
38 | fp->write_16(base_height);
|
---|
39 | fp->write_8(flags);
|
---|
40 | fp->write_8(num_mip_levels);
|
---|
41 | }
|
---|
42 |
|
---|
43 | void read(i4_file_class *fp)
|
---|
44 | {
|
---|
45 | for (int i=0; i<R1_MAX_MIP_LEVELS; i++)
|
---|
46 | offsets[i]=fp->read_32();
|
---|
47 | average_color=fp->read_32();
|
---|
48 | fp->read(tname, 32);
|
---|
49 | base_width=fp->read_16();
|
---|
50 | base_height=fp->read_16();
|
---|
51 | flags=fp->read_8();
|
---|
52 | num_mip_levels=fp->read_8();
|
---|
53 | }
|
---|
54 | };
|
---|
55 |
|
---|
56 | #define R1_MIP_IS_TRANSPARENT 1
|
---|
57 | #define R1_MIP_IS_ALPHATEXTURE 2
|
---|
58 | #define R1_MIP_IS_JPG_COMPRESSED 64
|
---|
59 |
|
---|
60 | //use this only temporarily. isnt necessarily maintained
|
---|
61 | #define R1_MIP_EXTRA_FLAG 32
|
---|
62 |
|
---|
63 | class r1_miplevel_t;
|
---|
64 | class r1_texture_entry_struct;
|
---|
65 |
|
---|
66 | #define R1_MIP_LOAD_NO_ROOM 1
|
---|
67 | #define R1_MIP_LOAD_BUSY 2
|
---|
68 |
|
---|
69 | class r1_mip_load_info
|
---|
70 | {
|
---|
71 | public:
|
---|
72 | r1_miplevel_t *dest_mip;
|
---|
73 | i4_file_class *src_file;
|
---|
74 | w8 error;
|
---|
75 | };
|
---|
76 |
|
---|
77 | #define R1_MIPLEVEL_IS_LOADING 1
|
---|
78 |
|
---|
79 | class r1_miplevel_t
|
---|
80 | {
|
---|
81 | public:
|
---|
82 | r1_miplevel_t::r1_miplevel_t()
|
---|
83 | {
|
---|
84 | level=0;
|
---|
85 | width=height=0;
|
---|
86 | vram_handle=0;
|
---|
87 | entry=0;
|
---|
88 | last_frame_used=0;
|
---|
89 | flags=0;
|
---|
90 | }
|
---|
91 |
|
---|
92 | //every time get_texture() is called and this miplevel is returned,
|
---|
93 | //the current frame # is copied into last_frame_used
|
---|
94 | sw32 last_frame_used;
|
---|
95 |
|
---|
96 | r1_texture_entry_struct *entry;
|
---|
97 | r1_vram_handle_type vram_handle; //this is just a void * (defined above)
|
---|
98 |
|
---|
99 | sw16 width,height; //not technically necessary, can be recalculated via entry and level
|
---|
100 | w8 level;
|
---|
101 | w8 flags;
|
---|
102 | };
|
---|
103 |
|
---|
104 |
|
---|
105 | struct i4_pixel_format;
|
---|
106 | void r1_setup_decompression(i4_pixel_format *reg_fmt,
|
---|
107 | i4_pixel_format *chroma_fmt,
|
---|
108 | i4_pixel_format *alpha_fmt,
|
---|
109 | w32 chroma_color,
|
---|
110 | i4_bool square_textures);
|
---|
111 |
|
---|
112 | void r1_end_decompression();
|
---|
113 |
|
---|
114 | i4_bool r1_decompress_to_local_mip(i4_file_class *src_file,
|
---|
115 | i4_file_class *dst_lowest_mip,
|
---|
116 | char *network_file,
|
---|
117 | char *local_file,
|
---|
118 | mipheader_t *old_mipheader,
|
---|
119 | sw32 max_mip_dimention);
|
---|
120 |
|
---|
121 | #endif
|
---|