I’ve been working on adding some new features to my VGA video card.
The initial FPGA code for the VGA card was very much done as a proof of concept, learning how to generate VGA signals, using the SRAM as a framebuffer and interfacing with the 68000. It was a learning experience in the VGA card design and expanding my knowledge of VHDL.
The previous version of the card was working well and it had a 80x30 text mode and a 640x480 12-bit (4096) bitmap mode along with some hardware accelerated drawing functions.
The text mode was working but has been updated as previously, while the text colour could be changed, it was limited to changing the colour of all text on screen. Now each character has its own foreground and background attributes. It’s limited to 16 colours each for the foreground and background from a fixed palette.
While having a 640x480 bitmap mode was nice but updating bitmap graphics at a reasonable speed on a 10Mhz CPU is not going to be practical so the plan has always been to have a lower resolution “game” mode of 320x240 with a 12, 8 or 4-bit palette that supports tile based graphics and sprites in addition to the bitmap display. This update implements the 320x240 bitmap mode and also includes an 8-bpp palette. Both bitmap modes can use the full 12-bit colour or the palette for display.
The initial implementation of the 320x240 mode was reasonably straight forward as it’s just adjusting the address in SRAM where it was fetching data. There is no caching of the data so currently the same data is being fetched from the RAM framebuffer more than once in the 8-bpp and the lower resolution modes. This is fine for just displaying bitmap data as it currently is, but this will need to be changed to add some of the planned features.
Once the different bitmap modes were working, the next feature I wanted to add was hardware scrolling. In theory this is an easy solution, just calculate the address in memory for the bitmap data you want to display. For resolutions of 640 and 320, they translate into fairly simple math for the FPGA to calculate the address for the next row of data. The initial idea was to have bitmaps of arbitrary sizes.
In practice having an arbitrary sized bitmap caused some speed issues in my implementation so as a compromise for that, using fixed width modes in a similar fashion to how the V9990 handle things solves the math issues. Bitmap widths can now be 512, 1024, 2048 or 4096 pixels wide. As the VGA card only has 2MB of video RAM, it limits what is available in different video modes. Vertical height is limited by the bitmap width and the available video memory. Fixing the bitmap width simplifies the scroll logic and scrolling past the bitmap width just results in the image wrapping around.
For the palette, it allows a selection of 256 colours out of a possible 4096. Currently only one palette is used but there a total of 4 separate palettes is supported. The plan eventually is to be able to have different palettes for bitmaps, tiles and sprites.
Overall I’m happy with the progress made but there are some limitations on the new video modes. The hardware drawing functions that I had previously implemented will only work on the 12bpp modes.
The next stage is to add caching of pixel data to make memory access more efficient. Once that is done, the next stage is to implement a tiled bitmap mode.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Hi again, do you think you ddraig can run with 16MHz CPU, by simply changing the crystal? Maybe I can build your system as a starting point for my planned 68ec020 system. I have all parts besides the fpga and the PCB.
Are you sure? yes | no
Hi Stephen,
I like your Y Ddraig project and are just beginning to plan something like that around an 68ec020. But I want a standalone system with onboard graphics. So I came around your VGA card. Specifications look good but it the video the graphic drawing seems very slow. Why is that?
Ages ago I had an Atari ST with an ISA ET4000 VGA card addon. It was possible to smoothly use a desktop resolution 800x600 with 256 colors on that 8MHz 68k machine. Only jpeg picture decoding was very slow.
So, what do you think is the bottleneck in your design?
I also like your idea of the expansion connectors. My first idea was to implement an ISA bus, but nowadays old ISA cards are seldom and expensive, so why. A real 68000 bus is a more reasonable solution.
Thanks for those great project ideas.
Thorsten
Are you sure? yes | no
Hi Thorsten,
The speed doesn't look that great on the card on that video, that is in part, because I don't think the video is actually showing the best use of the card either. It was more a test of some of the bitmap modes and features like the scrolling. The bitmaps are either 512, 1024, 2048 or 4096 pixels wide so often there is a lot more data being written rather than display. Additionally, my demo program is written in not very optimised C code and loading the image data from disk while uploading it to the video card memory at the same time so there is plenty of places where the speed could be improved.
I do plan to implement a simple 640x480 GUI at some point and that will help focus on speed but before I get to that I have a new version of the VGA card that has some minor improvements and can display a 16-bit color mode. The biggest change on the new video card will be re-writing the VHDL for the card from scratch. I have a better understanding of what’s required now and plan to implement everything in a much cleaner way,
I did look at a couple of other buses before I decided to use my own, there are things like VME bus which works well with the 68000 if you want to use a standard but it can be an interesting task implementing your own as well.
Are you sure? yes | no