1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-17 15:06:29 +00:00
C02/vcs/colors2.c02
2018-01-28 14:44:10 -05:00

77 lines
1.8 KiB
Plaintext

/* Atari VCS Color Bars Program */
#pragma origin $F800 //2k Cartridge
#include <vcshead.h02> //TIA and RIOT Registers
#include <vcsinit.h02> //Initialize VCS
zeropage char clrbkg; //Color Background
zeropage char clrofs; //Color Offset
zeropage char clrmsk; //Color/B&W Mask
/* Generate Vertical Sync Signal */
void vtsync() {
A=2; //Set Bit 2 (D1)
WSYNC=A; //Wait for end of Scanline
VSYNC=A; //Turn On Vertical Sync
WSYNC=A; //Wait 2 More Scanlines
WSYNC=A;
A=0; //Clear Bit 2 (D1)
WSYNC=A; //Wait for End of 3rd Scanline
VSYNC=A; //Turn On Vertical Sync
return;
}
/* Execute Vertical Blank Code */
void vtblnk() {
X=37; //Delay 37 Scanlines
do {
WSYNC=A; //Wait for end of Scanline
A=A-1;
} while (A);
return;
}
/* Execute Kernel Code */
void kernel() {
clrmsk = (SWCHB & 8) ? $FF : $0F;
if (SWCHB & 64) clrofs--; else clrofs++;
A=0; //Clear All Bits
WSYNC=A; //Wait for end of Scanline
VBLANK=A; //Turn Off Vertical Blank
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() {
WSYNC=A; //Wait for end of Scanline
A=2; //Set Bit 2 (D1)
VBLANK=A; //Turn On Vertical Blank
A=27; //Delay 27 Scanlines
do {
WSYNC=A; //Wait for end of Scanline
A=A-1;
} while(A);
return;
}
irqbrk: //Code to Execute when BRK Instruction is Encountered
main: //Start of Program Code
vtsync(); //Generate Vertical Sync Signal
vtblnk(); //Generate Vertical Blank Signal
kernel(); //Execute Kernal Code
ovrscn(); //Execute Overscan Code
goto main;
#include <vcsfoot.h02> //Finalization Code