summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlibjet <libj3t@gmail.com>2020-06-06 02:03:29 +0100
committerlibjet <libj3t@gmail.com>2020-06-06 02:03:29 +0100
commit44229a6cd68bf1e4937f2dab6efe6025dd703bf6 (patch)
tree9a82e02f4f7b5bafa8f2b21de3636c99a4b16166
parent29e2695d6eb6bf954ffbaa4993b23c6209cade89 (diff)
Add engine/events/name_rater.asm
-rwxr-xr-xdata/text/common_1.asm19
-rwxr-xr-xengine/events/name_rater.asm219
-rwxr-xr-xengine/link/time_capsule.asm6
-rw-r--r--main.asm9
4 files changed, 240 insertions, 13 deletions
diff --git a/data/text/common_1.asm b/data/text/common_1.asm
index 0bea4456..83b99c54 100755
--- a/data/text/common_1.asm
+++ b/data/text/common_1.asm
@@ -1557,7 +1557,7 @@ _EggPhotoText::
line "is worth more…"
done
-UnknownText_0x1c0043::
+_NameRaterHelloText::
text "Hello, hello! I'm"
line "the NAME RATER."
@@ -1568,13 +1568,13 @@ UnknownText_0x1c0043::
line "to rate names?"
done
-UnknownText_0x1c00a0::
+_NameRaterWhichMonText::
text "Which #MON's"
line "nickname should I"
cont "rate for you?"
prompt
-UnknownText_0x1c00cd::
+_NameRaterBetterNameText::
text "Hm… @"
text_ram wStringBuffer1
text "…"
@@ -1589,24 +1589,25 @@ UnknownText_0x1c00cd::
line "a better name?"
done
-UnknownText_0x1c0142::
+_NameRaterWhatNameText::
text "All right. What"
line "name should we"
cont "give it, then?"
prompt
-UnknownText_0x1c0171::
+_NameRaterFinishedText::
text "That's a better"
line "name than before!"
para "Well done!"
done
-UnknownText_0x1c019e::
+_NameRaterComeAgainText::
text "OK, then. Come"
line "again sometime."
done
+_NameRaterPerfectNameText::
text "Hm… @"
text_ram wStringBuffer1
text "?"
@@ -1619,12 +1620,12 @@ UnknownText_0x1c019e::
line "with loving care."
done
-UnknownText_0x1c0208::
+_NameRaterEggText::
text "Whoa… That's just"
line "an EGG."
done
-UnknownText_0x1c0222::
+_NameRaterSameNameText::
text "It might look the"
line "same as before,"
@@ -1634,7 +1635,7 @@ UnknownText_0x1c0222::
para "Well done!"
done
-UnknownText_0x1c0272::
+_NameRaterNamedText::
text "All right. This"
line "#MON is now"
cont "named @"
diff --git a/engine/events/name_rater.asm b/engine/events/name_rater.asm
new file mode 100755
index 00000000..e2b24c4c
--- /dev/null
+++ b/engine/events/name_rater.asm
@@ -0,0 +1,219 @@
+_NameRater:
+; Introduce himself
+ ld hl, NameRaterHelloText
+ call PrintText
+ call YesNoBox
+ jp c, .cancel
+; Select a Pokemon from your party
+ ld hl, NameRaterWhichMonText
+ call PrintText
+ farcall SelectMonFromParty
+ jr c, .cancel
+; He can't rename an egg...
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jr z, .egg
+; ... or a Pokemon you got from a trade.
+ call GetCurNick
+ call CheckIfMonIsYourOT
+ jr c, .traded
+; This name is good, but we can do better. How about it?
+ ld hl, NameRaterBetterNameText
+ call PrintText
+ call YesNoBox
+ jr c, .cancel
+; What name shall I give it then?
+ ld hl, NameRaterWhatNameText
+ call PrintText
+; Load the new nickname into wStringBuffer2
+ xor a ; PARTYMON
+ ld [wMonType], a
+ ld a, [wCurPartySpecies]
+ ld [wNamedObjectIndexBuffer], a
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld b, NAME_MON
+ ld de, wStringBuffer2
+ farcall _NamingScreen
+; If the new name is empty, treat it as unchanged.
+ call IsNewNameEmpty
+ ld hl, NameRaterSameNameText
+ jr c, .samename
+; If the new name is the same as the old name, treat it as unchanged.
+ call CompareNewToOld
+ ld hl, NameRaterSameNameText
+ jr c, .samename
+; Copy the new name from wStringBuffer2
+ ld hl, wPartyMonNicknames
+ ld bc, MON_NAME_LENGTH
+ ld a, [wCurPartyMon]
+ call AddNTimes
+ ld e, l
+ ld d, h
+ ld hl, wStringBuffer2
+ ld bc, MON_NAME_LENGTH
+ call CopyBytes
+ ld hl, NameRaterFinishedText
+
+.samename
+ push hl
+ call GetCurNick
+ ld hl, NameRaterNamedText
+ call PrintText
+ pop hl
+ jr .done
+
+.traded
+ ld hl, NameRaterPerfectNameText
+ jr .done
+
+.cancel
+ ld hl, NameRaterComeAgainText
+ jr .done
+
+.egg
+ ld hl, NameRaterEggText
+
+.done
+ call PrintText
+ ret
+
+CheckIfMonIsYourOT:
+; Checks to see if the partymon loaded in [wCurPartyMon] has the different OT as you. Returns carry if not.
+ ld hl, wPartyMonOT
+ ld bc, NAME_LENGTH
+ ld a, [wCurPartyMon]
+ call AddNTimes
+ ld de, wPlayerName
+ ld c, NAME_LENGTH
+ call .loop
+ jr c, .nope
+
+ ld hl, wPartyMon1ID
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld a, [wCurPartyMon]
+ call AddNTimes
+ ld de, wPlayerID
+ ld c, 2 ; number of bytes in which your ID is stored
+.loop
+ ld a, [de]
+ cp [hl]
+ jr nz, .nope
+ inc hl
+ inc de
+ dec c
+ jr nz, .loop
+ and a
+ ret
+
+.nope
+ scf
+ ret
+
+IsNewNameEmpty:
+; Checks to see if the nickname loaded in wStringBuffer2 is empty. If so, return carry.
+ ld hl, wStringBuffer2
+ ld c, MON_NAME_LENGTH - 1
+.loop
+ ld a, [hli]
+ cp "@"
+ jr z, .terminator
+ cp " "
+ jr nz, .nonspace
+ dec c
+ jr nz, .loop
+
+.terminator
+ scf
+ ret
+
+.nonspace
+ and a
+ ret
+
+CompareNewToOld:
+; Compares the nickname in wStringBuffer2 to the previous nickname. If they are the same, return carry.
+ ld hl, wPartyMonNicknames
+ ld bc, MON_NAME_LENGTH
+ ld a, [wCurPartyMon]
+ call AddNTimes
+ push hl
+ call GetNicknameLength
+ ld b, c
+ ld hl, wStringBuffer2
+ call GetNicknameLength
+ pop hl
+ ld a, c
+ cp b
+ jr nz, .different
+ ld de, wStringBuffer2
+.loop
+ ld a, [de]
+ cp "@"
+ jr z, .terminator
+ cp [hl]
+ jr nz, .different
+ inc hl
+ inc de
+ jr .loop
+
+.different
+ and a
+ ret
+
+.terminator
+ scf
+ ret
+
+GetNicknameLength:
+; Gets the length of the name starting at hl and returns it in c.
+ ld c, 0
+.loop
+ ld a, [hli]
+ cp "@"
+ ret z
+ inc c
+ ld a, c
+ cp MON_NAME_LENGTH - 1
+ jr nz, .loop
+ ret
+
+NameRaterHelloText:
+ text_far _NameRaterHelloText
+ text_end
+
+NameRaterWhichMonText:
+ text_far _NameRaterWhichMonText
+ text_end
+
+NameRaterBetterNameText:
+ text_far _NameRaterBetterNameText
+ text_end
+
+NameRaterWhatNameText:
+ text_far _NameRaterWhatNameText
+ text_end
+
+NameRaterFinishedText:
+ text_far _NameRaterFinishedText
+ text_end
+
+NameRaterComeAgainText:
+ text_far _NameRaterComeAgainText
+ text_end
+
+NameRaterPerfectNameText:
+ text_far _NameRaterPerfectNameText
+ text_end
+
+NameRaterEggText:
+ text_far _NameRaterEggText
+ text_end
+
+NameRaterSameNameText:
+ text_far _NameRaterSameNameText
+ text_end
+
+NameRaterNamedText:
+ text_far _NameRaterNamedText
+ text_end
diff --git a/engine/link/time_capsule.asm b/engine/link/time_capsule.asm
index f0aa9460..adbb3300 100755
--- a/engine/link/time_capsule.asm
+++ b/engine/link/time_capsule.asm
@@ -1,4 +1,6 @@
-ValidateOTTrademon::
+; These functions seem to be related to backwards compatibility
+
+ValidateOTTrademon:
ld a, [wceee]
ld hl, wOTPartyMon1Species
call GetPartyLocation
@@ -62,7 +64,7 @@ ValidateOTTrademon::
scf
ret
-Functionfb6ed::
+Functionfb6ed:
ld a, [wceed]
ld d, a
ld a, [wPartyCount]
diff --git a/main.asm b/main.asm
index ca794fef..d79ace67 100644
--- a/main.asm
+++ b/main.asm
@@ -375,29 +375,34 @@ Shrink2Pic:
INCBIN "gfx/new_game/shrink2.2bpp.lz"
INCLUDE "engine/link/time_capsule.asm"
+INCLUDE "engine/events/name_rater.asm"
-_NameRater::
- dr $fb7f7, $fb94b
PlaySlowCry::
dr $fb94b, $fb981
+
NewPokedexEntry::
dr $fb981, $fb9fb
+
ConvertMon_2to1::
dr $fb9fb, $fba12
ConvertMon_1to2::
dr $fba12, $fbb22
+
UpdateUnownDex::
dr $fbb22, $fbb38
PrintUnownWord::
dr $fbb38, $fbc3c
+
CheckMagikarpLength::
dr $fbc3c, $fbd00
CalcMagikarpLength::
dr $fbd00, $fbdd6
MagikarpHouseSign::
dr $fbdd6, $fbdf1
+
HiddenPowerDamage::
dr $fbdf1, $fbe5a
+
_DisappearUser::
dr $fbe5a, $fbe6f
_AppearUserRaiseSub::