54
54
55
55
' Setup and start video generator
56
56
or dira, vgapin ' Set video generator output pins
57
- or outa, vgapin ' Drive VGA pins low for blanking
57
+ andn outa, vgapin ' Drive VGA pins low for blanking
58
58
or dira, vspin ' Set VSync signal output pin
59
59
or dira, sigpin ' Set data ready signal output pin
60
60
or dira, syncpin ' Set sync output pins
@@ -65,143 +65,129 @@ vga
65
65
shr cnt , #10 ' Set-up ~1ms wait
66
66
add cnt , cnt ' Add 1ms wait
67
67
waitcnt cnt , #0 ' Allow PLL to settle
68
- mov vcfg, VidCfg ' Configure and start video generator
68
+ mov vcfg, SyncCfg ' Configure and start video generator
69
69
70
- ' Display vertical sync area
70
+ ' Display video
71
71
video or outa, vspin ' Drive vertical sync signal pin high
72
72
mov vptr, numFP ' Initialize vertical sync pointer
73
- : fporch mov vscl, BVidScl ' Set video scale for blank active video area
74
- andn outa, vspin ' Drive vertical sync signal pin low
75
- waitvid sColor, cPixel ' Display blank active video line
76
73
74
+ ' Display vertical sync area
75
+ : fporch mov vscl, blkScale ' Set video scale for blank active video area
76
+ andn outa, vspin ' Drive vertical sync signal pin low
77
+ waitvid sColor, pixel3 ' Display blank active video line
77
78
mov vscl, fphScale ' Set video generator scale to half front porch
78
- waitvid sColor, cPixel ' Display first half of front porch
79
- or outa, syncpin
79
+ waitvid sColor, pixel0 ' Display first half of front porch
80
+ or outa, syncpin ' Take control of sync pins from video generator
80
81
mov vcfg, SyncCfg ' Set video configuration to control sync pins
81
- waitvid sColor, pPixel ' Display second half of front porch
82
+ waitvid sColor, pixel3 ' Display second half of front porch
82
83
andn outa, syncpin ' Hand sync pin control to video generator
83
84
mov vscl, hsScale ' Set video generator scale to horizontal sync
84
- waitvid sColor, hsPixel ' Display horizontal sync
85
- mov vscl, bphScale ' Set video generator scale to half back porch
86
- waitvid sColor, pPixel ' Display first half of back porch
87
- cmp vptr, #1 wz
88
- if_nz or outa, syncpin ' Take sync pin control back from video generator
89
- if_nz waitvid sColor, cPixel ' Display second half of back porch
90
- if_nz mov vcfg, VidCfg ' Set video configuration to control color pins
91
- if_z waitvid sColor, pPixel
92
-
85
+ waitvid sColor, pixel2 ' Display horizontal sync
86
+ mov vscl, bphScale ' Set video generator scale to half back porch
87
+ waitvid sColor, pixel3 ' Display first half of back porch
88
+ or outa, syncpin ' Take sync pin control back from video generator
89
+ waitvid sColor, pixel0 ' Display second half of back porch
90
+ mov vcfg, ColCfg ' Set video configuration to control color pins
93
91
djnz vptr, #: fporch ' Display front porch lines
92
+ mov vcfg, SyncCfg ' Set video generator control to sync pins
94
93
mov vptr, numVS ' Initialize vertical sync pointer
95
- : vsync
96
- mov vscl, BVidScl ' Set video scale for blank active video area
97
- waitvid sColor, vPixel ' Display blank active VSync video line
94
+ : vsync mov vscl, blkScale ' Set video scale for blank active video area
95
+ waitvid sColor, pixel1 ' Display blank active VSync video line
96
+ andn outa, syncpin ' Hand sync pin control to video generator
98
97
mov vscl, fphScale ' Set video generator scale to half front porch
99
- waitvid sColor, vPixel ' Display first half of front porch
100
- waitvid sColor, vPixel ' Display second half of front porch
98
+ waitvid sColor, pixel1 ' Display first half of front porch
99
+ waitvid sColor, pixel1 ' Display second half of front porch
101
100
mov vscl, hsScale ' Set video generator scale to horizontal sync
102
- waitvid sColor, cPixel ' Display horizontal sync
101
+ waitvid sColor, pixel0 ' Display horizontal sync
103
102
mov vscl, bphScale ' Set video generator scale to half back porch
104
- waitvid sColor, vPixel ' Display first half of back porch
105
- waitvid sColor, vPixel ' Display second half of back porch
106
-
103
+ waitvid sColor, pixel1 ' Display first half of back porch
104
+ waitvid sColor, pixel1 ' Display second half of back porch
107
105
djnz vptr, #: vsync ' Display vertical sync lines
108
106
mov vptr, numBP ' Initialize vertical sync pointer
109
- : bporch mov vscl, BVidScl ' Set video scale for blank active video area
110
- waitvid sColor, pPixel ' Display blank active video line
111
-
112
-
107
+ : bporch mov vscl, blkScale ' Set video scale for blank active video area
108
+ waitvid sColor, pixel3 ' Display blank active video line
113
109
mov vscl, fphScale ' Set video generator scale to half front porch
114
- waitvid sColor, pPixel ' Display first half of front porch
115
- waitvid sColor, pPixel ' Display second half of front porch
110
+ waitvid sColor, pixel3 ' Display first half of front porch
111
+ waitvid sColor, pixel3 ' Display second half of front porch
116
112
mov vscl, hsScale ' Set video generator scale to horizontal sync
117
- waitvid sColor, hsPixel ' Display horizontal sync
113
+ waitvid sColor, pixel2 ' Display horizontal sync
118
114
mov vscl, bphScale ' Set video generator scale to half back porch
119
- waitvid sColor, pPixel ' Display first half of back porch
120
- cmp vptr, #1 wz
121
- if_z or outa, syncpin
122
- if_z waitvid sColor, cPixel ' Display second half of back porch
123
- if_z mov vcfg, VidCfg
124
- if_nz waitvid sColor, pPixel
125
-
126
-
115
+ waitvid sColor, pixel3 ' Display first half of back porch
116
+ cmp vptr, #1 wz ' Check if last back porch line
117
+ if_z or outa, syncpin ' Take control of sync pins from video generator
118
+ if_z waitvid sColor, pixel0 ' Display second half of back porch
119
+ if_z mov vcfg, ColCfg ' Set video configuration to control color pins
120
+ if_nz waitvid sColor, pixel3 ' Display second half of back porch
127
121
cmp vptr, dataSig wz ' Check if graphics data ready
128
122
if_z or outa, sigpin ' Signal data ready
129
123
djnz vptr, #: bporch ' Display back porch lines
130
124
andn outa, sigpin ' Disable data ready signal
131
125
132
126
' Display active video
133
127
nextsl add cursl, #1 ' Increment current scanline
134
- active mov vscl, VVidScl ' Set video scale for visible video
128
+ active mov vscl, visScale ' Set video scale for visible video
135
129
jmp #scancode ' Display line
136
130
scanret djnz lptr, #active ' Display same line twice
137
- mov lptr, #2 ' Reset line pointer
138
131
cmp cursl, numLines wz ' Check if at bottom of screen
139
- if_z mov cursl, #0 ' Reset current scanline
132
+ if_z mov cursl, #0 ' Reset current scanline
140
133
wrlong cursl, clptr ' Set current scanline in Main RAM
134
+ mov lptr, #2 ' Reset line pointer
141
135
if_nz jmp #nextsl ' Continue displaying remaining scanlines
142
136
jmp #video ' Return to start of display
143
137
144
- ' Scancode buffer
138
+ ' Scancode resources
145
139
scancode long 0 [80 * 2 ] ' Buffer containing display scancode
146
140
mov vscl, fphScale ' Set video generator scale to half front porch
147
- waitvid sColor, cPixel ' Display first half of front porch
148
- or outa, syncpin
141
+ waitvid sColor, pixel0 ' Display first half of front porch
142
+ or outa, syncpin ' Take control of sync pins from video generator
149
143
mov vcfg, SyncCfg ' Set video configuration to control sync pins
150
- waitvid sColor, pPixel ' Display second half of front porch
144
+ waitvid sColor, pixel3 ' Display second half of front porch
151
145
andn outa, syncpin ' Hand sync pin control to video generator
152
146
mov vscl, hsScale ' Set video generator scale to horizontal sync
153
- waitvid sColor, hsPixel ' Display horizontal sync
154
- mov vscl, bphScale ' Set video generator scale to half back porch
155
- waitvid sColor, pPixel ' Display first half of back porch
156
- or outa, syncpin ' Take sync pin control back from video generator
157
- waitvid sColor, cPixel ' Display second half of back porch
158
- mov vcfg, VidCfg ' Set video configuration to control color pins
147
+ waitvid sColor, pixel2 ' Display horizontal sync
148
+ mov vscl, bphScale ' Set video generator scale to half back porch
149
+ waitvid sColor, pixel3 ' Display first half of back porch
150
+ or outa, syncpin ' Take sync pin control back from video generator
151
+ waitvid sColor, pixel0 ' Display second half of back porch
152
+ mov vcfg, ColCfg ' Set video configuration to control color pins
159
153
jmp #scanret ' Return to rest of display
154
+ iR rdlong pixels, vbptrs+ 0 ' Load next pixels
155
+ iW waitvid pixels, #%% 3210 ' Display pixels
160
156
161
157
' Config values
162
158
vgapin long | < 16 | | < 17 | | < 18 | | < 19 | | < 20 | | < 21 | | < 22 | | < 23 ' VGA output pins
159
+ syncpin long | < 24 | | < 25 ' Sync pins
163
160
sigpin long | < 26 ' Data ready signal pin
164
161
vspin long | < 27 ' VSync signal output pin
165
162
pllfreq long 259917792 ' Counter A frequency
166
163
CtrCfg long %0_00001_101_00000000_000000_000_000000 ' Counter A configuration
167
- VidCfg long %0_01_1_0_0_000_00000000000_010_0_11111111 ' Video generator configuration
168
- VVidScl long %000000000000_00000010_000000001000 ' Video generator visible video scale register
169
- HVidScl long %000000000000_00010000_000010100000 ' Video generator horizontal sync scale register
170
- BVidScl long %000000000000_00000000_001010000000 ' Video generator blank line scale register
164
+ ColCfg long %0_01_1_0_0_000_00000000000_010_0_11111111 ' Video generator color pins configuration
165
+ SyncCfg long %0_01_1_0_0_000_00000000000_011_0_11111111 ' Video generator sync pins configuration
171
166
172
- ' Video Generator inputs
173
- ' ??????????????????????
167
+ ' Video generator resources
168
+ visScale long %000000000000_00000010_000000001000 ' Video generator visible video scale register
169
+ blkScale long %000000000000_00000000_001010000000 ' Video generator blank line scale register
170
+ fphScale long %000000000000_00000000_000000001000 ' Video generator scale for half of front porch
171
+ hsScale long %000000000000_00000000_000001100000 ' Video generator scale for horizontal sync
172
+ bphScale long %000000000000_00000000_000000011000 ' Video generator scale for horizontal sync
173
+ sColor long %00000011_00000001_00000010_00000000 ' Sync colors (porch_HSync_VSync_HVSync)
174
+ pixel0 long %%0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0 ' Porch color blank pixels
175
+ pixel1 long %%1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1 ' VSync pixels
176
+ pixel2 long %% 2_2_2_2_2_2_2_2_2_2_2_2_2_2_2_2 ' HSync sync blank pixels
177
+ pixel3 long %% 3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3 ' Porch sync blank pixels
174
178
175
- ' Video attributes
179
+ ' Video frame attributes
176
180
numFP long 10 ' Number of vertical front porch lines
177
181
numVS long 2 ' Number of vertical sync lines
178
182
numBP long 33 ' Number of vertical back porch lines
179
183
numLines long 240 ' Number of rendered lines
180
184
numSegs long 80 ' Number of scanline segments
181
- dataSig long 15 ' Back porch scanline to signal render cogs
182
-
183
- ' TESTING
184
- sColor long %00000011_00000001_00000010_00000000 ' Sync colors (porch_HSync_VSync_HVSync)
185
- cPixel long %%0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0 ' Porch color blank pixels
186
- vPixel long %%1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1 ' VSync pixels
187
- hsPixel long %% 2_2_2_2_2_2_2_2_2_2_2_2_2_2_2_2 ' HSync sync blank pixels
188
- pPixel long %% 3_3_3_3_3_3_3_3_3_3_3_3_3_3_3_3 ' Porch sync blank pixels
189
- fphScale long %000000000000_00000000_000000001000 ' Video generator scale for half of front porch
190
- hsScale long %000000000000_00000000_000001100000 ' Video generator scale for horizontal sync
191
- bphScale long %000000000000_00000000_000000011000 ' Video generator scale for horizontal sync
192
- bpScale long %000000000000_00000000_000000110000 ' Video generator scale for horizontal sync
193
- SyncCfg long %0_01_1_0_0_000_00000000000_011_0_11111111 ' Video generator sync pins configuration
194
- syncpin long | < 24 | | < 25 ' Sync pins
195
-
196
- ' Instructions used to generate scancode
197
- iR rdlong pixels, vbptrs+ 0 ' Load next pixels
198
- iW waitvid pixels, #%% 3210 ' Display pixels
199
185
200
186
' Other values
201
187
d0s0 long 1 << 9 + 1 ' Value to increment source and destination registers
202
188
d0 long 1 << 9 ' Value to increment destination register
203
189
d1 long 1 << 10 ' Value to incrememnt destination register by 2
204
-
190
+ dataSig long 15 ' Back porch scanline to signal render cogs
205
191
vbptrs long 0 [80 ] ' Buffer containing Main RAM video buffer memory locations
206
192
207
193
' Frame pointers
@@ -214,4 +200,4 @@ clptr res 1 ' Pointer to location of current scanline in Mai
214
200
cursl res 1 ' Container for current scanline
215
201
pixels res 1 ' Container for currently rendering pixels
216
202
217
- fit
203
+ fit
0 commit comments