Small polishing of the previous commit + Item Sorting

- Fixes a few bugs from the last commit, namely:
     - The guy who gives you the Pocket Lapras having bugged text
     - Being able to use it where you shouldn't (Cycling Road, Seafoam before the boulder puzzle)
     - Pocket Lapras not having an item description

- As well as this, automatic item sorting has been added. Just press Start in the bag menu and all your items will get assorted into a convenient list.

- Changed a few item descriptions since some of them didn't terminate properly

- Freed up some space in the Home bank
This commit is contained in:
Martha Schilling 2024-05-14 21:17:36 +01:00
parent dd7130c489
commit 2c02483f01
15 changed files with 379 additions and 66 deletions

View file

@ -13,7 +13,7 @@
const POKE_BALL ; $04 const POKE_BALL ; $04
const TOWN_MAP ; $05 const TOWN_MAP ; $05
const BICYCLE ; $06 const BICYCLE ; $06
const SURFBOARD ; $07 buggy? const POCKET_LAPRAS ; $07
const SAFARI_BALL ; $08 const SAFARI_BALL ; $08
const POKEDEX ; $09 const POKEDEX ; $09
const MOON_STONE ; $0A const MOON_STONE ; $0A

View file

@ -6,7 +6,7 @@ KeyItemFlags:
dbit FALSE ; POKE_BALL dbit FALSE ; POKE_BALL
dbit TRUE ; TOWN_MAP dbit TRUE ; TOWN_MAP
dbit TRUE ; BICYCLE dbit TRUE ; BICYCLE
dbit TRUE ; LAPRAS' BALL - SURFBOARD dbit TRUE ; POCKET_LAPRAS
dbit FALSE ; SAFARI_BALL dbit FALSE ; SAFARI_BALL
dbit TRUE ; POKEDEX dbit TRUE ; POKEDEX
dbit FALSE ; MOON_STONE dbit FALSE ; MOON_STONE

View file

@ -6,7 +6,7 @@ ItemNames::
li "POKé BALL" li "POKé BALL"
li "TOWN MAP" li "TOWN MAP"
li "BICYCLE" li "BICYCLE"
li "LAPRAS' BALL" ; surfboard, ?????, etc. li "LAPRAS' BALL" ; Pocket Lapras
li "SAFARI BALL" li "SAFARI BALL"
li "POKéDEX" li "POKéDEX"
li "MOON STONE" li "MOON STONE"

View file

@ -6,7 +6,7 @@ ItemPrices::
bcd3 200 ; POKE_BALL bcd3 200 ; POKE_BALL
bcd3 0 ; TOWN_MAP bcd3 0 ; TOWN_MAP
bcd3 0 ; BICYCLE bcd3 0 ; BICYCLE
bcd3 0 ; SURFBOARD bcd3 0 ; POCKET_LAPRAS
bcd3 1000 ; SAFARI_BALL bcd3 1000 ; SAFARI_BALL
bcd3 0 ; POKEDEX bcd3 0 ; POKEDEX
bcd3 0 ; MOON_STONE bcd3 0 ; MOON_STONE

View file

