Refactor the Unown wall word data (#1131)

This commit is contained in:
Sylvie
2024-07-24 10:56:46 -04:00
committed by GitHub
parent 024c8749a0
commit fed587fc37
4 changed files with 50 additions and 56 deletions

View File

@@ -418,6 +418,16 @@
charmap "", $fe charmap "", $fe
charmap "", $ff charmap "", $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 ; ASCII charmap, for mobile functions
pushc pushc
newcharmap ascii newcharmap ascii

View File

@@ -320,6 +320,8 @@ DEF NUM_UNOWN_PUZZLES EQU const_value
const UNOWNWORDS_LIGHT ; 1 const UNOWNWORDS_LIGHT ; 1
const UNOWNWORDS_WATER ; 2 const UNOWNWORDS_WATER ; 2
const UNOWNWORDS_HO_OH ; 3 const UNOWNWORDS_HO_OH ; 3
DEF NUM_UNOWN_WALLS EQU const_value
DEF UNOWN_WALL_MENU_HEADER_SIZE EQU 5
; MoveTutor setval arguments ; MoveTutor setval arguments
const_def 1 const_def 1

View File

@@ -1,45 +1,23 @@
MACRO unownwall ; strings correspond to UNOWNWORDS_* constants (see constants/script_constants.asm)
for n, CHARLEN(\1) DEF UNOWNWORD_{d:UNOWNWORDS_ESCAPE} EQUS "ESCAPE"
DEF x = CHARSUB(\1, n + 1) DEF UNOWNWORD_{d:UNOWNWORDS_LIGHT} EQUS "LIGHT"
if x == "-" DEF UNOWNWORD_{d:UNOWNWORDS_WATER} EQUS "WATER"
db $64 DEF UNOWNWORD_{d:UNOWNWORDS_HO_OH} EQUS "HO-OH"
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
UnownWalls: UnownWalls:
; UNOWNWORDS_ESCAPE ; entries correspond to UNOWNWORDS_* constants
; db $08, $44, $04, $00, $2e, $08, -1 list_start UnownWalls
unownwall "ESCAPE" for x, NUM_UNOWN_WALLS
; UNOWNWORDS_LIGHT li "{UNOWNWORD_{d:x}}"
; db $26, $20, $0c, $0e, $46, -1 endr
unownwall "LIGHT" assert_list_length NUM_UNOWN_WALLS
; UNOWNWORDS_WATER
; db $4c, $00, $46, $08, $42, -1
unownwall "WATER"
; UNOWNWORDS_HO_OH
; db $0e, $2c, $64, $2c, $0e, -1
unownwall "HO-OH"
MenuHeaders_UnownWalls: MenuHeaders_UnownWalls:
; UNOWNWORDS_ESCAPE ; entries correspond to UNOWNWORDS_* constants
db MENU_BACKUP_TILES ; flags table_width UNOWN_WALL_MENU_HEADER_SIZE, MenuHeaders_UnownWalls
menu_coords 3, 4, 16, 9 for x, NUM_UNOWN_WALLS
; UNOWNWORDS_LIGHT DEF n = CHARLEN("{UNOWNWORD_{d:x}}")
db MENU_BACKUP_TILES ; flags db MENU_BACKUP_TILES ; flags
menu_coords 4, 4, 15, 9 menu_coords 9 - n, 4, 10 + n, 9
; UNOWNWORDS_WATER endr
db MENU_BACKUP_TILES ; flags assert_table_length NUM_UNOWN_WALLS
menu_coords 4, 4, 15, 9
; UNOWNWORDS_HO_OH
db MENU_BACKUP_TILES ; flags
menu_coords 4, 4, 15, 9

View File

@@ -105,8 +105,8 @@ DisplayUnownWords:
and a and a
jr z, .load jr z, .load
ld d, $0 ld d, 0
ld e, $5 ld e, UNOWN_WALL_MENU_HEADER_SIZE
.loop .loop
add hl, de add hl, de
dec a dec a
@@ -148,17 +148,19 @@ DisplayUnownWords:
call CloseWindow call CloseWindow
ret ret
pushc
setcharmap unown
INCLUDE "data/events/unown_walls.asm" INCLUDE "data/events/unown_walls.asm"
_DisplayUnownWords_FillAttr: _DisplayUnownWords_FillAttr:
ld a, [de] ld a, [de]
cp $ff cp "@"
ret z ret z
cp $60 cp "Y"
ld a, VRAM_BANK_1 | PAL_BG_BROWN ld a, VRAM_BANK_1 | PAL_BG_BROWN
jr c, .got_pal jr c, .got_pal
ld a, PAL_BG_BROWN ld a, PAL_BG_BROWN
.got_pal .got_pal
call .PlaceSquare call .PlaceSquare
inc hl inc hl
@@ -183,7 +185,7 @@ _DisplayUnownWords_CopyWord:
push de push de
.word_loop .word_loop
ld a, [de] ld a, [de]
cp $ff cp "@"
jr z, .word_done jr z, .word_done
ld c, a ld c, a
call .ConvertChar call .ConvertChar
@@ -200,12 +202,12 @@ _DisplayUnownWords_CopyWord:
.ConvertChar: .ConvertChar:
push hl push hl
ld a, c ld a, c
cp $60 cp "Y"
jr z, .Tile60 jr z, .YChar
cp $62 cp "Z"
jr z, .Tile62 jr z, .ZChar
cp $64 cp "-"
jr z, .Tile64 jr z, .DashChar
ld [hli], a ld [hli], a
inc a inc a
ld [hld], a ld [hld], a
@@ -221,7 +223,7 @@ _DisplayUnownWords_CopyWord:
pop hl pop hl
ret ret
.Tile60: .YChar:
ld [hl], $5b ld [hl], $5b
inc hl inc hl
ld [hl], $5c ld [hl], $5c
@@ -233,7 +235,7 @@ _DisplayUnownWords_CopyWord:
pop hl pop hl
ret ret
.Tile62: .ZChar:
ld [hl], $4e ld [hl], $4e
inc hl inc hl
ld [hl], $4f ld [hl], $4f
@@ -245,7 +247,7 @@ _DisplayUnownWords_CopyWord:
pop hl pop hl
ret ret
.Tile64: .DashChar:
ld [hl], $2 ld [hl], $2
inc hl inc hl
ld [hl], $3 ld [hl], $3
@@ -256,3 +258,5 @@ _DisplayUnownWords_CopyWord:
ld [hl], $2 ld [hl], $2
pop hl pop hl
ret ret
popc