1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-30 23:50:04 +00:00

Cleaned up VCS files and patched C02 to use relative /include directory

This commit is contained in:
Curtis F Kaylor 2018-02-03 13:22:39 -05:00
parent e68f702734
commit 0ff3924e27
15 changed files with 52 additions and 419 deletions

7
.gitignore vendored
View File

@ -5,3 +5,10 @@
*/*.lst
*/*.prg
*/*.sym
#Converted Object Files
*.asc
*.out
*.s9
*.wav

BIN
c02 Normal file

Binary file not shown.

2
c02.c
View File

@ -36,7 +36,7 @@ void init()
curlin = 0;
inpfil = srcfil;
strcpy(inpnam, srcnam);
strcpy(incdir, "../include/");
strcpy(incdir, "include/");
alcvar = TRUE;
inblck = FALSE;
xstmnt[0] = 0;

BIN
c02.exe

Binary file not shown.

BIN
c02.tag

Binary file not shown.

37
c02prg Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
#Compile and Assemble C02 Program
#Split Script Into Directory and File Name
SDIR=${0%/*}; #Script Path
SNAM=${0##*/}; #Script Name
#Check for Command Line Argument
if [[ "$1" = "" ]]; then
echo "Usage: $SNAM file[.c02]"
exit
fi
#Split File Name Parts
FSPC=$1; #File Spec
FNAM=${FSPC%.*}; #File Name without Extension
FEXT=${FSPC##*.}; #File Extension
#Compile C02 FILE
$SDIR/c02 $FSPC
ESTS=$?; #Exit Status
if [[ $ESTS -ne 0 ]]; then
echo "Error compiling file $FSPC"
exit $ESTS
fi
#Assemble ASM File
dasm $FNAM.asm -f1 -o$FNAM.prg -l$FNAM.lst
ESTS=$?; #Exit Status
if [[ $ESTS -ne 0 ]]; then
echo "Error compiling file $FNAM.asm"
exit $ESTS
fi
#Report Successful Completion
echo "Successfully compiled and assembled file $FSPC"

View File

@ -2,3 +2,4 @@
del *.log
del *.lst
del *.sym
del *.out

BIN
common.h.gch Normal file

Binary file not shown.

5
vcs/c02.bat Normal file
View File

@ -0,0 +1,5 @@
ECHO Compiling File %1.c02
..\c02.exe %1
ECHO Assembling File %1.asm
C:\Programs\dasm %1.asm -f3 -o%1.bin -l%1.lst -s%1.sym

View File

@ -1,156 +0,0 @@
/* 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

View File

@ -1,81 +0,0 @@
/* 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

View File

@ -1,65 +0,0 @@
/* 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

View File

@ -1,66 +0,0 @@
/* 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 <score2.h02> //Two Player Score Kernel
#include <timerbar.h02> //Two Player Score Kernel
#include <k2line.h02> //Two Line Game Kernel
//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
//Constants Required by timerbar.h02
#define TMRCLR = $64
//Constants Required by k2line.h02
#define P0HGHT = 10 //Player 0 Height
#define P1HGHT = 10 //Player 1 Height
//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};
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(175, &human); //Set P0 Y-Position & Graphics Pointer
posobj(8,1); //Set P1 X-Position
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

View File

@ -1,50 +0,0 @@
/* 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

1
vcs/stella.bat Normal file
View File

@ -0,0 +1 @@
"C:\Program Files\Stella\stella" %1.bin