@ -12,8 +12,8 @@ _UltraBallDescription::
prompt prompt
_GreatBallDescription:: _GreatBallDescription::
text "A BALL with a de-" text "A BALL with a good"
next "cent success rate." next "success rate."
prompt prompt
_PokeBallDescription:: _PokeBallDescription::
@ -31,6 +31,11 @@ _BicycleDescription::
next "for travel." next "for travel."
prompt prompt
_PocketLaprasDescription::
text "A LAPRAS that lets"
next "you cross water."
prompt
_SafariBallDescription:: _SafariBallDescription::
text "Just an ULTRA BALL" text "Just an ULTRA BALL"
next "painted green." next "painted green."
@ -110,7 +115,7 @@ _EscapeRopeDescription::
_RepelDescription:: _RepelDescription::
text "Repels weak #-" text "Repels weak #-"
next "MON for 100 steps." next "MON. (100 steps)"
prompt prompt
_OldAmberDescription:: _OldAmberDescription::
@ -205,18 +210,18 @@ _MaxReviveDescription::
prompt prompt
_GuardSpecDescription:: _GuardSpecDescription::
text "Prevents stats" text "Prevents stat re-"
next "reduction. (1 BTL)" next "duction. (1 BTL)"
prompt prompt
_SuperRepelDescription:: _SuperRepelDescription::
text "Repels weak #-" text "Repels weak #-"
next "MON for 200 steps." next "MON. (200 steps)"
prompt prompt
_MaxRepelDescription:: _MaxRepelDescription::
text "Repels weak #-" text "Repels weak #-"
next "MON for 250 steps." next "MON. (250 steps)"
prompt prompt
_DireHitDescription:: _DireHitDescription::
@ -281,7 +286,7 @@ _OaksParcelDescription::
_ItemfinderDescription:: _ItemfinderDescription::
text "Checks for unseen" text "Checks for unseen"
next "items in the area." next "items nearby."
prompt prompt
_SilphScopeDescription:: _SilphScopeDescription::
@ -340,8 +345,8 @@ _ElixerDescription::
prompt prompt
_MaxElixerDescription:: _MaxElixerDescription::
text "Fully restores the" text "Fully restores PP"
next "PP of one #MON." next "of all moves."
prompt prompt
_CitrinePassDescription:: _CitrinePassDescription::
@ -380,13 +385,13 @@ _HM02Description::
prompt prompt
_HM03Description:: _HM03Description::
text "A strong water-" text "A strong WATER-"
next "type attack." next "type attack."
prompt prompt
_HM04Description:: _HM04Description::
text "A powerful physi-" text "A strong physical"
next "cal attack." next "attack."
prompt prompt
_HM05Description:: _HM05Description::
@ -420,12 +425,12 @@ _TM05Description::
prompt prompt
_TM06Description:: _TM06Description::
text "A poison move with" text "A POISON move with"
next "increasing damage." next "rising damage."
prompt prompt
_TM07Description:: _TM07Description::
text "A one-hit KO," text "A one-hit KO"
next "drill attack." next "drill attack."
prompt prompt
@ -475,8 +480,8 @@ _TM16Description::
prompt prompt
_TM17Description:: _TM17Description::
text "An attack that al-" text "A move that also"
next "so hurts the user." next "hurts the user."
prompt prompt
_TM18Description:: _TM18Description::
@ -520,13 +525,13 @@ _TM25Description::
prompt prompt
_TM26Description:: _TM26Description::
text "Tough but useless" text "Tough, but useless"
next "vs. flying foes." next "vs. FLYING foes."
prompt prompt
_TM27Description:: _TM27Description::
text "A GROUND-type," text "A one-hit KO"
next "one-hit KO attack." next "GROUND attack."
prompt prompt
_TM28Description:: _TM28Description::
@ -595,8 +600,8 @@ _TM40Description::
prompt prompt
_TM41Description:: _TM41Description::
text "Restores HP by 1/2" text "Restores 1/2 the"
next "the user's max HP." next "user's max HP."
prompt prompt
_TM42Description:: _TM42Description::
@ -615,8 +620,8 @@ _TM44Description::
prompt prompt
_TM45Description:: _TM45Description::
text "A move that may" text "A move that will"
next "cause paralysis." next "paralyze a foe."
prompt prompt
_TM46Description:: _TM46Description::
@ -640,8 +645,8 @@ _TM49Description::
prompt prompt
_TM50Description:: _TM50Description::
text "Makes a decoy with" text "Uses 1/4 max HP"
next "1/4 user's max HP." next "to make a decoy."
prompt prompt
_UnusedItemDescription:: _UnusedItemDescription::

View file

@ -233,3 +233,18 @@ ENDC
line "your friend and" line "your friend and"
cont "come again!" cont "come again!"
done done
_SortItemsText::
text "Would you like to"
next "sort items?"
done
_SortComplete::
text "Sorting is"
next "complete!"
prompt
_NothingToSort::
text "There are no items"
next "to sort."
prompt

View file

