-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbitmap_scanline_renderer.inc
243 lines (190 loc) · 8.72 KB
/
bitmap_scanline_renderer.inc
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
.org 0
mov offset, PAR
shr offset, #2
and offset, #$7
vsync
rdlong a, hub_fi wz
if_nz jmp #$-1 // wait for line counter reset (vsync)
mov sbuf_ptr, hub_palette
rdbyte palette, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+1, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+2, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+3, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+4, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+5, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+6, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+7, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+8, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+9, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+10, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+11, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+12, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+13, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+14, sbuf_ptr
add sbuf_ptr, #1
rdbyte palette+15, sbuf_ptr
mov scnt, offset
// bitmap
loop
mov loffs, scnt
mov video_ptr, loffs
shl video_ptr, #7
mov ecnt, #32
movd str0, #sbuf
movd str1, #sbuf+1
_l1 rdlong pixels1, video_ptr
add video_ptr, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv4, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv3, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv2, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv1, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv8, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv7, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv6, a
shr pixels1, #4
mov a, pixels1
and a, #$0F
add a, #palette
movs _mv5, a
_mv1 mov colors1, 0-0
shl colors1, #8
_mv2 or colors1, 0-0
shl colors1, #8
_mv3 or colors1, 0-0
shl colors1, #8
_mv4 or colors1, 0-0
str0 mov 0-0, colors1
add str0, inc_dest_2
_mv5 mov colors1, 0-0
shl colors1, #8
_mv6 or colors1, 0-0
shl colors1, #8
_mv7 or colors1, 0-0
shl colors1, #8
_mv8 or colors1, 0-0
str1 mov 0-0, colors1
add str1, inc_dest_2
djnz ecnt, #_l1
// scanline buffer output
emit
rdlong a, hub_fi
cmp a, scnt wz,wc
if_ne jmp #$-2 // wait for line fetch start
mov sbuf_ptr, hub_sbuf
wrlong sbuf, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 1, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 2, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 3, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 4, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 5, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 6, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 7, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 8, sbuf_ptr
add sbuf_ptr, #4
wrlong sbuf + 9, sbuf_ptr
add sbuf_ptr, #4
movd _wr0, #sbuf +(H_RES/4) -1
movd _wr1, #sbuf +(H_RES/4) -2
add sbuf_ptr, #(H_RES-40) -1
movi sbuf_ptr, #((H_RES/4)-10) -2
_wr0 wrlong 0-0, sbuf_ptr
sub _wr0, inc_dest_2
sub sbuf_ptr, i2s7 wc
_wr1 wrlong 0-0, sbuf_ptr
sub _wr1, inc_dest_2
if_nc djnz sbuf_ptr, #_wr0
add scnt, #COGS // next line to render
cmp scnt, #V_RES wc,wz
if_b jmp #loop
jmp #vsync
// driver parameters
hub_video_ram long $0000
hub_palette long $7800
hub_fi long $7EBC
hub_sbuf long $7EC0 + SBUF_OFS
// initialised data and/or presets
inc_dest long 1 << 9
inc_dest_2 long 2 << 9
inc_dest_5 long 5 << 9
i2s7 long 2 << 23 | 7
pixels1 long 0
colors1 long 0
palette long $00, $80, $20, $A0, $08, $88, $28, $A8
long $54, $C0, $30, $F0, $0C, $CC, $3C, $FC
// uninitialised data and/or temporaries
a res 1
data1 res 1
data2 res 1
offset res 1
loffs res 1
ecnt res 1
scnt res 1
video_ptr res 1
// code and/or data repurposed for scanline buffer
sbuf_ptr res 1
sbuf
fit $1F0
/*
* TERMS OF USE: MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/