2018-06-24 07:09:41 -07:00
|
|
|
_GetVarAction::
|
2015-11-19 15:07:20 -08:00
|
|
|
ld a, c
|
|
|
|
cp NUM_VARS
|
|
|
|
jr c, .valid
|
|
|
|
xor a
|
|
|
|
.valid
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2020-07-22 17:21:26 -07:00
|
|
|
ld hl, .VarActionTable
|
2015-11-19 15:07:20 -08:00
|
|
|
add hl, bc
|
2016-05-10 09:31:49 -07:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2015-11-19 15:07:20 -08:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
inc hl
|
|
|
|
ld b, [hl]
|
|
|
|
ld a, b
|
|
|
|
and RETVAR_EXECUTE
|
2020-07-22 17:21:26 -07:00
|
|
|
jr nz, .call
|
2015-11-19 15:07:20 -08:00
|
|
|
ld a, b
|
|
|
|
and RETVAR_ADDR_DE
|
|
|
|
ret nz
|
|
|
|
ld a, [de]
|
2020-07-22 17:21:26 -07:00
|
|
|
jr .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.call
|
2015-11-19 15:07:20 -08:00
|
|
|
call _de_
|
|
|
|
ret
|
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.loadstringbuffer2
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
ld [de], a
|
|
|
|
ret
|
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.VarActionTable:
|
|
|
|
; entries correspond to VAR_* constants
|
|
|
|
; RETVAR_STRBUF2: copy [de] to wStringBuffer2
|
|
|
|
; RETVAR_ADDR_DE: return address in de
|
|
|
|
; RETVAR_EXECUTE: call function
|
|
|
|
dwb wStringBuffer2, RETVAR_STRBUF2
|
|
|
|
dwb wPartyCount, RETVAR_STRBUF2
|
|
|
|
dwb .BattleResult, RETVAR_EXECUTE
|
|
|
|
dwb wBattleType, RETVAR_ADDR_DE
|
|
|
|
dwb wTimeOfDay, RETVAR_STRBUF2
|
|
|
|
dwb .CountCaughtMons, RETVAR_EXECUTE
|
|
|
|
dwb .CountSeenMons, RETVAR_EXECUTE
|
|
|
|
dwb .CountBadges, RETVAR_EXECUTE
|
|
|
|
dwb wPlayerState, RETVAR_ADDR_DE
|
|
|
|
dwb .PlayerFacing, RETVAR_EXECUTE
|
|
|
|
dwb .DayOfWeek, RETVAR_EXECUTE
|
|
|
|
dwb wMapGroup, RETVAR_STRBUF2
|
|
|
|
dwb wMapNumber, RETVAR_STRBUF2
|
|
|
|
dwb .UnownCaught, RETVAR_EXECUTE
|
|
|
|
dwb wEnvironment, RETVAR_STRBUF2
|
|
|
|
dwb .BoxFreeSpace, RETVAR_EXECUTE
|
|
|
|
dwb wBugContestMinsRemaining, RETVAR_STRBUF2
|
|
|
|
dwb wXCoord, RETVAR_STRBUF2
|
|
|
|
dwb wYCoord, RETVAR_STRBUF2
|
|
|
|
dwb wSpecialPhoneCallID, RETVAR_STRBUF2
|
|
|
|
dwb wKurtApricornQuantity, RETVAR_STRBUF2
|
|
|
|
dwb wCurCaller, RETVAR_ADDR_DE
|
|
|
|
dwb wBlueCardBalance, RETVAR_ADDR_DE
|
|
|
|
dwb wBuenasPassword, RETVAR_ADDR_DE
|
|
|
|
dwb NULL, RETVAR_STRBUF2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.CountCaughtMons:
|
2015-11-19 15:07:20 -08:00
|
|
|
; Caught mons.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPokedexCaught
|
|
|
|
ld b, wEndPokedexCaught - wPokedexCaught
|
2015-11-19 15:07:20 -08:00
|
|
|
call CountSetBits
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNumSetBits]
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.CountSeenMons:
|
2015-11-19 15:07:20 -08:00
|
|
|
; Seen mons.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPokedexSeen
|
|
|
|
ld b, wEndPokedexSeen - wPokedexSeen
|
2015-11-19 15:07:20 -08:00
|
|
|
call CountSetBits
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNumSetBits]
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.CountBadges:
|
2015-11-19 15:07:20 -08:00
|
|
|
; Number of owned badges.
|
2018-01-23 13:45:34 -08:00
|
|
|
ld hl, wBadges
|
2015-11-19 15:07:20 -08:00
|
|
|
ld b, 2
|
|
|
|
call CountSetBits
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNumSetBits]
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.PlayerFacing:
|
2015-11-19 15:07:20 -08:00
|
|
|
; The direction the player is facing.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerDirection]
|
2015-11-19 15:07:20 -08:00
|
|
|
and $c
|
|
|
|
rrca
|
|
|
|
rrca
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.DayOfWeek:
|
2015-11-19 15:07:20 -08:00
|
|
|
; The day of the week.
|
|
|
|
call GetWeekday
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.UnownCaught:
|
2015-11-19 15:07:20 -08:00
|
|
|
; Number of unique Unown caught.
|
2020-06-17 19:12:04 -07:00
|
|
|
call .count_unown
|
2015-11-19 15:07:20 -08:00
|
|
|
ld a, b
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.count_unown
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wUnownDex
|
2015-11-19 15:07:20 -08:00
|
|
|
ld b, 0
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
inc b
|
|
|
|
ld a, b
|
2018-01-10 23:35:46 -08:00
|
|
|
cp NUM_UNOWN
|
2015-11-19 15:07:20 -08:00
|
|
|
jr c, .loop
|
|
|
|
ret
|
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.BoxFreeSpace:
|
2015-11-19 15:07:20 -08:00
|
|
|
; Remaining slots in the current box.
|
|
|
|
ld a, BANK(sBoxCount)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-19 15:07:20 -08:00
|
|
|
ld hl, sBoxCount
|
|
|
|
ld a, MONS_PER_BOX
|
|
|
|
sub [hl]
|
|
|
|
ld b, a
|
|
|
|
call CloseSRAM
|
|
|
|
ld a, b
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|
2015-11-19 15:07:20 -08:00
|
|
|
|
2020-07-22 17:21:26 -07:00
|
|
|
.BattleResult:
|
2015-11-19 15:07:20 -08:00
|
|
|
ld a, [wBattleResult]
|
2021-11-23 17:37:18 -08:00
|
|
|
and ~BATTLERESULT_BITMASK
|
2020-07-22 17:21:26 -07:00
|
|
|
jp .loadstringbuffer2
|