@ -23,7 +23,7 @@ ItemUsePtrTable:
dw ItemUseBall ; POKE_BALL dw ItemUseBall ; POKE_BALL
dw ItemUseTownMap ; TOWN_MAP dw ItemUseTownMap ; TOWN_MAP
dw ItemUseBicycle ; BICYCLE dw ItemUseBicycle ; BICYCLE
dw ItemUseSurfboard ; out-of-battle Surf effect dw ItemUseLapras ; POCKET_LAPRAS
dw ItemUseBall ; SAFARI_BALL dw ItemUseBall ; SAFARI_BALL
dw ItemUsePokedex ; POKEDEX dw ItemUsePokedex ; POKEDEX
dw ItemUseEvoStone ; MOON_STONE dw ItemUseEvoStone ; MOON_STONE
@ -759,12 +759,17 @@ ItemUseBicycle:
jp PrintText jp PrintText
; used for Surf out-of-battle effect ; used for Surf out-of-battle effect
ItemUseSurfboard: ItemUseLapras:
ld a, [wWalkBikeSurfState] ld a, [wWalkBikeSurfState]
ld [wWalkBikeSurfStateCopy], a ld [wWalkBikeSurfStateCopy], a
cp 2 ; is the player already surfing? cp 2 ; is the player already surfing?
jr z, .tryToStopSurfing jr z, .tryToStopSurfing
.tryToSurf .tryToSurf
farcall IsSurfingAllowed
ld hl, wd728
bit 1, [hl]
res 1, [hl]
jp z, .no
call IsNextTileShoreOrWater call IsNextTileShoreOrWater
jp c, SurfingAttemptFailed jp c, SurfingAttemptFailed
ld hl, TilePairCollisionsWater ld hl, TilePairCollisionsWater
@ -837,6 +842,10 @@ ItemUseSurfboard:
inc a inc a
ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesIndex], a
ret ret
.no
ld a, 1
and a
ret
SurfingGotOnText: SurfingGotOnText:
text_far _SurfingGotOnText text_far _SurfingGotOnText

View file

@ -26,7 +26,7 @@ ItemDescriptionPointers:
text_end text_end
text_far _BicycleDescription text_far _BicycleDescription
text_end text_end
text_far _UnusedItemDescription text_far _PocketLaprasDescription
text_end text_end
text_far _SafariBallDescription text_far _SafariBallDescription
text_end text_end

View file

@ -165,7 +165,7 @@ StartMenu_Pokemon::
bit 1, [hl] bit 1, [hl]
res 1, [hl] res 1, [hl]
jp z, .loop jp z, .loop
ld a, SURFBOARD ld a, POCKET_LAPRAS
ld [wcf91], a ld [wcf91], a
ld [wPseudoItemID], a ld [wPseudoItemID], a
call UseItem call UseItem
@ -331,6 +331,7 @@ StartMenu_Item::
ld a, [wBagSavedMenuItem] ld a, [wBagSavedMenuItem]
ld [wCurrentMenuItem], a ld [wCurrentMenuItem], a
call DisplayListMenuID call DisplayListMenuID
jp nz, .sortItems
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld [wBagSavedMenuItem], a ld [wBagSavedMenuItem], a
jr nc, .choseItem jr nc, .choseItem
@ -451,6 +452,9 @@ StartMenu_Item::
.infoItem .infoItem
farcall DisplayItemDescription farcall DisplayItemDescription
jp ItemMenuLoop jp ItemMenuLoop
.sortItems
farcall SortItems
jp ItemMenuLoop
CannotUseItemsHereText: CannotUseItemsHereText:
text_far _CannotUseItemsHereText text_far _CannotUseItemsHereText

View file

