Skip to content

Commit

Permalink
Added Bait Pocket
Browse files Browse the repository at this point in the history
- Bait Pocket will store Bait items for fishing
- BUG: TM/HM Pocket scrolls right to Key Items but should scroll to Items. TODO
  • Loading branch information
OrchiidDev committed Sep 2, 2024
1 parent 4f28709 commit b89ad0b
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 9 deletions.
3 changes: 3 additions & 0 deletions constants/item_data_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DEF ITEMATTR_STRUCT_LENGTH EQU _RS
const KEY_ITEM ; 2
const BALL ; 3
const TM_HM ; 4
const BAIT_ITEM; 5
DEF NUM_ITEM_TYPES EQU const_value - 1

; item menu types
Expand All @@ -43,12 +44,14 @@ DEF CANT_TOSS EQU 1 << CANT_TOSS_F
const BALL_POCKET ; 1
const KEY_ITEM_POCKET ; 2
const TM_HM_POCKET ; 3
const BAIT_POCKET ; 4
DEF NUM_POCKETS EQU const_value

DEF MAX_ITEMS EQU 20
DEF MAX_BALLS EQU 12
DEF MAX_KEY_ITEMS EQU 25
DEF MAX_PC_ITEMS EQU 50
DEF MAX_BAIT EQU 10

DEF MAX_ITEM_STACK EQU 99

Expand Down
2 changes: 1 addition & 1 deletion data/items/attributes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ItemAttributes:
; EXP_SHARE
item_attribute 3000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; OLD_ROD
item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE
item_attribute 0, HELD_NONE, 0, CANT_TOSS, BAIT_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE
; GOOD_ROD
item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE
; SILVER_LEAF
Expand Down
2 changes: 2 additions & 0 deletions data/items/pocket_names.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ ItemPocketNames:
dw .Key
dw .Ball
dw .TM
dw .Bait
assert_table_length NUM_ITEM_TYPES

.Item: db "ITEM POCKET@"
.Key: db "KEY POCKET@"
.Ball: db "BALL POCKET@"
.TM: db "TM POCKET@"
.Bait: db "BAIT POCKET@"
24 changes: 24 additions & 0 deletions engine/items/items.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ _ReceiveItem::
dw .KeyItem
dw .Ball
dw .TMHM
dw .Bait

.Item:
ld h, d
Expand All @@ -31,6 +32,10 @@ _ReceiveItem::
ld hl, wNumBalls
jp PutItemInPocket

.Bait:
ld hl, wNumBait
jp PutItemInPocket

.TMHM:
ld h, d
ld l, e
Expand All @@ -57,11 +62,16 @@ _TossItem::
dw .KeyItem
dw .Ball
dw .TMHM
dw .Bait

.Ball:
ld hl, wNumBalls
jp RemoveItemFromPocket

.Bait:
ld hl, wNumBait
jp RemoveItemFromPocket

.TMHM:
ld h, d
ld l, e
Expand Down Expand Up @@ -100,11 +110,16 @@ _CheckItem::
dw .KeyItem
dw .Ball
dw .TMHM
dw .Bait

.Ball:
ld hl, wNumBalls
jp CheckTheItem

.Bait:
ld hl, wNumBait
jp CheckTheItem

.TMHM:
ld h, d
ld l, e
Expand Down Expand Up @@ -152,6 +167,15 @@ GetPocketCapacity:
ret z

.not_pc
ld c, MAX_BAIT
ld a, e
cp LOW(wNumBait)
jr nz, .not_bait
ld a, d
cp HIGH(wNumBait)
ret z

.not_bait
ld c, MAX_BALLS
ret

Expand Down
153 changes: 147 additions & 6 deletions engine/items/pack.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
const PACKSTATE_KEYITEMSPOCKETMENU ; 6
const PACKSTATE_INITTMHMPOCKET ; 7
const PACKSTATE_TMHMPOCKETMENU ; 8
const PACKSTATE_INITBAITPOCKET
const PACKSTATE_BAITPOCKETMENU
const PACKSTATE_QUITNOSCRIPT ; 9
const PACKSTATE_QUITRUNSCRIPT ; 10

