2018-06-24 07:09:41 -07:00
|
|
|
|
SelectQuantityToToss:
|
2018-01-23 13:08:43 -08:00
|
|
|
|
ld hl, TossItem_MenuHeader
|
|
|
|
|
call LoadMenuHeader
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call Toss_Sell_Loop
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SelectQuantityToBuy:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall GetItemPrice
|
2018-06-24 07:09:41 -07:00
|
|
|
|
RooftopSale_SelectQuantityToBuy:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld a, d
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld [wBuySellItemPrice + 0], a
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld a, e
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld [wBuySellItemPrice + 1], a
|
2018-01-23 13:08:43 -08:00
|
|
|
|
ld hl, BuyItem_MenuHeader
|
|
|
|
|
call LoadMenuHeader
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call Toss_Sell_Loop
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SelectQuantityToSell:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall GetItemPrice
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld a, d
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld [wBuySellItemPrice + 0], a
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld a, e
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld [wBuySellItemPrice + 1], a
|
2018-01-23 13:08:43 -08:00
|
|
|
|
ld hl, SellItem_MenuHeader
|
|
|
|
|
call LoadMenuHeader
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call Toss_Sell_Loop
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Toss_Sell_Loop:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld a, 1
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wItemQuantityChange], a
|
2015-12-13 14:11:58 -08:00
|
|
|
|
.loop
|
|
|
|
|
call BuySellToss_UpdateQuantityDisplay ; update display
|
|
|
|
|
call BuySellToss_InterpretJoypad ; joy action
|
|
|
|
|
jr nc, .loop
|
|
|
|
|
cp -1
|
|
|
|
|
jr nz, .nope ; pressed B
|
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.nope
|
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BuySellToss_InterpretJoypad:
|
2016-05-10 09:31:49 -07:00
|
|
|
|
call JoyTextDelay_ForcehJoyDown ; get joypad
|
2015-12-13 14:11:58 -08:00
|
|
|
|
bit B_BUTTON_F, c
|
|
|
|
|
jr nz, .b
|
|
|
|
|
bit A_BUTTON_F, c
|
|
|
|
|
jr nz, .a
|
|
|
|
|
bit D_DOWN_F, c
|
|
|
|
|
jr nz, .down
|
|
|
|
|
bit D_UP_F, c
|
|
|
|
|
jr nz, .up
|
|
|
|
|
bit D_LEFT_F, c
|
|
|
|
|
jr nz, .left
|
|
|
|
|
bit D_RIGHT_F, c
|
|
|
|
|
jr nz, .right
|
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.b
|
|
|
|
|
ld a, -1
|
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.a
|
|
|
|
|
ld a, 0
|
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.down
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld hl, wItemQuantityChange
|
2015-12-13 14:11:58 -08:00
|
|
|
|
dec [hl]
|
|
|
|
|
jr nz, .finish_down
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemQuantity]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
|
|
.finish_down
|
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.up
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld hl, wItemQuantityChange
|
2015-12-13 14:11:58 -08:00
|
|
|
|
inc [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemQuantity]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
cp [hl]
|
|
|
|
|
jr nc, .finish_up
|
|
|
|
|
ld [hl], 1
|
|
|
|
|
|
|
|
|
|
.finish_up
|
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.left
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemQuantityChange]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
sub 10
|
|
|
|
|
jr c, .load_1
|
|
|
|
|
jr z, .load_1
|
|
|
|
|
jr .finish_left
|
|
|
|
|
|
|
|
|
|
.load_1
|
|
|
|
|
ld a, 1
|
|
|
|
|
|
|
|
|
|
.finish_left
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wItemQuantityChange], a
|
2015-12-13 14:11:58 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.right
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemQuantityChange]
|
2015-12-13 17:33:56 -08:00
|
|
|
|
add 10
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld b, a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemQuantity]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
cp b
|
|
|
|
|
jr nc, .finish_right
|
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
|
|
.finish_right
|
|
|
|
|
ld a, b
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wItemQuantityChange], a
|
2015-12-13 14:11:58 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BuySellToss_UpdateQuantityDisplay:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call MenuBox
|
|
|
|
|
call MenuBoxCoord2Tile
|
|
|
|
|
ld de, SCREEN_WIDTH + 1
|
|
|
|
|
add hl, de
|
|
|
|
|
ld [hl], "×"
|
|
|
|
|
inc hl
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld de, wItemQuantityChange
|
2015-12-13 14:11:58 -08:00
|
|
|
|
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
|
|
|
|
|
call PrintNum
|
2018-01-23 13:08:43 -08:00
|
|
|
|
ld a, [wMenuDataPointer]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld e, a
|
2018-01-23 13:08:43 -08:00
|
|
|
|
ld a, [wMenuDataPointer + 1]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld d, a
|
|
|
|
|
ld a, [wMenuDataBank]
|
|
|
|
|
call FarCall_de
|
|
|
|
|
ret
|
|
|
|
|
|
2020-10-06 15:09:33 -07:00
|
|
|
|
NoPriceToDisplay:
|
|
|
|
|
; Does nothing.
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DisplayPurchasePrice:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call BuySell_MultiplyPrice
|
|
|
|
|
call BuySell_DisplaySubtotal
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DisplaySellingPrice:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call BuySell_MultiplyPrice
|
|
|
|
|
call Sell_HalvePrice
|
|
|
|
|
call BuySell_DisplaySubtotal
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BuySell_MultiplyPrice:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 0], a
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld a, [wBuySellItemPrice + 0]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 1], a
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld a, [wBuySellItemPrice + 1]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemQuantityChange]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2015-12-13 14:11:58 -08:00
|
|
|
|
push hl
|
|
|
|
|
call Multiply
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Sell_HalvePrice:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
push hl
|
|
|
|
|
ld hl, hProduct + 1
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
rra
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
rra
|
|
|
|
|
ld [hl], a
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BuySell_DisplaySubtotal:
|
2015-12-13 14:11:58 -08:00
|
|
|
|
push hl
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld hl, hCoinsTemp
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 1]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld [hli], a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 2]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld [hli], a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 3]
|
2015-12-13 14:11:58 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
pop hl
|
|
|
|
|
inc hl
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld de, hCoinsTemp
|
|
|
|
|
lb bc, PRINTNUM_COINS | 3, 6
|
2015-12-13 14:11:58 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
call WaitBGMap
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
|
TossItem_MenuHeader:
|
2018-01-14 02:59:56 -08:00
|
|
|
|
db MENU_BACKUP_TILES ; flags
|
2018-01-13 13:38:14 -08:00
|
|
|
|
menu_coords 15, 9, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
|
2020-10-06 15:09:33 -07:00
|
|
|
|
dw NoPriceToDisplay
|
2015-12-13 14:11:58 -08:00
|
|
|
|
db 0 ; default option
|
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
|
BuyItem_MenuHeader:
|
2018-01-14 02:59:56 -08:00
|
|
|
|
db MENU_BACKUP_TILES ; flags
|
2018-01-13 13:38:14 -08:00
|
|
|
|
menu_coords 7, 15, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
|
2015-12-13 14:11:58 -08:00
|
|
|
|
dw DisplayPurchasePrice
|
|
|
|
|
db -1 ; default option
|
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
|
SellItem_MenuHeader:
|
2018-01-14 02:59:56 -08:00
|
|
|
|
db MENU_BACKUP_TILES ; flags
|
2018-01-13 13:38:14 -08:00
|
|
|
|
menu_coords 7, 15, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
|
2015-12-13 14:11:58 -08:00
|
|
|
|
dw DisplaySellingPrice
|
|
|
|
|
db 0 ; default option
|