GetBuenasPassword:
; The password indices are held in c. High nybble contains the group index, low nybble contains the word index.
; Load the password group pointer in hl.
ld a, c
swap a
and $f
ld hl, BuenasPasswordTable
ld d, 0
ld e, a
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
; Get the password type and store it in b.
ld a, [hli]
ld b, a
push hl
inc hl
; Get the password index.
ld a, c
and $f
ld c, a
push hl
ld hl, .StringFunctionJumptable
ld e, b
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
pop de ; de now contains the pointer to the value of this week's password, in Blue Card Points.
call _hl_
pop hl
ld c, [hl]
ret
.StringFunctionJumptable:
; entries correspond to BUENA_* constants
table_width 2, GetBuenasPassword.StringFunctionJumptable
dw .Mon ; BUENA_MON
dw .Item ; BUENA_ITEM
dw .Move ; BUENA_MOVE
dw .RawString ; BUENA_STRING
assert_table_length NUM_BUENA_FUNCTIONS
.Mon:
ld h, 0
ld l, c
add hl, hl
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call GetPokemonIDFromIndex
+ ld [wNamedObjectIndex], a
call GetPokemonName
- ld [wNamedObjectIndex], a
ret
.Item:
ld h, 0
ld l, c
add hl, de
ld a, [hl]
ld [wNamedObjectIndex], a
call GetItemName
ret
.Move:
ld h, 0
ld l, c
add hl, hl
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call GetMoveIDFromIndex
+ ld [wNamedObjectIndex], a
call GetMoveName
- ld [wNamedObjectIndex], a
ret