pokecrystal-board/engine/overworld/decorations.asm

1190 lines
19 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
InitDecorations:
2015-11-17 12:54:03 -08:00
ld a, DECO_FEATHERY_BED
ld [wDecoBed], a
2015-11-17 12:54:03 -08:00
ld a, DECO_TOWN_MAP
ld [wDecoPoster], a
2015-11-17 12:54:03 -08:00
ret
_PlayerDecorationMenu:
2015-12-18 17:07:09 -08:00
ld a, [wWhichIndexSet]
2015-11-17 12:54:03 -08:00
push af
ld hl, .MenuHeader
call LoadMenuHeader
2015-11-17 12:54:03 -08:00
xor a
2018-01-23 14:39:09 -08:00
ld [wBuffer5], a
2015-11-17 12:54:03 -08:00
ld a, $1
2018-01-23 14:39:09 -08:00
ld [wBuffer6], a
2015-11-17 12:54:03 -08:00
.top_loop
2018-01-23 14:39:09 -08:00
ld a, [wBuffer6]
2015-11-17 12:54:03 -08:00
ld [wMenuCursorBuffer], a
call .FindCategoriesWithOwnedDecos
call DoNthMenu
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2018-01-23 14:39:09 -08:00
ld [wBuffer6], a
2015-11-17 12:54:03 -08:00
jr c, .exit_menu
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
ld hl, .pointers
call MenuJumptable
jr nc, .top_loop
.exit_menu
call ExitMenu
pop af
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
2018-01-23 14:39:09 -08:00
ld a, [wBuffer5]
2015-11-17 12:54:03 -08:00
ld c, a
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 5, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData
2015-11-17 12:54:03 -08:00
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
2015-11-17 12:54:03 -08:00
db 0 ; items
dw wd002
dw PlaceNthMenuStrings
dw .pointers
2018-06-24 07:09:41 -07:00
.pointers
2015-11-17 12:54:03 -08:00
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@"
2018-06-24 07:09:41 -07:00
.FindCategoriesWithOwnedDecos:
2015-11-17 12:54:03 -08:00
xor a
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
2015-11-17 12:54:03 -08:00
call .ClearStringBuffer2
call .FindOwndDecos
ld a, 7
call .AppendToStringBuffer2
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer2
2015-11-17 12:54:03 -08:00
ld de, wd002
ld bc, ITEM_NAME_LENGTH
call CopyBytes
ret
2018-06-24 07:09:41 -07:00
.ClearStringBuffer2:
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer2
2015-11-17 12:54:03 -08:00
xor a
ld [hli], a
ld bc, ITEM_NAME_LENGTH - 1
ld a, -1
call ByteFill
ret
2018-06-24 07:09:41 -07:00
.AppendToStringBuffer2:
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer2
2015-11-17 12:54:03 -08:00
inc [hl]
ld e, [hl]
ld d, 0
add hl, de
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
.FindOwndDecos:
2015-12-26 18:59:03 -08:00
ld hl, .dw
2015-11-17 12:54:03 -08:00
.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
2018-06-24 07:09:41 -07:00
.dw
2015-11-17 12:54:03 -08:00
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
2018-06-24 07:09:41 -07:00
Deco_FillTempWithMinusOne:
2015-11-17 12:54:03 -08:00
xor a
ld hl, wd002
ld [hli], a
ld a, -1
ld bc, $10
call ByteFill
ret
2018-06-24 07:09:41 -07:00
CheckAllDecorationFlags:
2015-11-17 12:54:03 -08:00
.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
2018-06-24 07:09:41 -07:00
AppendDecoIndex:
2015-11-17 12:54:03 -08:00
ld hl, wd002
inc [hl]
ld e, [hl]
ld d, $0
add hl, de
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
FindOwnedDecosInCategory:
2015-11-17 12:54:03 -08:00
push bc
push hl
call Deco_FillTempWithMinusOne
pop hl
call CheckAllDecorationFlags
pop bc
ld a, [wd002]
and a
ret z
ld a, c
call AppendDecoIndex
ld a, 0
call AppendDecoIndex
scf
ret
2018-06-24 07:09:41 -07:00
DecoBedMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedBeds
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedBeds:
2015-11-17 12:54:03 -08:00
ld hl, .beds
ld c, BEDS
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.beds
2015-11-17 12:54:03 -08:00
db DECO_FEATHERY_BED ; 2
db DECO_PINK_BED ; 3
db DECO_POLKADOT_BED ; 4
db DECO_PIKACHU_BED ; 5
db -1
2018-06-24 07:09:41 -07:00
DecoCarpetMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedCarpets
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedCarpets:
2015-11-17 12:54:03 -08:00
ld hl, .carpets
ld c, CARPETS
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.carpets
2015-11-17 12:54:03 -08:00
db DECO_RED_CARPET ; 7
db DECO_BLUE_CARPET ; 8
db DECO_YELLOW_CARPET ; 9
db DECO_GREEN_CARPET ; a
db -1
2018-06-24 07:09:41 -07:00
DecoPlantMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedPlants
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedPlants:
2015-11-17 12:54:03 -08:00
ld hl, .plants
ld c, PLANTS
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.plants
2015-11-17 12:54:03 -08:00
db DECO_MAGNAPLANT ; c
db DECO_TROPICPLANT ; d
db DECO_JUMBOPLANT ; e
db -1
2018-06-24 07:09:41 -07:00
DecoPosterMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedPosters
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedPosters:
2015-11-17 12:54:03 -08:00
ld hl, .posters
ld c, POSTERS
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.posters
2015-11-17 12:54:03 -08:00
db DECO_TOWN_MAP ; 10
db DECO_PIKACHU_POSTER ; 11
db DECO_CLEFAIRY_POSTER ; 12
db DECO_JIGGLYPUFF_POSTER ; 13
db -1
2018-06-24 07:09:41 -07:00
DecoConsoleMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedConsoles
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedConsoles:
2015-11-17 12:54:03 -08:00
ld hl, .consoles
ld c, CONSOLES
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.consoles
2015-11-17 12:54:03 -08:00
db DECO_FAMICOM ; 15
db DECO_SNES ; 16
db DECO_N64 ; 17
db DECO_VIRTUAL_BOY ; 18
db -1
2018-06-24 07:09:41 -07:00
DecoOrnamentMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedOrnaments
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedOrnaments:
2015-11-17 12:54:03 -08:00
ld hl, .ornaments
ld c, DOLLS
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.ornaments
2015-11-17 12:54:03 -08:00
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
2018-06-24 07:09:41 -07:00
DecoBigDollMenu:
2015-11-17 12:54:03 -08:00
call FindOwnedBigDolls
call PopulateDecoCategoryMenu
xor a
ret
2018-06-24 07:09:41 -07:00
FindOwnedBigDolls:
2015-11-17 12:54:03 -08:00
ld hl, .big_dolls
ld c, BIG_DOLLS
2015-11-17 12:54:03 -08:00
jp FindOwnedDecosInCategory
2018-06-24 07:09:41 -07:00
.big_dolls
2015-11-17 12:54:03 -08:00
db DECO_BIG_SNORLAX_DOLL ; 1a
db DECO_BIG_ONIX_DOLL ; 1b
db DECO_BIG_LAPRAS_DOLL ; 1c
db -1
2018-06-24 07:09:41 -07:00
DecoExitMenu:
2015-11-17 12:54:03 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
PopulateDecoCategoryMenu:
2015-11-17 12:54:03 -08:00
ld a, [wd002]
and a
jr z, .empty
cp 8
jr nc, .beyond_eight
xor a
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
ld hl, .NonscrollingMenuHeader
call LoadMenuHeader
2015-11-17 12:54:03 -08:00
call DoNthMenu
jr c, .no_action_1
call DoDecorationAction2
.no_action_1
call ExitMenu
ret
.beyond_eight
ld hl, wd002
ld e, [hl]
dec [hl]
ld d, 0
add hl, de
ld [hl], -1
call LoadStandardMenuHeader
ld hl, .ScrollingMenuHeader
call CopyMenuHeader
2015-11-17 12:54:03 -08:00
xor a
ld [hBGMapMode], a
call InitScrollingMenu
xor a
2015-11-23 13:04:53 -08:00
ld [wMenuScrollPosition], a
2015-12-17 19:31:16 -08:00
call ScrollingMenu
2015-12-15 15:59:49 -08:00
ld a, [wMenuJoypad]
2015-11-17 12:54:03 -08:00
cp 2
jr z, .no_action_2
call DoDecorationAction2
.no_action_2
call ExitMenu
ret
.empty
ld hl, .Text_nothing_to_choose
call MenuTextBoxBackup
ret
.Text_nothing_to_choose:
2015-11-17 12:54:03 -08:00
; There's nothing to choose.
text_jump UnknownText_0x1bc471
db "@"
.NonscrollingMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .NonscrollingMenuData
2015-11-17 12:54:03 -08:00
db 1 ; default option
.NonscrollingMenuData:
db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
2015-11-17 12:54:03 -08:00
db 0 ; items
dw wd002
dw DecorationMenuFunction
dw DecorationAttributes
.ScrollingMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 1, 1, SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2
dw .ScrollingMenuData
2015-11-17 12:54:03 -08:00
db 1 ; default option
.ScrollingMenuData:
db SCROLLINGMENU_DISPLAY_ARROWS ; flags
2015-11-17 12:54:03 -08:00
db 8, 0 ; rows, columns
db 1 ; horizontal spacing
dbw 0, wd002 ; text pointer
dba DecorationMenuFunction
dbw 0, 0
dbw 0, 0
2018-06-24 07:09:41 -07:00
GetDecorationData:
2015-11-17 12:54:03 -08:00
ld hl, DecorationAttributes
ld bc, 6
call AddNTimes
ret
2018-06-24 07:09:41 -07:00
GetDecorationName:
2015-11-17 12:54:03 -08:00
push hl
call GetDecorationData
call GetDecoName
pop hl
call CopyName2
ret
2018-06-24 07:09:41 -07:00
DecorationMenuFunction:
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
push de
call GetDecorationData
call GetDecoName
pop hl
call PlaceString
ret
2018-06-24 07:09:41 -07:00
DoDecorationAction2:
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
call GetDecorationData
ld de, 2 ; function 2
add hl, de
ld a, [hl]
ld hl, .DecoActions
rst JumpTable
ret
2018-06-24 07:09:41 -07:00
.DecoActions:
2015-11-17 12:54:03 -08:00
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
2018-06-24 07:09:41 -07:00
GetDecorationFlag:
2015-11-17 12:54:03 -08:00
call GetDecorationData
ld de, 3 ; event flag
add hl, de
ld a, [hli]
ld d, [hl]
ld e, a
ret
2018-06-24 07:09:41 -07:00
DecorationFlagAction:
2015-11-17 12:54:03 -08:00
push bc
call GetDecorationFlag
pop bc
call EventFlagAction
ret
2018-06-24 07:09:41 -07:00
GetDecorationSprite:
2015-11-17 12:54:03 -08:00
ld a, c
call GetDecorationData
ld de, 5 ; sprite
add hl, de
ld a, [hl]
ld c, a
ret
2017-12-27 08:56:03 -08:00
INCLUDE "data/decorations/attributes.asm"
2015-11-17 12:54:03 -08:00
2017-12-27 08:56:03 -08:00
INCLUDE "data/decorations/names.asm"
2015-11-17 12:54:03 -08:00
2018-06-24 07:09:41 -07:00
GetDecoName:
2015-11-17 12:54:03 -08:00
ld a, [hli]
ld e, [hl]
2018-01-23 14:39:09 -08:00
ld bc, wStringBuffer2
2015-11-17 12:54:03 -08:00
push bc
ld hl, .NameFunctions
rst JumpTable
pop de
ret
2018-06-24 07:09:41 -07:00
.NameFunctions:
2015-11-17 12:54:03 -08:00
dw .invalid
dw .plant
dw .bed
dw .carpet
dw .poster
dw .doll
dw .bigdoll
2018-06-24 07:09:41 -07:00
.invalid
2015-11-17 12:54:03 -08:00
ret
2018-06-24 07:09:41 -07:00
.plant
2015-11-17 12:54:03 -08:00
ld a, e
jr .getdeconame
2018-06-24 07:09:41 -07:00
.bed
2015-11-17 12:54:03 -08:00
call .plant
ld a, _BED
jr .getdeconame
2018-06-24 07:09:41 -07:00
.carpet
2015-11-17 12:54:03 -08:00
call .plant
ld a, _CARPET
jr .getdeconame
2018-06-24 07:09:41 -07:00
.poster
2015-11-17 12:54:03 -08:00
ld a, e
call .getpokename
ld a, _POSTER
jr .getdeconame
2018-06-24 07:09:41 -07:00
.doll
2015-11-17 12:54:03 -08:00
ld a, e
call .getpokename
ld a, _DOLL
jr .getdeconame
2018-06-24 07:09:41 -07:00
.bigdoll
2015-11-17 12:54:03 -08:00
push de
ld a, BIG_
call .getdeconame
pop de
ld a, e
jr .getpokename
2018-06-24 07:09:41 -07:00
.unused
2015-11-17 12:54:03 -08:00
push de
call .getdeconame
pop de
ld a, e
jr .getdeconame
2018-06-24 07:09:41 -07:00
.getpokename
2015-11-17 12:54:03 -08:00
push bc
ld [wNamedObjectIndexBuffer], a
2015-11-17 12:54:03 -08:00
call GetPokemonName
pop bc
jr .copy
2018-06-24 07:09:41 -07:00
.getdeconame
2015-11-17 12:54:03 -08:00
call ._getdeconame
jr .copy
2018-06-24 07:09:41 -07:00
._getdeconame
2015-11-17 12:54:03 -08:00
push bc
ld hl, DecorationNames
call GetNthString
ld d, h
ld e, l
pop bc
ret
2018-06-24 07:09:41 -07:00
.copy
2015-11-17 12:54:03 -08:00
ld h, b
ld l, c
call CopyName2
dec hl
ld b, h
ld c, l
ret
2018-06-24 07:09:41 -07:00
DecoAction_nothing:
2015-11-17 12:54:03 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
DecoAction_setupbed:
ld hl, wDecoBed
2015-11-17 12:54:03 -08:00
jp DecoAction_TrySetItUp
2018-06-24 07:09:41 -07:00
DecoAction_putawaybed:
ld hl, wDecoBed
2015-11-17 12:54:03 -08:00
jp DecoAction_TryPutItAway
2018-06-24 07:09:41 -07:00
DecoAction_setupcarpet:
ld hl, wDecoCarpet
2015-11-17 12:54:03 -08:00
jp DecoAction_TrySetItUp
2018-06-24 07:09:41 -07:00
DecoAction_putawaycarpet:
ld hl, wDecoCarpet
2015-11-17 12:54:03 -08:00
jp DecoAction_TryPutItAway
2018-06-24 07:09:41 -07:00
DecoAction_setupplant:
ld hl, wDecoPlant
2015-11-17 12:54:03 -08:00
jp DecoAction_TrySetItUp
2018-06-24 07:09:41 -07:00
DecoAction_putawayplant:
ld hl, wDecoPlant
2015-11-17 12:54:03 -08:00
jp DecoAction_TryPutItAway
2018-06-24 07:09:41 -07:00
DecoAction_setupposter:
ld hl, wDecoPoster
2015-11-17 12:54:03 -08:00
jp DecoAction_TrySetItUp
2018-06-24 07:09:41 -07:00
DecoAction_putawayposter:
ld hl, wDecoPoster
2015-11-17 12:54:03 -08:00
jp DecoAction_TryPutItAway
2018-06-24 07:09:41 -07:00
DecoAction_setupconsole:
ld hl, wDecoConsole
2015-11-17 12:54:03 -08:00
jp DecoAction_TrySetItUp
2018-06-24 07:09:41 -07:00
DecoAction_putawayconsole:
ld hl, wDecoConsole
2015-11-17 12:54:03 -08:00
jp DecoAction_TryPutItAway
2018-06-24 07:09:41 -07:00
DecoAction_setupbigdoll:
ld hl, wDecoBigDoll
2015-11-17 12:54:03 -08:00
jp DecoAction_TrySetItUp
2018-06-24 07:09:41 -07:00
DecoAction_putawaybigdoll:
ld hl, wDecoBigDoll
2015-11-17 12:54:03 -08:00
jp DecoAction_TryPutItAway
2018-06-24 07:09:41 -07:00
DecoAction_TrySetItUp:
2015-11-17 12:54:03 -08:00
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wBuffer1], a
2015-11-17 12:54:03 -08:00
push hl
call DecoAction_SetItUp
jr c, .failed
ld a, 1
2018-01-23 14:39:09 -08:00
ld [wBuffer5], a
2015-11-17 12:54:03 -08:00
pop hl
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
ld [hl], a
xor a
ret
.failed
pop hl
xor a
ret
2018-06-24 07:09:41 -07:00
DecoAction_SetItUp:
2015-11-17 12:54:03 -08:00
; See if there's anything of the same type already out
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
2015-11-17 12:54:03 -08:00
and a
jr z, .nothingthere
; See if that item is already out
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
cp b
jr z, .alreadythere
; Put away the item that's already out, and set up the new one
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld hl, wStringBuffer4
2015-11-17 12:54:03 -08:00
call GetDecorationName
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld hl, DecoText_PutAwayAndSetUp
call MenuTextBoxBackup
xor a
ret
.nothingthere
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld hl, DecoText_SetUpTheDeco
call MenuTextBoxBackup
xor a
ret
.alreadythere
ld hl, DecoText_AlreadySetUp
call MenuTextBoxBackup
scf
ret
2018-06-24 07:09:41 -07:00
DecoAction_TryPutItAway:
2015-11-17 12:54:03 -08:00
; If there is no item of that type already set, there is nothing to put away.
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wBuffer1], a
2015-11-17 12:54:03 -08:00
xor a
ld [hl], a
2018-01-23 14:39:09 -08:00
ld a, [wBuffer1]
2015-11-17 12:54:03 -08:00
and a
jr z, .nothingthere
; Put it away.
ld a, $1
2018-01-23 14:39:09 -08:00
ld [wBuffer5], a
ld a, [wBuffer1]
ld [wMenuSelection], a
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld hl, DecoText_PutAwayTheDeco
call MenuTextBoxBackup
xor a
ret
.nothingthere
ld hl, DecoText_NothingToPutAway
call MenuTextBoxBackup
xor a
ret
2018-06-24 07:09:41 -07:00
DecoAction_setupornament:
2015-11-17 12:54:03 -08:00
ld hl, UnknownText_0x26e41
call DecoAction_AskWhichSide
jr c, .cancel
call DecoAction_SetItUp_Ornament
jr c, .cancel
ld a, $1
2018-01-23 14:39:09 -08:00
ld [wBuffer5], a
2015-11-17 12:54:03 -08:00
jr DecoAction_FinishUp_Ornament
.cancel
xor a
ret
2018-06-24 07:09:41 -07:00
DecoAction_putawayornament:
2015-11-17 12:54:03 -08:00
ld hl, DecoText_WhichSide
call DecoAction_AskWhichSide
jr nc, .incave
xor a
ret
.incave
call DecoAction_PutItAway_Ornament
2018-06-24 07:09:41 -07:00
DecoAction_FinishUp_Ornament:
2015-11-17 12:54:03 -08:00
call QueryWhichSide
2017-12-09 16:41:03 -08:00
ld a, [wSelectedDecoration]
2015-11-17 12:54:03 -08:00
ld [hl], a
2017-12-09 16:41:03 -08:00
ld a, [wOtherDecoration]
2015-11-17 12:54:03 -08:00
ld [de], a
xor a
ret
2018-06-24 07:09:41 -07:00
DecoAction_SetItUp_Ornament:
2017-12-09 16:41:03 -08:00
ld a, [wSelectedDecoration]
2015-11-17 12:54:03 -08:00
and a
jr z, .nothingthere
ld b, a
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
cp b
jr z, .failed
ld a, b
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld hl, wStringBuffer4
2015-11-17 12:54:03 -08:00
call GetDecorationName
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2017-12-09 16:41:03 -08:00
ld [wSelectedDecoration], a
2015-11-17 12:54:03 -08:00
call .getwhichside
ld hl, DecoText_PutAwayAndSetUp
call MenuTextBoxBackup
xor a
ret
.nothingthere
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2017-12-09 16:41:03 -08:00
ld [wSelectedDecoration], a
2015-11-17 12:54:03 -08:00
call .getwhichside
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld hl, DecoText_SetUpTheDeco
call MenuTextBoxBackup
xor a
ret
.failed
ld hl, DecoText_AlreadySetUp
call MenuTextBoxBackup
scf
ret
2018-06-24 07:09:41 -07:00
.getwhichside
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-11-17 12:54:03 -08:00
ld b, a
2017-12-09 16:41:03 -08:00
ld a, [wOtherDecoration]
2015-11-17 12:54:03 -08:00
cp b
ret nz
xor a
2017-12-09 16:41:03 -08:00
ld [wOtherDecoration], a
2015-11-17 12:54:03 -08:00
ret
UnknownText_0x26e41:
2015-11-17 12:54:03 -08:00
; Which side do you want to put it on?
text_jump UnknownText_0x1bc48c
db "@"
2018-06-24 07:09:41 -07:00
DecoAction_PutItAway_Ornament:
2017-12-09 16:41:03 -08:00
ld a, [wSelectedDecoration]
2015-11-17 12:54:03 -08:00
and a
jr z, .nothingthere
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld a, $1
2018-01-23 14:39:09 -08:00
ld [wBuffer5], a
2015-11-17 12:54:03 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wSelectedDecoration], a
2015-11-17 12:54:03 -08:00
ld hl, DecoText_PutAwayTheDeco
call MenuTextBoxBackup
xor a
ret
.nothingthere
ld hl, DecoText_NothingToPutAway
call MenuTextBoxBackup
xor a
ret
DecoText_WhichSide:
2015-11-17 12:54:03 -08:00
; Which side do you want to put away?
text_jump UnknownText_0x1bc4b2
db "@"
2018-06-24 07:09:41 -07:00
DecoAction_AskWhichSide:
2015-11-17 12:54:03 -08:00
call MenuTextBox
ld hl, MenuHeader_0x26eab
2015-11-17 12:54:03 -08:00
call GetMenu2
call ExitMenu
call CopyMenuData
2015-11-17 12:54:03 -08:00
jr c, .nope
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-17 12:54:03 -08:00
cp 3
jr z, .nope
2018-01-23 14:39:09 -08:00
ld [wBuffer2], a
2015-11-17 12:54:03 -08:00
call QueryWhichSide
ld a, [hl]
2017-12-09 16:41:03 -08:00
ld [wSelectedDecoration], a
2015-11-17 12:54:03 -08:00
ld a, [de]
2017-12-09 16:41:03 -08:00
ld [wOtherDecoration], a
2015-11-17 12:54:03 -08:00
xor a
ret
.nope
scf
ret
2018-06-24 07:09:41 -07:00
QueryWhichSide:
ld hl, wDecoRightOrnament
ld de, wDecoLeftOrnament
2018-01-23 14:39:09 -08:00
ld a, [wBuffer2]
2015-11-17 12:54:03 -08:00
cp 1
ret z
push hl
ld h, d
ld l, e
pop de
ret
MenuHeader_0x26eab:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 13, 7
dw MenuData_0x26eb3
2015-11-17 12:54:03 -08:00
db 1 ; default option
MenuData_0x26eb3:
db STATICMENU_CURSOR ; flags
2015-11-17 12:54:03 -08:00
db 3 ; items
db "RIGHT SIDE@"
db "LEFT SIDE@"
db "CANCEL@"
DecoText_PutAwayTheDeco:
2015-11-17 12:54:03 -08:00
; Put away the @ .
text_jump UnknownText_0x1bc4d7
db "@"
DecoText_NothingToPutAway:
2015-11-17 12:54:03 -08:00
; There's nothing to put away.
text_jump UnknownText_0x1bc4ec
db "@"
DecoText_SetUpTheDeco:
2015-11-17 12:54:03 -08:00
; Set up the @ .
text_jump UnknownText_0x1bc509
db "@"
DecoText_PutAwayAndSetUp:
2015-11-17 12:54:03 -08:00
; Put away the @ and set up the @ .
text_jump UnknownText_0x1bc51c
db "@"
DecoText_AlreadySetUp:
2015-11-17 12:54:03 -08:00
; That's already set up.
text_jump UnknownText_0x1bc546
db "@"
2018-06-24 07:09:41 -07:00
GetDecorationName_c_de:
2015-11-17 12:54:03 -08:00
ld a, c
ld h, d
ld l, e
call GetDecorationName
ret
2018-06-24 07:09:41 -07:00
DecorationFlagAction_c:
2015-11-17 12:54:03 -08:00
ld a, c
jp DecorationFlagAction
2018-06-24 07:09:41 -07:00
GetDecorationName_c:
2015-11-17 12:54:03 -08:00
ld a, c
call GetDecorationID
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer1
2015-11-17 12:54:03 -08:00
push hl
call GetDecorationName
pop de
ret
2018-06-24 07:09:41 -07:00
SetSpecificDecorationFlag:
2015-11-17 12:54:03 -08:00
ld a, c
call GetDecorationID
ld b, SET_FLAG
call DecorationFlagAction
ret
2018-06-24 07:09:41 -07:00
GetDecorationID:
2015-11-17 12:54:03 -08:00
push hl
push de
ld e, a
ld d, 0
ld hl, DecorationIDs
add hl, de
ld a, [hl]
pop de
pop hl
ret
2018-06-24 07:09:41 -07:00
SetAllDecorationFlags:
2015-11-17 12:54:03 -08:00
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
2017-12-27 08:56:03 -08:00
INCLUDE "data/decorations/decorations.asm"
2015-11-17 12:54:03 -08:00
2018-06-24 07:09:41 -07:00
DescribeDecoration::
2015-11-17 12:54:03 -08:00
ld a, b
2018-01-11 22:40:20 -08:00
ld hl, .JumpTable
2015-11-17 12:54:03 -08:00
rst JumpTable
ret
2018-06-24 07:09:41 -07:00
.JumpTable:
2018-01-11 22:40:20 -08:00
; entries correspond to DECODESC_* constants
2015-11-17 12:54:03 -08:00
dw DecorationDesc_Poster
dw DecorationDesc_LeftOrnament
dw DecorationDesc_RightOrnament
dw DecorationDesc_GiantOrnament
dw DecorationDesc_Console
2018-06-24 07:09:41 -07:00
DecorationDesc_Poster:
ld a, [wDecoPoster]
2015-11-17 12:54:03 -08:00
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
2018-06-24 07:09:41 -07:00
DecorationDesc_PosterPointers:
2015-11-17 12:54:03 -08:00
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:
2015-12-09 15:25:44 -08:00
opentext
2015-11-17 12:54:03 -08:00
writetext .TownMapText
2015-11-25 07:16:29 -08:00
waitbutton
special OverworldTownMap
2015-11-25 07:16:29 -08:00
closetext
2015-11-17 12:54:03 -08:00
end
.TownMapText:
2015-11-17 12:54:03 -08:00
; It's the TOWN MAP.
text_jump UnknownText_0x1bc55d
db "@"
DecorationDesc_PikachuPoster:
2015-11-17 12:54:03 -08:00
jumptext .PikaPosterText
.PikaPosterText:
2015-11-17 12:54:03 -08:00
; It's a poster of a cute PIKACHU.
text_jump UnknownText_0x1bc570
db "@"
DecorationDesc_ClefairyPoster:
2015-11-17 12:54:03 -08:00
jumptext .ClefairyPosterText
.ClefairyPosterText:
2015-11-17 12:54:03 -08:00
; It's a poster of a cute CLEFAIRY.
text_jump UnknownText_0x1bc591
db "@"
DecorationDesc_JigglypuffPoster:
2015-11-17 12:54:03 -08:00
jumptext .JigglypuffPosterText
.JigglypuffPosterText:
2015-11-17 12:54:03 -08:00
; It's a poster of a cute JIGGLYPUFF.
text_jump UnknownText_0x1bc5b3
db "@"
2018-06-24 07:09:41 -07:00
DecorationDesc_NullPoster:
2015-11-17 12:54:03 -08:00
end
2018-06-24 07:09:41 -07:00
DecorationDesc_LeftOrnament:
ld a, [wDecoLeftOrnament]
2015-11-17 12:54:03 -08:00
jr DecorationDesc_OrnamentOrConsole
2018-06-24 07:09:41 -07:00
DecorationDesc_RightOrnament:
ld a, [wDecoRightOrnament]
2015-11-17 12:54:03 -08:00
jr DecorationDesc_OrnamentOrConsole
2018-06-24 07:09:41 -07:00
DecorationDesc_Console:
ld a, [wDecoConsole]
2015-11-17 12:54:03 -08:00
jr DecorationDesc_OrnamentOrConsole
2018-06-24 07:09:41 -07:00
DecorationDesc_OrnamentOrConsole:
2015-11-17 12:54:03 -08:00
ld c, a
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName_c_de
ld b, BANK(.OrnamentConsoleScript)
ld de, .OrnamentConsoleScript
ret
2018-06-24 07:09:41 -07:00
.OrnamentConsoleScript:
2015-11-17 12:54:03 -08:00
jumptext .OrnamentConsoleText
.OrnamentConsoleText:
2015-11-17 12:54:03 -08:00
; It's an adorable @ .
text_jump UnknownText_0x1bc5d7
db "@"
2018-06-24 07:09:41 -07:00
DecorationDesc_GiantOrnament:
2015-11-17 12:54:03 -08:00
ld b, BANK(.BigDollScript)
ld de, .BigDollScript
ret
2018-06-24 07:09:41 -07:00
.BigDollScript:
2015-11-17 12:54:03 -08:00
jumptext .BigDollText
.BigDollText:
2015-11-17 12:54:03 -08:00
; A giant doll! It's fluffy and cuddly.
text_jump UnknownText_0x1bc5ef
db "@"
2018-06-24 07:09:41 -07:00
ToggleMaptileDecorations:
2018-07-13 20:19:24 -07:00
; tile coordinates work the same way as for changeblock
lb de, 0, 4 ; bed coordinates
ld a, [wDecoBed]
2015-11-17 12:54:03 -08:00
call SetDecorationTile
2018-07-13 20:19:24 -07:00
lb de, 7, 4 ; plant coordinates
ld a, [wDecoPlant]
2015-11-17 12:54:03 -08:00
call SetDecorationTile
2018-07-13 20:19:24 -07:00
lb de, 6, 0 ; poster coordinates
ld a, [wDecoPoster]
2015-11-17 12:54:03 -08:00
call SetDecorationTile
call SetPosterVisibility
2018-07-13 20:19:24 -07:00
lb de, 0, 0 ; carpet top-left coordinates
2015-11-17 12:54:03 -08:00
call PadCoords_de
ld a, [wDecoCarpet]
2015-11-17 12:54:03 -08:00
and a
ret z
call _GetDecorationSprite
ld [hl], a
push af
2018-07-13 20:19:24 -07:00
lb de, 0, 2 ; carpet bottom-left coordinates
2015-11-17 12:54:03 -08:00
call PadCoords_de
pop af
inc a
2018-07-13 20:19:24 -07:00
ld [hli], a ; carpet bottom-left block
2015-11-17 12:54:03 -08:00
inc a
2018-07-13 20:19:24 -07:00
ld [hli], a ; carpet bottom-middle block
2015-11-17 12:54:03 -08:00
dec a
2018-07-13 20:19:24 -07:00
ld [hl], a ; carpet bottom-right block
2015-11-17 12:54:03 -08:00
ret
2018-06-24 07:09:41 -07:00
SetPosterVisibility:
2015-11-17 12:54:03 -08:00
ld b, SET_FLAG
ld a, [wDecoPoster]
2015-11-17 12:54:03 -08:00
and a
jr nz, .ok
ld b, RESET_FLAG
.ok
2018-01-22 16:10:09 -08:00
ld de, EVENT_PLAYERS_ROOM_POSTER
2015-11-17 12:54:03 -08:00
jp EventFlagAction
2018-06-24 07:09:41 -07:00
SetDecorationTile:
2015-11-17 12:54:03 -08:00
push af
call PadCoords_de
pop af
and a
ret z
call _GetDecorationSprite
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
ToggleDecorationsVisibility:
2018-01-22 16:10:09 -08:00
ld de, EVENT_PLAYERS_HOUSE_2F_CONSOLE
2018-01-23 14:39:09 -08:00
ld hl, wVariableSprites + SPRITE_CONSOLE - SPRITE_VARS
ld a, [wDecoConsole]
2015-11-17 12:54:03 -08:00
call ToggleDecorationVisibility
2018-01-22 16:10:09 -08:00
ld de, EVENT_PLAYERS_HOUSE_2F_DOLL_1
2018-01-23 14:39:09 -08:00
ld hl, wVariableSprites + SPRITE_DOLL_1 - SPRITE_VARS
ld a, [wDecoLeftOrnament]
2015-11-17 12:54:03 -08:00
call ToggleDecorationVisibility
2018-01-22 16:10:09 -08:00
ld de, EVENT_PLAYERS_HOUSE_2F_DOLL_2
2018-01-23 14:39:09 -08:00
ld hl, wVariableSprites + SPRITE_DOLL_2 - SPRITE_VARS
ld a, [wDecoRightOrnament]
2015-11-17 12:54:03 -08:00
call ToggleDecorationVisibility
2018-01-22 16:10:09 -08:00
ld de, EVENT_PLAYERS_HOUSE_2F_BIG_DOLL
2018-01-23 14:39:09 -08:00
ld hl, wVariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS
ld a, [wDecoBigDoll]
2015-11-17 12:54:03 -08:00
call ToggleDecorationVisibility
ret
2018-06-24 07:09:41 -07:00
ToggleDecorationVisibility:
2015-11-17 12:54:03 -08:00
and a
jr z, .hide
call _GetDecorationSprite
ld [hl], a
ld b, RESET_FLAG
jp EventFlagAction
.hide
ld b, SET_FLAG
jp EventFlagAction
2018-06-24 07:09:41 -07:00
_GetDecorationSprite:
2015-11-17 12:54:03 -08:00
ld c, a
push de
push hl
2017-12-24 09:47:30 -08:00
farcall GetDecorationSprite
2015-11-17 12:54:03 -08:00
pop hl
pop de
ld a, c
ret
2018-06-24 07:09:41 -07:00
PadCoords_de:
2018-07-13 20:19:24 -07:00
; 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