Expand Down Expand Up @@ -49,6 +51,8 @@ Pack:
dw .KeyItemsPocketMenu ; 6
dw .InitTMHMPocket ; 7
dw .TMHMPocketMenu ; 8
dw .InitBaitPocket
dw .BaitPocketMenu
dw Pack_QuitNoScript ; 9
dw Pack_QuitRunScript ; 10

Expand Down Expand Up @@ -110,7 +114,7 @@ Pack:
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
ld b, PACKSTATE_INITBALLSPOCKET ; left
ld b, PACKSTATE_INITBAITPOCKET ; left
ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad
ret c
Expand All @@ -131,7 +135,7 @@ Pack:
.TMHMPocketMenu:
farcall TMHMPocket
ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
ld c, PACKSTATE_INITITEMSPOCKET ; right
ld c, PACKSTATE_INITBAITPOCKET ; right
call Pack_InterpretJoypad
ret c
farcall _CheckTossableItem
Expand Down Expand Up @@ -233,6 +237,34 @@ Pack:
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
ld b, PACKSTATE_INITITEMSPOCKET ; left
ld c, PACKSTATE_INITBAITPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
ret

.InitBaitPocket:
ld a, BAIT_POCKET
ld [wCurPocket], a
call ClearPocketList
call DrawPocketName
call WaitBGMap_DrawPackGFX
call Pack_JumptableNext
ret

.BaitPocketMenu:
ld hl, BaitPocketMenuHeader
call CopyMenuHeader
ld a, [wBaitPocketCursor]
ld [wMenuCursorPosition], a
ld a, [wBaitPocketScrollPosition]
ld [wMenuScrollPosition], a
call ScrollingMenu
ld a, [wMenuScrollPosition]
ld [wBaitPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBaitPocketCursor], a
ld b, PACKSTATE_INITBALLSPOCKET ; left
ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
Expand Down Expand Up @@ -661,6 +693,8 @@ BattlePack:
dw .KeyItemsPocketMenu ; 6
dw .InitTMHMPocket ; 7
dw .TMHMPocketMenu ; 8
dw .InitBaitPocket
dw .BaitPocketMenu
dw Pack_QuitNoScript ; 9
dw Pack_QuitRunScript ; 10

Expand Down Expand Up @@ -722,7 +756,7 @@ BattlePack:
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
ld b, PACKSTATE_INITBALLSPOCKET ; left
ld b, PACKSTATE_INITBAITPOCKET ; left
ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad
ret c
Expand Down Expand Up @@ -774,6 +808,34 @@ BattlePack:
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
ld b, PACKSTATE_INITITEMSPOCKET ; left
ld c, PACKSTATE_INITBAITPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
ret

.InitBaitPocket:
ld a, BAIT_POCKET
ld [wCurPocket], a
call ClearPocketList
call DrawPocketName
call WaitBGMap_DrawPackGFX
call Pack_JumptableNext
ret

.BaitPocketMenu:
ld hl, BaitPocketMenuHeader
call CopyMenuHeader
ld a, [wBaitPocketCursor]
ld [wMenuCursorPosition], a
ld a, [wBaitPocketScrollPosition]
ld [wMenuScrollPosition], a
call ScrollingMenu
ld a, [wMenuScrollPosition]
ld [wBaitPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBaitPocketCursor], a
ld b, PACKSTATE_INITBALLSPOCKET ; left
ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
Expand Down Expand Up @@ -945,6 +1007,7 @@ DepositSellPack:
; entries correspond to *_POCKET constants
dw .ItemsPocket
dw .BallsPocket
dw .BaitPocket
dw .KeyItemsPocket
dw .TMHMPocket

Expand Down Expand Up @@ -1005,6 +1068,22 @@ DepositSellPack:
ld [wBallsPocketCursor], a
ret

.BaitPocket:
ld a, BAIT_POCKET
call InitPocket
ld hl, PC_Mart_BaitPocketMenuHeader
call CopyMenuHeader
ld a, [wBaitPocketCursor]
ld [wMenuCursorPosition], a
ld a, [wBaitPocketScrollPosition]
ld [wMenuScrollPosition], a
call ScrollingMenu
ld a, [wMenuScrollPosition]
ld [wBaitPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBaitPocketCursor], a
ret

