An Initial Intro to VERA Programming (from BASIC/BASLOAD)

Tutorials and help articles.

(Posts require approval. See pinned post.)
Forum rules
Post guides, tutorials, and other instructional content here.

This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.

Tech support questions should be asked in Hardware or Software support.
Post Reply
voidstar
Posts: 496
Joined: Thu Apr 15, 2021 8:05 am

An Initial Intro to VERA Programming (from BASIC/BASLOAD)

Post by voidstar »

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.

VERATEST.jpg
VERATEST.jpg (110.55 KiB) Viewed 430 times
Thx also to Stefan and Tony for helping clarify and improve some aspects to these examples.
Attachments
TEST1A.BASL.TXT
(2.29 KiB) Downloaded 33 times
TEST1.BASL.TXT
(1.94 KiB) Downloaded 36 times
TEST2.BASL.TXT
(880 Bytes) Downloaded 30 times
TEST2A.BASL.TXT
(754 Bytes) Downloaded 38 times
Post Reply