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

  ViewVC Help
Powered by ViewVC 1.1.26