KAZIK/tools/tests/presentation_test.inc

434 lines
12 KiB
PHP

; Exercise the shipping ASM startup, admission, overlay and input procedures.
.data
presFilmState dd 12 dup(0)
presFilmPointers dd OFFSET playerX,OFFSET playerY,OFFSET playerAngle,OFFSET worldMap3D
dd OFFSET viewEye3D,OFFSET viewCeiling3D,OFFSET viewHorizon3D,OFFSET floorTexture3D
dd OFFSET outdoorRender3D,OFFSET cityClock3D,OFFSET bankroll,OFFSET rngSeed3D
presTestStage dd 1
presTestIo dd 0
presTestPath db 'build\scratch\presentation-00.bgra',0
presBootFeatures db 'build\scratch\boot-features.bgra',0
presBootMotion db 'build\scratch\boot-motion-'
presBootDigits db '000.bgra',0
presTestWindow db 'build\scratch\presentation-window.bgra',0
presTestTimes dd 0,100,200,300,450,600,1200,2400,10000
presTestX dd 0
presTestY dd 0
presTestAngle dd 0
presTestBank dd 0
presTestRng dd 0
presTestMusicMode db 'status jboxmusic mode',0
presTestMusicVolume db 'status jboxmusic volume',0
presTestMusicPosition db 'status jboxmusic position',0
presTestMusicSeek db 'seek jboxmusic to 5000',0
presTestMusicReply db 64 dup(0)
.code
PresTestMusicNumber PROC uses esi ebx command:DWORD
invoke mciSendStringA,command,OFFSET presTestMusicReply,64,0
test eax,eax
jnz pres_music_number_failed
xor eax,eax
lea esi,presTestMusicReply
pres_music_number_digit:
movzx ebx,BYTE PTR [esi]
test ebx,ebx
jz pres_music_number_done
sub ebx,'0'
cmp ebx,9
ja pres_music_number_failed
imul eax,10
add eax,ebx
inc esi
jmp pres_music_number_digit
pres_music_number_failed:
mov eax,-1
pres_music_number_done:
ret
PresTestMusicNumber ENDP
PresTestCapture PROC uses ebx path:DWORD
invoke CreateFileA,path,40000000h,0,0,2,80h,0
cmp eax,-1
je pres_capture_failed
mov ebx,eax
invoke WriteFile,ebx,OFFSET screenBuffer,SCREEN_SIZE*4,OFFSET presTestIo,0
push eax
invoke CloseHandle,ebx
pop eax
ret
pres_capture_failed:
xor eax,eax
ret
PresTestCapture ENDP
RunPresentationTest3D PROC uses esi edi ebx
call InitPaths3D
call InitHall3D
call LoadTextures3D
call LoadHallAssets3D
call InitializeCasinoSprites3D
mov rngSeed3D,12345678h
mov bankroll,12345
mov keys3D[57h],1
call BeginStartup3D
cmp hdFile,-1
jne pres_film_assets_ready
cmp cinemaFile,-1
jne pres_film_assets_ready
cmp filmWheel.pixels,0
je pres_test_failed
cmp filmStudio.pixels,0
je pres_test_failed
cmp filmTitle.pixels,0
je pres_test_failed
pres_film_assets_ready:
cmp startupPage3D,STARTUP_WARNING
jne pres_test_failed
cmp keys3D[57h],0
jne pres_test_failed
mov startupElapsed3D,2500
call RenderStartup3D
invoke PresTestCapture,OFFSET presTestPath
mov presTestStage,2
; Exact automatic boundary: warning -> studio.
mov startupElapsed3D,8499
mov deltaTime3D,0
call HandleStartupInput3D
cmp startupPage3D,STARTUP_WARNING
jne pres_test_failed
mov deltaTime3D,1
call HandleStartupInput3D
cmp startupPage3D,STARTUP_STUDIO
jne pres_test_failed
cmp startupElapsed3D,0
jne pres_test_failed
cmp engineMode,MODE_INTRO
jne pres_test_failed
mov startupElapsed3D,2900
call RenderStartup3D
mov presTestPath[28],'1'
invoke PresTestCapture,OFFSET presTestPath
; Enter advances exactly one page and clears held gameplay input.
mov keys3D[57h],1
mov pressedKeys3D[0Dh],1
mov deltaTime3D,0
call HandleStartupInput3D
cmp startupPage3D,STARTUP_FEATURES
jne pres_test_failed
cmp keys3D[57h],0
jne pres_test_failed
mov startupElapsed3D,2900
call RenderStartup3D
mov presTestPath[28],'2'
invoke PresTestCapture,OFFSET presTestPath
mov presTestStage,3
mov startupElapsed3D,2500
call RenderStartup3D
invoke PresTestCapture,OFFSET presBootFeatures
mov startupElapsed3D,11000
call HandleStartupInput3D
cmp engineMode,MODE_ARRIVAL
jne pres_test_failed
cmp arrivalState3D,ARRIVAL_WALK
jne pres_test_failed
cmp cityPhase3D,CITY_BLACK
jne pres_test_failed
cmp welcomeActive3D,0
jne pres_test_failed
cmp jboxIsPlaying,0
jne pres_test_failed
cmp startupPixels3D,0
jne pres_test_failed
cmp startupSequence3D,0
jne pres_test_failed
; All three pages automatically advance; a fresh launch resets everything.
call BeginStartup3D
mov deltaTime3D,8500
call HandleStartupInput3D
mov deltaTime3D,STUDIO_HD_DURATION
call HandleStartupInput3D
cmp startupPage3D,STARTUP_FEATURES
jne pres_test_failed
mov deltaTime3D,11000
call HandleStartupInput3D
cmp engineMode,MODE_ARRIVAL
jne pres_test_failed
call BeginStartup3D
cmp startupPage3D,STARTUP_WARNING
jne pres_test_failed
; Capture motion while checking that the base scene and gameplay are untouched.
xor ebx,ebx
pres_film_save_state:
mov eax,presFilmPointers[ebx*4]
mov eax,[eax]
mov presFilmState[ebx*4],eax
inc ebx
cmp ebx,12
jb pres_film_save_state
xor esi,esi
pres_cinematic_frames:
mov startupPage3D,STARTUP_STUDIO
mov eax,esi
imul eax,50
mov startupElapsed3D,eax
call RenderStartup3D
xor ebx,ebx
pres_film_compare_state:
mov eax,presFilmPointers[ebx*4]
mov eax,[eax]
cmp eax,presFilmState[ebx*4]
jne pres_test_failed
inc ebx
cmp ebx,12
jb pres_film_compare_state
mov eax,esi
xor edx,edx
mov ecx,100
div ecx
add al,'0'
mov presBootDigits,al
mov eax,edx
xor edx,edx
mov ecx,10
div ecx
add al,'0'
add dl,'0'
mov presBootDigits[1],al
mov presBootDigits[2],dl
invoke PresTestCapture,OFFSET presBootMotion
test eax,eax
jz pres_test_failed
inc esi
cmp esi,STUDIO_HD_DURATION/50
jb pres_cinematic_frames
call FinishStartup3D
cmp engineMode,MODE_ARRIVAL
jne pres_test_failed
mov presTestStage,4
; Guest profile -> admission -> hall triggers the modal only after entry.
mov arrivalState3D,ARRIVAL_PROFILE
mov arrivalSelected3D,0
mov deltaTime3D,0
mov pressedKeys3D[0Dh],1
call HandleArrival3D
cmp arrivalConfirmed3D,1
jne pres_test_failed
cmp welcomeActive3D,0
jne pres_test_failed
cmp jboxIsPlaying,0
jne pres_test_failed
mov deltaTime3D,1200
call HandleArrival3D
cmp arrivalState3D,ARRIVAL_ENTER
jne pres_test_failed
cmp welcomeActive3D,0
jne pres_test_failed
cmp jboxIsPlaying,0
jne pres_test_failed
mov deltaTime3D,1400
call HandleArrival3D
cmp engineMode,MODE_WALK
jne pres_test_failed
cmp welcomeActive3D,1
jne pres_test_failed
cmp welcomeElapsed3D,0
jne pres_test_failed
mov presTestStage,41
cmp jboxIsPlaying,1
jne pres_test_failed
cmp jboxCurrentTrack,0
jne pres_test_failed
cmp jboxUserVolume,5
jne pres_test_failed
mov presTestStage,42
invoke mciSendStringA,OFFSET presTestMusicMode,OFFSET presTestMusicReply,64,0
test eax,eax
jnz pres_test_failed
cmp DWORD PTR presTestMusicReply,79616C70h ; "play" in "playing"
jne pres_test_failed
mov presTestStage,43
invoke PresTestMusicNumber,OFFSET presTestMusicVolume
cmp eax,-1
je pres_test_failed
cmp eax,500
ja pres_test_failed
test eax,eax
jz pres_test_failed
; Windows MCI rounds through device gain; allow a few units out of 1000.
sub eax,jboxEffectiveVolume
jns @F
neg eax
@@:
cmp eax,4
ja pres_test_failed
mov eax,playerX
mov presTestX,eax
mov eax,playerY
mov presTestY,eax
mov eax,playerAngle
mov presTestAngle,eax
mov eax,bankroll
mov presTestBank,eax
mov eax,rngSeed3D
mov presTestRng,eax
mov presTestStage,5
xor esi,esi
pres_test_overlay_frames:
mov eax,presTestTimes[esi*4]
mov welcomeElapsed3D,eax
mov deltaTime3D,0
call HandleWelcome3D
call RenderWelcomeScene3D
mov eax,esi
add al,'3'
cmp al,'9'
jbe @F
sub al,10
mov presTestPath[27],'1'
@@:
mov presTestPath[28],al
invoke PresTestCapture,OFFSET presTestPath
test eax,eax
jz pres_test_failed
inc esi
cmp esi,9
jb pres_test_overlay_frames
mov eax,presTestX
cmp eax,playerX
jne pres_test_failed
mov eax,presTestY
cmp eax,playerY
jne pres_test_failed
mov eax,presTestAngle
cmp eax,playerAngle
jne pres_test_failed
mov eax,presTestRng
cmp eax,rngSeed3D
jne pres_test_failed
mov eax,presTestBank
cmp eax,bankroll
jne pres_test_failed
mov presTestStage,6
; Put playback past zero: closing/reopening the modal must not restart it.
invoke mciSendStringA,OFFSET presTestMusicSeek,0,0,0
test eax,eax
jnz pres_test_failed
invoke mciSendStringA,OFFSET jboxPlayCmd,0,0,0
test eax,eax
jnz pres_test_failed
mov pressedKeys3D[0BDh],1
call HandleJukeboxKeys3D
cmp jboxUserVolume,4
jne pres_test_failed
; Early input cannot skip the deployment; typing completion is persistent.
call BeginWelcome3D
mov deltaTime3D,100
mov pressedKeys3D[0Dh],1
call HandleWelcome3D
cmp welcomeActive3D,1
jne pres_test_failed
cmp welcomeChars3D,0
jne pres_test_failed
call ClearKeys3D
mov deltaTime3D,700
call HandleWelcome3D
cmp welcomeChars3D,0
je pres_test_failed
cmp welcomeChars3D,welcomeTextLength3D
jae pres_test_failed
mov pressedKeys3D[0Dh],1
mov keys3D[57h],1
call HandleWelcome3D
cmp welcomeActive3D,1
jne pres_test_failed
cmp welcomeChars3D,welcomeTextLength3D
jne pres_test_failed
cmp keys3D[57h],0
jne pres_test_failed
mov deltaTime3D,1
call HandleWelcome3D
cmp welcomeChars3D,welcomeTextLength3D
jne pres_test_failed
mov pressedKeys3D[0Dh],1
call HandleWelcome3D
cmp welcomeActive3D,0
jne pres_test_failed
cmp pressedKeys3D[0Dh],0
jne pres_test_failed
cmp jboxUserVolume,4
jne pres_test_failed
invoke PresTestMusicNumber,OFFSET presTestMusicPosition
cmp eax,-1
je pres_test_failed
cmp eax,5000
jb pres_test_failed
; Escape uses the same clean close; click stays inside the button.
call BeginWelcome3D
call CloseWelcome3D
cmp welcomeActive3D,0
jne pres_test_failed
cmp paused3D,0
jne pres_test_failed
call BeginWelcome3D
mov welcomeElapsed3D,10000
mov mouseX3D,220
mov mouseY3D,190
mov mouseClick3D,1
call HandleWelcome3D
cmp welcomeActive3D,0
jne pres_test_failed
IFDEF PRESENTATION_WINDOW_TEST
mov presTestStage,7
call Create3DWindow
test eax,eax
jz pres_test_failed
cmp fullscreen3D,0
je @F
call ToggleFullscreen3D
@@:
invoke SetWindowPos,h3DWnd,0,80,80,800,640,14h
call BeginWelcome3D
invoke ShowWindow,h3DWnd,4
mov esi,150
pres_test_window_frame:
invoke PeekMessageA,OFFSET msg3D,0,0,0,PM_REMOVE
test eax,eax
jz pres_test_window_tick
invoke TranslateMessage,OFFSET msg3D
invoke DispatchMessageA,OFFSET msg3D
jmp pres_test_window_frame
pres_test_window_tick:
mov deltaTime3D,50
call HandleWelcome3D
call RenderWelcomeScene3D
call Present3D
invoke Sleep,17
dec esi
jnz pres_test_window_frame
invoke PresTestCapture,OFFSET presTestWindow
call CloseWelcome3D
invoke DestroyWindow,h3DWnd
ENDIF
mov presTestStage,8
; Manual track switching and Stop still work after automatic entry playback.
invoke PlayJukeboxTrack3D,1
cmp jboxIsPlaying,1
jne pres_test_failed
cmp jboxCurrentTrack,1
jne pres_test_failed
cmp jboxUserVolume,4
jne pres_test_failed
call StopJukeboxTrack3D
cmp jboxIsPlaying,0
jne pres_test_failed
cmp jboxCurrentTrack,-1
jne pres_test_failed
call FreeStartupAssets3D
call FreeArrivalAssets3D
xor eax,eax
ret
pres_test_failed:
call StopJukeboxTrack3D
mov eax,presTestStage
ret
RunPresentationTest3D ENDP