src/window/window_windows.c
The window sprite pool, opening and closing windows, starting messages. More…
Included by window.c.
Macros
| Name | Description | |
|---|---|---|
#define | TEXT_TILE_RESERVED 4 | A text tile battle keeps for the bottom border's lower rows: neither taken nor shown, it is never free (WIN_STATE.textTileState). |
#define | TILEMAP_BANDS 5 | The tilemap uploads in five bands of four tile rows, each a bit of WIN_STATE.dirty above bit 0, which asks for them all. |
#define | TILEMAP_BAND_SIZE (4 * BG_SCREEN_WIDTH * sizeof(Uint16)) | |
#define | TILEMAP_DIRTY_ALL ((1 << (TILEMAP_BANDS + 1)) - 1) |
Functions
| Name | Description | |
|---|---|---|
WINDOW_SPR * | mnWindowSpriteAcquireFree (void) | Takes the first window sprite from the free list, or returns NULL when every sprite is in use. |
void | mnWindowSpriteReleaseFree (WINDOW_SPR *sprite) | Returns a window sprite to the end of the free list. |
void | mnWindowSpriteInitFreeList (void) | Links all 64 window sprites of the pool into the free list. |
void | mnWindowSystemInitField (void) | Sets up the window system for the field (and the other screens outside battle): allocates and clears the state block, blanks the tilemap, frees every window sprite and starts the two per-tick events, the tilemap upload and the window update. |
void | mnWindowSystemInitBattle (Sint32 loadGlyphTiles) | Sets up the window system for battle, as mnWindowSystemInitField does for the field, and marks the state block as in battle (WINDOW_BATTLE). |
void | mnWindowSystemUploadTilemap (void) | The tilemap upload, a VBlank-pass event: copies each band of the tilemap marked in the dirty bits to VRAM. |
void | mnWindowEraseBorderRect (Sint32 x, Sint32 y, Uint32 width, Uint32 height) | Erases a window's rectangle of the tilemap (x, y, width and height in tiles) and frees the text tiles it showed. |
void | mnWindowDrawOpened (WINDOW *window) | Draws a window at its full size: its border, and for a text canvas window the canvas, filled with the window background under a border when the window is bordered and transparent otherwise. |
WINDOW * | mnWindowCreate ( Sint32 x, Sint32 y, Sint32 width, Sint32 height, Sint32 attributes) | Opens a window at tile (x, y) of width by height tiles in the first free window slot, and returns it, or NULL when all slots are in use. attributes takes the WINDOW_FLAG_ flags. |
void | mnWindowWaitZoom (WINDOW *window) | Waits until a zooming window has finished opening or closing. |
void | mnWindowClose (WINDOW *window, Sint32 instant) | Closes a window: clears its contents and remembers its last rectangle. |
void | mnWindowSpritePrepareForRedraw (WINDOW *window) | Clears a window's contents: redraws it empty and releases the window sprites it carries. |
void | mnWindowSpriteRedrawSavedRect (WINDOW *window) | Redraws a window empty, its border and fill, at its current rectangle. |
void | mnWindowSpriteClearList (void *sprites) | Releases every window sprite in a list and empties it. sprites is the list, or a window (whose sprite list comes first); NULL is ignored. |
void | mnWindowClearInteriorTiles ( const WINDOW *window, Uint32 left, Uint32 top, Uint32 right, Uint32 bottom) | Clears an area of a window's interior to the window fill. left, top, right and bottom are pixels inside the window, and the area covers every tile they touch. |
void | mnWindowSpriteUpdateListTail (WINDOW_SPR_LIST *list) | Points a list's tail link back at its last sprite, after the list has been edited by hand. |
void | mnWindowSpriteAppendToList (WINDOW_SPR_LIST *list, WINDOW_SPR *node) | Adds a window sprite to the end of a list; NULL lists are ignored. |
void | mnWindowSpriteRelease (WINDOW_SPR *entry) | Frees a window sprite: returns it to the free list, releases its VRAM cache entry unless it is a glyph, and for a portrait frees its palette slot too. |
MESSAGE * | mnMessageStart (WINDOW *window, Sint32 entry, Sint32 x, Sint32 y, Uint16 *spacing, Sint32 flags) | Starts a free message typing the decoded text that begins at entry into window, with the pen at pixel (x, y). spacing gives each of four lines an extra gap between characters, in 1/256 pixels (or none for NULL), and is copied, so the caller's array need not outlive the call; flags is kept with the message (nonzero keeps the window's size from page to page). |
MESSAGE * | mnBattleMessageContinue (WINDOW *window, Sint32 entry, Sint32 keepPos) | Starts a message typing the decoded text at entry into the battle message window, on its next line unless keepPos is set, and returns it, or NULL when no message is free. |
Sint32 | mnTextClearCanvas (void) | Clears the text canvas to transparent. |
Sint32 | mnTextFillCanvasBackground (void) | Fills the text canvas with the window background colour. |
void | mnMessageResetIdle (void) | Resets the pen and text style of the first idle message, clearing the canvas when the message still has a window. |
void | mnMessageApplyStyle (MESSAGE *msg) | Sets the colour, style and line spacing glyphs are drawn in to the message's. |
void | mnTextStartCanvasScroll (MESSAGE *msg) | Starts a message scrolling its canvas up a line: 12 pixel rows, 6 a tick over two ticks (mnMessageType, mnTextScrollCanvasUp), during which the message types nothing. |
Description
The window sprite pool, opening and closing windows, starting messages. Part
of window.c.
Macros in detail
TEXT_TILE_RESERVED
#define TEXT_TILE_RESERVED 4
A text tile battle keeps for the bottom border's lower rows: neither taken
nor shown, it is never free (WIN_STATE.textTileState).
Referenced by mnWindowSystemInitBattle().
Definition at line 6 of file window_windows.c.
TILEMAP_BANDS
#define TILEMAP_BANDS 5
The tilemap uploads in five bands of four tile rows, each a bit of
WIN_STATE.dirty above bit 0, which asks for them all.
Definition at line 10 of file window_windows.c.
TILEMAP_BAND_SIZE
#define TILEMAP_BAND_SIZE (4 * BG_SCREEN_WIDTH * sizeof(Uint16))
Referenced by mnWindowSystemUploadTilemap().
Definition at line 11 of file window_windows.c.
TILEMAP_DIRTY_ALL
#define TILEMAP_DIRTY_ALL ((1 << (TILEMAP_BANDS + 1)) - 1)
Referenced by mnWindowSystemUploadTilemap().
Definition at line 12 of file window_windows.c.
Functions in detail
mnWindowSpriteAcquireFree
WINDOW_SPR *mnWindowSpriteAcquireFree(void)
Takes the first window sprite from the free list, or returns NULL when every
sprite is in use.
References state.
Referenced by mnBattleDjinnMenuShowChangePreview(), mnGlyphDraw(), mnWindowPutGlyph() and mnWindowSpriteCreate().
Definition at line 16 of file window_windows.c.
mnWindowSpriteReleaseFree
void mnWindowSpriteReleaseFree(WINDOW_SPR *sprite)
Returns a window sprite to the end of the free list. A sprite from outside the state block's pool is ignored.
References state.
Referenced by mnWindowSpriteRelease().
Definition at line 34 of file window_windows.c.
mnWindowSpriteInitFreeList
void mnWindowSpriteInitFreeList(void)
Links all 64 window sprites of the pool into the free list.
Referenced by mnWindowSystemInitBattle() and mnWindowSystemInitField().
Definition at line 51 of file window_windows.c.
mnWindowSystemInitField
void mnWindowSystemInitField(void)
Sets up the window system for the field (and the other screens outside battle): allocates and clears the state block, blanks the tilemap, frees every window sprite and starts the two per-tick events, the tilemap upload and the window update.
References mnPortraitClearSlots(), mnWindowSpriteInitFreeList(), mnWindowSystemStartFieldUpdate(), mnWindowSystemUploadTilemap(), state, syDMAXCopy(), syHeapSlotAllocateEWRAM() and sySetEvent().
Definition at line 76 of file window_windows.c.
mnWindowSystemInitBattle
void mnWindowSystemInitBattle(Sint32 loadGlyphTiles)
Sets up the window system for battle, as mnWindowSystemInitField does for the
field, and marks the state block as in battle (WINDOW_BATTLE).
References mnWindowSpriteInitFreeList(), mnWindowSystemStartBattleUpdate(), mnWindowSystemUploadTilemap(), Sint32, state, syDMAXCopy(), syHeapSlotAllocateEWRAM(), sySetEvent() and syWordsClear().
Definition at line 116 of file window_windows.c.
mnWindowSystemUploadTilemap
void mnWindowSystemUploadTilemap(void)
The tilemap upload, a VBlank-pass event: copies each band of the tilemap
marked in the dirty bits to VRAM.
References state and syDMAXCopy().
Referenced by mnWindowSystemInitBattle() and mnWindowSystemInitField().
Definition at line 188 of file window_windows.c.
mnWindowEraseBorderRect
void mnWindowEraseBorderRect(Sint32 x, Sint32 y, Uint32 width, Uint32 height)
Erases a window's rectangle of the tilemap (x, y, width and height in tiles) and frees the text tiles it showed.
References mnWindowClearTextTilesInRect(), Sint32, state and width.
Referenced by mnMessageType(), mnPartyStatusDraw(), mnWindowClose(), mnWindowStepSwellEffect() and mnWindowUpdateZooms().
Definition at line 224 of file window_windows.c.
mnWindowDrawOpened
void mnWindowDrawOpened(WINDOW *window)
Draws a window at its full size: its border, and for a text canvas window the canvas, filled with the window background under a border when the window is bordered and transparent otherwise.
References mnWindowDrawBorder(), mnWindowMapTextCanvasTiles(), state, syWordsFill() and width.
Referenced by mnWindowCreate() and mnWindowUpdateZooms().
Definition at line 274 of file window_windows.c.
mnWindowCreate
WINDOW *mnWindowCreate( Sint32 x, Sint32 y, Sint32 width, Sint32 height, Sint32 attributes)
Opens a window at tile (x, y) of width by height tiles in the first free
window slot, and returns it, or NULL when all slots are in use. attributes
takes the WINDOW_FLAG_ flags.
References mnTextResetStyle(), mnWindowDrawOpened(), mnWindowWaitZoom(), Sint32, sySynch() and width.
Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbIncreaseItemAndLevelShowGlyphCaptions(), dbMenuTestSelectItem(), mnAreaNameWindowShow(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattleMessageOpen(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnColossoMenuChoose(), mnDebugBrowserIcons(), mnDebugBrowserPortraits(), mnDebugFlagEditorRun(), mnDebugSceneSelectRun(), mnDebugSelectShortcuts(), mnDjinnShowJoinedMessage(), mnFieldMessageShowCentered(), mnFileListSelectFile(), mnIconMenuCenter(), mnIconMenuChooseSendOption(), mnIconMenuLayoutIcons(), mnLinkCreateCountdownLabelWindow(), mnMessageOpenWindow(), mnNameEntryEditMemberName(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPartyStatusCreateWindow(), mnPauseMenuOpen(), mnPortraitOpenWindow(), mnSelectionMenuOpenNameWindow(), mnSettingsMenuOpen(), mnSettingsMenuRun(), scBattleArenaChooseDebugParamSet(), scInit(), scKalayTolbiDocksTalkToWomanSellingTickets(), scSanctumChooseRestartOption() and scTolbiSpringRunSpringGame().
Definition at line 318 of file window_windows.c.
mnWindowWaitZoom
void mnWindowWaitZoom(WINDOW *window)
Waits until a zooming window has finished opening or closing.
References sySynch().
Referenced by mnWindowCreate().
Definition at line 388 of file window_windows.c.
mnWindowClose
void mnWindowClose(WINDOW *window, Sint32 instant)
Closes a window: clears its contents and remembers its last rectangle.
References mnWindowEraseBorderRect(), mnWindowSpritePrepareForRedraw() and Sint32.
Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbMenuTestBrowseMessageRange(), dbMenuTestSelectItem(), mnAreaNameWindowHide(), mnAreaNameWindowUpdate(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattleMessageClose(), mnBattleMessageOpen(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnColossoMenuChoose(), mnDebugBrowserIcons(), mnDebugBrowserPortraits(), mnDebugFlagEditorRun(), mnDebugSceneSelectRun(), mnDebugSelectShortcuts(), mnDjinnShowJoinedMessage(), mnFieldMessageShow(), mnFieldMessageShowCentered(), mnFileListSelectFile(), mnIconMenuChooseSendOption(), mnIconMenuClose(), mnMessageCloseFinishedWindows(), mnMessageOpenWindow(), mnMessageUpdateAll(), mnNameEntryEditMemberName(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPartyStatusClose(), mnPauseMenuChoose(), mnPortraitCloseWindow(), mnReleaseSelectionState(), mnSelectionMenuClose(), mnSelectionMenuOpenNameWindow(), mnSettingsMenuRun(), mnWindowCloseAll(), scBattleArenaChooseDebugParamSet(), scBattleArenaEnterBattle(), scBattleArenaSaveBattleResults(), scBattleArenaSaveMonsterBattleResults(), scInit() and 3 more.
Definition at line 398 of file window_windows.c.
mnWindowSpritePrepareForRedraw
void mnWindowSpritePrepareForRedraw(WINDOW *window)
Clears a window's contents: redraws it empty and releases the window sprites it carries. A text canvas window is left alone.
References mnWindowSpriteClearList() and mnWindowSpriteRedrawSavedRect().
Referenced by mnBattleCommandRowRun(), mnDebugBrowserPortraits(), mnDebugFlagEditorDrawTable(), mnDebugSceneSelectDrawRow(), mnFileListDrawSummary(), mnIconMenuAnimateTo(), mnIconMenuChooseSendOption(), mnIconMenuRun(), mnMessageType(), mnNameEntryEditMemberName(), mnSelectionMenuOpenNameWindow(), mnTransferMethodDrawHelp(), mnWindowClose(), scBattleArenaChooseDebugParamSet() and scInit().
Definition at line 443 of file window_windows.c.
mnWindowSpriteRedrawSavedRect
void mnWindowSpriteRedrawSavedRect(WINDOW *window)
Redraws a window empty, its border and fill, at its current rectangle.
References mnWindowDrawBorder().
Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnDebugSelectShortcuts(), mnFileListSelectFile(), mnPartyStatusDraw() and mnWindowSpritePrepareForRedraw().
Definition at line 453 of file window_windows.c.
mnWindowSpriteClearList
void mnWindowSpriteClearList(void *sprites)
Releases every window sprite in a list and empties it. sprites is the list,
or a window (whose sprite list comes first); NULL is ignored.
References mnWindowSpriteRelease().
Referenced by dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), mnBattleDjinnMenuRun(), mnSettingsMenuRun(), mnTransferMethodDrawHelp() and mnWindowSpritePrepareForRedraw().
Definition at line 460 of file window_windows.c.
mnWindowClearInteriorTiles
void mnWindowClearInteriorTiles( const WINDOW *window, Uint32 left, Uint32 top, Uint32 right, Uint32 bottom)
Clears an area of a window's interior to the window fill. left, top, right and bottom are pixels inside the window, and the area covers every tile they touch.
References mnWindowClearTextTilesInRect(), state and width.
Referenced by mnPasswordLevelDrawHelp() and mnSettingsMenuRun().
Definition at line 485 of file window_windows.c.
mnWindowSpriteUpdateListTail
void mnWindowSpriteUpdateListTail(WINDOW_SPR_LIST *list)
Points a list's tail link back at its last sprite, after the list has been edited by hand.
Definition at line 524 of file window_windows.c.
mnWindowSpriteAppendToList
void mnWindowSpriteAppendToList(WINDOW_SPR_LIST *list, WINDOW_SPR *node)
Adds a window sprite to the end of a list; NULL lists are ignored.
Referenced by mnBattleDjinnMenuShowChangePreview(), mnGlyphDraw(), mnWindowPutGlyph() and mnWindowSpriteCreate().
Definition at line 538 of file window_windows.c.
mnWindowSpriteRelease
void mnWindowSpriteRelease(WINDOW_SPR *entry)
Frees a window sprite: returns it to the free list, releases its VRAM cache
entry unless it is a glyph, and for a portrait frees its palette slot too.
References mnWindowSpriteReleaseFree() and syVRAMCacheFreeEntry().
Referenced by mnWindowSpriteClearList().
Definition at line 558 of file window_windows.c.
mnMessageStart
MESSAGE *mnMessageStart(WINDOW *window, Sint32 entry, Sint32 x, Sint32 y, Uint16 *spacing, Sint32 flags)
Starts a free message typing the decoded text that begins at entry into
window, with the pen at pixel (x, y). spacing gives each of four lines an
extra gap between characters, in 1/256 pixels (or none for NULL), and is
copied, so the caller's array need not outlive the call; flags is kept with
the message (nonzero keeps the window's size from page to page).
References Sint32.
Referenced by mnFieldMessageShowCentered(), mnMessageOpenDecoded() and mnMessageOpenWindow().
Definition at line 579 of file window_windows.c.
mnBattleMessageContinue
MESSAGE *mnBattleMessageContinue(WINDOW *window, Sint32 entry, Sint32 keepPos)
Starts a message typing the decoded text at entry into the battle message
window, on its next line unless keepPos is set, and returns it, or NULL when
no message is free.
References mnTextStartCanvasScroll() and Sint32.
Referenced by mnBattleMessageOpen().
Definition at line 630 of file window_windows.c.
mnTextClearCanvas
Sint32 mnTextClearCanvas(void)
Clears the text canvas to transparent.
References Sint32 and syWordsFill().
Referenced by mnBattleTargetRunSelection() and mnMessageResetIdle().
Definition at line 697 of file window_windows.c.
mnTextFillCanvasBackground
Sint32 mnTextFillCanvasBackground(void)
Fills the text canvas with the window background colour.
References Sint32 and syWordsFill().
Referenced by mnBattleCollectPartyCommands(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun() and mnBattleSummonMenuRun().
Definition at line 703 of file window_windows.c.
mnMessageResetIdle
void mnMessageResetIdle(void)
Resets the pen and text style of the first idle message, clearing the canvas when the message still has a window.
References mnTextClearCanvas() and Sint32.
Definition at line 711 of file window_windows.c.
mnMessageApplyStyle
void mnMessageApplyStyle(MESSAGE *msg)
Sets the colour, style and line spacing glyphs are drawn in to the message's.
References state.
Referenced by mnMessageType().
Definition at line 741 of file window_windows.c.
mnTextStartCanvasScroll
void mnTextStartCanvasScroll(MESSAGE *msg)
Starts a message scrolling its canvas up a line: 12 pixel rows, 6 a tick over
two ticks (mnMessageType, mnTextScrollCanvasUp), during which the message
types nothing.
Referenced by mnBattleMessageContinue() and mnMessageType().
Definition at line 753 of file window_windows.c.