DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
texture.hpp
1#pragma once
2
3#include "common.h"
4
5#include <libgraph.h>
6
7class sceVif1Packet;
8class CTexture;
9struct TM2_head;
10
11struct IMG_head {
12 char tag[4];
13 u_int pictures;
14 u_int unk_08[2];
15};
16
17struct IMG_entry {
18 char name[32];
19 u_int offset;
20 u_int unk_24[3];
21};
22
23void SetTextureInfo(CTexture *texture, char *name, TM2_head *head);
24void SetTextureInfo(CTexture *texture, char *name, u_char *buffer);
25
26/* One texture file a block is built from, as the tables handed to EnterTextureFile hold them.
27 LoadTextureBlock walks a table from the front for each block in turn and stops at the first
28 entry whose name is null or empty, so a table states its own end rather than its length; the
29 third field is carried into EnterIMGFile unread by anything reconstructed. */
31 char *name;
33 int mipmap;
34};
35
36/* The same three fields for the block loaders that take an image already in memory. The first
37 field is spelled as a name because that is what the loaders read it as — they compare its first
38 character and hand it to the archive reader — and a caller with pixels rather than a file name
39 casts on the way in. */
41 char *name;
43 int mipmap;
44};
45
46/* One texture the registry hands out: the name it answers to, the block that owns it, the `TEX0`
47 and `TEX1` already assembled for it, and where each of its four mip levels and its palette were
48 copied. A block number of -1 marks a texture no block owns, which is what the registry's own
49 entry at index zero and every fixed texture carry. */
50class CTexture {
51public:
52 short block;
53 short width;
54 short height;
55 short bpp;
56 char name[32];
57 u_long tex0;
58 u_long tex1;
59 u_int *image[4];
60 u_int *clut;
63 CTexture();
64 void Initialize();
65};
66
67/* One of the seventy-two texture blocks: the run of video memory its textures were given, the run
68 of the registry's buffer their pixels were copied into, and how far another block has since
69 written over the first. `vram_end` is where the next texture entered into the block goes and
70 `vram_top` is where one entered without pixels goes, which is why the two move apart. */
72public:
73 char name[32];
76 int loaded;
77 int extend;
79 u_long128 *buffer;
80 u_long128 *buffer_end;
83 void Initialize();
84};
85
86/* The registry itself, of which the game keeps exactly one. Seventy-two blocks and a hundred and
87 ninety-six textures, all of them constructed at start-up, over one buffer taken whole from
88 `TextureData` at Initialize. Video memory is handed out from the bottom for the blocks and from
89 `vram_fix` downwards for the fixed textures, and the two meeting is the error every entry
90 point checks for. */
92public:
101 u_long128 *buffer;
106 CTextureManager() { Initialize(16352); }
107
108 void Initialize(int size);
109 void SetBuffer(u_long128 *buffer, int size);
110 int SearchTextureName(char *name, int block);
111 int GetTextureHandle(char *name, int block);
112 CTexture *GetTexture(int handle);
120 CTexture *GetTexture(char *name, int block);
121 CTexture *SearchTexture(char *name);
122 void EnterTexture(int block, char *name, u_char *image, int width, int height, int bpp, u_char *clut, int clut_colors, int mipmap, u_char *mip1, u_char *mip2, u_char *mip3, u_long tex1, int swizzled);
123 void EnterTextureEX(int block, char *name, u_char *image, int width, int height, int bpp, u_char *clut, int clut_colors, int mipmap, u_char *mip1, u_char *mip2, u_char *mip3, u_long tex1, int swizzled);
124 void EnterFixTexture(char *name, u_char *image, int width, int height, int bpp, u_char *clut, int clut_colors, int mipmap, u_char *mip1, u_char *mip2, u_char *mip3, u_long tex1, int swizzled);
125 void EnterFixTextureZ(u_char *buffer);
126 void EnterIMGFile(u_char *buffer, int block, int mipmap, int extend);
127 void ReloadTexture(sceVif1Packet *packet, int block);
128 void BeginEnterTextureBlock(int block);
129 void EndEnterTextureBlock(int block);
130 int DeleteTextureBlock(int block);
131 int CleanUpBuffer();
132 int CleanUpTextureList();
133 int LoadTextureBlock(int block, u_int *buffer);
134 int LoadTextureBlock(int block, LOADTEXTURE_INFO *table, u_int *buffer);
135 int LoadTextureBlock(int block, LOADTEXTURE_INFO2 *table);
136 int LoadTextureBlockEX(int block, LOADTEXTURE_INFO2 *table);
137 int EnterTextureFile(LOADTEXTURE_INFO *table);
138 void print_buff_info();
139};
140
141extern CTextureManager TexManager;
u_long128 * buffer_end
Definition texture.hpp:80
char name[32]
Definition texture.hpp:73
u_long128 * buffer
Definition texture.hpp:79
LOADTEXTURE_INFO * file
Definition texture.hpp:104
u_long128 * buffer
Definition texture.hpp:101
CTexture textures[196]
Definition texture.hpp:100
CTextureBlock blocks[72]
Definition texture.hpp:99
short height
Definition texture.hpp:54
int swizzled
Definition texture.hpp:61
short bpp
Definition texture.hpp:55
short block
Definition texture.hpp:52
u_int * image[4]
Definition texture.hpp:59
char name[32]
Definition texture.hpp:56
u_int * clut
Definition texture.hpp:60
short width
Definition texture.hpp:53
u_long tex1
Definition texture.hpp:58
u_long tex0
Definition texture.hpp:57
Definition texture.hpp:17
char name[32]
Definition texture.hpp:18
u_int offset
Definition texture.hpp:19
u_int pictures
Definition texture.hpp:13
char tag[4]
Definition texture.hpp:12