313 lines
7 KiB
PHP
313 lines
7 KiB
PHP
; ==============================================================================
|
|
; UNDERGROUND RAT RACES SCENE (CP1251)
|
|
; ==============================================================================
|
|
|
|
InitRatRace3D PROC
|
|
invoke LoadAnimPack3D, OFFSET ratRacePack, OFFSET ratRacePath
|
|
ret
|
|
InitRatRace3D ENDP
|
|
|
|
FreeRatRace3D PROC
|
|
invoke FreeAnimPack3D, OFFSET ratRacePack
|
|
ret
|
|
FreeRatRace3D ENDP
|
|
|
|
BeginRatRace3D PROC uses edi
|
|
mov edi,OFFSET racerX
|
|
xor eax,eax
|
|
mov ecx,12
|
|
rep stosd
|
|
mov edi,OFFSET racerState
|
|
mov ecx,4
|
|
rep stosd
|
|
mov edi,OFFSET uwRatRanks
|
|
mov ecx,4
|
|
rep stosd
|
|
mov uwRatFinished,0
|
|
mov uwRaceAccumulator,0
|
|
mov ratRacePhase,0
|
|
mov ratRaceSlamUsed,0
|
|
mov uwRatSlamTimer,0
|
|
mov ratRacePayout,0
|
|
mov engineMode,MODE_RAT_RACE
|
|
call ClearKeys3D
|
|
ret
|
|
BeginRatRace3D ENDP
|
|
|
|
HandleRatRace3D PROC uses ebx esi edi
|
|
cmp ratRacePhase,0
|
|
jne uw_race_running
|
|
mov esi,0
|
|
uw_choose_rat:
|
|
lea eax,[esi+31h]
|
|
invoke Pressed3D,eax
|
|
test eax,eax
|
|
jz @F
|
|
mov ratRaceSelected,esi
|
|
@@:
|
|
inc esi
|
|
cmp esi,4
|
|
jb uw_choose_rat
|
|
invoke Pressed3D,50h
|
|
test eax,eax
|
|
jz @F
|
|
xor uwRatPlaceBet,1
|
|
@@:
|
|
invoke Pressed3D,26h
|
|
test eax,eax
|
|
jz @F
|
|
cmp ratRaceBet,500
|
|
jae @F
|
|
add ratRaceBet,25
|
|
@@:
|
|
invoke Pressed3D,28h
|
|
test eax,eax
|
|
jz @F
|
|
cmp ratRaceBet,25
|
|
jbe @F
|
|
sub ratRaceBet,25
|
|
@@:
|
|
invoke Pressed3D,1Bh
|
|
test eax,eax
|
|
jnz uw_race_exit
|
|
invoke Pressed3D,0Dh
|
|
test eax,eax
|
|
jz uw_race_done
|
|
mov eax,ratRaceBet
|
|
cmp bankroll,eax
|
|
jb uw_race_done
|
|
sub bankroll,eax
|
|
mov ratRacePhase,1
|
|
call SaveProgress3D
|
|
ret
|
|
uw_race_running:
|
|
cmp ratRacePhase,1
|
|
jne uw_race_result_input
|
|
invoke Pressed3D,20h
|
|
test eax,eax
|
|
jz uw_race_clock
|
|
cmp ratRaceSlamUsed,0
|
|
jne uw_race_clock
|
|
mov ratRaceSlamUsed,1
|
|
mov uwRatSlamTimer,350
|
|
invoke PlayCasinoSound3D,OFFSET soundSkillHit,0,1
|
|
xor esi,esi
|
|
uw_race_slam:
|
|
invoke RandomRange3D,3
|
|
cmp eax,0
|
|
jne @F
|
|
mov racerState[esi*4],6
|
|
jmp uw_race_slam_next
|
|
@@:
|
|
cmp eax,1
|
|
jne uw_race_slam_next
|
|
add racerX[esi*4],10
|
|
uw_race_slam_next:
|
|
inc esi
|
|
cmp esi,4
|
|
jb uw_race_slam
|
|
uw_race_clock:
|
|
mov eax,deltaTime3D
|
|
cmp eax,200
|
|
jbe @F
|
|
mov eax,200
|
|
@@:
|
|
add uwRaceAccumulator,eax
|
|
sub uwRatSlamTimer,eax
|
|
jns @F
|
|
mov uwRatSlamTimer,0
|
|
@@:
|
|
uw_race_step:
|
|
cmp uwRaceAccumulator,70
|
|
jb uw_race_done
|
|
sub uwRaceAccumulator,70
|
|
invoke RandomRange3D,4
|
|
mov edi,eax
|
|
xor esi,esi
|
|
uw_race_move:
|
|
lea ebx,[esi+edi]
|
|
and ebx,3
|
|
cmp uwRatRanks[ebx*4],0
|
|
jne uw_race_next
|
|
cmp racerState[ebx*4],0
|
|
je uw_race_speed
|
|
dec racerState[ebx*4]
|
|
jmp uw_race_next
|
|
uw_race_speed:
|
|
invoke RandomRange3D,100
|
|
cmp eax,5
|
|
jae @F
|
|
mov racerState[ebx*4],5
|
|
jmp uw_race_next
|
|
@@:
|
|
cmp eax,13
|
|
jae @F
|
|
mov eax,6
|
|
jmp uw_race_advance
|
|
@@:
|
|
invoke RandomRange3D,3
|
|
inc eax
|
|
cmp ebx,0
|
|
jne @F
|
|
inc eax
|
|
@@:
|
|
cmp ebx,1
|
|
jne @F
|
|
cmp racerX[ebx*4],100
|
|
jb @F
|
|
add eax,2
|
|
@@:
|
|
cmp ebx,2
|
|
jne @F
|
|
add eax,eax
|
|
@@:
|
|
cmp ebx,3
|
|
jne uw_race_advance
|
|
mov eax,3
|
|
uw_race_advance:
|
|
add racerX[ebx*4],eax
|
|
inc racerAnimFrame[ebx*4]
|
|
cmp racerX[ebx*4],192
|
|
jb uw_race_next
|
|
mov racerX[ebx*4],192
|
|
inc uwRatFinished
|
|
mov eax,uwRatFinished
|
|
mov uwRatRanks[ebx*4],eax
|
|
cmp eax,1
|
|
jne uw_race_next
|
|
mov ratRaceWinner,ebx
|
|
uw_race_next:
|
|
inc esi
|
|
cmp esi,4
|
|
jb uw_race_move
|
|
cmp uwRatFinished,4
|
|
jb uw_race_step
|
|
mov ratRacePhase,2
|
|
mov ebx,ratRaceSelected
|
|
mov ecx,1
|
|
cmp uwRatPlaceBet,0
|
|
je @F
|
|
mov ecx,2
|
|
@@:
|
|
cmp uwRatRanks[ebx*4],ecx
|
|
ja uw_race_lost
|
|
mov eax,ratRaceBet
|
|
mov ecx,racerOddsNumerator[ebx*4]
|
|
cmp uwRatPlaceBet,0
|
|
je @F
|
|
mov ecx,15
|
|
@@:
|
|
mul ecx
|
|
mov ecx,10
|
|
div ecx
|
|
mov ratRacePayout,eax
|
|
add bankroll,eax
|
|
invoke PlayCasinoSound3D,OFFSET soundRoundWin,0,1
|
|
jmp uw_race_settle
|
|
uw_race_lost:
|
|
invoke PlayCasinoSound3D,OFFSET soundRoundLose,0,1
|
|
uw_race_settle:
|
|
call StepDebtRound3D
|
|
invoke DecaySecurityHeat,2
|
|
call SaveProgress3D
|
|
ret
|
|
uw_race_result_input:
|
|
invoke Pressed3D,1Bh
|
|
test eax,eax
|
|
jnz uw_race_exit
|
|
invoke Pressed3D,0Dh
|
|
test eax,eax
|
|
jz uw_race_done
|
|
cmp uwDebtPending,0
|
|
jne uw_race_exit
|
|
call BeginRatRace3D
|
|
ret
|
|
uw_race_exit:
|
|
mov engineMode,MODE_WALK
|
|
call ClearKeys3D
|
|
uw_race_done:
|
|
ret
|
|
HandleRatRace3D ENDP
|
|
|
|
RenderRatRace3D PROC uses ebx esi edi
|
|
invoke DrawBox,0,0,320,240,0014100Bh
|
|
invoke DrawBoxBorder,6,6,308,228,00221A12h,00836D42h,1
|
|
invoke DrawString8x8,16,16,OFFSET uwRatTitle,00E7CA88h
|
|
mov eax,ratRaceSelected
|
|
mov eax,uwRatNamePtrs[eax*4]
|
|
invoke DrawString8x8,16,30,eax,00A8DDB9h
|
|
xor esi,esi
|
|
uw_race_lane:
|
|
imul ebx,esi,34
|
|
add ebx,40
|
|
mov edi,004A3C2Fh
|
|
cmp esi,ratRaceSelected
|
|
jne @F
|
|
mov edi,00D8BC6Ah
|
|
@@:
|
|
invoke DrawBoxBorder,16,ebx,288,30,002D241Bh,edi,1
|
|
mov eax,esi
|
|
inc eax
|
|
add ebx,10
|
|
invoke DrawNumber,20,ebx,eax,edi
|
|
sub ebx,10
|
|
mov eax,esi
|
|
shl eax,2
|
|
mov edx,racerAnimFrame[esi*4]
|
|
and edx,3
|
|
add eax,edx
|
|
mov ecx,racerX[esi*4]
|
|
add ecx,38
|
|
cmp uwRatSlamTimer,0
|
|
je @F
|
|
add ecx,2
|
|
@@:
|
|
invoke DrawUnderworldSprite3D,OFFSET ratRacePack,eax,ecx,ebx,56,28
|
|
mov eax,uwRatRanks[esi*4]
|
|
test eax,eax
|
|
jz @F
|
|
add ebx,10
|
|
invoke DrawNumber,288,ebx,eax,00E7CA88h
|
|
@@:
|
|
inc esi
|
|
cmp esi,4
|
|
jb uw_race_lane
|
|
invoke DrawBox,280,40,2,132,00D8BC6Ah
|
|
cmp ratRacePhase,0
|
|
jne uw_race_render_running
|
|
invoke DrawString8x8,16,180,OFFSET uwRatKeys,00E4D9BDh
|
|
invoke DrawString8x8,16,192,OFFSET uwRatStart,00E4D9BDh
|
|
mov eax,OFFSET uwRatWinBet
|
|
cmp uwRatPlaceBet,0
|
|
je @F
|
|
mov eax,OFFSET uwRatPlaceText
|
|
@@:
|
|
invoke DrawString8x8,16,206,eax,00A8DDB9h
|
|
jmp uw_race_footer
|
|
uw_race_render_running:
|
|
cmp ratRacePhase,1
|
|
jne uw_race_render_result
|
|
mov eax,OFFSET uwRatRun
|
|
cmp ratRaceSlamUsed,0
|
|
je @F
|
|
mov eax,OFFSET uwRatUsed
|
|
@@:
|
|
invoke DrawString8x8,16,188,eax,00E7CA88h
|
|
jmp uw_race_footer
|
|
uw_race_render_result:
|
|
cmp ratRacePayout,0
|
|
je @F
|
|
invoke DrawString8x8,16,182,OFFSET uwRatWon,00A8DDB9h
|
|
invoke DrawNumber,104,182,ratRacePayout,00A8DDB9h
|
|
jmp uw_race_result_keys
|
|
@@:
|
|
invoke DrawString8x8,16,182,OFFSET uwRatLost,005555FFh
|
|
uw_race_result_keys:
|
|
invoke DrawString8x8,16,200,OFFSET uwRatResult,00E7CA88h
|
|
uw_race_footer:
|
|
invoke DrawString8x8,16,220,OFFSET uwRatMoney,00A8B6BBh
|
|
invoke DrawNumber,80,220,ratRaceBet,00E5D6B0h
|
|
invoke DrawString8x8,152,220,OFFSET uwBank,00A8B6BBh
|
|
invoke DrawNumber,208,220,bankroll,00E5D6B0h
|
|
ret
|
|
RenderRatRace3D ENDP
|