Squashed commit of the following:

commit ed00e1d1b5a9783a72dade3f3676b161a9cfe287
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 22:20:49 2018 -0400

    Documented joystk, paddle, and lgtpen modules

commit ec0a5ede8d1b043fcf0094ea653255a808dbf8d3
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 20:31:11 2018 -0400

    Added joystick, paddle, and lightpen test programs

commit 7b787f432e2f4f7ae5d7f0053ade1d3586a4fad1
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 20:30:03 2018 -0400

    Updated Apple II and VIC-20 Batch Files

commit 50568294349d7e3c6b7d0d364aeaece73c9e4ab6
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 20:28:09 2018 -0400

    Separated light pen code into separate files

commit d45e59f73d55eef1d30c591d19a043ad79cfd81a
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 19:28:56 2018 -0400

    Moved code for paddles into separate include files

commit fc5c5472d758c960332ea14105d5ec4a7c8cbbfb
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 16:15:32 2018 -0400

    Added system specific module 'joystk'
This commit is contained in:
Curtis F Kaylor 2018-09-12 09:54:54 -04:00
parent 330ed1285a
commit 35377b5807
38 changed files with 973 additions and 262 deletions

View File

@ -379,6 +379,12 @@ A modifier is used with a declaration to override the default properties of
an object. Modifiers may currently only be used with simple variable and
array declarations, although this may be expanded in the future.
The alias modifier specifies that a variable is to be located at a specific
address. The specified address may either be a literal in the range 0 to
65534 ($0 to $FFFF) or a previously defined variable name. When using the
alias modifier, the declared variable must be followed by the = character
and the literal or variable name to be aliased to.
The aligned modifier specifies that the the variable or array will start on
a page variable. This is used to ensure that accessing an array element will
not cross a page boundary, which requires extra CPU cycles to execute.
@ -400,13 +406,15 @@ zero (addresses 0 through 255). It should be used in conjunction with the
pragma zeropage directive.
Examples:
aligned char table[240]; //Defines 241 byte array aligned to page boundary
char debug = #TRUE; //Defines variable debug initialized to constant
char flag = 1; //Defines variable flag initialized to 1
const char s = "string"; //Defines 7 byte string s initialized to "string"
const char m = {1,2,3}; //Defines 3 byte array m containing 1, 2, and 3
alias char putcon = $F001; //Defines variable putcon with address $F001
alias char alpha = omega; //Defines variable alpha aliased to omega
aligned char table[240]; //Defines 241 byte array aligned to page boundary
const char debug = #TRUE; //Defines variable debug initialized to constant
const char flag = 1; //Defines variable flag initialized to 1
const char s = "string"; //Defines 7 byte string s initialized to "string"
const char m = {1,2,3}; //Defines 3 byte array m containing 1, 2, and 3
aligned const char fbncci[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34};
zeropage char ptr, tmp; //Defines zero page variables
zeropage char ptr, tmp; //Defines zero page variables
EXPRESSIONS

View File

@ -14,6 +14,7 @@ blkmem block Block Memory Search block for segment matching array.
blkstr block Block String Search block for segment beginning with string.
blkswp block Block Swap Swap bytes of array with the current segment.
blksrt block Block Sort Sort segments in block by initial string.
button paddle Button Read paddle button controller status.
ctoa stdlib Character to ASCII Convert byte to numeric string.
div stdlib Divide Divide two bytes.
failed test Failed Write " Fail" to screen.
@ -54,6 +55,8 @@ ispnct ctype Is Punctuation Return TRUE if Graphical and not Alphanu
isprnt ctype Is Printable Return TRUE if ASCII code is 32-126.
isspce ctype Is white Space Return TRUE if ASCII code is 9-13 or 32.
isuppr ctype Is Uppercase Return TRUE if character is A-Z.
joystk joystk Joystick Read Atari style joystick controller status.
lgtpen lgtpen Light Pen Read light pen status.
maddr memio Memory Address Return address contained in memory file pointer.
max stdlib Maximum Return greater of two byte.
mclose memio Memory Close Close memory file.
@ -73,6 +76,7 @@ mputc memio Memory Put Character Write single character to memory file.
mputln memio Memory Put String Write string followed by newline to memory file.
mputs memio Memory Put String Write string to memory file.
mult stdlib Multiply Multiply two bytes.
paddle paddle Paddle Read paddle controller position.
passed test Passed Write " Pass" to screen.
passln test Passed Line Print " Pass" plus newline to screen.
psflln test Pass or Fail Line Write " Pass" or " Fail" plus newline to screen.

View File

@ -13,48 +13,72 @@ Note: This will probably be replaced with a command line parameter
If compatibility with the C02 Standard Libraries is needed, the following
functions must be defined:
c = plkey(); Polls keyboard and returns raw ASCII character
corresponding to last/current pressed key.
c = plkey(); Polls keyboard and returns raw ASCII character
corresponding to last/current pressed key.
Returns constant NULKEY (usually 0) if no key was
pressed.
Returns constant NULKEY (usually 0) if no key was
pressed.
c = rdkey(); Waits for a keypress and returns the raw ASCII
character corresponding to the pressed key.
c = rdchr(); Waits for a keypress and returns the raw ASCII
character corresponding to the pressed key.
Note: Usually a loop that calls plkey(), but may
also directly call a system subroutine.
Note: Usually a loop that calls plkey(), but may
also directly call a system subroutine.
c = getkey(); Waits for a keypress and returns the cleaned
ASCII value corresponding to the pressed key.
c = getkey(); Waits for a keypress and returns the cleaned
ASCII value corresponding to the pressed key.
Note: Calls rdkey() followed by any necessary
character code conversions. This can be due to
high-bit being set by keyboard decoder,
non-standard key mappings, keys that generate
escape sequences, etc...
Note: Calls rdkey() followed by any necessary
character code conversions. This can be due to
high-bit being set by keyboard decoder,
non-standard key mappings, keys that generate
escape sequences, etc...
newlin(); Advances the cursor to the beginning of then
next line.
prchr(c); Writes character c to the screen.
Note: Depending on the system, this will usually
output a Carriage Return, Line Feed, both.
Note: Does any needed ACSII conversions, then calls
the native print character routine.
echo(c); Writes character c to the screen without any
translation.
newlin(); Advances the cursor to the beginning of then
next line.
Note: May directly access memory-mapped I/O
or may call a system subroutine.
Note: Depending on the system, this will usually
output a Carriage Return, Line Feed, both.
prchr(c); Writes character c to the screen.
delchr(); Delete character to left and move cursor one
character to the left.
Note: Does any needed ACSII conversions, then calls
echo().
Note: Depending on the system, this will usually
print one or two delete or backspace characters, and
possibly a space to overwite the deleted character.
clrscn(); Clears the screen. On systems without this capability,
such as the Apple 1, this function should simply
return without performing any actions.
Note: Depending on the system, this will may either
print the clear screen control character or execute
the native clear screen routine.
setpos(col,row); Moves the cursor to the specified column and row. On
systems without this capability, such as the Apple 1,
this function should simply returns without performing
any actions.
col, row = getpos(); Returns the cursor's current position. On systems
without this capability, such as the Apple 1,
this function should return the values 255, 255.
wid, hgt = getsiz(); Returns the size of the screen in columns, and rows.
Note: This may call a system subroutine, read system
variables, or simply return hard-coded values.
along with the Zero Page locations (each pair of which must be sequential)
srclo, srchi Spurce String Pointer
srclo, srchi Source String Pointer
dstlo, dsthi Destination String Pointer
stklo, stkhi Stack Pointer
the following locations that may be Zero Page, but don't have to before

