/[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 224 - (hide 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 dbug 218
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 dbug 219 ; nop $ea
24     ; inx $e8 11101000
25     ; dex $ca 11001010
26     ; iny $c8 11001000
27     ; dey $88 10001000
28 dbug 222
29    
30    
31     draw_totaly_vertical_8
32     .(
33     ldx _CurrentPixelX
34 dbug 219 ldy _TableDiv6,x
35 dbug 222 lda _TableBit6Reverse,x ; 4
36     sta _mask_patch+1
37 dbug 219
38 dbug 222 ldx dy
39     inx
40 dbug 220
41 dbug 222 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 dbug 220
48 dbug 222 ; 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 dbug 220
63 dbug 218
64 dbug 219
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 dbug 218
85 dbug 219 cur_bigger ; y1>y2
86     ; Swap X and Y
87     ; So we always draw from top to bottom
88 dbug 222 ldy _CurrentPixelY
89 dbug 219 ldx _OtherPixelY
90 dbug 222 sty _OtherPixelY
91 dbug 219 stx _CurrentPixelY
92 dbug 218
93 dbug 222 ldy _CurrentPixelX
94 dbug 219 ldx _OtherPixelX
95 dbug 222 sty _OtherPixelX
96 dbug 219 stx _CurrentPixelX
97    
98     jmp end
99    
100     cur_smaller ; y1<y2
101     ; Absolute value
102     eor #$ff
103     adc #1
104 dbug 222 end
105 dbug 219 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 dbug 218
117 dbug 219 ; 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 dbug 218
126 dbug 219 cur_bigger ; x1>x2
127     lda #$ca ; dex
128     bne end
129 dbug 218
130 dbug 219 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 dbug 218
140 dbug 219 ; 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 dbug 218
146 dbug 222 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 dbug 219 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 dbug 222 ldx _OtherPixelX
210     sta __auto_cpx+1
211 dbug 219
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 dbug 222 __auto_cpx
227     cpx #00 ; At the endpoint yet?
228 dbug 219 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 dbug 222 sty __auto_dy+1
244 dbug 219
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 dbug 222
258     jmp draw_pixel
259 dbug 219
260     loop
261     iny ; Step in y
262     __auto_adx
263     adc #00 ; +DX
264 dbug 222 bcc skip ; Time to step in x?
265 dbug 219
266     __auto_stepx
267     inx ; Step in x
268    
269     __auto_dy
270     sbc #00 ; -DY
271    
272 dbug 222 skip
273 dbug 219 ; 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 dbug 222 draw_pixel
281 dbug 219 ; 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