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

  ViewVC Help
Powered by ViewVC 1.1.26