48
doc/joystk.txt Normal file
View File

@ -0,0 +1,48 @@
Joystick Functions for C02 Programs
This module contains constants and a function for reading digital joysticks
(the type used on Atari and Commodore 8-bit computers). For systems that use
analog joysticks (such as the Apple II), the paddle module should be used.
The constants and assembly code vary by system, so when invoking the
cross-compilers, the command line option -s must be used to ensure that
the correct header files are included.
At the beginning of the program use the directives
#include <joystk.h02>
The following constants are defined:
#JYSTKS Maximum number of joysticks supported by system.
For systems with no joystick support, this will be 0.
#JOYUP Joystick Switch Bitmask - Up
#JOYDN Joystick Switch Bitmask - Down
#JOYLF Joystick Switch Bitmask - Left
#JOYRT Joystick Switch Bitmask - Right
#JOYB0 Joystick Switch Bitmask - Fire Button
The following functions are defined:
j = joystk(n); Returns the current state of joystick n.
If n is greater than or equal to #JYSTKS then $FF
will be returned. Otherwise, a byte representing the
state of the joystick switches will be returned.
Each switch in the joystick has a corresponding bit
in the result which will be 1 if the switch is
depressed or 0 if it is not.
The specific assignment of bits varies by system, so
the joystick bitmask constants should be used to check
the state of the individual switches.
The state of an individual switch can be determined by
doing a bitwise and of the result with the corresponding
bitmask constant, which will result in a non-zero value
if and only if that switch is depressed.
Note: This library has no external dependencies.

35
doc/lgtpen.txt Normal file
View File

@ -0,0 +1,35 @@
Lightpen Functions for C02 Programs
This module contains a constant and function for reading lightpens on
systems that support them.
The constants and assembly code vary by system, so when invoking the
cross-compilers, the command line option -s must be used to ensure that
the correct header files are included.
At the beginning of the program use the directives
#include <lgtpen.h02>
The following constants are defined:
#LGTPNS Light pen status. If loght pen support is available,
this will be 255 (true), otherwise, it will be 0 (false).
The following function is defined:
h,v,t = lgtpen(); Returns the state of the lightpen ot lightgun.
This function returns three values: the first
is the horizontal position on the screen, the
second is the vertical position on screen, and
the third is the state of the button or trigger
(255 if pressed, otherwise 0).
Note: The position returned by this function is
based on the position of the raster beam and does
not directly correspond to pixel coordinates.
Therefore, some sort of calibration and conversion
will be necessary when using a light pen.
Note: This library has no external dependencies.

73
doc/paddle.txt Normal file
View File

@ -0,0 +1,73 @@
Joystick Functions for C02 Programs
This module contains constants and a function for reading paddles and
analog joysticks. It can also be used with devices that emulate paddles,
such as the Koala Pad and some mice.
The constants and assembly code vary by system, so when invoking the
cross-compilers, the command line option -s must be used to ensure that
the correct header files are included.
At the beginning of the program use the directives
#include <paddle.h02>
The following constants are defined:
#PADDLS Maximum number of joysticks supported by system.
#BUTTNS Maximum number of paddle buttons supported by system.
For systems with no paddle support, both of these
will be 0
The following functions are defined:
p = paddle(n); Returns the current state of paddle n, the first
paddle having the number 0.
If n is greater than or equal to #PADDLS then 0
will be returned. Otherwise, a byte between 0 and
$FF representing the current paddle position will
be returned.
b = button(n); Returns the current state of button n, the first
paddle having the number 0. This number may or may
not correspond to a particular paddle number.
If n is greater than or equal to #BUTTNS then 0
will be returned. Otherwise, the number 255 (TRUE)
will be returned if the button is depressed, while
the number 0 (FALSE) will be returned if it is not.
System Specific Notes:
Atari Style Paddles These are used on Atari and Commodore 8-bit systems.
The paddles are grouped in pairs. Therefore, the
paddles in the first controller port will be
numbered 0 and 1, the paddles in the second port
will be numbered 2 and 3, and so on. The button
numbers directly correspond with the paddle numbers.
When using a Koala Pad, mouse in paddle emulation
mode, or similar device, two calls to the paddle()
and/or button() functions must be made. Using the
even paddle number (0 or 2) returns the horizontal
value, while the odd paddle number (1 or 3) returns
the vertical value. Likewise, using the even button
number reads the left button, while the odd button
reads the right button.
Apple II When using paddle controllers, the first paddle
and its button are both numbered 0 while the second
paddle and its button are both numbered 1.
When using joystick controllers, the first joystick's
horizontal and vertical positions are read using
paddle(0) and paddle(1) respectively, and its button
is read using button(0), while the second joystick's
horizontal and vertical positions are read using
paddle(2) and paddle(3) respectively, and its button
is read using button(1)
Note: This library has no external dependencies.

View File

@ -70,13 +70,13 @@ PLKEY: INC RDSEED ;Cycle Keypress Counter
LDA #0 ;Otherwise Return ASCII NUL
RTS
RDKEY: INC RDSEED ;Cycle Keypress Counter
GETCHR: INC RDSEED ;Cycle Keypress Counter
RDKEYC: BIT KBDCR ;Check the Keyboard Control Register
BPL RDKEYC ; and loop if key not pressed
RDKEYA: LDA KBD ; Read key into Accumulator
RTS
GETKEY: JSR RDKEY ;Subroutine - Read ASCII from Keyboard
GETKEY: JSR GETCHR ;Subroutine - Read ASCII from Keyboard
GETKEA: AND #$7F ;Strip High Bit
BIT GETKEM ;If Character is in
BEQ GETKEX ; Alpha Block ($40-$74)
@ -84,12 +84,26 @@ GETKEA: AND #$7F ;Strip High Bit
GETKEX: RTS
GETKEM: DC $40 ;Character Block Bit Mask
PRCHR EQU ECHO ;Alias to Monitor Routine
PUTCHR EQU ECHO ;Alias to Monitor Routine
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Underscore Character
JMP PRCHR ; and Print it
JMP PUTCHR ; and Print it
;Advance Character to Next line
NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP PRCHR ; and Print it
JMP PUTCHR ; and Print it
;Clear the Screen
CLRSCR: ;Do Nothing (Drop to RTS)
;Move Cursor to Specified Coordinates
SETPOS: RTS ;No Action
;Get Cursor Position
GETPOS EQU LGTPEN ;Return Error
;Get Screen Size
GETSIZ: LDA #40 ;40 Columns
LDY #24 ;24 Lines
RTS

