2018-06-24 14:09:41 +00:00
|
|
|
_NameRater:
|
2015-07-19 08:58:31 +00:00
|
|
|
; Introduce himself
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterHelloText
|
2013-09-09 20:09:34 +00:00
|
|
|
call PrintText
|
2013-12-04 07:49:12 +00:00
|
|
|
call YesNoBox
|
2015-07-19 08:58:31 +00:00
|
|
|
jp c, .cancel
|
|
|
|
; Select a Pokemon from your party
|
|
|
|
ld hl, NameRaterWhichMonText
|
2013-09-09 20:09:34 +00:00
|
|
|
call PrintText
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall SelectMonFromParty
|
2015-07-19 08:58:31 +00:00
|
|
|
jr c, .cancel
|
|
|
|
; He can't rename an egg...
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartySpecies]
|
2013-09-09 20:09:34 +00:00
|
|
|
cp EGG
|
2015-07-19 08:58:31 +00:00
|
|
|
jr z, .egg
|
|
|
|
; ... or a Pokemon you got from a trade.
|
2013-09-09 20:09:34 +00:00
|
|
|
call GetCurNick
|
2015-07-19 08:58:31 +00:00
|
|
|
call CheckIfMonIsYourOT
|
|
|
|
jr c, .traded
|
|
|
|
; This name is good, but we can do better. How about it?
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterBetterNameText
|
2013-09-09 20:09:34 +00:00
|
|
|
call PrintText
|
2013-12-04 07:49:12 +00:00
|
|
|
call YesNoBox
|
2015-07-19 08:58:31 +00:00
|
|
|
jr c, .cancel
|
|
|
|
; What name shall I give it then?
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterWhatNameText
|
2013-09-09 20:09:34 +00:00
|
|
|
call PrintText
|
2018-01-23 22:39:09 +00:00
|
|
|
; Load the new nickname into wStringBuffer2
|
2015-10-08 01:27:32 +00:00
|
|
|
xor a ; PARTYMON
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMonType], a
|
|
|
|
ld a, [wCurPartySpecies]
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurSpecies], a
|
2013-09-09 20:09:34 +00:00
|
|
|
call GetBaseData
|
2018-09-16 20:02:58 +00:00
|
|
|
ld b, NAME_MON
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wStringBuffer2
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall _NamingScreen
|
2015-07-19 08:58:31 +00:00
|
|
|
; If the new name is empty, treat it as unchanged.
|
|
|
|
call IsNewNameEmpty
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterSameNameText
|
2015-07-19 08:58:31 +00:00
|
|
|
jr c, .samename
|
|
|
|
; If the new name is the same as the old name, treat it as unchanged.
|
|
|
|
call CompareNewToOld
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterSameNameText
|
2015-07-19 08:58:31 +00:00
|
|
|
jr c, .samename
|
2018-01-23 22:39:09 +00:00
|
|
|
; Copy the new name from wStringBuffer2
|
|
|
|
ld hl, wPartyMonNicknames
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2013-09-09 20:09:34 +00:00
|
|
|
call AddNTimes
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wStringBuffer2
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2013-09-09 20:09:34 +00:00
|
|
|
call CopyBytes
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterFinishedText
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.samename
|
2013-09-09 20:09:34 +00:00
|
|
|
push hl
|
|
|
|
call GetCurNick
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterNamedText
|
2013-09-09 20:09:34 +00:00
|
|
|
call PrintText
|
|
|
|
pop hl
|
2015-07-19 08:58:31 +00:00
|
|
|
jr .done
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.traded
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterPerfectNameText
|
2015-07-19 08:58:31 +00:00
|
|
|
jr .done
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.cancel
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, NameRaterComeAgainText
|
2015-07-19 08:58:31 +00:00
|
|
|
jr .done
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.egg
|
|
|
|
ld hl, NameRaterEggText
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.done
|
2013-09-09 20:09:34 +00:00
|
|
|
call PrintText
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckIfMonIsYourOT:
|
2018-01-23 22:39:09 +00:00
|
|
|
; Checks to see if the partymon loaded in [wCurPartyMon] has the different OT as you. Returns carry if not.
|
|
|
|
ld hl, wPartyMonOT
|
2014-06-13 01:32:42 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2013-09-09 20:09:34 +00:00
|
|
|
call AddNTimes
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wPlayerName
|
2014-06-13 01:32:42 +00:00
|
|
|
ld c, NAME_LENGTH
|
2015-07-19 08:58:31 +00:00
|
|
|
call .loop
|
|
|
|
jr c, .nope
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMon1ID
|
2015-11-04 16:19:58 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2013-09-09 20:09:34 +00:00
|
|
|
call AddNTimes
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wPlayerID
|
2015-07-19 08:58:31 +00:00
|
|
|
ld c, 2 ; number of bytes in which your ID is stored
|
|
|
|
.loop
|
2013-09-09 20:09:34 +00:00
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .nope
|
2013-09-09 20:09:34 +00:00
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
dec c
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .loop
|
2013-09-09 20:09:34 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.nope
|
2013-09-09 20:09:34 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
IsNewNameEmpty:
|
2018-01-23 22:39:09 +00:00
|
|
|
; Checks to see if the nickname loaded in wStringBuffer2 is empty. If so, return carry.
|
|
|
|
ld hl, wStringBuffer2
|
2018-01-20 17:25:55 +00:00
|
|
|
ld c, MON_NAME_LENGTH - 1
|
2015-07-19 08:58:31 +00:00
|
|
|
.loop
|
2013-09-09 20:09:34 +00:00
|
|
|
ld a, [hli]
|
|
|
|
cp "@"
|
2015-07-19 08:58:31 +00:00
|
|
|
jr z, .terminator
|
2013-09-09 20:09:34 +00:00
|
|
|
cp " "
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .nonspace
|
2013-09-09 20:09:34 +00:00
|
|
|
dec c
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .loop
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.terminator
|
2013-09-09 20:09:34 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.nonspace
|
2013-09-09 20:09:34 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CompareNewToOld:
|
2018-01-23 22:39:09 +00:00
|
|
|
; Compares the nickname in wStringBuffer2 to the previous nickname. If they are the same, return carry.
|
|
|
|
ld hl, wPartyMonNicknames
|
2018-01-20 17:25:55 +00:00
|
|
|
ld bc, MON_NAME_LENGTH
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartyMon]
|
2013-09-09 20:09:34 +00:00
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2015-07-19 08:58:31 +00:00
|
|
|
call GetNicknameLength
|
2013-09-09 20:09:34 +00:00
|
|
|
ld b, c
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wStringBuffer2
|
2015-07-19 08:58:31 +00:00
|
|
|
call GetNicknameLength
|
2013-09-09 20:09:34 +00:00
|
|
|
pop hl
|
|
|
|
ld a, c
|
|
|
|
cp b
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .different
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wStringBuffer2
|
2015-07-19 08:58:31 +00:00
|
|
|
.loop
|
2013-09-09 20:09:34 +00:00
|
|
|
ld a, [de]
|
|
|
|
cp "@"
|
2015-07-19 08:58:31 +00:00
|
|
|
jr z, .terminator
|
2013-09-09 20:09:34 +00:00
|
|
|
cp [hl]
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .different
|
2013-09-09 20:09:34 +00:00
|
|
|
inc hl
|
|
|
|
inc de
|
2015-07-19 08:58:31 +00:00
|
|
|
jr .loop
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.different
|
2013-09-09 20:09:34 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-07-19 08:58:31 +00:00
|
|
|
.terminator
|
2013-09-09 20:09:34 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
GetNicknameLength:
|
2015-07-19 08:58:31 +00:00
|
|
|
; Gets the length of the name starting at hl and returns it in c.
|
2013-09-09 20:09:34 +00:00
|
|
|
ld c, 0
|
2015-07-19 08:58:31 +00:00
|
|
|
.loop
|
2013-09-09 20:09:34 +00:00
|
|
|
ld a, [hli]
|
|
|
|
cp "@"
|
|
|
|
ret z
|
|
|
|
inc c
|
|
|
|
ld a, c
|
2018-01-20 17:25:55 +00:00
|
|
|
cp MON_NAME_LENGTH - 1
|
2015-07-19 08:58:31 +00:00
|
|
|
jr nz, .loop
|
2013-09-09 20:09:34 +00:00
|
|
|
ret
|
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterHelloText:
|
|
|
|
text_far _NameRaterHelloText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
NameRaterWhichMonText:
|
2019-10-20 22:24:17 +00:00
|
|
|
text_far _NameRaterWhichMonText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterBetterNameText:
|
|
|
|
text_far _NameRaterBetterNameText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterWhatNameText:
|
|
|
|
text_far _NameRaterWhatNameText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterFinishedText:
|
|
|
|
text_far _NameRaterFinishedText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterComeAgainText:
|
|
|
|
text_far _NameRaterComeAgainText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterPerfectNameText:
|
|
|
|
text_far _NameRaterPerfectNameText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
NameRaterEggText:
|
2019-10-20 22:24:17 +00:00
|
|
|
text_far _NameRaterEggText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterSameNameText:
|
|
|
|
text_far _NameRaterSameNameText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2013-09-09 20:09:34 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
NameRaterNamedText:
|
|
|
|
text_far _NameRaterNamedText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|