@ -147,3 +147,264 @@ HandleItemListSwapping::
pop de pop de
pop hl pop hl
jp DisplayListMenuIDLoop jp DisplayListMenuIDLoop
SortItems::
push hl
push bc
ld hl, SortItemsText ; Display the text to ask to sort
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jp z, .beginSorting ; If yes
jr .done
.finishedSwapping
ld a, [hSwapTemp] ; If not 0, then a swap of items did occur
cp 0
jr z, .nothingSorted
ld hl, SortComplete
jr .printResultText
.nothingSorted
ld hl, NothingToSort
.printResultText
call PrintText
.done
xor a ; Zeroes a
pop bc
pop hl
ret
.beginSorting
xor a
ld [hSwapTemp], a ; 1 if something in the bag got sorted
ld de, 0
ld hl, ItemSortList
ld b, [hl] ; This is the first item to check for
ld hl, wBagItems
ld c, 0 ; Relative to wBagItems, this is where we'd like to begin swapping
.loopCurrItemInBag
ld a, [hl] ; Load the value of hl to a (which is an item number) and Increments to the quantity
cp -1 ; See if the item number is $ff, which is 'cancel'
jr z, .findNextItem ; If it is cancel, then move onto the next item
cp b
jr z, .hasItem ; If it's not b, then go to the next item in the bag
inc hl ; increments past the quantity to the next item to check
inc hl
jr .loopCurrItemInBag
.findNextItem
ld d, 0
inc e
ld hl, ItemSortList
add hl, de
ld b, [hl]
ld hl, wBagItems ; Resets hl to start at the beginning of the bag
ld a, b
cp -1 ; Check if we got through all of the items, to the last one
jr z, .finishedSwapping
jr .loopCurrItemInBag
.hasItem ; c contains where to swap to relative to the start of wBagItems
; hl contains where the item to swap is absolute.
; b contains the item ID
push de
ld d, h
ld e, l
ld hl, wBagItems
ld a, b
ld b, 0
add hl, bc ; hl now holds where we'd like to swap to
ld b, a
ld a, [de]
cp [hl]
jr z, .cont ; If they're the same item
ld a, 1
ld [hSwapTemp], a
ld a, [hl]
ld [hSwapItemID],a ; [hSwapItemID] = second item ID
inc hl
ld a,[hld]
ld [hSwapItemQuantity],a ; [hSwapItemQuantity] = second item quantity
ld a,[de]
ld [hli],a ; put first item ID in second item slot
inc de
ld a,[de]
ld [hl],a ; put first item quantity in second item slot
ld a,[hSwapItemQuantity]
ld [de],a ; put second item quantity in first item slot
dec de
ld a,[hSwapItemID]
ld [de],a ; put second item ID in first item slot
.cont
inc c
inc c
ld h, d
ld l, e
pop de
jr .findNextItem
SortItemsText::
text_far _SortItemsText
db "@"
SortComplete::
text_far _SortComplete
db "@"
NothingToSort::
text_far _NothingToSort
db "@"
ItemSortList::
; Used Key Items
db BICYCLE
db SUPER_ROD
db POCKET_LAPRAS
db ITEMFINDER
db TOWN_MAP
db MYSTERY_BOX
; Balls
db POKE_BALL
db GREAT_BALL
db ULTRA_BALL
db SAFARI_BALL
db MASTER_BALL
; Common Items
db REPEL
db SUPER_REPEL
db MAX_REPEL
db ESCAPE_ROPE
db POKE_DOLL
; Health
db POTION
db SUPER_POTION
db HYPER_POTION
db MAX_POTION
db FULL_RESTORE
db FRESH_WATER
db SODA_POP
db LEMONADE
; Revival
db REVIVE
db MAX_REVIVE
; Status
db ANTIDOTE
db BURN_HEAL
db ICE_HEAL
db AWAKENING
db PARLYZ_HEAL
db FULL_HEAL
db POKE_FLUTE
; PP
db ETHER
db MAX_ETHER
db ELIXER
db MAX_ELIXER
; Battle Raises
db X_ACCURACY
db X_ATTACK
db X_DEFEND
db X_SPEED
db X_SPECIAL
db GUARD_SPEC
db DIRE_HIT
; Permanent Raises
db RARE_CANDY
db HP_UP
db PROTEIN
db IRON
db CARBOS
db CALCIUM
db PP_UP
; Evolution Items
db LEAF_STONE
db FIRE_STONE
db THUNDER_STONE
db WATER_STONE
db MOON_STONE
db HEART_STONE
db POISON_STONE
db ICE_STONE
db METAL_COAT
db UP_GRADE
db DUBIOUS_DISC
db BLK_AUGURITE
db PROTECTOR
db CANDY_JAR
; Other Non-Key Items
db DOME_FOSSIL
db HELIX_FOSSIL
db WING_FOSSIL
db OLD_AMBER
db NUGGET
db BOTTLE_CAP
; Key Items With No Use
db COIN_CASE
db SILPHLETTER
db S_S_TICKET
db OLD_SEA_MAP
db CITRINE_PASS
db SECRET_KEY
db BIKE_VOUCHER
db CARD_KEY
db GOLD_TEETH
db OAKS_PARCEL
db LIFT_KEY
db SILPH_SCOPE
db TEA
db EXP_ALL
; TMs
db TM01
db TM01 + 1
db TM01 + 2
db TM01 + 3
db TM01 + 4
db TM01 + 5
db TM01 + 6
db TM01 + 7
db TM01 + 8
db TM01 + 9
db TM01 + 10
db TM01 + 11
db TM01 + 12
db TM01 + 13
db TM01 + 14
db TM01 + 15
db TM01 + 16
db TM01 + 17
db TM01 + 18
db TM01 + 19
db TM01 + 20
db TM01 + 21
db TM01 + 22
db TM01 + 23
db TM01 + 24
db TM01 + 25
db TM01 + 26
db TM01 + 27
db TM01 + 28
db TM01 + 29
db TM01 + 30
db TM01 + 31
db TM01 + 32
db TM01 + 33
db TM01 + 34
db TM01 + 35
db TM01 + 36
db TM01 + 37
db TM01 + 38
db TM01 + 39
db TM01 + 40
db TM01 + 41
db TM01 + 42
db TM01 + 43
db TM01 + 44
db TM01 + 45
db TM01 + 46
db TM01 + 47
db TM01 + 48
db TM01 + 49
; HMs
db HM01
db HM01 + 1
db HM01 + 2
db HM01 + 3
db HM01 + 4
db -1 ; end

