Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
draw.c
Go to the documentation of this file.
1/* FIGHTSTG's drawing helpers: a projected point and quads on a layer. */
2
4#include "engine/gte.h"
5
6/* Projects pos to the screen: its x and y, and its depth in the layer's
7 ordering table */
8void FIGHTSTG_projectPoint(Layer *layer, SVECTOR *pos, ShortVec3 *out) {
9 s32 shift = 16 - layer->getOtShift(layer);
10 DVECTOR screen;
11 MATRIX matrix;
12 s32 z;
13
14 gte_CompMatrix(&GsWSMATRIX, &IDENTITY_MATRIX, &matrix);
15 gte_SetRotMatrix(&matrix);
16 gte_SetTransMatrix(&matrix);
18 gte_rtps();
19 gte_stsxy(&screen);
20 gte_stszotz(&z);
21 out->x = screen.vx;
22 out->y = screen.vy;
23 out->z = z >> shift;
24}
25
26/* A Gouraud-shaded quad on a layer, blended when semi is set; the match
27 depends on setSemiTrans inside the if and on poly moving on past it */
28void FIGHTSTG_drawShadedQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors, s32 semi) {
29 Layer *layer = GFX.funcs.getLayer(layerId);
30 u_long *ot = layer->getOtEntry(layer, depth);
31 POLY_G4 *poly = GFX.funcs.getPrim();
32 DR_TPAGE *mode;
33
34 /* each color is copied whole over r, g, b and the byte after them */
35 *(CVECTOR *)&poly->r0 = colors[0];
36 *(CVECTOR *)&poly->r1 = colors[1];
37 *(CVECTOR *)&poly->r2 = colors[2];
38 *(CVECTOR *)&poly->r3 = colors[3];
39 setPolyG4(poly);
40 if (semi) {
41 setSemiTrans(poly, 1);
42 }
43 poly->x0 = xy[0].vx;
44 poly->x1 = xy[1].vx;
45 poly->x2 = xy[2].vx;
46 poly->x3 = xy[3].vx;
47 poly->y0 = xy[0].vy;
48 poly->y1 = xy[1].vy;
49 poly->y2 = xy[2].vy;
50 poly->y3 = xy[3].vy;
51 addPrim(ot, poly);
52 poly++;
53 if (semi) {
54 mode = (DR_TPAGE *)poly;
55 setlen(mode, 1);
56 mode->code[0] = 0xE1000245;
57 addPrim(ot, mode);
58 poly = (POLY_G4 *)(mode + 1);
59 }
60 GFX.funcs.setPrim(poly);
61}
62
63/* A Gouraud-shaded quad on a layer */
64void FIGHTSTG_drawQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors) {
65 FIGHTSTG_drawShadedQuad(layerId, depth, xy, colors, 0);
66}
67
68/* A Gouraud-shaded quad on a layer, blended */
69void FIGHTSTG_drawBlendedQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors) {
70 FIGHTSTG_drawShadedQuad(layerId, depth, xy, colors, 1);
71}
FIGHTSTG.PRO: the battle.
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
void FIGHTSTG_drawBlendedQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors)
A Gouraud-shaded quad on a layer, blended.
Definition draw.c:69
void FIGHTSTG_drawShadedQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors, s32 semi)
A Gouraud-shaded quad on a layer, blended when semi is set; the match depends on setSemiTrans inside ...
Definition draw.c:28
void FIGHTSTG_drawQuad(s32 layerId, s32 depth, DVECTOR *xy, CVECTOR *colors)
A Gouraud-shaded quad on a layer.
Definition draw.c:64
void FIGHTSTG_projectPoint(Layer *layer, SVECTOR *pos, ShortVec3 *out)
Projects pos to the screen: its x and y, and its depth in the layer's ordering table.
Definition draw.c:8
The GTE instructions that C can't say, as the SDK's inline_c.h has them but with the real encodings i...
#define gte_rtps()
V0 through RT and TR, then the perspective (SXY2, SZ3)
Definition gte.h:80
#define gte_stszotz(r0)
SZ3 / 4 into a word, the depth in the ordering table.
Definition gte.h:117
#define gte_SetTransMatrix(r0)
a MATRIX's translation into the GTE (TR)
Definition gte.h:127
#define gte_stsxy(r0)
SXY2 into a word.
Definition gte.h:92
#define gte_SetRotMatrix(r0)
a MATRIX's rotation into the GTE (RT)
Definition gte.h:46
#define gte_ldv0_unaligned(r0)
an SVECTOR that may not be word aligned into V0
Definition gte.h:69
MATRIX IDENTITY_MATRIX
the root bone's parent (src/engine/data/matrices.c)
Definition matrices.c:12
void *(* getPrim)(void)
Definition gfx.h:19
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
void(* setPrim)(void *next)
Definition gfx.h:20
GfxFuncs funcs
Definition gfx.h:77
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
u_long *(* getOtEntry)(struct Layer *, s32 depth)
Definition gfx.h:155
s32(* getOtShift)()
Definition gfx.h:158
A position or rotation, without the SVECTOR pad.
Definition model.h:14
s16 x
Definition model.h:15
s16 z
Definition model.h:17
s16 y
Definition model.h:16