pokecrystal/engine/overworld/variables.asm

111 lines
1.6 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
_GetVarAction::
2015-11-19 23:07:20 +00:00
ld a, c
cp NUM_VARS
jr c, .valid
xor a
.valid
ld c, a
ld b, 0
ld hl, VarActionTable
2015-11-19 23:07:20 +00:00
add hl, bc
add hl, bc
add hl, bc
2015-11-19 23:07:20 +00:00
ld e, [hl]
inc hl
ld d, [hl]
inc hl
ld b, [hl]
ld a, b
and RETVAR_EXECUTE
jr nz, .call_de
2015-11-19 23:07:20 +00:00
ld a, b
and RETVAR_ADDR_DE
ret nz
ld a, [de]
jr LoadStringBuffer2
2015-11-19 23:07:20 +00:00
.call_de
2015-11-19 23:07:20 +00:00
call _de_
ret
LoadStringBuffer2:
2018-01-23 22:39:09 +00:00
ld de, wStringBuffer2
2015-11-19 23:07:20 +00:00
ld [de], a
ret
INCLUDE "data/overworld/variables.asm"
2015-11-19 23:07:20 +00:00
Var_CountCaughtMons:
2015-11-19 23:07:20 +00:00
; Caught mons.
2018-01-23 22:39:09 +00:00
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
2015-11-19 23:07:20 +00:00
call CountSetBits
ld a, [wNumSetBits]
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
Var_CountSeenMons:
2015-11-19 23:07:20 +00:00
; Seen mons.
2018-01-23 22:39:09 +00:00
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
2015-11-19 23:07:20 +00:00
call CountSetBits
ld a, [wNumSetBits]
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
Var_CountBadges:
2015-11-19 23:07:20 +00:00
; Number of owned badges.
ld hl, wBadges
2015-11-19 23:07:20 +00:00
ld b, 2
call CountSetBits
ld a, [wNumSetBits]
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
Var_PlayerFacing:
2015-11-19 23:07:20 +00:00
; The direction the player is facing.
2018-01-23 22:39:09 +00:00
ld a, [wPlayerDirection]
2015-11-19 23:07:20 +00:00
and $c
rrca
rrca
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
Var_DayOfWeek:
2015-11-19 23:07:20 +00:00
; The day of the week.
call GetWeekday
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
Var_UnownCaught:
2015-11-19 23:07:20 +00:00
; Number of unique Unown caught.
call .count_unown
2015-11-19 23:07:20 +00:00
ld a, b
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
.count_unown:
2018-01-23 22:39:09 +00:00
ld hl, wUnownDex
2015-11-19 23:07:20 +00:00
ld b, 0
.loop
ld a, [hli]
and a
ret z
inc b
ld a, b
cp NUM_UNOWN
2015-11-19 23:07:20 +00:00
jr c, .loop
ret
Var_BoxFreeSpace:
2015-11-19 23:07:20 +00:00
; Remaining slots in the current box.
ld a, BANK(sBoxCount)
call OpenSRAM
2015-11-19 23:07:20 +00:00
ld hl, sBoxCount
ld a, MONS_PER_BOX
sub [hl]
ld b, a
call CloseSRAM
ld a, b
jp LoadStringBuffer2
2015-11-19 23:07:20 +00:00
Var_BattleResult:
; Outcome of the last battle.
2015-11-19 23:07:20 +00:00
ld a, [wBattleResult]
2018-04-05 15:44:02 +00:00
and $ff ^ BATTLERESULT_BITMASK
jp LoadStringBuffer2