mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-22 01:31:33 +00:00
Added Atari 2600 C02 test programs vcs/*.c02
This commit is contained in:
parent
50869e9c0f
commit
95c6c8ab95
11
vcs/banks.a02
Normal file
11
vcs/banks.a02
Normal file
@ -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)
|
||||
|
||||
|
166
vcs/collect02.c02
Normal file
166
vcs/collect02.c02
Normal file
@ -0,0 +1,166 @@
|
||||
/* Atari VCS 2 Line Kernel Test` */
|
||||
|
||||
#pragma origin $F800 //4k Cartridge
|
||||
#include <vcshead.h02> //TIA and RIOT Registers
|
||||
#include <vcsstub.h02> //VCS Program Stub
|
||||
#include <vcslib.h02> //VCS Library Routines
|
||||
#include <colors.h02> //Color Selection Routines
|
||||
#include <score2.h02> //Two Player Score Kernel
|
||||
#include <timerbar.h02> //Timer Bar Kernel
|
||||
#include <arena.h02> //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 <digits.h02> //Digit Graphics
|
||||
#include <vcsfoot.h02> //Finalization Code
|
||||
|
50
vcs/colorbar.c02
Normal file
50
vcs/colorbar.c02
Normal file
@ -0,0 +1,50 @@
|
||||
/* 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
|
||||
|
||||
|
74
vcs/colors0.c02
Normal file
74
vcs/colors0.c02
Normal file
@ -0,0 +1,74 @@
|
||||
//Atari VCS Color Bars Program
|
||||
|
||||
#pragma origin $F800 //2k Cartridge
|
||||
#include <vcshead.h02> //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 <vcsfoot.h02> //Finalization Code
|
||||
|
||||
|
69
vcs/colors1.c02
Normal file
69
vcs/colors1.c02
Normal file
@ -0,0 +1,69 @@
|
||||
//Atari VCS Color Bars Program
|
||||
|
||||
#pragma origin $F800 //2k Cartridge
|
||||
#include <vcshead.h02> //TIA and RIOT Registers
|
||||
#include <vcsinit.h02> //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 <vcsfoot.h02> //Finalization Code
|
||||
|
||||
|
76
vcs/colors2.c02
Normal file
76
vcs/colors2.c02
Normal file
@ -0,0 +1,76 @@
|
||||
/* 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
|
||||
|
||||
|
72
vcs/colors3.c02
Normal file
72
vcs/colors3.c02
Normal file
@ -0,0 +1,72 @@
|
||||
/* 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() {
|
||||
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 <vcsfoot.h02> //Finalization Code
|
||||
|
||||
|
156
vcs/colors4.c02
Normal file
156
vcs/colors4.c02
Normal file
@ -0,0 +1,156 @@
|
||||
/* 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
|
||||
|
||||
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 <vcsfoot.h02> //Finalization Code
|
||||
|
||||
|
50
vcs/colors5.c02
Normal file
50
vcs/colors5.c02
Normal file
@ -0,0 +1,50 @@
|
||||
/* 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
|
||||
|
||||
|
81
vcs/colors6.c02
Normal file
81
vcs/colors6.c02
Normal file
@ -0,0 +1,81 @@
|
||||
/* Atari VCS Color Bars Program */
|
||||
|
||||
#pragma origin $F800 //4k Cartridge
|
||||
#include <vcshead.h02> //TIA and RIOT Registers
|
||||
#include <vcsstub.h02> //Initialize VCS
|
||||
#include <vcslib.h02> //VCS Library Routines
|
||||
#include <score2.h02> //Two Player Score Kernel
|
||||
#include <sticks.h02> //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 <digits.h02> //Digit Graphics
|
||||
#include <vcsfoot.h02> //Finalization Code
|
||||
|
65
vcs/colorscr.c02
Normal file
65
vcs/colorscr.c02
Normal file
@ -0,0 +1,65 @@
|
||||
/* Atari VCS Color Bars Program */
|
||||
|
||||
#pragma origin $F800 //4k Cartridge
|
||||
#include <vcshead.h02> //TIA and RIOT Registers
|
||||
#include <vcsstub.h02> //Initialize VCS
|
||||
#include <vcslib.h02> //VCS Library Routines
|
||||
#include <score2.h02> //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 <digits.h02> //Digit Graphics
|
||||
#include <vcsfoot.h02> //Finalization Code
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <vcsstub.h02> //VCS Program Stub
|
||||
#include <vcslib.h02> //VCS Library Routines
|
||||
#include <score2.h02> //Two Player Score Kernel
|
||||
#include <timerbar.h02> //Two Player Score Kernel
|
||||
#include <k2line.h02> //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 <digits.h02> //Digit Graphics
|
||||
#include <vcsfoot.h02> //Finalization Code
|
||||
|
||||
|
50
vcs/humans0.c02
Normal file
50
vcs/humans0.c02
Normal file
@ -0,0 +1,50 @@
|
||||
/* Atari VCS Color Bars Program */
|
||||
|
||||
#pragma origin $F800 //4k Cartridge
|
||||
#include <vcshead.h02> //TIA and RIOT Registers
|
||||
#include <vcsstub.h02> //Initialize VCS
|
||||
#include <vcslib.h02> //VCS Library Routines
|
||||
#include <score2.h02> //Two Player Score Kernel
|
||||
#include <k2line.h02> //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 <digits.h02> //Digit Graphics
|
||||
#include <vcsfoot.h02> //Finalization Code
|
||||
|
13
vcs/template.c02
Normal file
13
vcs/template.c02
Normal file
@ -0,0 +1,13 @@
|
||||
/* Atari VCS C02 Program Template */
|
||||
|
||||
#include <vcshead.h02> //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 <vcsfoot.h02> //Finalization Code
|
||||
|
Loading…
Reference in New Issue
Block a user