View File

@ -40,10 +40,12 @@ void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
//System Subroutines
char plkey(); //Poll Console for character
char rdkey(); //Wait for character from Console
void delchr(); //Delete previous character
char getkey(); //Read ASCII character from Console
char getpos(); //Get Cursor Position
char getsiz(); //Get Screen Size
void newlin(); //Advance cursor to beginning of next line
void prchr(); //Print ASCII character to Console
void setdst(); //Set Destination Pointer
void setsrc(); //Set Source Pointer
char polkey(); //Poll Console for character
char putchr(); //Print ASCII character to Console
char getchr(); //Wait for character from Console
void setpos(); //Set Cursor Position

View File

@ -34,8 +34,6 @@ AKD EQU $C010 ;Keyboard Strobe Register
;Monitor Routines
PRBYTE EQU $FDDA ;Print Accumulator as Hexadecimal Number
PRHEX EQU $FDE3 ;Print Low Nybble of Accumulator as Hex Digit
ECHO EQU $FDF0 ;Print Character - Routine Monitor COUT1
EXIT EQU $03D0 ;Return to Monitor - Jump Vector to DOS warm start
ORG $0C00 ;Safe Area for Machine Language
@ -43,23 +41,23 @@ EXIT EQU $03D0 ;Return to Monitor - Jump Vector to DOS warm start
START: JSR NEWLIN ;Start On New Line
JMP MAIN ;Execute Program
;Subroutine Poll Keyboard
PLKEY: INC RDSEED ;Cycle Random Seed
;Poll Keyboard for Raw Character
POLKEY: INC RDSEED ;Cycle Random Seed
LDA #0 ;Clear Accumulator
BIT KBD ;Check Keyboard Strobe Bit
BPL PLKEYR ;If Key Pressed
BPL POLKER ;If Key Pressed
LDA KBD ; Load Key Value
STA AKD ; Clear Strobe
PLKEYR: RTS
POLKER: RTS
;Read Keyboard
GETKEY JSR PLKEY ;Poll Keyboard
;Get ASCII Character from Keyboard
GETKEY: JSR POLKEY ;Poll Keyboard
AND #$7F ;Strip High Bit
RTS
;Wait for Keypress
RDKEY: JSR GETKEY ;Get Modified Key Code
BEQ RDKEY ;Loop if No Key
;Wait for ASCII Character from Keyboard
GETCHR: JSR GETKEY ;Get Modified Key Code
BEQ GETCHR ;Loop if No Key
RTS
;Delete Previous Character
@ -70,12 +68,29 @@ DELCHR: LDX #2 ;Two Characters Total
;and Fall into PRCHR
;Print Character to Screen
PRCHR: ORA #$80 ;Set High Bit
PUTCHR: ORA #$80 ;Set High Bit
CMP #$E0 ;
BCC PRCHRX ;If Lower Case
AND #$1F ; Convert to Inverse
PRCHRX: JMP ECHO ;Alias to Monitor Routine
PRCHRX: JMP $FDF0 ;Call Monitor Routine COUT1
;Advance Character to Next line
NEWLIN EQU $FD8E ;Monitor Routine CROUT
;Clear the Screen
CLRSCR: EQU $FC58 ;Applesoft Routine HOME
;Move Cursor to Specified Coordinates
SETPOS: STA $24 ;Store Column in CH
TYA ;Transfer Row to Accumulator
JMP $FB5B ;Call Monitor Routine TABV
;Get Cursor Position
GETPOS: LDA $24 ;Load Column from CH
LDY $25 ;Load Row from CV
RTS
;Get Screen Size
GETSIZ: LDA $21 ;Load Width from WNDWDTH
LDY $23 ;Load Height from WNDBTM
RTS

View File

@ -1,39 +1,44 @@
/* Apple ][ Header File */
//Platform Specific Constants
/* Platform Specific Constants */
#define DELKEY $08 //Delete/Backspace Key
#define ESCKEY $1B //Escape/Stop Key
#define RTNKEY $0D //Return/Enter Key
/* Standard Library Variables */
/* Standard Library Pointers */
char srclo,srchi; //Source String Pointer for Library Functions
char dstlo,dsthi; //Destination String Pointer for Library Functions
char blklo,blkhi; //Block Segment Pointer
char stklo,stkhi; //System Pointer
char blkslo, blkshi; //Block Start Address
char blkelo, blkehi; //Block End Address
char blklen; //Block Segment Length
/* Standard Library Variables */
char blkslo, blkshi; //Block Start Address
char blkelo, blkehi; //Block End Address
char blklen; //Block Segment Length
char stkslo, stkshi; //Stack Start Address
char stkelo, stkehi; //Stsck End Address
char random, rdseed; //Pseudo-Random Number Generation
char temp0, temp1, temp2, temp3; //Temporary Variables
//System Variables
char invflg; //Video Invert Mask
/* Platform Specific Variables */
char invflg; //Video Invert Mask
//Keyboard I/O
char kbd; //Keyboard Data Register
char abd; //Keyboard Strobe Register
/* Keyboard I/O */
char kbd; //Keyboard Data Register
char akd; //Keyboard Strobe Register
//Monitor Subroutines
void echo(); //Print Character in Accumulator
void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
/* Monitor Subroutines */
void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
//System Subroutines
char plkey(); //Poll Console for character
char rdkey(); //Wait for character from Console
char getkey(); //Read ASCII character from Console
void newlin(); //Advance cursor to beginning of next line
void prchr(); //Print ASCII character to Console
void setdst(); //Set Destination Pointer
void setsrc(); //Set Source Pointer
/* System Subroutines */
void clrscr(); //Clear the Screen
void delchr(); //Delete previous character
char getchr(); //Wait for character from Console
char getkey(); //Read ASCII character from Console
char getpos(); //Get Cursor Position
char getsiz(); //Get Screen Size
void newlin(); //Advance cursor to beginning of next line
char polkey(); //Poll Console for character
char putchr(); //Print ASCII character to Console
void setpos(); //Set Cursor Position