View file

@ -33,7 +33,7 @@ TrySurf:
and a and a
jr nz, .no2 jr nz, .no2
call GetPartyMonName2 call GetPartyMonName2
ld a, SURFBOARD ld a, POCKET_LAPRAS
ld [wcf91], a ld [wcf91], a
ld [wPseudoItemID], a ld [wPseudoItemID], a
call UseItem call UseItem

View file

@ -1,7 +1,8 @@
; rst vectors (unused) ; rst vectors (unused)
SECTION "rst0", ROM0[$0000] SECTION "rst0", ROM0[$0000]
rst $38 _Bankswitch::
jp Bankswitch
ds $08 - @, 0 ; unused ds $08 - @, 0 ; unused

View file

@ -50,7 +50,7 @@ DisplayListMenuID::
ld [wTopMenuItemY], a ld [wTopMenuItemY], a
ld a, 5 ld a, 5
ld [wTopMenuItemX], a ld [wTopMenuItemX], a
ld a, A_BUTTON | B_BUTTON | SELECT ld a, A_BUTTON | B_BUTTON | SELECT | START
ld [wMenuWatchedKeys], a ld [wMenuWatchedKeys], a
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
@ -178,6 +178,8 @@ DisplayListMenuIDLoop::
jp nz, ExitListMenu ; if so, exit the menu jp nz, ExitListMenu ; if so, exit the menu
bit BIT_SELECT, a bit BIT_SELECT, a
jp nz, HandleItemListSwapping ; if so, allow the player to swap menu entries jp nz, HandleItemListSwapping ; if so, allow the player to swap menu entries
bit 3, a ; was the start button pressed?
jp nz, .sortItems ; if so, allow the player to swap menu entries
ld b, a ld b, a
bit BIT_D_DOWN, b bit BIT_D_DOWN, b
ld hl, wListScrollOffset ld hl, wListScrollOffset
@ -197,6 +199,10 @@ DisplayListMenuIDLoop::
jp z, DisplayListMenuIDLoop jp z, DisplayListMenuIDLoop
dec [hl] dec [hl]
jp DisplayListMenuIDLoop jp DisplayListMenuIDLoop
.sortItems
rra ; Sets the zero flag to 0 so the sorting function will happen
rla
jp BankswitchBack
DisplayChooseQuantityMenu:: DisplayChooseQuantityMenu::
; text box dimensions/coordinates for just quantity ; text box dimensions/coordinates for just quantity

