81 work->
tint[1] = green;
108 s32 greenScale,
s32 blueScale) {
128 return red + ((blue << 10) + (green << 5));
146 return red + ((blue << 10) + (green << 5));
160 step = ((phase + 12) % 24) * 4;
161 offset = brightness - 7;
192 if (++work->
page > 2)
200 switch (work->
page) {
220 switch (work->
page) {
248 selectedOption = work->
page;
253 if (selectedOption == 0) {
262 if (selectedOption == 1) {
271 if (selectedOption > 1)
273 work->
frame[selectedOption - 2][work->
option[selectedOption]]);
305#define SLIDER_PALETTE 14
306#define RESOURCE_SLOTS 96
327 labelMessage = MsgWindowColorLabel;
331#if (LANGUAGE != LANGUAGE_JAPANESE)
332 labelMessage = MsgMessageSpeedLabel;
348 y = window->
y * 8 + 12;
382 y = window->
y * 8 + 4;
394 y = window->
y * 8 + 20;
448 brightness = &work->
option[1];
453 selectedOption = (selectedOption + 5) % 5;
454 work->
option[selectedOption] =
457 work->
page = selectedOption;
461 for (i = 0; i <= 2; i++) {
462 frame = work->
frame[0][i];
472 for (i = 0; i <= 1; i++) {
473 frame = work->
frame[1][i];
483 for (i = 0; i <= 1; i++) {
484 frame = work->
frame[2][i];
497 y = settingsWindow->
y * 8 + 4;
501 y = settingsWindow->
y * 8 + 20;
504 x = work->
option[2] + MsgMessageSpeedSetting;
508 x = work->
option[3] + MsgSpeechSetting;
512 x = work->
option[4] + MsgAutoSleepSetting;
518 x = settingsWindow->
x * 8;
519 y = (selectedOption * 3 + settingsWindow->
y) * 8 + 4;
520 if (selectedOption == 0)
560 work->
option[selectedOption]--;
565 work->
option[selectedOption]++;
588#define WORKSPACE_ROWS 3
589#define WORKSPACE_DEBUG_ROWS 3
590#define WORKSPACE_ROW_HEIGHT 24
591#define WORKSPACE_TEXT_X 48
643 if (settingsOnly != 0) {
656 for (i = 1; i < rows; i++)
659 if (settingsOnly == 0) {
660 labelMessage = MsgWorkspaceSaveQuest;
670 labelMessage = MsgWorkspaceRoughMenu;
684 y = window->
y * 8 + 16;
688 for (i = 0; i < rows; i++) {
716 const s8 *iconFrames;
737 selectedEntry = work->
page;
738 if (settingsOnly != 0) {
748 selectedEntry = (selectedEntry + rows) % rows;
749 work->
page = selectedEntry;
760 if (i != work->
page) {
771 y = (((selectedEntry * 3) + top) * 8) + 0x10;
777 result = selectedEntry;
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...
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
s32 GameFlag_TestFar(s32 flag)
void Shop_SetCursorFar(struct ShopCursor *cursor, s32 targetX, s32 targetY, s32 kind)
void ShopCursor_SetPositionImmediateFar(struct ShopCursor *cursor, s32 x, s32 y)
void ShopCursor_AdvanceFar(struct ShopCursor *cursor)
void ShopCursor_MoveTowardTargetFar(struct ShopCursor *cursor)
void AudioCommand_PlayFar(s32 id)
#define FLAG_IN_LINK_LOBBY
Set when the cleared game's menu goes to the link lobby: there Psynergy has no effect and the system ...
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
volatile u8 gSleepDisabled
Nonzero: WaitFrames counts no idle time and ignores sleep requests.
u8 gDebugMode
Debug builds: Start+Select pauses the frame loop.
volatile u8 gIdleSleepEnabled
Sleep after three idle minutes.
struct GameState gGameState
u8 gResource_FixedBlockBTiles[]
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
#define OBJ_PLTT_COLOR(palette, color)
#define BG_PLTT_COLOR(palette, color)
#define Iwram_MulQ16(left, right)
volatile u32 gKeysPressed
Keys that went down this frame.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
void Runtime_ReleaseHeapBlock(s32 slot)
void SystemMenu_Initialize(void)
Allocates the system menu's work block and starts its per-frame callback.
UNUSED void GraphicsPalette_ReservedNoOpC9C4(void)
struct UiWindow * SystemMenu_Open(void)
Opens the system menu's window with its entries (Save your quest, Sleep, Change settings,...
UNUSED void OptionMenu_LowerSetting(struct WorkspaceWork *work)
Lowers the setting on the three-row cursor's row: message speed, window hue or window brightness.
#define WORKSPACE_ROW_HEIGHT
UNUSED void WindowColor_ComputeTint(struct WorkspaceWork *work)
Works out the window tint (red, green and blue, 0 to 31) from the window colour settings: the hue pic...
UNUSED void OptionMenu_ResetEntries(struct WorkspaceWork *work)
Clears the option screen's seven entry states, its row, its tint and its cursor animation.
void OptionMenu_AnimateCursors(void)
The option screen's per-frame callback: moves the cursor and the two slider markers,...
s32 Menu_RunWorkspaceSelectionLoop(void)
Runs the system menu until the player picks an entry (its number, counting Save your quest as 0) or c...
void OptionMenu_InitializeWork(void)
Allocates the option screen's work block, copies the settings into it with how many values each takes...
void SystemMenu_Release(void)
Stops the system menu's per-frame callback and frees its work block.
struct UiWindow * OptionMenu_Open(void)
Opens the option screen's window: the labels, the hue and brightness sliders with their markers,...
void GraphicsPalette_SelectionNoOp(void)
UNUSED void GraphicsPalette_ReservedNoOpC9C0(void)
void SystemMenu_AnimateCursor(void)
The system menu's per-frame callback: moves the cursor and pulses the chosen entry's icon.
#define WORKSPACE_DEBUG_ROWS
u16 Color_ScaleComponents(s16 *rgb, s32 redScale, s32 greenScale, s32 blueScale)
Returns rgb with each channel scaled (16.16 fixed point) and clamped to 0 to 31, as a BGR555 colour.
u16 WindowColor_ScaleTint(struct WorkspaceWork *work, s32 redScale, s32 greenScale, s32 blueScale)
Returns the window tint with each channel scaled (16.16 fixed point) and clamped to 0 to 31,...
void OptionMenu_Release(void)
Stops the option screen's per-frame callback and frees its work block.
UNUSED void OptionMenu_RaiseSetting(struct WorkspaceWork *work)
Raises the setting on the three-row cursor's row: message speed, window hue or window brightness.
void PaletteGlow_Update(s32 phase, s32 brightness)
Sets the window colours (BG palette 15, colours 4 to 10) for a window hue (0 to 23) and brightness (0...
UNUSED void WindowColor_WritePalette(struct WorkspaceWork *work)
Writes window colours 4 to 10 of BG palette 15, each a fixed scale of the window tint.
UNUSED void OptionMenu_NextRow(struct WorkspaceWork *work)
Moves the three-row settings cursor down, wrapping to the top.
s32 Menu_RunWorkspaceOptions(void)
Runs the option screen (window colour and brightness, message speed, speech, auto-sleep) until A or S...
UNUSED void GraphicsPalette_ReservedNoOpC9BC(void)
Nothing calls them.
UNUSED void OptionMenu_PreviousRow(struct WorkspaceWork *work)
Moves the three-row settings cursor up, wrapping to the bottom.
struct RenderOutput * RenderOutput_Create(s32 slot, s32 oamFlags, struct UiWindow *window, s32 offsetX, s32 offsetY)
Creates a sprite output for the VRAM cache slot slot and attaches it to window, placed at (offsetX,...
struct RenderOutput * RenderResource_CreateFrame(s32 icon, s32 remap, struct UiWindow *window, s32 x, s32 y)
Shows command icon icon (see RenderResource_LoadFrame) as a 32x32 256-colour sprite at (x,...
struct RenderOutput * RenderResource_CreatePair(s32 picture, struct UiWindow *window, s32 x, s32 y)
Shows picture picture of gRenderResource_PairSourceTable as two 32x32 sprites side by side at (x,...
void RenderResource_LoadFrame(s32 icon, s32 slot, s32 remap)
Decompresses command icon icon (a 32x32 picture of 256 colours, 1 KB) into VRAM slot slot,...
void Ui_ApplyTableScaleToObject(struct RenderOutput *obj)
Makes the sprite obj pulse: scales it about its centre by gUi_ObjectPulseScales (in 1/65536,...
void RenderOutput_BobPair(struct RenderOutput *obj)
Bobs the two sprites of a pair (see RenderResource_CreatePair) up and down by gUi_PairBobOffsets,...
char ResourceId_ShopCursorFrames
const u8 gPaletteGlow_WaveTable[121]
The window colour wheel: one colour channel's level (0 to 31) over 96 hue steps.
const u8 gOptionMenu_HuePresets[6]
The window colour presets SELECT cycles through on the option screen: the colour (hue) and the bright...
const s8 gOptionMenu_SleepFrames[2]
const u8 gOptionMenu_BrightnessPresets[6]
const s8 gMenu_WorkspaceIconFrames[8]
The sprite frame of each entry's icon in the system menu (Save your quest, Sleep, Change settings,...
const s8 gOptionMenu_SpeechFrames[2]
const s8 gOptionMenu_SpeedFrames[3]
The option screen's sprite frames for each setting's choices: message speed Slow, Normal and Fast; Sp...
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...
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
#define SE_MENU_CURSOR_MOVE
u8 paletteGlow[2]
window hue (0 to 24), brightness
u8 idleSleepEnabled
the option, saved from gIdleSleepEnabled
u8 messageSpeed
0 to 2; 1 on a new game
u8 speech
1 shows speakers' portraits beside their messages
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
u8 sentinel
depth slot it is drawn at (254 for glyphs)
s8 index
VRAM cache slot, or a glyph's tile after glyphTiles.
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
The option screen's work (heap block 20): the settings being edited and how many values each takes,...
struct RenderOutput * icon[6]
struct RenderOutput * frame[3][3]
union MenuCursor marker[2]
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
#define OPTION_SETTING_END
#define OPTION_WINDOW_WIDTH
void UiText_DrawResource(s32 message, struct UiWindow *window, s32 x, s32 y)
Decodes a message and draws it into a text canvas window at pixel (x, y).
void UiWindow_DrawDividerLine(struct UiWindow *win, u32 x1, u32 y1, u32 x2, u32 y2)
Draws a straight divider line inside a window from tile (x1, y1) to (x2, y2), horizontal or vertical:...
void UiText_DrawCharacterAtOffset(s32 message, const struct UiWindow *window, u32 offsetX, u32 offsetY)
Decodes a message and draws it as tiles in a window at pixel (offsetX, offsetY) of its interior.
#define DMA_COPY16(count)
The DMA control word that copies count halfwords.
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
s32 VramCache_Load(u32 no, u32 size, const void *src)
Gives cache entry no size bytes of sprite VRAM and copies src there.
What every part of the window object shares: its includes, edition values, macros and the codes of de...
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
void RenderOutput_ClearList(void *outputs)
Releases every render output in a list and empties it.
void UiWindow_ClearInteriorTiles(const struct UiWindow *window, u32 left, u32 top, u32 right, u32 bottom)
Clears an area of a window's interior to the window fill.
struct UiWindow * UiWindow_Create(s32 x, s32 y, s32 width, s32 height, s32 attrs)
Opens a window at tile (x, y) of width by height tiles in the first free window slot,...
struct WorkspaceWork * gSelectionWork