Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
card_drawer.c
Go to the documentation of this file.
1#include "engine/game.h"
2#include <libgs.h>
3#include <libetc.h>
4#include <libsnd.h>
5
6/* Small variables, addressed through $gp (see the Makefile) */
8
9/* Makes `obj` the card drawer the methods work on */
11 CARD_DRAWER = obj;
12}
13
14/*
15 * Card drawer method: picks the image of card `id` (0 or less: the first image of the first file)
16 */
18 CardImage *images;
19 s32 n;
20 s32 i;
21 if (id > 0) {
22 n = id - 1;
23 i = n >> 6;
24 images = FILE_CACHE.load(CARD_IMAGE_FILES[i]);
25 CARD_DRAWER->card = &images[n & 0x3F];
26 } else {
28 }
29}
30
31/* Card drawer method: loads the card's image and CLUT into its cell of VRAM */
40
41/* Card drawer method: the layer and depth to draw to */
42void cardDrawerSetLayer(s32 id, s32 depth) {
43 Layer *layer = GFX.funcs.getLayer(id);
44
45 CARD_DRAWER->layer = layer;
46 CARD_DRAWER->ot = layer->getOtEntry(layer, depth);
47}
48
49/* Card drawer method: the VRAM area of the image cells */
54
55/* Card drawer method: the VRAM area of the CLUTs */
57 CARD_DRAWER->clutX = x;
58 CARD_DRAWER->clutY = y;
59}
60
61/* Card drawer method: the cell a card is loaded to and drawn from */
63 CARD_DRAWER->cellX = x;
64 CARD_DRAWER->cellY = y;
65}
66
67/* Card drawer method: the CLUT rows between two columns of cells */
69 CARD_DRAWER->clutStride = stride;
70}
71
72/* Card drawer method: draws semi-transparent, or not */
76
77/* Card drawer method: draws the card of the current cell at (x, y), a 32x32 sprite */
79 SPRT *sprt = GFX.funcs.getPrim();
80 SPRT *base = sprt;
81 u8 *end;
82 u16 tpage;
83 u16 clut;
84
86 tpage = (1 << 7) | (1 << 5) | ((CARD_DRAWER->imageY & 0x100) >> 4) | (((CARD_DRAWER->imageX + CARD_DRAWER->cellX * 16) & 0x3C0) >> 6) | ((CARD_DRAWER->imageY & 0x200) << 2);
87 setSprt(sprt);
88 if (CARD_DRAWER->semiTrans != 0) {
89 setSemiTrans(sprt, 1);
90 }
91 setRGB0(sprt, 0x80, 0x80, 0x80);
92 setXY0(sprt, x, y);
93 setUV0(sprt, (CARD_DRAWER->cellX & 3) * 32, CARD_DRAWER->cellY * 32);
94 setWH(sprt, 32, 32);
95 sprt->clut = clut;
96 addPrim(CARD_DRAWER->ot, sprt);
97 /* the texture page goes right after the sprite */
98 sprt++;
99 SetDrawTPage((DR_TPAGE *)sprt, 0, 1, tpage);
100 end = (u8 *)base + sizeof(SPRT) + sizeof(DR_TPAGE); /* past both primitives */
101 /* addPrim, with the tag written through the start of the block */
102 setaddr(base + 1, getaddr(CARD_DRAWER->ot));
103 setaddr(CARD_DRAWER->ot, sprt);
104 GFX.funcs.setPrim(end);
105}
106
107/* Card drawer method: the kind of the current card (CARD_KINDS) */
111
112/* Clears a card drawer, gives it its methods and binds it */
128
129/* The card images, 64 cards to a file (cardDrawerSetCard), numbered in the
130 Japanese disc as in the USA one */
131#if VERSION_US || VERSION_JP
132s32 CARD_IMAGE_FILES[] = { 2023, 2024, 2025, 2026, 2027 };
133#elif VERSION_EU
134s32 CARD_IMAGE_FILES[] = { 2038, 2039, 2040, 2041, 2042 };
135#endif
136
137/* cardDrawerGetKind's kinds, by a card image's byte 3 */
138s32 CARD_KINDS[] = { 0, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 0, 0 };
s32 CARD_IMAGE_FILES[]
The card images, 64 cards to a file (cardDrawerSetCard), numbered in the Japanese disc as in the USA ...
s32 cardDrawerGetKind(void)
Card drawer method: the kind of the current card (CARD_KINDS)
void cardDrawerSetClutPos(s32 x, s32 y)
Card drawer method: the VRAM area of the CLUTs.
Definition card_drawer.c:56
void cardDrawerSetLayer(s32 id, s32 depth)
Card drawer method: the layer and depth to draw to.
Definition card_drawer.c:42
void cardDrawerDraw(s32 x, s32 y)
Card drawer method: draws the card of the current cell at (x, y), a 32x32 sprite.
Definition card_drawer.c:78
static CardDrawer * CARD_DRAWER
Small variables, addressed through $gp (see the Makefile)
Definition card_drawer.c:7
void cardDrawerSetCard(s32 id)
Card drawer method: picks the image of card id (0 or less: the first image of the first file)
Definition card_drawer.c:17
void bindCardDrawer(CardDrawer *obj)
Makes obj the card drawer the methods work on.
Definition card_drawer.c:10
void cardDrawerLoadImage(void)
Card drawer method: loads the card's image and CLUT into its cell of VRAM.
Definition card_drawer.c:32
s32 CARD_KINDS[]
cardDrawerGetKind's kinds, by a card image's byte 3
void cardDrawerSetSemiTrans(s32 on)
Card drawer method: draws semi-transparent, or not.
Definition card_drawer.c:73
void cardDrawerSetCell(s32 x, s32 y)
Card drawer method: the cell a card is loaded to and drawn from.
Definition card_drawer.c:62
void cardDrawerSetClutStride(s32 stride)
Card drawer method: the CLUT rows between two columns of cells.
Definition card_drawer.c:68
void cardDrawerSetImagePos(s32 x, s32 y)
Card drawer method: the VRAM area of the image cells.
Definition card_drawer.c:50
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
signed int s32
Definition common.h:11
unsigned short u16
Definition common.h:10
unsigned char u8
Definition common.h:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
Definition gfx.h:193
void(* setCard)()
(id)
Definition gfx.h:205
s32 cellY
Definition gfx.h:200
Layer * layer
Definition gfx.h:203
void(* setClutPos)()
(x, y)
Definition gfx.h:210
s32 clutStride
Definition gfx.h:201
void(* setCell)()
(x, y)
Definition gfx.h:211
s32 clutX
Definition gfx.h:197
void(* draw)()
(x, y)
Definition gfx.h:207
u_long * ot
Definition gfx.h:204
s32 semiTrans
Definition gfx.h:202
void(* setClutStride)()
(stride)
Definition gfx.h:212
s32(* getKind)(void)
Definition gfx.h:214
void(* setImagePos)()
(x, y)
Definition gfx.h:209
s32 imageX
VRAM position of the image grid.
Definition gfx.h:195
void(* loadImage)()
Definition gfx.h:206
s32 imageY
Definition gfx.h:196
s32 clutY
Definition gfx.h:198
void(* setLayer)()
(id, depth)
Definition gfx.h:208
s32 cellX
grid cell: 32x32 pixels, one CLUT row each
Definition gfx.h:199
void(* setSemiTrans)()
(on)
Definition gfx.h:213
CardImage * card
Definition gfx.h:194
A card's image (CardDrawer.card): 64 to a file, a 12-byte header and a 32x32 8-bit TIM.
Definition gfx.h:172
u8 kind
an index in CARD_KINDS
Definition gfx.h:176
u8 tim[0x620]
its header, a 256-colour CLUT block and the image block
Definition gfx.h:185
void *(* load)(u32 file)
Definition file.h:92
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
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
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
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setClutPos)()
(x, y)
Definition gfx.h:337
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* load)()
(TIM)
Definition gfx.h:335
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119