-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawing.asm
161 lines (148 loc) · 1.75 KB
/
drawing.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
;; t0 -> x
;; t1 -> y
;; t2 -> colour
;; On exit t3,t4 are the transformed address and X is the colour lookup
.plotPixel
{
LDA t1
LSR A
LSR A
AND #&FE
TAX
LDA t0
AND #&FE
ASL A
ASL A
STA t3
TXA
ADC #&40
STA t4
LDA t1
AND #7
TAY
LDA t0
LSR A
LDA t2
ROL A
TAX
LDA colours,X
EOR (t3),Y ; This can be change to two NOPs to stop the XOR
STA (t3),Y
RTS
}
.plotPixelSet
{
LDA t1
LSR A
LSR A
AND #&FE
TAX
LDA t0
AND #&FE
ASL A
ASL A
STA t3
TXA
ADC #&40
STA t4
LDA t1
AND #7
TAY
LDA t0
LSR A
LDA t2
ROL A
TAX
LDA (t3),Y
BNE noPlot
LDA colours,X
STA (t3),Y
SEC
RTS
.noPlot
CLC
RTS
}
PRINT "* Plot pixel size:", P%-plotPixel
IF FALSE
; Draws a box at t0,t1 with width and height at t2,t3 in colour t4
.drawBox
{
LDA t0
STA orgX
LDA t1
STA orgY
LDA t2
STA width
LDA t3
STA height
LDA t4
STA t2
; t0,t1 -> t0+w,t1
LDA orgX
STA t0
LDA orgY
STA t1
LDA width
STA t5
; change to inc &70
LDA #t0
STA iter+1
JSR drawLineLoop
; t0+w,t1 -> t0+w,t1+h
LDA orgX
CLC
ADC width
STA t0
LDA orgY
STA t1
LDA height
STA t5
; change to inc &71
LDA #t1
STA iter+1
JSR drawLineLoop
; t0,t1 -> t0,t1+h
LDA orgX
STA t0
LDA orgY
STA t1
INC t1
; change to inc &71
LDA #t1
STA iter+1
LDA height
STA t5
JSR drawLineLoop
; t0,t1+h -> t0+w,t1+h
LDA orgX
STA t0
INC t0
LDA orgY
CLC
ADC height
STA t1
; change to inc &71
LDA #t0
STA iter+1
LDA width
STA t5
JSR drawLineLoop
RTS
.orgX
SKIP 1
.orgY
SKIP 1
.width
SKIP 1
.height
SKIP 1
.drawLineLoop
JSR plotPixel
.iter
INC t0
DEC t5
BNE drawLineLoop
RTS
}
ENDIF