KAZIK/src_graphics/underworld.inc

290 lines
6.8 KiB
PHP

DrawUnderworldSprite3D PROC pack:DWORD,frame:DWORD,x:DWORD,y:DWORD,w:DWORD,h:DWORD
shl x,1
shl y,1
shl w,1
shl h,1
invoke DrawAnimSprite3D,pack,frame,x,y,w,h
ret
DrawUnderworldSprite3D ENDP
; Word wrap CP1251 to a bounded logical rectangle. Max y=196 protects footer.
DrawUnderworldText3D PROC uses ebx esi edi x:DWORD,y:DWORD,strPtr:DWORD,columns:DWORD,color:DWORD
local col:DWORD,wordLen:DWORD
mov esi,strPtr
mov col,0
uw_text_next:
cmp y,196
ja uw_text_done
movzx eax,BYTE PTR [esi]
test eax,eax
jz uw_text_done
cmp eax,10
je uw_text_newline
cmp eax,32
je uw_text_char
xor ecx,ecx
uw_word_scan:
movzx edx,BYTE PTR [esi+ecx]
cmp edx,32
jbe uw_word_end
inc ecx
jmp uw_word_scan
uw_word_end:
mov eax,col
test eax,eax
jz uw_text_word
add eax,ecx
cmp eax,columns
jbe uw_text_word
add y,12
mov col,0
uw_text_word:
mov wordLen,ecx
uw_word_char:
cmp wordLen,0
je uw_text_next
cmp y,196
ja uw_text_done
movzx eax,BYTE PTR [esi]
mov uwCharText,al
mov eax,col
shl eax,3
add eax,x
invoke DrawString8x8,eax,y,OFFSET uwCharText,color
inc esi
inc col
dec wordLen
mov eax,col
cmp eax,columns
jb uw_word_char
mov col,0
add y,12
jmp uw_word_char
uw_text_char:
inc esi
cmp col,0
je uw_text_next
inc col
mov eax,col
cmp eax,columns
jb uw_text_next
mov col,0
add y,12
jmp uw_text_next
uw_text_newline:
inc esi
mov col,0
add y,12
jmp uw_text_next
uw_text_done:
ret
DrawUnderworldText3D ENDP
UnderworldPath3D PROC
mov eax,OFFSET savePath3D
cmp nativeProfileActive3D,0
je @F
mov eax,OFFSET saveFullPath
@@:
invoke CopyCString,OFFSET uwProgressPath,eax
invoke AppendCString,OFFSET uwProgressPath,OFFSET uwProgressSuffix
invoke CopyCString,OFFSET uwProgressTemp,OFFSET uwProgressPath
invoke AppendCString,OFFSET uwProgressTemp,OFFSET uwTempSuffix
ret
UnderworldPath3D ENDP
UnderworldSignature3D PROC uses esi
mov esi,OFFSET uwProgressWords
mov ecx,15
mov eax,554E4432h
@@:
rol eax,5
xor eax,[esi]
add eax,9E3779B9h
add esi,4
loop @B
ret
UnderworldSignature3D ENDP
LoadUnderworldProgress3D PROC uses ebx
mov debtActive,0
mov debtAmount,0
mov debtBorrowed,0
mov debtRoundsLeft,0
mov securityHeat,0
mov heistCrewBartender,0
mov heistCrewSinger,0
mov heistCrewFortune,0
mov heistCrewHacker,0
mov heistComplete,0
mov uwDebtPending,0
mov uwSecurityPending,0
mov barBuffLuckSpins,0
call UnderworldPath3D
invoke CreateFileA,OFFSET uwProgressPath,80000000h,1,0,3,80h,0
cmp eax,-1
je uw_load_done
mov ebx,eax
invoke ReadFile,ebx,OFFSET uwProgressWords,64,OFFSET uwProgressIo,0
invoke CloseHandle,ebx
cmp uwProgressIo,64
jne uw_load_done
cmp uwProgressWords,554E4432h
jne uw_load_done
call UnderworldSignature3D
cmp eax,uwProgressWords[60]
jne uw_load_done
cmp uwProgressWords[4],1
ja uw_load_done
cmp uwProgressWords[8],16000
ja uw_load_done
cmp uwProgressWords[16],1000
ja uw_load_done
cmp uwProgressWords[20],100
ja uw_load_done
cmp uwProgressWords[24],15
ja uw_load_done
cmp uwProgressWords[28],1
ja uw_load_done
cmp uwProgressWords[32],15
ja uw_load_done
mov eax,uwProgressWords[4]
mov debtActive,eax
mov eax,uwProgressWords[8]
mov debtAmount,eax
mov eax,uwProgressWords[12]
mov debtBorrowed,eax
mov eax,uwProgressWords[16]
mov debtRoundsLeft,eax
mov eax,uwProgressWords[20]
mov securityHeat,eax
mov eax,uwProgressWords[24]
mov ecx,eax
and eax,1
mov heistCrewBartender,eax
mov eax,ecx
shr eax,1
and eax,1
mov heistCrewSinger,eax
mov eax,ecx
shr eax,2
and eax,1
mov heistCrewFortune,eax
shr ecx,3
and ecx,1
mov heistCrewHacker,ecx
mov eax,uwProgressWords[28]
mov heistComplete,eax
mov eax,uwProgressWords[32]
mov barBuffLuckSpins,eax
cmp debtActive,0
je @F
cmp debtRoundsLeft,0
jne @F
mov uwDebtPending,1
@@:
cmp securityHeat,100
jne uw_load_done
mov uwSecurityPending,1
uw_load_done:
ret
LoadUnderworldProgress3D ENDP
SaveUnderworldProgress3D PROC uses ebx
IFDEF CASINO_ACTION_TEST
ret
ENDIF
cmp obsActive3D,0
jne uw_save_done
cmp arrivalConfirmed3D,0
je uw_save_done
call UnderworldPath3D
mov uwProgressWords,554E4432h
mov eax,debtActive
mov uwProgressWords[4],eax
mov eax,debtAmount
mov uwProgressWords[8],eax
mov eax,debtBorrowed
mov uwProgressWords[12],eax
mov eax,debtRoundsLeft
mov uwProgressWords[16],eax
mov eax,securityHeat
mov uwProgressWords[20],eax
mov eax,heistCrewHacker
shl eax,1
or eax,heistCrewFortune
shl eax,1
or eax,heistCrewSinger
shl eax,1
or eax,heistCrewBartender
mov uwProgressWords[24],eax
mov eax,heistComplete
mov uwProgressWords[28],eax
mov eax,barBuffLuckSpins
mov uwProgressWords[32],eax
call UnderworldSignature3D
mov uwProgressWords[60],eax
invoke CreateFileA,OFFSET uwProgressTemp,40000000h,0,0,2,80h,0
cmp eax,-1
je uw_save_done
mov ebx,eax
invoke WriteFile,ebx,OFFSET uwProgressWords,64,OFFSET uwProgressIo,0
invoke CloseHandle,ebx
cmp uwProgressIo,64
jne uw_save_done
invoke MoveFileExA,OFFSET uwProgressTemp,OFFSET uwProgressPath,9
uw_save_done:
ret
SaveUnderworldProgress3D ENDP
; Defer interruptions until the paid game has settled and the player is walking.
UpdateUnderworld3D PROC
cmp engineMode,MODE_WALK
jne uw_update_done
cmp uwDebtPending,0
je uw_update_security
mov uwDebtPending,0
mov debtSubmode,1
mov engineMode,MODE_DEBT
call ClearKeys3D
ret
uw_update_security:
cmp uwSecurityPending,0
je uw_update_done
mov uwSecurityPending,0
call TriggerInterrogation3D
uw_update_done:
ret
UpdateUnderworld3D ENDP
UnderworldCanWalk3D PROC uses ebx esi px:DWORD,py:DWORD
mov esi,OFFSET bunkerRatRace3D
mov ebx,3
uw_object_collision:
mov eax,px
sub eax,[esi].CityProp3D.posX
jns @F
neg eax
@@:
mov ecx,[esi].CityProp3D.worldW
shr ecx,1
add ecx,FP_1/10
cmp eax,ecx
ja uw_object_next
mov eax,py
sub eax,[esi].CityProp3D.posY
jns @F
neg eax
@@:
cmp eax,FP_1*2/5
jbe uw_object_blocked
uw_object_next:
add esi,SIZEOF CityProp3D
dec ebx
jnz uw_object_collision
mov eax,1
ret
uw_object_blocked:
xor eax,eax
ret
UnderworldCanWalk3D ENDP