summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/battle/held_consumables.asm25
-rw-r--r--data/decorations/attributes.asm62
-rw-r--r--data/decorations/decorations.asm54
-rw-r--r--data/decorations/names.asm28
-rw-r--r--data/events/pokedex_ratings.asm27
-rwxr-xr-xdata/text/common_1.asm28
-rw-r--r--engine/battle/consume_held_item.asm57
-rw-r--r--engine/battle/returntobattle_useball.asm19
-rw-r--r--engine/events/prof_oaks_pc.asm193
-rwxr-xr-xengine/items/item_effects.asm6
-rw-r--r--engine/overworld/decorations.asm1168
-rw-r--r--main.asm26
-rw-r--r--wram.asm23
13 files changed, 1666 insertions, 50 deletions
diff --git a/data/battle/held_consumables.asm b/data/battle/held_consumables.asm
new file mode 100644
index 00000000..bd47c1d8
--- /dev/null
+++ b/data/battle/held_consumables.asm
@@ -0,0 +1,25 @@
+; Held item effects that are consumed on use
+
+ConsumableEffects:
+ db HELD_BERRY
+ db HELD_2
+ db HELD_5
+ db HELD_HEAL_POISON
+ db HELD_HEAL_FREEZE
+ db HELD_HEAL_BURN
+ db HELD_HEAL_SLEEP
+ db HELD_HEAL_PARALYZE
+ db HELD_HEAL_STATUS
+ db HELD_30
+ db HELD_ATTACK_UP
+ db HELD_DEFENSE_UP
+ db HELD_SPEED_UP
+ db HELD_SP_ATTACK_UP
+ db HELD_SP_DEFENSE_UP
+ db HELD_ACCURACY_UP
+ db HELD_EVASION_UP
+ db HELD_38
+ db HELD_71
+ db HELD_ESCAPE
+ db HELD_CRITICAL_UP
+ db -1
diff --git a/data/decorations/attributes.asm b/data/decorations/attributes.asm
new file mode 100644
index 00000000..77cd1388
--- /dev/null
+++ b/data/decorations/attributes.asm
@@ -0,0 +1,62 @@
+decoration: MACRO
+ ; type, name, command, event flag, tile/sprite
+ db \1, \2, \3
+ dw \4
+ db \5
+ENDM
+
+DecorationAttributes:
+; entries correspond to deco constants
+ decoration DECO_PLANT, 0, 0, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BED, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_BED, FEATHERY_BED, SET_UP_BED, EVENT_DECO_BED_1, $1b
+ decoration DECO_BED, PINK_BED, SET_UP_BED, EVENT_DECO_BED_2, $1c
+ decoration DECO_BED, POLKADOT_BED, SET_UP_BED, EVENT_DECO_BED_3, $1d
+ decoration DECO_BED, PIKACHU_BED, SET_UP_BED, EVENT_DECO_BED_4, $1e
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_CARPET, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_CARPET, RED_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_1, $08
+ decoration DECO_CARPET, BLUE_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_2, $0b
+ decoration DECO_CARPET, YELLOW_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_3, $0e
+ decoration DECO_CARPET, GREEN_CARPET, SET_UP_CARPET, EVENT_DECO_CARPET_4, $11
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_PLANT, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_PLANT, MAGNAPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_1, $20
+ decoration DECO_PLANT, TROPICPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_2, $21
+ decoration DECO_PLANT, JUMBOPLANT, SET_UP_PLANT, EVENT_DECO_PLANT_3, $22
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_POSTER, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_PLANT, TOWN_MAP_POSTER, SET_UP_POSTER, EVENT_DECO_POSTER_1, $1f
+ decoration DECO_POSTER, PIKACHU, SET_UP_POSTER, EVENT_DECO_POSTER_2, $23
+ decoration DECO_POSTER, CLEFAIRY, SET_UP_POSTER, EVENT_DECO_POSTER_3, $24
+ decoration DECO_POSTER, JIGGLYPUFF, SET_UP_POSTER, EVENT_DECO_POSTER_4, $25
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_CONSOLE, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_PLANT, FAMICOM, SET_UP_CONSOLE, EVENT_DECO_FAMICOM, SPRITE_FAMICOM
+ decoration DECO_PLANT, SUPER_NES, SET_UP_CONSOLE, EVENT_DECO_SNES, SPRITE_SNES
+ decoration DECO_PLANT, NINTENDO_64, SET_UP_CONSOLE, EVENT_DECO_N64, SPRITE_N64
+ decoration DECO_PLANT, VIRTUAL_BOY, SET_UP_CONSOLE, EVENT_DECO_VIRTUAL_BOY, SPRITE_VIRTUAL_BOY
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_BIG_DOLL, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_BIGDOLL, SNORLAX, SET_UP_BIG_DOLL, EVENT_DECO_BIG_SNORLAX_DOLL, SPRITE_BIG_SNORLAX
+ decoration DECO_BIGDOLL, ONIX, SET_UP_BIG_DOLL, EVENT_DECO_BIG_ONIX_DOLL, SPRITE_BIG_ONIX
+ decoration DECO_BIGDOLL, LAPRAS, SET_UP_BIG_DOLL, EVENT_DECO_BIG_LAPRAS_DOLL, SPRITE_BIG_LAPRAS
+ decoration DECO_PLANT, PUT_IT_AWAY, PUT_AWAY_DOLL, EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1, 0
+ decoration DECO_DOLL, PIKACHU, SET_UP_DOLL, EVENT_DECO_PIKACHU_DOLL, SPRITE_PIKACHU
+ decoration DECO_PLANT, SURF_PIKA_DOLL, SET_UP_DOLL, EVENT_DECO_SURFING_PIKACHU_DOLL, SPRITE_SURFING_PIKACHU
+ decoration DECO_DOLL, CLEFAIRY, SET_UP_DOLL, EVENT_DECO_CLEFAIRY_DOLL, SPRITE_CLEFAIRY
+ decoration DECO_DOLL, JIGGLYPUFF, SET_UP_DOLL, EVENT_DECO_JIGGLYPUFF_DOLL, SPRITE_JIGGLYPUFF
+ decoration DECO_DOLL, BULBASAUR, SET_UP_DOLL, EVENT_DECO_BULBASAUR_DOLL, SPRITE_BULBASAUR
+ decoration DECO_DOLL, CHARMANDER, SET_UP_DOLL, EVENT_DECO_CHARMANDER_DOLL, SPRITE_CHARMANDER
+ decoration DECO_DOLL, SQUIRTLE, SET_UP_DOLL, EVENT_DECO_SQUIRTLE_DOLL, SPRITE_SQUIRTLE
+ decoration DECO_DOLL, POLIWAG, SET_UP_DOLL, EVENT_DECO_POLIWAG_DOLL, SPRITE_POLIWAG
+ decoration DECO_DOLL, DIGLETT, SET_UP_DOLL, EVENT_DECO_DIGLETT_DOLL, SPRITE_DIGLETT
+ decoration DECO_DOLL, STARYU, SET_UP_DOLL, EVENT_DECO_STARMIE_DOLL, SPRITE_STARMIE
+ decoration DECO_DOLL, MAGIKARP, SET_UP_DOLL, EVENT_DECO_MAGIKARP_DOLL, SPRITE_MAGIKARP
+ decoration DECO_DOLL, ODDISH, SET_UP_DOLL, EVENT_DECO_ODDISH_DOLL, SPRITE_ODDISH
+ decoration DECO_DOLL, GENGAR, SET_UP_DOLL, EVENT_DECO_GENGAR_DOLL, SPRITE_GENGAR
+ decoration DECO_DOLL, SHELLDER, SET_UP_DOLL, EVENT_DECO_SHELLDER_DOLL, SPRITE_SHELLDER
+ decoration DECO_DOLL, GRIMER, SET_UP_DOLL, EVENT_DECO_GRIMER_DOLL, SPRITE_GRIMER
+ decoration DECO_DOLL, VOLTORB, SET_UP_DOLL, EVENT_DECO_VOLTORB_DOLL, SPRITE_VOLTORB
+ decoration DECO_DOLL, WEEDLE, SET_UP_DOLL, EVENT_DECO_WEEDLE_DOLL, SPRITE_WEEDLE
+ decoration DECO_DOLL, UNOWN, SET_UP_DOLL, EVENT_DECO_UNOWN_DOLL, SPRITE_UNOWN
+ decoration DECO_DOLL, GEODUDE, SET_UP_DOLL, EVENT_DECO_GEODUDE_DOLL, SPRITE_GEODUDE
+ decoration DECO_DOLL, MACHOP, SET_UP_DOLL, EVENT_DECO_MACHOP_DOLL, SPRITE_MACHOP
+ decoration DECO_DOLL, TENTACOOL, SET_UP_DOLL, EVENT_DECO_TENTACOOL_DOLL, SPRITE_TENTACOOL
+ decoration DECO_PLANT, GOLD_TROPHY, SET_UP_DOLL, EVENT_DECO_GOLD_TROPHY, SPRITE_GOLD_TROPHY
+ decoration DECO_PLANT, SILVER_TROPHY, SET_UP_DOLL, EVENT_DECO_SILVER_TROPHY, SPRITE_SILVER_TROPHY
diff --git a/data/decorations/decorations.asm b/data/decorations/decorations.asm
new file mode 100644
index 00000000..947bca1b
--- /dev/null
+++ b/data/decorations/decorations.asm
@@ -0,0 +1,54 @@
+DecorationIDs:
+; see constants/deco_constants.asm
+ db DECO_FEATHERY_BED ; 2
+ db DECO_PINK_BED ; 3
+ db DECO_POLKADOT_BED ; 4
+ db DECO_PIKACHU_BED ; 5
+
+ db DECO_RED_CARPET ; 7
+ db DECO_BLUE_CARPET ; 8
+ db DECO_YELLOW_CARPET ; 9
+ db DECO_GREEN_CARPET ; a
+
+ db DECO_MAGNAPLANT ; c
+ db DECO_TROPICPLANT ; d
+ db DECO_JUMBOPLANT ; e
+
+ db DECO_TOWN_MAP ; 10
+ db DECO_PIKACHU_POSTER ; 11
+ db DECO_CLEFAIRY_POSTER ; 12
+ db DECO_JIGGLYPUFF_POSTER ; 13
+
+ db DECO_FAMICOM ; 15
+ db DECO_SNES ; 16
+ db DECO_N64 ; 17
+ db DECO_VIRTUAL_BOY ; 18
+
+ db DECO_PIKACHU_DOLL ; 1e
+ db DECO_SURF_PIKACHU_DOLL ; 1f
+ db DECO_CLEFAIRY_DOLL ; 20
+ db DECO_JIGGLYPUFF_DOLL ; 21
+ db DECO_BULBASAUR_DOLL ; 22
+ db DECO_CHARMANDER_DOLL ; 23
+ db DECO_SQUIRTLE_DOLL ; 24
+ db DECO_POLIWAG_DOLL ; 25
+ db DECO_DIGLETT_DOLL ; 26
+ db DECO_STARMIE_DOLL ; 27
+ db DECO_MAGIKARP_DOLL ; 28
+ db DECO_ODDISH_DOLL ; 29
+ db DECO_GENGAR_DOLL ; 2a
+ db DECO_SHELLDER_DOLL ; 2b
+ db DECO_GRIMER_DOLL ; 2c
+ db DECO_VOLTORB_DOLL ; 2d
+ db DECO_WEEDLE_DOLL ; 2e
+ db DECO_UNOWN_DOLL ; 2f
+ db DECO_GEODUDE_DOLL ; 30
+ db DECO_MACHOP_DOLL ; 31
+ db DECO_TENTACOOL_DOLL ; 32
+ db DECO_BIG_SNORLAX_DOLL ; 1a
+ db DECO_BIG_ONIX_DOLL ; 1b
+ db DECO_BIG_LAPRAS_DOLL ; 1c
+TrophyIDs:
+ db DECO_GOLD_TROPHY_DOLL ; 33
+ db DECO_SILVER_TROPHY_DOLL ; 34
+ db -1
diff --git a/data/decorations/names.asm b/data/decorations/names.asm
new file mode 100644
index 00000000..3894bc7f
--- /dev/null
+++ b/data/decorations/names.asm
@@ -0,0 +1,28 @@
+DecorationNames:
+; entries correspond to constants/deco_constants.asm
+ db "CANCEL@"
+ db "PUT IT AWAY@"
+ db "MAGNAPLANT@"
+ db "TROPICPLANT@"
+ db "JUMBOPLANT@"
+ db "TOWN MAP@"
+ db "NES@"
+ db "SUPER NES@"
+ db "NINTENDO64@"
+ db "VIRTUAL BOY@"
+ db "GOLD TROPHY@"
+ db "SILVER TROPHY@"
+ db "SURF PIKACHU DOLL@"
+ db " BED@"
+ db " CARPET@"
+ db " POSTER@"
+ db " DOLL@"
+ db "BIG @"
+ db "FEATHERY@"
+ db "PIKACHU@"
+ db "PINK@"
+ db "POLKADOT@"
+ db "RED@"
+ db "BLUE@"
+ db "YELLOW@"
+ db "GREEN@"
diff --git a/data/events/pokedex_ratings.asm b/data/events/pokedex_ratings.asm
new file mode 100644
index 00000000..2a048860
--- /dev/null
+++ b/data/events/pokedex_ratings.asm
@@ -0,0 +1,27 @@
+rating: MACRO
+; count, sfx, text
+ dbww \1, \2, \3
+ENDM
+
+OakRatings:
+; if you caught at most this many, play this sound, load this text
+; (text is defined in engine/events/prof_oaks_pc.asm)
+ rating 9, SFX_DEX_FANFARE_LESS_THAN_20, OakRating01
+ rating 19, SFX_DEX_FANFARE_LESS_THAN_20, OakRating02
+ rating 34, SFX_DEX_FANFARE_20_49, OakRating03
+ rating 49, SFX_DEX_FANFARE_20_49, OakRating04
+ rating 64, SFX_DEX_FANFARE_50_79, OakRating05
+ rating 79, SFX_DEX_FANFARE_50_79, OakRating06
+ rating 94, SFX_DEX_FANFARE_80_109, OakRating07
+ rating 109, SFX_DEX_FANFARE_80_109, OakRating08
+ rating 124, SFX_CAUGHT_MON, OakRating09
+ rating 139, SFX_CAUGHT_MON, OakRating10
+ rating 154, SFX_DEX_FANFARE_140_169, OakRating11
+ rating 169, SFX_DEX_FANFARE_140_169, OakRating12
+ rating 184, SFX_DEX_FANFARE_170_199, OakRating13
+ rating 199, SFX_DEX_FANFARE_170_199, OakRating14
+ rating 214, SFX_DEX_FANFARE_200_229, OakRating15
+ rating 229, SFX_DEX_FANFARE_200_229, OakRating16
+ rating 239, SFX_DEX_FANFARE_230_PLUS, OakRating17
+ rating 248, SFX_DEX_FANFARE_230_PLUS, OakRating18
+ rating 255, SFX_DEX_FANFARE_230_PLUS, OakRating19
diff --git a/data/text/common_1.asm b/data/text/common_1.asm
index 8745b9ee..51fe6cf5 100755
--- a/data/text/common_1.asm
+++ b/data/text/common_1.asm
@@ -280,41 +280,41 @@ UnknownText_0x1bc45e::
line "amount."
done
-UnknownText_0x1bc471::
+_NothingToChooseText::
text "There's nothing to"
line "choose."
prompt
-UnknownText_0x1bc48c::
+_WhichSidePutOnText::
text "Which side do you"
line "want to put it on?"
done
-UnknownText_0x1bc4b2::
+_WhichSidePutAwayText::
text "Which side do you"
line "want to put away?"
done
-UnknownText_0x1bc4d7::
+_PutAwayTheDecoText::
text "Put away the"
line "@"
text_ram wStringBuffer3
text "."
prompt
-UnknownText_0x1bc4ec::
+_NothingToPutAwayText::
text "There's nothing to"
line "put away."
prompt
-UnknownText_0x1bc509::
+_SetUpTheDecoText::
text "Set up the"
line "@"
text_ram wStringBuffer3
text "."
prompt
-UnknownText_0x1bc51c::
+_PutAwayAndSetUpText::
text "Put away the"
line "@"
text_ram wStringBuffer3
@@ -326,38 +326,38 @@ UnknownText_0x1bc51c::
text "."
prompt
-UnknownText_0x1bc546::
+_AlreadySetUpText::
text "That's already set"
line "up."
prompt
-UnknownText_0x1bc55d::
+_LookTownMapText::
text "It's the TOWN MAP."
done
-UnknownText_0x1bc570::
+_LookPikachuPosterText::
text "It's a poster of a"
line "cute PIKACHU."
done
-UnknownText_0x1bc591::
+_LookClefairyPosterText::
text "It's a poster of a"
line "cute CLEFAIRY."
done
-UnknownText_0x1bc5b3::
+_LookJigglypuffPosterText::
text "It's a poster of a"
line "cute JIGGLYPUFF."
done
-UnknownText_0x1bc5d7::
+_LookAdorableDecoText::
text "It's an adorable"
line "@"
text_ram wStringBuffer3
text "."
done
-UnknownText_0x1bc5ef::
+_LookGiantDecoText::
text "A giant doll! It's"
line "fluffy and cuddly."
done
diff --git a/engine/battle/consume_held_item.asm b/engine/battle/consume_held_item.asm
new file mode 100644
index 00000000..c5e3b204
--- /dev/null
+++ b/engine/battle/consume_held_item.asm
@@ -0,0 +1,57 @@
+ConsumeHeldItem:
+ push hl
+ push de
+ push bc
+ ldh a, [hBattleTurn]
+ and a
+ ld hl, wOTPartyMon1Item
+ ld de, wEnemyMonItem
+ ld a, [wCurOTMon]
+ jr z, .theirturn
+ ld hl, wPartyMon1Item
+ ld de, wBattleMonItem
+ ld a, [wCurBattleMon]
+
+.theirturn
+ push hl
+ push af
+ ld a, [de]
+ ld b, a
+ farcall GetItemHeldEffect
+ ld hl, ConsumableEffects
+.loop
+ ld a, [hli]
+ cp b
+ jr z, .ok
+ inc a
+ jr nz, .loop
+ pop af
+ pop hl
+ pop bc
+ pop de
+ pop hl
+ ret
+
+.ok
+ xor a
+ ld [de], a
+ pop af
+ pop hl
+ call GetPartyLocation
+ ldh a, [hBattleTurn]
+ and a
+ jr nz, .ourturn
+ ld a, [wBattleMode]
+ dec a
+ jr z, .done
+
+.ourturn
+ ld [hl], NO_ITEM
+
+.done
+ pop bc
+ pop de
+ pop hl
+ ret
+
+INCLUDE "data/battle/held_consumables.asm"
diff --git a/engine/battle/returntobattle_useball.asm b/engine/battle/returntobattle_useball.asm
new file mode 100644
index 00000000..fd138ae6
--- /dev/null
+++ b/engine/battle/returntobattle_useball.asm
@@ -0,0 +1,19 @@
+_ReturnToBattle_UseBall:
+ call ClearBGPalettes
+ call ClearTilemap
+ ld a, [wBattleType]
+ cp BATTLETYPE_TUTORIAL
+ jr z, .gettutorialbackpic
+ farcall GetBattleMonBackpic
+ jr .continue
+
+.gettutorialbackpic
+ farcall GetTrainerBackpic
+.continue
+ farcall GetEnemyMonFrontpic
+ farcall _LoadBattleFontsHPBar
+ call GetMemSGBLayout
+ call CloseWindow
+ call LoadStandardMenuHeader
+ call WaitBGMap
+ jp SetPalettes
diff --git a/engine/events/prof_oaks_pc.asm b/engine/events/prof_oaks_pc.asm
new file mode 100644
index 00000000..40230d5b
--- /dev/null
+++ b/engine/events/prof_oaks_pc.asm
@@ -0,0 +1,193 @@
+ProfOaksPC:
+ ld hl, OakPCText1
+ call MenuTextbox
+ call YesNoBox
+ jr c, .shutdown
+ call ProfOaksPCBoot ; player chose "yes"?
+.shutdown
+ ld hl, OakPCText4
+ call PrintText
+ call JoyWaitAorB
+ call ExitMenu
+ ret
+
+ProfOaksPCBoot:
+ ld hl, OakPCText2
+ call PrintText
+ call Rate
+ call PlaySFX ; sfx loaded by previous Rate function call
+ call JoyWaitAorB
+ call WaitSFX
+ ret
+
+ProfOaksPCRating:
+ call Rate
+ push de
+ ld de, MUSIC_NONE
+ call PlayMusic
+ pop de
+ call PlaySFX
+ call JoyWaitAorB
+ call WaitSFX
+ ret
+
+Rate:
+; calculate Seen/Owned
+ ld hl, wPokedexSeen
+ ld b, wEndPokedexSeen - wPokedexSeen
+ call CountSetBits
+ ld [wceed], a
+ ld hl, wPokedexCaught
+ ld b, wEndPokedexCaught - wPokedexCaught
+ call CountSetBits
+ ld [wceee], a
+
+; print appropriate rating
+ call .UpdateRatingBuffers
+ ld hl, OakPCText3
+ call PrintText
+ call JoyWaitAorB
+ ld a, [wceee]
+ ld hl, OakRatings
+ call FindOakRating
+ push de
+ call PrintText
+ pop de
+ ret
+
+.UpdateRatingBuffers:
+ ld hl, wStringBuffer3
+ ld de, wceed
+ call .UpdateRatingBuffer
+ ld hl, wStringBuffer4
+ ld de, wceee
+ call .UpdateRatingBuffer
+ ret
+
+.UpdateRatingBuffer:
+ push hl
+ ld a, "@"
+ ld bc, ITEM_NAME_LENGTH
+ call ByteFill
+ pop hl
+ lb bc, PRINTNUM_LEFTALIGN | 1, 3
+ call PrintNum
+ ret
+
+FindOakRating:
+; return sound effect in de
+; return text pointer in hl
+ nop
+ ld c, a
+.loop
+ ld a, [hli]
+ cp c
+ jr nc, .match
+rept 4
+ inc hl
+endr
+ jr .loop
+
+.match
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ret
+
+INCLUDE "data/events/pokedex_ratings.asm"
+
+OakPCText1:
+ text_far _OakPCText1
+ text_end
+
+OakPCText2:
+ text_far _OakPCText2
+ text_end
+
+OakPCText3:
+ text_far _OakPCText3
+ text_end
+
+OakRating01:
+ text_far _OakRating01
+ text_end
+
+OakRating02:
+ text_far _OakRating02
+ text_end
+
+OakRating03:
+ text_far _OakRating03
+ text_end
+
+OakRating04:
+ text_far _OakRating04
+ text_end
+
+OakRating05:
+ text_far _OakRating05
+ text_end
+
+OakRating06:
+ text_far _OakRating06
+ text_end
+
+OakRating07:
+ text_far _OakRating07
+ text_end
+
+OakRating08:
+ text_far _OakRating08
+ text_end
+
+OakRating09:
+ text_far _OakRating09
+ text_end
+
+OakRating10:
+ text_far _OakRating10
+ text_end
+
+OakRating11:
+ text_far _OakRating11
+ text_end
+
+OakRating12:
+ text_far _OakRating12
+ text_end
+
+OakRating13:
+ text_far _OakRating13
+ text_end
+
+OakRating14:
+ text_far _OakRating14
+ text_end
+
+OakRating15:
+ text_far _OakRating15
+ text_end
+
+OakRating16:
+ text_far _OakRating16
+ text_end
+
+OakRating17:
+ text_far _OakRating17
+ text_end
+
+OakRating18:
+ text_far _OakRating18
+ text_end
+
+OakRating19:
+ text_far _OakRating19
+ text_end
+
+OakPCText4:
+ text_far _OakPCText4
+ text_end
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index e5a0960b..3b31aef8 100755
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -996,8 +996,8 @@ Text_AskNicknameNewlyCaughtMon:
text_far Text_AskNicknameNewlyCaughtMon_
db "@"
-ReturnToBattle_UseBall: ; ee4e (3:6e4e)
- farcall ReturnToBattle_UseBall_ ; 9:7307
+ReturnToBattle_UseBall:
+ farcall _ReturnToBattle_UseBall
ret
TownMap: ; ee55 (3:6e55)
@@ -2413,7 +2413,7 @@ NormalBox: ; f7aa (3:77aa)
GorgeousBox: ; f7ae (3:77ae)
ld c, DECOFLAG_GOLD_TROPHY_DOLL
asm_f7b0:
- farcall ReceiveDecorationC ; 9:70d5
+ farcall SetSpecificDecorationFlag
ld hl, Text_TrophyInside ; $77bf
call PrintText
jp Functionf7dc
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm
new file mode 100644
index 00000000..c9889472
--- /dev/null
+++ b/engine/overworld/decorations.asm
@@ -0,0 +1,1168 @@
+InitDecorations:
+ ld a, DECO_FEATHERY_BED
+ ld [wDecoBed], a
+ ld a, DECO_TOWN_MAP
+ ld [wDecoPoster], a
+ ret
+
+_PlayerDecorationMenu:
+ ld a, [wWhichIndexSet]
+ push af
+ ld hl, .MenuHeader
+ call LoadMenuHeader
+ xor a
+ ld [wBuffer5], a
+ ld a, $1
+ ld [wBuffer6], a
+.top_loop
+ ld a, [wBuffer6]
+ ld [wMenuCursorBuffer], a
+ call .FindCategoriesWithOwnedDecos
+ call DoNthMenu
+ ld a, [wMenuCursorY]
+ ld [wBuffer6], a
+ jr c, .exit_menu
+ ld a, [wMenuSelection]
+ ld hl, .pointers
+ call MenuJumptable
+ jr nc, .top_loop
+
+.exit_menu
+ call ExitMenu
+ pop af
+ ld [wWhichIndexSet], a
+ ld a, [wBuffer5]
+ ld c, a
+ ret
+
+.MenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 5, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
+ db 0 ; items
+ dw wceed
+ dw PlaceNthMenuStrings
+ dw .pointers
+
+.pointers
+ dw DecoBedMenu, .bed
+ dw DecoCarpetMenu, .carpet
+ dw DecoPlantMenu, .plant
+ dw DecoPosterMenu, .poster
+ dw DecoConsoleMenu, .game
+ dw DecoOrnamentMenu, .ornament
+ dw DecoBigDollMenu, .big_doll
+ dw DecoExitMenu, .exit
+
+.bed db "BED@"
+.carpet db "CARPET@"
+.plant db "PLANT@"
+.poster db "POSTER@"
+.game db "GAME CONSOLE@"
+.ornament db "ORNAMENT@"
+.big_doll db "BIG DOLL@"
+.exit db "EXIT@"
+
+.FindCategoriesWithOwnedDecos:
+ xor a
+ ld [wWhichIndexSet], a
+ call .ClearStringBuffer2
+ call .FindOwndDecos
+ ld a, 7
+ call .AppendToStringBuffer2
+ ld hl, wStringBuffer2
+ ld de, wceed
+ ld bc, ITEM_NAME_LENGTH
+ call CopyBytes
+ ret
+
+.ClearStringBuffer2:
+ ld hl, wStringBuffer2
+ xor a
+ ld [hli], a
+ ld bc, ITEM_NAME_LENGTH - 1
+ ld a, -1
+ call ByteFill
+ ret
+
+.AppendToStringBuffer2:
+ ld hl, wStringBuffer2
+ inc [hl]
+ ld e, [hl]
+ ld d, 0
+ add hl, de
+ ld [hl], a
+ ret
+
+.FindOwndDecos:
+ ld hl, .dw
+.loop
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ or e
+ jr z, .done
+ push hl
+ call _de_
+ pop hl
+ jr nc, .next
+ ld a, [hl]
+ push hl
+ call .AppendToStringBuffer2
+ pop hl
+.next
+ inc hl
+ jr .loop
+.done
+ ret
+
+.dw
+ dwb FindOwnedBeds, 0 ; bed
+ dwb FindOwnedCarpets, 1 ; carpet
+ dwb FindOwnedPlants, 2 ; plant
+ dwb FindOwnedPosters, 3 ; poster
+ dwb FindOwnedConsoles, 4 ; game console
+ dwb FindOwnedOrnaments, 5 ; ornament
+ dwb FindOwnedBigDolls, 6 ; big doll
+ dw 0 ; end
+
+Deco_FillTempWithMinusOne:
+ xor a
+ ld hl, wceed
+ ld [hli], a
+ ld a, -1
+ ld bc, $10
+ call ByteFill
+ ret
+
+CheckAllDecorationFlags:
+.loop
+ ld a, [hli]
+ cp -1
+ jr z, .done
+ push hl
+ push af
+ ld b, CHECK_FLAG
+ call DecorationFlagAction
+ ld a, c
+ and a
+ pop bc
+ ld a, b
+ call nz, AppendDecoIndex
+ pop hl
+ jr .loop
+
+.done
+ ret
+
+AppendDecoIndex:
+ ld hl, wceed
+ inc [hl]
+ ld e, [hl]
+ ld d, $0
+ add hl, de
+ ld [hl], a
+ ret
+
+FindOwnedDecosInCategory:
+ push bc
+ push hl
+ call Deco_FillTempWithMinusOne
+ pop hl
+ call CheckAllDecorationFlags
+ pop bc
+ ld a, [wceed]
+ and a
+ ret z
+
+ ld a, c
+ call AppendDecoIndex
+ ld a, 0
+ call AppendDecoIndex
+ scf
+ ret
+
+DecoBedMenu:
+ call FindOwnedBeds
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedBeds:
+ ld hl, .beds
+ ld c, BEDS
+ jp FindOwnedDecosInCategory
+
+.beds
+ db DECO_FEATHERY_BED ; 2
+ db DECO_PINK_BED ; 3
+ db DECO_POLKADOT_BED ; 4
+ db DECO_PIKACHU_BED ; 5
+ db -1
+
+DecoCarpetMenu:
+ call FindOwnedCarpets
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedCarpets:
+ ld hl, .carpets
+ ld c, CARPETS
+ jp FindOwnedDecosInCategory
+
+.carpets
+ db DECO_RED_CARPET ; 7
+ db DECO_BLUE_CARPET ; 8
+ db DECO_YELLOW_CARPET ; 9
+ db DECO_GREEN_CARPET ; a
+ db -1
+
+DecoPlantMenu:
+ call FindOwnedPlants
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedPlants:
+ ld hl, .plants
+ ld c, PLANTS
+ jp FindOwnedDecosInCategory
+
+.plants
+ db DECO_MAGNAPLANT ; c
+ db DECO_TROPICPLANT ; d
+ db DECO_JUMBOPLANT ; e
+ db -1
+
+DecoPosterMenu:
+ call FindOwnedPosters
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedPosters:
+ ld hl, .posters
+ ld c, POSTERS
+ jp FindOwnedDecosInCategory
+
+.posters
+ db DECO_TOWN_MAP ; 10
+ db DECO_PIKACHU_POSTER ; 11
+ db DECO_CLEFAIRY_POSTER ; 12
+ db DECO_JIGGLYPUFF_POSTER ; 13
+ db -1
+
+DecoConsoleMenu:
+ call FindOwnedConsoles
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedConsoles:
+ ld hl, .consoles
+ ld c, CONSOLES
+ jp FindOwnedDecosInCategory
+
+.consoles
+ db DECO_FAMICOM ; 15
+ db DECO_SNES ; 16
+ db DECO_N64 ; 17
+ db DECO_VIRTUAL_BOY ; 18
+ db -1
+
+DecoOrnamentMenu:
+ call FindOwnedOrnaments
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedOrnaments:
+ ld hl, .ornaments
+ ld c, DOLLS
+ jp FindOwnedDecosInCategory
+
+.ornaments
+ db DECO_PIKACHU_DOLL ; 1e
+ db DECO_SURF_PIKACHU_DOLL ; 1f
+ db DECO_CLEFAIRY_DOLL ; 20
+ db DECO_JIGGLYPUFF_DOLL ; 21
+ db DECO_BULBASAUR_DOLL ; 22
+ db DECO_CHARMANDER_DOLL ; 23
+ db DECO_SQUIRTLE_DOLL ; 24
+ db DECO_POLIWAG_DOLL ; 25
+ db DECO_DIGLETT_DOLL ; 26
+ db DECO_STARMIE_DOLL ; 27
+ db DECO_MAGIKARP_DOLL ; 28
+ db DECO_ODDISH_DOLL ; 29
+ db DECO_GENGAR_DOLL ; 2a
+ db DECO_SHELLDER_DOLL ; 2b
+ db DECO_GRIMER_DOLL ; 2c
+ db DECO_VOLTORB_DOLL ; 2d
+ db DECO_WEEDLE_DOLL ; 2e
+ db DECO_UNOWN_DOLL ; 2f
+ db DECO_GEODUDE_DOLL ; 30
+ db DECO_MACHOP_DOLL ; 31
+ db DECO_TENTACOOL_DOLL ; 32
+ db DECO_GOLD_TROPHY_DOLL ; 33
+ db DECO_SILVER_TROPHY_DOLL ; 34
+ db -1
+
+DecoBigDollMenu:
+ call FindOwnedBigDolls
+ call PopulateDecoCategoryMenu
+ xor a
+ ret
+
+FindOwnedBigDolls:
+ ld hl, .big_dolls
+ ld c, BIG_DOLLS
+ jp FindOwnedDecosInCategory
+
+.big_dolls
+ db DECO_BIG_SNORLAX_DOLL ; 1a
+ db DECO_BIG_ONIX_DOLL ; 1b
+ db DECO_BIG_LAPRAS_DOLL ; 1c
+ db -1
+
+DecoExitMenu:
+ scf
+ ret
+
+PopulateDecoCategoryMenu:
+ ld a, [wceed]
+ and a
+ jr z, .empty
+ cp 8
+ jr nc, .beyond_eight
+ xor a
+ ld [wWhichIndexSet], a
+ ld hl, .NonscrollingMenuHeader
+ call LoadMenuHeader
+ call DoNthMenu
+ jr c, .no_action_1
+ call DoDecorationAction2
+
+.no_action_1
+ call ExitMenu
+ ret
+
+.beyond_eight
+ ld hl, wceed
+ ld e, [hl]
+ dec [hl]
+ ld d, 0
+ add hl, de
+ ld [hl], -1
+ call LoadStandardMenuHeader
+ ld hl, .ScrollingMenuHeader
+ call CopyMenuHeader
+ xor a
+ ldh [hBGMapMode], a
+ call InitScrollingMenu
+ xor a
+ ld [wMenuScrollPosition], a
+ call ScrollingMenu
+ ld a, [wMenuJoypad]
+ cp 2
+ jr z, .no_action_2
+ call DoDecorationAction2
+
+.no_action_2
+ call ExitMenu
+ ret
+
+.empty
+ ld hl, .NothingToChooseText
+ call MenuTextboxBackup
+ ret
+
+.NothingToChooseText:
+ text_far _NothingToChooseText
+ text_end
+
+.NonscrollingMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
+ dw .NonscrollingMenuData
+ db 1 ; default option
+
+.NonscrollingMenuData:
+ db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
+ db 0 ; items
+ dw wceed
+ dw DecorationMenuFunction
+ dw DecorationAttributes
+
+.ScrollingMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 1, 1, SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2
+ dw .ScrollingMenuData
+ db 1 ; default option
+
+.ScrollingMenuData:
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
+ db 8, 0 ; rows, columns
+ db SCROLLINGMENU_ITEMS_NORMAL ; item format
+ dbw 0, wceed ; text pointer
+ dba DecorationMenuFunction
+ dbw 0, 0
+ dbw 0, 0
+
+GetDecorationData:
+ ld hl, DecorationAttributes
+ ld bc, 6
+ call AddNTimes
+ ret
+
+GetDecorationName:
+ push hl
+ call GetDecorationData
+ call GetDecoName
+ pop hl
+ call CopyName2
+ ret
+
+DecorationMenuFunction:
+ ld a, [wMenuSelection]
+ push de
+ call GetDecorationData
+ call GetDecoName
+ pop hl
+ call PlaceString
+ ret
+
+DoDecorationAction2:
+ ld a, [wMenuSelection]
+ call GetDecorationData
+ ld de, 2 ; function 2
+ add hl, de
+ ld a, [hl]
+ ld hl, .DecoActions
+ rst JumpTable
+ ret
+
+.DecoActions:
+ dw DecoAction_nothing
+ dw DecoAction_setupbed
+ dw DecoAction_putawaybed
+ dw DecoAction_setupcarpet
+ dw DecoAction_putawaycarpet
+ dw DecoAction_setupplant
+ dw DecoAction_putawayplant
+ dw DecoAction_setupposter
+ dw DecoAction_putawayposter
+ dw DecoAction_setupconsole
+ dw DecoAction_putawayconsole
+ dw DecoAction_setupbigdoll
+ dw DecoAction_putawaybigdoll
+ dw DecoAction_setupornament
+ dw DecoAction_putawayornament
+
+GetDecorationFlag:
+ call GetDecorationData
+ ld de, 3 ; event flag
+ add hl, de
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ ret
+
+DecorationFlagAction:
+ push bc
+ call GetDecorationFlag
+ pop bc
+ call EventFlagAction
+ ret
+
+GetDecorationSprite:
+ ld a, c
+ call GetDecorationData
+ ld de, 5 ; sprite
+ add hl, de
+ ld a, [hl]
+ ld c, a
+ ret
+
+INCLUDE "data/decorations/attributes.asm"
+
+INCLUDE "data/decorations/names.asm"
+
+GetDecoName:
+ ld a, [hli]
+ ld e, [hl]
+ ld bc, wStringBuffer2
+ push bc
+ ld hl, .NameFunctions
+ rst JumpTable
+ pop de
+ ret
+
+.NameFunctions:
+ dw .invalid
+ dw .plant
+ dw .bed
+ dw .carpet
+ dw .poster
+ dw .doll
+ dw .bigdoll
+
+.invalid
+ ret
+
+.plant
+ ld a, e
+ jr .getdeconame
+
+.bed
+ call .plant
+ ld a, _BED
+ jr .getdeconame
+
+.carpet
+ call .plant
+ ld a, _CARPET
+ jr .getdeconame
+
+.poster
+ ld a, e
+ call .getpokename
+ ld a, _POSTER
+ jr .getdeconame
+
+.doll
+ ld a, e
+ call .getpokename
+ ld a, _DOLL
+ jr .getdeconame
+
+.bigdoll
+ push de
+ ld a, BIG_
+ call .getdeconame
+ pop de
+ ld a, e
+ jr .getpokename
+
+.getpokename
+ push bc
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ pop bc
+ jr .copy
+
+.getdeconame
+ call ._getdeconame
+ jr .copy
+
+._getdeconame
+ push bc
+ ld hl, DecorationNames
+ call GetNthString
+ ld d, h
+ ld e, l
+ pop bc
+ ret
+
+.copy
+ ld h, b
+ ld l, c
+ call CopyName2
+ dec hl
+ ld b, h
+ ld c, l
+ ret
+
+DecoAction_nothing:
+ scf
+ ret
+
+DecoAction_setupbed:
+ ld hl, wDecoBed
+ jp DecoAction_TrySetItUp
+
+DecoAction_putawaybed:
+ ld hl, wDecoBed
+ jp DecoAction_TryPutItAway
+
+DecoAction_setupcarpet:
+ ld hl, wDecoCarpet
+ jp DecoAction_TrySetItUp
+
+DecoAction_putawaycarpet:
+ ld hl, wDecoCarpet
+ jp DecoAction_TryPutItAway
+
+DecoAction_setupplant:
+ ld hl, wDecoPlant
+ jp DecoAction_TrySetItUp
+
+DecoAction_putawayplant:
+ ld hl, wDecoPlant
+ jp DecoAction_TryPutItAway
+
+DecoAction_setupposter:
+ ld hl, wDecoPoster
+ jp DecoAction_TrySetItUp
+
+DecoAction_putawayposter:
+ ld hl, wDecoPoster
+ jp DecoAction_TryPutItAway
+
+DecoAction_setupconsole:
+ ld hl, wDecoConsole
+ jp DecoAction_TrySetItUp
+
+DecoAction_putawayconsole:
+ ld hl, wDecoConsole
+ jp DecoAction_TryPutItAway
+
+DecoAction_setupbigdoll:
+ ld hl, wDecoBigDoll
+ jp DecoAction_TrySetItUp
+
+DecoAction_putawaybigdoll:
+ ld hl, wDecoBigDoll
+ jp DecoAction_TryPutItAway
+
+DecoAction_TrySetItUp:
+ ld a, [hl]
+ ld [wBuffer1], a
+ push hl
+ call DecoAction_SetItUp
+ jr c, .failed
+ ld a, 1
+ ld [wBuffer5], a
+ pop hl
+ ld a, [wMenuSelection]
+ ld [hl], a
+ xor a
+ ret
+
+.failed
+ pop hl
+ xor a
+ ret
+
+DecoAction_SetItUp:
+; See if there's anything of the same type already out
+ ld a, [wBuffer1]
+ and a
+ jr z, .nothingthere
+; See if that item is already out
+ ld b, a
+ ld a, [wMenuSelection]
+ cp b
+ jr z, .alreadythere
+; Put away the item that's already out, and set up the new one
+ ld a, [wMenuSelection]
+ ld hl, wStringBuffer4
+ call GetDecorationName
+ ld a, [wBuffer1]
+ ld hl, wStringBuffer3
+ call GetDecorationName
+ ld hl, PutAwayAndSetUpText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+.nothingthere
+ ld a, [wMenuSelection]
+ ld hl, wStringBuffer3
+ call GetDecorationName
+ ld hl, SetUpTheDecoText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+.alreadythere
+ ld hl, AlreadySetUpText
+ call MenuTextboxBackup
+ scf
+ ret
+
+DecoAction_TryPutItAway:
+; If there is no item of that type already set, there is nothing to put away.
+ ld a, [hl]
+ ld [wBuffer1], a
+ xor a
+ ld [hl], a
+ ld a, [wBuffer1]
+ and a
+ jr z, .nothingthere
+; Put it away.
+ ld a, $1
+ ld [wBuffer5], a
+ ld a, [wBuffer1]
+ ld [wMenuSelection], a
+ ld hl, wStringBuffer3
+ call GetDecorationName
+ ld hl, PutAwayTheDecoText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+.nothingthere
+ ld hl, NothingToPutAwayText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+DecoAction_setupornament:
+ ld hl, WhichSidePutOnText
+ call DecoAction_AskWhichSide
+ jr c, .cancel
+ call DecoAction_SetItUp_Ornament
+ jr c, .cancel
+ ld a, $1
+ ld [wBuffer5], a
+ jr DecoAction_FinishUp_Ornament
+
+.cancel
+ xor a
+ ret
+
+DecoAction_putawayornament:
+ ld hl, WhichSidePutAwayText
+ call DecoAction_AskWhichSide
+ jr nc, .incave
+ xor a
+ ret
+
+.incave
+ call DecoAction_PutItAway_Ornament
+
+DecoAction_FinishUp_Ornament:
+ call QueryWhichSide
+ ld a, [wSelectedDecoration]
+ ld [hl], a
+ ld a, [wOtherDecoration]
+ ld [de], a
+ xor a
+ ret
+
+DecoAction_SetItUp_Ornament:
+ ld a, [wSelectedDecoration]
+ and a
+ jr z, .nothingthere
+ ld b, a
+ ld a, [wMenuSelection]
+ cp b
+ jr z, .failed
+ ld a, b
+ ld hl, wStringBuffer3
+ call GetDecorationName
+ ld a, [wMenuSelection]
+ ld hl, wStringBuffer4
+ call GetDecorationName
+ ld a, [wMenuSelection]
+ ld [wSelectedDecoration], a
+ call .getwhichside
+ ld hl, PutAwayAndSetUpText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+.nothingthere
+ ld a, [wMenuSelection]
+ ld [wSelectedDecoration], a
+ call .getwhichside
+ ld a, [wMenuSelection]
+ ld hl, wStringBuffer3
+ call GetDecorationName
+ ld hl, SetUpTheDecoText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+.failed
+ ld hl, AlreadySetUpText
+ call MenuTextboxBackup
+ scf
+ ret
+
+.getwhichside
+ ld a, [wMenuSelection]
+ ld b, a
+ ld a, [wOtherDecoration]
+ cp b
+ ret nz
+ xor a
+ ld [wOtherDecoration], a
+ ret
+
+WhichSidePutOnText:
+ text_far _WhichSidePutOnText
+ text_end
+
+DecoAction_PutItAway_Ornament:
+ ld a, [wSelectedDecoration]
+ and a
+ jr z, .nothingthere
+ ld hl, wStringBuffer3
+ call GetDecorationName
+ ld a, $1
+ ld [wBuffer5], a
+ xor a
+ ld [wSelectedDecoration], a
+ ld hl, PutAwayTheDecoText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+.nothingthere
+ ld hl, NothingToPutAwayText
+ call MenuTextboxBackup
+ xor a
+ ret
+
+WhichSidePutAwayText:
+ text_far _WhichSidePutAwayText
+ text_end
+
+DecoAction_AskWhichSide:
+ call MenuTextbox
+ ld hl, MenuHeader_0x2707e
+ call GetMenu2
+ call ExitMenu
+ call CopyMenuData
+ jr c, .nope
+ ld a, [wMenuCursorY]
+ cp 3
+ jr z, .nope
+ ld [wBuffer2], a
+ call QueryWhichSide
+ ld a, [hl]
+ ld [wSelectedDecoration], a
+ ld a, [de]
+ ld [wOtherDecoration], a
+ xor a
+ ret
+
+.nope
+ scf
+ ret
+
+QueryWhichSide:
+ ld hl, wDecoRightOrnament
+ ld de, wDecoLeftOrnament
+ ld a, [wBuffer2]
+ cp 1
+ ret z
+ push hl
+ ld h, d
+ ld l, e
+ pop de
+ ret
+
+MenuHeader_0x2707e:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 12, 7
+ dw MenuData_0x27086
+ db 1 ; default option
+
+MenuData_0x27086:
+ db STATICMENU_CURSOR ; flags
+ db 3 ; items
+ db "RIGHT SIDE@"
+ db "LEFT SIDE@"
+ db "CANCEL@"
+
+PutAwayTheDecoText:
+ text_far _PutAwayTheDecoText
+ text_end
+
+NothingToPutAwayText:
+ text_far _NothingToPutAwayText
+ text_end
+
+SetUpTheDecoText:
+ text_far _SetUpTheDecoText
+ text_end
+
+PutAwayAndSetUpText:
+ text_far _PutAwayAndSetUpText
+ text_end
+
+AlreadySetUpText:
+ text_far _AlreadySetUpText
+ text_end
+
+GetDecorationName_c_de:
+ ld a, c
+ ld h, d
+ ld l, e
+ call GetDecorationName
+ ret
+
+DecorationFlagAction_c:
+ ld a, c
+ jp DecorationFlagAction
+
+GetDecorationName_c:
+ ld a, c
+ call GetDecorationID
+ ld hl, wStringBuffer1
+ push hl
+ call GetDecorationName
+ pop de
+ ret
+
+SetSpecificDecorationFlag:
+ ld a, c
+ call GetDecorationID
+ ld b, SET_FLAG
+ call DecorationFlagAction
+ ret
+
+GetDecorationID:
+ push hl
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, DecorationIDs
+ add hl, de
+ ld a, [hl]
+ pop de
+ pop hl
+ ret
+
+SetAllDecorationFlags:
+ ld hl, DecorationIDs
+.loop
+ ld a, [hli]
+ cp -1
+ jr z, .done
+ push hl
+ ld b, SET_FLAG
+ call DecorationFlagAction
+ pop hl
+ jr .loop
+
+.done
+ ret
+
+INCLUDE "data/decorations/decorations.asm"
+
+DescribeDecoration::
+ ld a, b
+ ld hl, .JumpTable
+ rst JumpTable
+ ret
+
+.JumpTable:
+; entries correspond to DECODESC_* constants
+ dw DecorationDesc_Poster
+ dw DecorationDesc_LeftOrnament
+ dw DecorationDesc_RightOrnament
+ dw DecorationDesc_GiantOrnament
+ dw DecorationDesc_Console
+
+DecorationDesc_Poster:
+ ld a, [wDecoPoster]
+ ld hl, DecorationDesc_PosterPointers
+ ld de, 3
+ call IsInArray
+ jr c, .nope
+ ld de, DecorationDesc_NullPoster
+ ld b, BANK(DecorationDesc_NullPoster)
+ ret
+
+.nope
+ ld b, BANK(DecorationDesc_TownMapPoster)
+ inc hl
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ ret
+
+DecorationDesc_PosterPointers:
+ dbw DECO_TOWN_MAP, DecorationDesc_TownMapPoster
+ dbw DECO_PIKACHU_POSTER, DecorationDesc_PikachuPoster
+ dbw DECO_CLEFAIRY_POSTER, DecorationDesc_ClefairyPoster
+ dbw DECO_JIGGLYPUFF_POSTER, DecorationDesc_JigglypuffPoster
+ db -1
+
+DecorationDesc_TownMapPoster:
+ opentext
+ writetext .LookTownMapText
+ waitbutton
+ special OverworldTownMap
+ closetext
+ end
+
+.LookTownMapText:
+ text_far _LookTownMapText
+ text_end
+
+DecorationDesc_PikachuPoster:
+ jumptext .LookPikachuPosterText
+
+.LookPikachuPosterText:
+ text_far _LookPikachuPosterText
+ text_end
+
+DecorationDesc_ClefairyPoster:
+ jumptext .LookClefairyPosterText
+
+.LookClefairyPosterText:
+ text_far _LookClefairyPosterText
+ text_end
+
+DecorationDesc_JigglypuffPoster:
+ jumptext .LookJigglypuffPosterText
+
+.LookJigglypuffPosterText:
+ text_far _LookJigglypuffPosterText
+ text_end
+
+DecorationDesc_NullPoster:
+ end
+
+DecorationDesc_LeftOrnament:
+ ld a, [wDecoLeftOrnament]
+ jr DecorationDesc_OrnamentOrConsole
+
+DecorationDesc_RightOrnament:
+ ld a, [wDecoRightOrnament]
+ jr DecorationDesc_OrnamentOrConsole
+
+DecorationDesc_Console:
+ ld a, [wDecoConsole]
+ jr DecorationDesc_OrnamentOrConsole
+
+DecorationDesc_OrnamentOrConsole:
+ ld c, a
+ ld de, wStringBuffer3
+ call GetDecorationName_c_de
+ ld b, BANK(.OrnamentConsoleScript)
+ ld de, .OrnamentConsoleScript
+ ret
+
+.OrnamentConsoleScript:
+ jumptext .LookAdorableDecoText
+
+.LookAdorableDecoText:
+ text_far _LookAdorableDecoText
+ text_end
+
+DecorationDesc_GiantOrnament:
+ ld b, BANK(.BigDollScript)
+ ld de, .BigDollScript
+ ret
+
+.BigDollScript:
+ jumptext .LookGiantDecoText
+
+.LookGiantDecoText:
+ text_far _LookGiantDecoText
+ text_end
+
+ToggleMaptileDecorations:
+ ; tile coordinates work the same way as for changeblock
+ lb de, 0, 4 ; bed coordinates
+ ld a, [wDecoBed]
+ call SetDecorationTile
+ lb de, 7, 4 ; plant coordinates
+ ld a, [wDecoPlant]
+ call SetDecorationTile
+ lb de, 6, 0 ; poster coordinates
+ ld a, [wDecoPoster]
+ call SetDecorationTile
+ call SetPosterVisibility
+ lb de, 0, 0 ; carpet top-left coordinates
+ call PadCoords_de
+ ld a, [wDecoCarpet]
+ and a
+ ret z
+ call _GetDecorationSprite
+ ld [hl], a
+ push af
+ lb de, 0, 2 ; carpet bottom-left coordinates
+ call PadCoords_de
+ pop af
+ inc a
+ ld [hli], a ; carpet bottom-left block
+ inc a
+ ld [hli], a ; carpet bottom-middle block
+ dec a
+ ld [hl], a ; carpet bottom-right block
+ ret
+
+SetPosterVisibility:
+ ld b, SET_FLAG
+ ld a, [wDecoPoster]
+ and a
+ jr nz, .ok
+ ld b, RESET_FLAG
+
+.ok
+ ld de, EVENT_PLAYERS_ROOM_POSTER
+ jp EventFlagAction
+
+SetDecorationTile:
+ push af
+ call PadCoords_de
+ pop af
+ and a
+ ret z
+ call _GetDecorationSprite
+ ld [hl], a
+ ret
+
+ToggleDecorationsVisibility:
+ ld de, EVENT_PLAYERS_HOUSE_2F_CONSOLE
+ ld hl, wVariableSprites + SPRITE_CONSOLE - SPRITE_VARS
+ ld a, [wDecoConsole]
+ call ToggleDecorationVisibility
+ ld de, EVENT_PLAYERS_HOUSE_2F_DOLL_1
+ ld hl, wVariableSprites + SPRITE_DOLL_1 - SPRITE_VARS
+ ld a, [wDecoLeftOrnament]
+ call ToggleDecorationVisibility
+ ld de, EVENT_PLAYERS_HOUSE_2F_DOLL_2
+ ld hl, wVariableSprites + SPRITE_DOLL_2 - SPRITE_VARS
+ ld a, [wDecoRightOrnament]
+ call ToggleDecorationVisibility
+ ld de, EVENT_PLAYERS_HOUSE_2F_BIG_DOLL
+ ld hl, wVariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS
+ ld a, [wDecoBigDoll]
+ call ToggleDecorationVisibility
+ ret
+
+ToggleDecorationVisibility:
+ and a
+ jr z, .hide
+ call _GetDecorationSprite
+ ld [hl], a
+ ld b, RESET_FLAG
+ jp EventFlagAction
+
+.hide
+ ld b, SET_FLAG
+ jp EventFlagAction
+
+_GetDecorationSprite:
+ ld c, a
+ push de
+ push hl
+ farcall GetDecorationSprite
+ pop hl
+ pop de
+ ld a, c
+ ret
+
+PadCoords_de:
+; adjusts coordinates, the same way as Script_changeblock
+ ld a, d
+ add 4
+ ld d, a
+ ld a, e
+ add 4
+ ld e, a
+ call GetBlockLocation
+ ret
diff --git a/main.asm b/main.asm
index 5d00843c..26646edc 100644
--- a/main.asm
+++ b/main.asm
@@ -241,29 +241,11 @@ INCLUDE "engine/pokemon/mon_submenu.asm"
INCLUDE "engine/battle/menu.asm"
INCLUDE "engine/items/buy_sell_toss.asm"
INCLUDE "engine/menus/trainer_card.asm"
-
-ProfOaksPC::
- dr $267af, $267ca
-ProfOaksPCBoot::
- dr $267ca, $2692d
-InitDecorations::
- dr $2692d, $26938
-_PlayerDecorationMenu::
- dr $26938, $270d5
-
-ReceiveDecorationC::
- dr $270d5, $2712c
-DescribeDecoration::
- dr $2712c, $271be
-ToggleMaptileDecorations::
- dr $271be, $27216
-ToggleDecorationsVisibility::
- dr $27216, $27271
+INCLUDE "engine/events/prof_oaks_pc.asm"
+INCLUDE "engine/overworld/decorations.asm"
INCLUDE "engine/battle/read_trainer_dvs.asm"
-ReturnToBattle_UseBall_::
- dr $27307, $2733d
-ConsumeHeldItem::
- dr $2733d, $2739f
+INCLUDE "engine/battle/returntobattle_useball.asm"
+INCLUDE "engine/battle/consume_held_item.asm"
INCLUDE "data/moves/effects.asm"
diff --git a/wram.asm b/wram.asm
index b77d21d5..c2ca624e 100644
--- a/wram.asm
+++ b/wram.asm
@@ -3196,19 +3196,20 @@ wCurMapSceneScriptsPointer:: dw ; d952
wCurMapCallbackCount:: db ; d954
wCurMapCallbacksPointer:: dw ; d955
-wd957:: ds 1 ; d957
-wd958:: ds 1 ; d958
-wd959:: ds 1 ; d959
-wd95a:: ds 1 ; d95a
-wd95b:: ds 1 ; d95b
-wd95c:: ds 1 ; d95c
-wd95d:: ds 1 ; d95d
-wd95e:: ds 1 ; d95e
-wd95f:: ds 1 ; d95f
-wd960:: ds 1 ; d960
+ ds 2
+
+; Sprite id of each decoration
+wDecoBed:: db ; d959
+wDecoCarpet:: db ; d95a
+wDecoPlant:: db ; d95b
+wDecoPoster:: db ; d95c
+wDecoConsole:: db ; d95d
+wDecoLeftOrnament:: db ; d95e
+wDecoRightOrnament:: db ; d95f
+wDecoBigDoll:: db ; d960
+
wd961:: ds 1 ; d961
wd962:: ds 1 ; d962
-
wMomItemTriggerBalance:: ds 3 ; d963
wDailyResetTimer:: dw ; d966