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

  ViewVC Help
Powered by ViewVC 1.1.26