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

  ViewVC Help
Powered by ViewVC 1.1.26