EBLAN_ENGINE/tests/lighting_engine_checks.inc

103 lines
4.4 KiB
PHP

.data
lightFile db 'lit.dat',0
lightBadCount db 'lit_badcount.dat',0
lightBadRadius db 'lit_badradius.dat',0
lightBadRGB db 'lit_badrgb.dat',0
lightBakeDump db 'lighting_bake.bin',0
lightFrameDump db 'lighting_frame.bin',0
lightSavedRed dd 0
lightSavedBlue dd 0
lightSavedPulse dd 0
.code
RunLightingChecks PROC uses ebx ecx edx esi edi
invoke LoadSublevelBinary,OFFSET lightFile,-1,-1,0
CHECK eax,1 ; v5 authored lighting loads in ASM
CHECK authoredLightCount,2 ; all authored lights reach runtime slots
CHECK lightingMode,2 ; map lighting mode loads without a startup override
CHECK isFlashlightOn,0 ; saved flashlight toggle reaches the game
CHECK DWORD PTR [lightSources+40+LightSource.color],00FF0000h ; static light color retained on load
call Render3DScene
invoke Dump,OFFSET lightFrameDump,OFFSET screenBuffer,FRAME_BUFFER_SIZE
call BakeMapLighting
invoke Dump,OFFSET lightBakeDump,OFFSET lightGridRGB,4096
CHECK DWORD PTR [lightGridRGB+(5*32+14)*4],000A0A0Ah ; static light cannot leak through a wall
mov lightingMode,1
invoke SamplePointLighting,480,352,0,0
mov eax,lightRed
mov lightSavedRed,eax
mov eax,lightBlue
mov lightSavedBlue,eax
mov lightingMode,2
call UpdateDynamicLights
invoke SamplePointLighting,480,352,0,0
CHECK lightRed,lightSavedRed ; dynamic mode does not count static light twice
xor eax,eax
mov ebx,lightBlue
cmp ebx,lightSavedBlue
seta al
CHECK eax,1 ; realtime blue light contributes beyond the baked map
mov DWORD PTR [lightSources+80+LightSource.x],928
invoke SamplePointLighting,480,352,0,0
CHECK lightBlue,10 ; dynamic source is occluded by a separating wall
mov DWORD PTR [lightSources+80+LightSource.flags],LIGHT_FLAG_ACTIVE
invoke SamplePointLighting,480,352,0,0
xor eax,eax
cmp lightBlue,10
seta al
CHECK eax,1 ; disabling dynamic shadows allows unoccluded contribution
mov DWORD PTR [lightSources+80+LightSource.lightType],LIGHT_TYPE_PULSE
mov lightingTick,0
call UpdateDynamicLights
mov eax,DWORD PTR [lightSources+80+LightSource.curIntensity]
mov lightSavedPulse,eax
mov lightingTick,31
call UpdateDynamicLights
mov eax,DWORD PTR [lightSources+80+LightSource.curIntensity]
cmp eax,lightSavedPulse
setne al
movzx eax,al
CHECK eax,1 ; pulse light changes intensity with the simulation clock
mov DWORD PTR [lightSources+13*40+LightSource.intensity],77
invoke SpawnMuzzleFlashLight,160,160
invoke SpawnExplosionLight,160,160
CHECK DWORD PTR [lightSources+13*40+LightSource.intensity],77 ; combat bursts cannot overwrite authored light slots
call UpdateDynamicLights
CHECK DWORD PTR [lightSources+14*40+LightSource.curIntensity],180 ; muzzle light decays in its reserved slot
call InitLightingSystem
mov lightingMode,2
mov edi,OFFSET lightGridRGB
mov ecx,1024
mov eax,000A0A0Ah
rep stosd
mov playerX,160
mov playerY,160
mov playerAngle,0
invoke SamplePointLighting,288,160,0,0
xor eax,eax
cmp lightRed,10
seta al
CHECK eax,1 ; flashlight illuminates points inside its forward cone
invoke SamplePointLighting,160,288,0,0
CHECK lightRed,10 ; flashlight cannot illuminate sprites outside its cone
mov BYTE PTR [gameMap+2*32+3],CELL_DOOR
invoke SamplePointLighting,288,160,0,0
CHECK lightRed,10 ; a closed door blocks the player flashlight
mov BYTE PTR [gameMap+2*32+3],CELL_DOOR_OPEN
invoke CastLightRay,160,160,288,160
CHECK eax,1 ; an open door transmits dynamic light
mov BYTE PTR [gameMap+5*32+6],CELL_BRICK
invoke CastLightRay,352,352,416,416
CHECK eax,0 ; ASM light rays reject diagonal corner leaks
invoke LoadSublevelBinary,OFFSET lightFile,-1,-1,0
invoke LoadSublevelBinary,OFFSET lightBadCount,-1,-1,0
CHECK eax,0 ; excessive lighting count rejected before committing a room
CHECK authoredLightCount,2 ; malformed lighting preserves current authored lights
invoke LoadSublevelBinary,OFFSET lightBadRadius,-1,-1,0
CHECK eax,0 ; zero radius rejected without a divide by zero
invoke LoadSublevelBinary,OFFSET lightBadRGB,-1,-1,0
CHECK eax,0 ; malformed baked RGB cannot replace current lighting
invoke LoadSublevelBinary,OFFSET mainPath,-1,-1,0
CHECK authoredLightCount,0 ; loading a legacy room clears stale dynamic sources
CHECK lightingMode,0 ; legacy room restores classic lighting mode
ret
RunLightingChecks ENDP