View file

@ -1,13 +1,13 @@
MACRO farcall MACRO farcall
ld b, BANK(\1) ld b, BANK(\1)
ld hl, \1 ld hl, \1
call Bankswitch rst _Bankswitch
ENDM ENDM
MACRO callfar MACRO callfar
ld hl, \1 ld hl, \1
ld b, BANK(\1) ld b, BANK(\1)
call Bankswitch rst _Bankswitch
ENDM ENDM
MACRO farjp MACRO farjp

View file

@ -87,34 +87,42 @@ CinnabarIslandText7:
_CinnabarPocketLapras1: _CinnabarPocketLapras1:
text "Bah, this LAPRAS" text "Bah, this LAPRAS"
line "just doesn't" line "just doesn't want"
cont "wanna fight! Can" cont "to fight! Can you"
cont "you believe that?" cont "believe that?"
para "All it does is" para "All it likes to"
line "SURF. My GYARADOS" line "do is SURF, but"
cont "can do that!" cont "my GYARADOS can"
cont "already do that!"
para "Here. Take it." para "Here, take it. I"
line "I can't stand" line "can't stand its"
cont "looking at its" cont "big ol' eyes"
cont "big ol' eyes." cont "looking at me."
done prompt
_PocketLaprasNoRoomText: _PocketLaprasNoRoomText:
text "You don't have" text "You don't have"
line "room either?" line "room, either?"
para "Well, it's not" para "Well, it's not"
line "going anywhere..." line "like it's going"
cont "anywhere..."
done done
_ReceivedPocketLaprasText: _ReceivedPocketLaprasText:
text "Take care of that" text "<PLAYER> received"
line "LAPRAS though," line "@"
cont "yeah? They're" text_ram wStringBuffer
cont "an endangered" text "!@"
cont "species." text_end
_CinnabarPocketLapras2:
text "Take care of it"
line "though, alright?"
cont "LAPRAS is very"
cont "endangered."
para "You should stay" para "You should stay"
line "safe, too." ; haha, llinos, you sly dog line "safe, too." ; haha, llinos, you sly dog
@ -124,6 +132,10 @@ _ReceivedPocketLaprasText:
CinnabarPocketLapras1: CinnabarPocketLapras1:
text_far _CinnabarPocketLapras1 text_far _CinnabarPocketLapras1
text_end text_end
CinnabarPocketLapras2:
text_far _CinnabarPocketLapras2
text_end
PocketLaprasNoRoomText: PocketLaprasNoRoomText:
text_far _PocketLaprasNoRoomText text_far _PocketLaprasNoRoomText
@ -139,21 +151,21 @@ CinnabarPocketLapras:
jr nz, .skip jr nz, .skip
ld hl, CinnabarPocketLapras1 ld hl, CinnabarPocketLapras1
call PrintText call PrintText
call TheAutoskipStopinator ; it's been a while but i didnt forget how annoying this was lb bc, POCKET_LAPRAS, 1
lb bc, SURFBOARD, 1
call GiveItem call GiveItem
jr nc, .bag_full jr nc, .bag_full
SetEvent EVENT_GOT_POCKET_LAPRAS ; if you get here, it's done. Using this to load all three texts with one PrintText instruction
sound_get_key_item
ld hl, ReceivedPocketLaprasText ld hl, ReceivedPocketLaprasText
call PrintText
ld a, SFX_GET_KEY_ITEM
call PlaySound
SetEvent EVENT_GOT_POCKET_LAPRAS ; if you get here, it's done.
jr .end jr .end
.bag_full .bag_full
ld hl, PocketLaprasNoRoomText ld hl, PocketLaprasNoRoomText
jr .end jr .end
.skip .skip
ld hl, ReceivedPocketLaprasText ld hl, CinnabarPocketLapras2
call PrintText
; fallthrough ; fallthrough
.end .end
call PrintText
call TheAutoskipStopinator
jp TextScriptEnd jp TextScriptEnd