-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexture.c
73 lines (61 loc) · 1.67 KB
/
texture.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "global.h"
#include "model.h"
#include "texture.h"
#include "files.h"
TEXTURES textures;
void initTextures() {
textures.apple = file2texture("APPLE.TIM");
textures.pony = file2texture("TWILY.TIM");
textures.cloud = file2texture("CLOUD.TIM");
textures.ground = file2texture("CHAO.TIM");
textures.shadow = file2texture("SHADOW.TIM");
textures.casa1 = file2texture("CASA1.TIM");
}
void DpqColor(CVECTOR *orgc, int depth, CVECTOR *newc) {
gte_lddp(depth);
gte_ldrgb(orgc);
gte_dpcs();
gte_strgb(newc);
}
void sce_make_fog_clut(RECT *crect, u_short *clut, int num) {
int i,j;
int stp;
int depth;
u_short newclut[256];
CVECTOR orgc, newc;
RECT rect;
rect.x = crect->x;
rect.w = crect->w;
rect.h = crect->h;
for (i = 0; i < num; i++) {
depth = i * ONE / num;
for (j = 0; j < crect->w; j++) {
if (clut[j] == 0) {
newclut[j] = clut[j];
} else {
orgc.r = (clut[j] & 0x1f) << 3;
orgc.g = ((clut[j] >> 5) & 0x1f) << 3;
orgc.b = ((clut[j] >> 10) & 0x1f) << 3;
stp = clut[j] & 0x8000;
DpqColor(&orgc, depth, &newc);
newclut[j] = stp | (newc.r >> 3)
| (((u_int)(newc.g & 0xf8)) << 2)
| (((u_int)(newc.b & 0xf8)) << 7);
}
}
rect.y = crect->y + i;
LoadImage(&rect, (u_int *)newclut);
}
}
void LoadTexture(u_int *tim, GsIMAGE *tparam) {
GsGetTimInfo(tim, tparam);
printf("PRECT: %d %d %d %d\n", tparam->px, tparam->py, tparam->pw, tparam->ph);
RECT prect = {tparam->px, tparam->py, tparam->pw, tparam->ph};
RECT crect = {tparam->cx, tparam->cy, tparam->cw, tparam->ch};
LoadImage(&prect, tparam->pixel);
DrawSync(0);
if (tparam->pmode & 0x8) {
sce_make_fog_clut(&crect, tparam->clut, 8);
DrawSync(0);
}
}