25
include/apple2/paddle.a02 Normal file
View File

@ -0,0 +1,25 @@
;Paddle Controller Constants and Functions for Apple II
PADDLS EQU #4 ;Maximum Numbers of Paddles
;Read Paddle
PADDLE: LDY #0 ;Set Result to 0
CMP #PADDLS ;If Paddle# >= Max
BCS PADDLZ ; Return # of Paddles & Carry Set
TAX ;Copy Paddle# to X Register
JSR $FB1E ;Execute Monitor PREAD Routine
PADDLZ: TYA ;Copy Result to Accumulator
RTS
BUTTNS EQU #2 ;Maximum Numbers of Buttons
;Read Paddle Button
BUTTON: LDY #0 ;Set Result to 0
CMP #BUTTNS ;If Button# >= Max
BCS BUTTOZ ; Return Zero & Carry Set
TAX ;Copy Paddle# to X Register
LDA $C061,X ;Load Button Register
BPL BUTTOZ ;If Bit 7 Set
DEY ; Change Result to $FF
BUTTOZ: TYA ;Copy Result to Accumulator
RTS

15
include/apple2/paddle.h02 Normal file
View File

@ -0,0 +1,15 @@
/* Psddle Controllers Header File for Apple II */
#define PADDLS $04 //Number of Paddles
#define BUTTNS $02 //Number of Paddle Buttons
/* Get Paddle Button Status *
* Args: p = Paddle Number *
* Returns: $FF if Button Pressed *
* $00 if Not Pressed */
void button();
/* Get Paddle Status *
* Args: p = Paddle Number *
* Returns: Paddle Value (0-255) */
void paddle();

15
include/joystk.a02 Normal file
View File

@ -0,0 +1,15 @@
;Joystick Constants and Functions
;Non-Functional Skeleton for Systems with No Joystick Support
JYSTKS EQU 0 ;Number of Joysticks
;Joystick Bit Masks
JOYUP EQU $00 ;N/A - Up
JOYDN EQU $00 ;N/A - Down
JOYLF EQU $00 ;N/A - Left
JOYRT EQU $00 ;N/A - Right
JOYB0 EQU $00 ;N/A - Button
;Read Joystick
JOYSTK: LDA #255 ;Return Error Code
RTS

17
include/joystk.h02 Normal file
View File

@ -0,0 +1,17 @@
/* Joystick Header File *
* Nonfunctional Skeleton for *
* Systems w/o Joystick Support */
#define JYSTKS $00 //Number of Joysticks
#define JOYUP $00 //Undefined - Up
#define JOYDN $00 //Undefined - Down
#define JOYLF $10 //Undefined - Left
#define JOYRT $00 //Undefined - Right
#define JOYB0 $20 //Undefined - Button
/* Read Joystick State *
* Args: j = Joystick Number *
* Returns: $FF = Error *
* No Joysticks */
char joystk();

11
include/lgtpen.a02 Normal file
View File

@ -0,0 +1,11 @@
;Light Pen Constants and Functions
;Non-Functional Skeleton for Systems with No Joystick Support
LGTPNS EQU #0 ;Light Pen Status (Unsupported)
;Read Light Pen
LGTPEN: LDA #0 ;Return FALSE
TAY
TAX
SEC ;and Carry Set
RTS

7
include/lgtpen.h02 Normal file
View File

@ -0,0 +1,7 @@
/* Light Pen Header File *
* Nonfunctional Skeleton for *
* Systems w/o Light Pen Support */
#define LGTPNS 0 //Light Pen Status (Unsupported)
char lgtpen(); //Read Light Pen

14
include/paddle.a02 Normal file
View File

@ -0,0 +1,14 @@
;Paddle Controller Constants and Functions
;Non-Functional Skeleton for Systems with No Paddle77 Support
PADDLS EQU 0 ;Number of Joysticks
;Read Paddle
PADDLE: LDA #0 ;Return Zero
SEC ;and Carry Set
RTS
BUTTNS EQU 0 ;Number of Paddle Buttons
;Read Button
BUTTON: EQU PADDLE ;Return Zero & Carry Set

17
include/paddle.h02 Normal file
View File

@ -0,0 +1,17 @@
/* Psddle Controllers Header File *
* Nonfunctional Skeleton for *
* Systems w/o Paddle Support */
#define BUTTNS $00 //Number of Paddle Buttons
#define PADDLS $00 //Number of Paddles
/* Get Paddle Button Status *
* Args: p = Paddle Number *
* Returns: 0 */
void button();
/* Get Paddle Status *
* Args: p = Paddle Number *
* Returns: 0 */
void paddle();

View File

@ -47,26 +47,63 @@ EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
RTS ;Return to BASIC
;Poll Keyboard for Character
PLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
POLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
;Get Character from Keyboard
GETKEY: EQU PLKEY
GETKEY: JSR POLKEY ;Get Key From Keybord
;The below is not working...
LDY $9005 ;Get Character Memory Offset
CPY #242 ;If Upper/Lower
BNE GETKEX
BIT $FF ; Bit 7 -> C, Bit 6 -> V
BVC GETKEX ; If Bit 6 Set (Alpha)
BCC GETKEL ; If Bit 7 Set (PETSCII Upper)
AND #$7F ; Clear Bit 7 (ASCII Upper)
BNE GETKEX ; Else
GETKEL: ORA #$20 ; Set Bit 5 (ASCII Lower)
GETKEX: ORA #$00 ;Set Flags
RTS
;A = $41 %0100 0001
;a = $C1 %1100 0001 PETSCII
;a = $61 %0110 0001 PETSCII
;$9005 = 240 UPR/GFX
; 242 UPR/LWR
;Wait for Character from Keyboard
RDKEY: JSR GETKEY ;Poll Keyboard
BEQ RDKEY ;If No Key, Loop
GETCHR: JSR GETKEY ;Poll Keyboard
BEQ GETCHR ;If No Key, Loop
RTS
;Print Character to Console
;uses direct call to SCRNOUT instead of CHROUT
PUTCHR EQU $E742 ;Aliased to SRCNOUT Routine
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Delete Character
JMP PRCHR ;Print and Return
JMP PUTCHR ;Print and Return
;Advance Character to Next line
NEWLIN: LDA #RTNKEY ;Load C/R into Accumulator
JMP PRCHR ;Print and Return
JMP PUTCHR ;Print and Return
;Print Character to Console
PRCHR EQU $FFD2 ;Aliased to Kernal CHROUT Routine
;Clear the Screen
CLRSCR EQU $E55F ;Alias to CLSR Routine
;Move Cursor to Specified Coordinates
SETPOS: STA $D3 ;Save Cursor Column
STY $D6 ;Save Cursor Row
JMP $E587 ;Set Screen Poiners and Return
;Get Cursor Position
GETPOS: LDY $D6 ;Load Cursor Row
LDA $D3 ;Load Cursor Column
RTS
;Get Screen Size
GETSIZ: JSR $FFED ;Call SCREEN Kernal Routine
TXA ;Transfer Width to Accumulator
RTS
;Print Byte as Two-Digit Hex Number to Console
PRBYTE: PHA ;Save Accumulater
@ -84,4 +121,4 @@ PRHEX: AND #$0F ;Strip High Nybble
BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PRCHR ;Print Hex Digit and Return
JMP PUTCHR ;Print Hex Digit and Return

