Page 1 of 1

Assembly Vector Graphics Demo

Posted: Wed Feb 03, 2021 9:17 pm
by gavinhaslehurst


This is a quick demo of a 2D graphics library I've been working on recently. It's written in assembler, and aims to make life a bit easier when it comes to drawing vector graphics. You can define individual polygons which can be moved about and rotated. The source code looks fairly daunting, but when it comes down to it, building, transforming and rendering the polygons is very straightforward. Hopefully this will form the basis of a game at some point soon. (Perhaps an Asteroids clone?) Once I sink my teeth into interrupt handling, I should be able to "vsync" everything so it's flicker-free. 




All comments and suggestions welcome! 




Short screen capture of this demo on YouTube (featuring my tunez!!): 

Commander X16 Demo - Vector Graphics in 6502 Assembly - YouTube




WARNING: For those who are sensitive to flickering/strobing, please be aware that this may cause problems for you. 




--




See below for a quick preview of the game I'm working on, retro flickering and all! 




Desktop 2021.02.07 - 20.15.07.01.gif



Now with less flicker! Using a bit of a hack to switch between VERA layers 0 and 1.  The effect is a bit strange, but I think overall nicer to look at. I think once I get my head around manipulating VERA memory directly I can do this properly. In the meantime, I think I've got far enough to start working on a game based on this code. 




--




Using vsync interrupt to wait before clearing the screen. Still on the flickery side, so any advice appreciated! Thanks to Stephern Horn for his tutorial on interrupts, which was very clear indeed. Check it out here (ASM Programming) Interrupts and interrupt handling · commanderx16/x16-emulator Wiki · GitHub



Re: Assembly Vector Graphics Demo

Posted: Fri Feb 03, 2023 6:46 pm
by pastblast
Are you still working on this? I had some thoughts that might help, if you like.

First, either pre-compute the rotated X/Y coordinates, or at least use integer sin/cos tables (possibly with interpolation, but preferably not) to get your angles.

Second, switch to sprites, and don't draw at all.

Third, if you want to use double buffering (layer 0 versus layer 1), and you want to save some time when clearing the screen, simply redraw what was on the older layer, using the background color. That has to be faster than clearing the entire screen, when the pixels on the screen are relatively sparse, as they are here.