KAZIK/src_graphics/hall_lighting.inc
Игорь Федосеев ca62db53e9 feat: implement native billiards, scratch tickets, first-person dice, and city wake scene
- Billiards: add native Russian Pyramid & American Eight-Ball pool with physics prediction, controls, and regression tests
- Scratch Tickets: add dedicated counter, mat presentation, elliptical coin scraping, 4 ticket types, and payout effects
- First-Person Dice: add native dice scene, hand anchor frames, throwing animation, and table perspective
- City Wake & Weather: add arrival cutscene, alley geometry, weather/rain effects, and lighter/rocker animation
- World Dressing: add hall paintings, furniture packs, hall lighting, and scene regression tests
- Build & Tooling: update build.bat for modern MSVC toolchain, update launcher hash, and refresh shipping binaries
2026-10-16 12:37:40 +03:00

383 lines
7.8 KiB
PHP

; Static world-space light and contact maps, shaded only before the HUD.
HallLightVisible3D PROC uses ebx esi lx:DWORD,ly:DWORD,tx:DWORD,ty:DWORD
mov esi,1
hall_light_ray:
mov eax,tx
sub eax,lx
imul eax,esi
sar eax,3
add eax,lx
sar eax,3
mov ebx,eax
mov eax,ty
sub eax,ly
imul eax,esi
sar eax,3
add eax,ly
sar eax,3
shl eax,5
add eax,ebx
cmp casinoMap[eax],0
jne hall_light_blocked
inc esi
cmp esi,8
jb hall_light_ray
mov eax,1
ret
hall_light_blocked:
xor eax,eax
ret
HallLightVisible3D ENDP
AddHallLight3D PROC uses ebx esi edi wx:DWORD,wy:DWORD,radius:DWORD,power:DWORD
local lightX:DWORD,lightY:DWORD,gx:DWORD,gy:DWORD,minX:DWORD,maxX:DWORD,maxY:DWORD
local radiusSq:DWORD,weight:DWORD
mov eax,wx
sar eax,13
mov lightX,eax
mov eax,wy
sar eax,13
mov lightY,eax
mov eax,radius
imul eax,eax
mov radiusSq,eax
mov eax,lightX
sub eax,radius
jns @F
xor eax,eax
@@:
mov minX,eax
mov eax,lightX
add eax,radius
cmp eax,255
jle @F
mov eax,255
@@:
mov maxX,eax
mov eax,lightY
sub eax,radius
jns @F
xor eax,eax
@@:
mov gy,eax
mov eax,lightY
add eax,radius
cmp eax,255
jle @F
mov eax,255
@@:
mov maxY,eax
hall_light_bake_row:
mov eax,minX
mov gx,eax
hall_light_bake_cell:
mov eax,gx
sub eax,lightX
imul eax,eax
mov ebx,gy
sub ebx,lightY
imul ebx,ebx
add eax,ebx
cmp eax,radiusSq
jae hall_light_bake_next
neg eax
add eax,radiusSq
shl eax,8
xor edx,edx
div radiusSq
imul eax,eax
imul eax,power
shr eax,16
test eax,eax
jz hall_light_bake_next
mov weight,eax
invoke HallLightVisible3D,lightX,lightY,gx,gy
test eax,eax
jz hall_light_bake_next
mov edi,gy
shl edi,8
add edi,gx
movzx eax,hallLightMap3D[edi]
add eax,weight
cmp eax,160
jbe @F
mov eax,160
@@:
mov hallLightMap3D[edi],al
hall_light_bake_next:
inc gx
mov eax,gx
cmp eax,maxX
jle hall_light_bake_cell
inc gy
mov eax,gy
cmp eax,maxY
jle hall_light_bake_row
ret
AddHallLight3D ENDP
AddHallContact3D PROC uses ebx esi edi wx:DWORD,wy:DWORD,worldWidth:DWORD
local centerX:DWORD,centerY:DWORD,radius:DWORD,gx:DWORD,gy:DWORD,minX:DWORD,maxX:DWORD,maxY:DWORD
mov eax,wx
sar eax,13
mov centerX,eax
mov eax,wy
sar eax,13
mov centerY,eax
mov eax,worldWidth
shr eax,14
add eax,2
mov radius,eax
mov eax,centerX
sub eax,radius
jns @F
xor eax,eax
@@:
mov minX,eax
mov eax,centerX
add eax,radius
cmp eax,255
jle @F
mov eax,255
@@:
mov maxX,eax
mov eax,centerY
sub eax,4
jns @F
xor eax,eax
@@:
mov gy,eax
mov eax,centerY
add eax,4
cmp eax,255
jle @F
mov eax,255
@@:
mov maxY,eax
hall_contact_row:
mov eax,minX
mov gx,eax
hall_contact_cell:
mov eax,gx
sub eax,centerX
imul eax,256
cdq
idiv radius
imul eax,eax
mov ebx,eax
mov eax,gy
sub eax,centerY
imul eax,64
imul eax,eax
add eax,ebx
cmp eax,65536
jae hall_contact_next
neg eax
add eax,65536
imul eax,40
shr eax,16
mov edi,gy
shl edi,8
add edi,gx
cmp al,hallContactMap3D[edi]
jbe hall_contact_next
mov hallContactMap3D[edi],al
hall_contact_next:
inc gx
mov eax,gx
cmp eax,maxX
jle hall_contact_cell
inc gy
mov eax,gy
cmp eax,maxY
jle hall_contact_row
ret
AddHallContact3D ENDP
BuildHallLighting3D PROC uses ebx esi edi
lea edi,hallLightMap3D
xor eax,eax
mov ecx,WORLD_LIGHT_W*WORLD_LIGHT_H
rep stosb
lea edi,hallContactMap3D
mov ecx,WORLD_LIGHT_W*WORLD_LIGHT_H
rep stosb
lea esi,hallLights3D
mov edi,HALL_LIGHT_COUNT
hall_bake_chandelier:
invoke AddHallLight3D,[esi].CityProp3D.posX,[esi].CityProp3D.posY,32,86
add esi,SIZEOF CityProp3D
dec edi
jnz hall_bake_chandelier
lea esi,hallLoungeDecor3D
mov edi,HALL_DECOR_COUNT
hall_bake_furniture:
cmp [esi].CityProp3D.asset,OFFSET hallRopeFurniture3D
je hall_bake_furniture_next
invoke AddHallContact3D,[esi].CityProp3D.posX,[esi].CityProp3D.posY,[esi].CityProp3D.worldW
cmp [esi].CityProp3D.asset,OFFSET hallLampFurniture3D
jne hall_bake_furniture_next
invoke AddHallLight3D,[esi].CityProp3D.posX,[esi].CityProp3D.posY,20,110
hall_bake_furniture_next:
add esi,SIZEOF CityProp3D
dec edi
jnz hall_bake_furniture
xor esi,esi
hall_bake_sconce:
invoke AddHallLight3D,FP_1*5/4,hallSconceY3D[esi*4],22,110
invoke AddHallLight3D,FP_1*123/4,hallSconceY3D[esi*4],22,110
inc esi
cmp esi,4
jb hall_bake_sconce
invoke AddHallLight3D,4*FP_1,23*FP_1,22,90
invoke AddHallLight3D,6*FP_1,23*FP_1,22,90
invoke AddHallLight3D,8*FP_1,23*FP_1,22,90
mov hallLightReady3D,1
ret
BuildHallLighting3D ENDP
ApplyHallLighting3D PROC uses ebx esi edi
local rowY:DWORD,columnX:DWORD,planeDepth:DWORD,planeFloor:DWORD
local gainR:DWORD,gainG:DWORD,gainB:DWORD,cell:DWORD,floorHit:DWORD
local light:DWORD,contact:DWORD,pixelRow:DWORD,pixelColumn:DWORD
cmp hallLighting3D,0
je hall_light_draw_done
cmp hallLightReady3D,0
je hall_light_draw_done
cmp outdoorRender3D,0
jne hall_light_draw_done
cmp hallLevel3D,0
jne hall_light_draw_done
mov rowY,0
hall_light_draw_row:
mov eax,rowY
mov planeFloor,0
cmp eax,viewHorizon3D
jge hall_light_floor_depth
mov ecx,viewHorizon3D
sub ecx,eax
mov eax,viewCeiling3D
sub eax,viewEye3D
jmp hall_light_plane_depth
hall_light_floor_depth:
sub eax,viewHorizon3D
inc eax
mov ecx,eax
mov eax,viewEye3D
mov planeFloor,1
hall_light_plane_depth:
imul eax,480
cdq
idiv ecx
mov planeDepth,eax
mov columnX,0
hall_light_draw_column:
imul edi,rowY,640
add edi,columnX
mov eax,cityDepthBuffer3D[edi*4]
mov floorHit,0
cmp eax,planeDepth
jl @F
mov eax,planeDepth
mov edx,planeFloor
mov floorHit,edx
@@:
mov esi,eax
mov ebx,columnX
imul cityRayX3D[ebx*4]
shrd eax,edx,16
add eax,playerX
sar eax,13
cmp eax,256
jae hall_light_ambient
mov cell,eax
mov eax,esi
imul cityRayY3D[ebx*4]
shrd eax,edx,16
add eax,playerY
sar eax,13
cmp eax,256
jae hall_light_ambient
shl eax,8
add eax,cell
movzx ecx,hallLightMap3D[eax]
mov light,ecx
mov contact,0
cmp floorHit,0
je hall_light_gains
movzx eax,hallContactMap3D[eax]
mov contact,eax
jmp hall_light_gains
hall_light_ambient:
mov light,0
mov contact,0
hall_light_gains:
mov eax,light
add eax,184
sub eax,contact
mov gainR,eax
mov eax,light
imul eax,7
shr eax,3
add eax,188
sub eax,contact
mov gainG,eax
mov eax,light
shr eax,1
add eax,200
sub eax,contact
mov gainB,eax
mov pixelRow,0
hall_light_pixel_row:
mov pixelColumn,0
hall_light_pixel:
mov eax,pixelRow
imul eax,640
add eax,pixelColumn
add eax,edi
mov esi,eax
mov ebx,screenBuffer[esi*4]
movzx eax,bl
imul eax,gainB
shr eax,8
cmp eax,255
jbe @F
mov eax,255
@@:
mov ecx,eax
movzx eax,bh
imul eax,gainG
shr eax,8
cmp eax,255
jbe @F
mov eax,255
@@:
shl eax,8
or ecx,eax
mov eax,ebx
shr eax,16
and eax,255
imul eax,gainR
shr eax,8
cmp eax,255
jbe @F
mov eax,255
@@:
shl eax,16
or eax,ecx
mov screenBuffer[esi*4],eax
inc pixelColumn
cmp pixelColumn,2
jb hall_light_pixel
inc pixelRow
cmp pixelRow,2
jb hall_light_pixel_row
add columnX,2
cmp columnX,640
jb hall_light_draw_column
add rowY,2
cmp rowY,480
jb hall_light_draw_row
hall_light_draw_done:
ret
ApplyHallLighting3D ENDP