35
include/vic/joystk.a02 Normal file
View File

@ -0,0 +1,35 @@
;Joystick Assembly Language Library for VIC-20
JYSTKS EQU $01 ;Number of Joysticks
;Joystick Bit Masks
JOYUP EQU $04 ;Bit 2 - Up
JOYDN EQU $08 ;Bit 3 - Down
JOYLF EQU $10 ;Bit 4 - Left
JOYRT EQU $01 ;Bit 1 - Right
JOYB0 EQU $20 ;Bit 5 - Button
;Read Joystick
JOYSTK: LDX #$FF ;Preset X with 255
ORA #0 ;Check Parameter
BNE JOYSTZ ;If Not Zero, Return Error
TAX ;Set X to 0
LDA $9113 ;Get DDR for Port A Status
PHA ;and Save It
LDA $9122 ;Set DDR for Port B Status
PHA ;amd Save It
STX $9113 ;Set DDR for Port A to All Inputs
STX $9122 ;Set DDR for Port B to All Inputs
LDA $9120 ;Read Port B (Right)
ASL ;Shift Bit 7 into Carry
LDA $9111 ;Read Port A
AND #$3C ;Mask Bits
ADC #0 ;Move Carry into Bit 0
EOR #$3D ;Invert Bits
TAX ;and Save in X Register
PLA ;Restore Port B DDDR
STA $9122
PLA ;Restore Port A DDDR
STA $9113
JOYSTZ: TXA ;Copy Status Back into Accumulator
RTS

15
include/vic/joystk.h02 Normal file
View File

@ -0,0 +1,15 @@
/* Joystick Library Header File for VIC-20 */
#define JYSTKS $01 //Number of Joysticks
#define JOYUP $04 //Bit 2 - Up
#define JOYDN $08 //Bit 3 - Down
#define JOYLF $10 //Bit 4 - Left
#define JOYRT $01 //Bit 1 - Right
#define JOYB0 $20 //Bit 5 - Button
/* Read Joystick State *
* Args: n = Joystick Number *
* Returns: Joystick Status *
* $FF = Invalid Argument */
char joystk();

32
include/vic/lgtpen.a02 Normal file
View File

@ -0,0 +1,32 @@
;Light Pen Constants and Functions
;Non-Functional Skeleton for Systems with No Joystick Support
LGTPNS EQU #$FF ;Light Pen Status (Supported)
;Read Light Pen
LGTPEN: LDX #0 ;Initialize X to FALSE (0)
LDA $9009 ;Check Paddle 1 (Magnum Light Phaser)
BMI LGTPEJ ;If Trigger Pulled
DEX ; Set X to TRUE ($FF)
BNE LGTPEP ;Else Check Joystick Inputs
LGTPEJ: LDA $9113 ; Get DDR for Port A Status
PHA ; and Save It
LDA $9122 ; Set DDR for Port B Status
PHA ; and Save It
STX $9113 ; Set DDR for Port A to All Inputs
STX $9122 ; Set DDR for Port B to All Inputs
LDA $9120 ; Read Port B (S2)
ASL ; Shift Bit 7 into Carry
LDA $9111 ; Read Port A
ROR ; Rotate Carry Back In
EOR #$FF ; Invert Bits
AND #$9E ; and Mask Joystick Inputs
BEQ LGTPES ; If Any Bits Set
DEX ; Set X to TRUE ($FF)
LGTPES: PLA ; Restore Port B DDDR
STA $9122
PLA ; Restore Port A DDDR
STA $9113
LGTPEP: LDY $9007 ;Read Y Position into Y
LDA $9006 ;Read X Position into A
RTS

7
include/vic/lgtpen.h02 Normal file
View File

@ -0,0 +1,7 @@
/* Light Pen Header File *
* Nonfunctional Skeleton for *
* Systems w/o Light Pen Support */
#define LGTPNS $FF //Light Pen Status (Supported)
char lgtpen(); //Read Light Pen

48
include/vic/paddle.a02 Normal file
View File

@ -0,0 +1,48 @@
;Paddle Controller Constants and Functions for VIC-20
PADDLS EQU #2 ;Maximum Numbers of Paddles
;Read Paddle
;Args: A = Paddle #
;Returns: A,Y = Paddle Value
; 0 and Carry Set if Paddle # Invalid
; X = Paddle #
PADDLE: LDY #0 ;Preset Result to 0
CMP #PADDLS ;If Paddle# >= # of Paddles
BCS PADDLZ ; Return Zero & Carry Set
TAX ;Copy Paddle # to X Register
LDY $9008,X ;Read Paddle
PADDLZ: TYA ;Copy Result to Accumulator
RTS
BUTTNS EQU #2 ;Maximum Numbers of Paddle Buttons
;Read Paddle Button
;Args: A = Button #
;Affects: Y
;Returns: A = $FF if Paddle Button Pressed
; $00 if Paddle Button Not Pressed
; Carry Set if Button Number Invalid
; X = Button #
BUTTON: CMP #2 ;If Button# >= # of Buttons
BCS BUTTOZ ; Return FALSE & Carry Set
TAX ;Copy Button Number to X Register
LDY BUTTOR,X ;Get Button Register Offset
LDA $9102,Y ;Read Data Direction Register
PHA ;and Save It
LDA #$00 ;Set Port to All Inputs
STA $9102,Y ;
LDA $9100,Y ;Read Button Port
AND BUTTOM,X ;and Isolate Bit
TAX ;Save Result in X
PLA ;Retrieve Original DDR Value
STA $9102,Y ;Restore Data Direction Register
TXA ;Get Result from X, Setting Flags
BNE BUTTOZ ;If Bit Not Set
LDA #$FF ; Return TRUE
RTS ;Else
BUTTOZ: LDA #$00 ; Return FALSE
RTS
;Paddle Buttons 0 = S2 ($9111 bit 4), 1 = S3 ($9120 bit 7)
BUTTOR: DC $11,$20 ;Paddle Button VIC Registers
BUTTOM: DC $10,$80 ;Paddle Button Bit Masks

