-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender.asm
111 lines (77 loc) · 2.72 KB
/
render.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
%include "utils.inc"
[section .bss]
ddbltfx resb DDBLTFX_size
t resd 1
col resd 1
__SECT__
invoke timeGetTime
sub eax, [start_time]
mov [t], eax
mov esi, [ddbacksurf]
mov ebx, [esi]
%if 1
mov eax, ddbltfx
mov dword [eax + DDBLTFX.dwSize], DDBLTFX_size
;mov ecx, RGB(249,240,213)
mov ecx, RGB(0xff,0xff,0xff)
mov dword [eax + DDBLTFX.dwFillColor], ecx
invokeintf ebx, IDirectDrawSurface.Blt, esi, byte 0, byte 0, byte 0, dword DDBLT_WAIT | DDBLT_COLORFILL, eax
checkerror {test eax, eax}, nz, eback
%endif
invokeintf ebx, IDirectDrawSurface.Lock, esi, byte 0, dword ddsd, dword DDLOCK_WAIT, byte 0
checkerror {test eax, eax}, nz, eback
mov edi, [ddsd + DDSURFACEDESC.lpSurface]
mov ebx, [ddsd + DDSURFACEDESC.lPitch]
; -----------------------------------------------------------------------------
mov edi, [ddsd + DDSURFACEDESC.lpSurface]
mov ebx, [ddsd + DDSURFACEDESC.lPitch]
%include "part0.asm"
; -----------------------------------------------------------------------------
mov ebx, [esi]
invokeintf ebx, IDirectDrawSurface.Unlock, esi, byte 0
checkerror {test eax, eax}, nz, eback
%ifdef FPS_DISPLAY
%define FPS_UPDATE_INTERVAL 1000 ; update fps every x ms
%include "libc.inc"
%include "gdi32.inc"
[section .bss]
hdc resd 1
textbuf resb 32
[section .data]
fps_start dd 0
frames dd 0
_temp:
fps dd 0
nf1000 dd 1000.0
format db "%u", 0
__SECT__
inc dword [frames]
invoke timeGetTime
sub eax, [start_time]
mov edi, eax
sub eax, [fps_start]
cmp eax, FPS_UPDATE_INTERVAL
jl .no_fps_calc
; frames / s = fps
fild dword [frames]
mov [_temp], eax
fild dword [_temp]
; convert ms to s
fdiv dword [nf1000]
; divide frames by s
fdivp st1, st0
fistp dword [fps]
mov dword [fps_start], edi
mov dword [frames], 0
.no_fps_calc:
push dword [fps]
push format
push textbuf
call [wsprintfA]
add esp, 3*4
mov edi, eax
invokeintf ebx, IDirectDrawSurface.GetDC, esi, hdc
invoke TextOutA, dword [hdc], 10, 10, textbuf, edi
invokeintf ebx, IDirectDrawSurface.ReleaseDC, esi, hdc
%endif
; *** ebx: IDirectDrawSurface vtable*