Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
layer.c File Reference
#include "engine/game.h"
#include <libgs.h>
#include <libetc.h>
#include <libsnd.h>
Include dependency graph for layer.c:

Go to the source code of this file.

Functions

Layer * getLayer (s32 id)
 The layer with id id, or NULL.
 
s32 findLayerSlot (s32 id)
 The slot of the layer with this id; id 0 finds a free slot.
 
void removeLayerSlot (s32 index)
 Closes the gap of a removed layer in the draw order.
 
void insertLayerSlot (s32 index, Layer *layer, s32 id)
 Puts a layer at position index of the draw order, moving the later ones back.
 
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.
 
s32 destroyLayer (s32 id)
 Frees the layer with id id; 0 if there is none.
 
void moveLayer (s32 id, s32 targetId, s32 delta)
 Moves a layer to the position of another one (plus delta) in the draw order.
 
void layerClearOt (Layer *layer)
 Layer method: clears the OT of the buffer being drawn.
 
void layerSkipEmptyOt (Layer *layer)
 Links every run of empty OT entries past itself, so the GPU skips it.
 
void layerDraw (Layer *layer)
 Layer method: sends the OT of the finished buffer, after its DRAWENV with the layer's offset.
 
u_long * layerGetOtEntry (Layer *layer, s32 depth)
 Layer method: the OT entry at depth in the buffer being drawn.
 
u_long * layerGetOtEntryZ (Layer *layer, s32 z)
 Layer method: the OT entry for a 16-bit Z, scaled to the OT's length.
 
u_long * layerGetOt (Layer *layer)
 Layer method: the OT of the buffer being drawn.
 
s32 layerGetOtShift (LayerView *layer)
 Layer method: the OT size it was created with.
 
void layerSetBgColor (LayerView *layer, u8 r, u8 g, u8 b)
 Layer method: the color the layer's area is cleared to (black: not cleared).
 
void layerSetOffset (LayerView *layer, s16 x, s16 y)
 Layer method: the drawing offset.
 
void layerGetScroll (LayerView *layer, Vec2 *out)
 Layer method: the scroll position, in pixels.
 
void layerSetScroll (LayerView *layer, s32 x, s32 y)
 Layer method: sets the scroll position (8.8 fixed point)
 
void layerAddScroll (LayerView *layer, s32 dx, s32 dy)
 Layer method: scrolls by (dx, dy) (8.8 fixed point)
 
void layerSetClipPos (LayerView *layer, s16 x, s16 y)
 Layer method: moves the clip rectangle.
 
void layerSetClipSize (LayerView *layer, s16 w, s16 h)
 Layer method: resizes the clip rectangle.
 
void layerGetViewRect (LayerView *layer, Rect16 *rect)
 Layer method: the part of the scrolled world the clip rectangle shows.
 
void layerFree (Layer *layer)
 Layer method: frees its OTs and draw callbacks, once the GPU is done with them.
 
void layerResetCallbacks (Layer *layer)
 Layer method: empties the draw callbacks, but for the head entry, which sorts first.
 
void layerAllocCallbacks (Layer *layer, s32 count)
 Layer method: room for count draw callbacks.
 
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 layerAddCallback (Layer *layer, void(*func)(s32, void *, s32), s32 arg)
 Layer method: adds a draw callback at the end of the list.
 
void layerRunCallbacks (Layer *layer)
 Layer method: runs the draw callbacks in order, then empties the list.
 
void layerSetKeepView (Layer *layer, s32 enable, s32 projection)
 Layer method: keeps the current world-screen matrix and projection for this buffer's drawing.
 
void layerLoadView (Layer *layer)
 Layer method: restores the view that setKeepView kept.
 
void layerSetKeepLightMatrix (Layer *layer, s32 enable)
 Layer method: keeps the current light matrix for this buffer's drawing.
 
void layerLoadLightMatrix (Layer *layer)
 Layer method: restores the light matrix that setKeepLightMatrix kept.
 
Layer * newLayer (DRAWENV *env, s32 otShift)
 Allocates a layer with its two OTs and methods.
 

Variables

s16 OT_LENGTHS []
 A layer's ordering table length, by its otShift - 1.
 

Function Documentation

◆ getLayer()

Layer * getLayer ( s32  id)

The layer with id id, or NULL.

Definition at line 7 of file layer.c.

◆ findLayerSlot()

s32 findLayerSlot ( s32  id)

The slot of the layer with this id; id 0 finds a free slot.

Definition at line 19 of file layer.c.

Referenced by createLayer(), destroyLayer(), and moveLayer().

Here is the caller graph for this function:

◆ removeLayerSlot()

void removeLayerSlot ( s32  index)

Closes the gap of a removed layer in the draw order.

Definition at line 35 of file layer.c.

Referenced by destroyLayer(), and moveLayer().

Here is the caller graph for this function:

◆ insertLayerSlot()

void insertLayerSlot ( s32  index,
Layer *  layer,
s32  id 
)

Puts a layer at position index of the draw order, moving the later ones back.

Definition at line 43 of file layer.c.

Referenced by moveLayer().

Here is the caller graph for this function:

◆ createLayer()

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.

Definition at line 58 of file layer.c.

Here is the call graph for this function:

◆ destroyLayer()

s32 destroyLayer ( s32  id)

Frees the layer with id id; 0 if there is none.

Definition at line 71 of file layer.c.

Here is the call graph for this function:

◆ moveLayer()

void moveLayer ( s32  id,
s32  targetId,
s32  delta 
)

Moves a layer to the position of another one (plus delta) in the draw order.

Definition at line 86 of file layer.c.

Here is the call graph for this function:

◆ layerClearOt()

void layerClearOt ( Layer *  layer)