15
include/vic/paddle.h02 Normal file
View File

@ -0,0 +1,15 @@
/* Psddle Controllers Header File for VIC-20 */
#define BUTTNS $02 //Number of Paddle Buttons
#define PADDLS $02 //Number of Paddles
/* Get Paddle Button Status *
* Args: p = Paddle Number *
* Returns: $FF if Button Pressed *
* $00 if Not Pressed */
void button();
/* Get Paddle Status *
* Args: p = Paddle Number *
* Returns: Paddle Value (0-255) */
void paddle();

124
include/vic/screen.a02 Normal file
View File

@ -0,0 +1,124 @@
;Screen Control Assembly Lanuage Routines for C02
;Vic Display Colors
BLACK EQU 0 Black
WHITE EQU 1 White
RED EQU 2 Red
CYAN EQU 3 Cyan
MAGENT EQU 4 Purple
GREEN EQU 5 Green
BLUE EQU 6 Blue
YELLOW EQU 7 Yellow
;PETSCII Screen Control Characters
CHRCLR EQU 147 Clear (CLR)
CHRDEL EQU 20 Delete (DEL)
CHRDN EQU 17 Cursor Down
CHRRTN EQU 13 Return
CHRFN1 EQU 133 Function Key 1 (F1)
CHRFN2 EQU 137 Function Key 2 (F2)
CHRFN3 EQU 134 Function Key 3 (F3)
CHRFN4 EQU 138 Function Key 4 (F4)
CHRFN5 EQU 135 Function Key 5 (F5)
CHRFN6 EQU 139 Function Key 6 (F6)
CHRFN7 EQU 136 Function Key 7 (F7)
CHRFN8 EQU 140 Function Key 8 (F8)
CHRHOM EQU 19 Home
CHRINS EQU 148 Insert
CHRLFT EQU 157 Cursor Left
CHRRGT EQU 29 Cursor Left
CHRRVF EQU 146 Reverse Off
CHRRVN EQU 18 Reverse On
CHRUP EQU 145 Cursor Up
;PETSCII Box Drawing Characters
BOXBLC EQU 173 Bottom Left Corner
BOXBRC EQU 189 Bottom Right Corner
BOXBCT EQU 177 Bottom to Cetter Tee
BOXCTR EQU 123 Center Cross
BOXHLN EQU 96 Horizontal Line
BOXLCT EQU 171 Left To Center T
BOXRCT EQU 179 Right To Center T
BOXTLC EQU 176 Top Left Corner
BOXTRC EQU 174 Top Right Corner
BOXTCT EQU 178 Top to Center T
BOXVLN EQU 98 Verical Line
;PETSCII Color Code Table
CLRCDS DC 144, 5, 28, 159, 156, 30, 32, 158
;Set Background Color
;Args: A = Vic Color Code
;Uses: TEMP0 - Temporary Storage
;Affects: A,C,N,Z
SCRBKG: LSR ;Shift Color Code 4 Bits Left
LSR
LSR
LSR
STA TEMP0 ;Save it
LDA $900F ;Read VIC Color Control Register
AND #$15 ;Strip Existing Backround Color
ORA ;Add in Background Color
STA $900F ;Write back to VIC Chip
RTS
;Set Text Color
;Args: A = Vic color code
;Affects: A,X,C,N,Z
SCRTXT: TAX ;Transfer Color Code to Index
LDA CLRTBL,X ;Load PETSCII Color Control Character
JMP PRCHR ;Print Character and Return
;Clear Screen
;Affects A,C,N,Z
SCRCLR: LDA #CLEAR ;Load Clear Screen Character
JMP PRCHR ;Print it and Return
;Move Cursor Down
;Affects A,C,N,Z
SCRDWN: LDA #DOWN ;Load Cursor Down Character
JMP PRCHR ;Print it and Return
;Move Cursor To Home Position
;Affects A,C,N,Z
SRCHOM: LDA #HOME ;Load Cursor Home Character
JMP PRCHR ;Print it and Return
;Move Cursor Left
;Affects A,C,N,Z
SCRLFT: LDA #LEFT ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor Right
;Affects A,C,N,Z
SCRRGT: LDA #RIGHT ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor Up
;Affects A,C,N,Z
SCRUP: LDA #UP ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor to Specified Coordinates
;Args: A = screen column (0 = top)
; Y = screen line (0 = left)
SCRMOV: TAX ;Transfer Column to X Register
CLC ;Clear Carry Flag
JMP $FFF0 ;Call PLOT Kernal Routine and Return
;Get Cursor Position
;Returns: A = current cursor column
; Y = current cursor row
; X = current cursor column
SCRPOS: SEC ;Set Carry Flag
JSR $FFF0 ;Call PLOT Kernal Routine
TXA ;Transfer Column to Accumulator
RTS
;Get Screen Size
;Returns: A = width of screen in columns
; Y = height of screen in rows
; X = width of screen in columns
SCRSIZ: JSR $FFED ;Call SCREEN Kernal Routine
TXA ;Transfer Width to Accumulator
RTS

83
include/vic/screen.h02 Normal file
View File

@ -0,0 +1,83 @@
/*****************************************************
* Screen Control Functions and Constants for VIC-20 *
*****************************************************/
/* Display Colors */
enum {BLACK, WHITE, RED, CYAN, MAGENT, GREEN, BLUE, YELLOW};
/* PETSCII Color Code Table */
const char clrtbl = {144, 5, 28, 159, 156, 30, 32, 158};
;PETSCII Screen Control Characters
CHRCLR EQU 147 Clear (CLR)
CHRDEL EQU 20 Delete (DEL)
CHRDN EQU 17 Cursor Down
CHRRTN EQU 13 Return
CHRFN1 EQU 133 Function Key 1 (F1)
CHRFN2 EQU 137 Function Key 2 (F2)
CHRFN3 EQU 134 Function Key 3 (F3)
CHRFN4 EQU 138 Function Key 4 (F4)
CHRFN5 EQU 135 Function Key 5 (F5)
CHRFN6 EQU 139 Function Key 6 (F6)
CHRFN7 EQU 136 Function Key 7 (F7)
CHRFN8 EQU 140 Function Key 8 (F8)
CHRHOM EQU 19 Home
CHRINS EQU 148 Insert
CHRLFT EQU 157 Cursor Left
CHRRGT EQU 29 Cursor Left
CHRRVF EQU 146 Reverse Off
CHRRVN EQU 18 Reverse On
CHRUP EQU 145 Cursor Up
/* PETSCII Box Drawing Characters */
#define BOXBLC = 173 //Bottom Left Corner
#define BOXBRC = 189 //Bottom Right Corner
#define BOXBCT = 177 //Bottom to Cetter Tee
#define BOXCTR = 123 //Center Cross
#define BOXHLN = 96 //Horizontal Line
#define BOXLCT = 171 //Left To Center T
#define BOXRCT = 179 //Right To Center T
#define BOXTLC = 176 //Top Left Corner
#define BOXTRC = 174 //Top Right Corner
#define BOXTCT = 178 //Top to Center T
#define BOXVLN = 98 //Verical Line
/* Set Background Color *
* Args: c - color */
char scrbkg();
/* Clear Screen*/
char scrclr();
/* Move Cursor Down */
char scrdwn();
/* Move Cursor Home */
char scrhom();
/* Move Cursor Left */
char scrlft();
/* Move Cursor *
* Args: col - column *
* row - row */
char scrmov();
/* Get Cursor Position *
* Returns: column, row */
char scrpos();
/* Move Cursor Right */
char scrrgt();
/* Get Screen Size *
* Returns: width, height */
char scrsiz();
/* Set Text Color *
* Args: c - color */
char scrtxt();
/* Move Cursor Upt */
char scrup();

