19 void *(*getPrim)(void);
24 struct Layer *(*createLayer)(RECT *rect,
s32 otShift,
s32 id);
36#define SCREEN_WIDTH 320
37#define SCREEN_HEIGHT 240
45#define SCREEN_LAYER 0x1000
51#define VSYNC_STEP_NTSC 0x100
52#define VSYNC_STEP_PAL 0x133
156 u_long *(*getOtEntryZ)(
struct Layer *layer,
s32 z);
267#define STRETCH_SPRITE_BY(sprite, level, scaleX, scaleY, x, y) \
268 if ((level) != ONE) { \
269 (sprite).setScale(scaleX, scaleY, ONE); \
270 (sprite).setPivot(x, y); \
272 (sprite).setScale(ONE, ONE, ONE)
273#define STRETCH_SPRITE(sprite, level, x, y) STRETCH_SPRITE_BY(sprite, level, level, ONE, x, y)
274#define STRETCH_SPRITE_V(sprite, level, x, y) STRETCH_SPRITE_BY(sprite, level, ONE, level, x, y)
275#define ZOOM_SPRITE(sprite, level, x, y) STRETCH_SPRITE_BY(sprite, level, level, level, x, y)
358#define FADE_LEVEL_MAX 0xFF00
#define FLEXIBLE
The length of an array that ends a struct and runs as far as each object of it needs: s32 seps[FLEXIB...
The task system and its registry (task/)
#define TASK_HEADER(Type)
void spriteDrawerSetLayer(Layer *layer, s32 arg1)
Sprite drawer method: the layer and depth to draw to.
u_long * layerGetOtEntryZ(Layer *layer, s32 z)
Layer method: the OT entry for a 16-bit Z, scaled to the OT's length.
void layerLoadLightMatrix(Layer *layer)
Layer method: restores the light matrix that setKeepLightMatrix kept.
void * getPrim(void)
The next free byte of the packet buffer being drawn.
void allocPrimBuffers(s32 size)
Allocates the two GPU packet buffers, size bytes each, at the end of the heap.
void freePrimBuffers(void)
Frees the two packet buffers.
void bindTimLoader(TimLoader *obj)
Makes obj the TIM loader the methods work on.
s32 CARD_IMAGE_FILES[]
The card images, 64 cards to a file (cardDrawerSetCard), numbered in the Japanese disc as in the USA ...
void layerClearOt(Layer *layer)
Layer method: clears the OT of the buffer being drawn.
void spriteDrawerSetFollowScroll(s32 on)
Sprite drawer method: whether the sprites move with the layer's scroll.
void timLoaderSetImagePos(s32 x, s32 y)
TIM loader method: where in VRAM the next image goes.
void layerFree(Layer *layer)
Layer method: frees its OTs and draw callbacks, once the GPU is done with them.
s32 cardDrawerGetKind(void)
Card drawer method: the kind of the current card (CARD_KINDS)
void setDisplayArea(s32 x, s32 y, s32 w, s32 h)
Shows the same VRAM area from both display buffers.
void cardDrawerSetClutPos(s32 x, s32 y)
Card drawer method: the VRAM area of the CLUTs.
void layerRunCallbacks(Layer *layer)
Layer method: runs the draw callbacks in order, then empties the list.
s32 findLayerSlot(s32 id)
The slot of the layer with this id; id 0 finds a free slot.
void layerSkipEmptyOt(Layer *layer)
Links every run of empty OT entries past itself, so the GPU skips it.
void drawScreenFade(struct ScreenFade *task)
A full-screen POLY_F4 with subtractive blending (tpage 0xE1000245)
void layerAddCallback(Layer *layer, void(*func)(s32, void *, s32), s32 arg)
Layer method: adds a draw callback at the end of the list.
s32 NTSC_MODE
The European version runs at 50 Hz (PAL) unless NTSC_MODE is set; its clocks then advance 0x133,...
void insertLayerSlot(s32 index, Layer *layer, s32 id)
Puts a layer at position index of the draw order, moving the later ones back.
u_long * layerGetOtEntry(Layer *layer, s32 depth)
Layer method: the OT entry at depth in the buffer being drawn.
void cardDrawerSetLayer(s32 id, s32 depth)
Card drawer method: the layer and depth to draw to.
ScreenFade * createScreenFade(s32 layerId)
A screen fade task on a layer, idle until started.
GfxState GFX
GFX: the graphics state and its methods.
void vsyncCallback(void)
Every vsync: advances the time counters and the play time, runs GFX.vsyncFunc, shows the finished buf...
void layerDraw(Layer *layer)
Layer method: sends the OT of the finished buffer, after its DRAWENV with the layer's offset.
void cardDrawerDraw(s32 x, s32 y)
Card drawer method: draws the card of the current cell at (x, y), a 32x32 sprite.
void layerGetScroll(LayerView *layer, Vec2 *out)
Layer method: the scroll position, in pixels.
void spriteDrawerSetClutRow(s32 row)
Sprite drawer method: the CLUT row added to every part's.
void drawFrame(s32 draw)
Ends a frame: lets the layers run their draw callbacks, waits for the GPU and for the vsync that show...
void layerAddSortedCallback(Layer *layer, void(*func)(s32, void *, s32), s32 arg, s32 priority, s32 param)
Layer method: adds a draw callback in order of priority, highest first.
void timLoaderSetClutPos(s32 x, s32 y)
TIM loader method: where in VRAM the next CLUT goes.
void spriteDrawerSetColor(CVECTOR *color)
Sprite drawer method: the color the sprites are tinted with.
Layer * getLayer(s32 id)
The layer with id id, or NULL.
void spriteDrawerSetTexture(s32 x, s32 y)
Sprite drawer method: the VRAM position of the sheet's texture and CLUTs.
s32 SHIFT_PAL_SCREEN
moves both display areas 0x18 lines down
void layerSetScroll(LayerView *layer, s32 x, s32 y)
Layer method: sets the scroll position (8.8 fixed point)
u_long * layerGetOt(Layer *layer)
Layer method: the OT of the buffer being drawn.
void cardDrawerSetCard(s32 id)
Card drawer method: picks the image of card id (0 or less: the first image of the first file)
void layerGetViewRect(LayerView *layer, Rect16 *rect)
Layer method: the part of the scrolled world the clip rectangle shows.
void layerSetClipSize(LayerView *layer, s32 w, s32 h)
old-style: s16 w, h
void bindCardDrawer(CardDrawer *obj)
Makes obj the card drawer the methods work on.
void screenFadeStart(ScreenFade *task, s32 fadeIn, s32 duration)
Starts fading the screen to black (fadeIn 0) or back, over duration frames.
s32 destroyLayer(s32 id)
Frees the layer with id id; 0 if there is none.
void timLoaderLoad(void *tim)
TIM loader method: sends a TIM's CLUT (4 and 8-bit images) and image to VRAM.
void spriteDrawerSetScale(s32 x, s32 y, s32 z)
Sprite drawer method: scales the sprites (ONE: as they are)
s32 layerGetOtShift(LayerView *layer)
Layer method: the OT size it was created with.
void cardDrawerLoadImage(void)
Card drawer method: loads the card's image and CLUT into its cell of VRAM.
#define LAYER_COUNT
The drawing layers GFX holds at most.
void resetGraphics(void)
Destroys every layer and clears the packet buffers' state; the first call just picks the buffers.
void layerAllocCallbacks(Layer *layer, s32 count)
Layer method: room for count draw callbacks.
s32 CARD_KINDS[]
cardDrawerGetKind's kinds, by a card image's byte 3
void bindSpriteDrawer(SpriteDrawer *obj)
Makes obj the sprite drawer the methods work on.
void spriteDrawerSetLayerId(s32 id, s32 depth)
Sprite drawer method: the layer (by id) and depth to draw to.
Layer * newLayer(DRAWENV *env, s32 otShift)
Allocates a layer with its two OTs and methods.
s32 getTime(void)
The vsyncs since boot (in 60 Hz frames)
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
void setPrim(void *next)
Moves the packet buffer's free pointer past the primitives just written.
void cardDrawerSetSemiTrans(s32 on)
Card drawer method: draws semi-transparent, or not.
void setDisplayMode(s32 w, s32 h, s32 hires, s32 interlace)
Sets up the two display buffers: side by side in hi-res (interlaced 320x480 24-bit),...
void layerSetKeepLightMatrix(Layer *layer, s32 enable)
Layer method: keeps the current light matrix for this buffer's drawing.
void layerSetOffset(LayerView *layer, s32 x, s32 y)
old-style: s16 x, y
void layerResetCallbacks(Layer *layer)
Layer method: empties the draw callbacks, but for the head entry, which sorts first.
void layerSetBgColor(LayerView *layer, s32 r, s32 g, s32 b)
old-style: u8 r, g, b
void cardDrawerSetCell(s32 x, s32 y)
Card drawer method: the cell a card is loaded to and drawn from.
s16 OT_LENGTHS[]
A layer's ordering table length, by its otShift - 1.
void updateScreenFade(struct ScreenFade *task)
Moves the fade one frame on and draws it; TASK_DONE at the end, still drawn.
void spriteDrawerSetPivot(s32 x, s32 y)
Sprite drawer method: the point the sprites scale and rotate around.
s32 getFrameCount(void)
The frames drawn since boot.
void layerSetClipPos(LayerView *layer, s32 x, s32 y)
old-style: s16 x, y
Layer * createLayer(RECT *rect, s32 otShift, s32 id)
A new layer drawing to rect, with an OT of OT_LENGTHS[otShift - 1] entries; NULL when all are in use.
void initSpriteDrawer(struct SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
void spriteDrawerSetRotation(s32 x, s32 y, s32 z)
old-style: s16 x, y, z
void spriteDrawerSetAltClut(s32 x, s32 y)
Sprite drawer method: the other CLUT area, for parts that ask for it.
void cardDrawerSetClutStride(s32 stride)
Card drawer method: the CLUT rows between two columns of cells.
s32 getFrameTime(void)
The vsyncs the last frame took (in 60 Hz frames)
void layerAddScroll(LayerView *layer, s32 dx, s32 dy)
Layer method: scrolls by (dx, dy) (8.8 fixed point)
void cardDrawerSetImagePos(s32 x, s32 y)
Card drawer method: the VRAM area of the image cells.
void layerSetKeepView(Layer *layer, s32 enable, s32 projection)
Layer method: keeps the current world-screen matrix and projection for this buffer's drawing.
void moveLayer(s32 id, s32 targetId, s32 delta)
Moves a layer to the position of another one (plus delta) in the draw order.
void spriteDrawerDraw(s32 *sheet, s32 frame, s32 x, s32 y)
Draws frame frame of a sprite sheet (see SpritePart) at (x, y): as sprites, changing the texture page...
void removeLayerSlot(s32 index)
Closes the gap of a removed layer in the draw order.
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
void startVSyncCallback(void)
Installs vsyncCallback.
void timLoaderLoadArchive(void *archive)
TIM loader method: loads every TIM of an archive side by side, 0x40 halfwords apart,...
void timLoaderSetBufferSize(s32 size)
TIM loader method: the buffer that RLEN TIMs are unpacked to.
void layerLoadView(Layer *layer)
Layer method: restores the view that setKeepView kept.
One frame of a sprite animation; frame 0xFF ends it (or loops it)
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
void(* setClutPos)()
(x, y)
void(* setClutStride)()
(stride)
void(* setImagePos)()
(x, y)
s32 imageX
VRAM position of the image grid.
void(* setLayer)()
(id, depth)
s32 cellX
grid cell: 32x32 pixels, one CLUT row each
void(* setSemiTrans)()
(on)
A card's image (CardDrawer.card): 64 to a file, a 12-byte header and a 32x32 8-bit TIM.
u8 level
a Digimon's, 2-5 (CARDGAME shows its name); 0 on the other cards
s16 comboCard
the card (from 1) that three or more of it make (CARDGAME_findCardSet), 0 for none
u8 unused4
1-4 on the 60 option cards (a colour's first 4, its last two 1), 0 on the Digimon; nothing reads it
u8 kind
an index in CARD_KINDS
s16 rank
by strength, from 1 the strongest (0 on the two blank cards)
u8 tim[0x620]
its header, a 256-colour CLUT block and the image block
u8 points
what it adds to its colour
u8 pad7
0 on every card; nothing reads it
A function that a layer calls when it is drawn (Layer.addDrawCallback)
void(* func)(s32 arg, void *layer, s32 param)
struct DrawCallback * next
The graphics methods (GFX.funcs)
s32(* getFrameTime)(void)
s32(* getFrameCount)(void)
void(* freePrimBuffers)(void)
s32(* destroyLayer)(s32 id)
void(* allocPrimBuffers)(s32 size)
void(* setPrim)(void *next)
void(* setDisplayMode)(s32 w, s32 h, s32 hires, s32 interlace)
The graphics state: double-buffered display, the GPU packet buffers that primitives are written to (g...
void * prim
next free byte of the packet buffer
void(* vsyncFunc)(s32 arg)
s32 buffer
the one being drawn
struct Layer * layers[30]
s32 time
vsyncs since boot
s32 frameTime
vsyncs that the last frame took
Layer as its clip/scroll methods see it: the clip rect as unsigned.
s16 ofs[2]
DRAWENV's fields on (Layer.env)
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
void(* loadLightMatrix)(struct Layer *)
void(* runCallbacks)(struct Layer *)
void(* setBgColor)()
no prototype: callers would truncate u8 args
void(* setOffset)()
no prototype: callers would truncate s16 args
void(* draw)(struct Layer *)
void(* loadView)(struct Layer *)
void(* clearOt)(struct Layer *)
void(* setClipSize)()
no prototype: callers would truncate s16 args
void(* setKeepLightMatrix)()
void(* free)(struct Layer *)
void(* setClipPos)()
no prototype: callers would truncate s16 args
void(* addSortedCallback)()
Fades the whole screen to black and back with a subtractive rectangle.
void(* start)(struct ScreenFade *fade, s32 fadeIn, s32 frames)
TASK_DONE when done.
s32 level
0-FADE_LEVEL_MAX
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
s32 clutRow
added to the CLUT y: palette animations
void(* setAltClut)()
(x, y)
void(* setLayer)()
(layer, depth)
s32 altClutX
for the parts that are flagged
s32 followScroll
offset by the layer's scroll
void(* setScale)()
(x, y, z), ONE = 1.0
void(* setColor)()
(CVECTOR *)
void(* setLayerId)()
(id, depth)
s32 tpageX
VRAM position of the sheet's texture.
void(* setFollowScroll)()
(on)
void(* setClutRow)()
(row)
VECTOR scale
ScaleMatrix's.
void(* draw)()
(sheet, frame, x, y)
void(* setRotation)()
(x, y, z); no prototype: callers would truncate s16 args
void(* setTexture)()
(x, y)
One part of a sprite sheet, a rectangle of its texture.
s16 clutX
added to the drawer's CLUT position
s16 mode
0: 4-bit texture, 1: 8-bit, with the drawer's other CLUT
A TIM's CLUT or image block.
u32 size
in bytes, this header included
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
s32 bufferSize
for the RLE-compressed images
void(* setClutPos)()
(x, y)
void(* setImagePos)()
(x, y)
u8 pad4[4]
never read or written
void(* setBufferSize)()
(size)
u16 w
size of the last image
void(* loadArchive)()
(archive): each image 64 halfwords to the right
The next free primitive of the packet buffer (getPrim), written as the kind that is drawn next.
Where timLoaderLoad is in a TIM: its words, then its blocks, which their sizes in bytes take it past.