diff --git a/vcs/banks.a02 b/vcs/banks.a02 new file mode 100644 index 0000000..49fe97e --- /dev/null +++ b/vcs/banks.a02 @@ -0,0 +1,11 @@ +;Bank Switching Registers +BANK0 EQU $1FF4 ;Select Bank 0 (32K) +BANK1 EQU $1FF5 ;Select Bank 1 (32K) +BANK2 EQU $1FF6 ;Select Bank 2 (32K) Bank 0 (16K) Switch Banks (8K) +BANK3 EQU $1FF7 ;Select Bank 3 (32K) Bank 1 (16K) Switch Banks (8K) +BANK4 EQU $1FF8 ;Select Bank 4 (32K) Bank 2 (16K) +BANK5 EQU $1FF9 ;Select Bank 5 (32K) Bank 3 (16K) +BANK6 EQU $1FFA ;Select Bank 6 (32K) +BANK7 EQU $1FFB ;Select Bank 7 (32K) + + diff --git a/vcs/collect02.c02 b/vcs/collect02.c02 new file mode 100644 index 0000000..512a8db --- /dev/null +++ b/vcs/collect02.c02 @@ -0,0 +1,166 @@ +/* Atari VCS 2 Line Kernel Test` */ + +#pragma origin $F800 //4k Cartridge +#include //TIA and RIOT Registers +#include //VCS Program Stub +#include //VCS Library Routines +#include //Color Selection Routines +#include //Two Player Score Kernel +#include //Timer Bar Kernel +#include //Arena Two-Line Kernel + +#pragma zeropage $80 + +//Boolean Equivalents +#define TRUE = $FF +#define FALSE = 0 + +//TIA Register Bit Masks +#define CLEAR = 0 +#define SET = $0B + +//Console Switch Bit Masks +#define P1DIFF = $80 //Player 1 Difficulty +#define P0DIFF = $40 //Player 0 Difficulty +#define SELECT = $02 //Game Select +#define RESET = $01 //Game Reset + +//Joystick Direction Bit Masks +#define STK1UP = $01 //Joystick Up +#define STK1DN = $02 //Joystick Down +#define STK1LF = $04 //Joystick Left +#define STK1RT = $08 //Joystick Right +#define STK0UP = $10 //Joystick Up +#define STK0DN = $20 //Joystick Down +#define STK0LF = $40 //Joystick Left +#define STK0RT = $80 //Joystick Right + + +//Constants Required by arena.h02 +#define ARLINS = 88 //88 Kernel Lines = 176 Scan Lines +#define ARMULT = 4 //Playfield Multiplier +#define P0LINS = 10 //Player 0 Lines +#define P1LINS = 10 //Player 1 Lines + +zeropage char frame; //Frame Counter +zeropage char cntdwn; //Countdown Timer +zeropage char arnclr; //Arena Playfield Color +zeropage char tmrclr; //Timer Playfield Color +zeropage char gstate; //Game State: #TRUE = Running +zeropage char clmask; //Color Cycling Mask + +zeropage char p0xpos, p1xpos; //Player X-Positions +zeropage char p0ypos, p1ypos; //Player Y-Positions +zeropage char s0xpos, s1xpos; //Player Saved X-Positions +zeropage char s0ypos, s1ypos; //Player Saved Y-Positions + +//Color Table +char colors = {$86, $C6, $46, $00, $0E, $06, $0A, $00}; + +//Human Shaped Player Graphics +char human = {%00011100, %00011000, %00011000, %00011000, %01011010, + %01011010, %00111100, %00000000, %00011000, %00011000}; + +//Aren Playfield Data +char arena0 = {$F0, $10, $10, $10, $10, $10, $10, $10, $10, $10, $10, + $10, $10, $10, $10, $10, $10, $10, $10, $10, $10, $F0}; + +char arena1 = {$FF, $00, $00, $00, $00, $00, $0F, $08, $08, $08, $08, + $08, $08, $08, $08, $0F, $00, $00, $00, $00, $00, $FF}; + +char arena2 = {$FF, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, + $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $FF}; + + +/* Setup Code */ +void setup() { + gstate = #FALSE; + init(); +} + +/* Initialize Game */ +void init() { + clmask = 0; + frame = 0; + cntdwn = 15; + tmprep(); //Initialize Timer Bar + p0xpos = 12; p0ypos = 98; + p1xpos = 136; p1ypos = 98; +} + +/* Process Joystick */ +void pstcks() { + s0xpos = p0xpos; s0ypos = p0ypos; + s1xpos = p1xpos; s1ypos = p1ypos; + if (!SWCHA & #STK0UP) p0ypos++; + if (!SWCHA & #STK0DN) p0ypos--; + if (!SWCHA & #STK0RT) {p0xpos++; REFP0 = #CLEAR;} + if (!SWCHA & #STK0LF) { + if (p0xpos) {p0xpos--; REFP0 = #SET;} + } + if (!SWCHA & #STK1UP) p1ypos++; + if (!SWCHA & #STK1DN) p1ypos--; + if (!SWCHA & #STK1RT) {p1xpos++; REFP1 = #CLEAR;} + if (!SWCHA & #STK1LF) { + if (p1xpos) {p1xpos--; REFP1 = #SET;} + } +} + +/* Process Collisions */ +void pclsns() { + if (CXP0FB:-) {p0xpos = s0xpos; p0ypos = s0ypos;} + if (CXP1FB:-) {p1xpos = s1xpos; p1ypos = s1ypos;} + CXCLR = A; +} + +/* Process Console Switches */ +void pswchs() { + if (!SWCHB & #SELECT) { + setup(); + } + if (!SWCHB & #RESET) { + gstate = #TRUE; + init(); + } +} +/* Vertical Blank Code */ +void vrtblk() { + pswchs(); //Process Console Switches + setclr(clmask, &colors); //Set Color Table + tmrclr = getclr(clmask, $64, $04); + arnclr = getclr(clmask, $46, $0A); + scprep(); //Prepare Score For Display + posobj(p0xpos,0); //Set P0 X-Position + p0prep(p0ypos, &human); //Set P0 Y-Position & Graphics Pointer + posobj(p1xpos,1); //Set P1 X-Position + p1prep(p1ypos, &human); //Set P1 Y-Position & Graphics Pointer +} + +/* Execute Kernel Code */ +void kernel() { + scdisp(); //Display Scores + tmdisp(tmrclr); //Display Timer Bar + ardisp(arnclr); //Display Playfield and Objects +} + +/* Execute Overscan Code */ +void ovrscn() { + frame++; + if (gstate) { + if (!frame & 63) { //Decrement Timer Every X Frames + if (!tmtick()) tmprep(); //Reset Timer if It Runs Out + } + pclsns(); //Process Collisions + pstcks(); //Process Joysticks + } + else { + if (!frame & 63) { + if (cntdwn) cntdwn--; //Countdown + else clmask++; //Cycle Color Mask + } + } +} + +#include //Digit Graphics +#include //Finalization Code + diff --git a/vcs/colorbar.c02 b/vcs/colorbar.c02 new file mode 100644 index 0000000..182dddd --- /dev/null +++ b/vcs/colorbar.c02 @@ -0,0 +1,50 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers +#include //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 //Finalization Code + + diff --git a/vcs/colors0.c02 b/vcs/colors0.c02 new file mode 100644 index 0000000..5cf30d3 --- /dev/null +++ b/vcs/colors0.c02 @@ -0,0 +1,74 @@ +//Atari VCS Color Bars Program + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers + +/* Generate Vertical Sync Signal */ +void vtsync() { + A=2; //Set Bit 2 (D1) + WSYNC; //Wait for end of Scanline + VSYNC=A; //Turn On Vertical Sync + WSYNC; //Wait 2 More Scanlines + WSYNC; + A=0; //Clear Bit 2 (D1) + WSYNC; //Wait for End of 3rd Scanline + VSYNC=A; //Turn On Vertical Sync +} + +/* Execute Vertical Blank Code */ +void vtblnk() { + X=37; //Delay 37 Scanlines + do { + WSYNC; //Wait for end of Scanline + X--; + } while (*); +} + +/* Execute Kernel Code */ +void kernel() { + A=0; //Clear All Bits + WSYNC; //Wait for end of Scanline + VBLANK=A; //Turn Off Vertical Blank + X=0; //Draw 192 Scanlines (256-64) + do { + if (X & 3) { + WSYNC; //Wait for end of Scanline + COLUBK = X; //Set Background Color + } + X--; + } while (*); +} + +/* Execute Overscan Code */ +void ovrscn() { + WSYNC; //Wait for end of Scanline + VBLANK=2; //Turn On Vertical Blank + X=27; //Delay 27 Scanlines + do { + WSYNC; //Wait for end of Scanline + X--; + } while(*); +} + +start: + asm("","SEI",""); + asm("","CLD",""); + A = 0; + X = A; + Y = A; + do { + X--; + asm("","TXS",""); + push A; + } while (*); +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 //Finalization Code + + diff --git a/vcs/colors1.c02 b/vcs/colors1.c02 new file mode 100644 index 0000000..530fbea --- /dev/null +++ b/vcs/colors1.c02 @@ -0,0 +1,69 @@ +//Atari VCS Color Bars Program + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers +#include //Initialize VCS + +/* 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() { + A=0; //Clear All Bits + WSYNC=A; //Wait for end of Scanline + VBLANK=A; //Turn Off Vertical Blank + X=0; //Draw 192 Scanlines (256-64) + do { + if (X & 3) { + WSYNC = A; //Wait for end of Scanline + COLUBK = X; //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 //Finalization Code + + diff --git a/vcs/colors2.c02 b/vcs/colors2.c02 new file mode 100644 index 0000000..2063dae --- /dev/null +++ b/vcs/colors2.c02 @@ -0,0 +1,76 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers +#include //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 //Finalization Code + + diff --git a/vcs/colors3.c02 b/vcs/colors3.c02 new file mode 100644 index 0000000..94646aa --- /dev/null +++ b/vcs/colors3.c02 @@ -0,0 +1,72 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers +#include //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() { + X=49; //49*64 Cycles (37 Scanlines) + A=2; //Set Bit 2 (D1) + WSYNC=A; //Wait for end of Scanline + VSYNC=A; //Turn On Vertical Sync + TIM64T=X; //Set Timer + 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 Off Vertical Sync + return; +} + +/* Execute Vertical Blank Code */ +void vtblnk() { + clrmsk = (SWCHB & 8) ? $FF : $0F; + if (SWCHB & 64) clrofs--; else clrofs++; + A=0; //Clear All Bits + return; +} + +/* Execute Kernel Code */ +void kernel() { + do WSYNC=A; while(INTIM); + VBLANK=0; //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 + TIM64T = 32; //Delay 32*64 Cycles (27 Scanlines) + do { + WSYNC=A; //Wait for end of Scanline + } while(INTIM); + 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 //Finalization Code + + diff --git a/vcs/colors4.c02 b/vcs/colors4.c02 new file mode 100644 index 0000000..4b23772 --- /dev/null +++ b/vcs/colors4.c02 @@ -0,0 +1,156 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers +#include //Initialize VCS + +zeropage char clrbkg; //Color Background +zeropage char clrofs; //Color Offset +zeropage char clrmsk; //Color/B&W Mask + +zeropage char score; //Two Digit BCD Score +zeropage char timer; //Two Digit BDC Timer +zeropage char scrone; //Offset into Ones Digit +zeropage char tmrone; +zeropage char scrten; //Offset into Tens Digit +zeropage char tmrten; +zeropage char scrgfx; //Score Graphics Data +zeropage char tmrgfx; //Score Timer Graphics + +zeropage char temp; //Scratch Variable + +/* Generate Ones Digit Offset */ +char ofsone() { + temp = A & $0F; + temp++; + A<<; A<<; + return A + temp; +} + +/* Generate Tens Digit Offset */ +char ofsten() { + A = A & $F0; + A>>; A>>; + temp = A; + temp++; + A>>; A>>; + return A + temp; +} + +/* Prepare Score and Timer for Display */ +void prepst() { + scrone = ofsone(score); + scrten = ofsten(score); + tmrone = ofsone(timer); + tmrten = ofsten(timer); +} + +/* Display Score and Timer */ +void dispst() { + X = 5; //5 lines in digit + +} + +ScoreLoop: ; 43 - cycle after bpl ScoreLoop + ldy DigitTens ; 3 46 - get the tens digit offset for the Score + lda DigitGfx,y ; 5 51 - use it to load the digit graphics + and #$F0 ; 2 53 - remove the graphics for the ones digit + sta ScoreGfx ; 3 56 - and save it + ldy DigitOnes ; 3 59 - get the ones digit offset for the Score + lda DigitGfx,y ; 5 64 - use it to load the digit graphics + and #$0F ; 2 66 - remove the graphics for the tens digit + ora ScoreGfx ; 3 69 - merge with the tens digit graphics + sta ScoreGfx ; 3 72 - and save it + sta WSYNC ; 3 75 - wait for end of scanline +;--------------------------------------- + sta PF1 ; 3 3 - @66-28, update playfield for Score dislay + ldy DigitTens+1 ; 3 6 - get the left digit offset for the Timer + lda DigitGfx,y ; 5 11 - use it to load the digit graphics + and #$F0 ; 2 13 - remove the graphics for the ones digit + sta TimerGfx ; 3 16 - and save it + ldy DigitOnes+1 ; 3 19 - get the ones digit offset for the Timer + lda DigitGfx,y ; 5 24 - use it to load the digit graphics + and #$0F ; 2 26 - remove the graphics for the tens digit + ora TimerGfx ; 3 29 - merge with the tens digit graphics + sta TimerGfx ; 3 32 - and save it + jsr Sleep12 ;12 44 - waste some cycles + sta PF1 ; 3 47 - @39-54, update playfield for Timer display + ldy ScoreGfx ; 3 50 - preload for next scanline + sta WSYNC ; 3 53 - wait for end of scanline +;--------------------------------------- + sty PF1 ; 3 3 - @66-28, update playfield for the Score display + inc DigitTens ; 5 8 - advance for the next line of graphic data + inc DigitTens+1 ; 5 13 - advance for the next line of graphic data + inc DigitOnes ; 5 18 - advance for the next line of graphic data + inc DigitOnes+1 ; 5 23 - advance for the next line of graphic data + jsr Sleep12 ;12 35 - waste some cycles + dex ; 2 37 - decrease the loop counter + sta PF1 ; 3 40 - @39-54, update playfield for the Timer display + bne ScoreLoop ; 2 42 - (3 43) if dex != 0 then branch to ScoreLoop + sta WSYNC ; 3 45 - wait for end of scanline +;--------------------------------------- + stx PF1 ; 3 3 - x = 0, so this blanks out playfield + sta WSYNC ; 3 6 - wait for end of scanline + +/* Generate Vertical Sync Signal */ +void vtsync() { + X=49; //49*64 Cycles (37 Scanlines) + A=2; //Set Bit 2 (D1) + WSYNC=A; //Wait for end of Scanline + VSYNC=A; //Turn On Vertical Sync + TIM64T=X; //Set Timer + 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 Off Vertical Sync + return; +} + +/* Execute Vertical Blank Code */ +void vtblnk() { + clrmsk = (SWCHB & 8) ? $FF : $0F; + if (SWCHB & 64) clrofs--; else clrofs++; + A=0; //Clear All Bits + return; +} + +/* Execute Kernel Code */ +void kernel() { + do WSYNC=A; while(INTIM); + VBLANK=0; //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 + TIM64T = 32; //Delay 32*64 Cycles (27 Scanlines) + do { + WSYNC=A; //Wait for end of Scanline + } while(INTIM); + 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 //Finalization Code + + diff --git a/vcs/colors5.c02 b/vcs/colors5.c02 new file mode 100644 index 0000000..182dddd --- /dev/null +++ b/vcs/colors5.c02 @@ -0,0 +1,50 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //2k Cartridge +#include //TIA and RIOT Registers +#include //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 //Finalization Code + + diff --git a/vcs/colors6.c02 b/vcs/colors6.c02 new file mode 100644 index 0000000..b44cfc8 --- /dev/null +++ b/vcs/colors6.c02 @@ -0,0 +1,81 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //4k Cartridge +#include //TIA and RIOT Registers +#include //Initialize VCS +#include //VCS Library Routines +#include //Two Player Score Kernel +#include //Joystick Functions + +zeropage char clrbkg; //Background Color +zeropage char clrmov; //Color Movement Flag +zeropage char clrofs; //Color Offset +zeropage char clrmsk; //Color/B&W Mask +zeropage char clrskp; //Color Skip Flag +zeropage char cntdwn; //Timer Countdown +zeropage char temp; //Scratch Variable + +char colors = {$86, $C6, $46, $00, $0E, $06, $0A, $00}; //Color Table + +/* Setup Code */ +void setup() { + NUSIZ1 = $07; +} + +/* Vertical Blank Code */ +void vrtblk() { + setclr(&colors); //Set Color Table + scrprp(); //Prepare Score for Display + GRP0 = 0; GRP1 = A; //Clear Player Graphics + posobj(score1,0); //Set Player 0 Position + posobj(score2,1); //Set Player 0 Position + WSYNC;HMOVE; //Move Players +} + +/* Execute Kernel Code */ +void kernel() { + CTRLPF = 2; //Set Score Mode + scrdsp(); //Display Scores (12 Scanlines) + GRP0 = $FF; GRP1 = A; //Set Player Graphics + X=179; //Draw 180 Scanlines + do { + clrbkg = X; + if (clrskp) 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; + clrskp = (!SWCHB & 128) ? $FF : $0F; + if (clrmov) { + if (SWCHB & 64) clrofs--; else clrofs++; + } + temp = getstk(0); + if (temp & 4) score1--; + if (temp & 8) score1++; + if (INPT4:-) { + cntdwn++; + if (cntdwn == 10) { + cntdwn = 0; + score2++; + //addbcd(1,&score2); //Increment Player 2 Score + //if (!score2) score1++; //Increment Player 1 Score + //if (!score2) addbcd(1, &score1); //Increment Player 1 Score + + } + } +} + +#include //Digit Graphics +#include //Finalization Code + diff --git a/vcs/colorscr.c02 b/vcs/colorscr.c02 new file mode 100644 index 0000000..9ea7161 --- /dev/null +++ b/vcs/colorscr.c02 @@ -0,0 +1,65 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //4k Cartridge +#include //TIA and RIOT Registers +#include //Initialize VCS +#include //VCS Library Routines +#include //Two Player Score Kernel + +zeropage char clrbkg; //Background Color +zeropage char clrmov; //Color Movement Flag +zeropage char clrofs; //Color Offset +zeropage char clrmsk; //Color/B&W Mask +zeropage char cntdwn; //Timer Countdown + +char colors = {$86, $C6, $46, $00, $0E, $06, $0A, $00}; //Color Table + +/* Setup Code */ +void setup() { +} + +/* Vertical Blank Code */ +void vrtblk() { + setclr(&colors); //Set Color Table + scrprp(); //Prepare Score for Display +} + +/* Execute Kernel Code */ +void kernel() { + CTRLPF = 2; //Set Score Mode + scrdsp(); //Display Scores (12 Scanlines) + + X=180; //Draw 180 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++; + } + cntdwn++; + if (cntdwn == 10) { + cntdwn = 0; + addbcd(1,&score2); //Increment Player 2 Score + if (!score2) addbcd(1, &score1); //Increment Player 1 Score + } +} + +#include //Digit Graphics +#include //Finalization Code + + diff --git a/vcs/humans.c02 b/vcs/humans.c02 index 66fd489..0b718e0 100644 --- a/vcs/humans.c02 +++ b/vcs/humans.c02 @@ -5,6 +5,7 @@ #include //VCS Program Stub #include //VCS Library Routines #include //Two Player Score Kernel +#include //Two Player Score Kernel #include //Two Line Game Kernel //TIA Register Bit Masks @@ -15,8 +16,10 @@ #define P1DIFF = $80 //Player 1 Difficulty #define P0DIFF = $40 //Player 0 Difficulty +//Constants Required by timerbar.h02 +#define TMRCLR = $64 + //Constants Required by k2line.h02 -#define KNLLNS = 90 //Kernal Lines (Scanlines/2) #define P0HGHT = 10 //Player 0 Height #define P1HGHT = 10 //Player 1 Height @@ -27,30 +30,37 @@ char colors = {$86, $C6, $46, $00, $0E, $06, $0A, $00}; char human = {%00011100, %00011000, %00011000, %00011000, %01011010, %01011010, %00111100, %00000000, %00011000, %00011000}; +zeropage char frame; //Frame Counter + /* Setup Code */ void setup() { setclr(&colors); //Set Color Table + initmr(); //Initialize Timer Bar } /* Vertical Blank Code */ void vrtblk() { scrprp(); //Prepare Score For Display posobj(0,0); //Set P0 X-Position - p0prep(179, &human); //Set P0 Y-Position & Graphics Pointer + p0prep(175, &human); //Set P0 Y-Position & Graphics Pointer posobj(8,1); //Set P1 X-Position - p1prep(179, &human); //Set P1 Y-Position & Graphics Pointer + p1prep(175, &human); //Set P1 Y-Position & Graphics Pointer } /* Execute Kernel Code */ void kernel() { scrdsp(); //Display Scores + dsptmr(); //Display Timer Bar dsplns(); //Display Playfield and Objects } /* Execute Overscan Code */ void ovrscn() { + frame++; + if (!frame & 7) { //Decrement Timer Every X Frames + if (!dectmr()) initmr(); //Reset Timer if It Runs Out + } } #include //Digit Graphics #include //Finalization Code - diff --git a/vcs/humans0.c02 b/vcs/humans0.c02 new file mode 100644 index 0000000..e7442d1 --- /dev/null +++ b/vcs/humans0.c02 @@ -0,0 +1,50 @@ +/* Atari VCS Color Bars Program */ + +#pragma origin $F800 //4k Cartridge +#include //TIA and RIOT Registers +#include //Initialize VCS +#include //VCS Library Routines +#include //Two Player Score Kernel +#include //Two Line Game Kernel + +//Color Table +char colors = {$86, $C6, $46, $00, $0E, $06, $0A, $00}; + +//Human Shaped Player Graphics +char human = {%00011100, %00011000, %00011000, %00011000, %01011010, + %01011010, %00111100, %00000000, %00011000, %00011000}; + +/* Setup Code */ +void setup() { + setclr(&colors); //Set Color Table + scrprp(); //Prepare Score for Display + scnlns = 96; //Set Number of Scanlines + setpl0(10, &human); + setpl1(10, &human); + //VDELP0 = 1; +} + +/* Vertical Blank Code */ +void vrtblk() { + posobj(0,0); //Set Player 0 X Position + prppl0(190); //Set Player 0 Y Position + posobj(8,1); //Set Player 0 X Position + prppl1(190); //Set Player 1 Y Position + prpdsp(); //Prepare Display +} + +/* Execute Kernel Code */ +void kernel() { + //CTRLPF = 2; //Set Score Mode + //scrdsp(); //Display Scores (12 Scanlines) + //CTRLPF = 0; //Clear Score Mode + dsplns(); //Display Playfield and Objects +} + +/* Execute Overscan Code */ +void ovrscn() { +} + +#include //Digit Graphics +#include //Finalization Code + diff --git a/vcs/template.c02 b/vcs/template.c02 new file mode 100644 index 0000000..96fbb58 --- /dev/null +++ b/vcs/template.c02 @@ -0,0 +1,13 @@ +/* Atari VCS C02 Program Template */ + +#include //TIA and RIOT Registers + +//ROM Start Address - $F800 for 2K, $F000 for 4K Cartridge +#pragma origin $F000 + +irqbrk: //Code to Execute when BRK Instruction is Encountered +start: //Start of Program Code + goto start; + +#include //Finalization Code +