/* Atari VCS Color Bars Program */

#pragma origin $F800    //2k Cartridge
#include <vcshead.h02>  //TIA and RIOT Registers
#include <vcsstub.h02>  //Initialize VCS

zeropage char clrbkg; //Background Color
zeropage char clrmov; //Color Movement Flag
zeropage char clrofs; //Color Offset
zeropage char clrmsk; //Color/B&W Mask

/* Setup Code */
void setup() {
  return;
}

/* Vertical Blank Code */
void vrtblk() {
  return;
}

/* Execute Kernel Code */
void kernel() {
  X=192; //Draw 192 Scanlines
  do {
    clrbkg = X;
    if (!SWCHB & 128) clrbkg<<;
    A = clrbkg + clrofs & clrmsk; //Set Background Color
    WSYNC = A;  //Wait for end of Scanline
    COLUBK = A; //Set Background Color
    X--;
  } while (X);
  return;
}

/* Execute Overscan Code */
void ovrscn() {
  if (!SWCHB & 1)  //Game Reset
    clrmov = $FF; //Turn On Scrolling
  if (!SWCHB & 2)  //Game Select
    clrmov = 0;   //Turn Off Scrolling
  clrmsk = (SWCHB & 8) ? $FF : $0F;
  if (clrmov) {
      if (SWCHB & 64) clrofs--; else clrofs++;  
  }
}

#include <vcsfoot.h02>  //Finalization Code


