KAZIK/src_graphics/startup_code.inc
Artvasil09 3ad5bf4c9d Develop assembly-only casino scenes and native games
Add native Durak, poker, blackjack, roulette, Buckshot and billiards scenes with animation assets and regression tests. Improve arrival, city, hall, profiles, shops, audio and exit handling; remove the portable C game core and refresh shipping executables.
2026-10-08 22:39:19 +03:00

279 lines
6 KiB
PHP

; A single 640x480 bitmap; scan reveal and illumination run entirely in MASM.
ClearKeys3D PROC uses edi
mov mouseClick3D, 0
lea edi, keys3D
xor eax, eax
mov ecx, 128
rep stosd
ret
ClearKeys3D ENDP
FreeStartupAssets3D PROC
call FreeStartupSequence3D
cmp startupPixels3D, 0
je @F
invoke HeapFree, startupHeap3D, 0, startupPixels3D
mov startupPixels3D, 0
@@:
ret
FreeStartupAssets3D ENDP
LoadStartupAssets3D PROC uses ebx
local count:DWORD
cmp startupPixels3D, 0
jne startup_asset_ready
invoke CreateFileA, OFFSET startupPath3D, 80000000h, 1, 0, 3, 80h, 0
cmp eax, -1
je startup_asset_failed
mov ebx, eax
invoke ReadFile, ebx, OFFSET startupHeader3D, 16, ADDR count, 0
test eax, eax
jz startup_asset_close
cmp count, 16
jne startup_asset_close
cmp startupHeader3D, 31474245h
jne startup_asset_close
cmp startupHeader3D[4], SCREEN_W
jne startup_asset_close
cmp startupHeader3D[8], SCREEN_H
jne startup_asset_close
cmp startupHeader3D[12], INTRO_BYTES
jne startup_asset_close
invoke GetProcessHeap
mov startupHeap3D, eax
invoke HeapAlloc, eax, 0, INTRO_BYTES
mov startupPixels3D, eax
test eax, eax
jz startup_asset_close
invoke ReadFile, ebx, startupPixels3D, INTRO_BYTES, ADDR count, 0
test eax, eax
jz startup_asset_close
cmp count, INTRO_BYTES
jne startup_asset_close
invoke CloseHandle, ebx
startup_asset_ready:
mov eax, 1
ret
startup_asset_close:
invoke CloseHandle, ebx
call FreeStartupAssets3D
startup_asset_failed:
xor eax, eax
ret
LoadStartupAssets3D ENDP
BeginStartup3D PROC
mov engineMode, MODE_INTRO
mov paused3D, 0
mov interactTargetId, 0
mov interactPromptPtr, 0
mov startupElapsed3D, 0
mov startupVariant3D, 0
mov animationClock3D, 0
mov rr3d_state, RR_READY
call ClearKeys3D
call LoadStartupAssets3D
call LoadStartupSequence3D
ret
BeginStartup3D ENDP
FinishStartup3D PROC
mov paused3D, 0
mov interactTargetId, 0
mov interactPromptPtr, 0
call ClearKeys3D
call FreeStartupAssets3D
call BeginArrival3D
ret
FinishStartup3D ENDP
HandleStartupInput3D PROC
mov eax, deltaTime3D
add startupElapsed3D, eax
invoke Pressed3D, 71h
test eax, eax
jz @F
xor startupVariant3D, 1
mov startupElapsed3D, 0
@@:
invoke Pressed3D, 0Dh
test eax, eax
jnz startup_enter
invoke Pressed3D, 20h
test eax, eax
jz startup_input_done
startup_enter:
call FinishStartup3D
startup_input_done:
cmp engineMode, MODE_INTRO
jne @F
cmp startupElapsed3D, 7000
jb @F
call FinishStartup3D
@@:
ret
HandleStartupInput3D ENDP
RenderStartup3D PROC
cmp startupVariant3D, 0
jne startup_studio_variant
cmp startupSequence3D, 0
je startup_studio_variant
call RenderStartupSequence3D
call FadeStartupOut3D
ret
startup_studio_variant:
call RenderStudioStartup3D
call FadeStartupOut3D
ret
RenderStartup3D ENDP
FadeStartupOut3D PROC
cmp startupElapsed3D, 6600
jb @F
mov eax, startupElapsed3D
cmp eax, 7000
jbe startup_fade_time
mov eax, 7000
startup_fade_time:
sub eax, 6600
shl eax, 8
xor edx, edx
mov ecx, 400
div ecx
neg eax
add eax, 256
invoke FadeCityFrame3D, eax
@@:
ret
FadeStartupOut3D ENDP
RenderStudioStartup3D PROC uses ebx esi edi
local row:DWORD, gain:DWORD, reveal:DWORD, beam:DWORD, shiftPx:DWORD, red:DWORD, green:DWORD
cmp startupPixels3D, 0
je startup_fallback
mov eax, startupElapsed3D
cmp eax, 1200
jb @F
mov eax, 1200
@@:
imul eax, SCREEN_H
xor edx, edx
mov ecx, 1200
div ecx
mov reveal, eax
mov eax, startupElapsed3D
xor edx, edx
mov ecx, 5400
div ecx
mov eax, edx
imul eax, 600
xor edx, edx
div ecx
sub eax, 60
mov beam, eax
mov row, 0
lea edi, screenBuffer
startup_row:
mov eax, row
imul eax, SCREEN_W * 4
add eax, startupPixels3D
mov esi, eax
mov shiftPx, 0
mov eax, startupElapsed3D
cmp eax, 1000
jae startup_steady_gain
imul eax, 240
xor edx, edx
mov ecx, 1000
div ecx
add eax, 16
mov gain, eax
; A few moving horizontal slices during the initial signal lock only.
mov eax, startupElapsed3D
shr eax, 5
add eax, row
and eax, 63
cmp eax, 4
jae startup_reveal
mov shiftPx, 12
jmp startup_reveal
startup_steady_gain:
mov gain, 240
startup_reveal:
mov eax, row
cmp eax, reveal
jb startup_beam
mov gain, 16
startup_beam:
cmp startupElapsed3D, 1200
jb startup_pixels
mov eax, row
sub eax, beam
cdq
xor eax, edx
sub eax, edx
cmp eax, 24
jae startup_pixels
mov gain, 256
startup_pixels:
cmp gain, 256
jne startup_shaded_row
mov ecx, SCREEN_W
rep movsd
jmp startup_next_row
startup_shaded_row:
xor ebx, ebx
startup_pixel:
mov ecx, ebx
add ecx, shiftPx
cmp ecx, SCREEN_W
jb @F
sub ecx, SCREEN_W
@@:
mov edx, [esi+ecx*4]
mov eax, edx
shr eax, 16
and eax, 255
imul eax, gain
shr eax, 8
shl eax, 16
mov red, eax
mov eax, edx
shr eax, 8
and eax, 255
imul eax, gain
shr eax, 8
shl eax, 8
mov green, eax
mov eax, edx
and eax, 255
imul eax, gain
shr eax, 8
or eax, green
or eax, red
stosd
inc ebx
cmp ebx, SCREEN_W
jb startup_pixel
startup_next_row:
inc row
cmp row, SCREEN_H
jb startup_row
jmp startup_prompt
startup_fallback:
lea edi, screenBuffer
mov eax, 000A1012h
mov ecx, SCREEN_SIZE
rep stosd
invoke DrawString8x8, 140, 84, OFFSET startupName3D, 005FE6F2h
invoke DrawString8x8, 140, 112, OFFSET startupGames3D, 00E9DBADh
startup_prompt:
cmp startupElapsed3D, 1200
jb startup_render_done
invoke DrawString8x8, 140, 220, OFFSET startupEnter3D, 00F4E4BCh
startup_render_done:
ret
RenderStudioStartup3D ENDP
include src_graphics\startup_sequence.inc