7#if (LANGUAGE != LANGUAGE_JAPANESE)
16#define NAME_VOICED_MARK 0xde
17#define NAME_SEMIVOICED_MARK 0xdf
25 if (mark < NAME_VOICED_MARK || mark > NAME_SEMIVOICED_MARK)
27 if (mark == NAME_VOICED_MARK)
31 for (; *range != 0; range += 2) {
32 if (letter >= range[0] && letter <= range[1])
44 for (; *name != 0; name++) {
46 if ((
u8)(*name - NAME_VOICED_MARK) > 1)
67 cell = window->
y * 32 + window->
x;
71 for (row = 0; row < window->
height; row++) {
74 for (column = 0; column < window->
width; column++) {
80 vram += 32 - window->
width;
81 mirror += 32 - window->
width;
100 if (x + width > 29) {
107 if (y + height > 29) {
110 if (width > 0 && height > 0) {
115 s32 remaining = width;
116 while (remaining != 0) {
126 }
while (height != 0);
144#define NAME_COMMAND_COLUMN 18
145#define NAME_MAX_LETTERS 5
146#define NAME_MAX_BYTES 14
176#define TEXT_COLOR_COMMAND 8
187 text[length] = *name;
190 }
while (*name != 0);
196 while (length <= 6) {
197 text[length++] =
'_';
207#if (LANGUAGE == LANGUAGE_SPANISH) || (LANGUAGE == LANGUAGE_ITALIAN)
208#define NAME_LABEL_WIDTH 9
210#define NAME_LABEL_WIDTH 8
215#if (LANGUAGE == LANGUAGE_GERMAN) || (LANGUAGE == LANGUAGE_SPANISH) || \
216 (LANGUAGE == LANGUAGE_FRENCH)
217#define NAME_KEY_LABELS 1
219#define NAME_KEY_LABELS 0
221#if (LANGUAGE == LANGUAGE_GERMAN)
222#define NAME_END_KEY_WIDTH 4
224#define NAME_END_KEY_WIDTH 3
235 s32 originalLength = 0;
238 u8 *editedName = text + 1;
246 s32 keyColumn, keyRow, vramSlot;
262 render->
dirty = textDirty;
269 u32 c = originalName[i];
283 if (vramSlot <= 95) {
289 keyboardWindow->
x * 8 + 140,
290 keyboardWindow->
y * 8 + 52);
293 if (vramSlot <= 95) {
308 end = (
u8 *)(originalLength + (
s32)editedName);
327 (keyboardWindow->
x + keyColumn) * 8 - 7,
328 (keyboardWindow->
y + keyRow) * 8 + 15, 3);
354 keyRow = (keyRow != 3);
366 keyRow = (keyRow != 6);
374 if (keyColumn == -1) {
376 if (keyRow < 4 || keyRow > 5)
378 }
else if (keyColumn == 5 || keyColumn == 11 || keyColumn == 17) {
388 else if (keyColumn == 5 || keyColumn == 11 || keyColumn == 17)
402 if (letterCount != 0) {
419 if (letterCount == 0) {
425 u8 *dst = originalName;
426 u8 *src = editedName;
450 goto remove_character;
454 u32 tx = keyboardWindow->
x + keyColumn + 1;
458 cell = ((keyboardWindow->
y + keyRow + 1) << 5) + tx;
460 letter = ((
u8 *)&render->
tilemap)[cell * 2];
496 u8 *editedName = text + 1;
504 s32 keyColumn, keyRow, vramSlot, x;
516 render->
dirty = textDirty;
523 letter = originalName[i];
525 editedName[i] = letter;
529 if ((
u8)(letter - NAME_VOICED_MARK) <= 1)
539 if (vramSlot <= 95) {
543 keyCursor.output =
output;
545 keyboardWindow->
x * 8 + 140,
546 keyboardWindow->
y * 8 + 92);
549 if (vramSlot <= 95) {
553 nameCaret.output =
output;
584 (keyboardWindow->
x + keyColumn) * 8 - 7,
585 (keyboardWindow->
y + keyRow) * 8 + 15, 3);
597 output = nameCaret.output;
610 else if (keyRow == 5)
616 keyRow = (keyRow != 7);
633 else if (keyRow == 9)
643 if (keyColumn == -1) {
644 if (keyRow == 0 || keyRow == 8 || keyRow == 10)
648 }
else if (keyColumn == 5 || keyColumn == 11 || keyColumn == 17) {
658 else if (keyColumn == 5 || keyColumn == 11 || keyColumn == 17)
661 if (keyRow == 0 || keyRow == 8 || keyRow == 10)
689 if (letterCount != 0) {
692 letter = editedName[bytes];
693 editedName[bytes] = 0;
694 if ((
u8)(letter - NAME_VOICED_MARK) <= 1) {
696 editedName[bytes] = 0;
713 if (letterCount == 0) {
714 nameCaret.output->active = 13;
733 if (keyboardWindow->
height)
735 if (keyboardWindow->
height)
737 if (keyboardWindow->
height)
739 if (keyboardWindow->
height)
749 goto remove_character;
751 goto change_keyboard;
755 u32 tx = keyboardWindow->
x + keyColumn + 1;
759 cell = ((keyboardWindow->
y + keyRow + 1) << 5) + tx;
761 letter = ((
u8 *)&render->
tilemap)[cell * 2];
764 letter = NAME_VOICED_MARK;
767 letter = NAME_SEMIVOICED_MARK;
769 (
u8)(letter - NAME_VOICED_MARK) > 1)
771 dst = editedName + bytes;
778 editedName[bytes] = 0;
780 if ((
u8)(letter - NAME_VOICED_MARK) <= 1)
What every part of the menu object shares: its includes, edition values, macros and the link round st...
#define OUTPUT_SIZE_16X16
OAM attribute bits a sprite output is created with: the size field of attribute 1 (bits 30-31 of the ...
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...
struct BattleUnit * UnitGetFar(u32 owner)
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)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
u32 gFrameTick
Counted up by every VBlank.
const u8 gNameEntry_SemivoicedMarkRanges[]
const u8 gNameEntry_KeyboardTilemap[]
u8 gNameEntry_EndKeyLabel[]
u8 gResource_FixedBlockBTiles[]
const u8 gResource_FixedBlockATiles[]
s8 gNameEntry_CaretWave[]
const u8 gNameEntry_VoicedMarkRanges[]
u8 gNameEntry_DeleteKeyLabel[]
const u8 gNameEntry_AlternateKeyboardTilemap[]
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
#define BG_PLTT_COLOR(palette, color)
volatile u32 gKeysPressed
Keys that went down this frame.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
void UiText_MeasureEntryDimensions(s32 entryIndex, u32 *outWidth, u32 *outHeight, u16 *spacing)
Measures decoded text from entryIndex to its first page's end: returns the width of the longest line ...
void MemFree(void *buffer)
void UiWindow_CopyTilemapRegion(const struct UiWindow *window, const void *source)
Decompresses the type-01 tilemap source and copies it over window's rectangle, both into the BG scree...
#define TEXT_COLOR_COMMAND
The text control code that sets the colour of the text after it, from the byte that follows ({text_co...
void Resource_CopyFixedBlockA(s32 slot)
Loads the 16x16 sprite gResource_FixedBlockATiles into VRAM slot slot.
s32 NameEntry_EditOwnerName(s32 member)
The name entry screen for party member member: the player types a name of up to NAME_MAX_LETTERS lett...
s32 UiText_SetRenderString(const u8 *str)
Puts the string str into the UI's text entries and returns its width in pixels.
#define NAME_MAX_BYTES
stored name bytes, excluding its terminator
void UiWindow_SetTileAttributeRect(const struct UiWindow *window, s32 x, s32 y, s32 width, s32 height, u32 palette)
Like UiWindow_SetTileAttributeBitRect, but ORs all of palette into the palette number of each entry (...
void UiText_DrawPaddedLabel(struct UiWindow *window, u8 *name)
Draws the name being entered, name, at the top left of window, with the free places up to its seventh...
#define NAME_COMMAND_COLUMN
the keyboard column of the command keys
void Resource_CopyFixedBlockB(s32 slot)
Loads the pointing hand cursor's tiles into VRAM slot slot.
UNUSED s32 NameEntry_AcceptsMark(s32 mark, s32 letter)
The international name entry has no voicing marks: where the Japanese edition checks a mark against t...
#define NAME_END_KEY_WIDTH
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,...
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
#define SE_MENU_CURSOR_MOVE
u8 name[0x0f]
The name, one byte a character, ending in 0.
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
s8 active
its UI_SPRITE_ motion; 0 while free
The window system's work: the windows' tilemap, the windows, the three text channels,...
u16 tilemap[640]
the windows' BG tilemap, 32 by 20 tiles
u8 dirty
The tilemap's 4-row bands to upload: bit 0 for all, bit n + 1 for band n.
u16 entries[RENDER_ENTRY_MASK+1]
decoded text, a ring of codes
u16 count
where the next code goes in entries
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
u16 frame
The zoom's step: counts down from 7 to 0 while opening, and up from 0 to duration while closing.
struct RenderOutputList output
the sprites the window carries
void Ui_LoadWindowGraphics(void)
Loads the window font and frame tiles into BG character block 0, the window palette into BG palette 1...
void UiText_DrawStringInWindow(const u8 *text, struct UiWindow *window, u32 x, u32 y)
Draws a byte string into a window's tilemap at pixel (x, y) of its interior, rounded down to tiles.
void UiText_DrawString(const u8 *text, struct UiWindow *window, s32 x, s32 y)
Draws a byte string 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:...
s32 NameEntry_CountLetters(const u8 *name)
#define UI_TILEMAP_VRAM
The UI tilemap in VRAM (BG screen block 4), which UiWork_UploadDirtyBlocks copies the work block's ti...
#define DMA_COPY32(count)
The DMA control word that copies count words.
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.
s32 Localization_LookupEntryId(u32 value)
Returns the portrait of a character (ids below 20) or another speaker's sprite (128 and up for those)...
void UiWork_FinalizeEntityMatchingLocalizedId(u32 speaker)
Closes the portrait window showing speaker entry, if one is open.
struct UiWindow * UiWindow_CreateWithSideObject(s32 speaker, s32 portraitOption, s32 x, s32 y)
Opens a portrait window at tile (x, y) showing the speaker's portrait.
void RenderOutput_PrepareForRedraw(struct UiWindow *window)
Clears a window's contents: redraws its empty frame and releases the render outputs it carries.
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
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,...