KAZIK/src_graphics/rooftop_gl.inc
Artvasil09 41ba8f46ed feat: add rooftop city and optimize native terrace rendering
Add rooftop elevator, lounge, volumetric city, river and animated traffic. Prune invisible mesh faces, clip CPU surfaces, streamline compositing and add automatic/F8 roof quality profiles with renderer diagnostics.

Include dartboard/reticle improvements, tracked fortune orb numerals and fate-session visuals, native regression tests, compatible jukebox IDs and updated shipping executables.
2026-10-26 23:20:35 +03:00

1118 lines
29 KiB
PHP

RoofGLProc3D PROC procName:DWORD,alternate:DWORD
invoke wglGetProcAddress,procName
cmp eax,3
jbe roof_gl_proc_alternate
cmp eax,-1
jne roof_gl_proc_done
roof_gl_proc_alternate:
invoke wglGetProcAddress,alternate
cmp eax,3
jbe roof_gl_proc_missing
cmp eax,-1
jne roof_gl_proc_done
roof_gl_proc_missing:
xor eax,eax
roof_gl_proc_done:
ret
RoofGLProc3D ENDP
LoadRoofMesh3D PROC uses ebx esi edi slot:DWORD,path:DWORD
local io:DWORD,allocation:DWORD
mov esi,slot
cmp DWORD PTR [esi+12],0
jne roof_mesh_ready
invoke CreateFileA,path,80000000h,1,0,3,80h,0
cmp eax,-1
je roof_mesh_failed
mov ebx,eax
invoke ReadFile,ebx,esi,12,ADDR io,0
test eax,eax
jz roof_mesh_close
cmp io,12
jne roof_mesh_close
cmp DWORD PTR [esi],314D4752h
jne roof_mesh_close
mov eax,[esi+4]
test eax,eax
jz roof_mesh_close
cmp eax,65000
ja roof_mesh_close
imul eax,100
cmp eax,[esi+8]
jne roof_mesh_close
invoke GetFileSize,ebx,0
sub eax,12
cmp eax,[esi+8]
jne roof_mesh_close
invoke GetProcessHeap
invoke HeapAlloc,eax,0,[esi+8]
test eax,eax
jz roof_mesh_close
mov allocation,eax
invoke ReadFile,ebx,allocation,[esi+8],ADDR io,0
test eax,eax
jz roof_mesh_free
mov eax,io
cmp eax,[esi+8]
jne roof_mesh_free
mov edi,allocation
mov ecx,[esi+4]
roof_mesh_validate:
mov eax,[edi]
cmp eax,ROOF_DECK
jb roof_mesh_free
cmp eax,209
ja roof_mesh_free
add edi,100
dec ecx
jnz roof_mesh_validate
invoke CloseHandle,ebx
mov eax,allocation
mov [esi+12],eax
roof_mesh_ready:
mov eax,1
ret
roof_mesh_free:
invoke GetProcessHeap
invoke HeapFree,eax,0,allocation
roof_mesh_close:
invoke CloseHandle,ebx
roof_mesh_failed:
xor eax,eax
ret
LoadRoofMesh3D ENDP
FreeRoofMesh3D PROC uses esi slot:DWORD
mov esi,slot
cmp DWORD PTR [esi+12],0
je @F
invoke GetProcessHeap
invoke HeapFree,eax,0,[esi+12]
mov DWORD PTR [esi+12],0
@@:
ret
FreeRoofMesh3D ENDP
UploadRoofGLTexture3D PROC pixels:DWORD,tw:DWORD,th:DWORD,texture:DWORD
invoke glBindTexture,0DE1h,texture
invoke glTexParameteri,0DE1h,2801h,2601h
invoke glTexParameteri,0DE1h,2800h,2601h
invoke glTexParameteri,0DE1h,2802h,2901h
invoke glTexParameteri,0DE1h,2803h,2901h
invoke glTexImage2D,0DE1h,0,8058h,tw,th,0,80E1h,1401h,pixels
cmp roofGLMipmap3D,0
je @F
push 0DE1h
call roofGLMipmap3D
invoke glTexParameteri,0DE1h,2801h,2703h
@@:
ret
UploadRoofGLTexture3D ENDP
UploadRoofGLSky3D PROC uses ebx esi edi pack:DWORD,texture:DWORD
local allocation:DWORD,tile:DWORD,row:DWORD
invoke GetProcessHeap
invoke HeapAlloc,eax,0,2048*512*4
test eax,eax
jz roof_gl_sky_failed
mov allocation,eax
mov tile,0
roof_gl_sky_tile:
mov row,0
roof_gl_sky_row:
mov esi,pack
mov eax,tile
shl eax,20
add eax,[esi].AnimPack3D.pixels
mov edx,row
shl edx,11
add eax,edx
mov esi,eax
mov eax,row
shl eax,13
add eax,allocation
mov edx,tile
shl edx,11
add eax,edx
mov edi,eax
mov ecx,512
rep movsd
inc row
cmp row,512
jb roof_gl_sky_row
inc tile
cmp tile,4
jb roof_gl_sky_tile
invoke UploadRoofGLTexture3D,allocation,2048,512,texture
invoke glTexParameteri,0DE1h,2803h,812Fh
invoke GetProcessHeap
invoke HeapFree,eax,0,allocation
mov eax,1
ret
roof_gl_sky_failed:
xor eax,eax
ret
UploadRoofGLSky3D ENDP
BuildRoofGLList3D PROC uses ebx esi edi mesh:DWORD,theme:DWORD,emission:DWORD,listId:DWORD
local count:DWORD,currentMat:DWORD,inside:DWORD,vertex:DWORD,texture:DWORD
mov esi,mesh
mov eax,[esi+4]
mov count,eax
mov esi,[esi+12]
mov currentMat,-1
mov inside,0
invoke glNewList,listId,1300h
roof_gl_list_triangle:
mov ebx,[esi]
cmp ebx,currentMat
je roof_gl_list_vertices
cmp inside,0
je @F
invoke glEnd
mov inside,0
@@:
mov currentMat,ebx
sub ebx,ROOF_DECK
mov eax,roofHDDayTextures3D[ebx*4]
cmp theme,0
je @F
mov eax,roofHDNightTextures3D[ebx*4]
@@:
cmp emission,0
je @F
mov eax,roofHDEmissionTextures3D[ebx*4]
@@:
mov texture,eax
test eax,eax
jz roof_gl_list_skip
cmp currentMat,ROOF_CITY_WATER
je roof_gl_list_skip
invoke glBindTexture,0DE1h,texture
cmp emission,0
jne roof_gl_list_begin
invoke glMaterialfv,408h,1600h,OFFSET roofGLEmissionZero3D
cmp theme,0
je roof_gl_list_surface
cmp currentMat,ROOF_LIGHT
jne @F
invoke glMaterialfv,408h,1600h,OFFSET roofGLEmissionLamp3D
@@:
cmp currentMat,ROOF_BRASS
jne roof_gl_list_surface
invoke glMaterialfv,408h,1600h,OFFSET roofGLEmissionGold3D
roof_gl_list_surface:
cmp currentMat,208
jne roof_gl_list_opaque
invoke glDisable,0B50h
invoke glEnable,0B60h
invoke glFogfv,0B66h,OFFSET roofGLFogWhite3D
invoke glEnable,0BE2h
invoke glBlendFunc,306h,0
invoke glDepthMask,0
jmp roof_gl_list_begin
roof_gl_list_opaque:
invoke glDisable,8037h
cmp currentMat,ROOF_CITY_ROAD
jne @F
invoke glEnable,8037h
invoke glPolygonOffset,0BF800000h,0BF800000h
@@:
invoke glEnable,0B50h
invoke glEnable,0B60h
invoke glDisable,0BE2h
invoke glDepthMask,1
roof_gl_list_begin:
invoke glBegin,4
mov inside,1
roof_gl_list_vertices:
cmp inside,0
je roof_gl_list_skip
lea edi,[esi+4]
mov vertex,3
roof_gl_list_vertex:
invoke glNormal3f,[edi+12],[edi+16],[edi+20]
invoke glTexCoord2f,[edi+24],[edi+28]
invoke glVertex3f,[edi],[edi+4],[edi+8]
add edi,32
dec vertex
jnz roof_gl_list_vertex
roof_gl_list_skip:
add esi,100
dec count
jnz roof_gl_list_triangle
cmp inside,0
je @F
invoke glEnd
@@:
invoke glEndList
ret
BuildRoofGLList3D ENDP
InitRoofHD3D PROC uses ebx esi edi
local maxTexture:DWORD,oldTheme:DWORD,allocation:DWORD,model:DWORD,theme:DWORD
cmp roofHDReady3D,0
jne roof_hd_init_status
mov roofHDReady3D,-1
mov roofHDStage3D,1
cmp roofSkyArt3D.pixels,0
je roof_hd_init_failed
cmp roofNightArt3D.pixels,0
je roof_hd_init_failed
cmp roofCityArt3D.pixels,0
je roof_hd_init_failed
cmp roofCityNightArt3D.pixels,0
je roof_hd_init_failed
cmp roofMaterialArt3D.pixels,0
je roof_hd_init_failed
cmp roofDetailArt3D.pixels,0
je roof_hd_init_failed
cmp roofLightingArt3D.pixels,0
je roof_hd_init_failed
cmp roofLightingArt3D.frames,3
jb roof_hd_init_failed
invoke GetModuleHandleA,0
mov roofHDModule3D,eax
mov roofHDClass3D[16],eax
invoke RegisterClassA,OFFSET roofHDClass3D
invoke CreateWindowExA,0,OFFSET roofHDClassName3D,OFFSET roofHDTitle3D,86000000h,0,0,ROOF_HD_W,ROOF_HD_H,0,0,roofHDModule3D,0
test eax,eax
jz roof_hd_init_failed
mov roofHDWindow3D,eax
invoke GetDC,eax
mov roofHDDC3D,eax
invoke ChoosePixelFormat,eax,OFFSET roofHDPixelFormat3D
test eax,eax
jz roof_hd_init_failed
invoke SetPixelFormat,roofHDDC3D,eax,OFFSET roofHDPixelFormat3D
test eax,eax
jz roof_hd_init_failed
invoke wglCreateContext,roofHDDC3D
test eax,eax
jz roof_hd_init_failed
mov roofHDRC3D,eax
invoke wglMakeCurrent,roofHDDC3D,eax
test eax,eax
jz roof_hd_init_failed
mov roofHDStage3D,2
xor esi,esi
roof_hd_load_gl_proc:
invoke RoofGLProc3D,roofGLProcNames3D[esi*4],roofGLProcExtNames3D[esi*4]
mov edi,roofGLProcSlots3D[esi*4]
mov [edi],eax
test eax,eax
jnz roof_hd_gl_proc_ready
cmp esi,10
jne roof_hd_init_failed
roof_hd_gl_proc_ready:
inc esi
cmp esi,11
jb roof_hd_load_gl_proc
invoke glGetIntegerv,0D33h,ADDR maxTexture
cmp maxTexture,2048
jb roof_hd_init_failed
mov roofHDStage3D,3
push OFFSET roofHDFBO3D
push 1
call roofGLGenFBO3D
push roofHDFBO3D
push 8D40h
call roofGLBindFBO3D
invoke glGenTextures,1,OFFSET roofHDColorTex3D
invoke glBindTexture,0DE1h,roofHDColorTex3D
invoke glTexParameteri,0DE1h,2801h,2601h
invoke glTexImage2D,0DE1h,0,8058h,ROOF_HD_W,ROOF_HD_H,0,1908h,1401h,0
push 0
push roofHDColorTex3D
push 0DE1h
push 8CE0h
push 8D40h
call roofGLAttachTexture3D
push OFFSET roofHDDepth3D
push 1
call roofGLGenRBO3D
push roofHDDepth3D
push 8D41h
call roofGLBindRBO3D
push ROOF_HD_H
push ROOF_HD_W
push 81A6h
push 8D41h
call roofGLStoreRBO3D
push roofHDDepth3D
push 8D41h
push 8D00h
push 8D40h
call roofGLAttachRBO3D
push 8D40h
call roofGLCheckFBO3D
cmp eax,8CD5h
jne roof_hd_init_failed
invoke glDrawBuffer,8CE0h
invoke glReadBuffer,8CE0h
invoke GetProcessHeap
invoke HeapAlloc,eax,8,ROOF_HD_W*ROOF_HD_H*4
test eax,eax
jz roof_hd_init_failed
mov roofHDBuffer3D,eax
mov roofHDStage3D,4
invoke LoadRoofMesh3D,OFFSET roofHDMeshScene3D,OFFSET roofHDScenePath3D
test eax,eax
jz roof_hd_init_failed
invoke LoadRoofMesh3D,OFFSET roofHDMeshCar3D,OFFSET roofHDCarPath3D
test eax,eax
jz roof_hd_init_failed
invoke LoadRoofMesh3D,OFFSET roofHDMeshBoat3D,OFFSET roofHDBoatPath3D
test eax,eax
jz roof_hd_init_failed
lea edi,roofHDUsedMaterials3D
xor eax,eax
mov ecx,ROOF_GL_TEXTURES
rep stosb
mov model,0
roof_hd_collect_materials:
mov ebx,model
mov esi,roofHDMeshPtrs3D[ebx*4]
mov ecx,[esi+4]
mov esi,[esi+12]
roof_hd_collect_triangle:
mov eax,[esi]
sub eax,ROOF_DECK
mov roofHDUsedMaterials3D[eax],1
add esi,100
dec ecx
jnz roof_hd_collect_triangle
inc model
cmp model,3
jb roof_hd_collect_materials
invoke glGenTextures,ROOF_GL_TEXTURES,OFFSET roofHDDayTextures3D
invoke glGenTextures,ROOF_GL_TEXTURES,OFFSET roofHDNightTextures3D
invoke glGenTextures,ROOF_GL_TEXTURES,OFFSET roofHDEmissionTextures3D
mov eax,roofNight3D
mov oldTheme,eax
mov theme,0
roof_hd_upload_theme:
mov eax,theme
mov roofNight3D,eax
mov esi,ROOF_DECK
roof_hd_upload_material:
mov ebx,esi
sub ebx,ROOF_DECK
cmp roofHDUsedMaterials3D[ebx],0
jne roof_hd_upload_used
mov roofHDDayTextures3D[ebx*4],0
mov roofHDNightTextures3D[ebx*4],0
jmp roof_hd_upload_next
roof_hd_upload_used:
cmp theme,0
je roof_hd_upload_pixels
cmp esi,ROOF_FACADE
jb roof_hd_share_material
cmp esi,ROOF_FACADE+7
jbe roof_hd_upload_pixels
cmp esi,ROOF_MODERN_FACADE
jb roof_hd_share_material
cmp esi,ROOF_MODERN_FACADE+7
jbe roof_hd_upload_pixels
roof_hd_share_material:
mov eax,roofHDDayTextures3D[ebx*4]
mov roofHDNightTextures3D[ebx*4],eax
jmp roof_hd_upload_next
roof_hd_upload_pixels:
invoke ResolveRoofSurface3D,esi
mov edi,roofHDDayTextures3D[ebx*4]
cmp theme,0
je @F
mov edi,roofHDNightTextures3D[ebx*4]
@@:
invoke UploadRoofGLTexture3D,eax,ecx,edx,edi
roof_hd_upload_next:
inc esi
cmp esi,ROOF_LAST_MATERIAL
jbe roof_hd_upload_material
mov esi,OFFSET roofLightingArt3D
mov eax,theme
shl eax,20
add eax,[esi].AnimPack3D.pixels
mov edi,roofHDDayTextures3D[47*4]
cmp theme,0
je @F
mov edi,roofHDNightTextures3D[47*4]
@@:
invoke UploadRoofGLTexture3D,eax,512,512,edi
invoke glTexParameteri,0DE1h,2802h,812Fh
invoke glTexParameteri,0DE1h,2803h,812Fh
inc theme
cmp theme,2
jb roof_hd_upload_theme
mov roofHDDayTextures3D[48*4],0
mov roofHDNightTextures3D[48*4],0
mov roofHDStage3D,5
invoke GetProcessHeap
invoke HeapAlloc,eax,0,512*512*4
test eax,eax
jz roof_hd_restore_failed
mov allocation,eax
mov esi,ROOF_DECK
roof_hd_emission_material:
mov ebx,esi
sub ebx,ROOF_DECK
cmp roofHDUsedMaterials3D[ebx],0
je roof_hd_emission_empty
cmp esi,ROOF_FACADE
jb roof_hd_emission_empty
cmp esi,ROOF_FACADE+7
jbe roof_hd_emission_create
cmp esi,ROOF_MODERN_FACADE
jb roof_hd_emission_empty
cmp esi,ROOF_MODERN_FACADE+7
ja roof_hd_emission_empty
roof_hd_emission_create:
invoke ResolveRoofSurface3D,esi
mov ebx,eax
mov edi,allocation
mov ecx,512*512
roof_hd_emission_pixel:
mov eax,[ebx]
cmp eax,0FF000000h
jae @F
xor eax,eax
@@:
stosd
add ebx,4
dec ecx
jnz roof_hd_emission_pixel
mov ebx,esi
sub ebx,ROOF_DECK
invoke UploadRoofGLTexture3D,allocation,512,512,roofHDEmissionTextures3D[ebx*4]
jmp roof_hd_emission_next
roof_hd_emission_empty:
mov ebx,esi
sub ebx,ROOF_DECK
; No emission list binds these handles; zero is an explicit skipped material.
mov roofHDEmissionTextures3D[ebx*4],0
roof_hd_emission_next:
inc esi
cmp esi,ROOF_LAST_MATERIAL
jbe roof_hd_emission_material
mov roofHDEmissionTextures3D[47*4],0
mov eax,roofLightingArt3D.pixels
add eax,2*512*512*4
invoke UploadRoofGLTexture3D,eax,512,512,roofHDEmissionTextures3D[48*4]
invoke glTexParameteri,0DE1h,2802h,812Fh
invoke glTexParameteri,0DE1h,2803h,812Fh
invoke GetProcessHeap
invoke HeapFree,eax,0,allocation
mov eax,oldTheme
mov roofNight3D,eax
invoke glGenTextures,2,OFFSET roofHDSkyTextures3D
invoke UploadRoofGLSky3D,OFFSET roofSkyArt3D,roofHDSkyTextures3D[0]
test eax,eax
jz roof_hd_init_failed
invoke UploadRoofGLSky3D,OFFSET roofNightArt3D,roofHDSkyTextures3D[4]
test eax,eax
jz roof_hd_init_failed
invoke glGenLists,9
test eax,eax
jz roof_hd_init_failed
mov roofHDLists3D,eax
mov model,0
roof_hd_compile_model:
mov ebx,model
mov edi,roofHDMeshPtrs3D[ebx*4]
imul ebx,3
add ebx,roofHDLists3D
invoke BuildRoofGLList3D,edi,0,0,ebx
inc ebx
invoke BuildRoofGLList3D,edi,1,0,ebx
inc ebx
invoke BuildRoofGLList3D,edi,1,1,ebx
inc model
cmp model,3
jb roof_hd_compile_model
invoke FreeRoofMesh3D,OFFSET roofHDMeshScene3D
invoke FreeRoofMesh3D,OFFSET roofHDMeshCar3D
invoke FreeRoofMesh3D,OFFSET roofHDMeshBoat3D
invoke CreateCompatibleDC,0
test eax,eax
jz roof_hd_init_failed
mov roofHDOverlayDC3D,eax
invoke CreateDIBSection,eax,OFFSET roofHDOverlayBMI3D,0,OFFSET roofHDOverlayPixels3D,0,0
test eax,eax
jz roof_hd_init_failed
mov roofHDOverlayBmp3D,eax
invoke SelectObject,roofHDOverlayDC3D,eax
mov roofHDOverlayOld3D,eax
invoke CreateCompatibleDC,0
test eax,eax
jz roof_hd_init_failed
mov roofHDFinalDC3D,eax
invoke CreateDIBSection,eax,OFFSET roofHDBMI3D,0,OFFSET roofHDFinalPixels3D,0,0
test eax,eax
jz roof_hd_init_failed
mov roofHDFinalBmp3D,eax
invoke SelectObject,roofHDFinalDC3D,eax
mov roofHDFinalOld3D,eax
invoke glGetError
test eax,eax
jnz roof_hd_init_failed
mov roofHDReady3D,1
mov roofHDStage3D,0
call WriteRoofRendererInfo3D
roof_hd_init_status:
xor eax,eax
cmp roofHDReady3D,1
sete al
ret
roof_hd_restore_failed:
mov eax,oldTheme
mov roofNight3D,eax
roof_hd_init_failed:
call WriteRoofRendererInfo3D
call FreeRoofHD3D
mov roofHDReady3D,-1
xor eax,eax
ret
InitRoofHD3D ENDP
DrawRoofGLSky3D PROC uses ebx esi edi
local px:DWORD,x0:REAL4,x1:REAL4,u0:REAL4,u1:REAL4,v0:REAL4,v1:REAL4
local skyWidth:DWORD,logicalHeight:DWORD
local fadeTop:REAL4,fadeBottom:REAL4,fadePixel:DWORD
mov skyWidth,2048
invoke glDisable,0B44h
mov logicalHeight,480
invoke glDisable,0B71h
invoke glDisable,0B50h
invoke glDisable,0B60h
invoke glDisable,0BE2h
invoke glEnable,0DE1h
invoke glDepthMask,0
invoke glColor4f,3F800000h,3F800000h,3F800000h,3F800000h
invoke glMatrixMode,1701h
invoke glLoadIdentity
invoke glOrtho,DWORD PTR roofGLZeroD3D,DWORD PTR roofGLZeroD3D+4,DWORD PTR roofGLScreenWidthD3D,DWORD PTR roofGLScreenWidthD3D+4,DWORD PTR roofGLZeroD3D,DWORD PTR roofGLZeroD3D+4,DWORD PTR roofGLScreenHeightD3D,DWORD PTR roofGLScreenHeightD3D+4,DWORD PTR roofGLMinusOneD3D,DWORD PTR roofGLMinusOneD3D+4,DWORD PTR roofGLOneD3D,DWORD PTR roofGLOneD3D+4
invoke glMatrixMode,1700h
invoke glLoadIdentity
mov eax,roofNight3D
invoke glBindTexture,0DE1h,roofHDSkyTextures3D[eax*4]
mov eax,HALF_H
sub eax,viewHorizon3D
mov px,eax
fild px
fidiv logicalHeight
fst v0
fld1
faddp st(1),st
fstp v1
mov px,0
roof_hd_sky_segment:
mov ebx,px
fild px
fstp x0
add px,16
fild px
fstp x1
shr ebx,1
mov eax,roofSkyColumns3D[ebx*4]
mov ecx,playerAngle
shl ecx,2
add eax,ecx
mov skyWidth,2048
mov ebx,eax
push eax
fild DWORD PTR [esp]
add esp,4
fidiv skyWidth
fstp u0
mov ebx,px
shr ebx,1
cmp ebx,639
jbe @F
mov ebx,639
@@:
mov eax,roofSkyColumns3D[ebx*4]
mov ecx,playerAngle
shl ecx,2
add eax,ecx
push eax
fild DWORD PTR [esp]
add esp,4
fidiv skyWidth
fstp u1
invoke glBegin,7
invoke glTexCoord2f,DWORD PTR u0,DWORD PTR v1
invoke glVertex3f,DWORD PTR x0,0,0
invoke glTexCoord2f,DWORD PTR u1,DWORD PTR v1
invoke glVertex3f,DWORD PTR x1,0,0
invoke glTexCoord2f,DWORD PTR u1,DWORD PTR v0
invoke glVertex3f,DWORD PTR x1,44700000h,0
invoke glTexCoord2f,DWORD PTR u0,DWORD PTR v0
invoke glVertex3f,DWORD PTR x0,44700000h,0
invoke glEnd
cmp px,ROOF_HD_W
jb roof_hd_sky_segment
; The atmospheric horizon blends into the same haze as distant geometry.
mov eax,viewHorizon3D
shl eax,1
neg eax
add eax,ROOF_HD_H+120
mov fadePixel,eax
fild fadePixel
fstp fadeTop
sub fadePixel,210
fild fadePixel
fstp fadeBottom
invoke glDisable,0DE1h
invoke glEnable,0BE2h
invoke glBlendFunc,302h,303h
invoke glBegin,7
invoke glColor4f,DWORD PTR roofGLFogCurrent3D[0],DWORD PTR roofGLFogCurrent3D[4],DWORD PTR roofGLFogCurrent3D[8],3F800000h
invoke glVertex3f,0,0,0
invoke glVertex3f,44A00000h,0,0
invoke glVertex3f,44A00000h,DWORD PTR fadeBottom,0
invoke glVertex3f,0,DWORD PTR fadeBottom,0
invoke glVertex3f,0,DWORD PTR fadeBottom,0
invoke glVertex3f,44A00000h,DWORD PTR fadeBottom,0
invoke glColor4f,DWORD PTR roofGLFogCurrent3D[0],DWORD PTR roofGLFogCurrent3D[4],DWORD PTR roofGLFogCurrent3D[8],0
invoke glVertex3f,44A00000h,DWORD PTR fadeTop,0
invoke glVertex3f,0,DWORD PTR fadeTop,0
invoke glEnd
invoke glDisable,0BE2h
invoke glEnable,0DE1h
invoke glColor4f,3F800000h,3F800000h,3F800000h,3F800000h
ret
DrawRoofGLSky3D ENDP
DrawRoofGLTraffic3D PROC uses ebx esi edi
local px:DWORD,py:DWORD,fx:REAL4,fy:REAL4,level:REAL4,angle:DWORD,listId:DWORD
xor esi,esi
roof_hd_car:
imul eax,esi,17000
add eax,animationClock3D
mov ecx,393
mul ecx
mov ecx,340*FP_1
div ecx
sub edx,160*FP_1
mov px,edx
mov py,-FP_1*59/10
mov angle,0
test esi,1
jz @F
neg edx
mov px,edx
mov py,-FP_1*81/10
mov angle,43340000h
@@:
cmp esi,4
jb roof_hd_car_pose
mov eax,px
mov py,eax
mov px,FP_1*391/10
mov angle,42B40000h
test esi,1
jz roof_hd_car_pose
mov px,FP_1*369/10
mov angle,43870000h
roof_hd_car_pose:
fild px
fmul roofGLInvFP3D
fstp fx
fild py
fmul roofGLInvFP3D
fstp fy
invoke glPushMatrix
invoke glTranslatef,DWORD PTR fx,0C2700000h,DWORD PTR fy
invoke glRotatef,angle,0,3F800000h,0
mov ebx,roofHDLists3D
add ebx,3
add ebx,roofNight3D
invoke glCallList,ebx
cmp roofNight3D,0
je roof_hd_car_pop
invoke glDisable,0B50h
invoke glDisable,0B60h
invoke glEnable,0BE2h
invoke glBlendFunc,1,1
invoke glEnable,8037h
invoke glPolygonOffset,0BF800000h,0BF800000h
invoke glDepthMask,0
mov eax,roofHDLists3D
add eax,5
invoke glCallList,eax
invoke glDisable,8037h
invoke glDepthMask,1
roof_hd_car_pop:
invoke glPopMatrix
inc esi
cmp esi,8
jb roof_hd_car
xor esi,esi
roof_hd_boat:
imul eax,esi,47000
add eax,animationClock3D
mov ecx,98
mul ecx
mov ecx,340*FP_1
div ecx
sub edx,160*FP_1
mov px,edx
mov py,68*FP_1
cmp esi,3
jb roof_hd_boat_pose
imul eax,esi,61000
add eax,animationClock3D
mov ecx,98
mul ecx
mov ecx,660*FP_1
div ecx
add edx,90*FP_1
mov px,edx
mov py,44*FP_1
test esi,1
jz roof_hd_boat_pose
mov py,63*FP_1
roof_hd_boat_pose:
fild px
fmul roofGLInvFP3D
fstp fx
fild py
fmul roofGLInvFP3D
fstp fy
invoke glPushMatrix
invoke glTranslatef,DWORD PTR fx,0C2700000h,DWORD PTR fy
mov eax,roofHDLists3D
add eax,6
add eax,roofNight3D
invoke glCallList,eax
invoke glPopMatrix
inc esi
cmp esi,6
jb roof_hd_boat
ret
DrawRoofGLTraffic3D ENDP
DrawRoofGLWater3D PROC uses ebx esi
local ticks:DWORD,flowX:REAL4,flowY:REAL4
mov eax,animationClock3D
xor edx,edx
mov ecx,200000
div ecx
mov ticks,edx
fild ticks
fdiv roofGLWaveDiv3D
fst flowX
fmul roofGLHalf3D
fstp flowY
invoke glMatrixMode,1702h
invoke glLoadIdentity
invoke glTranslatef,DWORD PTR flowX,DWORD PTR flowY,0
invoke glMatrixMode,1700h
mov eax,roofHDDayTextures3D[(ROOF_CITY_WATER-ROOF_DECK)*4]
cmp roofNight3D,0
je @F
mov eax,roofHDNightTextures3D[(ROOF_CITY_WATER-ROOF_DECK)*4]
@@:
invoke glBindTexture,0DE1h,eax
invoke glNormal3f,0,3F800000h,0
invoke glBegin,7
mov esi,OFFSET roofGLWaterVertices3D
mov ebx,8
roof_gl_water_vertex:
invoke glTexCoord2f,[esi+12],[esi+16]
invoke glVertex3f,[esi],[esi+4],[esi+8]
add esi,20
dec ebx
jnz roof_gl_water_vertex
invoke glEnd
invoke glMatrixMode,1702h
invoke glLoadIdentity
invoke glMatrixMode,1700h
ret
DrawRoofGLWater3D ENDP
UpdateRoofGLFog3D PROC uses ebx esi
local channel:DWORD
mov esi,roofSkyArt3D.pixels
cmp roofNight3D,0
je @F
mov esi,roofNightArt3D.pixels
@@:
mov eax,playerAngle
shl eax,2
and eax,2047
mov edx,eax
shr edx,9
shl edx,20
add esi,edx
and eax,511
lea esi,[esi+eax*4+256*512*4]
movzx eax,BYTE PTR [esi+2]
mov channel,eax
fild channel
fdiv roofGLColorScale3D
fstp roofGLFogCurrent3D[0]
movzx eax,BYTE PTR [esi+1]
mov channel,eax
fild channel
fdiv roofGLColorScale3D
fstp roofGLFogCurrent3D[4]
movzx eax,BYTE PTR [esi]
mov channel,eax
fild channel
fdiv roofGLColorScale3D
fstp roofGLFogCurrent3D[8]
ret
UpdateRoofGLFog3D ENDP
RenderRoofHD3D PROC uses ebx esi edi
local left:REAL8,right:REAL8,bottom:REAL8,top:REAL8
local angle:REAL4,px:REAL4,py:REAL4,eye:REAL4,clock:DWORD
call UpdateRoofQuality3D
invoke InitRoofHD3D
test eax,eax
jz roof_hd_render_failed
mov eax,animationClock3D
xor edx,edx
mov ecx,33
div ecx
mov clock,eax
cmp eax,roofHDRenderClock3D
jne roof_hd_render_refresh
mov eax,playerX
cmp eax,roofHDRenderX3D
jne roof_hd_render_refresh
mov eax,playerY
cmp eax,roofHDRenderY3D
jne roof_hd_render_refresh
mov eax,playerAngle
cmp eax,roofHDRenderAngle3D
jne roof_hd_render_refresh
mov eax,viewEye3D
cmp eax,roofHDRenderEye3D
jne roof_hd_render_refresh
mov eax,viewHorizon3D
cmp eax,roofHDRenderHorizon3D
jne roof_hd_render_refresh
mov eax,roofNight3D
cmp eax,roofHDRenderTheme3D
je roof_hd_render_ready
roof_hd_render_refresh:
invoke wglMakeCurrent,roofHDDC3D,roofHDRC3D
push roofHDFBO3D
push 8D40h
call roofGLBindFBO3D
invoke glViewport,0,0,roofRenderW3D,roofRenderH3D
invoke glDepthMask,1
invoke glClearColor,0,0,0,3F800000h
invoke glClear,4100h
call UpdateRoofGLFog3D
call DrawRoofGLSky3D
invoke glEnable,0B71h
invoke glDepthFunc,203h
invoke glDepthMask,1
invoke glEnable,0B44h
invoke glFrontFace,901h
invoke glCullFace,405h
invoke glEnable,0DE1h
invoke glEnable,0B50h
invoke glEnable,4000h
invoke glEnable,0BA1h
invoke glEnable,0B57h
invoke glColorMaterial,408h,1602h
invoke glColor4f,3F800000h,3F800000h,3F800000h,3F800000h
invoke glShadeModel,1D01h
invoke glEnable,0B60h
invoke glFogi,0B65h,801h
invoke glFogf,0B62h,3B2A64C3h
mov eax,OFFSET roofGLFogCurrent3D
mov ebx,OFFSET roofGLAmbientDay3D
mov esi,OFFSET roofGLSunColorDay3D
cmp roofNight3D,0
je @F
mov ebx,OFFSET roofGLAmbientNight3D
mov esi,OFFSET roofGLSunColorNight3D
@@:
invoke glFogfv,0B66h,eax
invoke glLightModelfv,0B53h,ebx
invoke glLightfv,4000h,1201h,esi
fild viewHorizon3D
fidiv roofGLCameraH3D
fst top
fld1
fsubp st(1),st
fstp bottom
invoke glMatrixMode,1701h
invoke glLoadIdentity
invoke glFrustum,DWORD PTR roofGLLeft3D,DWORD PTR roofGLLeft3D+4,DWORD PTR roofGLRight3D,DWORD PTR roofGLRight3D+4,DWORD PTR bottom,DWORD PTR bottom+4,DWORD PTR top,DWORD PTR top+4,DWORD PTR roofGLNear3D,DWORD PTR roofGLNear3D+4,DWORD PTR roofGLFar3D,DWORD PTR roofGLFar3D+4
invoke glMatrixMode,1700h
invoke glLoadIdentity
fild playerAngle
fmul roofGLDegrees3D
fadd roofGLNinety3D
fstp angle
invoke glRotatef,DWORD PTR angle,0,3F800000h,0
fild playerX
fmul roofGLInvFP3D
fchs
fstp px
fild playerY
fmul roofGLInvFP3D
fchs
fstp py
fild viewEye3D
fmul roofGLInvFP3D
fchs
fstp eye
invoke glTranslatef,DWORD PTR px,DWORD PTR eye,DWORD PTR py
invoke glLightfv,4000h,1203h,OFFSET roofGLSunDirection3D
invoke glMaterialfv,408h,1600h,OFFSET roofGLEmissionZero3D
invoke glDisable,0BE2h
call DrawRoofGLWater3D
mov eax,roofHDLists3D
add eax,roofNight3D
invoke glCallList,eax
cmp roofNight3D,0
je roof_hd_render_traffic
invoke glDisable,0B50h
invoke glEnable,0B60h
invoke glFogfv,0B66h,OFFSET roofGLFogBlack3D
invoke glEnable,0BE2h
invoke glBlendFunc,1,1
invoke glEnable,8037h
invoke glPolygonOffset,0BF800000h,0BF800000h
invoke glDepthMask,0
mov eax,roofHDLists3D
add eax,2
invoke glCallList,eax
invoke glDisable,8037h
invoke glDepthMask,1
roof_hd_render_traffic:
invoke glFogfv,0B66h,OFFSET roofGLFogCurrent3D
call DrawRoofGLTraffic3D
invoke glReadPixels,0,0,roofRenderW3D,roofRenderH3D,80E1h,1401h,roofHDBuffer3D
invoke glGetError
test eax,eax
jnz roof_hd_render_failed
mov eax,playerX
mov roofHDRenderX3D,eax
mov eax,playerY
mov roofHDRenderY3D,eax
mov eax,playerAngle
mov roofHDRenderAngle3D,eax
mov eax,viewEye3D
mov roofHDRenderEye3D,eax
mov eax,viewHorizon3D
mov roofHDRenderHorizon3D,eax
mov eax,roofNight3D
mov roofHDRenderTheme3D,eax
mov eax,clock
mov roofHDRenderClock3D,eax
roof_hd_render_ready:
mov eax,1
ret
roof_hd_render_failed:
call FreeRoofHD3D
mov roofHDReady3D,-1
xor eax,eax
ret
RenderRoofHD3D ENDP
PresentRoofHD3D PROC uses ebx esi edi dc:DWORD,left:DWORD,top:DWORD,viewW:DWORD,viewH:DWORD
cmp hallLevel3D,HALL_ROOF
jne roof_hd_present_fallback
cmp engineMode,MODE_WALK
jne roof_hd_present_fallback
call RenderRoofHD3D
test eax,eax
jz roof_hd_present_fallback
call ComposeRoofFrame3D
invoke StretchBlt,dc,left,top,viewW,viewH,roofHDFinalDC3D,0,0,roofRenderW3D,roofRenderH3D,SRCCOPY
ret
roof_hd_present_fallback:
xor eax,eax
ret
PresentRoofHD3D ENDP
FreeRoofHD3D PROC uses ebx esi edi
cmp roofHDRC3D,0
je roof_hd_free_windows
invoke wglMakeCurrent,roofHDDC3D,roofHDRC3D
cmp roofHDLists3D,0
je @F
invoke glDeleteLists,roofHDLists3D,9
mov roofHDLists3D,0
@@:
invoke glDeleteTextures,ROOF_GL_TEXTURES,OFFSET roofHDDayTextures3D
invoke glDeleteTextures,ROOF_GL_TEXTURES,OFFSET roofHDNightTextures3D
invoke glDeleteTextures,ROOF_GL_TEXTURES,OFFSET roofHDEmissionTextures3D
invoke glDeleteTextures,2,OFFSET roofHDSkyTextures3D
cmp roofHDFBO3D,0
je @F
cmp roofGLDeleteFBO3D,0
je @F
push OFFSET roofHDFBO3D
push 1
call roofGLDeleteFBO3D
mov roofHDFBO3D,0
@@:
cmp roofHDDepth3D,0
je @F
cmp roofGLDeleteRBO3D,0
je @F
push OFFSET roofHDDepth3D
push 1
call roofGLDeleteRBO3D
mov roofHDDepth3D,0
@@:
invoke glDeleteTextures,1,OFFSET roofHDColorTex3D
invoke wglMakeCurrent,0,0
invoke wglDeleteContext,roofHDRC3D
mov roofHDRC3D,0
roof_hd_free_windows:
cmp roofHDFinalDC3D,0
je @F
invoke SelectObject,roofHDFinalDC3D,roofHDFinalOld3D
invoke DeleteDC,roofHDFinalDC3D
mov roofHDFinalDC3D,0
@@:
cmp roofHDFinalBmp3D,0
je @F
invoke DeleteObject,roofHDFinalBmp3D
mov roofHDFinalBmp3D,0
@@:
cmp roofHDOverlayDC3D,0
je @F
invoke SelectObject,roofHDOverlayDC3D,roofHDOverlayOld3D
invoke DeleteDC,roofHDOverlayDC3D
mov roofHDOverlayDC3D,0
@@:
cmp roofHDOverlayBmp3D,0
je @F
invoke DeleteObject,roofHDOverlayBmp3D
mov roofHDOverlayBmp3D,0
@@:
cmp roofHDDC3D,0
je @F
invoke ReleaseDC,roofHDWindow3D,roofHDDC3D
mov roofHDDC3D,0
@@:
cmp roofHDWindow3D,0
je @F
invoke DestroyWindow,roofHDWindow3D
mov roofHDWindow3D,0
@@:
cmp roofHDBuffer3D,0
je @F
invoke GetProcessHeap
invoke HeapFree,eax,0,roofHDBuffer3D
mov roofHDBuffer3D,0
@@:
invoke FreeRoofMesh3D,OFFSET roofHDMeshScene3D
invoke FreeRoofMesh3D,OFFSET roofHDMeshCar3D
invoke FreeRoofMesh3D,OFFSET roofHDMeshBoat3D
mov roofHDReady3D,0
mov roofHDRenderClock3D,-1
ret
FreeRoofHD3D ENDP