Extend profiles from 280 to 312 bytes with legacy compatibility. Keep tower relics run-local and share the profile bankroll.
452 lines
11 KiB
PHP
452 lines
11 KiB
PHP
BeginMerchant3D PROC
|
||
call LoadArrivalAssets3D
|
||
mov engineMode, MODE_SHOP
|
||
mov merchantTime3D, 0
|
||
mov merchantReaction3D, 1280
|
||
mov merchantMessage3D, 0
|
||
mov merchantTab3D, 1
|
||
mov artifactBuyArmed3D,0
|
||
mov merchantCharmSelected3D, 0
|
||
mov eax, selectedBack3D
|
||
cmp eax, 12
|
||
jbe @F
|
||
xor eax, eax
|
||
@@:
|
||
mov merchantSelected3D, eax
|
||
mov merchantPreviousFocus3D, eax
|
||
call ClearKeys3D
|
||
ret
|
||
BeginMerchant3D ENDP
|
||
|
||
BuyMerchantBack3D PROC uses ebx style:DWORD
|
||
mov ebx, style
|
||
cmp ebx, 12
|
||
ja merchant_purchase_done
|
||
bt ownedBacks3D, ebx
|
||
jc merchant_equip
|
||
mov eax, merchantPrices3D[ebx*4]
|
||
cmp bankroll, eax
|
||
jb merchant_purchase_poor
|
||
sub bankroll, eax
|
||
bts ownedBacks3D, ebx
|
||
; Keep the existing shopper achievement bit without opening a console popup.
|
||
cmp nativeProfileActive3D, 0
|
||
je merchant_equip
|
||
or achievements, 10h
|
||
merchant_equip:
|
||
mov selectedBack3D, ebx
|
||
mov merchantMessage3D, 1
|
||
mov merchantReaction3D, 0
|
||
mov merchantReactionKind3D, 2
|
||
call SaveProgress3D
|
||
invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1
|
||
ret
|
||
merchant_purchase_poor:
|
||
mov merchantMessage3D, 2
|
||
mov merchantReaction3D, 0
|
||
mov merchantReactionKind3D, 1
|
||
merchant_purchase_done:
|
||
ret
|
||
BuyMerchantBack3D ENDP
|
||
|
||
BuyMerchantCharm3D PROC uses ebx esi charmIndex:DWORD
|
||
mov ebx,charmIndex
|
||
cmp ebx,CHARM_COUNT
|
||
jae charm_purchase_done
|
||
lea esi,charmCloverUses
|
||
mov eax,[esi+ebx*4]
|
||
add eax,charmUsesPack3D[ebx*4]
|
||
cmp eax,CHARM_MAX_USES
|
||
ja charm_purchase_limit
|
||
mov eax,charmPrices3D[ebx*4]
|
||
cmp bankroll,eax
|
||
jb charm_purchase_poor
|
||
sub bankroll,eax
|
||
mov eax,charmUsesPack3D[ebx*4]
|
||
add [esi+ebx*4],eax
|
||
mov merchantMessage3D,1
|
||
call SaveProgress3D
|
||
invoke PlayCasinoSound3D,OFFSET soundCoin,0,1
|
||
jmp charm_purchase_done
|
||
charm_purchase_limit:
|
||
mov merchantMessage3D,3
|
||
ret
|
||
charm_purchase_poor:
|
||
mov merchantMessage3D,2
|
||
charm_purchase_done:
|
||
ret
|
||
BuyMerchantCharm3D ENDP
|
||
|
||
HandleMerchant3D PROC uses ebx
|
||
cmp merchantTab3D,1
|
||
jne @F
|
||
call HandleArtifactShop3D
|
||
ret
|
||
@@:
|
||
mov eax, merchantSelected3D
|
||
cmp eax, merchantPreviousFocus3D
|
||
je @F
|
||
mov merchantPreviousFocus3D, eax
|
||
mov merchantReaction3D, 0
|
||
mov merchantReactionKind3D, 1
|
||
@@:
|
||
mov eax, deltaTime3D
|
||
add merchantTime3D, eax
|
||
add merchantReaction3D, eax
|
||
|
||
; TAB (09h), Left Arrow (25h), Right Arrow (27h) toggle tabs
|
||
invoke Pressed3D, 09h
|
||
test eax, eax
|
||
jnz merchant_tab_toggle
|
||
invoke Pressed3D, 25h
|
||
test eax, eax
|
||
jnz merchant_tab_toggle
|
||
invoke Pressed3D, 27h
|
||
test eax, eax
|
||
jz @F
|
||
merchant_tab_toggle:
|
||
xor merchantTab3D, 1
|
||
mov merchantReaction3D, 0
|
||
mov merchantReactionKind3D, 1
|
||
invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1
|
||
@@:
|
||
cmp merchantTab3D, 0
|
||
jne handle_charms_vertical
|
||
|
||
; Shirts vertical navigation
|
||
invoke Pressed3D, 26h
|
||
test eax, eax
|
||
jz @F
|
||
cmp merchantSelected3D, 0
|
||
je @F
|
||
dec merchantSelected3D
|
||
@@:
|
||
invoke Pressed3D, 28h
|
||
test eax, eax
|
||
jz merchant_after_vertical
|
||
cmp merchantSelected3D, 12
|
||
jae merchant_after_vertical
|
||
inc merchantSelected3D
|
||
jmp merchant_after_vertical
|
||
|
||
handle_charms_vertical:
|
||
; Charms vertical navigation
|
||
invoke Pressed3D, 26h
|
||
test eax, eax
|
||
jz @F
|
||
cmp merchantCharmSelected3D, 0
|
||
je @F
|
||
dec merchantCharmSelected3D
|
||
@@:
|
||
invoke Pressed3D, 28h
|
||
test eax, eax
|
||
jz merchant_after_vertical
|
||
cmp merchantCharmSelected3D, 3
|
||
jae merchant_after_vertical
|
||
inc merchantCharmSelected3D
|
||
|
||
merchant_after_vertical:
|
||
cmp mouseClick3D, 0
|
||
je merchant_enter
|
||
cmp mouseX3D, 168
|
||
jb merchant_enter
|
||
cmp mouseX3D, 311
|
||
jae merchant_enter
|
||
|
||
; Tab header clicks (y 31..46)
|
||
cmp mouseY3D, 31
|
||
jb merchant_enter
|
||
cmp mouseY3D, 46
|
||
jae merchant_mouse_content
|
||
cmp mouseX3D, 235
|
||
jae tab_charms_click
|
||
mov merchantTab3D, 0
|
||
ret
|
||
tab_charms_click:
|
||
mov merchantTab3D, 1
|
||
ret
|
||
|
||
merchant_mouse_content:
|
||
cmp merchantTab3D, 0
|
||
jne merchant_mouse_charms
|
||
|
||
cmp mouseY3D, 48
|
||
jae merchant_mouse_rows
|
||
cmp mouseY3D, 34
|
||
jb merchant_enter
|
||
cmp mouseX3D, 248
|
||
jb merchant_enter
|
||
cmp mouseX3D, 278
|
||
jae merchant_mouse_next
|
||
cmp merchantSelected3D, 0
|
||
je merchant_handle_done
|
||
dec merchantSelected3D
|
||
ret
|
||
merchant_mouse_next:
|
||
cmp merchantSelected3D, 12
|
||
jae merchant_handle_done
|
||
inc merchantSelected3D
|
||
ret
|
||
merchant_mouse_rows:
|
||
mov eax, mouseY3D
|
||
sub eax, 52
|
||
js merchant_handle_done
|
||
cmp eax, 130
|
||
jae merchant_mouse_buy
|
||
xor edx, edx
|
||
mov ecx, 26
|
||
div ecx
|
||
mov ebx, eax
|
||
mov eax, merchantSelected3D
|
||
xor edx, edx
|
||
mov ecx, 5
|
||
div ecx
|
||
imul eax, 5
|
||
add eax, ebx
|
||
cmp eax, 12
|
||
ja merchant_handle_done
|
||
mov merchantSelected3D, eax
|
||
ret
|
||
|
||
merchant_mouse_charms:
|
||
cmp mouseY3D, 50
|
||
jb merchant_mouse_buy
|
||
cmp mouseY3D, 178
|
||
jae merchant_mouse_buy
|
||
mov eax, mouseY3D
|
||
sub eax, 50
|
||
xor edx, edx
|
||
mov ecx, 32
|
||
div ecx
|
||
cmp eax, 3
|
||
ja merchant_handle_done
|
||
mov merchantCharmSelected3D, eax
|
||
ret
|
||
|
||
merchant_mouse_buy:
|
||
cmp mouseY3D, 193
|
||
jb merchant_handle_done
|
||
cmp mouseY3D, 211
|
||
ja merchant_handle_done
|
||
jmp merchant_confirm
|
||
|
||
merchant_enter:
|
||
invoke Pressed3D, 0Dh
|
||
test eax, eax
|
||
jz merchant_handle_done
|
||
|
||
merchant_confirm:
|
||
cmp merchantTab3D, 0
|
||
jne @F
|
||
invoke BuyMerchantBack3D, merchantSelected3D
|
||
ret
|
||
@@:
|
||
invoke BuyMerchantCharm3D, merchantCharmSelected3D
|
||
merchant_handle_done:
|
||
ret
|
||
HandleMerchant3D ENDP
|
||
|
||
RenderMerchant3D PROC uses ebx esi edi
|
||
local rowY:DWORD,start:DWORD,frame:DWORD,ink:DWORD
|
||
cmp merchantTab3D,1
|
||
jne @F
|
||
call RenderArtifactShop3D
|
||
ret
|
||
@@:
|
||
invoke DrawBox, 0, 0, 320, 240, 00252B24h
|
||
invoke DrawBox, 0, 21, 320, 7, 00836638h
|
||
invoke DrawBox, 0, 151, 320, 63, 003C3024h
|
||
invoke DrawAnimSprite3D, OFFSET propsPack3D, 4, 8, 111, 298, 298
|
||
mov frame, 0
|
||
cmp merchantReaction3D, 1280
|
||
jae merchant_idle_pose
|
||
mov eax, merchantReaction3D
|
||
xor edx, edx
|
||
mov ecx, 160
|
||
div ecx
|
||
add eax, 16
|
||
cmp merchantReactionKind3D, 2
|
||
jne @F
|
||
sub eax, 8
|
||
@@:
|
||
mov frame, eax
|
||
jmp merchant_draw_pose
|
||
merchant_idle_pose:
|
||
mov eax, merchantTime3D
|
||
xor edx, edx
|
||
mov ecx, 5400
|
||
div ecx
|
||
cmp edx, 3640
|
||
jb merchant_draw_pose
|
||
mov eax, edx
|
||
sub eax, 3640
|
||
xor edx, edx
|
||
mov ecx, 220
|
||
div ecx
|
||
mov frame, eax
|
||
merchant_draw_pose:
|
||
invoke DrawAnimSprite3D, OFFSET merchantPack3D, frame, -10, 66, 342, 342
|
||
invoke DrawBox, 0, 194, 162, 29, 0045372Ah
|
||
invoke DrawBox, 0, 192, 162, 3, 00B79B63h
|
||
mov esi, OFFSET merchantHello3D
|
||
cmp merchantMessage3D, 1
|
||
jne @F
|
||
mov esi, OFFSET merchantThanks3D
|
||
@@:
|
||
invoke DrawString8x8, 6, 209, esi, 00F0D7ABh
|
||
|
||
; Draw card back preview only on Shirts tab
|
||
cmp merchantTab3D, 0
|
||
jne @F
|
||
invoke DrawAnimSprite3D, OFFSET backsPack3D, merchantSelected3D, 24, 282, 68, 96
|
||
@@:
|
||
invoke DrawBox, 0, 0, 320, 21, 00181D1Bh
|
||
invoke DrawString8x8, 8, 6, OFFSET merchantTitle3D, 00E9CD9Ah
|
||
invoke DrawString8x8, 152, 6, OFFSET textBank3D, 00B8D5B3h
|
||
invoke FormatNumber, bankroll, OFFSET hudNumBuffer
|
||
invoke DrawString8x8, 203, 6, OFFSET hudNumBuffer, 00FFFFFFh
|
||
|
||
; Right Panel
|
||
invoke DrawBoxBorder, 166, 31, 147, 187, 00191D1Fh, 009A825Ah, 1
|
||
|
||
; Tab 1: [ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ] (x 169..232)
|
||
cmp merchantTab3D, 0
|
||
jne @F
|
||
invoke DrawBox, 169, 33, 64, 13, 00395046h
|
||
invoke DrawString8x8, 171, 36, OFFSET merchantStock3D, 00FFFFFFh
|
||
jmp tab2_draw
|
||
@@:
|
||
invoke DrawString8x8, 171, 36, OFFSET merchantStock3D, 007E8E81h
|
||
|
||
tab2_draw:
|
||
; Tab 2: [ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ] (x 236..310)
|
||
cmp merchantTab3D, 1
|
||
jne @F
|
||
invoke DrawBox, 236, 33, 74, 13, 00395046h
|
||
invoke DrawString8x8, 238, 36, OFFSET merchantTabCharmsLabel, 00FFFFFFh
|
||
jmp tab_draw_done
|
||
@@:
|
||
invoke DrawString8x8, 238, 36, OFFSET merchantTabCharmsLabel, 007E8E81h
|
||
|
||
tab_draw_done:
|
||
cmp merchantTab3D, 0
|
||
jne render_charms_view
|
||
|
||
; --- SHIRTS VIEW ---
|
||
invoke DrawBoxBorder, 248, 34, 24, 12, 00373F3Bh, 00889985h, 1
|
||
invoke DrawString8x8, 256, 36, OFFSET merchantArrowUp3D, 00FFFFFFh
|
||
invoke DrawBoxBorder, 279, 34, 24, 12, 00373F3Bh, 00889985h, 1
|
||
invoke DrawString8x8, 287, 36, OFFSET merchantArrowDown3D, 00FFFFFFh
|
||
mov eax, merchantSelected3D
|
||
xor edx, edx
|
||
mov ecx, 5
|
||
div ecx
|
||
imul eax, 5
|
||
mov start, eax
|
||
mov ebx, eax
|
||
mov rowY, 52
|
||
merchant_render_row:
|
||
cmp ebx, 12
|
||
ja merchant_render_footer
|
||
mov ink, 00C1C8C1h
|
||
cmp ebx, merchantSelected3D
|
||
jne @F
|
||
invoke DrawBoxBorder, 169, rowY, 140, 24, 00395046h, 00A7C4AEh, 1
|
||
mov ink, 00FFFFFFh
|
||
@@:
|
||
mov eax, rowY
|
||
add eax, 3
|
||
invoke DrawString8x8, 173, eax, merchantNames3D[ebx*4], ink
|
||
mov esi, OFFSET merchantOwned3D
|
||
cmp ebx, selectedBack3D
|
||
jne @F
|
||
mov esi, OFFSET merchantEquipped3D
|
||
jmp merchant_item_status
|
||
@@:
|
||
bt ownedBacks3D, ebx
|
||
jc merchant_item_status
|
||
invoke FormatNumber, merchantPrices3D[ebx*4], OFFSET hudNumBuffer
|
||
mov esi, OFFSET hudNumBuffer
|
||
merchant_item_status:
|
||
mov eax, rowY
|
||
add eax, 14
|
||
invoke DrawString8x8, 173, eax, esi, 00C7B58Ah
|
||
add rowY, 26
|
||
inc ebx
|
||
mov eax, ebx
|
||
sub eax, start
|
||
cmp eax, 5
|
||
jb merchant_render_row
|
||
jmp merchant_render_footer
|
||
|
||
render_charms_view:
|
||
; --- CHARMS VIEW ---
|
||
xor ebx, ebx
|
||
mov rowY, 50
|
||
charm_render_loop:
|
||
cmp ebx, 4
|
||
jae merchant_render_footer
|
||
|
||
mov ink, 00C1C8C1h
|
||
cmp ebx, merchantCharmSelected3D
|
||
jne @F
|
||
invoke DrawBoxBorder, 168, rowY, 142, 28, 00395046h, 00A7C4AEh, 1
|
||
mov ink, 00FFFFFFh
|
||
@@:
|
||
; Line 1: Charm Name
|
||
mov eax, rowY
|
||
add eax, 2
|
||
invoke DrawString8x8, 171, eax, charmNames3D[ebx*4], ink
|
||
|
||
; Line 2: Charm Description
|
||
mov eax, rowY
|
||
add eax, 11
|
||
invoke DrawString8x8, 171, eax, charmDescs3D[ebx*4], 0088B8A8h
|
||
|
||
; Line 3: Price and Charges
|
||
mov eax, rowY
|
||
add eax, 20
|
||
push eax
|
||
|
||
invoke DrawString8x8, 171, eax, OFFSET merchantDollar3D, 00C7B58Ah
|
||
invoke FormatNumber, charmPrices3D[ebx*4], OFFSET hudNumBuffer
|
||
pop eax
|
||
push eax
|
||
invoke DrawString8x8, 179, eax, OFFSET hudNumBuffer, 00FFFFFFh
|
||
|
||
pop eax
|
||
push eax
|
||
invoke DrawString8x8, 234, eax, OFFSET merchantStockUsesLabel, 00A0A0A0h
|
||
|
||
mov edx, charmCloverUses
|
||
cmp ebx, 0
|
||
je draw_cur_uses
|
||
mov edx, charmHorseshoeUses
|
||
cmp ebx, 1
|
||
je draw_cur_uses
|
||
mov edx, charmSkullUses
|
||
cmp ebx, 2
|
||
je draw_cur_uses
|
||
mov edx, charmDevilUses
|
||
draw_cur_uses:
|
||
invoke FormatNumber, edx, OFFSET hudNumBuffer
|
||
pop eax
|
||
invoke DrawString8x8, 274, eax, OFFSET hudNumBuffer, 00FFE060h
|
||
|
||
add rowY, 31
|
||
inc ebx
|
||
jmp charm_render_loop
|
||
|
||
merchant_render_footer:
|
||
cmp merchantMessage3D, 2
|
||
jne @F
|
||
invoke DrawString8x8, 172, 182, OFFSET merchantPoor3D, 00EA8A77h
|
||
@@:
|
||
invoke DrawBoxBorder, 171, 194, 136, 17, 003B5949h, 00CBAF73h, 1
|
||
invoke DrawString8x8, 194, 199, OFFSET merchantBuy3D, 00FFFFFFh
|
||
invoke DrawBox, 0, 224, 320, 16, 00181D1Bh
|
||
invoke DrawString8x8, 8, 229, OFFSET merchantShopKeysWithTabs, 00C5C7B8h
|
||
ret
|
||
RenderMerchant3D ENDP
|
||
|
||
include src_graphics\artifact_shop.inc
|