/[projet1]/public/oric/routines/rasterization/CircleBench/circle.s
Defence Force logotype

Contents of /public/oric/routines/rasterization/CircleBench/circle.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 236 - (show annotations)
Wed Feb 3 20:00:30 2010 UTC (9 years, 9 months ago) by dbug
File size: 7816 byte(s)
Modified the parameters to get a complete clipping window (more practical to find errors when testing), removed the useless variables.
1 ; History of timings...
2 ; Using (10,160)
3 ;1186
4 ;1136
5 ;993
6 ;949
7 ;874
8 ;840
9 ;820
10 ;801
11 ;785
12 ;....
13 ; Using (120,100)
14 ;845
15 ; Using clipping to 10/190 vertically
16 ;827
17
18
19 #include "params.h"
20
21
22 .zero
23
24 X1 .byt 0
25 Y1 .byt 0
26
27 save_y .dsb 1
28
29 ; Circle centre and radius
30 _CentreY .word 0
31 _CentreX .word 0
32 _Radius .word 0
33
34 ; Variables for circlepoints
35 sy .word 0
36 sx .word 0
37
38 p .word 0
39
40
41 .text
42
43 _circleMidpoint
44 .(
45
46 ; Check if circle is visible
47 ;; _CentreX + _Radius < lhs of screen fails
48 lda _CentreX
49 clc
50 adc _Radius
51 sta tmp
52 lda _CentreX+1
53 adc _Radius+1
54 sta tmp+1
55 .(
56 lda tmp
57 cmp #(CLIP_LEFT)
58 lda tmp+1
59 sbc #0
60 bvc ret ; N eor V
61 eor #$80
62 ret
63 .)
64 bmi circleExit
65
66 ;; x - size > rhs of screen fails
67 lda _CentreX
68 sec
69 sbc _Radius
70 sta tmp
71 lda _CentreX+1
72 sbc _Radius+1
73 sta tmp+1
74 .(
75 lda tmp
76 cmp #(CLIP_RIGHT-1)
77 lda tmp+1
78 sbc #0
79 bvc ret ; N eor V
80 eor #$80
81 ret
82 .)
83 bpl circleExit
84
85 ;; y + size < top of screen fails
86 lda _CentreY
87 clc
88 adc _Radius
89 sta tmp
90 lda _CentreY+1
91 adc _Radius+1
92 sta tmp+1
93 .(
94 lda tmp
95 cmp #(CLIP_TOP)
96 lda tmp+1
97 sbc #0
98 bvc ret ; N eor V
99 eor #$80
100 ret
101 .)
102
103 bmi circleExit
104
105 ;; y - size > bot of screen fails
106 lda _CentreY
107 sec
108 sbc _Radius
109 sta tmp
110 lda _CentreY+1
111 sbc _Radius+1
112 sta tmp+1
113 .(
114 lda tmp
115 cmp #(CLIP_BOTTOM-1)
116 lda tmp+1
117 sbc #0
118 bvc ret ; N eor V
119 eor #$80
120 ret
121 .)
122 bpl circleExit
123
124 drawit
125 ;x=0;y=radius
126 lda #0
127 sta sx
128 sta sx+1
129 lda _Radius
130 sta sy
131 lda _Radius+1
132 sta sy+1
133
134 ; p=1-radius
135 lda #1
136 sec
137 sbc _Radius
138 sta p
139 lda #0
140 sbc _Radius+1
141 sta p+1
142
143 draw
144 ; circlePoints (xCenter, yCenter, x, y);
145 jmp _circlePoints
146 .)
147
148 circleExit
149 rts
150
151
152 ;while (x < y) {
153 ; x++;
154 ; if (p < 0)
155 ; p += 2 * x + 1;
156 ; else {
157 ; y--;
158 ; p += 2 * (x - y) + 1;
159 ; }
160 ; circlePoints (xCenter, yCenter, x, y);
161 ; }
162
163 ;.dsb 256-(*&255) 825 with, 822 without Oo
164
165 loop
166 .(
167 sec
168 lda sx
169 sbc sy
170 lda sx+1
171 sbc sy+1
172 bpl circleExit
173
174 inc sx
175 bne noinc
176 inc sx+1
177 noinc
178
179 lda p+1
180 bpl positivep
181
182 lda sx
183 asl
184 sta tmp
185 lda sx+1
186 rol
187 sta tmp+1
188
189 inc tmp
190 bne noinc2
191 inc tmp+1
192 noinc2
193 lda p
194 clc
195 adc tmp
196 sta p
197 lda p+1
198 adc tmp+1
199 sta p+1
200
201 jmp _circlePoints
202
203 positivep
204
205 lda sy
206 bne nodec
207 dec sy+1
208 nodec
209 dec sy
210
211 lda sx
212 sec
213 sbc sy
214 sta tmp
215 lda sx+1
216 sbc sy+1
217 sta tmp+1
218
219 asl tmp
220 rol tmp+1
221
222 inc tmp
223 bne noinc3
224 inc tmp+1
225 noinc3
226
227 lda p
228 clc
229 adc tmp
230 sta p
231 lda p+1
232 adc tmp+1
233 sta p+1
234
235 ;jmp _circlePoints
236
237 .)
238
239 _circlePoints
240 .(
241 ; Calculate _CentreY+y
242 lda _CentreY
243 clc
244 adc sy
245 tay
246 lda _CentreY+1
247 adc sy+1
248 sta Y1
249
250 ; Calculate _CentreX+x
251 lda _CentreX
252 clc
253 adc sx
254 tax
255 lda _CentreX+1
256 adc sx+1
257 ora Y1
258 bne skip1
259
260 .(
261 cpx #(CLIP_RIGHT)
262 bcs end
263 cpx #(CLIP_LEFT)
264 bcc end
265 cpy #(CLIP_BOTTOM)
266 bcs end
267 cpy #(CLIP_TOP)
268 bcc end
269
270 lda _HiresAddrLow,y ; 4
271 sta tmp0+0 ; 3
272 lda _HiresAddrHigh,y ; 4
273 sta tmp0+1 ; 3 => Total 14 cycles
274
275 sty save_y
276 ldy _TableDiv6,x
277 lda _TableBit6Reverse,x ; 4
278 ora (tmp0),y
279 sta (tmp0),y
280 ldy save_y
281 end
282
283 .)
284
285
286 skip1
287 ; Calculate _CentreY+y (already done)
288 ; Calculate _CentreX-x
289 lda _CentreX
290 sec
291 sbc sx
292 tax
293 lda _CentreX+1
294 sbc sx+1
295 sta X1
296 ora Y1
297 bne skip2
298
299 .(
300 cpx #(CLIP_RIGHT)
301 bcs end
302 cpx #(CLIP_LEFT)
303 bcc end
304 cpy #(CLIP_BOTTOM)
305 bcs end
306 cpy #(CLIP_TOP)
307 bcc end
308
309 lda _HiresAddrLow,y ; 4
310 sta tmp0+0 ; 3
311 lda _HiresAddrHigh,y ; 4
312 sta tmp0+1 ; 3 => Total 14 cycles
313
314 ldy _TableDiv6,x
315 lda _TableBit6Reverse,x ; 4
316 ora (tmp0),y
317 sta (tmp0),y
318 end
319
320 .)
321
322 skip2
323 ; Calculate _CentreY-y
324 lda _CentreY
325 sec
326 sbc sy
327 tay
328 lda _CentreY+1
329 sbc sy+1
330 sta Y1
331 ora X1
332 bne skip3
333
334 ; Calculate _CentreX-x (already done)
335
336 .(
337 cpx #(CLIP_RIGHT)
338 bcs end
339 cpx #(CLIP_LEFT)
340 bcc end
341 cpy #(CLIP_BOTTOM)
342 bcs end
343 cpy #(CLIP_TOP)
344 bcc end
345
346 lda _HiresAddrLow,y ; 4
347 sta tmp0+0 ; 3
348 lda _HiresAddrHigh,y ; 4
349 sta tmp0+1 ; 3 => Total 14 cycles
350
351 sty save_y
352 ldy _TableDiv6,x
353 lda _TableBit6Reverse,x ; 4
354 ora (tmp0),y
355 sta (tmp0),y
356 ldy save_y
357 end
358
359 .)
360
361 skip3
362 ; Calculate _CentreY-y (already done)
363 ; Calculate _CentreX+x
364 lda _CentreX
365 clc
366 adc sx
367 tax
368 lda _CentreX+1
369 adc sx+1
370 sta X1
371 ora Y1
372 bne skip4
373
374 .(
375 cpx #(CLIP_RIGHT)
376 bcs end
377 cpx #(CLIP_LEFT)
378 bcc end
379 cpy #(CLIP_BOTTOM)
380 bcs end
381 cpy #(CLIP_TOP)
382 bcc end
383
384 lda _HiresAddrLow,y ; 4
385 sta tmp0+0 ; 3
386 lda _HiresAddrHigh,y ; 4
387 sta tmp0+1 ; 3 => Total 14 cycles
388
389 ldy _TableDiv6,x
390 lda _TableBit6Reverse,x ; 4
391 ora (tmp0),y
392 sta (tmp0),y
393 end
394
395 .)
396
397 skip4
398 ; Calculate _CentreY+x
399 lda _CentreY
400 clc
401 adc sx
402 tay
403 lda _CentreY+1
404 adc sx+1
405 sta Y1
406
407 ; Calculate _CentreX+y
408 lda _CentreX
409 clc
410 adc sy
411 tax
412 lda _CentreX+1
413 adc sy+1
414 ora Y1
415 bne skip5
416
417 .(
418 cpx #(CLIP_RIGHT)
419 bcs end
420 cpx #(CLIP_LEFT)
421 bcc end
422 cpy #(CLIP_BOTTOM)
423 bcs end
424 cpy #(CLIP_TOP)
425 bcc end
426
427 lda _HiresAddrLow,y ; 4
428 sta tmp0+0 ; 3
429 lda _HiresAddrHigh,y ; 4
430 sta tmp0+1 ; 3 => Total 14 cycles
431
432 sty save_y
433 ldy _TableDiv6,x
434 lda _TableBit6Reverse,x ; 4
435 ora (tmp0),y
436 sta (tmp0),y
437 ldy save_y
438 end
439
440 .)
441
442 skip5
443 ; Calculate _CentreX+y (already done)
444 ; Calculate _CentreX-y
445 lda _CentreX
446 sec
447 sbc sy
448 tax
449 lda _CentreX+1
450 sbc sy+1
451 sta X1
452 ora Y1
453 bne skip6
454
455 .(
456 cpx #(CLIP_RIGHT)
457 bcs end
458 cpx #(CLIP_LEFT)
459 bcc end
460 cpy #(CLIP_BOTTOM)
461 bcs end
462 cpy #(CLIP_TOP)
463 bcc end
464
465 lda _HiresAddrLow,y ; 4
466 sta tmp0+0 ; 3
467 lda _HiresAddrHigh,y ; 4
468 sta tmp0+1 ; 3 => Total 14 cycles
469
470 sty save_y
471 ldy _TableDiv6,x
472 lda _TableBit6Reverse,x ; 4
473 ora (tmp0),y
474 sta (tmp0),y
475 ldy save_y
476 end
477
478 .)
479
480 skip6
481 ; Calculate _CentreX-y (already done)
482 ; Calculate _CentreY-x
483 lda _CentreY
484 sec
485 sbc sx
486 tay
487 lda _CentreY+1
488 sbc sx+1
489 sta Y1
490 ora X1
491 bne skip7
492
493 .(
494 cpx #(CLIP_RIGHT)
495 bcs end
496 cpx #(CLIP_LEFT)
497 bcc end
498 cpy #(CLIP_BOTTOM)
499 bcs end
500 cpy #(CLIP_TOP)
501 bcc end
502
503 lda _HiresAddrLow,y ; 4
504 sta tmp0+0 ; 3
505 lda _HiresAddrHigh,y ; 4
506 sta tmp0+1 ; 3 => Total 14 cycles
507
508 sty save_y
509 ldy _TableDiv6,x
510 lda _TableBit6Reverse,x ; 4
511 ora (tmp0),y
512 sta (tmp0),y
513 ldy save_y
514 end
515
516 .)
517
518 skip7
519 ; Calculate _CentreY-x (already done)
520 ; Calculate _CentreX+y
521 lda _CentreX
522 clc
523 adc sy
524 tax
525 lda _CentreX+1
526 adc sy+1
527 ora Y1
528 bne skip8
529
530 .(
531 cpx #(CLIP_RIGHT)
532 bcs end
533 cpx #(CLIP_LEFT)
534 bcc end
535 cpy #(CLIP_BOTTOM)
536 bcs end
537 cpy #(CLIP_TOP)
538 bcc end
539
540 lda _HiresAddrLow,y ; 4
541 sta tmp0+0 ; 3
542 lda _HiresAddrHigh,y ; 4
543 sta tmp0+1 ; 3 => Total 14 cycles
544
545 ldy _TableDiv6,x
546 lda _TableBit6Reverse,x ; 4
547 ora (tmp0),y
548 sta (tmp0),y
549 end
550
551 .)
552
553 skip8
554 jmp loop
555 .)
556
557
558
559
560
561
562
563
564

  ViewVC Help
Powered by ViewVC 1.1.26