View File

@ -1,19 +1,17 @@
/* Unexpanded VIC 20 Header File */
//#pragma ascii invert //switch case for PETSCII
//Platform Specific Constants
/* Platform Specific Constants */
#define DELKEY $14 //Delete/Backspace Key (DEL)
#define ESCKEY $03 //Escape/Stop Key (STOP)
#define ESCKEY $03 //Escape/Break Key (STOP)
#define RTNKEY $0D //Return/Enter Key (RETURN)
//Library Pointer Variables
/* Standard Library Pointers */
char srclo,srchi; //Source String Pointer for Library Functions
char dstlo,dsthi; //Destination String Pointer for Library Functions
char blklo,blkhi; //Block Segment Pointer
char stklo,stkhi; //Stack Pointer
//Library Variables
/* Standard Library Variables */
char blkslo, blkshi; //Block Start Address
char blkelo, blkehi; //Block End Address
char blklen; //Block Segment Length
@ -22,13 +20,15 @@ char stkelo, stkehi; //Stsck End Address
char random, rdseed; //Pseudo-Random Number Generation
char temp0, temp1, temp2, temp3; //Temporary Storage
//System Subroutines
char plkey(); //Poll Console for character
char rdkey(); //Wait for character from Console
char getkey(); //Read ASCII character from Console
void newlin(); //Advance cursor to beginning of next line
/* System Subroutines */
void delchr(); //Delete previous character
void prchr(); //Print ASCII character to Console
char getkey(); //Read ASCII character from Keyboard
char getpos(); //Get Cursor Position
char getsiz(); //Get Screen Size
void newlin(); //Advance cursor to beginning of next line
char polkey(); //Poll Keyboard for character
char putchr(); //Print ASCII character to Keyboard
void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
char getchr(); //Wait for character from Keyboard
void setpos(); //Set Cursor Position

View File

@ -1,152 +0,0 @@
;Screen Control Assembly Lanuage Routines for C02
;Vic Display Colors
BLACK EQU 0 Black
WHITE EQU 1 White
RED EQU 2 Red
CYAN EQU 3 Cyan
MAGNTA EQU 4 Purple
GREEN EQU 5 Green
BLUE EQU 6 Blue
YELLOW EQU 7 Yellow
;PETSCII Color Codes
CTLBLK EQU 144 Black
CTLWHT EQU 5 White
CTLRED EQU 28 Red
CTLCYN EQU 159 Cyan
CTLPUR EQU 156 Purple
CTLGRN EQU 30 Green
CTLBLU EQU 32 Blue
CTLYLW EQU 158 Yellow
;PETSCII Screen Control Codes
CLEAR EQU 147 Clear (CLR)
DELETE EQU 20 Delete (DEL)
DOWN EQU 17 Cursor Down
ENTER EQU 13 Return
FN1 EQU 133 Function Key 1 (F1)
FN2 EQU 137 Function Key 2 (F2)
FN3 EQU 134 Function Key 3 (F3)
FN4 EQU 138 Function Key 4 (F4)
FN5 EQU 135 Function Key 5 (F5)
FN6 EQU 139 Function Key 6 (F6)
FN7 EQU 136 Function Key 7 (F7)
FN8 EQU 140 Function Key 8 (F8)
HOME EQU 19 Home
INSERT EQU 148 Insert
LEFT EQU 157 Cursor Left
RIGHT EQU 29 Cursor Left
RVSOFF EQU 146 Reverse Off
RVSON EQU 18 Reverse On
UP EQU 145 Cursor Up
;PETSCII Box Drawing Characters
BTMLFT EQU 173 Bottom Left Corner
BTMRGT EQU 189 Bottom Right Corner
BTMTEE EQU 177 Bottom to Cetter Tee
CTRCRS EQU 123 Center Cross
HRZLIN EQU 96 Horizontal Line
LFTTEE EQU 171 Left To Center T
RGHTEE EQU 179 Right To Center T
TOPLFT EQU 176 Top Left Corner
TOPRGT EQU 174 Top Right Corner
TOPTEE EQU 178 Top to Center T
VRTLIN EQU 98 Verical Line
;PETSII Color Table
CLRTBL: DB CTLBLK,CTLWHT,CTLRED,CTLCYN,CTLPUR,CTLGRN,CTLBLU,CTLYLW
;Set Background Color
;Args: A = Vic Color Code
;Uses: TEMP0 - Temporary Storage
;Affects: A,C,N,Z
BKGCLR: LSR ;Shift Color Code 4 Bits Left
LSR
LSR
LSR
STA TEMP0 ;Save it
LDA $900F ;Read VIC Color Control Register
AND #$15 ;Strip Existing Backround Color
ORA ;Add in Background Color
STA $900F ;Write back to VIC Chip
RTS
;Set Text Color
;Args: A = Vic color code
;Affects: A,X,C,N,Z
TXTCLR: TAX ;Transfer Color Code to Index
LDA CLRTBL,X ;Load PETSCII Color Control Character
JMP PRCHR ;Print Character and Return
;Clear Screen
;Affects A,C,N,Z
CLRSCN: LDA #CLEAR ;Load Clear Screen Character
JMP PRCHR ;Print it and Return
;Move Cursor Down
;Affects A,C,N,Z
CRSRDN: LDA #DOWN ;Load Cursor Down Character
JMP PRCHR ;Print it and Return
;Move Cursor To Home Position
;Affects A,C,N,Z
CRSRHM: LDA #HOME ;Load Cursor Home Character
JMP PRCHR ;Print it and Return
;Move Cursor Left
;Affects A,C,N,Z
CRSRLF: LDA #LEFT ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor Right
;Affects A,C,N,Z
CRSRRT: LDA #RIGHT ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor Up
;Affects A,C,N,Z
CRSRUP: LDA #UP ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor to Specified Coordinates
;Args: A = screen column (0 = top)
; Y = screen line (0 = left)
MVCRSR: TAX ;Transfer Column to X Register
CLC ;Clear Carry Flag
JMP $FFF0 ;Call PLOT Kernal Routine and Return
;Get Cursor Horizontal Position
;Returns: A = current cursor column
; Y = current cursor row
; X = current cursor column
SCNCOL: SEC ;Set Carry Flag
JSR $FFF0 ;Call PLOT Kernal Routine
TXA ;Transfer Column to Accumulator
RTS
;Get Screen Height in Rows
;Returns: A = height of screen in rows
; Y = height of screen in rows
; X = width of screen in columns
SCNGHT: JSR $FFED ;Call SCREEN Kernal Routine
TYA ;Transfer Height to Accumulator
RTS
;Get Cursor Vertical Position
;Returns: A = current cursor row
; Y = current cursor row
; X = current cursor column
SCNROW: SEC ;Set Carry Flag
JSR $FFF0 ;Call PLOT Kernal Routine
TYA ;Transfer Row to Accumulator
RTS
;Get Screen Width in Rows
;Returns: A = width of screen in columns
; Y = height of screen in rows
; X = width of screen in columns
SCNWID: JSR $FFED ;Call SCREEN Kernal Routine
TXA ;Transfer Width to Accumulator
RTS

