An Initial Intro to VERA Programming (from BASIC/BASLOAD)
Posted: Fri Sep 13, 2024 5:54 am
Here is a set of BASLOAD examples to demonstrate mainly how to use the ADDR.L, ADDR.M, ADDR.H VERA registers to interact with the graphics display of the X16.
EDIT: Improved TEST1A to be a bit more interesting (by using RND).
TEST1: How to "bit twiddle" a linear VERA address offset (stored as a BASIC variable) into individual bytes to be applied to the VERA registers. Part of this example also includes a slight distraction related to how AND, OR, HEX$ BASIC keywords can only be applied to signed-integers (which itself is a bit of a lengthy explanation on why all that is - but in short, this example shows how to resolve that limitation by using a DEF FN). This is not the best or fastest way to interact with VERA, so this is a talking-point or instructive way to get oriented about the concept (that you "talk to" the display via $9F20/21/22/23).
TEST1A: This example shows how to work with general X/Y coordinates with VERA, to convert them into a linear VERA address offset and vice versa. If you wanted your own version of BASIC PSET (such as in a different language besides BASIC), this is an example of how to do so (i.e. to get some pixels somewhere on the screen). Example shows a scattering of pixels near the center of the screen.
TEST2: Evolving from TEST1, this example shows how to manage a "17-bit increment" yourself. This is faster than the more complicated DEF FN and logical operations of TEST1, but maybe only about 20% (even in WARP mode, this solution is quite slow in the emulator). But it does have the benefit of still being able to overlay PRINT content.
TEST2A: This example enables the "auto-increment" feature of VERA, demonstrating a substantial improvement in performance when doing so. This is good for "linear painting" (background), but aspects of TEST1A is still needed for more "surgical drawing" of precise shapes (such as how the animated character in the King's Quest demo may do its user-controlled movement).
The VERA "Programmer's Reference" is here:
https://github.com/X16Community/x16-doc ... ference.md
These are some "concrete examples" that may help others get started. There is still a lot more to VERA than this (palettes, sprites, layers, etc.), much of which still isn't exactly clear from the Programmer's Reference. But maybe these small initial steps might help some start to interpret and experiment with the technical info that is there in that reference.
Thx also to Stefan and Tony for helping clarify and improve some aspects to these examples.
EDIT: Improved TEST1A to be a bit more interesting (by using RND).
TEST1: How to "bit twiddle" a linear VERA address offset (stored as a BASIC variable) into individual bytes to be applied to the VERA registers. Part of this example also includes a slight distraction related to how AND, OR, HEX$ BASIC keywords can only be applied to signed-integers (which itself is a bit of a lengthy explanation on why all that is - but in short, this example shows how to resolve that limitation by using a DEF FN). This is not the best or fastest way to interact with VERA, so this is a talking-point or instructive way to get oriented about the concept (that you "talk to" the display via $9F20/21/22/23).
TEST1A: This example shows how to work with general X/Y coordinates with VERA, to convert them into a linear VERA address offset and vice versa. If you wanted your own version of BASIC PSET (such as in a different language besides BASIC), this is an example of how to do so (i.e. to get some pixels somewhere on the screen). Example shows a scattering of pixels near the center of the screen.
TEST2: Evolving from TEST1, this example shows how to manage a "17-bit increment" yourself. This is faster than the more complicated DEF FN and logical operations of TEST1, but maybe only about 20% (even in WARP mode, this solution is quite slow in the emulator). But it does have the benefit of still being able to overlay PRINT content.
TEST2A: This example enables the "auto-increment" feature of VERA, demonstrating a substantial improvement in performance when doing so. This is good for "linear painting" (background), but aspects of TEST1A is still needed for more "surgical drawing" of precise shapes (such as how the animated character in the King's Quest demo may do its user-controlled movement).
The VERA "Programmer's Reference" is here:
https://github.com/X16Community/x16-doc ... ference.md
These are some "concrete examples" that may help others get started. There is still a lot more to VERA than this (palettes, sprites, layers, etc.), much of which still isn't exactly clear from the Programmer's Reference. But maybe these small initial steps might help some start to interpret and experiment with the technical info that is there in that reference.
Thx also to Stefan and Tony for helping clarify and improve some aspects to these examples.