KAZIK/src_graphics/startup_cinematic.inc

446 lines
9.5 KiB
PHP

; Native 640x480 motion graphics. Geometry, timing and drawing are all MASM.
StartupRect3D PROC uses edi ebx x:SDWORD,y:SDWORD,w:DWORD,h:DWORD,ink:DWORD
local right:DWORD,bottom:DWORD
mov eax,x
add eax,w
cmp eax,SCREEN_W
jle @F
mov eax,SCREEN_W
@@:
mov right,eax
mov eax,y
add eax,h
cmp eax,SCREEN_H
jle @F
mov eax,SCREEN_H
@@:
mov bottom,eax
cmp x,0
jge @F
mov x,0
@@:
cmp y,0
jge @F
mov y,0
@@:
mov ebx,y
startup_rect_row:
cmp ebx,bottom
jge startup_rect_done
mov ecx,right
sub ecx,x
jle startup_rect_done
mov eax,ebx
imul eax,SCREEN_W
add eax,x
lea edi,screenBuffer[eax*4]
mov eax,ink
rep stosd
inc ebx
jmp startup_rect_row
startup_rect_done:
ret
StartupRect3D ENDP
StartupLine3D PROC uses ebx esi edi x:SDWORD,y:SDWORD,x2:SDWORD,y2:SDWORD,ink:DWORD,weight:DWORD
local lineDX:SDWORD,lineDY:SDWORD,stepX:SDWORD,stepY:SDWORD,err:SDWORD,twice:SDWORD
mov stepX,1
mov eax,x2
sub eax,x
jns @F
neg eax
mov stepX,-1
@@:
mov lineDX,eax
mov stepY,1
mov eax,y2
sub eax,y
jns @F
neg eax
mov stepY,-1
@@:
neg eax
mov lineDY,eax
add eax,lineDX
mov err,eax
startup_line_pixel:
invoke StartupRect3D,x,y,weight,weight,ink
mov eax,x
cmp eax,x2
jne startup_line_step
mov eax,y
cmp eax,y2
je startup_line_done
startup_line_step:
mov eax,err
add eax,eax
mov twice,eax
cmp eax,lineDY
jl startup_line_y
mov eax,lineDY
add err,eax
mov eax,stepX
add x,eax
startup_line_y:
mov eax,twice
cmp eax,lineDX
jg startup_line_pixel
mov eax,lineDX
add err,eax
mov eax,stepY
add y,eax
jmp startup_line_pixel
startup_line_done:
ret
StartupLine3D ENDP
StartupInk3D PROC uses ebx ink:DWORD,gain:DWORD
mov eax,ink
and eax,00FF00FFh
imul eax,gain
shr eax,8
and eax,00FF00FFh
mov ebx,eax
mov eax,ink
and eax,0000FF00h
imul eax,gain
shr eax,8
and eax,0000FF00h
or eax,ebx
ret
StartupInk3D ENDP
StartupGlyph3D PROC uses ebx esi edi x:DWORD,y:DWORD,glyphCode:DWORD,unit:DWORD,ink:DWORD
local glyphX1:DWORD,glyphY1:DWORD,glyphX2:DWORD,glyphY2:DWORD,weight:DWORD
mov eax,glyphCode
sub eax,'A'
cmp eax,25
ja startup_glyph_done
mov esi,startupGlyphs3D[eax*4]
movzx edi,BYTE PTR [esi]
inc esi
mov eax,unit
shr eax,1
inc eax
mov weight,eax
startup_glyph_segment:
movzx eax,BYTE PTR [esi]
imul eax,unit
add eax,x
mov glyphX1,eax
movzx eax,BYTE PTR [esi+1]
imul eax,unit
add eax,y
mov glyphY1,eax
movzx eax,BYTE PTR [esi+2]
imul eax,unit
add eax,x
mov glyphX2,eax
movzx eax,BYTE PTR [esi+3]
imul eax,unit
add eax,y
mov glyphY2,eax
invoke StartupLine3D,glyphX1,glyphY1,glyphX2,glyphY2,ink,weight
add esi,4
dec edi
jnz startup_glyph_segment
startup_glyph_done:
ret
StartupGlyph3D ENDP
StartupWord3D PROC uses esi edi ebx x:DWORD,y:DWORD,text:DWORD,unit:DWORD,tracking:DWORD,ink:DWORD,start:DWORD
local charY:DWORD,charInk:DWORD,age:DWORD,offsetY:DWORD
mov esi,text
xor edi,edi
startup_word_char:
movzx ebx,BYTE PTR [esi]
test ebx,ebx
jz startup_word_done
mov eax,edi
imul eax,75
add eax,start
mov edx,startupElapsed3D
sub edx,eax
js startup_word_done
mov age,edx
mov eax,edx
cmp eax,500
jbe @F
mov eax,500
@@:
imul eax,256
xor edx,edx
mov ecx,500
div ecx
invoke StartupInk3D,ink,eax
mov charInk,eax
mov eax,age
cmp eax,600
jb @F
mov eax,600
@@:
neg eax
add eax,600
imul eax,eax
imul eax,18
xor edx,edx
mov ecx,360000
div ecx
add eax,y
mov charY,eax
; A single restrained highlight crosses each settled word, without flicker.
mov eax,startupElapsed3D
sub eax,start
sub eax,1500
js startup_word_draw
xor edx,edx
mov ecx,120
div ecx
cmp eax,edi
jne startup_word_draw
mov charInk,00F8EBCCh
startup_word_draw:
invoke StartupGlyph3D,x,charY,ebx,unit,charInk
mov eax,unit
imul eax,10
add eax,tracking
add x,eax
inc esi
inc edi
jmp startup_word_char
startup_word_done:
ret
StartupWord3D ENDP
StartupCanvas3D PROC uses ebx esi edi
local row:DWORD,base:DWORD
lea edi,screenBuffer
mov row,0
startup_canvas_row:
mov eax,row
sub eax,220
cdq
xor eax,edx
sub eax,edx
shr eax,5
neg eax
add eax,9
mov base,eax
xor ebx,ebx
startup_canvas_pixel:
mov eax,ebx
sub eax,320
cdq
xor eax,edx
sub eax,edx
shr eax,6
neg eax
add eax,base
cmp eax,2
jge @F
mov eax,2
@@:
mov ecx,ebx
imul ecx,13
xor ecx,row
and ecx,1
add eax,ecx
imul eax,00010101h
add eax,00010406h
stosd
inc ebx
cmp ebx,SCREEN_W
jb startup_canvas_pixel
inc row
cmp row,SCREEN_H
jb startup_canvas_row
ret
StartupCanvas3D ENDP
StartupEmblem3D PROC uses esi edi ebx centerX:DWORD,centerY:DWORD,radius:DWORD,start:DWORD
local x1:SDWORD,y1:SDWORD,x2:SDWORD,y2:SDWORD,progress:DWORD
mov eax,startupElapsed3D
sub eax,start
js startup_emblem_done
; An outline builds edge by edge. Final edge is interpolated each frame.
imul eax,8
cmp eax,8000
jbe @F
mov eax,8000
@@:
mov progress,eax
xor esi,esi
startup_emblem_edge:
mov edi,esi
shl edi,3
mov eax,startupOctagon3D[edi]
imul eax,radius
cdq
mov ebx,68
idiv ebx
add eax,centerX
mov x1,eax
mov eax,startupOctagon3D[edi+4]
imul eax,radius
cdq
idiv ebx
add eax,centerY
mov y1,eax
mov eax,startupOctagon3D[edi+8]
imul eax,radius
cdq
idiv ebx
add eax,centerX
mov x2,eax
mov eax,startupOctagon3D[edi+12]
imul eax,radius
cdq
idiv ebx
add eax,centerY
mov y2,eax
mov eax,progress
cmp eax,1000
jae startup_emblem_full_edge
mov eax,x2
sub eax,x1
imul eax,progress
cdq
mov ebx,1000
idiv ebx
add eax,x1
mov x2,eax
mov eax,y2
sub eax,y1
imul eax,progress
cdq
idiv ebx
add eax,y1
mov y2,eax
startup_emblem_full_edge:
invoke StartupLine3D,x1,y1,x2,y2,00917A51h,2
sub progress,1000
jle startup_emblem_done
inc esi
cmp esi,8
jb startup_emblem_edge
startup_emblem_done:
ret
StartupEmblem3D ENDP
RenderStudioCinematic3D PROC
call RenderStudioFilm3D
ret
RenderStudioCinematic3D ENDP
RenderTitleCinematic3D PROC
call RenderTitleFilm3D
ret
RenderTitleCinematic3D ENDP
RenderBootWarning3D PROC
invoke StartupRect3D,48,56,66,34,00C3A574h
invoke StartupRect3D,49,57,64,32,000B1012h
invoke PresentationText3D,58,66,OFFSET bootAge,00E1C898h,2,-1
invoke PresentationText3D,136,62,OFFSET bootWarningTag,00919B99h,1,-1
invoke PresentationText3D,48,118,OFFSET bootWarningTitle,00E8DCC4h,2,-1
invoke StartupRect3D,48,156,544,1,004B4639h
invoke PresentationText3D,48,186,OFFSET bootWarningBody,00BCC4C2h,2,-1
invoke PresentationText3D,48,337,OFFSET bootWarningAI,008D9D9Bh,1,-1
ret
RenderBootWarning3D ENDP
RenderBootFeatures3D PROC uses esi ebx
local rowY:DWORD,headerY:DWORD,bodyY:DWORD
invoke PresentationText3D,48,48,OFFSET bootFeatureTag,00919B99h,1,-1
invoke PresentationText3D,48,78,OFFSET bootFeatureTitle,00E8DCC4h,2,-1
mov rowY,151
xor esi,esi
boot_feature_row:
invoke StartupRect3D,48,rowY,2,55,008C744Dh
mov eax,rowY
add eax,2
invoke PresentationText3D,66,eax,bootFeatureNumbers[esi*4],00B59A6Ch,1,-1
mov eax,rowY
mov headerY,eax
add eax,28
mov bodyY,eax
invoke PresentationText3D,108,headerY,bootFeatureHeaders[esi*4],00D8C8AAh,2,-1
invoke PresentationText3D,108,bodyY,bootFeatureBodies[esi*4],00AABBB8h,1,-1
add rowY,83
inc esi
cmp esi,3
jb boot_feature_row
invoke PresentationText3D,48,414,OFFSET bootFeatureControls,00A4ABA2h,1,-1
ret
RenderBootFeatures3D ENDP
RenderStartupCinematic3D PROC uses ebx esi edi
call StartupCanvas3D
cmp startupPage3D,STARTUP_WARNING
jne @F
call RenderBootWarning3D
jmp boot_cinematic_footer
@@:
cmp startupPage3D,STARTUP_STUDIO
jne @F
call RenderStudioCinematic3D
jmp boot_cinematic_footer
@@:
cmp startupPage3D,STARTUP_TITLE
jne @F
call RenderTitleCinematic3D
jmp boot_cinematic_footer
@@:
call RenderBootFeatures3D
boot_cinematic_footer:
; Three active chapters: warning, studio, features (title slot is retained).
invoke PresentationText3D,48,456,OFFSET bootNext,006D7C7Ah,1,-1
mov edi,startupPage3D
cmp edi,STARTUP_FEATURES
jne @F
dec edi
@@:
mov esi,0
mov ebx,555
boot_chapter_mark:
mov eax,003D463Fh
cmp esi,edi
jne @F
mov eax,00BBA173h
@@:
invoke StartupRect3D,ebx,457,9,2,eax
add ebx,15
inc esi
cmp esi,3
jb boot_chapter_mark
; Every page ends at black, matching the opening's closed eyes.
mov eax,startupElapsed3D
cmp eax,400
jae boot_cinematic_fade_out
imul eax,256
xor edx,edx
mov ecx,400
div ecx
invoke FadeCityFrame3D,eax
ret
boot_cinematic_fade_out:
mov ecx,startupPage3D
mov ebx,startupDurations3D[ecx*4]
sub ebx,500
cmp eax,ebx
jb boot_cinematic_done
sub eax,ebx
cmp eax,500
jbe @F
mov eax,500
@@:
imul eax,256
xor edx,edx
mov ecx,500
div ecx
neg eax
add eax,256
invoke FadeCityFrame3D,eax
boot_cinematic_done:
ret
RenderStartupCinematic3D ENDP