/[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 253 - (hide annotations)
Sat Feb 6 15:41:16 2010 UTC (9 years, 8 months ago) by thrust26
File size: 6688 byte(s)
simple optimizations, 579 now
1 dbug 249 ; History of timings...
2     ;649
3     ;614 (replacing the update of tmp0)
4     ;607
5 thrust26 253 ;588
6     ;583 after alignment
7     ;579
8 dbug 218
9 thrust26 253 .zero
10 dbug 218
11 thrust26 253 ; *= tmp1
12 dbug 218
13 thrust26 253 ;e .dsb 2 ; Error decision factor (slope) 2 bytes in zero page
14     ;i .dsb 1 ; Number of pixels to draw (iteration counter) 1 byte in zp
15     ;dx .dsb 1 ; Width
16     ;dy .dsb 1 ; Height
17     ;_CurrentPixelX .dsb 1
18     ;_CurrentPixelY .dsb 1
19     ;_OtherPixelX .dsb 1
20     ;_OtherPixelY .dsb 1
21    
22     save_a .dsb 1
23     save_y .dsb 1
24    
25     .text
26    
27     .dsb 256-(*&255)
28    
29 dbug 219 ; nop $ea
30     ; inx $e8 11101000
31     ; dex $ca 11001010
32     ; iny $c8 11001000
33     ; dey $88 10001000
34 dbug 222
35    
36    
37     draw_totaly_vertical_8
38     .(
39 thrust26 253 ldx _CurrentPixelX
40     ldy _TableDiv6,x
41     lda _TableBit6Reverse,x ; 4
42     sta _mask_patch+1
43    
44     ldx dy
45     inx
46    
47     clc ; 2
48 dbug 222 loop
49     _mask_patch
50 thrust26 253 lda #0 ; 2
51     eor (tmp0),y ; 5
52     sta (tmp0),y ; 6 => total = 13 cycles
53 dbug 220
54 thrust26 253 ; Update screen adress
55     .(
56     lda tmp0+0 ; 3
57     adc #40 ; 2
58     sta tmp0+0 ; 3
59     bcc skip ; 2 (+1 if taken)
60     inc tmp0+1 ; 5
61     clc ; 2
62 dbug 222 skip
63 thrust26 253 .)
64     ; ------------------Min=13 Max=17
65 dbug 222
66 thrust26 253 dex
67     bne loop
68     rts
69 dbug 222 .)
70 dbug 218
71 thrust26 253
72    
73 dbug 219 ;
74     ; Expects the following variables to be set when called:
75     ; _CurrentPixelX
76     ; _CurrentPixelY
77     ; _OtherPixelX
78     ; _OtherPixelY
79 thrust26 253 ;
80 dbug 219 _DrawLine8
81 thrust26 253 ;
82     ; Compute deltas and signs
83     ;
84    
85     ; Test Y value
86 dbug 219 .(
87 thrust26 253 sec
88     lda _CurrentPixelY
89     sbc _OtherPixelY
90     beq end
91     bcc cur_smaller
92 dbug 218
93 thrust26 253 cur_bigger ; y1>y2
94     ; Swap X and Y
95     ; So we always draw from top to bottom
96     ldy _CurrentPixelY
97     ldx _OtherPixelY
98     sty _OtherPixelY
99     stx _CurrentPixelY
100 dbug 218
101 thrust26 253 ldy _CurrentPixelX
102     ldx _OtherPixelX
103     sty _OtherPixelX
104     stx _CurrentPixelX
105    
106     jmp end
107    
108     cur_smaller ; y1<y2
109     ; Absolute value
110     eor #$ff
111     adc #1
112 dbug 222 end
113 thrust26 253 sta dy
114 dbug 219 .)
115 dbug 218
116 thrust26 253 ;
117     ; Initialise screen pointer
118     ;
119     ldy _CurrentPixelY
120     lda _HiresAddrLow,y ; 4
121     sta tmp0+0 ; 3
122     lda _HiresAddrHigh,y ; 4
123     sta tmp0+1 ; 3 => Total 14 cycles
124    
125     ; Test X value
126 dbug 219 .(
127 thrust26 253 sec
128     lda _CurrentPixelX
129     sbc _OtherPixelX
130     sta dx
131     beq draw_totaly_vertical_8
132     bcc cur_smaller
133 dbug 218
134 thrust26 253 cur_bigger ; x1>x2
135     lda #$ca ; dex
136     bne end
137 dbug 218
138 thrust26 253 cur_smaller ; x1<x2
139     ; Absolute value
140     eor #$ff
141     adc #1
142     sta dx
143    
144     lda #$e8 ; inx
145 dbug 219 end
146     .)
147 dbug 218
148 thrust26 253 jmp alignIt
149 dbug 218
150 thrust26 253 .dsb 256-(*&255)
151    
152     alignIt
153     ; Compute slope and call the specialized code for mostly horizontal or vertical lines
154     ldy dy
155     beq draw_totaly_horizontal_8
156     cpy dx
157     bcs draw_nearly_vertical_8
158    
159     draw_nearly_horizontal_8
160     .(
161     ; here we have DY in Y, and the OPCODE in A
162     sta __auto_stepx ; Write a (dex / nop / inx) instruction
163     cmp #$ca ; dex?
164     bne skipDex
165     dey ; adjust for carry being set in loop
166     skipDex
167     sty __auto_ady+1
168    
169     lda dx
170     sta __auto_dx+1
171    
172     lda _OtherPixelX
173     sta __auto_cpx+1
174    
175     ldx _CurrentPixelX ;Plotting coordinates
176     ldy _CurrentPixelY ;in X and Y
177    
178     lda dy
179     lsr
180     eor #$ff
181     ; clc
182    
183     loopX
184     sta save_a ; 3 = 3
185     loopY
186     ; Draw the pixel
187     __auto_div6
188     ldy _TableDiv6,x ; 4
189     __auto_bit6
190     lda _TableBit6Reverse,x ; 4
191     eor (tmp0),y ; 5*
192     sta (tmp0),y ; 6*= 19
193    
194     __auto_cpx
195     cpx #00 ; 2 At the endpoint yet?
196     beq exitLoop ; 2/3
197 dbug 222 __auto_stepx
198 thrust26 253 inx ; 2 Step in x
199     lda save_a ; 3
200 dbug 222 __auto_ady
201 thrust26 253 adc #00 ; 2 +DY
202     bcc loopX ; 2/3=13/14
203     ; Time to step in y
204     __auto_dx
205     sbc #00 ; 2 -DX
206     sta save_a ; 3 = 5
207    
208     ; Set the new screen adress
209     lda tmp0+0 ; 3
210     adc #40 ; 2
211     sta tmp0+0 ; 3
212     bcc loopY ; 2/3=10/11 ~84 taken
213     inc tmp0+1 ; 5
214     bcs loopY ; 3 = 8
215     ; average: 12.12
216    
217     exitLoop
218     rts
219     ; Timings:
220     ; x++/y : 36
221     ; x++/y++: 49.12
222     ; average: 42.56
223     .)
224    
225 dbug 219 draw_totaly_horizontal_8
226     .(
227 thrust26 253 ; here we have DY in Y, and the OPCODE in A
228     sta _outer_patch ; Write a (dex / nop / inx) instruction
229    
230     ldx _OtherPixelX
231     sta __auto_cpx+1
232    
233     ldx _CurrentPixelX
234    
235     ;
236     ; Draw loop
237     ;
238 dbug 219 outer_loop
239 thrust26 253 ldy _TableDiv6,x
240     lda _TableBit6Reverse,x ; 4
241     eor (tmp0),y ; 5
242     sta (tmp0),y ; 6
243 dbug 219
244     _outer_patch
245 thrust26 253 inx
246 dbug 219
247 thrust26 253 __auto_cpx
248     cpx #00 ; At the endpoint yet?
249     bne outer_loop
250     rts
251     .)
252    
253    
254 dbug 219 ;
255     ; This code is used when the things are moving faster
256     ; vertically than horizontally
257     ;
258     ; dy>dx
259     ;
260 thrust26 253 draw_nearly_vertical_8
261     .(
262     ; here we have DY in Y, and the OPCODE in A
263     sta __auto_stepx ; Write a (dex / nop / inx) instruction
264     sty __auto_dy+1
265 dbug 219
266 thrust26 253 lda dx
267     sta __auto_adx+1
268    
269     lda _OtherPixelY
270     sta __auto_cpy+1
271    
272     ldx _CurrentPixelX ; Plotting coordinates
273     ldy _CurrentPixelY ; in X and Y
274    
275     lda dx
276     lsr
277     eor #$ff ; -DX/2
278     ; clc
279    
280     loop
281     ; Draw the pixel
282     sty save_y ; 3
283     ldy _TableDiv6,x ; 4
284     lda _TableBit6Reverse,x ; 4
285     eor (tmp0),y ; 5*
286     sta (tmp0),y ; 6*
287     lda save_a ; 3
288     ldy save_y ; 3 = 28
289    
290     __auto_cpy
291     cpy #00 ; 2 At the endpoint yet?
292     beq exitLoop ; 2/3
293    
294     iny ; 2 Step in y
295 dbug 219 __auto_adx
296 thrust26 253 adc #00 ; 2 +DX
297     bcc skipX ; 2/3=10/11 ~50% taken
298     ; Time to step in x
299 dbug 219 __auto_stepx
300 thrust26 253 inx ; 2 Step in x
301     __auto_dy
302     sbc #00 ; 2 = 4 -DY
303     skipX
304     ; Set the new screen adress
305     sta save_a ; 3 = 3
306 dbug 219
307 thrust26 253 ; Update screen adress
308     lda tmp0+0 ; 3
309     adc #40 ; 2
310     sta tmp0+0 ; 3
311     bcc loop ; 2/3 ~84% taken
312     inc tmp0+1 ; 5
313     bcs loop ; 3
314     ; = 12.12 average
315    
316     ; x ,y++: 54.12
317     ; x++,y++: 57.12
318     ; average: 55.62
319     exitLoop
320     rts
321     .)

  ViewVC Help
Powered by ViewVC 1.1.26