Jump to content

VERA window panning demo 1.0.2b

   (0 reviews)

2 Screenshots

About This File

This program is written using kickc of Jesper Gravgaard. I'm helping him to create a framework encapsulating the CX16 vera in order to be able to quickly create graphical effects for games.

This is a short demo and I hope you like it.

This program uses the keyboard to progress through the program!

So be sure to run this from the desktop, since the emulator on mobile phones do not have a keyboard!

What's New in Version 1.0.1b   See changelog


This code now displays the character set on layer 0, while the default terminal is working with the VERA layer 1.

So, the raster interrupt implementation allows to type on the terminal, while the screen on layer 0 is scrolling in the background :-).

Background transparency in 1 bit per pixel text mode in 16x16 color mode is achieved by ensuring that the background of both layer 1 and layer 2 are black. 

You can experiment with this while typing on the terminal, changing colors, while the scroll on layer 0 is working in the background ...


The demo also illustrates the progress I've been making with the vera encapsulation functions.

// Example program for the Commander X16.
// Demonstrates the usage of the VERA layer 0 and 1.

// Author: Sven Van de Velde

// The default layer of the CX16 is layer 1.
// The CX16 starts in tile map mode, 1BPP in 16 color mode, and uses 8x8 tiles.
// The map base is address 0x00000 in VERA VRAM, the tile map is address 0x0F800.

#include <veralib.h>
#include <printf.h>
#include <6502.h>

void main() {


    // Now we set the tile map width and height.
    vera_set_layer_mapbase(0,0x80); // Set the map base to address 0x10000 in VERA VRAM!
    vera_set_layer_config(0, vera_get_layer_config(1));
    vera_set_layer_tilebase(0, vera_get_layer_tilebase(1));
    dword tilebase = vera_get_layer_tilebase_address(0);
    dword tilecolumn = tilebase;
    dword tilerow = tilebase;

    scroll(0); // Scrolling on conio is deactivated, so conio will output beyond the borders of the visible screen.

    for(byte y:0..15) {
        tilerow = tilebase;
        for(byte r:0..7) {
            tilecolumn = tilerow;
            for(byte x:0..15) {
                byte data = *VERA_DATA0;
                byte bit = data;
                for(byte b:8..1) {
                    bit = (data >> (b-1)) & $1;
                    printf("%c", (char)((bit)?'*':'.'));
                tilecolumn += 8;
            tilerow += 1;
        tilebase += 8*16;

    // Enable VSYNC IRQ (also set line bit 8 to 0)
    *KERNEL_IRQ = &irq_vsync;



    printf("\n\nthis demo displays the design of the standard X16 commander\n");
    printf("character set on the vera layer 0. it's the character set i grew up with :-).\n");
    printf("\nthe smooth scrolling is implemented by manipulating the scrolling \n");
    printf("registers of layer 0. at each raster line interrupt, \n");
    printf("the x and y scrolling registers are manipulated. the cx16 terminal \n");
    printf("works on layer 1. when layer 0 is enabled with the scrolling, \n");
    printf("it gives a nice background effect. this technique can be used to implement\n");
    printf("smooth scrolling backgrounds using tile layouts in games or demos.\n");

    printf("\npress a key to continue ...");


// X sine index
volatile int scroll_x = 0;
volatile int scroll_y = 0;
volatile int delta_x = 2;
volatile int delta_y = 0;
volatile int speed = 2;

// VSYNC Interrupt Routine
__interrupt(rom_sys_cx16) void irq_vsync() {

    scroll_x += delta_x;
    scroll_y += delta_y;

    if( scroll_x>(128*8-80*8)) {
        delta_x = 0;
        delta_y = speed;
        scroll_x = (128*8-80*8);
    if( scroll_y>(128*8-60*8)) {
        delta_x = -speed;
        delta_y = 0;
        scroll_y = (128*8-60*8);
    if(scroll_x<0) {
        delta_x = 0;
        delta_y = -speed;
        scroll_x = 0;
    if(scroll_y<0) {
        delta_x = speed;
        delta_y = 0;
        scroll_y = 0;


    // Reset the VSYNC interrupt
    // Exit CX16 KERNAL IRQ
    asm {
        // soft exit (keep kernal running)
        jmp $e034




  • Like 5
  • Thanks 1

User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

  • Create New...

Important Information

Please review our Terms of Use