2018-06-24 07:09:41 -07:00
|
|
|
AddPhoneNumber::
|
2015-10-24 07:34:19 -07:00
|
|
|
call _CheckCellNum
|
|
|
|
jr c, .cant_add
|
|
|
|
call Phone_FindOpenSlot
|
|
|
|
jr nc, .cant_add
|
|
|
|
ld [hl], c
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.cant_add
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DelCellNum::
|
2015-10-24 07:34:19 -07:00
|
|
|
call _CheckCellNum
|
|
|
|
jr nc, .not_in_list
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.not_in_list
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckCellNum::
|
2020-02-23 12:30:21 -08:00
|
|
|
jp _CheckCellNum ; useless
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_CheckCellNum:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, wPhoneList
|
|
|
|
ld b, CONTACT_LIST_SIZE
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr z, .got_it
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.got_it
|
|
|
|
dec hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Phone_FindOpenSlot:
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetRemainingSpaceInPhoneList
|
|
|
|
ld b, a
|
|
|
|
ld hl, wPhoneList
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .FoundOpenSpace
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FoundOpenSpace:
|
2015-10-24 07:34:19 -07:00
|
|
|
dec hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetRemainingSpaceInPhoneList:
|
2015-10-24 07:34:19 -07:00
|
|
|
xor a
|
2020-11-03 16:53:07 -08:00
|
|
|
ld [wRegisteredPhoneNumbers], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, PermanentNumbers
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp -1
|
|
|
|
jr z, .done
|
|
|
|
cp c
|
2018-01-10 22:45:27 -08:00
|
|
|
jr z, .continue
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
ld c, a
|
|
|
|
call _CheckCellNum
|
2018-01-10 22:45:27 -08:00
|
|
|
jr c, .permanent
|
2020-11-03 16:53:07 -08:00
|
|
|
ld hl, wRegisteredPhoneNumbers
|
2015-10-24 07:34:19 -07:00
|
|
|
inc [hl]
|
2018-01-10 22:45:27 -08:00
|
|
|
.permanent
|
2015-10-24 07:34:19 -07:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
|
2018-01-10 22:45:27 -08:00
|
|
|
.continue
|
2015-10-24 07:34:19 -07:00
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, CONTACT_LIST_SIZE
|
2020-11-03 16:53:07 -08:00
|
|
|
ld hl, wRegisteredPhoneNumbers
|
2015-10-24 07:34:19 -07:00
|
|
|
sub [hl]
|
|
|
|
ret
|
|
|
|
|
2018-01-10 22:45:27 -08:00
|
|
|
INCLUDE "data/phone/permanent_numbers.asm"
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckPhoneCall::
|
2015-10-24 07:34:19 -07:00
|
|
|
; Check if the phone is ringing in the overworld.
|
|
|
|
|
|
|
|
call CheckStandingOnEntrance
|
|
|
|
jr z, .no_call
|
|
|
|
|
|
|
|
call .timecheck
|
|
|
|
nop
|
|
|
|
jr nc, .no_call
|
|
|
|
|
2021-09-07 16:18:22 -07:00
|
|
|
; 50% chance for a call
|
2015-10-24 07:34:19 -07:00
|
|
|
call Random
|
|
|
|
ld b, a
|
2021-09-07 16:18:22 -07:00
|
|
|
and %01111111
|
2015-10-24 07:34:19 -07:00
|
|
|
cp b
|
|
|
|
jr nz, .no_call
|
|
|
|
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapPhoneService
|
2015-10-24 07:34:19 -07:00
|
|
|
and a
|
|
|
|
jr nz, .no_call
|
|
|
|
|
|
|
|
call GetAvailableCallers
|
|
|
|
call ChooseRandomCaller
|
|
|
|
jr nc, .no_call
|
|
|
|
|
|
|
|
ld e, a
|
|
|
|
call LoadCallerScript
|
|
|
|
ld a, BANK(Script_ReceivePhoneCall)
|
|
|
|
ld hl, Script_ReceivePhoneCall
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.no_call
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.timecheck
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckReceiveCallTimer
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckPhoneContactTimeOfDay:
|
2015-10-24 07:34:19 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push af
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckTime
|
2015-10-24 07:34:19 -07:00
|
|
|
pop af
|
2018-01-15 19:00:56 -08:00
|
|
|
and ANYTIME
|
2015-10-24 07:34:19 -07:00
|
|
|
and c
|
|
|
|
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ChooseRandomCaller:
|
2015-10-24 07:34:19 -07:00
|
|
|
; If no one is available to call, don't return anything.
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wNumAvailableCallers]
|
2015-10-24 07:34:19 -07:00
|
|
|
and a
|
|
|
|
jr z, .NothingToSample
|
|
|
|
|
2019-04-08 15:50:10 -07:00
|
|
|
; Store the number of available callers in c.
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, a
|
2019-04-08 15:50:10 -07:00
|
|
|
; Sample a random number between 0 and 31.
|
2015-10-24 07:34:19 -07:00
|
|
|
call Random
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hRandomAdd]
|
2015-10-24 07:34:19 -07:00
|
|
|
swap a
|
|
|
|
and $1f
|
|
|
|
; Compute that number modulo the number of available callers.
|
|
|
|
call SimpleDivide
|
|
|
|
; Return the caller ID you just sampled.
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2019-04-08 15:50:10 -07:00
|
|
|
ld hl, wAvailableCallers
|
2015-10-24 07:34:19 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NothingToSample:
|
2015-10-24 07:34:19 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetAvailableCallers:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckTime
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, c
|
2019-04-08 15:50:10 -07:00
|
|
|
ld [wCheckedTime], a
|
|
|
|
ld hl, wNumAvailableCallers
|
|
|
|
ld bc, CONTACT_LIST_SIZE + 1
|
2015-10-24 07:34:19 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
ld de, wPhoneList
|
|
|
|
ld a, CONTACT_LIST_SIZE
|
|
|
|
|
|
|
|
.loop
|
2019-04-08 15:50:10 -07:00
|
|
|
ld [wPhoneListIndex], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
jr z, .not_good_for_call
|
|
|
|
ld hl, PhoneContacts + PHONE_CONTACT_SCRIPT2_TIME
|
2019-04-08 15:50:10 -07:00
|
|
|
ld bc, PHONE_CONTACT_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call AddNTimes
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wCheckedTime]
|
2015-10-24 07:34:19 -07:00
|
|
|
and [hl]
|
|
|
|
jr z, .not_good_for_call
|
|
|
|
ld bc, PHONE_CONTACT_MAP_GROUP - PHONE_CONTACT_SCRIPT2_TIME
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2015-10-24 07:34:19 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .different_map
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2015-10-24 07:34:19 -07:00
|
|
|
cp [hl]
|
|
|
|
jr z, .not_good_for_call
|
|
|
|
.different_map
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wNumAvailableCallers]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, a
|
2020-11-09 12:17:03 -08:00
|
|
|
ld b, 0
|
2015-10-24 07:34:19 -07:00
|
|
|
inc a
|
2019-04-08 15:50:10 -07:00
|
|
|
ld [wNumAvailableCallers], a
|
|
|
|
ld hl, wAvailableCallers
|
2015-10-24 07:34:19 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
|
|
|
.not_good_for_call
|
|
|
|
inc de
|
2019-04-08 15:50:10 -07:00
|
|
|
ld a, [wPhoneListIndex]
|
2015-10-24 07:34:19 -07:00
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckSpecialPhoneCall::
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wSpecialPhoneCallID]
|
|
|
|
and a
|
|
|
|
jr z, .NoPhoneCall
|
|
|
|
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, SpecialPhoneCallList
|
2021-03-03 19:22:41 -08:00
|
|
|
ld a, SPECIALCALL_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call _hl_
|
|
|
|
jr nc, .NoPhoneCall
|
|
|
|
|
|
|
|
call .DoSpecialPhoneCall
|
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
push hl
|
|
|
|
call LoadCallerScript
|
|
|
|
pop hl
|
2019-04-08 15:50:10 -07:00
|
|
|
ld de, wCallerContact + PHONE_CONTACT_SCRIPT2_BANK
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
ld a, BANK(.script)
|
|
|
|
ld hl, .script
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
2016-04-10 11:42:14 -07:00
|
|
|
.NoPhoneCall:
|
2015-10-24 07:34:19 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.script
|
2015-10-24 07:34:19 -07:00
|
|
|
pause 30
|
2019-03-10 13:39:31 -07:00
|
|
|
sjump Script_ReceivePhoneCall
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.DoSpecialPhoneCall:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wSpecialPhoneCallID]
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, SpecialPhoneCallList
|
2021-03-03 19:22:41 -08:00
|
|
|
ld a, SPECIALCALL_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpecialCallOnlyWhenOutside:
|
2017-12-24 10:08:38 -08:00
|
|
|
ld a, [wEnvironment]
|
2023-08-04 09:45:50 -07:00
|
|
|
cp INDOOR_ENVIRONMENT
|
|
|
|
jr c, .outside
|
2015-10-24 07:34:19 -07:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.outside
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpecialCallWhereverYouAre:
|
2015-10-24 07:34:19 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-04 19:34:50 -07:00
|
|
|
MakePhoneCallFromPokegear:
|
2015-10-24 07:34:19 -07:00
|
|
|
; Don't do the call if you're in a link communication
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .OutOfArea
|
|
|
|
; If you're in an area without phone service, don't do the call
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapPhoneService
|
2015-10-24 07:34:19 -07:00
|
|
|
and a
|
|
|
|
jr nz, .OutOfArea
|
|
|
|
; If the person can't take a call at that time, don't do the call
|
|
|
|
ld a, b
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurCaller], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, PhoneContacts
|
2019-04-08 15:50:10 -07:00
|
|
|
ld bc, PHONE_CONTACT_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld hl, PHONE_CONTACT_SCRIPT1_TIME
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
call CheckPhoneContactTimeOfDay
|
|
|
|
jr z, .OutOfArea
|
|
|
|
; If we're in the same map as the person we're calling,
|
|
|
|
; use the "Just talk to that person" script.
|
|
|
|
ld hl, PHONE_CONTACT_MAP_GROUP
|
|
|
|
add hl, de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2015-10-24 07:34:19 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .GetPhoneScript
|
|
|
|
ld hl, PHONE_CONTACT_MAP_NUMBER
|
|
|
|
add hl, de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2015-10-24 07:34:19 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .GetPhoneScript
|
|
|
|
ld b, BANK(PhoneScript_JustTalkToThem)
|
|
|
|
ld hl, PhoneScript_JustTalkToThem
|
|
|
|
jr .DoPhoneCall
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetPhoneScript:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, PHONE_CONTACT_SCRIPT1_BANK
|
|
|
|
add hl, de
|
|
|
|
ld b, [hl]
|
2020-07-08 13:20:15 -07:00
|
|
|
ld hl, PHONE_CONTACT_SCRIPT1_ADDR
|
2015-10-24 07:34:19 -07:00
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jr .DoPhoneCall
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.OutOfArea:
|
2019-10-20 15:24:17 -07:00
|
|
|
ld b, BANK(LoadOutOfAreaScript)
|
|
|
|
ld de, LoadOutOfAreaScript
|
2015-10-24 07:34:19 -07:00
|
|
|
call ExecuteCallbackScript
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoPhoneCall:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPhoneScriptBank], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPhoneCaller], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPhoneCaller + 1], a
|
2019-10-20 15:24:17 -07:00
|
|
|
ld b, BANK(LoadPhoneScriptBank)
|
|
|
|
ld de, LoadPhoneScriptBank
|
2015-10-24 07:34:19 -07:00
|
|
|
call ExecuteCallbackScript
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
LoadPhoneScriptBank:
|
2019-03-10 13:39:31 -07:00
|
|
|
memcall wPhoneScriptBank
|
2020-07-17 05:37:03 -07:00
|
|
|
endcallback
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
LoadOutOfAreaScript:
|
|
|
|
scall PhoneOutOfAreaScript
|
2020-07-17 05:37:03 -07:00
|
|
|
endcallback
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadCallerScript:
|
2015-10-24 07:34:19 -07:00
|
|
|
nop
|
|
|
|
nop
|
|
|
|
ld a, e
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurCaller], a
|
2015-10-24 07:34:19 -07:00
|
|
|
and a
|
|
|
|
jr nz, .actualcaller
|
|
|
|
ld a, BANK(WrongNumber)
|
|
|
|
ld hl, WrongNumber
|
|
|
|
jr .proceed
|
|
|
|
|
|
|
|
.actualcaller
|
|
|
|
ld hl, PhoneContacts
|
2019-04-08 15:50:10 -07:00
|
|
|
ld bc, PHONE_CONTACT_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, e
|
|
|
|
call AddNTimes
|
|
|
|
ld a, BANK(PhoneContacts)
|
|
|
|
.proceed
|
2019-04-08 15:50:10 -07:00
|
|
|
ld de, wCallerContact
|
|
|
|
ld bc, PHONE_CONTACT_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call FarCopyBytes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WrongNumber:
|
2015-10-24 16:49:19 -07:00
|
|
|
db TRAINER_NONE, PHONE_00
|
2015-10-24 07:34:19 -07:00
|
|
|
dba .script
|
2016-04-10 12:01:49 -07:00
|
|
|
.script
|
2019-10-20 15:24:17 -07:00
|
|
|
writetext .PhoneWrongNumberText
|
2015-10-24 07:34:19 -07:00
|
|
|
end
|
2019-10-20 15:24:17 -07:00
|
|
|
.PhoneWrongNumberText:
|
|
|
|
text_far _PhoneWrongNumberText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
Script_ReceivePhoneCall:
|
2024-02-10 15:16:00 -08:00
|
|
|
reanchormap
|
2015-10-24 07:34:19 -07:00
|
|
|
callasm RingTwice_StartCall
|
2019-04-08 15:50:10 -07:00
|
|
|
memcall wCallerContact + PHONE_CONTACT_SCRIPT2_BANK
|
2015-11-25 07:16:29 -08:00
|
|
|
waitbutton
|
2015-10-24 07:34:19 -07:00
|
|
|
callasm HangUp
|
2015-11-25 07:16:29 -08:00
|
|
|
closetext
|
2015-10-24 07:34:19 -07:00
|
|
|
callasm InitCallReceiveDelay
|
|
|
|
end
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
Script_SpecialBillCall::
|
2016-03-27 09:47:28 -07:00
|
|
|
callasm .LoadBillScript
|
2019-03-10 13:39:31 -07:00
|
|
|
sjump Script_ReceivePhoneCall
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LoadBillScript:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld e, PHONE_BILL
|
|
|
|
jp LoadCallerScript
|
|
|
|
|
2020-10-26 12:45:57 -07:00
|
|
|
Script_SpecialElmCall: ; unreferenced
|
2016-03-27 09:47:28 -07:00
|
|
|
callasm .LoadElmScript
|
2015-10-24 07:34:19 -07:00
|
|
|
pause 30
|
2019-03-10 13:39:31 -07:00
|
|
|
sjump Script_ReceivePhoneCall
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LoadElmScript:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld e, PHONE_ELM
|
|
|
|
jp LoadCallerScript
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RingTwice_StartCall:
|
2015-10-24 07:34:19 -07:00
|
|
|
call .Ring
|
|
|
|
call .Ring
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Ring:
|
2015-10-24 07:34:19 -07:00
|
|
|
call Phone_StartRinging
|
|
|
|
call Phone_Wait20Frames
|
2020-12-07 10:32:08 -08:00
|
|
|
call .CallerTextboxWithName
|
2015-10-24 07:34:19 -07:00
|
|
|
call Phone_Wait20Frames
|
|
|
|
call Phone_CallerTextbox
|
|
|
|
call Phone_Wait20Frames
|
2020-12-07 10:32:08 -08:00
|
|
|
call .CallerTextboxWithName
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2020-12-07 10:32:08 -08:00
|
|
|
.CallerTextboxWithName:
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurCaller]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld b, a
|
2020-10-04 19:34:50 -07:00
|
|
|
call Phone_TextboxWithName
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PhoneCall::
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPhoneScriptBank], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPhoneCaller], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPhoneCaller + 1], a
|
2020-12-07 10:32:08 -08:00
|
|
|
call .Ring
|
|
|
|
call .Ring
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2020-12-07 10:32:08 -08:00
|
|
|
.Ring:
|
2015-10-24 07:34:19 -07:00
|
|
|
call Phone_StartRinging
|
|
|
|
call Phone_Wait20Frames
|
2020-12-07 10:32:08 -08:00
|
|
|
call .CallerTextboxWithName
|
2015-10-24 07:34:19 -07:00
|
|
|
call Phone_Wait20Frames
|
|
|
|
call Phone_CallerTextbox
|
|
|
|
call Phone_Wait20Frames
|
2020-12-07 10:32:08 -08:00
|
|
|
call .CallerTextboxWithName
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2020-12-07 10:32:08 -08:00
|
|
|
.CallerTextboxWithName:
|
2015-10-24 07:34:19 -07:00
|
|
|
call Phone_CallerTextbox
|
|
|
|
hlcoord 1, 2
|
2018-01-18 23:30:19 -08:00
|
|
|
ld [hl], "☎"
|
2015-10-24 07:34:19 -07:00
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPhoneCaller]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPhoneCaller + 1]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld d, a
|
2023-07-27 04:01:32 -07:00
|
|
|
ld a, [wPhoneScriptBank]
|
|
|
|
call PlaceFarString
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Phone_NoSignal:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld de, SFX_NO_SIGNAL
|
|
|
|
call PlaySFX
|
|
|
|
jr Phone_CallEnd
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HangUp::
|
2015-10-24 07:34:19 -07:00
|
|
|
call HangUp_Beep
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
Phone_CallEnd:
|
|
|
|
call HangUp_BoopOn
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
call HangUp_BoopOff
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
call HangUp_BoopOn
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
call HangUp_BoopOff
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
call HangUp_BoopOn
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
call HangUp_BoopOff
|
|
|
|
call HangUp_Wait20Frames
|
|
|
|
ret
|
|
|
|
|
2020-10-05 13:15:57 -07:00
|
|
|
HangUp_ShutDown: ; unreferenced
|
2015-10-24 07:34:19 -07:00
|
|
|
ld de, SFX_SHUT_DOWN_PC
|
|
|
|
call PlaySFX
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HangUp_Beep:
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, PhoneClickText
|
2023-08-11 03:28:14 -07:00
|
|
|
call PrintText2bpp
|
2015-10-24 07:34:19 -07:00
|
|
|
ld de, SFX_HANG_UP
|
|
|
|
call PlaySFX
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
PhoneClickText:
|
|
|
|
text_far _PhoneClickText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HangUp_BoopOn:
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, PhoneEllipseText
|
2023-08-11 03:28:14 -07:00
|
|
|
call PrintText2bpp
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
PhoneEllipseText:
|
|
|
|
text_far _PhoneEllipseText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HangUp_BoopOff:
|
2023-08-11 03:28:14 -07:00
|
|
|
call SpeechTextbox2bpp
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Phone_StartRinging:
|
2015-10-24 07:34:19 -07:00
|
|
|
call WaitSFX
|
|
|
|
ld de, SFX_CALL
|
|
|
|
call PlaySFX
|
|
|
|
call Phone_CallerTextbox
|
|
|
|
call UpdateSprites
|
2023-08-29 09:33:20 -07:00
|
|
|
call PhoneRing_CopyTilemapAtOnce
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HangUp_Wait20Frames:
|
2015-10-24 07:34:19 -07:00
|
|
|
jr Phone_Wait20Frames
|
|
|
|
|
2018-05-05 00:19:04 -07:00
|
|
|
Phone_Wait20Frames:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
2023-08-29 09:33:20 -07:00
|
|
|
call PhoneRing_CopyTilemapAtOnce
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2023-08-28 08:31:39 -07:00
|
|
|
PhoneRing_CopyTilemapAtOnce:
|
|
|
|
ld a, [wSpriteUpdatesEnabled]
|
|
|
|
and a
|
|
|
|
jp z, WaitBGMap
|
|
|
|
jp CopyTilemapAtOnce
|
|
|
|
|
2020-10-04 19:34:50 -07:00
|
|
|
Phone_TextboxWithName:
|
2015-10-24 07:34:19 -07:00
|
|
|
push bc
|
|
|
|
call Phone_CallerTextbox
|
|
|
|
hlcoord 1, 1
|
2018-01-18 23:30:19 -08:00
|
|
|
ld [hl], "☎"
|
2015-10-24 07:34:19 -07:00
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2015-10-24 07:34:19 -07:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop bc
|
2020-10-04 19:34:50 -07:00
|
|
|
call GetCallerClassAndName
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Phone_CallerTextbox:
|
2015-10-24 07:34:19 -07:00
|
|
|
hlcoord 0, 0
|
|
|
|
ld b, 2
|
|
|
|
ld c, SCREEN_WIDTH - 2
|
2023-08-11 03:28:14 -07:00
|
|
|
call Textbox1bpp
|
2015-10-24 07:34:19 -07:00
|
|
|
ret
|
|
|
|
|
2020-10-04 19:34:50 -07:00
|
|
|
GetCallerClassAndName:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
ld a, b
|
|
|
|
call GetCallerTrainerClass
|
|
|
|
call GetCallerName
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckCanDeletePhoneNumber:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, c
|
|
|
|
call GetCallerTrainerClass
|
|
|
|
ld a, c
|
2016-01-09 20:41:03 -08:00
|
|
|
; and a
|
2015-10-24 07:34:19 -07:00
|
|
|
ret nz
|
|
|
|
ld a, b
|
2016-01-09 20:41:03 -08:00
|
|
|
cp PHONECONTACT_MOM
|
2015-10-24 07:34:19 -07:00
|
|
|
ret z
|
2016-01-09 20:41:03 -08:00
|
|
|
cp PHONECONTACT_ELM
|
2015-10-24 07:34:19 -07:00
|
|
|
ret z
|
|
|
|
ld c, $1
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetCallerTrainerClass:
|
2015-10-24 07:34:19 -07:00
|
|
|
push hl
|
|
|
|
ld hl, PhoneContacts + PHONE_CONTACT_TRAINER_CLASS
|
2019-04-08 15:50:10 -07:00
|
|
|
ld bc, PHONE_CONTACT_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, [hl]
|
|
|
|
ld c, a
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetCallerName:
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr z, .NotTrainer
|
|
|
|
|
|
|
|
call Phone_GetTrainerName
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
call PlaceString
|
|
|
|
ld a, ":"
|
|
|
|
ld [bc], a
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ld de, SCREEN_WIDTH + 3
|
|
|
|
add hl, de
|
|
|
|
call Phone_GetTrainerClassName
|
|
|
|
call PlaceString
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NotTrainer:
|
2015-10-24 07:34:19 -07:00
|
|
|
push hl
|
|
|
|
ld c, b
|
|
|
|
ld b, 0
|
|
|
|
ld hl, NonTrainerCallerNames
|
|
|
|
add hl, bc
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, bc
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld d, [hl]
|
|
|
|
pop hl
|
|
|
|
call PlaceString
|
|
|
|
ret
|
|
|
|
|
2018-01-25 19:19:24 -08:00
|
|
|
INCLUDE "data/phone/non_trainer_names.asm"
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Phone_GetTrainerName:
|
2015-10-24 07:34:19 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetTrainerName
|
2015-10-24 07:34:19 -07:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Phone_GetTrainerClassName:
|
2015-10-24 07:34:19 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetTrainerClassName
|
2015-10-24 07:34:19 -07:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetCallerLocation:
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurCaller]
|
2015-10-24 07:34:19 -07:00
|
|
|
call GetCallerTrainerClass
|
|
|
|
ld d, c
|
|
|
|
ld e, b
|
|
|
|
push de
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurCaller]
|
2015-10-24 07:34:19 -07:00
|
|
|
ld hl, PhoneContacts + PHONE_CONTACT_MAP_GROUP
|
2019-04-08 15:50:10 -07:00
|
|
|
ld bc, PHONE_CONTACT_SIZE
|
2015-10-24 07:34:19 -07:00
|
|
|
call AddNTimes
|
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
push bc
|
|
|
|
call GetWorldMapLocation
|
|
|
|
ld e, a
|
2023-08-20 03:08:24 -07:00
|
|
|
farcall LevelSelectionMenu_GetLandmarkName
|
2015-10-24 07:34:19 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-01-09 16:51:30 -08:00
|
|
|
INCLUDE "data/phone/phone_contacts.asm"
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-01-09 16:51:30 -08:00
|
|
|
INCLUDE "data/phone/special_calls.asm"
|
2017-12-11 19:44:25 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
PhoneOutOfAreaScript:
|
|
|
|
writetext PhoneOutOfAreaText
|
2015-10-24 07:34:19 -07:00
|
|
|
end
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
PhoneOutOfAreaText:
|
|
|
|
text_far _PhoneOutOfAreaText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
PhoneScript_JustTalkToThem:
|
2019-10-20 15:24:17 -07:00
|
|
|
writetext PhoneJustTalkToThemText
|
2015-10-24 07:34:19 -07:00
|
|
|
end
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
PhoneJustTalkToThemText:
|
|
|
|
text_far _PhoneJustTalkToThemText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2020-10-26 12:45:57 -07:00
|
|
|
PhoneThankYouTextScript: ; unreferenced
|
2019-10-20 15:24:17 -07:00
|
|
|
writetext PhoneThankYouText
|
2015-10-24 07:34:19 -07:00
|
|
|
end
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
PhoneThankYouText:
|
|
|
|
text_far _PhoneThankYouText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|