12 for (i = 0; i < 30; i++) {
15 found = pool->
tasks[i];
36 for (i = 0; i < 30; i++) {
37 task = pool->
tasks[i];
39 for (j = 0; j < 30; j++) {
47 for (k = 0; k < 30; k++) {
76 for (i = 0; i < 4; i++) {
79 SetSemiTrans(prim.
sprt, 1);
82 prim.
sprt->x0 = x - scroll.
x + ((i & 1) << 6);
83 prim.
sprt->y0 = y - scroll.
y + ((i << 5) & 0x40);
89 addPrim(ot, prim.
any);
92 addPrim(ot, prim.
any);
103 for (i = 0; i < 30; i++) {
104 task = pool->
tasks[i];
105 if (task->
getFrame(task) == frame) {
145 for (r = 0; r < 3; r++) {
146 if (r + tile.
y >= task->
height) {
149 for (c = 0; c < 4; c++) {
150 if (c + tile.
x >= task->
width) {
153 frame = c + tile.
x + (r + tile.
y) * task->
width;
156 if (stream !=
NULL) {
157 slots[count].
stream = stream;
158 slots[count].
frame = frame;
164 slots[count].
x = (c + tile.
x) * 128;
165 slots[count].
y = (r + tile.
y) * 128;
169 for (i = 0; i < count; i++) {
170 if (slots[i].loaded && slots[i].entry != -1) {
184 slots[i].
stream->
draw(slots[i].stream, layer, slots[i].x, slots[i].y);
186 }
else if (slots[i].tile != 0) {
191 for (i = 0; i < count; i++) {
192 if (slots[i].loaded && slots[i].entry == -1 && slots[i].stream->
isLoaded(slots[i].
stream)) {
195 for (j = 0; j < 12; j++) {
204 if (stream !=
NULL) {
205 stream->clearSlot(stream);
245 offset = task->
scroll.
x & 0x7F;
246 quadrant = offset > 0x40;
250 offset = scrollY - (scrollY & ~0x7F);
254 for (row = 0; row < 5; row++) {
255 for (col = 0; col < 6; col++) {
274 for (col = 0; col < 30; col++) {
277 for (row = 0; row < 5; row++) {
278 y = row + task->
viewY;
279 if (y >= 0 && y < task->height) {
280 for (col = 0; col < 6; col++) {
281 x = col + task->
viewX;
282 if (x >= 0 && x < task->width) {
300 switch (task->
state) {
320 for (j = 0; j < count; j++) {
326 for (i = 0; i < 30; i++) {
329 for (i = 0; i < 12; i++) {
CdReader CD_READER
The CD reader.
Decompressor * createDecompressor(void)
A decompressor task.
GfxState GFX
GFX: the graphics state and its methods.
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
#define FIELD_TASK_MAP
The ids of the field's tasks (createTaskWithId, TASK_REGISTRY.funcs.find)
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
FIELDSTG.PRO: the field mode, where the player walks around the map.
u8 FIELDSTG_slotOffsets[][2][2]
the slots' offset in tiles: [quadrant][x, y][unflipped, flipped]
Vec2 FIELDSTG_mapSize
FIELDSTG_getMapSize's.
u8 FIELDSTG_dirLayouts[][2]
the layout and its flips for each direction
FieldState FIELDSTG_state
u8 FIELDSTG_slotLayouts[][4][5][6]
FIELDSTG_pickViewTiles's slot layouts: [layout][quadrant][row][column].
#define SCREEN_WIDTH
The screen the modes draw on (setDisplayMode, their layers' rects)
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
void FIELDSTG_runMapStreamer(MapStreamer *task, StreamPool *pool)
The map streamer's update: reads the map's header and creates the 30 stream tasks,...
void FIELDSTG_drawCoverBlock(Layer *layer, s32 x, s32 y, s32 level)
Draws a 128-pixel block of the cover at (x, y), at a shade of level (8.8)
StreamTask * FIELDSTG_findOldestStream(StreamPool *pool)
The stream task drawn or loaded the longest ago.
StreamTask * FIELDSTG_findStream(StreamPool *pool, s32 frame)
The stream task that holds a frame (a tile of the map), or NULL.
Vec2 * FIELDSTG_getMapSize(MapStreamer *task)
The map's size in pixels.
MapStreamer * FIELDSTG_createMapStreamer(s32 file)
Creates the map streamer of a file.
void FIELDSTG_requestTiles(MapStreamer *map, StreamPool *pool)
Streams the map's tiles while the CD reader is free: a tile of viewTiles (0xFF for none) that a strea...
void FIELDSTG_drawMapTiles(MapStreamer *task, StreamPool *pool)
Draws the map's tiles in view, under a cover that fades from the new ones, and while the decompressor...
void FIELDSTG_pickViewTiles(MapStreamer *task)
Points the slots around the view at the map's tiles: viewTiles gets, for each of the 30 slots,...
void FIELDSTG_drawCover(s32 id, s32 level)
Covers the screen on the layer id at a shade of level (8.8)
TaskRegistry TASK_REGISTRY
StreamTask * FIELDSTG_createStream(s32 size, s32 file)
Creates a stream task of a file, with a buffer of size.
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
void(* read)(s32 file, s32 offset, s32 size, void *buf, s32 *done)
union FieldState::@12 images
FieldImage * field
the field's image (the first two ActorImages)
struct Layer *(* getLayer)(s32 id)
void(* setPrim)(void *next)
void *(* alloc)(s32 size, s32 tag)
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
u_long *(* getOtEntry)(struct Layer *, s32 depth)
s32 time
when it was last drawn
s32 cover
the level of the cover over a new tile (8.8), 0 for none
s32 frame
the tile it holds, or -1
A tile of the map in view (FIELDSTG_drawMapTiles)
s32 entry
into MapStreamer.images, or -1
s16 loaded
a StreamTask has its frame
The task that streams the map's tiles from the CD around the view (FIELDSTG_runMapStreamer,...
s32 viewX
the tile column of the slots' left edge
s32 frameSectors
a tile's sectors on the CD
MapTile * tiles
width * height
Vec2 *(* getSize)(struct MapStreamer *)
in pixels (FIELDSTG_getMapSize)
void(* nextState)(struct MapStreamer *task)
void(* nextSubstate)(struct MapStreamer *task)
MapFileHeader * header
the map file's, while it is read
s32 width
in 128-pixel tiles
s32 file
the map's tiles, read from the CD (FieldState.mapFile)
u8 viewTiles[30]
by the slots around the view, their tiles
A tile of the map that MapStreamer streams.
s32 size
its bytes on the CD, 0 for none
s32 sectors
what it reads (StreamTask.seek)
The StreamTasks of a task's children (FIELDSTG_requestTiles)
Decompressor * decompressor
A task that reads the frames of a file from the disc (FIELDSTG_createStream)
s32(* getFrame)(struct StreamTask *task)
s32(* getSlot)(struct StreamTask *task)
void(* seek)(struct StreamTask *task, s32 frame, s32 size)
void(* setSource)(struct StreamTask *task, s32 slot, Decompressor *source)
void(* updateTime)(struct StreamTask *task)
void(* draw)(struct StreamTask *task, Layer *layer, s32 x, s32 y)
s32(* isLoaded)(struct StreamTask *task)
s32 loadedTime
when its read ended, 0 while reading
void *(* find)(s32 id, s32 key1, s32 key2)
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
The next free primitive of the packet buffer (getPrim), written as the kind that is drawn next.