/[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 218 - (hide annotations)
Sat Jan 30 23:14:12 2010 UTC (9 years, 10 months ago) by dbug
Original Path: users/dbug/rasterization/linebench/line8.s
File size: 3107 byte(s)
8 bit line routine
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_x .dsb 1
18     save_y .dsb 1
19    
20     .text
21    
22     .dsb 256-(*&255)
23    
24    
25    
26    
27    
28    
29     ;Drawin' a line
30     ;v1.3 SLJ 7/2/94
31     _DrawLine8
32     ; Compute DX
33     sec
34     lda _OtherPixelX
35     sta __auto_cpx+1
36     sbc _CurrentPixelX
37     sta __auto_dx+1
38    
39     ; Compute DY
40     sec
41     lda _OtherPixelY
42     sbc _CurrentPixelY
43     sta __auto_sdy+1
44     sta __auto_ady+1
45    
46     ldx _CurrentPixelX ;Plotting coordinates
47     ldy _CurrentPixelY ;in X and Y
48    
49     ; Set the start screen adress
50     lda _HiresAddrLow,y
51     sta tmp0+0
52     lda _HiresAddrHigh,y
53     sta tmp0+1
54    
55     lda #00 ;Saves us a CMP
56     sec
57     __auto_sdy
58     sbc #00 ; -DY
59    
60     ; Draw the first pixel
61     sta save_a
62     sty save_y
63     ldy _TableDiv6,x
64     lda _TableBit6Reverse,x
65     eor (tmp0),y
66     sta (tmp0),y
67     lda save_a
68     ldy save_y
69    
70     clc
71     LOOP
72     inx ; Step in x
73     __auto_ady
74     adc #00 ; +DY
75     bcc NOPE ; Time to step in y?
76     iny ; Step in y
77    
78     ; Set the new screen adress
79     sta save_a
80     lda _HiresAddrLow,y
81     sta tmp0+0
82     lda _HiresAddrHigh,y
83     sta tmp0+1
84     lda save_a
85    
86     __auto_dx
87     sbc #00 ; -DX
88    
89     NOPE
90     ; Draw the pixel
91     sta save_a
92     sty save_y
93     ldy _TableDiv6,x
94     lda _TableBit6Reverse,x
95     eor (tmp0),y
96     sta (tmp0),y
97     lda save_a
98     ldy save_y
99    
100     __auto_cpx
101     cpx #00 ; At the endpoint yet?
102     bne LOOP
103     rts
104    
105    
106     /*
107     Therefore, if we could keep track of the bit position of x, we could tell when x crossed a column,
108     and just add 128 to the base address. Not only that, but we also know to increase the high byte of
109     the pointer by one when we have crossed two columns.
110    
111     The logic is as follows:
112    
113     Find the bit pattern for a given x (for speed, use a table)
114     If it is 10000000 then we have jumped a column
115     If the column we are in doesn't have the high bit set in the low byte of the pointer to the base of
116     the column, then set the high bit (add 128)
117     Otherwise, set the high bit to zero (add 128), and increase the high byte of the column pointer
118     (step into the next page).
119     Here is (more or less) the code:
120     In BASIC:
121    
122     2000 rem bp(x) contains bit position for x
123     2010 if int(x/8) = x/8 then base=base+128
124     2020 poke base+y, (peek(base+y) or bp(x))
125    
126     In assembly:
127     LDA BITP,X 4 ;Load the bit pattern from a table
128     BPL CONT 3 2 ;Still in the same column?
129     EOR $LO 3 ;If not, add 128 to the low byte
130     STA $LO 3
131     BMI CONT 3 2 ;If the high bit is set, stay in the same page
132     INC $HI 5 ;Otherwise point to the next page
133     LDA #$128 2 ;We still need the bit pattern for x!
134     CONT ORA ($LO),Y 5
135     STA ($LO),Y 6 ;Plot the point
136     --------
137     Cycle count: 18 26 32
138    
139     */
140    
141    

  ViewVC Help
Powered by ViewVC 1.1.26