summaryrefslogtreecommitdiff
path: root/event/name_rater.asm
diff options
context:
space:
mode:
Diffstat (limited to 'event/name_rater.asm')
-rw-r--r--event/name_rater.asm165
1 files changed, 90 insertions, 75 deletions
diff --git a/event/name_rater.asm b/event/name_rater.asm
index 43d6c9a90..62edbcbee 100644
--- a/event/name_rater.asm
+++ b/event/name_rater.asm
@@ -1,24 +1,31 @@
NameRater: ; fb6ed
- ld hl, UnknownText_0xfb80f
+; Introduce himself
+ ld hl, NameRaterIntroText
call PrintText
call YesNoBox
- jp c, .asm_fb77e
- ld hl, UnknownText_0xfb814
+ jp c, .cancel
+; Select a Pokemon from your party
+ ld hl, NameRaterWhichMonText
call PrintText
- callba Function50000
- jr c, .asm_fb77e
+ callba SelectMonFromParty
+ jr c, .cancel
+; He can't rename an egg...
ld a, [CurPartySpecies]
cp EGG
- jr z, .asm_fb783
+ jr z, .egg
+; ... or a Pokemon you got from a trade.
call GetCurNick
- call Functionfb78a
- jr c, .asm_fb779
- ld hl, UnknownText_0xfb819
+ call CheckIfMonIsYourOT
+ jr c, .traded
+; This name is good, but we can do better. How about it?
+ ld hl, NameRaterIsGoodText
call PrintText
call YesNoBox
- jr c, .asm_fb77e
- ld hl, UnknownText_0xfb81e
+ jr c, .cancel
+; What name shall I give it then?
+ ld hl, NameRaterWhichNameText
call PrintText
+; Load the new nickname into StringBuffer2
xor a
ld [MonType], a
ld a, [CurPartySpecies]
@@ -27,148 +34,156 @@ NameRater: ; fb6ed
call GetBaseData
ld b, 0
ld de, StringBuffer2
- callba Function116b7
- call Functionfb7be
- ld hl, UnknownText_0xfb837
- jr c, .asm_fb76c
- call Functionfb7d3
- ld hl, UnknownText_0xfb837
- jr c, .asm_fb76c
+ callba _NamingScreen
+; If the new name is empty, treat it as unchanged.
+ call IsNewNameEmpty
+ ld hl, NameRaterSameAsBeforeText
+ jr c, .samename
+; If the new name is the same as the old name, treat it as unchanged.
+ call CompareNewToOld
+ ld hl, NameRaterSameAsBeforeText
+ jr c, .samename
+; Copy the new name from StringBuffer2
ld hl, PartyMonNicknames
- ld bc, $000b
+ ld bc, PKMN_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld e, l
ld d, h
ld hl, StringBuffer2
- ld bc, $000b
+ ld bc, PKMN_NAME_LENGTH
call CopyBytes
- ld hl, UnknownText_0xfb823
+ ld hl, NameRaterEvenBetterText
-.asm_fb76c
+.samename
push hl
call GetCurNick
- ld hl, UnknownText_0xfb83c
+ ld hl, NameRaterDoneText
call PrintText
pop hl
- jr .asm_fb786
+ jr .done
-.asm_fb779
- ld hl, UnknownText_0xfb82d
- jr .asm_fb786
+.traded
+ ld hl, NameRaterTradedText
+ jr .done
-.asm_fb77e
- ld hl, UnknownText_0xfb828
- jr .asm_fb786
+.cancel
+ ld hl, NameRaterCancelText
+ jr .done
-.asm_fb783
- ld hl, UnknownText_0xfb832
+.egg
+ ld hl, NameRaterEggText
-.asm_fb786
+.done
call PrintText
ret
; fb78a
-Functionfb78a: ; fb78a
+CheckIfMonIsYourOT: ; fb78a
+; Checks to see if the partymon loaded in [CurPartyMon] has the different OT as you. Returns carry if not.
ld hl, PartyMonOT
ld bc, NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld de, PlayerName
ld c, NAME_LENGTH
- call .asm_fb7b1
- jr c, .asm_fb7bc
+ call .loop
+ jr c, .nope
+
ld hl, PartyMon1ID
ld bc, PartyMon2 - PartyMon1
ld a, [CurPartyMon]
call AddNTimes
ld de, PlayerID
- ld c, $2
-.asm_fb7b1
+ ld c, 2 ; number of bytes in which your ID is stored
+.loop
ld a, [de]
cp [hl]
- jr nz, .asm_fb7bc
+ jr nz, .nope
inc hl
inc de
dec c
- jr nz, .asm_fb7b1
+ jr nz, .loop
and a
ret
-.asm_fb7bc
+.nope
scf
ret
; fb7be
-Functionfb7be: ; fb7be
+IsNewNameEmpty: ; fb7be
+; Checks to see if the nickname loaded in StringBuffer2 is empty. If so, return carry.
ld hl, StringBuffer2
- ld c, 10
-.asm_fb7c3
+ ld c, PKMN_NAME_LENGTH - 1
+.loop
ld a, [hli]
cp "@"
- jr z, .asm_fb7cf
+ jr z, .terminator
cp " "
- jr nz, .asm_fb7d1
+ jr nz, .nonspace
dec c
- jr nz, .asm_fb7c3
+ jr nz, .loop
-.asm_fb7cf
+.terminator
scf
ret
-.asm_fb7d1
+.nonspace
and a
ret
; fb7d3
-Functionfb7d3: ; fb7d3
+CompareNewToOld: ; fb7d3
+; Compares the nickname in StringBuffer2 to the previous nickname. If they are the same, return carry.
ld hl, PartyMonNicknames
- ld bc, $000b
+ ld bc, PKMN_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
push hl
- call Functionfb802
+ call GetNicknameLength
ld b, c
ld hl, StringBuffer2
- call Functionfb802
+ call GetNicknameLength
pop hl
ld a, c
cp b
- jr nz, .asm_fb7fe
+ jr nz, .different
ld de, StringBuffer2
-.asm_fb7f2
+.loop
ld a, [de]
cp "@"
- jr z, .asm_fb800
+ jr z, .terminator
cp [hl]
- jr nz, .asm_fb7fe
+ jr nz, .different
inc hl
inc de
- jr .asm_fb7f2
+ jr .loop
-.asm_fb7fe
+.different
and a
ret
-.asm_fb800
+.terminator
scf
ret
; fb802
-Functionfb802: ; fb802
+GetNicknameLength: ; fb802
+; Gets the length of the name starting at hl and returns it in c.
ld c, 0
-.asm_fb804
+.loop
ld a, [hli]
cp "@"
ret z
inc c
ld a, c
- cp 10
- jr nz, .asm_fb804
+ cp PKMN_NAME_LENGTH - 1
+ jr nz, .loop
ret
; fb80f
-UnknownText_0xfb80f: ; 0xfb80f
+NameRaterIntroText: ; 0xfb80f
; Hello, hello! I'm the NAME RATER.
; I rate the names of #MON.
; Would you like me to rate names?
@@ -176,13 +191,13 @@ UnknownText_0xfb80f: ; 0xfb80f
db "@"
; 0xfb814
-UnknownText_0xfb814: ; 0xfb814
+NameRaterWhichMonText: ; 0xfb814
; Which #MON's nickname should I rate for you?
text_jump UnknownText_0x1c00a0
db "@"
; 0xfb819
-UnknownText_0xfb819: ; 0xfb819
+NameRaterIsGoodText: ; 0xfb819
; Hm… @ … That's a fairly decent name.
; But, how about a slightly better nickname?
; Want me to give it a better name?
@@ -190,45 +205,45 @@ UnknownText_0xfb819: ; 0xfb819
db "@"
; 0xfb81e
-UnknownText_0xfb81e: ; 0xfb81e
+NameRaterWhichNameText: ; 0xfb81e
; All right. What name should we give it, then?
text_jump UnknownText_0x1c0142
db "@"
; 0xfb823
-UnknownText_0xfb823: ; 0xfb823
+NameRaterEvenBetterText: ; 0xfb823
; That's a better name than before! Well done!
text_jump UnknownText_0x1c0171
db "@"
; 0xfb828
-UnknownText_0xfb828: ; 0xfb828
+NameRaterCancelText: ; 0xfb828
; OK, then. Come again sometime.
text_jump UnknownText_0x1c019e
db "@"
; 0xfb82d
-UnknownText_0xfb82d: ; 0xfb82d
+NameRaterTradedText: ; 0xfb82d
; Hm… @ ? What a great name! It's perfect.
; Treat @ with loving care.
text_jump UnknownText_0x1c01be
db "@"
; 0xfb832
-UnknownText_0xfb832: ; 0xfb832
+NameRaterEggText: ; 0xfb832
; Whoa… That's just an EGG.
text_jump UnknownText_0x1c0208
db "@"
; 0xfb837
-UnknownText_0xfb837: ; 0xfb837
- ; It might look the same as before,
+NameRaterSameAsBeforeText: ; 0xfb837
+ ; It might look the different as before,
; but this new name is much better! Well done!
text_jump UnknownText_0x1c0222
db "@"
; 0xfb83c
-UnknownText_0xfb83c: ; 0xfb83c
+NameRaterDoneText: ; 0xfb83c
; All right. This #MON is now named @ .
text_jump UnknownText_0x1c0272
db "@"