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