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

  ViewVC Help
Powered by ViewVC 1.1.26