Layer method: clears the OT of the buffer being drawn.

Definition at line 106 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSkipEmptyOt()

void layerSkipEmptyOt ( Layer *  layer)

Links every run of empty OT entries past itself, so the GPU skips it.

Definition at line 111 of file layer.c.

Referenced by layerDraw().

Here is the caller graph for this function:

◆ layerDraw()

void layerDraw ( Layer *  layer)

Layer method: sends the OT of the finished buffer, after its DRAWENV with the layer's offset.

Definition at line 130 of file layer.c.

Referenced by newLayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layerGetOtEntry()

u_long * layerGetOtEntry ( Layer *  layer,
s32  depth 
)

Layer method: the OT entry at depth in the buffer being drawn.

Definition at line 154 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerGetOtEntryZ()

u_long * layerGetOtEntryZ ( Layer *  layer,
s32  z 
)

Layer method: the OT entry for a 16-bit Z, scaled to the OT's length.

Definition at line 159 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerGetOt()

u_long * layerGetOt ( Layer *  layer)

Layer method: the OT of the buffer being drawn.

Definition at line 166 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerGetOtShift()

s32 layerGetOtShift ( LayerView *  layer)

Layer method: the OT size it was created with.

Definition at line 171 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSetBgColor()

void layerSetBgColor ( LayerView *  layer,
u8  r,
u8  g,
u8  b 
)

Layer method: the color the layer's area is cleared to (black: not cleared).

An old-style definition, as Layer.setBgColor's unprototyped callers suit: they pass ints, which it takes as bytes.

Definition at line 180 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSetOffset()

void layerSetOffset ( LayerView *  layer,
s16  x,
s16  y 
)

Layer method: the drawing offset.

Old-style, as layerSetBgColor

Definition at line 197 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerGetScroll()

void layerGetScroll ( LayerView *  layer,
Vec2 *  out 
)

Layer method: the scroll position, in pixels.

Definition at line 207 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSetScroll()

void layerSetScroll ( LayerView *  layer,
s32  x,
s32  y 
)

Layer method: sets the scroll position (8.8 fixed point)

Definition at line 213 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerAddScroll()

void layerAddScroll ( LayerView *  layer,
s32  dx,
s32  dy 
)

Layer method: scrolls by (dx, dy) (8.8 fixed point)

Definition at line 219 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSetClipPos()

void layerSetClipPos ( LayerView *  layer,
s16  x,
s16  y 
)

Layer method: moves the clip rectangle.

Old-style, as layerSetBgColor

Definition at line 225 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSetClipSize()

void layerSetClipSize ( LayerView *  layer,
s16  w,
s16  h 
)

Layer method: resizes the clip rectangle.

Old-style, as layerSetBgColor

Definition at line 235 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerGetViewRect()

void layerGetViewRect ( LayerView *  layer,
Rect16 *  rect 
)

Layer method: the part of the scrolled world the clip rectangle shows.

Definition at line 245 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerFree()

void layerFree ( Layer *  layer)

Layer method: frees its OTs and draw callbacks, once the GPU is done with them.

Definition at line 253 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerResetCallbacks()

void layerResetCallbacks ( Layer *  layer)

Layer method: empties the draw callbacks, but for the head entry, which sorts first.

Definition at line 263 of file layer.c.

Referenced by layerAllocCallbacks(), and layerRunCallbacks().

Here is the caller graph for this function:

◆ layerAllocCallbacks()

void layerAllocCallbacks ( Layer *  layer,
s32  count 
)

Layer method: room for count draw callbacks.

< the current mode's: freed by main whenever the mode task ends

Definition at line 273 of file layer.c.

Referenced by newLayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layerAddSortedCallback()

void layerAddSortedCallback ( Layer *  layer,
void(*)(s32, void *, s32)  func,
s32  arg,
s32  priority,
s32  param 
)

Layer method: adds a draw callback in order of priority, highest first.

Definition at line 280 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerAddCallback()

void layerAddCallback ( Layer *  layer,
void(*)(s32, void *, s32)  func,
s32  arg 
)

Layer method: adds a draw callback at the end of the list.

Definition at line 323 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerRunCallbacks()

void layerRunCallbacks ( Layer *  layer)

Layer method: runs the draw callbacks in order, then empties the list.

Definition at line 341 of file layer.c.

Referenced by newLayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layerSetKeepView()

void layerSetKeepView ( Layer *  layer,
s32  enable,
s32  projection 
)

Layer method: keeps the current world-screen matrix and projection for this buffer's drawing.

Definition at line 357 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerLoadView()

void layerLoadView ( Layer *  layer)

Layer method: restores the view that setKeepView kept.

Definition at line 366 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerSetKeepLightMatrix()

void layerSetKeepLightMatrix ( Layer *  layer,
s32  enable 
)

Layer method: keeps the current light matrix for this buffer's drawing.

Definition at line 372 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ layerLoadLightMatrix()

void layerLoadLightMatrix ( Layer *  layer)

Layer method: restores the light matrix that setKeepLightMatrix kept.

Definition at line 380 of file layer.c.

Referenced by newLayer().

Here is the caller graph for this function:

◆ newLayer()

Layer * newLayer ( DRAWENV *  env,
s32  otShift 
)

Allocates a layer with its two OTs and methods.

< the current mode's: freed by main whenever the mode task ends

< the current mode's: freed by main whenever the mode task ends

< the current mode's: freed by main whenever the mode task ends

Definition at line 385 of file layer.c.

Referenced by createLayer().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ OT_LENGTHS

s16 OT_LENGTHS[]
Initial value:
= {
0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000,
}

A layer's ordering table length, by its otShift - 1.

Definition at line 422 of file layer.c.

Referenced by newLayer().