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

  ViewVC Help
Powered by ViewVC 1.1.26