diff --git a/constants/charmap.asm b/constants/charmap.asm index 3edce65ffa2..3b834dc3f38 100644 --- a/constants/charmap.asm +++ b/constants/charmap.asm @@ -418,6 +418,16 @@ charmap "8", $fe charmap "9", $ff +; Unown charmap, for Unown words (see gfx/tilesets/ruins_of_alph.png) +pushc + newcharmap unown + DEF PRINTABLE_UNOWN EQUS "ABCDEFGHIJKLMNOPQRSTUVWXYZ-" + for i, STRLEN("{PRINTABLE_UNOWN}") + charmap STRSUB("{PRINTABLE_UNOWN}", i + 1, 1), $10 * (i / 8) + 2 * i + endr + charmap "@", $ff ; end +popc + ; ASCII charmap, for mobile functions pushc newcharmap ascii diff --git a/constants/script_constants.asm b/constants/script_constants.asm index 29f9de8bf54..bfc0a500813 100644 --- a/constants/script_constants.asm +++ b/constants/script_constants.asm @@ -320,6 +320,8 @@ DEF NUM_UNOWN_PUZZLES EQU const_value const UNOWNWORDS_LIGHT ; 1 const UNOWNWORDS_WATER ; 2 const UNOWNWORDS_HO_OH ; 3 +DEF NUM_UNOWN_WALLS EQU const_value +DEF UNOWN_WALL_MENU_HEADER_SIZE EQU 5 ; MoveTutor setval arguments const_def 1 diff --git a/data/events/unown_walls.asm b/data/events/unown_walls.asm index 6e28b5f1c26..c71df387396 100644 --- a/data/events/unown_walls.asm +++ b/data/events/unown_walls.asm @@ -1,45 +1,23 @@ -MACRO unownwall - for n, CHARLEN(\1) - DEF x = CHARSUB(\1, n + 1) - if x == "-" - db $64 - elif x >= "Y" - db 2 * (x - "Y") + $60 - elif x >= "Q" - db 2 * (x - "Q") + $40 - elif x >= "I" - db 2 * (x - "I") + $20 - else - db 2 * (x - "A") - endc - endr - db -1 ; end -ENDM +; strings correspond to UNOWNWORDS_* constants (see constants/script_constants.asm) +DEF UNOWNWORD_{d:UNOWNWORDS_ESCAPE} EQUS "ESCAPE" +DEF UNOWNWORD_{d:UNOWNWORDS_LIGHT} EQUS "LIGHT" +DEF UNOWNWORD_{d:UNOWNWORDS_WATER} EQUS "WATER" +DEF UNOWNWORD_{d:UNOWNWORDS_HO_OH} EQUS "HO-OH" UnownWalls: -; UNOWNWORDS_ESCAPE - ; db $08, $44, $04, $00, $2e, $08, -1 - unownwall "ESCAPE" -; UNOWNWORDS_LIGHT - ; db $26, $20, $0c, $0e, $46, -1 - unownwall "LIGHT" -; UNOWNWORDS_WATER - ; db $4c, $00, $46, $08, $42, -1 - unownwall "WATER" -; UNOWNWORDS_HO_OH - ; db $0e, $2c, $64, $2c, $0e, -1 - unownwall "HO-OH" +; entries correspond to UNOWNWORDS_* constants + list_start UnownWalls + for x, NUM_UNOWN_WALLS + li "{UNOWNWORD_{d:x}}" + endr + assert_list_length NUM_UNOWN_WALLS MenuHeaders_UnownWalls: -; UNOWNWORDS_ESCAPE - db MENU_BACKUP_TILES ; flags - menu_coords 3, 4, 16, 9 -; UNOWNWORDS_LIGHT - db MENU_BACKUP_TILES ; flags - menu_coords 4, 4, 15, 9 -; UNOWNWORDS_WATER - db MENU_BACKUP_TILES ; flags - menu_coords 4, 4, 15, 9 -; UNOWNWORDS_HO_OH - db MENU_BACKUP_TILES ; flags - menu_coords 4, 4, 15, 9 +; entries correspond to UNOWNWORDS_* constants + table_width UNOWN_WALL_MENU_HEADER_SIZE, MenuHeaders_UnownWalls + for x, NUM_UNOWN_WALLS + DEF n = CHARLEN("{UNOWNWORD_{d:x}}") + db MENU_BACKUP_TILES ; flags + menu_coords 9 - n, 4, 10 + n, 9 + endr + assert_table_length NUM_UNOWN_WALLS diff --git a/engine/events/unown_walls.asm b/engine/events/unown_walls.asm index 3934943f4db..cfa624c04d0 100644 --- a/engine/events/unown_walls.asm +++ b/engine/events/unown_walls.asm @@ -105,8 +105,8 @@ DisplayUnownWords: and a jr z, .load - ld d, $0 - ld e, $5 + ld d, 0 + ld e, UNOWN_WALL_MENU_HEADER_SIZE .loop add hl, de dec a @@ -148,17 +148,19 @@ DisplayUnownWords: call CloseWindow ret +pushc +setcharmap unown + INCLUDE "data/events/unown_walls.asm" _DisplayUnownWords_FillAttr: ld a, [de] - cp $ff + cp "@" ret z - cp $60 + cp "Y" ld a, VRAM_BANK_1 | PAL_BG_BROWN jr c, .got_pal ld a, PAL_BG_BROWN - .got_pal call .PlaceSquare inc hl @@ -183,7 +185,7 @@ _DisplayUnownWords_CopyWord: push de .word_loop ld a, [de] - cp $ff + cp "@" jr z, .word_done ld c, a call .ConvertChar @@ -200,12 +202,12 @@ _DisplayUnownWords_CopyWord: .ConvertChar: push hl ld a, c - cp $60 - jr z, .Tile60 - cp $62 - jr z, .Tile62 - cp $64 - jr z, .Tile64 + cp "Y" + jr z, .YChar + cp "Z" + jr z, .ZChar + cp "-" + jr z, .DashChar ld [hli], a inc a ld [hld], a @@ -221,7 +223,7 @@ _DisplayUnownWords_CopyWord: pop hl ret -.Tile60: +.YChar: ld [hl], $5b inc hl ld [hl], $5c @@ -233,7 +235,7 @@ _DisplayUnownWords_CopyWord: pop hl ret -.Tile62: +.ZChar: ld [hl], $4e inc hl ld [hl], $4f @@ -245,7 +247,7 @@ _DisplayUnownWords_CopyWord: pop hl ret -.Tile64: +.DashChar: ld [hl], $2 inc hl ld [hl], $3 @@ -256,3 +258,5 @@ _DisplayUnownWords_CopyWord: ld [hl], $2 pop hl ret + +popc