pokecrystal-board/engine/overworld/decorations.asm

1190 lines
20 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
2020-11-03 16:53:07 -08:00
xor a ; FALSE
ld [wChangedDecorations], a
ld a, $1 ; bed
ld [wCurDecorationCategory], a
2015-11-17 12:54:03 -08:00
.top_loop
2020-11-03 16:53:07 -08:00
ld a, [wCurDecorationCategory]
ld [wMenuCursorPosition], a
2015-11-17 12:54:03 -08:00
call .FindCategoriesWithOwnedDecos
call DoNthMenu
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2020-11-03 16:53:07 -08:00
ld [wCurDecorationCategory], a
2015-11-17 12:54:03 -08:00
jr c, .exit_menu
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld hl, .category_pointers
2015-11-17 12:54:03 -08:00
call MenuJumptable
jr nc, .top_loop
.exit_menu
call ExitMenu
pop af
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
2020-11-03 16:53:07 -08:00
ld a, [wChangedDecorations]
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 wNumOwnedDecoCategories
2015-11-17 12:54:03 -08:00
dw PlaceNthMenuStrings
dw .category_pointers
.category_pointers:
table_width 2 + 2, _PlayerDecorationMenu.category_pointers
dw DecoBedMenu, .bed
dw DecoCarpetMenu, .carpet
dw DecoPlantMenu, .plant
dw DecoPosterMenu, .poster
dw DecoConsoleMenu, .game
2015-11-17 12:54:03 -08:00
dw DecoOrnamentMenu, .ornament
dw DecoBigDollMenu, .big_doll
dw DecoExitMenu, .exit
assert_table_length NUM_DECO_CATEGORIES + 1
.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@"
2015-11-17 12:54:03 -08:00
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
2020-11-03 16:53:07 -08:00
call .FindOwnedDecos
2015-11-17 12:54:03 -08:00
ld a, 7
call .AppendToStringBuffer2
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer2
ld de, wDecoNameBuffer
2015-11-17 12:54:03 -08:00
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
2020-11-03 16:53:07 -08:00
.FindOwnedDecos:
ld hl, .owned_pointers
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
.owned_pointers:
table_width 3, _PlayerDecorationMenu.owned_pointers
dwb FindOwnedBeds, 0 ; bed
dwb FindOwnedCarpets, 1 ; carpet
dwb FindOwnedPlants, 2 ; plant
dwb FindOwnedPosters, 3 ; poster
dwb FindOwnedConsoles, 4 ; game console
2015-11-17 12:54:03 -08:00
dwb FindOwnedOrnaments, 5 ; ornament
dwb FindOwnedBigDolls, 6 ; big doll
assert_table_length NUM_DECO_CATEGORIES
2015-11-17 12:54:03 -08:00
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, wNumOwnedDecoCategories
2015-11-17 12:54:03 -08:00
ld [hli], a
assert wNumOwnedDecoCategories + 1 == wOwnedDecoCategories
2015-11-17 12:54:03 -08:00
ld a, -1
ld bc, 16
2015-11-17 12:54:03 -08:00
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:
ld hl, wNumOwnedDecoCategories
2015-11-17 12:54:03 -08:00
inc [hl]
assert wNumOwnedDecoCategories + 1 == wOwnedDecoCategories
2015-11-17 12:54:03 -08:00
ld e, [hl]
ld d, 0
2015-11-17 12:54:03 -08:00
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, [wNumOwnedDecoCategories]
2015-11-17 12:54:03 -08:00
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
.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
.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
.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
.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
.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
.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
.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:
ld a, [wNumOwnedDecoCategories]
2015-11-17 12:54:03 -08:00
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, wNumOwnedDecoCategories
2015-11-17 12:54:03 -08:00
ld e, [hl]
dec [hl]
assert wNumOwnedDecoCategories + 1 == wOwnedDecoCategories
2015-11-17 12:54:03 -08:00
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
ldh [hBGMapMode], a
2015-11-17 12:54:03 -08:00
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, .NothingToChooseText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
ret
.NothingToChooseText:
text_far _NothingToChooseText
text_end
2015-11-17 12:54:03 -08:00
.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 wDecoNameBuffer
2015-11-17 12:54:03 -08:00
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 SCROLLINGMENU_ITEMS_NORMAL ; item format
dbw 0, wNumOwnedDecoCategories
2015-11-17 12:54:03 -08:00
dba DecorationMenuFunction
dbw 0, NULL
dbw 0, NULL
2015-11-17 12:54:03 -08:00
2018-06-24 07:09:41 -07:00
GetDecorationData:
2015-11-17 12:54:03 -08:00
ld hl, DecorationAttributes
ld bc, DECOATTR_STRUCT_LENGTH
2015-11-17 12:54:03 -08:00
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, DECOATTR_ACTION
2015-11-17 12:54:03 -08:00
add hl, de
ld a, [hl]
ld hl, .DecoActions
rst JumpTable
ret
2018-06-24 07:09:41 -07:00
.DecoActions:
table_width 2, DoDecorationAction2.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
assert_table_length NUM_DECO_ACTIONS + 1
2015-11-17 12:54:03 -08:00
2018-06-24 07:09:41 -07:00
GetDecorationFlag:
2015-11-17 12:54:03 -08:00
call GetDecorationData
ld de, DECOATTR_EVENT_FLAG
2015-11-17 12:54:03 -08:00
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, DECOATTR_SPRITE
2015-11-17 12:54:03 -08:00
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:
ld a, [hli] ; DECOATTR_TYPE
ld e, [hl] ; DECOATTR_NAME
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:
table_width 2, GetDecoName.NameFunctions
2015-11-17 12:54:03 -08:00
dw .invalid
dw .plant
dw .bed
dw .carpet
dw .poster
dw .doll
dw .bigdoll
assert_table_length NUM_DECO_TYPES + 1
2015-11-17 12:54:03 -08:00
.invalid:
2015-11-17 12:54:03 -08:00
ret
.plant:
2015-11-17 12:54:03 -08:00
ld a, e
jr .getdeconame
.bed:
2015-11-17 12:54:03 -08:00
call .plant
ld a, _BED
jr .getdeconame
.carpet:
2015-11-17 12:54:03 -08:00
call .plant
ld a, _CARPET
jr .getdeconame
.poster:
2015-11-17 12:54:03 -08:00
ld a, e
call .getpokename
ld a, _POSTER
jr .getdeconame
.doll:
2015-11-17 12:54:03 -08:00
ld a, e
call .getpokename
ld a, _DOLL
jr .getdeconame
.bigdoll:
2015-11-17 12:54:03 -08:00
push de
ld a, BIG_
call .getdeconame
pop de
ld a, e
jr .getpokename
.unused: ; unreferenced
2015-11-17 12:54:03 -08:00
push de
call .getdeconame
pop de
ld a, e
jr .getdeconame
.getpokename:
2015-11-17 12:54:03 -08:00
push bc
ld [wNamedObjectIndex], a
2015-11-17 12:54:03 -08:00
call GetPokemonName
pop bc
jr .copy
.getdeconame:
2015-11-17 12:54:03 -08:00
call ._getdeconame
jr .copy
._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
.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]
2020-11-03 16:53:07 -08:00
ld [wCurDecoration], a
2015-11-17 12:54:03 -08:00
push hl
call DecoAction_SetItUp
jr c, .failed
2020-11-03 16:53:07 -08:00
ld a, TRUE
ld [wChangedDecorations], 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
2020-11-03 16:53:07 -08:00
ld a, [wCurDecoration]
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
2020-11-03 16:53:07 -08:00
ld a, [wCurDecoration]
2018-01-23 14:39:09 -08:00
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld hl, PutAwayAndSetUpText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
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, SetUpTheDecoText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
xor a
ret
.alreadythere
ld hl, AlreadySetUpText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
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]
2020-11-03 16:53:07 -08:00
ld [wCurDecoration], a
2015-11-17 12:54:03 -08:00
xor a
ld [hl], a
2020-11-03 16:53:07 -08:00
ld a, [wCurDecoration]
2015-11-17 12:54:03 -08:00
and a
jr z, .nothingthere
; Put it away.
2020-11-03 16:53:07 -08:00
ld a, TRUE
ld [wChangedDecorations], a
ld a, [wCurDecoration]
2018-01-23 14:39:09 -08:00
ld [wMenuSelection], a
ld hl, wStringBuffer3
2015-11-17 12:54:03 -08:00
call GetDecorationName
ld hl, PutAwayTheDecoText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
xor a
ret
.nothingthere
ld hl, NothingToPutAwayText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
xor a
ret
2018-06-24 07:09:41 -07:00
DecoAction_setupornament:
ld hl, WhichSidePutOnText
2015-11-17 12:54:03 -08:00
call DecoAction_AskWhichSide
jr c, .cancel
call DecoAction_SetItUp_Ornament
jr c, .cancel
2020-11-03 16:53:07 -08:00
ld a, TRUE
ld [wChangedDecorations], 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:
ld hl, WhichSidePutAwayText
2015-11-17 12:54:03 -08:00
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, PutAwayAndSetUpText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
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, SetUpTheDecoText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
xor a
ret
.failed
ld hl, AlreadySetUpText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
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
WhichSidePutOnText:
text_far _WhichSidePutOnText
text_end
2015-11-17 12:54:03 -08:00
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
2020-11-03 16:53:07 -08:00
ld a, TRUE
ld [wChangedDecorations], a
2015-11-17 12:54:03 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wSelectedDecoration], a
ld hl, PutAwayTheDecoText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
xor a
ret
.nothingthere
ld hl, NothingToPutAwayText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-17 12:54:03 -08:00
xor a
ret
WhichSidePutAwayText:
text_far _WhichSidePutAwayText
text_end
2015-11-17 12:54:03 -08:00
2018-06-24 07:09:41 -07:00
DecoAction_AskWhichSide:
2019-04-08 05:15:10 -07:00
call MenuTextbox
2020-10-04 16:43:28 -07:00
ld hl, DecoSideMenuHeader
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]
2020-11-03 16:53:07 -08:00
cp 3 ; cancel
2015-11-17 12:54:03 -08:00
jr z, .nope
2020-11-03 16:53:07 -08:00
ld [wSelectedDecorationSide], 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
2020-11-03 16:53:07 -08:00
ld a, [wSelectedDecorationSide]
cp 1 ; right side
2015-11-17 12:54:03 -08:00
ret z
2020-11-03 16:53:07 -08:00
; left side, swap hl and de
2015-11-17 12:54:03 -08:00
push hl
ld h, d
ld l, e
pop de
ret
2020-10-04 16:43:28 -07:00
DecoSideMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 13, 7
2020-10-04 16:43:28 -07:00
dw .MenuData
2015-11-17 12:54:03 -08:00
db 1 ; default option
2020-10-04 16:43:28 -07:00
.MenuData:
db STATICMENU_CURSOR ; flags
2015-11-17 12:54:03 -08:00
db 3 ; items
db "RIGHT SIDE@"
db "LEFT SIDE@"
db "CANCEL@"
PutAwayTheDecoText:
text_far _PutAwayTheDecoText
text_end
2015-11-17 12:54:03 -08:00
NothingToPutAwayText:
text_far _NothingToPutAwayText
text_end
2015-11-17 12:54:03 -08:00
SetUpTheDecoText:
text_far _SetUpTheDecoText
text_end
2015-11-17 12:54:03 -08:00
PutAwayAndSetUpText:
text_far _PutAwayAndSetUpText
text_end
2015-11-17 12:54:03 -08:00
AlreadySetUpText:
text_far _AlreadySetUpText
text_end
2015-11-17 12:54:03 -08:00
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
SetAllDecorationFlags: ; unreferenced
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
ld hl, .Jumptable
2015-11-17 12:54:03 -08:00
rst JumpTable
ret
.Jumptable:
2018-01-11 22:40:20 -08:00
; entries correspond to DECODESC_* constants
table_width 2, DescribeDecoration.Jumptable
2015-11-17 12:54:03 -08:00
dw DecorationDesc_Poster
dw DecorationDesc_LeftOrnament
dw DecorationDesc_RightOrnament
dw DecorationDesc_GiantOrnament
dw DecorationDesc_Console
assert_table_length NUM_DECODESCS
2015-11-17 12:54:03 -08:00
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
writetext .LookTownMapText
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
.LookTownMapText:
text_far _LookTownMapText
text_end
2015-11-17 12:54:03 -08:00
DecorationDesc_PikachuPoster:
jumptext .LookPikachuPosterText
2015-11-17 12:54:03 -08:00
.LookPikachuPosterText:
text_far _LookPikachuPosterText
text_end
2015-11-17 12:54:03 -08:00
DecorationDesc_ClefairyPoster:
jumptext .LookClefairyPosterText
2015-11-17 12:54:03 -08:00
.LookClefairyPosterText:
text_far _LookClefairyPosterText
text_end
2015-11-17 12:54:03 -08:00
DecorationDesc_JigglypuffPoster:
jumptext .LookJigglypuffPosterText
2015-11-17 12:54:03 -08:00
.LookJigglypuffPosterText:
text_far _LookJigglypuffPosterText
text_end
2015-11-17 12:54:03 -08:00
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:
jumptext .LookAdorableDecoText
2015-11-17 12:54:03 -08:00
.LookAdorableDecoText:
text_far _LookAdorableDecoText
text_end
2015-11-17 12:54:03 -08:00
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:
jumptext .LookGiantDecoText
2015-11-17 12:54:03 -08:00
.LookGiantDecoText:
text_far _LookGiantDecoText
text_end
2015-11-17 12:54:03 -08:00
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