View File

@ -23,12 +23,12 @@ char random, rdseed; //Pseudo-Random Number Generation
char temp0, temp1, temp2, temp3; //Temporary Storage
//System Subroutines
char plkey(); //Poll Console for character
char rdkey(); //Wait for character from Console
char polkey(); //Poll Console for character
char getchr(); //Wait for character from Console
char getkey(); //Read ASCII character from Console
void newlin(); //Advance cursor to beginning of next line
void delchr(); //Delete previous character
void prchr(); //Print ASCII character to Console
char putchr(); //Print ASCII character to Console
void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit

View File

@ -23,12 +23,15 @@ char random, rdseed; //Pseudo-Random Number Generation
char temp0, temp1, temp2, temp3; //Temporary Storage
//System Subroutines
char plkey(); //Poll Console for character
char rdkey(); //Wait for character from Console
char polkey(); //Poll Console for character
char getchr(); //Wait for character from Console
char getkey(); //Read ASCII character from Console
void newlin(); //Advance cursor to beginning of next line
void delchr(); //Delete previous character
void prchr(); //Print ASCII character to Console
char putchr(); //Print ASCII character to Console
void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
void clrscr(); //Clear the Screen
char getsiz(); //Get Screen Size
char getpos(); //Get Cursor Position
void setpos(); //Set Cursor Position

View File

@ -5,7 +5,7 @@ IF EXIST %1.c02 GOTO COMPILE
:COMPILE
ECHO Compiling File %1.c02
..\c02.exe -h apple2 %1 >%1.dbg
..\c02.exe -h apple2 -s apple2 %1 >%1.dbg
IF ERRORLEVEL 1 EXIT /B
ECHO Assembling File %1.asm

40
test/joystick.c02 Normal file
View File

@ -0,0 +1,40 @@
/*************************************
* JOYSTICK - Test joystk() function *
*************************************/
//use -h option on command line
#include <joystk.h02>
char i,j,r;
char aa,yy,xx;
void prtdir(aa,yy,xx) {
if (aa & yy) xx = '*';
putchr(xx);
}
main:
clrscr();
if (!#JYSTKS) goto exit;
for (i=0;i<#JYSTKS;i++) {
r = i + 1;
setpos(1,r);
putchr('J'); prhex(i); putchr(':');
}
while() {
for(i=0; i<#JYSTKS; i++) {
j = joystk(i);
r = i + 1;
setpos(4,r);
prbyte(j);
putchr(' ');
prtdir(j,#JOYUP,'U');
prtdir(j,#JOYDN,'D');
prtdir(j,#JOYLF,'L');
prtdir(j,#JOYRT,'R');
prtdir(j,#JOYB0,'B');
}
if (getkey()==#ESCKEY) break;
}
goto exit;

37
test/lightpen.c02 Normal file
View File

@ -0,0 +1,37 @@
/************************************
* LIGHTPEN - Test lgtpen() function *
************************************/
//use -h option on command line
#include <lgtpen.h02>
char aa,xx,yy;
void prtlbl(aa,yy,xx) {
setpos(aa,yy);
putchr(xx); putchr(':');
}
void prtbyt(aa,yy,xx) {
setpos(aa,yy);
prbyte(xx);
}
char px,py,pt;
main:
clrscr();
if (!#LGTPNS) goto exit;
prtlbl(1,1,'X');
prtlbl(1,2,'Y');
prtlbl(1,3,'T');
loop:
if (getkey() == #ESCKEY) goto exit;
px,py,pt = lgtpen();
prtbyt(4,1,px);
prtbyt(4,2,py);
prtbyt(4,3,pt);
goto loop;

37
test/paddles.c02 Normal file
View File

@ -0,0 +1,37 @@
/************************************
* PADDLES - Test paddle() function *
************************************/
//use -h option on command line
#include <paddle.h02>
char i,b,p;
main:
clrscr();
if (!#PADDLS|#BUTTNS) goto exit;
for (i=0;i<#PADDLS;i++) {
setpos(1,i);
putchr('P'); prhex(i); putchr(':');
}
for (i=0;i<#BUTTNS;i++) {
setpos(7,i);
putchr('B'); prhex(i); putchr(':');
}
loop:
if (getkey() == #ESCKEY) goto exit;
for (i=0;i<#PADDLS;i++) {
p = paddle(i);
setpos(4,i);
prbyte(p);
}
for (i=0;i<#BUTTNS;i++) {
b = button(i);
setpos(10,i);
prbyte(b);
}
goto loop;

View File

@ -5,7 +5,7 @@ IF EXIST %1.c02 GOTO COMPILE
:COMPILE
ECHO Compiling File %1.c02 for VIC 20 +8k
..\c02.exe -H vic8k %1 >%1.dbg
..\c02.exe -h vic8k -s vic %1 >%1.dbg
IF %ERRORLEVEL% NEQ 0 GOTO EOF
ECHO Assembling File %1.asm
C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym

View File

@ -15,6 +15,7 @@ VICVideoCache=1
VICFilter=0
SidEngine=1
SidModel=0
JoyDevice1=1
DriveTrueEmulation=0
ETHERNET_DISABLED=1
ETHERNETCARTBase=38912