Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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