Alchemy
Loading...
Searching...
No Matches

world_map.c

Go to the documentation of this file.
1/// @file
2/// The world map: its perspective view, its tiles, and the still picture of
3/// the view BG1 shows while a menu or event runs.
4/// Part of field.c, the field object, compiled only through it.
5
6#include "../field_internal.h"
7
8/// Writes a halfword register (value first).
9static __inline__ void Io_Set16(s32 value, volatile u16 *reg) { *reg = value; }
10
11/// Writes a halfword register (register first).
12static __inline__ void Io_Put16(volatile u16 *reg, s32 value) { *reg = value; }
13
14typedef s32 (*WorldMapPlaneFn)(void *camera, s32 *position, void *lines,
15 void *out);
16
17/// One 32-pixel cell of the world map: its tile, its kind (21 selects the
18/// second graphics set) and a flag.
20 u32 tile : 24;
21 u32 kind : 7;
22 u32 flag : 1;
23};
24
25#define WORLD_MAP_BG_PALETTE ((s16 *)BG_PLTT)
26
27#define WORLD_MAP_CELLS ((struct WorldMapCell *)Ram_MapBlocks)
28
29/// Loads world map tile `tile` into quarter (x & 1, y & 1) of a layer's block
30/// buffer, decompressing it from the area's graphics, and with update set
31/// also draws it into the layer's BG map. Returns 0 when that quarter already
32/// shows the tile (and update is 0), else 1.
33///
34/// Called by Map_UpdateCurrentTileBlock and Map_SetWindowCellTile (update
35/// 1) and by Map_PreloadCurrentTileBlock (update 0). Sets the quarter's entry
36/// in perspective->quarterTiles, and borrows heap slot 14 for the decoded
37/// tile.
38s32 Map_WriteLayerCellTile(s32 layer, s32 x, s32 y, s32 tile, s32 update) {
39 struct PerspectiveWork *perspective = gMapWork[0];
40 u32 *tileOffsets = perspective->tiles;
41 u16 *shownQuarter;
42 u16 *decodedTile;
43 u16 *sourceTiles;
44 u8 *quarterCells;
45 u16 *screenTiles;
46 u32 rowIndex;
47 u32 columnIndex;
48 u32 metatileId;
49
50 x &= 1;
51 y &= 1;
52 shownQuarter = &perspective->quarterTiles[(layer * 2 + y) * 2 + x];
53 if (update == 0 && tile == *shownQuarter)
54 return 0;
55 *shownQuarter = tile;
56 decodedTile = Runtime_AllocateHeapBlock(14, 0x400);
57 Resource_DecodeByteLz((u8 *)tileOffsets + tileOffsets[tile], decodedTile);
58
59 // A tile is 16 by 16 cells of 4 bytes. Each layer's block buffer holds
60 // 2 by 2 tiles, 32 cells (128 bytes) to a row, so each of the tile's rows
61 // goes 64 bytes (16 words) at a time.
62 sourceTiles = decodedTile;
63 quarterCells = Ram_MapBlocks + (((layer * 2 + y) * 32 + x) << 6);
64 for (rowIndex = 0; rowIndex < 16; rowIndex++) {
65 Dma_Set(sourceTiles, quarterCells, (DMA_ENABLE | DMA_32BIT) << 16 | 0x10,
66 REG_DMA3);
67 sourceTiles += 32;
68 quarterCells += 128;
69 }
70
71 // The affine BG map has one byte a tile, 64 to a row: each cell's first
72 // halfword picks a block from Ram_MapCellBuffer, whose two halfwords are
73 // its top two tiles and its bottom two, a row (64 bytes) below.
74 if (update != 0) {
75 screenTiles =
76 (u16 *)(BG_SCREEN_BLOCK(8) + ((((layer * 2 + y) << 6) + x) << 5));
77 sourceTiles = decodedTile;
78 for (rowIndex = 0; rowIndex < 16; rowIndex++) {
79 for (columnIndex = 0; columnIndex < 16; columnIndex++) {
80 u16 *bottomTiles;
81
82 metatileId = *sourceTiles;
83 screenTiles[0] = *(u16 *)(Ram_MapCellBuffer + metatileId * 4);
84 bottomTiles = (u16 *)(Ram_MapCellBuffer + 2);
85 bottomTiles = (u16 *)((u8 *)bottomTiles + metatileId * 4);
86 screenTiles[32] = *bottomTiles;
87 screenTiles++;
88 sourceTiles += 2;
89 }
90 screenTiles += 48;
91 }
92 }
94 return 1;
95}
96
97// UB: no value is returned, and run_scene.c ignores it; as void, the epilogue
98// changes.
99/// Sets up the world map's perspective view: BG2 and BG3 in affine mode, the
100/// camera work, the projection, the per-scanline ground plane routine in RAM
101/// (Transform_UpdateVertices) and its first frame, and the per-frame view and
102/// HBlank updates.
103///
104/// Called through Map_InitializePerspectiveSceneFar when the world map scene
105/// starts (run_scene.c). Allocates and clears the perspective work in
106/// HEAP_SLOT_MAP, the camera in HEAP_SLOT_CAMERA and the affine pages in heap
107/// slot 7; loads the default cells, block attributes and tile animations;
108/// writes the blend, BG and affine registers and REG_DISPCNT (mode 2); and
109/// registers WorldMap_UpdateView and MapAnimation_ApplyAffineFrame with the
110/// scheduler.
111#ifdef UBFIX
113#else
115#endif
116 struct PerspectiveWork *perspective;
117 struct BattleCamera *camera;
118 struct MapFrameWork *frameWork;
119 struct MapAffinePair(*affinePages)[160];
120 s32 *cameraPosition;
121 s32 *distance;
122 u16 *yaw;
123 u16 *pitch;
124 u16 *zoomTransitionFrames;
125 /* FAKEMATCH(volatile): the fill word is this function's own volatile local,
126 * filled by Dma_Fill32Cell, so it takes the native frame slot at sp+28; as
127 * Dma_Fill32, 2 of 331 instructions differ in tbs-en. */
128 volatile u32 fill;
129 struct FixedPointPosition eyeOffset;
130 s32 farPlane;
131 s32 tileIndex;
132
133 // Hide the backgrounds and sprites while their memory is replaced.
137 perspective =
139 Dma_Fill32Cell(fill, 0, perspective, sizeof(struct PerspectiveWork));
140 perspective->viewX = 0;
141 perspective->viewY = 0;
142 perspective->scaleX = 0x200000;
143 perspective->scaleY = 0x400000;
144 perspective->limitX = 0x1fe00000;
145 perspective->limitY = 0x1fe00000;
146 perspective->script = NULL;
147 perspective->tiles =
151 Ram_MapCollision + 0x1000);
155 &REG_BLDCNT);
157 REG_BLDY = 0;
164 // The ground is BG3 and BG2, two 512-pixel affine layers that wrap (char
165 // blocks 2 and 3, screen blocks 8 and 10); BG1 is a plain layer on screen
166 // block 5. The affine matrices start as the identity (0x100 is 1.0).
167 perspective->fade = 0x1f00;
168 perspective->fadeStep = 0x80;
171 &REG_BG3CNT);
174 &REG_BG2CNT);
176 Io_Write16(0x100, &REG_BG2PA);
177 REG_BG2PB = 0;
178 REG_BG2PC = 0;
179 /* FAKEMATCH(one-pass): its loop notes keep the 0x100 for BG2PD built just
180 * before its store and the 12 for Runtime_AllocateBlock loaded before the 76;
181 * as plain statements, 3 of 331 instructions differ in tbs-en. */
182 do {
183 Io_Put16(&REG_BG2PD, 0x100);
184 REG_BG2X = 0;
185 REG_BG2Y = 0;
186 Io_Put16(&REG_BG3PA, 0x100);
187 REG_BG3PB = 0;
188 REG_BG3PC = 0;
189 Io_Put16(&REG_BG3PD, 0x100);
190 REG_BG3X = 0;
191 REG_BG3Y = 0;
192 } while (0);
193
194 camera = Runtime_AllocateBlock(HEAP_SLOT_CAMERA, sizeof(struct BattleCamera));
195 frameWork = Runtime_AllocateHeapBlock(7, sizeof(struct MapFrameWork));
196 cameraPosition = camera->pos;
197 affinePages = frameWork->pages;
198 farPlane = 0x1fe0000;
199 perspective->farPlane = farPlane;
200 distance = &perspective->distance;
201 *distance = farPlane;
202 perspective->zoom = 0x10000;
203 zoomTransitionFrames = &perspective->zoomTransitionFrames;
204 camera->unk18 = 0;
205 camera->followPos = 0;
206 *zoomTransitionFrames = 0;
207 // A first view from the origin at pitch and yaw 0, so the scanline
208 // table and the first affine page exist before the first frame; the
209 // projection's centre is 120 by 96, as on the layered maps.
210 gProjection.centerX = 120;
211 gProjection.centerY = 96;
212 Projection_Set(farPlane, farPlane >> 1, farPlane << 1);
213 SET_VECTOR(cameraPosition, 0, 0, 0);
215 SceneTransform_ApplyPosition(cameraPosition);
216 yaw = &perspective->yaw;
218 pitch = &perspective->pitch;
220 eyeOffset.x = 0;
221 eyeOffset.y = 0;
222 eyeOffset.z = farPlane;
223 Iwram_TransformVector(&eyeOffset, (s32 *)camera);
225 Transform_SetLookAt(camera->eye, cameraPosition);
228 Iwram_RatioMulQ14(Trig_Cos(*pitch), Trig_Sin(*pitch)), cameraPosition,
229 frameWork->scanlines);
230 gScanlineAngle = 0;
231 gScanlinePitch = perspective->pitch;
232 ((WorldMapPlaneFn)gWorkSlot[46])(camera, cameraPosition, frameWork->scanlines,
233 affinePages[gFrameCount & 1]);
234 // Then the world map's own view: pitch 0xe000 (minus an eighth of a
235 // turn) and yaw 0, with the eye one pixel beyond the distance.
236 SET_VECTOR(cameraPosition, 0, 0, 0);
238 Io_Put16(pitch, 0xe000);
239 *yaw = 0;
241 SceneTransform_ApplyPosition(cameraPosition);
244 eyeOffset.x = 0;
245 eyeOffset.y = 0;
246 eyeOffset.z = *distance + 0x10000;
247 Iwram_TransformVector(&eyeOffset, camera->eye);
248 REG_MOSAIC = 0;
250 gBgScroll[1].x = 0;
251 gBgScroll[1].y = 0;
252 gBgScroll[2].x = 0;
253 gBgScroll[2].y = 0;
254 gBgScroll[3].x = 0;
255 gBgScroll[3].y = 0;
256 // Rows 0 to 159: the whole screen shows the perspective view.
257 perspective->windowTop = 0;
258 perspective->windowBottom = 159;
261 // Each of the 16 by 16 grid cells starts on the tile of its own number.
262 for (tileIndex = 255; tileIndex >= 0; tileIndex--)
263 perspective->tileIds[tileIndex] = tileIndex;
264}
265
266/// Puts world map tile (x / 16, y / 16) at cell (px / 16, py / 16) of the
267/// tile id grid, and draws it at once when it is next to the view. Layer 1
268/// takes the tile 0x140 (320) further on. Called by the world map scene
269/// (FieldMap_SetWindowCellTile, through Map_SetWindowCellTileFar). Sets
270/// perspective->tileIds.
272 struct PerspectiveWork *perspective;
273 s32 *followedPosition;
274 s32 originX;
275 s32 originY;
276 s32 tileId;
277
278 perspective = gMapWork[0];
279 originX = 0;
280 originY = 0;
281 followedPosition = perspective->origin;
282 if (followedPosition != 0) {
283 originX = *followedPosition++;
284 originY = followedPosition[1];
285 }
286
287 originX >>= 24;
288 originY >>= 24;
289 x >>= 4;
290 y >>= 4;
291 px >>= 3;
292 py >>= 3;
293 tileId = (y << 4) + x;
294 perspective->tileIds[(((py / 2) & 15) << 4) + ((px / 2) & 15)] = tileId;
295
296 if (ABS(originX - px) <= 1 && ABS(originY - py) <= 1) {
297 Map_WriteLayerCellTile(0, px / 2, py / 2, tileId, 1);
298 Map_WriteLayerCellTile(1, px / 2, py / 2, tileId + 0x140, 1);
299 }
300}
301
302/// Loads the world map's palette and tiles for the area at (x, z): the second
303/// set where the ground there is terrain kind 21. Fills the BG maps, and for
304/// the second set swaps in its own tiles at ids 10-12 and 26-28.
305///
306/// Called through WorldMap_LoadGraphicsFar when the world map scene starts,
307/// with the party's position (run_scene.c). Sets perspective->resources,
308/// which Map_LoadAreaGraphics reloads from; writes BG palette colours 1 to
309/// 223 (keeping the backdrop), char blocks 2 and 3, gMapLayerData and screen
310/// blocks 5 and 6.
312 struct PerspectiveWork *perspective;
313 u32 *resources;
314 u8 *buffer;
315 u8 *tiles;
316 u32 *screenTiles;
317 u32 tilePair;
318 s32 graphicsSet;
319 s32 screenRow;
320 s32 screenColumn;
321 s16 backdropColor;
322
323 graphicsSet = 0;
324 buffer = MemAlloc(0x200);
325 perspective = gMapWork[0];
326 if (WORLD_MAP_CELLS[((x / 0x200000) & 31) + (((z / 0x200000) & 31) << 5)]
327 .kind == 21)
328 graphicsSet = 1;
330 perspective->resources = resources;
331 backdropColor = WORLD_MAP_BG_PALETTE[0];
333 *(s16 *)buffer = backdropColor;
334 Dma_Set(buffer, WORLD_MAP_BG_PALETTE, (DMA_ENABLE | DMA_32BIT) << 16 | 0x70,
335 REG_DMA3);
338 Dma_Set(tiles, BG_CHAR_BLOCK(2), (DMA_ENABLE | DMA_32BIT) << 16 | 0x800,
339 REG_DMA3);
341 Ram_BgTileBuffer + 0x2000);
342 Dma_Set(Ram_BgTileBuffer + 0x2000, BG_CHAR_BLOCK(2) + 0x2000,
343 (DMA_ENABLE | DMA_32BIT) << 16 | 0x800, REG_DMA3);
345 Ram_BgTileBuffer + 0x4000);
347 (DMA_ENABLE | DMA_32BIT) << 16 | 0x800, REG_DMA3);
349 Ram_BgTileBuffer + 0x6000);
350 Dma_Set(Ram_BgTileBuffer + 0x6000, BG_CHAR_BLOCK(3) + 0x2000,
351 (DMA_ENABLE | DMA_32BIT) << 16 | 0x800, REG_DMA3);
353 // BG1's map (screen block 5) is filled with tile 0x7f of palette 15, and
354 // screen block 6 numbers a 30 by 20 tile picture from tile 0x1a8, two
355 // tile numbers a word, for the still view WorldMap_BeginStillView shows.
356 Dma_Fill32(0xf07ff07f, BG_SCREEN_BLOCK(5), 0x600);
357 screenTiles = (u32 *)BG_SCREEN_BLOCK(6);
358 tilePair = 0x01a901a8;
359 for (screenRow = 0; screenRow < 20; screenRow++) {
360 for (screenColumn = 0; screenColumn < 15; screenColumn++) {
361 *screenTiles++ = tilePair;
362 tilePair += 0x00020002;
363 }
364 screenTiles++;
365 }
366 if (graphicsSet == 1) {
367 perspective->tileIds[10] = 0x10a;
368 perspective->tileIds[11] = 0x10b;
369 perspective->tileIds[12] = 0x10c;
370 perspective->tileIds[26] = 0x11a;
371 perspective->tileIds[27] = 0x11b;
372 perspective->tileIds[28] = 0x11c;
374 }
375 MemFree(buffer);
376}
377
378/// HBlank setup each frame on the world map: copies the first scanline's BG2
379/// and BG3 affine parameters, starts the HBlank DMA for the rest, and picks
380/// the BG mode from the window's top and bottom.
381///
382/// Registered with the scheduler by Map_InitializePerspectiveScene (priority
383/// 0x480). Reads this frame's affine page (gFrameCount & 1), restarts DMA 0,
384/// sets shownTop and shownBottom, writes REG_DISPCNT's mode and clears
385/// windowPending.
387 struct MapAffinePair(*affinePages)[160] =
388 ((struct MapFrameWork *)WORK_SLOT(7))->pages;
389 s32 displayControl = (s16)(REG_DISPCNT & 0xfff8);
390 u32 *affineRegisters = (u32 *)&REG_BG2PA;
391 struct PerspectiveWork *perspective = WORK_SLOT(HEAP_SLOT_MAP);
392 volatile u16 *dma0 = REG_DMA0;
393 u32 *affineSource;
394 u32 mode;
396 u32 nextDisplayControl;
397
398 // Stop last frame's HBlank DMA, then load line 0's eight words (BG2PA to
399 // BG3Y) by hand; the DMA repeats eight words into the same registers at
400 // each HBlank for the lines after it.
402 dma0[5] &= ~DMA_ENABLE;
403 (void)dma0[5];
404 if (affinePages != NULL) {
405 affineSource = (u32 *)affinePages[gFrameCount & 1];
406 *affineRegisters++ = *affineSource++;
407 *affineRegisters++ = *affineSource++;
408 *affineRegisters++ = *affineSource++;
409 *affineRegisters++ = *affineSource++;
410 *affineRegisters++ = *affineSource++;
411 *affineRegisters++ = *affineSource++;
412 *affineRegisters++ = *affineSource++;
413 *affineRegisters = *affineSource++;
414 Dma_Set(affineSource, (void *)&REG_BG2PA,
417 << 16 |
418 8,
419 (volatile u32 *)dma0);
420 }
421 perspective->shownTop = perspective->windowTop;
422 perspective->shownBottom = perspective->windowBottom;
423 // Mode 2 (the affine ground) for the load's rows 0 to 159; mode 0 for
424 // WorldMap_BeginStillView's 200 and 255, which show the still view on BG1.
425 windowTop = perspective->shownTop;
426 mode = 0;
427 if (windowTop < 200) {
428 u16 bottom = perspective->shownBottom;
429
430 mode = (bottom != 0) << 1;
431 if (windowTop <= bottom) {
432 mode = 0;
433 if (windowTop == 0)
434 mode = 2;
435 }
436 }
437 displayControl |= mode;
438 nextDisplayControl = (u16)displayControl;
439 REG_DISPCNT = nextDisplayControl;
440 perspective->windowPending = 0;
441}
442
443/// Copies one world map cell's two tile entries (top and bottom) to a BG map.
444static __inline__ void WorldMap_CopyCellTiles(u8 *cellBytes, u8 *screenTile) {
445 u32 metatileIndex = *(u16 *)cellBytes;
446 u16 *metatileTiles = (u16 *)Ram_MapCellBuffer;
447
448 metatileTiles += metatileIndex * 2;
449 *(u16 *)screenTile = *metatileTiles++;
450 *(u16 *)(screenTile + 64) = *metatileTiles;
451}
452
453/// Draws world map tileRow into the BG map: 32 cells, then 32
454/// more a screen block on. Called by WorldMap_UpdateView when the view
455/// crosses a row.
457 u8 *sourceCell;
458 u8 *screenTile;
459 u32 cellsCopied;
460
461 sourceCell = Ram_MapBlocks + ((((s32)tileRow / 2) & 31) << 7);
462 screenTile = (u8 *)((u32)BG_SCREEN_BLOCK(8) + ((tileRow & 62) << 6));
463 cellsCopied = 0;
464 do {
465 WorldMap_CopyCellTiles(sourceCell, screenTile);
466 cellsCopied++;
467 screenTile += 2;
468 sourceCell += 4;
469 } while (cellsCopied <= 31);
470
471 screenTile += 0xfc0;
472 sourceCell += 0xf80;
473 cellsCopied = 0;
474 do {
475 WorldMap_CopyCellTiles(sourceCell, screenTile);
476 cellsCopied++;
477 screenTile += 2;
478 sourceCell += 4;
479 } while (cellsCopied <= 31);
480}
481
482/// Draws world map tileColumn into the BG map: 64 cells down. Called by
483/// WorldMap_UpdateView when the view crosses a column.
485 u8 *sourceCell;
486 u8 *screenTile;
487 u32 cellsCopied;
488
489 sourceCell = Ram_MapBlocks + ((((s32)tileColumn / 2) & 31) << 2);
490 screenTile = (u8 *)((u32)BG_SCREEN_BLOCK(8) + (tileColumn & 62));
491 cellsCopied = 0;
492 do {
493 WorldMap_CopyCellTiles(sourceCell, screenTile);
494 cellsCopied++;
495 screenTile += 128;
496 sourceCell += 128;
497 } while (cellsCopied <= 63);
498}
499
500/// Each frame on the world map: loads tiles as the view moves, shakes and
501/// follows the player, draws the BG row or column that scrolls into view,
502/// moves the camera, and builds the ground plane's scanline table.
503///
504/// Registered with the scheduler by Map_InitializePerspectiveScene (priority
505/// 0xc85, as Map_UpdateLayerScroll is on layered maps). Sets viewX and viewY,
506/// decays the shake, moves the camera and its eye, and runs
507/// Transform_UpdateVertices from heap slot 46 into this frame's affine page.
509 struct BattleCamera *camera = WORK_SLOT(HEAP_SLOT_CAMERA);
510 struct MapFrameWork *frameWork = WORK_SLOT(7);
511 struct PerspectiveWork *perspective = WORK_SLOT(HEAP_SLOT_MAP);
512 s32 *cameraPosition = camera->pos;
513 s32 *followedPosition = perspective->origin;
514 struct MapAffinePair(*affinePages)[160] = frameWork->pages;
515 s32 distance = perspective->farPlane;
516 s32 height = perspective->distance;
517 struct FixedPointPosition eyeOffset;
518
520 if (followedPosition != NULL) {
521 s32 x;
522 s32 y;
523 s32 tileColumn;
524 s32 tileRow;
525
526 y = followedPosition[2];
527 x = followedPosition[0];
528 if (perspective->shakeX != 0) {
529 s32 shakeDifference = Random16();
530 s32 shakeAmplitude;
531
532 shakeDifference -= Random16();
533 shakeAmplitude = perspective->shakeX;
534 x += Iwram_MulQ16(shakeAmplitude, shakeDifference);
535 perspective->shakeX =
536 Iwram_MulQ16(shakeAmplitude, perspective->shakeDecay);
537 }
538 if (perspective->shakeY != 0) {
539 s32 shakeDifference = Random16();
540 s32 shakeAmplitude;
541
542 shakeDifference -= Random16();
543 shakeAmplitude = perspective->shakeY;
544 y += Iwram_MulQ16(shakeAmplitude, shakeDifference);
545 perspective->shakeY =
546 Iwram_MulQ16(shakeAmplitude, perspective->shakeDecay);
547 }
548 // On crossing a 16-pixel line, draw the column 16 on that side, or the
549 // row 12 on when y grows and 18 back when it falls.
550 tileColumn = x / 0x100000;
551 tileRow = y / 0x100000;
552 if ((perspective->viewX ^ x) & 0x100000) {
553 if (perspective->viewX < x)
554 Map_RenderPaletteMappedColumn(tileColumn + 16);
555 else
556 Map_RenderPaletteMappedColumn(tileColumn - 16);
557 }
558 if ((perspective->viewY ^ y) & 0x100000) {
559 if (perspective->viewY < y)
560 Map_RenderPaletteMappedRow(tileRow + 12);
561 else
562 Map_RenderPaletteMappedRow(tileRow - 18);
563 }
564 perspective->viewX = x;
565 perspective->viewY = y;
566 }
567 // Rebuild the projection and look at the followed position from the
568 // current pitch and yaw, the eye one pixel beyond the zoomed distance.
569 // XXX: followedPosition is read here without the NULL test above; whether
570 // the world map can run without a followed point would settle if that is
571 // safe.
572 gProjection.centerX = 120;
573 gProjection.centerY = 96;
574 Projection_Set(distance, height / 2, height * 2);
575 SET_VECTOR(cameraPosition, *followedPosition++, 0, followedPosition[1]);
577 SceneTransform_ApplyPosition(cameraPosition);
578 SceneTransform_ApplyYaw(perspective->yaw);
579 SceneTransform_ApplyPitch(perspective->pitch);
580 eyeOffset.x = 0;
581 eyeOffset.y = 0;
582 eyeOffset.z = height + 0x10000;
583 Iwram_TransformVector(&eyeOffset, (s32 *)camera);
585 Transform_SetLookAt(camera->eye, cameraPosition);
586 // The scanline table depends only on the pitch, so it is rebuilt only when
587 // the pitch has changed.
588 if (gScanlinePitch != perspective->pitch) {
589 s32 cosine = Trig_Cos(perspective->pitch);
590 s32 sine = Trig_Sin(perspective->pitch);
591
592 WorldMap_BuildScanlineTable(Iwram_RatioMulQ14(cosine, sine), cameraPosition,
593 frameWork->scanlines);
594 gScanlineAngle = 0;
595 gScanlinePitch = perspective->pitch;
596 }
597 ((s32 (*)(void *, s32 *, void *, void *))gWorkSlot[46])(
598 camera, cameraPosition, frameWork->scanlines,
599 affinePages[gFrameCount & 1]);
600}
601
602/// Loads and draws the 2x2 world map tiles around the player in both layers.
603/// Called through Map_UpdateCurrentTileBlockFar when the world map scene
604/// starts, by WorldMap_LoadGraphics for the second graphics set, and by
605/// Map_LoadAreaGraphics and Map_LoadDefaultCellsAndUpdateBlock after the
606/// still view.
608 struct PerspectiveWork *perspective = gMapWork[0];
609 s32 firstQuarterX = 0;
610 s32 firstQuarterY = 0;
611 u32 layer;
612 u32 row;
613 u32 col;
614 s32 layerTileBase;
615 s32 tileId;
616
617 if (perspective->origin != NULL) {
618 s32 *followedPosition = perspective->origin;
619
620 firstQuarterX = *followedPosition++;
621 firstQuarterY = followedPosition[1];
622 }
623 // The top left of the 2x2 tiles (512 pixels each, >> 25) around the
624 // point, 256 pixels left of it and 320 above.
625 firstQuarterX = (firstQuarterX - 0x1000000) >> 25;
626 firstQuarterY = (firstQuarterY - 0x1400000) >> 25;
627 layer = 0;
628 layerTileBase = 0;
629 for (; layer < 2; layer++) {
630 for (row = 0; row < 2; row++) {
631 for (col = 0; col < 2; col++) {
632 tileId =
633 (((firstQuarterY + row) & 15) << 4) + ((firstQuarterX + col) & 15);
634 tileId = perspective->tileIds[tileId];
635 tileId += layerTileBase;
636 Map_WriteLayerCellTile(layer, firstQuarterX + col, firstQuarterY + row,
637 tileId, 1);
638 }
639 }
640 layerTileBase += 320;
641 }
642}
643
644/// Loads the first of the 2x2 world map tiles around the player that is not
645/// shown yet (at most one a frame), without drawing it. Called at the start of
646/// each WorldMap_UpdateView, so tiles come in one a frame as the player
647/// walks.
649 struct PerspectiveWork *perspective = gMapWork[0];
650 s32 firstQuarterX = 0;
651 s32 firstQuarterY = 0;
652 u32 layer;
653 u32 row;
654 u32 col;
655 s32 tileId;
656
657 if (perspective->origin != NULL) {
658 s32 *followedPosition = perspective->origin;
659
660 firstQuarterX = *followedPosition++;
661 firstQuarterY = followedPosition[1];
662 }
663 firstQuarterX = (firstQuarterX - 0x1000000) >> 25;
664 firstQuarterY = (firstQuarterY - 0x1400000) >> 25;
665 for (layer = 0; layer < 2; layer++) {
666 for (row = 0; row < 2; row++) {
667 for (col = 0; col < 2; col++) {
668 tileId =
669 (((firstQuarterY + row) & 15) << 4) + ((firstQuarterX + col) & 15);
670 tileId = perspective->tileIds[tileId];
671 tileId += layer * 320;
672 if (Map_WriteLayerCellTile(layer, firstQuarterX + col,
673 firstQuarterY + row, tileId, 0) != 0)
674 return;
675 }
676 }
677 }
678}
679
680/// VBlank: shows BG1 and copies the decoded frame's tiles into VRAM. The
681/// frame is the still view WorldMap_BeginStillView draws: 0x2580 words, 240 by
682/// 160 pixels at a byte each, shown as 256-colour tiles on screen block 6. Set
683/// as gVBlankHook by WorldMap_BeginStillView.
686 &REG_BG1CNT);
688 (DMA_ENABLE | DMA_32BIT) << 16 | 0x2580, REG_DMA3);
689}
690
691/// Freezes the world map's perspective view as a still picture on BG1:
692/// saves BG1's tiles, draws the current affine frame into pixels and hands
693/// the window and VBlank to it.
694///
695/// Called through WorldMap_BeginStillViewFar by WorldMap_BeginEvent
696/// when a menu or event starts on the world map, and by the world map
697/// scene's lighthouse transition. Sets animationActive, suspends the tile
698/// animations (MapAnimation_Update), copies 8 KB of char block 1 to
699/// gDecodeBuffer, sets the window rows to 200 and 255 (BG mode 0) and sets
700/// gVBlankHook to MapAnimation_PresentFrame. Map_LoadAreaGraphics undoes it.
702 struct MapFrameWork *frameWork = WORK_SLOT(7);
703 struct PerspectiveWork *perspective = WORK_SLOT(HEAP_SLOT_MAP);
704 s32 one = 1;
705
706 perspective->animationActive = one;
709 (DMA_ENABLE | DMA_32BIT) << 16 | 0x800, REG_DMA3);
710 WaitFrames(1);
711 TileMap_DrawRowsFromRam(frameWork->pages[gFrameCount & one],
712 (u8 *)gMapCellBuffer);
713 perspective->windowTop = 200;
714 perspective->windowBottom = 255;
716}
717
718/// VBlank: shows BG1 and copies the area's tiles back into VRAM. Restores
719/// BG1CNT as Map_InitializePerspectiveScene set it, and the 32 KB of char
720/// blocks 2 and 3 the still view overwrote, from gBgTileBuffer. Set as
721/// gVBlankHook by Map_LoadAreaGraphics and Map_LoadDefaultCellsAndUpdateBlock.
725 (DMA_ENABLE | DMA_32BIT) << 16 | 0x2000, REG_DMA3);
726}
727
728/// Reloads the world map area's palette and tiles after the still view, puts
729/// the default cells back and returns to the perspective view.
730///
731/// Called through Map_LoadAreaGraphicsFar by
732/// WorldMap_EndEvent when a menu or event ends, by
733/// Map_ShowWorldMap, and by the world map scene's lighthouse transition.
734/// Decodes into gMapCellBuffer and gBgTileBuffer, sets gVBlankHook to
735/// Map_ShowBg1FromBuffer, sets the window rows back to 0 and 159, clears
736/// animationActive and resumes the tile animations. Waits two frames.
738 struct PerspectiveWork *perspective;
739 u32 *graphicsResources;
740 u8 *decodeBuffer;
741 s16 backdropColor;
742
743 perspective = gMapWork[0];
744 decodeBuffer = (u8 *)gMapCellBuffer;
745 graphicsResources = perspective->resources;
746 backdropColor = *(s16 *)BG_PLTT;
747 Resource_DecodeByteLz(Resource_GetTableEntry(graphicsResources[0]),
748 decodeBuffer);
749 *(s16 *)decodeBuffer = backdropColor;
750 Dma_Set(decodeBuffer, (void *)BG_PLTT, (DMA_ENABLE | DMA_32BIT) << 16 | 0x70,
751 REG_DMA3);
752 Resource_DecodeType01(Resource_GetTableEntry(graphicsResources[1]),
754 Resource_DecodeType01(Resource_GetTableEntry(graphicsResources[2]),
755 Ram_BgTileBuffer + 0x2000);
756 Resource_DecodeType01(Resource_GetTableEntry(graphicsResources[3]),
757 Ram_BgTileBuffer + 0x4000);
758 Resource_DecodeType01(Resource_GetTableEntry(graphicsResources[4]),
759 Ram_BgTileBuffer + 0x6000);
760 // The VBlank copies the tiles back and the next frame shows the ground;
761 // only then is the still picture's buffer refilled with the cells.
763 perspective->windowTop = 0;
764 perspective->windowBottom = 159;
765 WaitFrames(1);
769 perspective->animationActive = 0;
771 WaitFrames(1);
772}
773
774/// Puts the default world map cells back after the still view and returns
775/// to the perspective view, without reloading the area's palette or tiles.
776/// Called three times by the world map scene's events. Unlike
777/// Map_LoadAreaGraphics it leaves animationActive set.
778/// XXX: whether leaving animationActive set is intended; a scene that calls
779/// it and then opens a menu would show the effect.
781 struct PerspectiveWork *perspective = gMapWork[0];
783 perspective->windowTop = 0;
784 perspective->windowBottom = 159;
785 WaitFrames(1);
790 WaitFrames(1);
791}
792
793#undef WORLD_MAP_BG_PALETTE
794#undef WORLD_MAP_CELLS
#define Dma_Fill32Cell(cell, value, destination, size)
Dma_Fill32 through the caller's own volatile word cell, so a function that fills several blocks keeps...
Definition dma.h:42
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
Definition dma.h:62
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
Definition dma.h:30
void Fade_FromBlack(s32 frames)
Fades in from black.
Definition fade.c:79
void TileMap_DrawRowsFromRam(const struct MapAffinePair *lines, u8 *pixels)
Draws the current affine page into the world map's still-view pixels.
Definition view.c:64
void WorldMap_BuildScanlineTable(s32 pitchSlope, s32 *position, struct MapScanline *scanline)
Rebuilds the ground plane's scanline terms when the world map pitch changes.
Definition view.c:88
void Map_ShowBg1FromBuffer(void)
VBlank: shows BG1 and copies the area's tiles back into VRAM.
Definition world_map.c:722
static __inline__ void Io_Set16(s32 value, volatile u16 *reg)
Writes a halfword register (value first).
Definition world_map.c:9
void Map_RenderPaletteMappedColumn(u32 tileColumn)
Draws world map tileColumn into the BG map: 64 cells down.
Definition world_map.c:484
s32 Map_InitializePerspectiveScene(void)
Sets up the world map's perspective view: BG2 and BG3 in affine mode, the camera work,...
Definition world_map.c:114
void WorldMap_UpdateView(void)
Each frame on the world map: loads tiles as the view moves, shakes and follows the player,...
Definition world_map.c:508
void Map_LoadAreaGraphics(void)
Reloads the world map area's palette and tiles after the still view, puts the default cells back and ...
Definition world_map.c:737
void Map_SetWindowCellTile(s32 x, s32 y, s32 px, s32 py)
Puts world map tile (x / 16, y / 16) at cell (px / 16, py / 16) of the tile id grid,...
Definition world_map.c:271
static __inline__ void Io_Put16(volatile u16 *reg, s32 value)
Writes a halfword register (register first).
Definition world_map.c:12
#define WORLD_MAP_BG_PALETTE
Definition world_map.c:25
void MapAnimation_ApplyAffineFrame(void)
HBlank setup each frame on the world map: copies the first scanline's BG2 and BG3 affine parameters,...
Definition world_map.c:386
s32(*) WorldMapPlaneFn(void *camera, s32 *position, void *lines, void *out)
Definition world_map.c:14
#define WORLD_MAP_CELLS
Definition world_map.c:27
void Map_UpdateCurrentTileBlock(void)
Loads and draws the 2x2 world map tiles around the player in both layers.
Definition world_map.c:607
void MapAnimation_PresentFrame(void)
VBlank: shows BG1 and copies the decoded frame's tiles into VRAM.
Definition world_map.c:684
void Map_RenderPaletteMappedRow(u32 tileRow)
Draws world map tileRow into the BG map: 32 cells, then 32 more a screen block on.
Definition world_map.c:456
static __inline__ void WorldMap_CopyCellTiles(u8 *cellBytes, u8 *screenTile)
Copies one world map cell's two tile entries (top and bottom) to a BG map.
Definition world_map.c:444
void WorldMap_BeginStillView(void)
Freezes the world map's perspective view as a still picture on BG1: saves BG1's tiles,...
Definition world_map.c:701
void Map_LoadDefaultCellsAndUpdateBlock(void)
Puts the default world map cells back after the still view and returns to the perspective view,...
Definition world_map.c:780
void WorldMap_LoadGraphics(s32 x, s32 z)
Loads the world map's palette and tiles for the area at (x, z): the second set where the ground there...
Definition world_map.c:311
s32 Map_WriteLayerCellTile(s32 layer, s32 x, s32 y, s32 tile, s32 update)
Loads world map tile tile into quarter (x & 1, y & 1) of a layer's block buffer, decompressing it fro...
Definition world_map.c:38
void Map_PreloadCurrentTileBlock(void)
Loads the first of the 2x2 world map tiles around the player that is not shown yet (at most one a fra...
Definition world_map.c:648
u32 gScanlinePitch
u8 Transform_UpdateVerticesSize
What every part of the field object shares: its includes and the few names more than one part uses.
s32 Trig_Cos(s32 angle)
s32 Trig_Sin(s32 angle)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
void(*) gVBlankHook(void)
Run once by the next VBlank handler, which clears it first.
volatile u32 gFrameCount
Frames WaitFrames has finished.
struct EffectStep gMapCellBuffer[]
Map cells; battle effects reuse this as a particle array.
u8 gDecodeBuffer[]
void * gMapWork[]
void * MemAlloc(s32 size)
Allocates size bytes (rounded up to words) with no slot, from IWRAM when they fit and EWRAM otherwise...
Definition heap.c:115
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
Definition heap.c:80
void * Runtime_AllocateHeapBlock(s32 kind, s32 size)
Returns heap slot kind's block, first allocating size bytes for it (rounded up to words),...
Definition heap.c:47
@ HEAP_SLOT_MAP
Definition heap_state.h:36
@ HEAP_SLOT_CAMERA
Definition heap_state.h:38
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
Definition heap_state.h:14
#define REG_BG3PC
Definition io_reg.h:69
#define BGCNT_CHAR_BASE(block)
Definition io_reg.h:25
#define REG_BG3PD
Definition io_reg.h:70
#define BLDCNT_TGT1_BG3
Definition io_reg.h:126
#define BGCNT_256_COLORS
Definition io_reg.h:27
#define BGCNT_PRIORITY(n)
Definition io_reg.h:24
#define BLDCNT_TGT1_OBJ
Definition io_reg.h:127
#define BG_SCREEN_BLOCK(n)
Definition io_reg.h:167
#define REG_BG3CNT
Definition io_reg.h:22
#define REG_BG3PB
Definition io_reg.h:68
#define BLDCNT_TGT1_BG2
Definition io_reg.h:125
#define REG_BG2PD
Definition io_reg.h:64
#define BG_CHAR_BLOCK(n)
Definition io_reg.h:166
#define REG_BG3X
Definition io_reg.h:71
#define REG_DMA0
Definition io_reg.h:151
#define DMA_START_TIMING_DRQ_REPEAT
A DMA control's start timing (bits 12 and 13), cartridge request (bit 11) and repeat (bit 9): the bit...
Definition io_reg.h:220
#define REG_BLDY
Definition io_reg.h:146
#define BGCNT_SIZE(n)
The background's size: for an affine one, 0 to 3 are 128, 256, 512 and 1024 pixels square.
Definition io_reg.h:33
#define REG_BG3PA
Definition io_reg.h:67
@ DISPCNT_OBJ_ON
Definition io_reg.h:44
@ DISPCNT_WIN0_ON
Definition io_reg.h:45
@ DISPCNT_BG3_ON
Definition io_reg.h:43
@ DISPCNT_MODE_2
BG2 and BG3 affine.
Definition io_reg.h:38
@ DISPCNT_OBJ_1D_MAP
Definition io_reg.h:39
@ DISPCNT_BG2_ON
Definition io_reg.h:42
@ DISPCNT_BG1_ON
Definition io_reg.h:41
#define BLDCNT_EFFECT_LIGHTEN
towards white by REG_BLDY
Definition io_reg.h:132
#define REG_BG2PC
Definition io_reg.h:63
#define REG_BG2X
Definition io_reg.h:65
#define DMA_32BIT
Definition io_reg.h:210
#define REG_DISPCNT
Definition io_reg.h:9
#define DMA_DEST_RELOAD
Definition io_reg.h:204
#define DMA_START_HBLANK
Definition io_reg.h:214
#define BLDCNT_TGT2_ALL
Definition io_reg.h:140
#define REG_DMA3
Definition io_reg.h:153
#define REG_BG2Y
Definition io_reg.h:66
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
Definition io_reg.h:145
#define DMA_REPEAT
Definition io_reg.h:208
#define BGCNT_SCREEN_BASE(block)
Definition io_reg.h:28
#define BLDCNT_TGT1_BG1
Definition io_reg.h:124
#define REG_BG2CNT
Definition io_reg.h:21
#define REG_BLDALPHA
Definition io_reg.h:142
#define BG_PLTT
Definition io_reg.h:157
#define REG_BG2PB
Definition io_reg.h:62
#define REG_BG3Y
Definition io_reg.h:72
#define REG_BG2PA
Definition io_reg.h:61
#define REG_BLDCNT
Definition io_reg.h:119
#define REG_BG1CNT
Definition io_reg.h:20
#define REG_MOSAIC
Definition io_reg.h:118
#define DMA_ENABLE
Definition io_reg.h:217
#define BGCNT_WRAP
Affine backgrounds only: wrap around instead of showing the backdrop.
Definition io_reg.h:30
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
Definition iowrite.h:14
static s32 Iwram_RatioMulQ14(s32 divisor, s32 value)
All calls go through this layer.
Definition iwram_call.h:51
#define Iwram_MulQ16(left, right)
Definition iwram_call.h:127
static s32 Iwram_TransformVector(const void *vector, s32 *result)
Definition iwram_call.h:65
#define ABS(v)
The magnitude of v. v is read twice.
Definition macros.h:32
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
Definition macros.h:12
u8 gMapLayerData[]
u8 gBgTileBuffer[]
void MapAnimation_Update(void)
Each frame: runs the 16 tile animation channels.
void MapAnimation_StartChannels(const u16 *script)
Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel ...
struct BgScroll gBgScroll[]
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
void Runtime_ReleaseHeapBlock(s32 slot)
void MemFree(void *buffer)
struct Projection gProjection
#define Ram_MapBlocks
Definition ram_buffer.h:12
#define Ram_MapCollision
Definition ram_buffer.h:13
#define Ram_MapCellBuffer
Definition ram_buffer.h:10
#define Ram_BgTileBuffer
Definition ram_buffer.h:14
#define RamCode_LoadSlot(slot, code, bytes)
Allocates a work-slot copy; release it with Runtime_ReleaseHeapBlock.
Definition ramcode.h:26
char ResourceId_DefaultMetatileAttributes
char ResourceId_DefaultMapAnimation
char ResourceId_PerspectiveDataA
char ResourceId_DefaultMapCells
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
Definition decompress.c:31
s32 Resource_DecodeByteLz(const void *source, void *destination)
Decodes a byte-oriented LZ resource and returns its unpacked byte count.
Definition decompress.c:37
s32 Scheduler_ResumeTasks(SchedulerCallback callback)
Resumes the task running callback, or every task when callback is null, by clearing bit 0 of its orde...
Definition scheduler.c:243
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
Definition scheduler.c:102
s32 Scheduler_SuspendTasks(SchedulerCallback callback)
Suspends the task running callback, or every task when callback is null, by setting bit 0 of its orde...
Definition scheduler.c:172
#define NULL
Definition bilibin.h:6
void * gWorkSlot[]
The battle camera: its eye, the focus it turns about, and its pitch, yaw and distance.
s32 * followPos
when set, the focus followed instead of pos
s32 pos[3]
the focus, 16.16 fixed-point pixels
s32 eye[3]
The eye, 16.16 fixed-point pixels: written each frame distance behind the focus along the turned view...
s32 unk18
cleared beside followPos; not read by name in TBS
u16 y
pixels
Definition map_scroll.h:65
A position in three coordinates, each in 16.16 fixed point.
s32 z
16.16 fixed point
s32 x
16.16 fixed point
s32 y
16.16 fixed point
One screen line's affine parameters for BG2 and BG3.
Definition mapframe.h:27
The world map's frame work in heap slot 7: the scanline terms and two pages of per-line affine parame...
Definition mapframe.h:33
struct MapScanline scanlines[160]
Definition mapframe.h:34
struct MapAffinePair pages[2][160]
Definition mapframe.h:35
The world map's perspective view: the followed position, screen shake, view position,...
Definition perspective.h:12
s32 scaleX
0x200000 at load
Definition perspective.h:21
u16 quarterTiles[8]
The tile each quarter of each layer's block buffer shows, so an unchanged quarter is not decoded agai...
Definition perspective.h:51
s32 farPlane
0x1fe0000 at load
Definition perspective.h:52
u16 windowPending
cleared by the frame update; not set by name
Definition perspective.h:38
u32 * resources
a row of gWorldMap_GraphicsResources, by terrain
Definition perspective.h:46
s8 animationActive
Set by WorldMap_BeginStillView while BG1 shows the drawn map; the tile animations are then neither su...
Definition perspective.h:27
s32 limitY
0x1fe00000 at load
Definition perspective.h:24
s32 zoom
16.16 fixed point, 0x10000 full size
Definition perspective.h:55
s32 limitX
0x1fe00000 at load
Definition perspective.h:23
u8 * script
NULL at load.
Definition perspective.h:15
u16 shownTop
windowTop as the frame update last applied it
Definition perspective.h:36
s32 viewY
16.16 fixed-point pixels
Definition perspective.h:20
u16 tileIds[256]
the world map tile in each of 16 by 16 cells
Definition perspective.h:48
u8 fadeStep
MapScrollWork's wideTiles, 0x80 at load.
Definition perspective.h:17
u16 windowTop
Screen rows, 0 and 159 at load and 200 and 255 from WorldMap_BeginStillView; each frame copies them t...
Definition perspective.h:33
s32 scaleY
0x400000 at load
Definition perspective.h:22
u16 shownBottom
windowBottom as the frame update last applied it
Definition perspective.h:37
void * tiles
The world map's tile offsets (ResourceId_PerspectiveDataA), each tile LZ-compressed.
Definition perspective.h:42
u16 pitch
1/65536 turns
Definition perspective.h:44
u16 fade
MapScrollWork's flags: REG_DISPCNT bits, 0x1f00 at load.
Definition perspective.h:16
s32 * origin
the followed point, as in MapScrollWork
Definition perspective.h:13
s32 shakeDecay
the screen shake, as in MapScrollWork
Definition perspective.h:14
u16 zoomTransitionFrames
a zoom transition's length; 0 when none
Definition perspective.h:56
s32 viewX
16.16 fixed-point pixels
Definition perspective.h:19
u16 yaw
1/65536 turns
Definition perspective.h:45
s32 distance
farPlane scaled by the zoom
Definition perspective.h:53
s32 centerX
screen pixels
Definition project.h:16
s32 centerY
screen pixels
Definition project.h:17
One 32-pixel cell of the world map: its tile, its kind (21 selects the second graphics set) and a fla...
Definition world_map.c:19
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
Definition system.c:150
void SceneTransform_ApplyYaw(s32 angle)
Rotates gTransform about the Y axis by angle.
Definition transform.c:113
void Projection_Set(u32 focal, u32 nearDepth, u32 farDepth)
Sets gProjection's focal length and depth range directly.
Definition transform.c:350
void SceneTransform_ApplyPitch(s32 angle)
Rotates gTransform about the X axis by angle.
Definition transform.c:97
void SceneTransform_ApplyPosition(const s32 *position)
Translates gTransform by position (x, y, z in 16.16).
Definition transform.c:145
void Render_ResetTransformState(void)
Allocates the one-level save area (heap slot HEAP_SLOT_TRANSFORM_STACK), clears gTransformStackDepth ...
Definition transform.c:19
void Transform_SetLookAt(s32 *eye, s32 *target)
Makes the camera at eye looking at target the whole of gTransform.
Definition transform.c:318
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
void Transform_UpdateVertices(struct Position *eye, struct Position *target, struct ScanVertex *line, struct BgAffine *affine)
Builds the world map's per-scanline affine table for one frame: the ground plane seen from eye toward...
Definition vertices.c:88
u32 gScanlineAngle
u32 gWorldMap_GraphicsResources[2][6]
Each set is a palette and five tile sets; WorldMap_LoadGraphics takes the second set when the cell it...