Alchemy
Loading...
Searching...
No Matches

world_map.c

Go to the documentation of this file.
1/// @file
2/// The world map screen: place markers, the cursor and the place name.
3/// Part of psynergy_effects.c, compiled only through it.
4
6
7#define WORLD_MAP_MARKER_TILE_BYTES 0x80
8#define WORLD_MAP_SCREEN_WIDTH 240
9#define WORLD_MAP_SCREEN_HEIGHT 160
10#define WORLD_MAP_WORLD_SIZE 4096
11#define WORLD_MAP_X_ORIGIN PIXELS(4096)
12#define WORLD_MAP_FIRST_PLACE_ACTOR 11
13#define WORLD_MAP_MARKER_CAPACITY 66
14#define WORLD_MAP_CURSOR_PART WORLD_MAP_MARKER_CAPACITY
15#define WORLD_MAP_CURSOR_MIN_SPEED PIXELS(1)
16#define WORLD_MAP_CURSOR_MAX_SPEED PIXELS(6)
17#define WORLD_MAP_CURSOR_ACCELERATION (PIXELS(1) / 8)
18#define WORLD_MAP_MARKER_BLEND_STEPS 32
19#define WORLD_MAP_CURSOR_MIN_X 16
20#define WORLD_MAP_CURSOR_MAX_X (WORLD_MAP_SCREEN_WIDTH - 1)
21#define WORLD_MAP_CURSOR_MAX_Y 141
22
23/// The renderer's linked sprite entry and the three words that initialize it.
27};
28
29#ifdef UBFIX
30#define WORLD_MAP_MARKER_VIEW(marker) ((marker)->sprite)
31#else
32#define WORLD_MAP_MARKER_VIEW(marker) (*(marker))
33#endif
34
36 sizeof(struct AnimationSpritePart));
37
38// BUG: the original reserves 32 bytes but writes and uploads 128. The bump
39// allocator takes bytes, not words; reserve the whole tile buffer with BUGFIX.
40#ifdef BUGFIX
41#define WORLD_MAP_MARKER_ALLOCATION_SIZE WORLD_MAP_MARKER_TILE_BYTES
42#else
43#define WORLD_MAP_MARKER_ALLOCATION_SIZE 32
44#endif
45
46/// Scratch work while Map_ShowWorldMap owns gMapCellBuffer. Setup runs before
47/// the marker task; cleanup removes its window before map graphics reuse it.
49 u16 markerVramBlock; ///< owns the four generated marker tiles
50 u16 cursorVramBlock; ///< owns the cursor picture's tiles
51 union FieldCoordinate cursorX; ///< screen column, 16.16 pixels
52 union FieldCoordinate cursorY; ///< screen row, 16.16 pixels
53 u8 padding0c[6]; ///< not read by this screen
54 s16 namedMarker; ///< actor whose name is drawn; -1 clears the name
55 u8 padding14[4]; ///< not read by this screen
56 s32 cursorSpeed; ///< 16.16 screen pixels per frame
57 struct UiWindow *nameWindow; ///< owned until this screen closes
58 // Packed visible places, then a nearest-place frame; the last is the cursor.
59#ifdef UBFIX
61#else
63#endif
64};
65
66STATIC_ASSERT(offsetof(struct WorldMapWork, markers) == 0x20);
67STATIC_ASSERT(sizeof(struct WorldMapWork) == 0x344);
69 sizeof(((struct FieldWork *)0)->actors) /
70 sizeof(((struct FieldWork *)0)->actors[0]));
71
72/// Sets up the world map screen: the marker tiles and their OAM entries, the
73/// cursor where the leader is on the map (or mid-screen when the place is not
74/// on it), and the place-name window.
76#ifdef UBFIX
77 union WorldMapMarkerPart *marker;
78#else
79 u32 *oam;
80#endif
81 u32 *markerTiles;
82 struct WorldMapWork *work;
83 struct FieldActor *object;
84 s32 tileAttributes;
85 u32 i;
86 u32 tile;
87 u32 cursorAttributes;
88
89 markerTiles =
92#ifdef UBFIX
93 marker = work->markers;
94#else
95 // UB: the flat word view runs across sprite records. Typed word/sprite
96 // unions change tbs-en setup from 368 to 364 bytes.
97 oam = (u32 *)work->markers;
98#endif
102 markerTiles[0] = 255;
103 markerTiles[1] = 0x1ff;
104 markerTiles[2] = 272;
105 markerTiles[8] = 68;
106 markerTiles[9] = 324;
107 markerTiles[10] = 272;
108 markerTiles[16] = 119;
109 markerTiles[17] = 0x177;
110 markerTiles[18] = 272;
111 markerTiles[24] = 0xff0;
112 markerTiles[25] = 0xffff;
113 markerTiles[26] = 0x1ffff;
114 markerTiles[27] = 0x11ff0;
115 markerTiles[28] = 0x1100;
116 tileAttributes = VramCache_Load(work->markerVramBlock,
117 WORLD_MAP_MARKER_TILE_BYTES, markerTiles) |
118 0x400;
119 for (i = 0; i < WORLD_MAP_MARKER_CAPACITY; i++) {
120#ifdef UBFIX
121 marker->words[0] = 0;
122 marker->words[1] = 0;
123 marker->words[2] = tileAttributes;
124 marker++;
125#else
126 *oam++ = 0;
127 *oam++ = 0;
128 *oam++ = tileAttributes;
129#endif
130 }
131 MemFree(markerTiles);
135 } else {
136 work->cursorX.fixed = (((object->x.fixed - WORLD_MAP_X_ORIGIN) >> 16) *
138 << 16;
139 work->cursorY.fixed = ((object->z.part.pixel * WORLD_MAP_SCREEN_HEIGHT) /
141 << 16;
142 }
145 work->nameWindow = UiWindow_CreateFar(0, 0, 0, 0, 2);
146 work->namedMarker = -1;
148#ifdef UBFIX
149 marker->words[0] = 0;
150 marker->words[1] = 0x40000000;
151#else
152 *oam++ = 0;
153 *oam++ = 0x40000000;
154#endif
155 cursorAttributes = 0x400;
156 cursorAttributes |= tile >> 5;
157#ifdef UBFIX
158 marker->words[2] = cursorAttributes;
159#else
160 *oam = cursorAttributes;
161#endif
162}
163
164#if TBS_PATCH_2
165/// The cursor snaps to the nearest place when the d-pad is released.
166#define WORLD_MAP_CURSOR_SNAPS 1
167#define WORLD_MAP_NAME_RANGE 64 ///< squared distance that shows a place's name
168#define WORLD_MAP_NAME_LEFT 3 ///< how far left of its marker the name goes
169#else
170#define WORLD_MAP_CURSOR_SNAPS 0
171#define WORLD_MAP_NAME_RANGE 100
172#define WORLD_MAP_NAME_LEFT 1
173#endif
174
175/// Closes the world map screen: returns its VRAM blocks and removes the
176/// place-name window.
178 struct WorldMapWork *work = (struct WorldMapWork *)gMapCellBuffer;
179
183}
184
185/// Scheduler callback of the world map screen: shows a marker at each place
186/// whose flag is set, moves the cursor with the d-pad (to the current place
187/// while L or R is held) and shows the name of the marker nearest the cursor.
189 s32 leader;
190 const s32 *place;
191 s32 tileBase;
192 s32 blend;
193 s32 nearestMarker;
194 s32 nearestDistanceSquared;
195 s32 cursorX;
196 s32 nearestX;
197 s32 nearestY;
198 s32 message;
199 s32 nearestName;
200 s32 height;
201 s32 width;
202 struct FieldPosition pos;
203 struct WorldMapWork *work;
204 struct FieldActor *placeActor;
205 s32 cursorY;
206 s32 tile;
207 s32 mode;
208 s32 flag;
209 s32 markerIndex;
210#ifdef UBFIX
211 union WorldMapMarkerPart *marker;
212#else
213 struct AnimationSpritePart *marker;
214#endif
215 s32 x;
216 s32 y;
217 s32 angle;
218
219#if WORLD_MAP_CURSOR_SNAPS
220 leader = gGameState.selectedActor;
221 work = (struct WorldMapWork *)Ram_MapCellBuffer;
222 marker = work->markers;
224 tileBase = gVramBlockCache[work->markerVramBlock].offset >> 5;
225#else
226 work = (struct WorldMapWork *)Ram_MapCellBuffer;
227 leader = gGameState.selectedActor;
229 tileBase = gVramBlockCache[work->markerVramBlock].offset >> 5;
230 marker = work->markers;
231#endif
232 nearestMarker = -1;
233 nearestDistanceSquared = WORLD_MAP_NAME_RANGE;
236
237 // Field_RunScene creates the selected actor before event -888 opens this
238 // screen. No actor task removes it while the marker callback runs.
240 // L or R: the current place.
242#ifdef UBFIX
243 // The native null branch leaves this frame's cursor coordinates unset.
244 // A missing selected actor violates the screen's lifetime contract;
245 // skipping that frame changes tbs-en from 1088 to 1092 bytes.
246 if (placeActor == NULL)
247 return;
248#endif
249 if (placeActor != NULL) {
250 cursorX = ((placeActor->x.fixed - WORLD_MAP_X_ORIGIN) >> 16) *
252 cursorY = placeActor->z.part.pixel * WORLD_MAP_SCREEN_HEIGHT /
254 }
255 } else {
256 // The d-pad: faster the longer it is held.
257 angle = gWorldMap_CursorDirectionAngles[(gKeysHeld >> 4) & 15];
258 if (angle != 0xffff) {
259 pos.x = work->cursorX.fixed;
260 pos.y = 0;
261 pos.z = work->cursorY.fixed;
262 Vector_AddPolarOffset(work->cursorSpeed, angle, &pos);
267 if (pos.z < 0)
268 pos.z = 0;
271 work->cursorX.fixed = pos.x;
272 work->cursorY.fixed = pos.z;
275 } else {
277 }
278 cursorX = work->cursorX.part.pixel;
279 cursorY = work->cursorY.part.pixel;
280 }
281
282 // Actor 0 consumes no place row. Ordinary rows begin at actor 11; a
283 // selected slot in 1..10 also consumes one. Zero rows reserve actors with
284 // no marker and -1 ends the table. A row is (tile << 16 | flag, scene id).
285 for (markerIndex = 0; markerIndex < WORLD_MAP_MARKER_CAPACITY;
286 markerIndex++) {
287 if (markerIndex != leader && markerIndex < WORLD_MAP_FIRST_PLACE_ACTOR)
288 continue;
289 if (markerIndex == 0) {
291 continue;
292 tile = 0;
293 flag = leader;
294 mode = 0;
295 } else {
296 flag = *place++;
297 message = *place++;
298 if (flag == 0)
299 continue;
300#if WORLD_MAP_CURSOR_SNAPS
301 if (flag == -1)
302 break;
303 tile = flag >> 16;
304 mode = 1;
305#else
306 tile = flag >> 16;
307 mode = 1;
308 if (flag == -1)
309 break;
310#endif
311 }
312 if (!GameFlag_TestFar(flag))
313 continue;
314 placeActor = ObjectTable_Get(markerIndex);
315 if (placeActor == NULL)
316 continue;
317
318 // Field x starts at 4096; the picture covers 4096 square world pixels.
319 x = ((placeActor->x.fixed - WORLD_MAP_X_ORIGIN) >> 16) *
321 y = placeActor->z.part.pixel * WORLD_MAP_SCREEN_HEIGHT /
323 WORLD_MAP_MARKER_VIEW(marker).objectMode = mode;
324 WORLD_MAP_MARKER_VIEW(marker).tile = tileBase + tile;
325 WORLD_MAP_MARKER_VIEW(marker).x = x - 1;
326 WORLD_MAP_MARKER_VIEW(marker).y = y - 1;
327 width = x - cursorX;
328 height = y - cursorY;
329 if (width * width + height * height < nearestDistanceSquared) {
330 // UB: marker 0 has no table message. Its unused native read keeps the
331 // 1088-byte tbs-en body; skip the read for that marker with UBFIX.
332#ifdef UBFIX
333 if (markerIndex != 0)
334#endif
335 nearestName = message;
336 // These coordinates and the name are valid only with nearestMarker set.
337 nearestMarker = markerIndex;
338 nearestDistanceSquared = width * width + height * height;
339 nearestX = x;
340 nearestY = y;
341 }
342 // Blink the current place for eight frames out of sixteen.
343 if (markerIndex != 0 || (gFrameCount & 15) <= 7)
345 }
346#if WORLD_MAP_CURSOR_SNAPS
347 // With the d-pad released, the cursor moves onto the nearest marker.
348 if (gKeysHeld == 0) {
349 if (nearestMarker != -1) {
350 if (nearestDistanceSquared <= 1) {
351 work->cursorX.fixed = nearestX << 16;
352 work->cursorY.fixed = nearestY << 16;
354 } else {
355 if (work->cursorSpeed < PIXELS(2))
356 work->cursorSpeed = PIXELS(2);
357 angle = ArcTan2(nearestY - cursorY, nearestX - cursorX);
358 pos.x = work->cursorX.fixed;
359 pos.y = 0;
360 pos.z = work->cursorY.fixed;
361 Vector_AddPolarOffset(work->cursorSpeed, (u16)angle, &pos);
362 work->cursorX.fixed = pos.x;
363 work->cursorY.fixed = pos.z;
366 }
367 cursorX = work->cursorX.part.pixel;
368 cursorY = work->cursorY.part.pixel;
369 } else {
371 }
372 }
373#endif
374
375 // The blinking frame round the nearest marker.
376 if (nearestMarker != -1 && (gFrameCount & 15) <= 7) {
377 WORLD_MAP_MARKER_VIEW(marker).objectMode = 0;
378 WORLD_MAP_MARKER_VIEW(marker).tile = tileBase + 3;
379 WORLD_MAP_MARKER_VIEW(marker).x = nearestX - 2;
380 WORLD_MAP_MARKER_VIEW(marker).y = nearestY - 2;
382 }
383
384 // The cursor.
385 marker = &work->markers[WORLD_MAP_CURSOR_PART];
386 WORLD_MAP_MARKER_VIEW(marker).affineIndex = 0;
387 WORLD_MAP_MARKER_VIEW(marker).x = cursorX - 17;
388 WORLD_MAP_MARKER_VIEW(marker).y = cursorY + 1;
390
391 // Redraw only when the selected marker changes, including to no marker.
392 if (work->namedMarker != nearestMarker) {
393 work->namedMarker = nearestMarker;
395 if (nearestMarker != -1) {
396 if (nearestMarker == 0)
397 nearestName = MsgPresentLocation;
398 else
399 nearestName =
400 Scene_GetAreaNameIndex(nearestName, 1) + MsgDebugEntryName;
401 UiText_MeasureResourceEntriesFar(nearestName, &width, &height);
402 cursorX = nearestX;
403 cursorY = nearestY;
405 cursorY -= 11;
406 if (cursorX + width > WORLD_MAP_SCREEN_WIDTH) {
407 // Past the right edge, it goes up and left of the marker.
408 cursorX = WORLD_MAP_SCREEN_WIDTH - 8 - width;
409 cursorY = nearestY - 20;
410 }
411 if (cursorY < 0)
412 cursorY = 0;
413 UiText_DrawResourceFar(nearestName, work->nameWindow, cursorX, cursorY);
414 }
415 }
416
417 // Pulse the markers' transparency.
419 IO_WRITE_QUEUE_PUSH((u32)&REG_BLDALPHA, ((16 - blend) << 8) | blend,
421}
422
423/// Borrows the map-cell buffer for the still map until A or B closes it.
424/// Field_RunScene reaches this for event -888 in world-map mode. The marker
425/// task stops before map graphics are restored, so neither uses the other's
426/// scratch storage. The picture argument is unused; the resource is fixed.
427void Map_ShowWorldMap(s32 picture) {
428 struct MapState *map = WORK_SLOT(8);
429 struct FieldWork *field =
433 struct MapAnimation *layer;
434 u8 savedFlags[sizeof(map->anim) / sizeof(map->anim[0])];
435 s32 i;
436 u8 *graphics;
437 s32 savedStatus;
438 s16 blend;
439
440 if (field->mode != MODE_WORLD_MAP)
441 return;
442 field->camera->movementState = 1;
443 savedStatus = field->transitionFrames;
444 field->transitionFrames = 6;
447 layer = map->anim;
448 for (i = 0; i < (s32)(sizeof(savedFlags) / sizeof(savedFlags[0])); i++) {
449 savedFlags[i] = layer->paused;
450 layer->paused = 1;
451 layer++;
452 }
453 menu->suspended = 1;
454 WaitFrames(1);
455 blend = REG_BLDALPHA;
456 graphics = Resource_GetTableEntry(resource);
457 Dma_Set(graphics, (void *)BG_PLTT,
458 (u32)(DMA_ENABLE | DMA_32BIT) << 16 | (448 / 4), REG_DMA3);
459 BG_PLTT[0] = 0;
460 Resource_DecodeType01(graphics + 448, gMapCellBuffer);
462 (u32)(DMA_ENABLE | DMA_32BIT) << 16 |
464 REG_DMA3);
468 &REG_DISPCNT);
474 do {
475 WaitFrames(1);
476 } while ((gKeysRepeat & (KEY_A | KEY_B)) == 0);
482 layer = map->anim;
483 for (i = 0; i < (s32)(sizeof(savedFlags) / sizeof(savedFlags[0])); i++) {
484 layer->paused = savedFlags[i];
485 layer++;
486 }
487 menu->suspended = 0;
490 field->transitionFrames = savedStatus;
491 field->camera->movementState = 0;
492}
493
494/// On the world map, shows only the scene actors within 320 pixels sideways,
495/// 600 above and 400 below the camera.
497 struct ObjectRuntime *object;
498 s32 x;
499 s32 y;
500 s32 left;
501 s32 right;
502 s32 top;
503 s32 bottom;
504 u32 id;
505
506 // The selected actor lookup has no used result; the bounds follow the camera.
508 object = ((struct FieldWork *)gEventWork)->camera;
509 x = object->x;
510 left = x - (320 << 16);
511 right = x + (320 << 16);
512 y = object->z;
513 top = y - (600 << 16);
514 bottom = y + (400 << 16);
515
517 do {
518 object = ObjectTable_Get(id);
519
520 if (object != 0) {
521 s32 ox = object->x;
522 s32 oy = object->z;
523
524 if (ox < left || ox > right || oy < top || oy > bottom) {
525 object->animationKind = 0;
526 } else {
527 object->animationKind = 1;
528 }
529 }
530 id++;
531 } while (id < WORLD_MAP_MARKER_CAPACITY);
532}
533
534/// On the world map, zooms the view out (0x9d89) while L is held, then back.
536 struct FieldWork *field =
538
539 if (field->mode == MODE_WORLD_MAP) {
544 if (gKeysHeld & KEY_L) {
545 do {
546 WaitFrames(1);
547 } while (gKeysHeld & KEY_L);
548 }
551 }
552}
553
554#undef WORLD_MAP_MARKER_TILE_BYTES
555#undef WORLD_MAP_SCREEN_WIDTH
556#undef WORLD_MAP_SCREEN_HEIGHT
557#undef WORLD_MAP_WORLD_SIZE
558#undef WORLD_MAP_X_ORIGIN
559#undef WORLD_MAP_FIRST_PLACE_ACTOR
560#undef WORLD_MAP_MARKER_CAPACITY
561#undef WORLD_MAP_CURSOR_PART
562#undef WORLD_MAP_CURSOR_MIN_SPEED
563#undef WORLD_MAP_CURSOR_MAX_SPEED
564#undef WORLD_MAP_CURSOR_ACCELERATION
565#undef WORLD_MAP_MARKER_BLEND_STEPS
566#undef WORLD_MAP_CURSOR_MIN_X
567#undef WORLD_MAP_CURSOR_MAX_X
568#undef WORLD_MAP_CURSOR_MAX_Y
569#undef WORLD_MAP_MARKER_VIEW
570#undef WORLD_MAP_MARKER_ALLOCATION_SIZE
571#undef WORLD_MAP_CURSOR_SNAPS
572#undef WORLD_MAP_NAME_RANGE
573#undef WORLD_MAP_NAME_LEFT
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
Definition actors.c:462
const s32 gWorldMap_PlaceMarkers[]
#define SCHEDULER_KEY_MAIN_LOOP
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 Map_LoadAreaGraphicsFar(void)
s32 GameFlag_TestFar(s32 flag)
void RenderOutput_PrepareForRedrawFar(struct UiWindow *window)
struct UiWindow * UiWindow_CreateFar(s32 x, s32 y, s32 width, s32 height, s32 attrs)
void UiText_ShowPositionedMessageAndWaitFar(s32 no, s32 flags)
void UiText_MeasureResourceEntriesFar(s32 no, s32 *x, s32 *y)
void UiText_DrawResourceFar(s32 arg0, struct UiWindow *arg1, s32 arg2, s32 arg3)
void UiWork_FinalizeFar(struct UiWindow *work, s32 release)
s32 Resource_LoadFixedBlockBIntoFreeSlotFar(void)
@ ACTOR_FIRST_PLACED
#define PIXELS(value)
#define FLAG_NOT_ON_MAP
the current place is not on the world map
Definition flags.h:37
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
volatile u32 gFrameCount
Frames WaitFrames has finished.
const u16 gWorldMap_CursorDirectionAngles[16]
An angle for each +Control Pad direction (eight of them); 0xffff for none.
Definition fxdata.c:515
const u8 gWorldMap_MarkerBlendCycle[32]
The brightness of the world map markers ((gFrameCount >> 1) & 31).
Definition fxdata.c:509
struct GameState gGameState
struct EffectStep gMapCellBuffer[]
Map cells; battle effects reuse this as a particle array.
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
Definition heap.c:140
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
@ HEAP_SLOT_MENU_CONTROL
Definition heap_state.h:35
@ HEAP_SLOT_EVENT
Definition heap_state.h:40
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
Definition heap_state.h:14
#define BGCNT_256_COLORS
Definition io_reg.h:27
#define BG_CHAR_BLOCK(n)
Definition io_reg.h:166
@ DISPCNT_OBJ_ON
Definition io_reg.h:44
@ DISPCNT_BG0_ON
Definition io_reg.h:40
@ DISPCNT_OBJ_1D_MAP
Definition io_reg.h:39
@ DISPCNT_BG1_ON
Definition io_reg.h:41
@ KEY_B
Definition io_reg.h:244
@ KEY_A
Definition io_reg.h:243
@ KEYS_SHOULDERS
Definition io_reg.h:256
@ KEY_L
Definition io_reg.h:252
#define DMA_32BIT
Definition io_reg.h:210
#define REG_DISPCNT
Definition io_reg.h:9
#define BLDCNT_TGT2_ALL
Definition io_reg.h:140
#define REG_DMA3
Definition io_reg.h:153
#define BGCNT_SCREEN_BASE(block)
Definition io_reg.h:28
#define REG_BLDALPHA
Definition io_reg.h:142
#define BG_PLTT
Definition io_reg.h:157
#define REG_BLDCNT
Definition io_reg.h:119
#define REG_BG1CNT
Definition io_reg.h:20
#define DMA_ENABLE
Definition io_reg.h:217
#define IO_WRITE_16
Writes a halfword.
#define IO_WRITE_QUEUE_PUSH(address, value, control)
Disables interrupts to add one register write or DMA to the queue; a write to a full queue is dropped...
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
Definition iowrite.h:14
volatile u32 gKeysHeld
Keys down now.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
void Vector_AddPolarOffset(s32 radius, s32 angle, void *position)
Moves the point position by radius in direction angle on the ground plane: x by the cosine,...
Definition math.c:23
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
Definition math.c:36
void MemFree(void *buffer)
s32 Scene_GetAreaNameIndex(s32 scene, s32 entrance)
Returns the place name of scene and entrance, from the first rule matching the scene or its group; 0 ...
Definition encounter.c:326
void Leader_StopMoving(void)
Stops the leader where it stands: no horizontal velocity, the normal walking speed (1....
Definition events.c:67
void Event_FinishScreenTransition(void)
The event command "close screen": finishes the event's screen transition and clears work->transitionA...
Definition events.c:499
void Event_WaitTransitionFrames(void)
The event command "wait for screen": waits as long as the transition runs (work->transitionFrames).
Definition events.c:509
void Event_StartScreenTransition(void)
The event command "open screen": starts the event's screen transition and sets work->transitionActive...
Definition events.c:488
void BattleFx_ScheduleRatioTransition(s32 zoom, s32 frames)
Starts a zoom to zoom (16.16) over frames frames, on the world map (event mode 3) only.
Definition view.c:69
#define WORLD_MAP_CURSOR_MAX_SPEED
Definition world_map.c:16
#define WORLD_MAP_X_ORIGIN
Definition world_map.c:11
#define WORLD_MAP_MARKER_TILE_BYTES
Definition world_map.c:7
#define WORLD_MAP_CURSOR_MIN_SPEED
Definition world_map.c:15
#define WORLD_MAP_NAME_LEFT
Definition world_map.c:172
#define WORLD_MAP_MARKER_CAPACITY
Definition world_map.c:13
void BattleFx_RunVisibilityTransition(void)
On the world map, zooms the view out (0x9d89) while L is held, then back.
Definition world_map.c:535
#define WORLD_MAP_FIRST_PLACE_ACTOR
Definition world_map.c:12
void Map_UpdateWorldMapMarkers(void)
Scheduler callback of the world map screen: shows a marker at each place whose flag is set,...
Definition world_map.c:188
#define WORLD_MAP_WORLD_SIZE
Definition world_map.c:10
#define WORLD_MAP_CURSOR_MIN_X
Definition world_map.c:19
#define WORLD_MAP_CURSOR_MAX_X
Definition world_map.c:20
void BattleFx_SetupResourcesAndWindow(void)
Sets up the world map screen: the marker tiles and their OAM entries, the cursor where the leader is ...
Definition world_map.c:75
#define WORLD_MAP_SCREEN_HEIGHT
Definition world_map.c:9
#define WORLD_MAP_MARKER_BLEND_STEPS
Definition world_map.c:18
#define WORLD_MAP_SCREEN_WIDTH
Definition world_map.c:8
void Map_ShowWorldMap(s32 picture)
Borrows the map-cell buffer for the still map until A or B closes it.
Definition world_map.c:427
void Field_UpdateObjectVisibilityBounds(void)
On the world map, shows only the scene actors within 320 pixels sideways, 600 above and 400 below the...
Definition world_map.c:496
#define WORLD_MAP_MARKER_VIEW(marker)
Definition world_map.c:32
#define WORLD_MAP_CURSOR_ACCELERATION
Definition world_map.c:17
#define WORLD_MAP_CURSOR_PART
Definition world_map.c:14
void BattleFx_CleanupResourcesAndWindow(void)
Closes the world map screen: returns its VRAM blocks and removes the place-name window.
Definition world_map.c:177
#define WORLD_MAP_CURSOR_MAX_Y
Definition world_map.c:21
#define WORLD_MAP_NAME_RANGE
Definition world_map.c:171
#define WORLD_MAP_MARKER_ALLOCATION_SIZE
Definition world_map.c:43
What every part of psynergy_effects.c shares: its includes and the macros and types more than one par...
#define Ram_MapCellBuffer
Definition ram_buffer.h:10
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
Definition render.c:79
char ResourceId_WorldMapPicture
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
Definition decompress.c:31
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_ResumeOverlayTasks(void)
Resumes every task whose routine is in an overlay, flagged or not.
Definition scheduler.c:265
s32 Scheduler_SuspendOverlayTasks(void)
Suspends every task whose routine is in an overlay (EWRAM, 0x02xxxxxx) unless its flag bit 0 asks to ...
Definition scheduler.c:197
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
Definition scheduler.c:146
struct EventWork * gEventWork
#define NULL
Definition bilibin.h:6
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
The hardware sprite attributes one part of an animated sprite (its image or its shadow) is drawn with...
Definition animspr.h:84
u16 y
The OAM entry's attributes 0 to 2.
Definition animspr.h:90
u16 x
screen pixels
Definition animspr.h:96
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
A position on the field.
s32 z
16.16 fixed-point pixels
Full event work allocated by Field_RunScene (heap slot 27).
struct ObjectRuntime * camera
the object the map view follows
s16 mode
MODE_WORLD_MAP (3) on the world map.
s32 transitionFrames
frames; 16 on entry and at each event
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
One of the 16 tile animation channels, which copy tiles into VRAM by script.
Definition map.h:40
u16 paused
Definition map.h:44
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels,...
Definition map.h:49
struct MapAnimation anim[16]
Definition map.h:54
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
u8 movementState
nonzero skips its script and motion (paused)
s32 x
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
The object system's work: the flag that suspends sprite projection, the outline's edge and fill colou...
Definition animspr.h:66
s16 suspended
nonzero while a menu has suspended sprite projection
Definition animspr.h:69
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition uiwindow.h:11
u16 offset
bytes from the start of OBJ VRAM
Definition vram_tab.h:25
Scratch work while Map_ShowWorldMap owns gMapCellBuffer.
Definition world_map.c:48
union FieldCoordinate cursorX
screen column, 16.16 pixels
Definition world_map.c:51
u8 padding0c[6]
not read by this screen
Definition world_map.c:53
struct AnimationSpritePart markers[WORLD_MAP_MARKER_CAPACITY+1]
Definition world_map.c:62
s32 cursorSpeed
16.16 screen pixels per frame
Definition world_map.c:56
u16 cursorVramBlock
owns the cursor picture's tiles
Definition world_map.c:50
u8 padding14[4]
not read by this screen
Definition world_map.c:55
u16 markerVramBlock
owns the four generated marker tiles
Definition world_map.c:49
union FieldCoordinate cursorY
screen row, 16.16 pixels
Definition world_map.c:52
s16 namedMarker
actor whose name is drawn; -1 clears the name
Definition world_map.c:54
struct UiWindow * nameWindow
owned until this screen closes
Definition world_map.c:57
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
Definition system.c:150
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
A field coordinate, read whole or as its fraction and its whole pixels.
struct FieldCoordinate::@024321007066302143002254325121164243234242211074 part
s32 fixed
16.16 fixed-point pixels
The renderer's linked sprite entry and the three words that initialize it.
Definition world_map.c:24
struct AnimationSpritePart sprite
Definition world_map.c:25
#define MODE_WORLD_MAP
the world map
Definition object.h:78
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
Definition vram_cache.c:106
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
Definition vram_cache.c:211
s32 VramCache_Load(u32 no, u32 size, const void *src)
Gives cache entry no size bytes of sprite VRAM and copies src there.
Definition vram_cache.c:143
struct VramBlockCacheEntry gVramBlockCache[]