Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
; TRIANGLE SPEED TEST 3
3
; 32 triangle draw use! 12300 triangle in sec on 800Mhz processor
4
;
5
; Pavlushin Evgeni 11.09.2004
6
; mail: waptap@mail.ru       site: www.deck4.narod.ru
7
;                                www.cyberdeck.fatal.ru
8
 
9
use32
10
               org     0x0
11
               db     'MENUET01'              ; 8 byte id
12
               dd     0x01                    ; header version
13
               dd     START                   ; start of code
14
               dd     I_END                   ; size of image
180 heavyiron 15
               dd     0x100000                ; memory for app
16
               dd     0x100000                ; esp
31 halyavin 17
               dd     0x0 , 0x0               ; I_Param , I_Icon
18
 
19
SCREEN_X equ 320 ;800
20
SCREEN_Y equ 200 ;600
21
 
485 heavyiron 22
include '..\..\..\macros.inc'
31 halyavin 23
include 'lang.inc'
24
include 'ascl.inc'
25
include 'ascgl.inc'
26
 
27
START:
180 heavyiron 28
red:
31 halyavin 29
    call draw_window
30
 
31
still:
32
    scevent red,key,button
195 heavyiron 33
    fps  250,8,cl_White,cl_Black
31 halyavin 34
 
35
main_loop:
36
     random SCREEN_X,eax
37
     mov [@@tx1],eax
38
     random SCREEN_Y,eax
39
     mov [@@ty1],eax
40
     random SCREEN_X,eax
41
     mov [@@tx2],eax
42
     random SCREEN_Y,eax
43
     mov [@@ty2],eax
44
     random SCREEN_X,eax
45
     mov [@@tx3],eax
46
     random SCREEN_Y,eax
47
     mov [@@ty3],eax
48
 
49
     random 255,eax
50
     mov byte [@@rgb],al
51
     random 255,eax
52
     mov byte [@@rgb+1],al
53
     random 255,eax
54
     mov byte [@@rgb+2],al
55
     pushad
56
     call filled_triangle
57
     popad
58
 
59
     dec [count]  ;for max speed
60
     jnz xxx
61
     call outscr
62
     mov [count],100
63
xxx:
64
     jmp still
65
 
66
count dd 100
67
 
68
key:
69
     mov eax,2
485 heavyiron 70
     mcall
31 halyavin 71
     jmp still
72
button:
73
     mov eax,17
485 heavyiron 74
     mcall
31 halyavin 75
     cmp ah,1
76
     jne still
77
exit:
78
     mov eax,-1
485 heavyiron 79
     mcall
31 halyavin 80
 
81
;Draw window
82
draw_window:
180 heavyiron 83
 
31 halyavin 84
    mov eax,12  ;Start
85
    mov ebx,1
485 heavyiron 86
    mcall
31 halyavin 87
 
180 heavyiron 88
    xor eax,eax   ;Draw window
195 heavyiron 89
    mov ebx,100*65536+(SCREEN_X+9) ;x start*65536+x size
90
    mov ecx,100*65536+(SCREEN_Y+26) ;y start*65536+y size
551 spraid 91
    mov edx,0x14000000              ;0x13 use skinned window
485 heavyiron 92
    mov edi,title
93
    mcall
31 halyavin 94
 
95
    mov eax,12  ;End
96
    mov ebx,2
485 heavyiron 97
    mcall
31 halyavin 98
    ret
99
 
485 heavyiron 100
title db '3D TEST SAMPLE',0
31 halyavin 101
 
102
outscr:
103
 
104
;outscrbuf
105
 mov ebx,scrbuf
106
 mov ecx,SCREEN_X*65536+SCREEN_Y
107
 mov edx,5*65536+22
108
 mov ax,7
485 heavyiron 109
 mcall
31 halyavin 110
 
111
	ret
112
 
113
;filled trangle 32 bit draw procedure
114
;from NAAG3d demo
115
 
116
@@tx1  dd 0
117
@@ty1  dd 0
118
@@tx2  dd 0
119
@@ty2  dd 0
120
@@tx3  dd 0
121
@@ty3  dd 0
122
@@rgb  dd 0
123
 
124
@@dx12 dd 0
125
@@dx13 dd 0
126
@@dx23 dd 0
127
 
128
filled_triangle:
129
	mov eax,[@@ty1]
130
	cmp eax,[@@ty3]
131
	jle @@ok13
132
 
133
	xchg eax,[@@ty3]
134
	mov [@@ty1],eax
135
 
136
	mov eax,[@@tx1]
137
	xchg eax,[@@tx3]
138
	mov [@@tx1],eax
139
@@ok13:
140
	mov eax,[@@ty2]
141
	cmp eax,[@@ty3]
142
	jle @@ok23
143
 
144
	xchg eax,[@@ty3]
145
	mov [@@ty2],eax
146
 
147
	mov eax,[@@tx2]
148
	xchg eax,[@@tx3]
149
	mov [@@tx2],eax
150
@@ok23:
151
	mov eax,[@@ty1]
