src/window/window_windows.c
The window system's setup and tilemap upload, the pool of window sprites, opening and closing windows, and starting a message typing into one. 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 | |
|---|---|---|
void | mnWindowDrawOpened (WINDOW *window) | Draws a window at its full size: its border, and for a text canvas window the canvas, filled with colour 4 under a border when the window is bordered and transparent otherwise. |
void | mnWindowWaitZoom (void *window) | Waits until a zooming window has finished opening or closing. |
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 *out) | 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 its state, 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, starting the field's window update when loadGlyphTiles is set (mnWindowSystemStartBattleUpdate). |
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; in battle the rows of the command window go back to its panel. |
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 | mnWindowClose (WINDOW *window, Sint32 instant) | Closes a window, its sprites and contents going at once: with instant set (callers pass WINDOW_FLAG_INSTANT or 1) its rectangle is erased and its slot freed now, else its tick shrinks away over WINDOW_CLOSE_TICKS. |
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). |
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. |
MESSAGE * | mnBattleMessageContinue (WINDOW *window, Sint32 entry, Sint32 keepPos) | Starts a message typing the decoded text at entry into the battle message window. |
Sint32 | mnTextClearCanvas (void) | Clears the text canvas to transparent. |
Sint32 | mnTextFillCanvasBackground (void) | Fills the text canvas with the window background colour (4). |
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) | Makes the message's text colour, style and line spacing the ones glyphs are drawn with, before it draws its next character. |
Description
The window system's setup and tilemap upload, the pool of window sprites,
opening and closing windows, and starting a message typing into one. 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 10 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 14 of file window_windows.c.
TILEMAP_BAND_SIZE
#define TILEMAP_BAND_SIZE (4 * BG_SCREEN_WIDTH * sizeof(Uint16))
Referenced by mnWindowSystemUploadTilemap().
Definition at line 15 of file window_windows.c.
TILEMAP_DIRTY_ALL
#define TILEMAP_DIRTY_ALL ((1 << (TILEMAP_BANDS + 1)) - 1)
Referenced by mnWindowSystemUploadTilemap().
Definition at line 16 of file window_windows.c.
Functions in detail
mnWindowDrawOpened
void mnWindowDrawOpened(WINDOW *window)
Draws a window at its full size: its border, and for a text canvas window the canvas, filled with colour 4 under a border when the window is bordered and transparent otherwise.
References mnWindowDrawBorder(), mnWindowMapTextCanvasTiles(), Sint32 and syWordsFill().
Referenced by mnWindowCreate() and mnWindowUpdateZooms().
Definition at lines 5 and 245 of file window_windows.c.
mnWindowWaitZoom
void mnWindowWaitZoom(void *window)
Waits until a zooming window has finished opening or closing.
References sySynch().
Referenced by mnWindowCreate().
Definition at lines 6 and 354 of file window_windows.c.
mnWindowSpriteAcquireFree
WINDOW_SPR *mnWindowSpriteAcquireFree(void)
Takes the first window sprite from the free list, or returns NULL when every
sprite is in use.
Referenced by mnBattleDjinnMenuShowChangePreview(), mnGlyphAddBlankSprite(), mnGlyphDraw(), mnGlyphDrawAsSprite(), mnWindowPutGlyph() and mnWindowSpriteCreate().
Definition at line 20 of file window_windows.c.
mnWindowSpriteReleaseFree
void mnWindowSpriteReleaseFree(WINDOW_SPR *out)
Returns a window sprite to the end of the free list. A sprite from outside the window system's pool is ignored.
Referenced by mnWindowSpriteRelease().
Definition at line 37 of file window_windows.c.
mnWindowSpriteInitFreeList
void mnWindowSpriteInitFreeList(void)
Links all 64 window sprites of the pool into the free list.
References Sint32.
Referenced by mnWindowSystemInitBattle() and mnWindowSystemInitField().
Definition at line 53 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 its state, 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(), Sint32, syHeapSlotAllocateEWRAM(), sySetEvent() and syWordsFill().
Referenced by scInit().
Definition at line 77 of file window_windows.c.
mnWindowSystemInitBattle
void mnWindowSystemInitBattle(Sint32 loadGlyphTiles)
Sets up the window system for battle, as mnWindowSystemInitField does for the
field, starting the field's window update when loadGlyphTiles is set
(mnWindowSystemStartBattleUpdate).
References mnWindowSpriteInitFreeList(), mnWindowSystemStartBattleUpdate(), mnWindowSystemUploadTilemap(), Sint32, syDMAXCopy(), syHeapSlotAllocateEWRAM() and sySetEvent().
Definition at line 99 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 syDMAXCopy().
Referenced by mnWindowSystemInitBattle() and mnWindowSystemInitField().
Definition at line 152 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; in battle the rows of the command window go back to its panel.
References mnWindowClearTextTilesInRect() and Sint32.
Referenced by mnMessageType(), mnPartyStatusDraw(), mnWindowClose() and mnWindowUpdateZooms().
Definition at line 190 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 and sySynch().
Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectItem(), dbShopTestRunLevelEditor(), dbShopTestSelectItem(), mnAreaNameWindowShow(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattleMessageOpen(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnDebugBrowserIcons(), mnDebugBrowserPortraits(), mnDebugFlagEditorRun(), mnDebugMenuOpen(), mnDebugSceneSelectRun(), mnDebugShortcutOpen(), mnDebugSoundTestOpen(), mnDebugWarpOpen(), mnDjinnShowJoinedMessage(), mnFieldMessageShowCentered(), mnFileListSelectFile(), mnIconMenuCenter(), mnIconMenuChooseSendOption(), mnIconMenuLayoutIcons(), mnLinkCreateCountdownLabelWindow(), mnMessageOpenWindow(), mnNameEntryEditMemberName(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPartyStatusCreateWindow(), mnPauseMenuOpen(), mnPortraitOpenWindow(), mnSaveProgressOpen(), mnSelectionMenuOpenNameWindow(), mnSettingsMenuOpen(), mnSettingsMenuRun(), mnSummonShowLearnedMessage(), scClearEnterPassword(), scClearReceiveByLink(), scLemuriaSpringRunSpringGame(), scLinkLobbyChooseDebugParamSet() and scLinkLobbyTakeSongRequest().
Definition at line 286 of file window_windows.c.
mnWindowClose
void mnWindowClose(WINDOW *window, Sint32 instant)
Closes a window, its sprites and contents going at once: with instant set
(callers pass WINDOW_FLAG_INSTANT or 1) its rectangle is erased and its slot
freed now, else its tick shrinks away over WINDOW_CLOSE_TICKS.
References mnWindowEraseBorderRect(), mnWindowSpritePrepareForRedraw() and Sint32.
Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectItem(), dbPsynergyTestBrowseMessageRange(), dbShopTestBrowseMessageRange(), dbShopTestRunLevelEditor(), dbShopTestSelectItem(), mnAreaNameWindowHide(), mnAreaNameWindowUpdate(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattleMessageClose(), mnBattleMessageOpen(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnDebugBrowserIcons(), mnDebugBrowserPortraits(), mnDebugFlagEditorRun(), mnDebugMenuRun(), mnDebugSceneSelectRun(), mnDebugShortcutRun(), mnDebugSoundTestRun(), mnDebugWarpRun(), mnDjinnShowJoinedMessage(), mnFieldMessageShow(), mnFieldMessageShowCentered(), mnFileListSelectFile(), mnIconMenuChooseSendOption(), mnIconMenuClose(), mnMessageCloseFinishedWindows(), mnMessageOpenWindow(), mnMessageUpdateAll(), mnNameEntryEditMemberName(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnPartyStatusClose(), mnPauseMenuChoose(), mnPortraitCloseWindow(), mnSaveProgressClose(), mnSelectionMenuClose(), mnSelectionMenuOpenNameWindow(), mnSettingsMenuRun(), mnSummonShowLearnedMessage(), mnWindowCloseAll(), scClearEnterPassword() and 7 more.
Definition at line 369 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 dbShopTestSelectItem(), mnBattleCommandRowRun(), mnDebugBrowserPortraits(), mnDebugFlagEditorDrawTable(), mnDebugSceneSelectDrawRow(), mnFileListDrawSummary(), mnIconMenuAnimateTo(), mnIconMenuChooseSendOption(), mnIconMenuRun(), mnMessageType(), mnNameEntryEditMemberName(), mnSelectionMenuOpenNameWindow(), mnWindowClose(), scClearReceiveByLink(), scLinkLobbyChooseDebugParamSet() and scLinkLobbyTakeSongRequest().
Definition at line 411 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(), dbIncreaseItemAndLevelSelectItem(), dbShopTestRunLevelEditor(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnDebugSoundTestRun(), mnFileListSelectFile(), mnPartyStatusDraw(), mnWindowSpritePrepareForRedraw() and scClearEnterPassword().
Definition at line 421 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 dbIncreaseItemAndLevelSelectItem(), mnBattleDjinnMenuRun(), mnSettingsMenuRun(), mnTransferMethodMenuDrawHelp() and mnWindowSpritePrepareForRedraw().
Definition at line 428 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() and Sint32.
Referenced by mnPasswordLevelMenuDrawContents() and mnSettingsMenuRun().
Definition at line 453 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 503 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(), mnGlyphAddBlankSprite(), mnGlyphDraw(), mnGlyphDrawAsSprite(), mnWindowPutGlyph() and mnWindowSpriteCreate().
Definition at line 517 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 534 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 mnDjinnShowJoinedMessage(), mnFieldMessageShowCentered(), mnMessageOpenDecoded(), mnMessageOpenWindow(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage() and mnSummonShowLearnedMessage().
Definition at line 555 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 lines 606 and 737 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. A message that already serves a typed-out window continues below its
last line (scrolling up once both lines are used) unless keepPos is set.
Returns the message, or NULL when all three are busy.
References mnTextStartCanvasScroll() and Sint32.
Referenced by mnBattleMessageOpen().
Definition at line 612 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 680 of file window_windows.c.
mnTextFillCanvasBackground
Sint32 mnTextFillCanvasBackground(void)
Fills the text canvas with the window background colour (4).
References Sint32 and syWordsFill().
Referenced by mnBattleCollectPartyCommands(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleRefuseFlee(), mnBattleStatusScreenRun() and mnBattleSummonMenuRun().
Definition at line 686 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 694 of file window_windows.c.
mnMessageApplyStyle
void mnMessageApplyStyle(MESSAGE *msg)
Makes the message's text colour, style and line spacing the ones glyphs are drawn with, before it draws its next character.
Referenced by mnMessageType().
Definition at line 725 of file window_windows.c.