215 lines
5 KiB
PHP
215 lines
5 KiB
PHP
FreeCinematicMaster3D PROC
|
|
cmp cinemaFile,-1
|
|
je @F
|
|
invoke CloseHandle,cinemaFile
|
|
mov cinemaFile,-1
|
|
@@:
|
|
cmp cinemaCompressed,0
|
|
je @F
|
|
invoke GetProcessHeap
|
|
invoke HeapFree,eax,0,cinemaCompressed
|
|
mov cinemaCompressed,0
|
|
@@:
|
|
cmp cinemaPixels,0
|
|
je @F
|
|
invoke GetProcessHeap
|
|
invoke HeapFree,eax,0,cinemaPixels
|
|
mov cinemaPixels,0
|
|
@@:
|
|
mov cinemaCachedFrame,-1
|
|
cmp cinemaPacked,0
|
|
je @F
|
|
invoke GetProcessHeap
|
|
invoke HeapFree,eax,0,cinemaPacked
|
|
mov cinemaPacked,0
|
|
@@:
|
|
ret
|
|
FreeCinematicMaster3D ENDP
|
|
|
|
LoadCinematicMaster3D PROC uses ebx esi edi
|
|
local count:DWORD,indexBytes:DWORD,minOffset:DWORD
|
|
cmp cinemaFile,-1
|
|
jne cinema_load_ready
|
|
invoke GetModuleHandleA,OFFSET cinemaNtDll
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
invoke GetProcAddress,eax,OFFSET cinemaDecoderName
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
mov cinemaDecoder,eax
|
|
invoke CreateFileA,cinemaPathPtr,80000000h,1,0,3,80h,0
|
|
cmp eax,-1
|
|
je cinema_load_failure
|
|
mov cinemaFile,eax
|
|
invoke GetFileSize,eax,0
|
|
cmp eax,256*1024*1024
|
|
ja cinema_load_failure
|
|
mov cinemaFileBytes,eax
|
|
invoke ReadFile,cinemaFile,OFFSET cinemaHeader,32,ADDR count,0
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
cmp count,32
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader,334D4643h
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[4],3
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[8],30
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[12],600
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[16],SCREEN_W
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[20],SCREEN_H
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[24],SCREEN_SIZE*2
|
|
jne cinema_load_failure
|
|
cmp cinemaHeader[28],SCREEN_SIZE*2+4096
|
|
jne cinema_load_failure
|
|
mov indexBytes,600*8
|
|
mov minOffset,32+600*8
|
|
invoke ReadFile,cinemaFile,OFFSET cinemaIndex,indexBytes,ADDR count,0
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
cmp count,600*8
|
|
jne cinema_load_failure
|
|
xor esi,esi
|
|
mov ebx,32+600*8
|
|
cinema_validate_entry:
|
|
mov eax,cinemaIndex[esi*8]
|
|
cmp eax,ebx
|
|
jne cinema_load_failure
|
|
mov edx,cinemaIndex[esi*8+4]
|
|
test edx,edx
|
|
jz cinema_load_failure
|
|
cmp edx,SCREEN_SIZE*2+4096
|
|
ja cinema_load_failure
|
|
add eax,edx
|
|
jc cinema_load_failure
|
|
cmp eax,cinemaFileBytes
|
|
ja cinema_load_failure
|
|
mov ebx,eax
|
|
inc esi
|
|
cmp esi,600
|
|
jb cinema_validate_entry
|
|
cmp ebx,cinemaFileBytes
|
|
jne cinema_load_failure
|
|
invoke GetProcessHeap
|
|
invoke HeapAlloc,eax,0,SCREEN_SIZE*2+4096
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
mov cinemaCompressed,eax
|
|
invoke GetProcessHeap
|
|
invoke HeapAlloc,eax,0,SCREEN_SIZE*4
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
mov cinemaPixels,eax
|
|
invoke GetProcessHeap
|
|
invoke HeapAlloc,eax,0,SCREEN_SIZE*2
|
|
test eax,eax
|
|
jz cinema_load_failure
|
|
mov cinemaPacked,eax
|
|
xor edx,edx
|
|
cinema_build_color_table:
|
|
mov eax,edx
|
|
and eax,31
|
|
mov ebx,eax
|
|
shl eax,3
|
|
shr ebx,2
|
|
or eax,ebx
|
|
mov edi,eax
|
|
mov eax,edx
|
|
shr eax,5
|
|
and eax,63
|
|
mov ebx,eax
|
|
shl eax,2
|
|
shr ebx,4
|
|
or eax,ebx
|
|
shl eax,8
|
|
or edi,eax
|
|
mov eax,edx
|
|
shr eax,11
|
|
mov ebx,eax
|
|
shl eax,3
|
|
shr ebx,2
|
|
or eax,ebx
|
|
shl eax,16
|
|
or eax,edi
|
|
mov cinema565Table[edx*4],eax
|
|
inc edx
|
|
cmp edx,65536
|
|
jb cinema_build_color_table
|
|
mov cinemaCachedFrame,-1
|
|
cinema_load_ready:
|
|
mov eax,1
|
|
ret
|
|
cinema_load_failure:
|
|
call FreeCinematicMaster3D
|
|
xor eax,eax
|
|
ret
|
|
LoadCinematicMaster3D ENDP
|
|
|
|
RenderCinematicMaster3D PROC uses ebx esi edi timeMs:DWORD
|
|
local frame:DWORD,count:DWORD,unpacked:DWORD
|
|
cmp cinemaFile,-1
|
|
je cinema_render_unavailable
|
|
mov eax,timeMs
|
|
cmp eax,20000
|
|
jb @F
|
|
mov eax,19999
|
|
@@:
|
|
imul eax,30
|
|
xor edx,edx
|
|
mov ecx,1000
|
|
div ecx
|
|
mov frame,eax
|
|
cmp eax,cinemaCachedFrame
|
|
je cinema_copy_frame
|
|
mov ebx,eax
|
|
invoke SetFilePointer,cinemaFile,cinemaIndex[ebx*8],0,0
|
|
cmp eax,-1
|
|
je cinema_render_failure
|
|
invoke ReadFile,cinemaFile,cinemaCompressed,cinemaIndex[ebx*8+4],ADDR count,0
|
|
test eax,eax
|
|
jz cinema_render_failure
|
|
mov eax,cinemaIndex[ebx*8+4]
|
|
cmp eax,count
|
|
jne cinema_render_failure
|
|
lea eax,unpacked
|
|
push eax
|
|
push count
|
|
push cinemaCompressed
|
|
push SCREEN_SIZE*2
|
|
push cinemaPacked
|
|
push 2
|
|
call cinemaDecoder
|
|
test eax,eax
|
|
jnz cinema_render_failure
|
|
cmp unpacked,SCREEN_SIZE*2
|
|
jne cinema_render_failure
|
|
mov esi,cinemaPacked
|
|
mov edi,cinemaPixels
|
|
mov ecx,SCREEN_SIZE
|
|
cinema_expand_color:
|
|
movzx eax,WORD PTR [esi]
|
|
mov eax,cinema565Table[eax*4]
|
|
stosd
|
|
add esi,2
|
|
dec ecx
|
|
jnz cinema_expand_color
|
|
mov eax,frame
|
|
mov cinemaCachedFrame,eax
|
|
cinema_copy_frame:
|
|
mov esi,cinemaPixels
|
|
lea edi,screenBuffer
|
|
mov ecx,SCREEN_SIZE
|
|
rep movsd
|
|
mov eax,1
|
|
ret
|
|
cinema_render_failure:
|
|
call FreeCinematicMaster3D
|
|
call LoadStartupProceduralAssets3D
|
|
cinema_render_unavailable:
|
|
xor eax,eax
|
|
ret
|
|
RenderCinematicMaster3D ENDP
|