Alchemy
Loading...
Searching...
No Matches

colosso_setup.h

Go to the documentation of this file.
1/// @file
2/// Colosso Log and Colosso River: setting up a race against the rival, with
3/// the race gauge at the top of the screen and the rival running a recorded
4/// path (colosso_path_rival.h).
5#include "types.h"
6#include "field_obj.h"
7#include "field_event.h"
8#include "flags.h"
9
10/// Starts the race gauge (struct ColossoGaugeWork, in work slot 59): Isaac and
11/// the rival as playerActor and rivalActor, a bar of segments pieces either
12/// side, and the finish at pixel (finishX, finishZ) in 16.16, where the two
13/// item actors stand. Unless the party returns to where it was, the rival is
14/// put opposite Isaac across x = finishX.
15void Colosso_StartRaceGauge(s32 playerActor, s32 rivalActor, s32 segments,
16 s32 finishX, s32 finishZ, s32 finishItemActorA,
17 s32 finishItemActorB) {
18
19 u8 *desc;
20 struct FieldActor *player;
21 struct FieldActor *rival;
22 s32 handle;
23 s32 pal;
24
25 desc = Runtime_AllocateBlock(59, 0x7170);
27
28 *(u16 *)(desc + 222) = playerActor;
29 *(u16 *)(desc + 224) = rivalActor;
30 *(u16 *)(desc + 226) = finishItemActorA;
31 *(u16 *)(desc + 228) = finishItemActorB;
32 *(u16 *)(desc + 230) = segments;
33 *(s32 *)(desc + 232) = finishX;
34 *(s32 *)(desc + 236) = finishZ;
35
36 player = Object_GetById(playerActor);
37 rival = Object_GetById(rivalActor);
38
40 rival->x.fixed = (finishX << 1) - player->x.fixed;
41 rival->z.fixed = player->z.fixed;
42 }
43
44 // level and hold
45 *(u16 *)(desc + 218) = 0;
46 *(u16 *)(desc + 220) = 0;
47
49
50 // vramBlock
52 *(u16 *)(desc + 216) = pal;
53 Engine_VramLoad((s16)pal, 512, (const void *)handle);
54
55 // The native object stores this local Thumb symbol with an even value and
56 // adds the state bit here. Modern GCC already includes that bit in a
57 // function pointer; adding one would turn it into an ARM-state address.
58#ifdef UBFIX
59 FieldScheduler_AddCallback(Colosso_DrawGauge, 0xc76);
60#else
61 FieldScheduler_AddCallback((SchedulerCallback)((s32)Colosso_DrawGauge + 1),
62 0xc76);
63#endif
64
65 Runtime_BumpFree((void *)handle);
66}
67
68/// Decodes the rival's recorded path (resource) after the gauge's work and,
69/// unless the party returns to where it was, has the rival run it from the
70/// start, mirrored across the finish; then starts the rival's callback.
71void Colosso_StartRival(s32 resource) {
73 struct PathRecorder *recorder = (struct PathRecorder *)gSceneState;
74
77 recorder->mode = 1;
78 recorder->mirror = 1;
79 recorder->actor = *(u16 *)(work + 224);
80 recorder->still = 0;
81 recorder->pos = 0;
82 }
83 FieldScheduler_AddCallback(Colosso_UpdatePathRival, 0xc85);
84}
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void(*) SchedulerCallback(void)
u8 gColosso_GaugeGraphics[]
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
Definition engine_call.h:36
static s32 FieldResource_DecodeType01(const void *source, void *destination)
Decodes type-01 compressed data.
Definition engine_call.h:90
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
s32 Engine_VramLoad(s32 block, s32 size, const void *data)
s32 Engine_GameFlagIsSet(s32 flag)
u8 gSceneState[]
u8 * gColossoWork
Field objects and actors, and the scene transition styles.
Game flags, named where their meaning is shown.
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
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
void Runtime_BumpFree(void *buffer)
void Colosso_StartRaceGauge(s32 playerActor, s32 rivalActor, s32 segments, s32 finishX, s32 finishZ, s32 finishItemActorA, s32 finishItemActorB)
Starts the race gauge (struct ColossoGaugeWork, in work slot 59): Isaac and the rival as playerActor ...
void Colosso_StartRival(s32 resource)
Decodes the rival's recorded path (resource) after the gauge's work and, unless the party returns to ...
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
The Colosso rival's path player in the scene state: its mode (1 playing, 2 recording,...
Definition field.h:75
s16 actor
Definition field.h:78
u16 pos
Definition field.h:79
s16 mirror
Definition field.h:77
s16 mode
Definition field.h:76
s16 still
frames
Definition field.h:80
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
Definition system.c:150
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
s32 fixed
16.16 fixed-point pixels
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