InitPocket:
ld [wCurPocket], a
call ClearPocketList
Expand Down Expand Up @@ -1044,7 +1123,10 @@ DepositSellTutorial_InterpretJoypad:
.d_left
ld a, [wJumptableIndex]
dec a
maskbits NUM_POCKETS
cp -1
jr nz, .left_ok
ld a, NUM_POCKETS - 1
.left_ok
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
Expand All @@ -1056,7 +1138,10 @@ DepositSellTutorial_InterpretJoypad:
.d_right
ld a, [wJumptableIndex]
inc a
maskbits NUM_POCKETS
cp NUM_POCKETS
jr nz, .right_ok
xor a
.right_ok
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
Expand Down Expand Up @@ -1091,11 +1176,12 @@ TutorialPack:
dw .Balls
dw .KeyItems
dw .TMHM
dw .Bait

.Items:
xor a ; ITEM_POCKET
ld hl, .ItemsMenuHeader
jr .DisplayPocket
jp .DisplayPocket

.ItemsMenuHeader:
db MENU_BACKUP_TILES ; flags
Expand All @@ -1112,6 +1198,26 @@ TutorialPack:
dba PlaceMenuItemQuantity
dba UpdateItemDescription

.Bait:
ld a, BAIT_POCKET
ld hl, .BaitMenuHeader
jr .DisplayPocket

.BaitMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .BaitMenuData
db 1 ; default option

.BaitMenuData:
db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, wDudeNumBait
dba PlaceMenuItemName
dba PlaceMenuItemQuantity
dba UpdateItemDescription

.KeyItems:
ld a, KEY_ITEM_POCKET
ld hl, .KeyItemsMenuHeader
Expand Down Expand Up @@ -1242,6 +1348,7 @@ PackGFXPointers:
dw PackGFX + (15 tiles) * 3 ; BALL_POCKET
dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET
dw PackGFX + (15 tiles) * 4 ; BAIT_POCKET

Pack_InterpretJoypad:
ld hl, wMenuJoypad
Expand Down Expand Up @@ -1415,6 +1522,10 @@ DrawPocketName:
.tilemap: ; 5x12
; the 5x3 pieces correspond to *_POCKET constants
INCBIN "gfx/pack/pack_menu.tilemap"
; BAIT_POCKET
db $00, $04, $04, $04, $01 ; top border
db $1a, $1b, $1c, $1d, $1e ; Bait
db $02, $05, $05, $05, $03 ; bottom border

Pack_GetItemName:
ld a, [wCurItem]
Expand Down Expand Up @@ -1474,6 +1585,36 @@ PC_Mart_ItemsPocketMenuHeader:
dba PlaceMenuItemQuantity
dba UpdateItemDescription

BaitPocketMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData
db 1 ; default option

.MenuData:
db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db SCROLLINGMENU_ITEMS_QUANTITY ; item format
dbw 0, wNumBait
dba PlaceMenuItemName
dba PlaceMenuItemQuantity
dba UpdateItemDescription

PC_Mart_BaitPocketMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData
db 1 ; default option

.MenuData:
db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
db 5, 8 ; rows, columns
db SCROLLINGMENU_ITEMS_QUANTITY ; item format
dbw 0, wNumBait
dba PlaceMenuItemName
dba PlaceMenuItemQuantity
dba UpdateItemDescription

KeyItemsPocketMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
Expand Down
1 change: 1 addition & 0 deletions engine/items/pack_kris.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ PackFGFXPointers:
dw PackFGFX + (15 tiles) * 3 ; BALL_POCKET
dw PackFGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
dw PackFGFX + (15 tiles) * 2 ; TM_HM_POCKET
dw PackFGFX + (15 tiles) * 4 ; BAIT_POCKET

PackFGFX:
INCBIN "gfx/pack/pack_f.2bpp"
Loading

0 comments on commit b89ad0b

Please sign in to comment.