152
	cmp eax,[@@ty2]
153
	jle @@ok12
154
 
155
	xchg eax,[@@ty2]
156
	mov [@@ty1],eax
157
 
158
	mov eax,[@@tx1]
159
	xchg eax,[@@tx2]
160
	mov [@@tx1],eax
161
@@ok12:
162
 
163
	mov ebx,[@@ty2]
164
	sub ebx,[@@ty1]
165
	jnz @@make_d12
166
 
167
	mov [@@dx12],dword 0
168
	jmp @@done_d12
169
@@make_d12:
170
	mov eax,[@@tx2]
171
	sub eax,[@@tx1]
172
	shl eax,12 ;7
173
	cdq
174
	idiv ebx
175
	mov [@@dx12],eax			; dx12 = (x2-x1)/(y2-y1)
176
@@done_d12:
177
 
178
	mov ebx,[@@ty3]
179
	sub ebx,[@@ty1]
180
	jnz @@make_d13
181
 
182
	mov [@@dx13],dword 0
183
	jmp @@done_d13
184
@@make_d13:
185
	mov eax,[@@tx3]
186
	sub eax,[@@tx1]
187
	shl eax,12 ;7
188
	cdq
189
	idiv ebx
190
	mov [@@dx13],eax			; dx13 = (x3-x1)/(y3-y1)
191
@@done_d13:
192
 
193
	mov ebx,[@@ty3]
194
	sub ebx,[@@ty2]
195
	jnz @@make_d23
196
 
197
	mov [@@dx23],dword 0
198
	jmp @@done_d23
199
@@make_d23:
200
	mov eax,[@@tx3]
201
	sub eax,[@@tx2]
202
	shl eax,12 ;7
203
	cdq
204
	idiv ebx
205
	mov [@@dx23],eax			; dx23 = (x3-x2)/(y3-y2)
206
@@done_d23:
207
 
208
	mov eax,[@@tx1]
209
	shl eax,12 ;7
210
	mov ebx,eax
211
 
212
	mov ecx,[@@ty1]
213
 cmp ecx,[@@ty2]
214
 jge @@end_loop12
215
 
216
@@loop12:
217
 
218
 call flat_line
219
 
220
	add eax,[@@dx13]
221
	add ebx,[@@dx12]
222
	inc ecx
223
	cmp ecx,[@@ty2]
224
	jl  @@loop12
225
@@end_loop12:
226
 
227
 mov ecx,[@@ty2]
228
 cmp ecx,[@@ty3]
229
 jge @@end_loop23
230
 
231
	mov ebx,[@@tx2]
232
	shl ebx,12 ;7
233
@@loop23:
234
 
235
 call flat_line
236
 
237
	add eax,[@@dx13]
238
	add ebx,[@@dx23]
239
	inc ecx
240
	cmp ecx,[@@ty3]
241
	jl  @@loop23
242
@@end_loop23:
243
 
244
	ret
245
 
246
;flatline proc
247
 
248
flat_line:
249
 push eax
250
 push ebx
251
 push ecx
252
 
253
 or ecx,ecx
254
 jl @@quit
255
 cmp ecx,SCREEN_Y-1 ;199
256
 jg @@quit
257
 
258
 sar eax,12
259
 sar ebx,12
260
 
261
 or eax,eax
262
 jge @@ok1
263
 xor eax,eax
264
 jmp @@ok2
265
@@ok1:
266
 cmp eax,SCREEN_X-1 ;319
267
 jle @@ok2
268
 mov eax,SCREEN_X-1 ;319
269
@@ok2:
270
 or ebx,ebx
271
 jge @@ok3
272
 xor ebx,ebx
273
 jmp @@ok4
274
@@ok3:
275
 cmp ebx,SCREEN_X-1 ;319
276
 jle @@ok4
277
 mov ebx,SCREEN_X-1 ;319
278
@@ok4:
279
 cmp eax,ebx
280
 jl @@ok
281
 je @@quit
282
 
283
 xchg eax,ebx
284
@@ok:
285
 mov edi,ecx
286
 
287
; shl edi,6    ;for 320 speed+
288
; shl ecx,8
289
; add edi,ecx
290
 
291
 push eax
292
 mov eax,SCREEN_X
293
 mul edi
294
 mov edi,eax
295
 pop eax
296
 
297
 add edi,eax
298
 
299
 mov ebp,edi
300
 shl ebp,1
301
 add edi,ebp
302
 
303
 add edi,scrbuf
304
 
305
 mov ecx,ebx
306
 sub ecx,eax
307
 
308
lineout:
309
 mov eax,[@@rgb]
310
 mov byte [edi],al
311
 shr eax,8
312
 mov byte [edi+1],al
313
 shr eax,8
314
 mov byte [edi+2],al
315
 add edi,3
316
 dec ecx
317
 jnz lineout
318
 
319
@@quit:
320
 pop ecx
321
 pop ebx
322
 pop eax
323
 ret
324
 
325
scrbuf:
326
I_END: