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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (show annotations)
Fri Feb 5 21:24:38 2010 UTC (9 years, 9 months ago) by dbug
File size: 4902 byte(s)
649->607 thanks to Thomas
1 ; History of timings...
2 ;649
3 ;614 (replacing the update of tmp0)
4 ;607
5
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 ; nop $ea
27 ; inx $e8 11101000
28 ; dex $ca 11001010
29 ; iny $c8 11001000
30 ; dey $88 10001000
31
32
33
34 draw_totaly_vertical_8
35 .(
36 ldx _CurrentPixelX
37 ldy _TableDiv6,x
38 lda _TableBit6Reverse,x ; 4
39 sta _mask_patch+1
40
41 ldx dy
42 inx
43
44 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
51 ; Update screen adress
52 .(
53 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 .)
61 ; ------------------Min=13 Max=17
62
63 dex
64 bne loop
65 rts
66 .)
67
68
69
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
90 cur_bigger ; y1>y2
91 ; Swap X and Y
92 ; So we always draw from top to bottom
93 ldy _CurrentPixelY
94 ldx _OtherPixelY
95 sty _OtherPixelY
96 stx _CurrentPixelY
97
98 ldy _CurrentPixelX
99 ldx _OtherPixelX
100 sty _OtherPixelX
101 stx _CurrentPixelX
102
103 jmp end
104
105 cur_smaller ; y1<y2
106 ; Absolute value
107 eor #$ff
108 adc #1
109 end
110 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
122 ; 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
131 cur_bigger ; x1>x2
132 lda #$ca ; dex
133 bne end
134
135 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
145 ; 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
151 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 .(
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
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 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 ldx _OtherPixelX
215 sta __auto_cpx+1
216
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 __auto_cpx
232 cpx #00 ; At the endpoint yet?
233 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 sty __auto_dy+1
249
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
263 jmp draw_pixel
264
265 loop
266 iny ; Step in y
267 __auto_adx
268 adc #00 ; +DX
269 bcc skip ; Time to step in x?
270
271 __auto_stepx
272 inx ; Step in x
273
274 __auto_dy
275 sbc #00 ; -DY
276
277 skip
278 ; Set the new screen adress
279 sta save_a
280 .(
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
291 draw_pixel
292 ; 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