/[projet1]/public/oric/routines/rasterization/linebench/line8.s
Defence Force logotype

Annotation of /public/oric/routines/rasterization/linebench/line8.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 281 - (hide annotations)
Sun Feb 14 17:24:27 2010 UTC (9 years, 9 months ago) by thrust26
File size: 17646 byte(s)
fixed vertical lines
1 thrust26 261 ; History of linebench timings...
2 dbug 249 ;649
3     ;614 (replacing the update of tmp0)
4     ;607
5 thrust26 253 ;588
6     ;583 after alignment
7     ;579
8 thrust26 258 ;534 redid mainly_vertical
9 thrust26 257 ;529 removed page penalty
10 thrust26 258 ;517 final optimization at mainly_horizontal
11 thrust26 259 ;501 chunking, initial version
12 thrust26 261 ;482 optimized chunking (avg: 38.91 cylces)
13 thrust26 265 ;473 final optimization for mainly_vertical (37.89 -> 38.34 corrected)
14 thrust26 267 ;468 a weird stunt on mainly_horizontal (38.07)
15 thrust26 272 ;467 minor very_horizontal optimization (37.88 -> 38.56 corrected)
16 thrust26 273 ;463 self modifying pointer in mainly_horizontal (38.35)
17     ;459 self modifying pointer in mainly_vertical (37.99)
18     ;459 a little tweak to very_horizontal (37.94)
19 thrust26 278 ;451 refactored to make x-direction always positive (37.07)
20 dbug 218
21 thrust26 261 ; TODOs:
22 thrust26 262 ; + chunking (-35)
23 thrust26 261 ; - two separate branches instead of patching?
24 thrust26 265 ; + countdown minor
25     ; x mainly_horizontal (won't work)
26 thrust26 262 ; + mainly_vertical (-9)
27 thrust26 272 ; o optimizing for space (-2 tables and one alignment page)
28 thrust26 278 ; + optimize horizontal (merge with very_horizontal)
29 thrust26 277 ; o optimize vertical
30 thrust26 272 ; + correct branch taken percentages
31 thrust26 277 ; + always draw left to right and patch y-direction (-8)
32     ; + switch between XOR and OR
33 thrust26 261
34 thrust26 253 .zero
35 dbug 218
36 thrust26 253 ; *= tmp1
37 dbug 218
38 thrust26 253 ;e .dsb 2 ; Error decision factor (slope) 2 bytes in zero page
39     ;i .dsb 1 ; Number of pixels to draw (iteration counter) 1 byte in zp
40     ;dx .dsb 1 ; Width
41     ;dy .dsb 1 ; Height
42     ;_CurrentPixelX .dsb 1
43     ;_CurrentPixelY .dsb 1
44     ;_OtherPixelX .dsb 1
45     ;_OtherPixelY .dsb 1
46    
47     save_a .dsb 1
48 thrust26 255 curBit .dsb 1
49 thrust26 259 chunk .dsb 1
50 thrust26 261 lastSum .dsb 1
51 thrust26 253
52 thrust26 261
53 thrust26 277 ;#define OPP ORA
54     #define OPP EOR
55    
56 thrust26 259 #define BYTE_PIXEL 6
57 thrust26 258 #define X_SIZE 240
58 thrust26 259 #define ROW_SIZE X_SIZE/BYTE_PIXEL
59 thrust26 257
60     #define _INY $c8
61     #define _DEY $88
62     #define _INC_ZP $e6
63     #define _DEC_ZP $c6
64 thrust26 272 #define _INC_ABS $ee
65     #define _DEC_ABS $ce
66 thrust26 277 #define _ADC_IMM $69
67     #define _SBC_IMM $e9
68     #define _BCC $90
69     #define _BCS $b0
70     #define _CLC $18
71     #define _SEC $38
72 thrust26 257
73 thrust26 258
74 thrust26 253 .text
75    
76 thrust26 268 ; .dsb 256-(*&255)
77 thrust26 253
78 thrust26 264 ;**********************************************************
79 thrust26 277 ;
80 dbug 219 ; Expects the following variables to be set when called:
81     ; _CurrentPixelX
82     ; _CurrentPixelY
83     ; _OtherPixelX
84     ; _OtherPixelY
85 thrust26 253 ;
86 dbug 219 _DrawLine8
87 thrust26 277 ;
88     ; compute deltas and signs
89     ;
90 dbug 219 .(
91 thrust26 277 ; test X value
92 thrust26 253 sec
93 thrust26 277 lda _CurrentPixelX
94     sbc _OtherPixelX
95 thrust26 270 bcc cur_smaller
96 thrust26 253 beq end
97 dbug 218
98 thrust26 277 ldy _CurrentPixelX
99     ldx _OtherPixelX
100     sty _OtherPixelX
101     stx _CurrentPixelX
102    
103 thrust26 253 ldy _CurrentPixelY
104     ldx _OtherPixelY
105     sty _OtherPixelY
106     stx _CurrentPixelY
107 dbug 218
108 thrust26 270 bcs end
109 thrust26 253
110     cur_smaller ; y1<y2
111 thrust26 277 ; absolute value
112 thrust26 253 eor #$ff
113     adc #1
114 dbug 222 end
115 thrust26 277 sta dx
116 dbug 219 .)
117 thrust26 277 ;
118     ; initialise screen pointer
119     ;
120 thrust26 253 ldy _CurrentPixelY
121     lda _HiresAddrLow,y ; 4
122     sta tmp0+0 ; 3
123     lda _HiresAddrHigh,y ; 4
124     sta tmp0+1 ; 3 => Total 14 cycles
125 dbug 219 .(
126 thrust26 277 ; test Y value
127 thrust26 253 sec
128 thrust26 277 lda _CurrentPixelY
129     sbc _OtherPixelY
130 thrust26 278 ; beq horizontal
131 thrust26 277 ldx #_DEY
132 thrust26 270 bcs cur_bigger
133 dbug 218
134 thrust26 253 cur_smaller ; x1<x2
135 thrust26 277 ; absolute value
136 thrust26 253 eor #$ff
137     adc #1
138    
139 thrust26 277 ldx #_INY
140 thrust26 270 cur_bigger ; x1>x2
141 thrust26 277 sta dy
142 dbug 219 .)
143 thrust26 277 tay
144 thrust26 267 jmp alignIt
145    
146 thrust26 278 ;horizontal
147     ; jmp draw_totally_horizontal_8
148    
149 thrust26 267 .dsb 256-(*&255)
150    
151     alignIt
152 thrust26 277 ; Compute slope and call the specialized code for mostly horizontal or vertical lines
153     cmp dx
154 thrust26 259 bcc draw_mainly_horizontal_8
155 thrust26 277 lda dx
156     beq draw_totaly_vertical_8
157 thrust26 257 jmp draw_mainly_vertical_8
158 thrust26 253
159 thrust26 264 ;**********************************************************
160 thrust26 277 draw_totaly_vertical_8
161 thrust26 259 .(
162 thrust26 277 cpx #_INY
163 thrust26 281 bne doDey
164     ; iny -> moving up:
165     clc
166     ldx _CurrentPixelX
167     bcc endPatch
168 thrust26 258
169 thrust26 277 ; dey -> moving down:
170 thrust26 281 doDey ; _DEY < _INY -> C==0!
171     ldy _OtherPixelY
172     lda _HiresAddrLow,y ; 4
173     sta tmp0+0 ; 3
174     lda _HiresAddrHigh,y ; 4
175     sta tmp0+1 ; 3 => Total 14 cycles
176 thrust26 258 ldx _OtherPixelX
177    
178 thrust26 277 endPatch
179     ldy _TableDiv6,x
180 thrust26 258 lda _TableBit6Reverse,x ; 4
181 thrust26 277 sta _mask_patch+1
182     ldx dy
183     inx
184 thrust26 258
185 thrust26 277 loop
186     _mask_patch
187     lda #0 ; 2
188     OPP (tmp0),y ; 5*
189     sta (tmp0),y ; 6*= 13**
190 thrust26 258
191 thrust26 277 ; update the screen address:
192     tya ; 2
193     adc #ROW_SIZE ; 2
194     tay ; 2
195     bcc skip ; 2/3 84.4% taken
196     inc tmp0+1 ; 5
197     clc ; 2
198     skip ; = 9.94
199     dex ; 2
200     bne loop ; 2/3=4/5
201 thrust26 258 rts
202 thrust26 277 ; average: 27.94
203 thrust26 258 .)
204    
205 thrust26 264 ;**********************************************************
206 thrust26 255 draw_mainly_horizontal_8
207 thrust26 259 .(
208 thrust26 270 ; A = DX, Y = DY, X = opcode
209 thrust26 277 lda dx
210 thrust26 253 lsr
211 thrust26 259 cmp dy
212 thrust26 267 bcc contMainly
213     jmp draw_very_horizontal_8
214 thrust26 270
215 thrust26 267 contMainly
216 thrust26 253
217 thrust26 259 ; all this stress to be able to use dex, beq :)
218 thrust26 277 cpx #_INY
219     beq doIny
220 thrust26 253
221 thrust26 277 ; dey -> moving down:
222     dey
223     sty _patch_dy+1
224 thrust26 267
225 thrust26 277 lda #<(loopX-_patch_loop-2)
226     sta _patch_loop+1
227    
228     lda #_SBC_IMM
229     sta _patch_adc
230     lda #ROW_SIZE-1
231     sta _patch_adc+1
232     lda #_DEC_ABS
233     ldx #_BCS
234     ldy #_SEC
235 thrust26 258 bne endPatch
236    
237 thrust26 277 doIny
238     sty _patch_dy+1
239 thrust26 267
240 thrust26 277 lda #<(loopX-_patch_loop-1)
241     sta _patch_loop+1
242    
243     lda #_ADC_IMM
244     sta _patch_adc
245     lda #ROW_SIZE
246     sta _patch_adc+1
247     lda #_INC_ABS
248     ldx #_BCC
249     ldy #_CLC
250     endPatch
251     sta _patch_inc1
252     sta _patch_inc2
253     stx _patch_bcc
254     sty _patch_clc1
255     sty _patch_clc2
256    
257 thrust26 258 lda #X_SIZE-1
258 thrust26 277 sec
259 thrust26 258 sbc _OtherPixelX
260 thrust26 277 sta _patch_bit1+1
261     sta _patch_bit2+1
262 thrust26 258
263 thrust26 268 ldx _CurrentPixelX
264 thrust26 267 lda _TableDiv6,x
265     clc
266     adc tmp0
267     tay
268 thrust26 272 lda tmp0+1
269     adc #0
270 thrust26 277 sta _patch_ptr0+2
271     sta _patch_ptr1+2
272 thrust26 267
273 thrust26 258 lda dx
274 thrust26 269 tax
275 thrust26 259 inx ; 2 +1 since we count to 0
276 thrust26 277 sta _patch_dx+1
277 thrust26 258 lsr
278     eor #$ff
279 thrust26 277 _patch_clc1
280 thrust26 258 clc
281 thrust26 267
282     sta save_a ; 3 = 3
283 thrust26 277 _patch_bit1
284     lda _TableBit6-1,x;4
285 thrust26 272 and #$7f ; remove signal bit
286 thrust26 277 bne contColumn
287 thrust26 267
288 thrust26 258 ; a = sum, x = dX+1
289 thrust26 264 ;----------------------------------------------------------
290 thrust26 258 loopX
291 thrust26 277 sec ; 1 50% executed (y--)
292     sta save_a ; 3 = 4
293 thrust26 258 loopY
294 thrust26 277 _patch_bit2
295     lda _TableBit6-1,x ; 4
296     bmi nextColumn ; 2/10.05 16.7% taken
297 thrust26 267 contColumn
298 thrust26 277 _patch_ptr0
299     OPP $a000,y ; 4
300     _patch_ptr1
301     sta $a000,y ; 5 = 16.34
302 thrust26 258
303     dex ; 2 Step in x
304     beq exitLoop ; 2/3 At the endpoint yet?
305     lda save_a ; 3
306 thrust26 277 _patch_dy
307 thrust26 259 adc #00 ; 2 +DY
308 thrust26 277 _patch_loop
309 thrust26 272 bcc loopX ; 2/3=11/12 ~28.0% taken (not 50% due do to special code for very horizontal lines)
310 thrust26 258 ; Time to step in y
311 thrust26 277 _patch_dx
312 thrust26 258 sbc #00 ; 2 -DX
313     sta save_a ; 3 = 5
314    
315 thrust26 259 ; update the screen address:
316 thrust26 267 tya ; 2
317 thrust26 277 _patch_adc
318 thrust26 258 adc #ROW_SIZE ; 2
319 thrust26 267 tay ; 2
320 thrust26 277 _patch_bcc
321 thrust26 267 bcc loopY ; 2/3= 8/9 ~84.4% taken
322 thrust26 277 _patch_inc1
323     inc _patch_ptr0+2 ; 6
324     _patch_inc2
325     inc _patch_ptr1+2 ; 6
326     _patch_clc2
327 thrust26 258 clc ; 2
328 thrust26 277 bne loopY ; 3 = 17
329     ; average: 11.50
330 thrust26 258
331     exitLoop
332 thrust26 253 rts
333 thrust26 267
334     nextColumn
335     and #$7f ; 2 remove signal bit
336     iny ; 2
337 thrust26 277 bne contColumn ; 2/3= 6/7 99% taken
338     inc _patch_ptr0+2 ; 6
339     inc _patch_ptr1+2 ; 6
340     bne contColumn ; 3 = 15
341 thrust26 267
342 thrust26 258 ; Timings:
343 thrust26 277 ; x++/y : 32.34 (28.0%)
344     ; x++/y++: 43.84 (72.0%)
345     ; average: 40.62
346 thrust26 259 .)
347 thrust26 253
348 thrust26 273 ; .dsb 256-(*&255)
349 thrust26 264 ;**********************************************************
350 thrust26 259 draw_very_horizontal_8
351     .(
352     ; dX > 2*dY, here we use "chunking"
353 thrust26 277 ; here we have DY in Y, and the OPCODE (inx, dex) in X
354     sty _patch_dy0+1
355     sty _patch_dy1+1
356     sty _patch_dy2+1
357     cpx #_INY
358 thrust26 261 php
359 thrust26 262 ; setup pointer and Y:
360 thrust26 259 ldx _CurrentPixelX
361 thrust26 261 lda _TableDiv6,x
362     clc
363     adc tmp0
364     tay
365 thrust26 273 lda #0
366     sta tmp0
367 thrust26 261 bcc skipHi
368     inc tmp0+1
369     skipHi
370 thrust26 269 lda _TableDiv6,x
371     asl
372     adc _TableDiv6,x
373     asl
374 thrust26 278 ; clc
375     adc #BYTE_PIXEL;-1
376     ; sec
377     sbc _CurrentPixelX
378 thrust26 277 tax
379     lda Pot2PTbl,x
380     sta chunk
381    
382 thrust26 262 ; patch the code:
383 thrust26 261 plp
384 thrust26 277 beq doIny
385 thrust26 278 ; no y-direction?
386     lda dy
387     beq draw_totally_horizontal_8
388 thrust26 277 ; negative y-direction
389     dec _patch_dy0+1
390 thrust26 259
391 thrust26 277 lda #_SBC_IMM
392     sta _patch_adc
393     lda #ROW_SIZE-1
394     sta _patch_adc+1
395     lda #_BCS
396     sta _patch_bcc
397 thrust26 259 lda #_DEC_ZP
398 thrust26 277 sta _patch_inc
399     lda #_SEC
400 thrust26 259 bne endPatch
401    
402 thrust26 277 doIny
403     ; positive y-direction
404     lda #_ADC_IMM
405     sta _patch_adc
406     lda #ROW_SIZE
407     sta _patch_adc+1
408     lda #_BCC
409     sta _patch_bcc
410 thrust26 259 lda #_INC_ZP
411 thrust26 277 sta _patch_inc
412     lda #_CLC
413 thrust26 259 endPatch
414 thrust26 277 sta _patch_clc
415 thrust26 269
416 thrust26 259 lda dx
417 thrust26 277 sta _patch_dx+1
418 thrust26 261 ; calculate initial bresenham sum
419 thrust26 259 lsr
420 thrust26 261 sta lastSum ; 3 this is used for the last line segment
421     eor #$ff ; = -dx/2
422 thrust26 259 clc
423 thrust26 267 bcc loopX
424 thrust26 270 ; a = sum, x = _CurrentPixelX % 6, y = ptr-offset
425 thrust26 259
426 thrust26 264 ;----------------------------------------------------------
427 thrust26 277 nextColumnC ;
428     clc ; 2 = 2
429 thrust26 259 nextColumn ;
430     tax ; 2
431     lda chunk ; 3
432 thrust26 277 OPP (tmp0),y ; 5
433 thrust26 259 sta (tmp0),y ; 6
434     lda #%00111111 ; 2
435     sta chunk ; 3
436     txa ; 2
437     ldx #BYTE_PIXEL-1 ; 2
438     iny ; 2 next column
439 thrust26 277 bne contColumn ; 2/3=29/30 99% taken
440 thrust26 259 inc tmp0+1 ; 5 dec/inc
441 thrust26 277 bne contColumn ; 3 = 8
442     ; average: 30.03
443 thrust26 262 ;----------------------------------------------------------
444 thrust26 278 draw_totally_horizontal_8
445     lda #1
446     sta _patch_dy2+1
447     lda dx
448     eor #$ff ; = -dx
449     clc
450     bcc loopXEnd
451     ;----------------------------------------------------------
452 thrust26 261 loopY
453 thrust26 277 lda save_a ; 3
454 thrust26 261 dec dy ; 5 all but one vertical segments drawn?
455 thrust26 277 beq exitLoop ; 2/3=10/11 yes, exit loop
456 thrust26 270 dex ; 2
457 thrust26 277 bmi nextColumnC ; 2/38.03 ~16.7% taken (this will continue below)
458     _patch_dy0
459     adc #00 ; 2 = 12.01 +DY, no check necessary here!
460 thrust26 259 loopX
461     dex ; 2
462 thrust26 277 bmi nextColumn ; 2/33.03 ~16.7% taken
463     contColumn ; = 9.17
464     _patch_dy1
465 thrust26 259 adc #00 ; 2 +DY
466 thrust26 272 bcc loopX ; 2/3= 4/5 ~76.4% taken
467 thrust26 259 ; Time to step in y
468 thrust26 277 _patch_dx
469 thrust26 259 sbc #00 ; 2 -DX
470     sta save_a ; 3 = 5
471    
472 thrust26 272 ; plot the last bits of current segment:
473 thrust26 261 lda Pot2PTbl,x ; 4
474 thrust26 259 eor chunk ; 3
475 thrust26 277 OPP (tmp0),y ; 5
476 thrust26 259 sta (tmp0),y ; 6
477 thrust26 261 lda Pot2PTbl,x ; 4
478 thrust26 259 sta chunk ; 3 = 25
479    
480     ; update the screen address:
481     tya ; 2
482 thrust26 277 _patch_adc
483 thrust26 259 adc #ROW_SIZE ; 2
484     tay ; 2
485 thrust26 277 _patch_bcc
486     bcc loopY ; 2/3= 8/9 ~84.4% taken
487     _patch_inc
488 thrust26 259 inc tmp0+1 ; 5
489 thrust26 277 _patch_clc
490 thrust26 259 clc ; 2
491 thrust26 277 bne loopY ; 3 = 10
492     ; average: 10.40
493 thrust26 259
494 thrust26 261 ; Timings:
495 thrust26 277 ; x++/y : 14.17 (76.4%)
496     ; x++/y++: 62.41 (23.6%)
497     ; average: 25.55
498 thrust26 262 ;----------------------------------------------------------
499 thrust26 259 exitLoop
500 thrust26 261 ; draw the last horizontal line segment:
501 thrust26 278 clc
502 thrust26 261 adc lastSum ; 3
503     loopXEnd
504     dex ; 2
505     bmi nextColumnEnd ; 2/37.03 ~16.7% taken
506     contColumnEnd ; = 9.85
507 thrust26 277 _patch_dy2
508 thrust26 261 adc #00 ; 2 +DY
509 thrust26 272 bcc loopXEnd ; 2/3= 4/5 ~38.2% taken
510 thrust26 261
511     ; plot last chunk:
512     lda Pot2PTbl,x ; 4
513 thrust26 259 eor chunk ; 3
514 thrust26 277 OPP (tmp0),y ; 5
515 thrust26 259 sta (tmp0),y ; 6 = 18
516     rts
517 thrust26 262 ;----------------------------------------------------------
518 thrust26 261 nextColumnEnd ;
519     tax ; 2
520     lda chunk ; 3
521 thrust26 277 OPP (tmp0),y ; 5
522 thrust26 261 sta (tmp0),y ; 6
523     lda #%00111111 ; 2
524     sta chunk ; 3
525     txa ; 2
526     ldx #BYTE_PIXEL-1 ; 2
527     iny ; 2 next column
528 thrust26 277 bne contColumnEnd ; 2/3=29/30 99% taken
529 thrust26 261 inc tmp0+1 ; 5 dec/inc
530 thrust26 277 bne contColumnEnd ; 3 = 8
531 thrust26 261
532 thrust26 259 Pot2PTbl
533     .byte %00000001, %00000011, %00000111, %00001111
534     .byte %00011111, %00111111
535     .)
536    
537 thrust26 277 .dsb 256-(*&255)
538    
539 thrust26 264 ;**********************************************************
540 dbug 219 ;
541     ; This code is used when the things are moving faster
542     ; vertically than horizontally
543     ;
544     ; dy>dx
545     ;
546 thrust26 255 draw_mainly_vertical_8
547 thrust26 277 ; A = DX, Y = DY, X = opcode
548 thrust26 259 .(
549 thrust26 255 ; setup bresenham values:
550 thrust26 277 sty _patch_dy+1
551 dbug 219
552 thrust26 255 ; setup direction:
553 thrust26 277 cpx #_DEY ; which direction?
554     bne doIny
555     ; dey -> moving down:
556     lda #_SBC_IMM
557     sta _patch_adc1
558     sta _patch_adc2
559     lda #ROW_SIZE-1
560     sta _patch_adc1+1
561     sta _patch_adc2+1
562     lda #_BCC
563     sta _patch_bcs1
564     sta _patch_bcs2
565     lda #_DEC_ZP
566     sta _patch_inc2
567     ldy #_SEC
568     ldx dx
569     dex
570 thrust26 272 lda #_DEC_ABS
571 thrust26 258 bne endPatch
572 thrust26 253
573 thrust26 277 doIny
574     ; inx -> moving up:
575     lda #_ADC_IMM
576     sta _patch_adc1
577     sta _patch_adc2
578     lda #ROW_SIZE
579     sta _patch_adc1+1
580     sta _patch_adc2+1
581     lda #_BCS
582     sta _patch_bcs1
583     sta _patch_bcs2
584     lda #_INC_ZP
585     sta _patch_inc2
586     ldy #_CLC
587     ldx dx
588 thrust26 272 lda #_INC_ABS
589 thrust26 258 endPatch
590 thrust26 277 sta _patch_inc0
591     sta _patch_inc1
592     stx _patch_dx1+1
593     stx _patch_dx2+1
594     sty _patch_clc1
595     sty _patch_clc2
596    
597 thrust26 255 ; setup X
598 thrust26 264 ldx dx ; X = dx
599 thrust26 255 ; setup current bit:
600     ldy _CurrentPixelX
601     lda _TableBit6Reverse,y ; 4
602     sta curBit
603     ; setup pointer and Y:
604     lda _TableDiv6,y
605     clc
606     adc tmp0
607     tay
608     lda #0
609     sta tmp0
610 thrust26 272 lda tmp0+1
611     adc #0
612 thrust26 277 sta _patch_ptr0+2
613     sta _patch_ptr1+2
614 thrust26 255 ; calculate initial bresenham sum:
615     lda dy
616 thrust26 253 lsr
617 thrust26 262 sta lastSum
618 thrust26 257 eor #$ff ; -DY/2
619 thrust26 255 clc ; 2
620     bcc loopY ; 3
621 thrust26 264 ; a = sum, y = tmp0, x = dX, tmp0 = 0
622     ;----------------------------------------------------------
623 thrust26 262 incHiPtr ;
624 thrust26 277 _patch_inc0
625     inc _patch_ptr0+2 ; 6
626     _patch_inc1
627     inc _patch_ptr1+2 ; 6
628     _patch_clc1
629 thrust26 255 clc ; 2
630 thrust26 278 bne contHiPtr ; 3 = 17
631 thrust26 257 ;----------------------------------------------------------
632 thrust26 255 loopY
633 thrust26 262 sta save_a ; 3
634     lda curBit ; 3 = 6
635     loopX
636 thrust26 253 ; Draw the pixel
637 thrust26 277 _patch_ptr0
638     OPP $a000,y ; 4
639     _patch_ptr1
640 thrust26 272 sta $a000,y ; 5 = 9
641 thrust26 259 ; update the screen address:
642 thrust26 255 tya ; 2
643 thrust26 277 _patch_adc1
644 thrust26 257 adc #ROW_SIZE ; 2
645 thrust26 255 tay ; 2
646 thrust26 277 _patch_bcs1
647 thrust26 272 bcs incHiPtr ; 2/20 ~15.6% taken
648 thrust26 278 contHiPtr ; = 10.81 average
649 thrust26 255 lda save_a ; 3
650 thrust26 277 _patch_dx1
651 thrust26 253 adc #00 ; 2 +DX
652 thrust26 272 bcc loopY ; 2/3= 7/8 ~41.4% taken
653 thrust26 253 ; Time to step in x
654 thrust26 277 _patch_dy
655 thrust26 255 sbc #00 ; 2 -DY
656     sta save_a ; 3 = 5
657 dbug 219
658 thrust26 255 lda curBit ; 3
659 thrust26 277 lsr ; 2
660     beq nextColumn ; 2/12.05 ~16.7% taken
661 thrust26 255 contNextColumn
662 thrust26 277 sta curBit ; 3 =~11.68
663 thrust26 262 ; step in x:
664     dex ; 2 At the endpoint yet?
665     bne loopX ; 2/3= 4/5
666 thrust26 253
667 thrust26 278 ; x ,y++: 33.81 (41.4%)
668     ; x++,y++: 48.49 (58.6%)
669     ; average: 42.41
670 thrust26 262
671     ; draw the last vertical line segment:
672 thrust26 277 ldx _patch_ptr0+2 ; 4
673 thrust26 272 stx tmp0+1 ; 3
674 thrust26 262 lda save_a ; 3
675     adc lastSum ; 3
676     loopYEnd
677     tax ; 2 = 2
678 thrust26 255 ; Draw the pixel
679 thrust26 262 lda curBit ; 3
680 thrust26 277 OPP (tmp0),y ; 5
681 thrust26 262 sta (tmp0),y ; 6 = 14
682     ; update the screen address:
683     tya ; 2
684 thrust26 277 _patch_adc2
685 thrust26 262 adc #ROW_SIZE ; 2
686     tay ; 2
687 thrust26 277 _patch_bcs2
688 thrust26 262 bcs incHiPtrEnd ; 2/13 ~15.6% taken
689     contHiPtrEnd ; = 9.72 average
690     txa ; 2
691 thrust26 277 _patch_dx2
692 thrust26 262 adc #00 ; 2 +DX
693 thrust26 272 bcc loopYEnd ; 2/3= 6/7 ~20.7% taken
694 thrust26 277 rts ; 6
695 thrust26 257 ;----------------------------------------------------------
696 thrust26 255 nextColumn
697 thrust26 277 clc ; 2
698     lda #%00100000 ; 2
699     iny ; 2
700     bne contNextColumn ; 2/3= 8/9 ~99% taken
701     inc _patch_ptr0+2 ; 6
702     inc _patch_ptr1+2 ; 6
703     bcc contNextColumn ; 3 = 15
704 thrust26 255
705 thrust26 262 incHiPtrEnd ; 9
706 thrust26 277 _patch_inc2
707 thrust26 262 inc tmp0+1 ; 5
708 thrust26 277 _patch_clc2
709 thrust26 262 clc ; 2
710 thrust26 277 bne contHiPtrEnd ; 3
711 thrust26 262 ;----------------------------------------------------------
712 thrust26 259 .)
713 thrust26 258
714 thrust26 261 ; *** total timings: ***
715 thrust26 277 ; draw_very_horizontal_8 (29.5%): 25.55 (was 25.73)
716     ; draw_mainly_horizontal_8 (20.5%): 40.62 (was 41.30)
717 thrust26 278 ; draw_mainly_vertical_8 (50.0%): 42.41 (was 43.77)
718 thrust26 261 ;----------------------------------------
719 thrust26 278 ; total average (100.0%): 37.07 (was 37.94)

  ViewVC Help
Powered by ViewVC 1.1.26