6502 as a VGA controller
Posted: Sat Mar 06, 2021 3:00 pm
Since it is possible to run W65C02 at 25.175MHz, I wonder how it can serve as a VGA controller with a little bit of glue logic.
VGA needs 3 signals, vertical sync, horizontal sync, and video out. Video out is fastest at 25.175MHz pixel rate; horizontal sync is derived from modulo-800 of the 25.175MHz; and vertical sync is modulo-525 of horizontal sync. Video out is too fast for 6502 to bit bang but can be supported with a 8-bit shift register that 6502 writes to every 8 clocks; horizontal & vertical sync can be software generated.
What can 6502 do in 8 clocks? It needs to fetch graphic data from memory, one fetch every 8 clocks. I'm thinking something like:
repeated 80 times to generate one line of 640 pixel.
Instruction memory is 0x0-0x3FFF and graphic memory is 0x4000 and above. Hardware needs to load data fetched by the LDA instruction into a 8-bit shift register. Any access with addresses A14 or A15 high is to be loaded into the shift register. Horizontal sync and vertical sync are outputs of flip flops written by 6502.
This scheme is for monochrome VGA. Color needs multiple plane of memory and shift registers for R/G/B video which can become complicated rapidly.
Thoughts?
PS, it just occurs to me that this may already has been done. Apology if so and I'd appreciate a link.
VGA needs 3 signals, vertical sync, horizontal sync, and video out. Video out is fastest at 25.175MHz pixel rate; horizontal sync is derived from modulo-800 of the 25.175MHz; and vertical sync is modulo-525 of horizontal sync. Video out is too fast for 6502 to bit bang but can be supported with a 8-bit shift register that 6502 writes to every 8 clocks; horizontal & vertical sync can be software generated.
What can 6502 do in 8 clocks? It needs to fetch graphic data from memory, one fetch every 8 clocks. I'm thinking something like:
Code: Select all
LDA (zp),y
INY
LDA (zp),y
INY
...Instruction memory is 0x0-0x3FFF and graphic memory is 0x4000 and above. Hardware needs to load data fetched by the LDA instruction into a 8-bit shift register. Any access with addresses A14 or A15 high is to be loaded into the shift register. Horizontal sync and vertical sync are outputs of flip flops written by 6502.
This scheme is for monochrome VGA. Color needs multiple plane of memory and shift registers for R/G/B video which can become complicated rapidly.
Thoughts?
PS, it just occurs to me that this may already has been done. Apology if so and I'd appreciate a link.