1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-16 13:29:33 +00:00

Updated standard library include files

This commit is contained in:
Curtis F Kaylor 2018-11-07 00:11:09 -05:00
parent 9bee7114fd
commit 11fbab1281
29 changed files with 833 additions and 193 deletions

View File

@ -46,7 +46,7 @@ STORY EQU $C3B3 ;Store Accumulator at Current Screen Position
PRBLNK EQU $F94C ;Print 3 blanks PRBLNK EQU $F94C ;Print 3 blanks
PRBLNX EQU $F94C ;Print X blanks PRBLNX EQU $F94C ;Print X blanks
PRBLAX EQU $F94C ;Print character in A followed by X-1 blanks PRBLAX EQU $F94C ;Print character in A followed by X-1 blanks
RDKEY EQU $FD0C ;Waits for keypress and return in A GETCHR EQU $FD0C ;Waits for keypress and return in A
KEYIN EQU $FD1B ;Waits for keypress and cycle random-number generator KEYIN EQU $FD1B ;Waits for keypress and cycle random-number generator
RDCHAR EQU $FD35 ;Read keyboard (processing escapes) RDCHAR EQU $FD35 ;Read keyboard (processing escapes)
GETLIN EQU $FD6A ;Get Line from Keyboard into Input Buffer GETLIN EQU $FD6A ;Get Line from Keyboard into Input Buffer
@ -74,13 +74,13 @@ PLKEY: LDA #0 ;Clear Accumulator
PLKEYR: RTS PLKEYR: RTS
;Read Keyboard ;Read Keyboard
GETKEY JSR PLKEY ;Poll Keyboard GETKEY JSR POLKEY ;Poll Keyboard
BEQ GETKEY ;Loop if No Key BEQ GETKEY ;Loop if No Key
AND #$7F ;Strip High Bit AND #$7F ;Strip High Bit
RTS RTS
;Print Character to Screen ;Print Character to Screen
PRCHR: ORA #$80 ;Set High Bit PUTCHR ORA #$80 ;Set High Bit
CMP #$E0 ; CMP #$E0 ;
BCC PRCHRX ;If Lower Case BCC PRCHRX ;If Lower Case
AND #$1F ; Convert to Inverse AND #$1F ; Convert to Inverse
@ -91,7 +91,7 @@ DELCHR: LDX #2 ;Two Characters Total
LDA #$88 ;Load Backspace Character LDA #$88 ;Load Backspace Character
JSR PRBLAX ;Print Accumulator and X-1 Blanks JSR PRBLAX ;Print Accumulator and X-1 Blanks
LDA #$88 ;Load Backspace Character LDA #$88 ;Load Backspace Character
JMP PRCHR ;and Print it JMP PUTCHR ;and Print it
;Advance Character to Next line ;Advance Character to Next line
NEWLIN EQU CROUT ;Alias to Monitor Routine NEWLIN EQU CROUT ;Alias to Monitor Routine

View File

@ -27,10 +27,10 @@ void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit void prhex(); //Print Low Nybble of Accumulator as Hex Digit
//System Subroutines //System Subroutines
char plkey(); //Poll Console for character char polkey(); //Poll Console for character
char rdkey(); //Wait for character from Console char getchr(); //Wait for character from Console
char getkey(); //Read ASCII character from Console char getkey(); //Read ASCII character from Console
void newlin(); //Advance cursor to beginning of next line void newlin(); //Advance cursor to beginning of next line
void prchr(); //Print ASCII character to Console char putchr(); //Print ASCII character to Console
void setdst(); //Set Destination Pointer void setdst(); //Set Destination Pointer
void setsrc(); //Set Source Pointer void setsrc(); //Set Source Pointer

43
include/atari/color.a02 Normal file
View File

@ -0,0 +1,43 @@
;Color and Character Assembly Language Equates for Atari 400 & 800
; Display Colors
BLACK EQU $00 Black
RED EQU $00 Red
GREEN EQU $00 Green
YELLOW EQU $00 Yellow
BLUE EQU $00 Blue
MAGENT EQU $00 Magenta
CYAN EQU $00 Cyan
WHITE EQU $00 White
;ASCII Screen Control Characters
CHRBCK EQU $7E Backspace
CHRBEL EQU $FD Beep (Buzzer)
CHRCLR EQU $7D Clear Screen
CHRDEL EQU $FE Delete (Character)
CHRDWN EQU $1C Cursor Down
CHRFLS EQU $00 Flash On
CHRHOM EQU $00 Home (None)
CHRINS EQU $FF Insert (Character)
CHRLFT EQU $1E Cursor Left
CHRRGT EQU $1F Cursor Right
CHRRTN EQU $9B Return (End of Line)
CHRTAB EQU $7F Tab
CHRUP EQU $1B Cursor Up
;ATASCII Symbolic Characters
CHRBLK EQU $A0 Block
;ASCII Box Drawing Characters
BOXBLC EQU $0A Bottom Left Corner
BOXBRC EQU $03 Bottom Right Corner
BOXBCT EQU $18 Bottom to Cetter Tee
BOXCTR EQU $13 Center Cross
BOXHLN EQU $12 Horizontal Line
BOXLCT EQU $01 Left To Center T)
BOXRCT EQU $04 Right To Center T
BOXTLC EQU $11 Top Left Corner
BOXTRC EQU $05 Top Right Corner
BOXTCT EQU $17 Top to Center T
BOXVLN EQU $7C Vertical Line (|)

22
include/atari/joystk.a02 Normal file
View File

@ -0,0 +1,22 @@
;Joystick Assembly Language Module for Atari 400 & 800
JYSTKS EQU $02 ;Number of Joysticks
;Joystick Bit Masks
JOYUP EQU $01 ;Bit 0 - Up
JOYDN EQU $02 ;Bit 1 - Down
JOYLF EQU $04 ;Bit 2 - Left
JOYRT EQU $08 ;Bit 3 - Right
JOYB0 EQU $10 ;Bit 4 - Button
;Read Joystick
JOYSTK: CMP #JYSTKS ;If Invalid Joystick#
BCS JOYSTZ ; Return Error
EOR #$01 ;Invert Joystick Number
TAX ;and Copy to X Register
LDA $DC00,X ;Read Joystick
EOR #$FF ;Invert and
AND #$1F ;Mask Bits
RTS
JOYSTZ: LDA #$FF ;Return Error
RTS

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

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

21
include/atari/lgtpen.a02 Normal file
View File

@ -0,0 +1,21 @@
;Lightpen Assembly Language Module for Atari 400 & 800
LGTPNS EQU #$FF ;Light Pen Status (Supported)
;Read Light Pen
;Returns: A = X Position / 2
; Y = Y Position
; X = Trigger Status ($FF = Pressed)
LGTPEN: LDX #0 ;Initialize X to FALSE (0)
LDA $0284 ;Check Joystick Button
EOR #$FF ;Invert and
AND #$01 ;Mask Bits
BEQ LGTPET ;If Trigger Pulled, Set X to $FF
LDA $0278 ;Read Joystick Switches
EOR #$FF ;Invert and
AND #$0F ;Mask Bits
BEQ LGTPEP ;If Trigger Pulled
LGTPET: DEX ; Set X to TRUE ($FF)
LGTPEP: LDY $0234 ;Read Y Position into Y
LDA $0235 ;Read X Position into A
RTS

5
include/atari/lgtpen.h02 Normal file
View File

@ -0,0 +1,5 @@
/* Lightpen Module Header File for Atari 400 & 800 */
#define LGTPNS $FF //Light Pen Status (Supported)
char lgtpen(); //Read Light Pen

33
include/atari/paddle.a02 Normal file
View File

@ -0,0 +1,33 @@
;Paddle Controller Constants and Functions for Atari 400 & 800
PADDLS EQU #$08 ;Maximum Numbers of Paddles
;Read Paddle
;Args: A = Paddle #
;Affects: X
;Returns: A = Paddle Value
; 0 and Carry Set if Paddle # Invalid
PADDLE: CMP #PADDLS ;If Invalid Paddle #
BCS BUTTOZ ; Return 0 & Carry Set
TAX ;Copy Paddle # to X
LDA $0270,X ;Read Paddle Shadow Register
RTS
BUTTNS EQU #$04 ;Maximum Numbers of Paddle Buttons
;Read Paddle Button
;Args: A = Button #
;Affects: X,Y
;Returns: A = $FF if Paddle Button Pressed
; $00 if Paddle Button Not Pressed
; Carry Set if Button Number Invalid
BUTTON: CMP #BUTTNS ;If Button# >= # of Buttons
BCS BUTTOZ ; Return FALSE & Carry Set
TAX ;and Copy to X Register
LDA $027C,Y ;Read Button Shadow Register
AND #$01 ;Mask off Relevant Bit
BNE BUTTOZ ;If Bit is 0
LDA #$FF ; Return TRUE
RTS ;Else
BUTTOZ: LDA #$00 ; Return FALSE
RTS

20
include/atari/paddle.h02 Normal file
View File

@ -0,0 +1,20 @@
/* Psddle Controllers Header File for Atari 400 & 800 */
#define BUTTNS 4 //Number of Paddle Buttons
#define PADDLS 4 //Number of Paddles
/* Get Paddle Button Status *
* Args: b = Button Number *
* Same as Paddle Number *
* Returns: $FF if Button Pressed *
* $00 if Not Pressed */
void button();
/* Get Paddle Status *
* Args: p = Paddle Number *
* 0 - Port 1 Paddle X *
* 1 - Port 1 Paddle Y *
* 2 - Port 2 Paddle X *
* 3 - Port 2 Paddle Y *
* Returns: Paddle Value (0-255) */
void paddle();

View File

@ -1,4 +1,5 @@
;Screen Control Assembly Language Routines for Oric-1 ;Screen Control Assembly Language Routines for Atari 400 & 800
;*** Incomplete - Copied from Oric-1 ***
; Display Colors ; Display Colors
BLACK EQU $00 Black BLACK EQU $00 Black

View File

@ -90,20 +90,4 @@ NEWLIN: LDX #0 ;Store 0
STX $D3 ;in Cursor Column and STX $D3 ;in Cursor Column and
JMP $E87C ;Execute NXTLINE Routine JMP $E87C ;Execute NXTLINE Routine
;Print Byte as Two-Digit Hex Number to Console INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routine
PRBYTE: PHA ;Save Accumulater
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR PRHEX ; and Print it
PLA ;Restore Accumulator
; and fall into prhex
;Print Low Nybble as Hex Digit to Console
PRHEX: AND #$0F ;Strip High Nybble
CMP #$0A ;If Low Nybble >= 10
BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return

View File

@ -1,6 +1,6 @@
;Joystick Assembly Language Module for C64 ;Joystick Assembly Language Module for C64
JYSTKS EQU $02 ;Number of Joysticks JYSTKS EQU $04 ;Number of Joysticks
;Joystick Bit Masks ;Joystick Bit Masks
JOYUP EQU $01 ;Bit 0 - Up JOYUP EQU $01 ;Bit 0 - Up
@ -12,11 +12,14 @@ JOYB0 EQU $10 ;Bit 4 - Button
;Read Joystick ;Read Joystick
JOYSTK: CMP #JYSTKS ;If Invalid Joystick# JOYSTK: CMP #JYSTKS ;If Invalid Joystick#
BCS JOYSTZ ; Return Error BCS JOYSTZ ; Return Error
EOR #$01 ;Invert Joystick Number TAX ;Copy Joystick # to X
TAX ;and Copy to X Register LDA $0284,X ;Read Trigger Control Register
LDA $DC00,X ;Read Joystick ROR ;Move Bit 0 into Carry
LDA $DC00,X ;Read Joystick Shadow Register
EOR #$FF ;Invert and EOR #$FF ;Invert and
AND #$1F ;Mask Bits AND #$0F ;Mask Bits
RTS BCS JOYSTX ;If Trigger Pressed
ORA #$10 ; Set Bit 4
HOYSTX: RTS
JOYSTZ: LDA #$FF ;Return Error JOYSTZ: LDA #$FF ;Return Error
RTS RTS

88
include/comm.h02 Normal file
View File

@ -0,0 +1,88 @@
/***********************************************
* comm - Serial Communication Library for C02 *
***********************************************/
/* Command Register Constants */
#define BR50 = $01 //Baud Rate - 50 BPS
#define BR75 = $02 //Baud Rate - 75 BPS
#define BR110 = $03 //Baud Rate - 110 BPS
#define BR134 = $04 //Baud Rate - 134 BPS
#define BR150 = $05 //Baud Rate - 140 BPS
#define BR300 = $06 //Baud Rate - 300 BPS
#define BR600 = $07 //Baud Rate - 300 BPS
#define BR1200 = $08 //Baud Rate - 1200 BPS
#define BR1800 = $09 //Baud Rate - 1800 BPS
#define BR2400 = $0A //Baud Rate - 2400 BPS
#define BR4800 = $0B //Baud Rate - 4800 BPS
#define BR9600 = $0C //Baud Rate - 9600 BPS
#define SBITS1 = $00 //1 Stop Bit
#define SBITS2 = $80 //2 Stop Bits
#define WRDLN5 = $60 //Word Length - 5 Bits
#define WRDLN6 = $40 //Word Length - 5 Bits
#define WRDLN7 = $20 //Word Length - 5 Bits
#define WRDLN8 = $00 //Word Length - 5 Bits
/* Control Register Constants */
#define PTYOFF = $00 //Parity - Disable
#define PTYODD = $01 //Parity - Odd
#define PTYEVN = $02 //Parity - Even
#define PTYMRK = $03 //Parity - Mark
#define PTYSPC = $04 //Parity - Space
#define DPXFUL = $00 //Duplex - Full
#define DPXHLF = $80 //Duplex - Half
#define XLTNON = $00 //No Translation
#define XTLASC = $10 //ASCII Translation
#define LFNONE = $00 //No LF after CR
#define LFSEND = $40 //Send LF after CR
#define SHKSFT = $00 //Handshake - Software
#define SHKHRD = $80 //Handshake - Hardware
/* Return Serial Buffer Status *
* Args: fp - file pointer *
* Returns: tuple: number of characters in *
input buffer and output buffer */
char cbffrs();
/* Close Serial Port *
* Args: fp - file pointer *
* Returns: 0 if successful *
* 255 if error */
char cclose();
/* Get Serial Port Error Status *
* Returns: Error Code *
* 0 if No Error */
char cerror();
/* Read Character from Serial Port *
* Args: fp - file pointer *
* Returns: character read */
char cgetc();
/* Open Serial Port for Communication *
* Args: prt - Serial Port Number *
* cmd - Command Register *
* ctl - Control Register *
* Returns: File Pointer for Opened Port *
* 0 if Error */
char copen();
/* Write Character to Serial Port *
* Args: fp - file pointer *
* c - character to write *
* Returns: 0 if successful *
255 if error */
char cputc();
/* Write String to Serial Port *
* Args: fp - file pointer *
* &s - string to write *
* Returns: 0 if successful *
255 if error */
char cputs();

View File

@ -42,6 +42,14 @@ START: NOP ;System specific initialization code
STX STKSAV ; the Stack Pointer should be preserved STX STKSAV ; the Stack Pointer should be preserved
JMP MAIN ;Execute Program JMP MAIN ;Execute Program
;Exit Program and Return to Operating System or Monitor
EXIT: BRK ;Usually BRK if returning to Monitor
LDX STKSAV ;If an RTS is used to return to the Operating System,
TXS ; the Stack Pointer should be restored to original state
RTS ; in case program exits in the middle of a Function
JMP WSTART ;Or it may just execute the BASIC Warm Start Routine
;Poll Character from Keyboard ;Poll Character from Keyboard
PLKEY: INC RDSEED ;Cycle the Random Seed (if not provided by system) PLKEY: INC RDSEED ;Cycle the Random Seed (if not provided by system)
NOP ;Code Read from Keyboad NOP ;Code Read from Keyboad
@ -52,8 +60,8 @@ GETKEY; ;Usually Drops into RDKEY, but may need to call RDKEY
; then clean/convert returned value (e.g. Apple-1) ; then clean/convert returned value (e.g. Apple-1)
;Wait for Character from Console ;Wait for Character from Console
RDKEY: JSR PLKEY ;Usually calls PLKEY GETCHR: JSR POLKEY ;Usually calls POLKEY
BEQ RDKEY ; until a non-zero is returned BEQ GETCHR ; until a non-zero is returned
RTS RTS
;Delete Previous Character ;Delete Previous Character
@ -65,13 +73,19 @@ NEWLIN: RTS ;Code to move Cursor to beginning of next line
;May emit Carriage Return, Line Feed, or both ;May emit Carriage Return, Line Feed, or both
;Print Character to Screen ;Print Character to Screen
PRCHR: RTS ;Code to write ASCII character to Screen PUTCHR RTS ;Code to write ASCII character to Screen
;Exit Program and Return to Operating System or Monitor ;Clear the Screen
EXIT: BRK ;Usually BRK if returning to Monitor CLRSCR: RTS ;Code to Clear Screen
LDX STKSAV ;If an RTS is used to return to the Operating System,
TXS ; the Stack Pointer should be restored to original state ;Move Cursor to Specified Coordinates
RTS ; in case program exits in the middle of a Function SETPOS: RTS ;Move Cursor to Column A, Row Y
;Get Cursor Position
GETPOS: RTS ;Return Cursor Column in A, Row in Y
;Get Screen Size
GETSIZ: RTS ;Return Screen Width in A, Height in Y
;Note: The following two functions replicate calls available ;Note: The following two functions replicate calls available
;in the Apple-1 monitor and are included for test purposes ;in the Apple-1 monitor and are included for test purposes
@ -94,7 +108,7 @@ PRHEX: AND #$0F ;Strip High Nybb
ADC #$90 ;Convert to $90-$99,$00-$05 ADC #$90 ;Convert to $90-$99,$00-$05
ADC #$40 ;Convert to $30-$39,$41-$46 ADC #$40 ;Convert to $30-$39,$41-$46
CLD ;Clear Decimal Flag CLD ;Clear Decimal Flag
JMP PRCHR ;Print Hex Digit and Return JMP PUTCHR ;Print Hex Digit and Return
;Alternate Code for Systems with Interrupts that don't CLD ;Alternate Code for Systems with Interrupts that don't CLD
PRHEX: AND #$0F ;Strip High Nybble PRHEX: AND #$0F ;Strip High Nybble
@ -102,4 +116,4 @@ PRHEX: AND #$0F ;Strip High Nybble
BCC PRHEXC ; BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'... ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PRCHR ;Print Hex Digit and Return JMP PUTCHR ;Print Hex Digit and Return

View File

@ -34,10 +34,14 @@ char random; //Last Result of Pseudo-Random Number Generator
char rdseed; //System Seed for Pseudo-Random Number Generator char rdseed; //System Seed for Pseudo-Random Number Generator
//System Subroutines //System Subroutines
char plkey(); //Poll Console for character void delchr(); //Delete previous character
char rdkey(); //Wait for character from Console
char getkey(); //Read ASCII 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 void newlin(); //Advance cursor to beginning of next line
void prchr(); //Print ASCII character to Console char polkey(); //Poll Console for character
char putchr(); //Print ASCII character to Console
void prbyte(); //Print Accumulator as Hexadadecimal number void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit void prhex(); //Print Low Nybble of Accumulator as Hex Digit
char getchr(); //Wait for character from Console
void setpos(); //Set Cursor Position

24
include/intrpt.a02 Normal file
View File

@ -0,0 +1,24 @@
;Interrupt Vector Manipulation Routines
;Interrupt Vectors
NMILO EQU $FFFA ;Non-Maskable Interrupt
NMIHI EQU $FFFB
RSTLO EQU $FFFC ;Reset
RSTHI EQU $FFFD
IRQLO EQU $FFFE ;Maskable Interrupt
IRQHI EQU $FFFF
;Set Non-Maskable Interrupt Handler
SETNMI: STY NMIHI
STX NMILO
RTS
;Set Reset Handler
SETRST: STY RSTHI
STX RSTLO
RTS
;Set Maskable Interrupt Handler
SETIRQ: STY IRQHI
STX IRQLO
RTS

View File

@ -1,39 +1,30 @@
; c02 Program Initialization Code for Commodore Plus/4 & 16 ; c02 Program Initialization Code for Commodore Plus/4 & 16
;ASCII Control Codes Equivalents
CR EQU $0D ;Carriage Return
LF EQU $11 ;Line Feed (Cursor Down)
DEL EQU $14 ;Delete
HT EQU $1D ;Horizontal Tab (Cursor Right)
VT EQU $91 ;Vertical Tab (Cursor Up)
FF EQU $93 ;Form Feed (Clear Screen)
BS EQU $9D ;Backspace (Cursor Left)
;PETSCII Key Mappings ;PETSCII Key Mappings
DELKEY EQU $14 ;Delete/Backspace Key (Delete) DELKEY EQU $14 ;Delete/Backspace Key (Delete)
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP) ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
RTNKEY EQU $0D ;Return/Enter Key (RETURN) RTNKEY EQU $0D ;Return/Enter Key (RETURN)
;Zero Page Locations ;Zero Page Locations
strlo EQU $FE ;String Pointer (stdio.asm) STRLO EQU $FE ;String Pointer (stdio.asm)
strhi EQU $FF ; STRHI EQU $FF ;
;Other RAM Locations ;Other RAM Locations
tbffr EQU $0333 ;Cassette I/O Buffer TBFFR EQU $0333 ;Cassette I/O Buffer
;Video RAM and ROM ;Video RAM and ROM
vidscn EQU $0C00 ;Video Screen Memory Area VIDSCN EQU $0C00 ;Video Screen Memory Area
chrrom EQU $D000 ;Character Generator ROM CHRROM EQU $D000 ;Character Generator ROM
vidclr EQU $0800 ;Color RAM VIDCLR EQU $0800 ;Color RAM
;Kernal Routines ;Kernal Routines
chrin EQU $FFCF ;Input Character to Channel CHROUT EQU $FFD2 ;Output Character to Channel
chrout EQU $FFD2 ;Output Character to Channel GETIN EQU $FFE4 ;Read Character from Keyboard Buffer
getin EQU $FFE4 ;Read Character from Keyboard Buffer CHRIN EQU $FFCF ;Input Character to Channel
;Machine Language Basic Stub ;Machine Language Basic Stub
ORG $1001 ;Start ORG $1001 ;Start
basic: DC $0C, $10 ; Pointer to Next Line (4108) BASIC: DC $0C, $10 ; Pointer to Next Line (4108)
DC $00, $00 ; Line Number (0) DC $00, $00 ; Line Number (0)
DC $9E ; SYS DC $9E ; SYS
DC $20 ; ' ' DC $20 ; ' '
@ -41,46 +32,44 @@ basic: DC $0C, $10 ; Pointer to Next Line (4108)
DC $00 ;End of Line Marker DC $00 ;End of Line Marker
DC $00, $00 ;End of Basic Program DC $00, $00 ;End of Basic Program
start: TSX ;Get Stack Pointer START: TSX ;Get Stack Pointer
STX user15 ;and Save for Exit STX user15 ;and Save for Exit
JMP main ;Execute Program JMP main ;Execute Program
exit: LDX user15 ;Retrieve Saved Stack Pointer EXIT: LDX user15 ;Retrieve Saved Stack Pointer
TXS ;and Restore It TXS ;and Restore It
RTS ;Return to BASIC RTS ;Return to BASIC
;Poll Keyboard for Character ;Poll Keyboard for Character
plkey EQU getin ;Read Character from Keyboard Buffer POLKEY EQU $FFE4 ;Alias to Kernal Routine GETIN
;Get Character from Keyboard ;Get Character from Keyboard
getkey: GETKEY EQU POLKEY
;Wait for Character from Keyboard ;Wait for Character from Keyboard
rdkey: JSR plkey ;Poll Keyboard GETCHR: JSR POLKEY ;Poll Keyboard
BEQ getkey ;If No Key, Loop BEQ GETCHR ;If No Key, Loop
RTS RTS
;Delete Previous Character
delchr: RTS
;Advance Character to Next line ;Advance Character to Next line
newlin: LDA #$0D ;Load C/R into Accumulator NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP PUTCHR
;Print Character to Console ;Print Character to Console
prchr EQU chrout ; PUTCHR EQU $FFD2 ;Alias to Kernal Routine CHROUT
;Delete Previous Character ;Delete Previous Character
delchr: LDA #$9D ;Load Cursor Left into Accumulator DELCJR: LDA #$9D ;Load Cursor Left into Accumulator
JSR prchr ; and Print it JSR PUTCHR ; and Print it
LDA #$14 ;Load Delete into Accumulater LDA #$14 ;Load Delete into Accumulater
JMP prchr ; and Print it JMP PUTCHR ; and Print it
;Advance Character to Next line ;Advance Character to Next line
newlin: LDA #$0D ;Load C/R into Accumulator NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP prchr ; and Print it JMP PUTCHR ; and Print it
;Print Byte as Two-Digit Hex Number to Console ;Print Byte as Two-Digit Hex Number to Console
prbyte: PHA ;Save Accumulater PRBYTE: PHA ;Save Accumulater
LSR ;Shift Hi Nybble to Low Nybble LSR ;Shift Hi Nybble to Low Nybble
LSR LSR
LSR LSR
@ -90,12 +79,12 @@ prbyte: PHA ;Save Accumulater
; and fall into prhex ; and fall into prhex
;Print Low Nybble as Hex Digit to Console ;Print Low Nybble as Hex Digit to Console
prhex: AND #$0F ;Strip High Nybble PRHEX: AND #$0F ;Strip High Nybble
CMP #$0A ;If Low Nybble >= 10 CMP #$0A ;If Low Nybble >= 10
BCC prhexc ; BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'... ADC #$06 ; Convert ':' to 'A'...
prhexc: ADC #$30 ;Convert to ASCII Character PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP prchr ;Print Hex Digit and Return JMP PUTCHR ;Print Hex Digit and Return
exit: RTS ;Return to Monitor EXIT: RTS ;Return to BASIC

View File

@ -66,7 +66,7 @@ POLKEY: INC RDSEED ;Cycle the Random Seed
GETKEY EQU POLKEY ;Aliased to POLKEY GETKEY EQU POLKEY ;Aliased to POLKEY
;Wait for Character from Console ;Wait for Character from Console
GETCHR JSR POLKEY ;Calls POLKEY GETCHR: JSR GETKEY ;Calls GETKEY
BEQ GETCHR ; until a non-zero is returned BEQ GETCHR ; until a non-zero is returned
RTS RTS
@ -81,32 +81,17 @@ NEWLIN EQU $CB9F ;Basic NEWLINE Routine ($CBF0 for ATMOS)
; LDA #$0A ;Load Line Feed and fall through to PRCHR ; LDA #$0A ;Load Line Feed and fall through to PRCHR
;Print Character to Screen ;Print Character to Screen
PUTCHR TAX ;Transfer Character to X Register PUTCHR: TAX ;Transfer Character to X Register
JMP $F409 ;Execute VDU Routine JMP $F409 ;Execute VDU Routine
;Get End of Free Memory
RAMTOP: LDX $A6 ;Load HIMEM LSB
LDY $A7 ;Load HIMEM MSB
RTS
;Exit Program and Return to Operating System or Monitor ;Exit Program and Return to Operating System or Monitor
EXIT LDA #255 ;Set Caps Lock On EXIT: LDA #255 ;Set Caps Lock On
STA $020C STA $020C
JMP $C003 ;BASIC Warm Start JMP $C003 ;BASIC Warm Start
;
;Note: The following two functions replicate calls available
;in the Apple-1 monitor and are included for test purposes
;They will likely be removed before the final release
;Print Byte as Two-Digit Hex Number to Console INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
PRBYTE: PHA ;Save Accumulater
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR PRHEX ; and Print it
PLA ;Restore Accumulator
; and fall into PRHEX
;Print Low Nybble as Hex Digit to Console
PRHEX: AND #$0F ;Strip High Nybble
CMP #$0A ;If Low Nybble >= 10
BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return

106
include/oric/color.a02 Normal file
View File

@ -0,0 +1,106 @@
;Screen Control Assembly Language Routines for Oric-1
; Display Colors
BLACK EQU 0 Black
RED EQU 1 Red
GREEN EQU 2 Green
YELLOW EQU 3 Yellow
BLUE EQU 4 Blue
MAGENT EQU 5 Magenta
CYAN EQU 6 Cyan
WHITE EQU 7 White
;ASCII Screen Control Characters
CHRBEL EQU $07 Beep (Bell)
CHRBLK EQU $FF Block
CHRCAP EQU $14 Caps Lock ()
CHRCKR EQU $7E Checkerboard
CHRCLR EQU $0C Clear (Form Feed)
CHRDEL EQU $7F Delete (Delete)
CHRDWN EQU $0A Cursor Down (Line Feed)
CHRFLS EQU 140 Flash On
CHRHOM EQU $00 Home (None)
CHRINS EQU $00 Insert
CHRLFT EQU $08 Cursor Left (Backspace)
CHRRGT EQU $09 Cursor Right (Tab)
CHRRTN EQU $0D Return (Carriage Return)
CHRRVF EQU $00 Reverse Off
CHRRVN EQU $00 Reverse On
CHRUP EQU $0B Cursor Up (Vertical Tab)
;ASCII Box Drawing Characters
BOXBLC EQU 43 Bottom Left Corner (+)
BOXBRC EQU 43 Bottom Right Corner (+)
BOXBCT EQU 45 Bottom to Cetter Tee (-)
BOXCTR EQU 123 Center Cross (+)
BOXHLN EQU 45 Horizontal Line (-)
BOXLCT EQU 124 Left To Center T (|)
BOXRCT EQU 124 Right To Center T (|)
BOXTLC EQU 43 Top Left Corner (+)
BOXTRC EQU 43 Top Right Corner (+)
BOXTCT EQU 45 Top to Center T (-)
BOXVLN EQU 124 Vertical Line (|)
;ASCII Color Code Table
CLRCDS DC 128, 129, 130, 131, 132, 133, 134, 136
;Set Background Color
;Args: A = Oric Color Code
;Uses: TEMP0 - Temporary Storage
;Affects: A,C,N,Z
SCRBKG: AND $07 ;Strip High Bits
ORA $90 ;Convert to Control Character
JMP PRCHR ;Print Character and Return
;Set Text Color
;Args: A = Vic color code
;Affects: A,X,C,N,Z
SCRTXT: AND $07 ;Strip High Bits
ORA $80 ;Convert to Control Character
JMP PRCHR ;Print Character and Return
;Clear Screen
;Affects A,C,N,Z
SCRCLR: LDA #CHRCLR ;Load Clear Screen Character
JMP PRCHR ;Print it and Return
;Move Cursor Down
;Affects A,C,N,Z
SCRDWN: LDA #CHRDWN ;Load Cursor Down Character
JMP PRCHR ;Print it and Return
;Move Cursor To Home Position
;Affects A,C,N,Z
SCRHOM: LDA #0 ;Column 0
TAY ;Row 0
BEQ SRCMOV ;Move Cursor
;Move Cursor Left
;Affects A,C,N,Z
SCRLFT: LDA #CHRLFT ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor Right
;Affects A,C,N,Z
SCRRGT: LDA #CHRRGT ;Load Cursor Left Character
JMP PRCHR ;Print it and Return
;Move Cursor Up
;Affects A,C,N,Z
SCRUP: LDA #CHRUP ;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: RTS ;Not Yet Implemented
;Get Cursor Position
;Returns: A = current cursor column
; Y = current cursor row
SCRPOS: RTS ;Not Yet Implemented
;Get Screen Size
;Returns: A = width of screen in columns
; Y = height of screen in rows
SCRSIZ: RTS ;Not Yet Implemented

84
include/oric/color.h02 Normal file
View File

@ -0,0 +1,84 @@
/*****************************************************
* Screen Control Functions and Constants for Oric-1 *
* INCOMPLETE: Copied from VIC20/C64 *
*****************************************************/
/* 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();

20
include/prbyte.a02 Normal file
View File

@ -0,0 +1,20 @@
;Assembly Header Include File for platforms
;that do not have PRBYTE amnd PRHEX routines in ROM
;Print Byte as Two-Digit Hex Number to Console
PRBYTE: PHA ;Save Accumulater
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR PRHEX ; and Print it
PLA ;Restore Accumulator
; and fall into prhex
;Print Low Nybble as Hex Digit to Console
PRHEX: AND #$0F ;Strip High Nybble
CMP #$0A ;If Low Nybble >= 10
BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return

View File

@ -38,14 +38,6 @@ STKEHI EQU $4F
PUTCON EQU $F001 ;Write Character to Console PUTCON EQU $F001 ;Write Character to Console
GETCON EQU $F004 ;Read Character from Console GETCON EQU $F004 ;Read Character from Console
;Interrupt Vectors
NMILO EQU $FFFA ;Non-Maskable Interrupt
NMIHI EQU $FFFB
RSTLO EQU $FFFC ;Reset
RSTHI EQU $FFFD
IRQLO EQU $FFFE ;Maskable Interrupt
IRQHI EQU $FFFF
ORG $0200 ;START Directly Above Stack ORG $0200 ;START Directly Above Stack
START: JMP MAIN ;Execute Program START: JMP MAIN ;Execute Program
@ -53,19 +45,20 @@ START: JMP MAIN ;Execute Program
;Poll Character from Keyboard ;Poll Character from Keyboard
POLKEY: INC RDSEED ;Cycle the RANDOM Seed (if not provided by system) POLKEY: INC RDSEED ;Cycle the RANDOM Seed (if not provided by system)
LDA GETCON ;Read Character from Console LDA GETCON ;Read Character from Console
CMP #$E0 RTS
BEQ POLKEX ;If Not E0 Extended Key
ORA #$00 ; Set Status Flags
RTS ; and Return
POLKEX: LDA GETCON ;Else Get Second Byte
ORA #$80 ; Set High Byte
RTS ; and Return
;Read Character from Console ;Read Character from Console
GETKEY ;Same As RDKEY GETKEY JSR POLKEY ;Get Raw Key Character
CMP #$E0
BEQ GETKEX ;If Not E0 Extended Key
ORA #$00 ; Set Status Flags
RTS ; and Return
GETKEX: JSR POLKEY ;Else Get Second Byte
ORA #$80 ; Set High Bit
RTS ; and Return
;Wait for Character from Console ;Wait for Character from Console
GETCHR: JSR POLKEY ;Read Character from Console GETCHR: JSR GETKEY ;Read Character from Console
BEQ GETCHR ; Loop if None Received BEQ GETCHR ; Loop if None Received
RTS RTS
@ -89,36 +82,4 @@ PUTCHR STA PUTCON ;Write Character to Console
EXIT: BRK ;Return to Monitor EXIT: BRK ;Return to Monitor
;Print Byte as Two-Digit Hex Number to Console INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
PRBYTE: PHA ;Save Accumulater
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR PRHEX ; and Print it
PLA ;Restore Accumulator
; and fall into PRHEX
;Print Low Nybble as Hex Digit to Console
PRHEX: AND #$0F ;Strip High Nybb
SED ;Set Decimal Flag for
CLC ; Addition Wizardry
ADC #$90 ;Convert to $90-$99,$00-$05
ADC #$40 ;Convert to $30-$39,$41-$46
CLD ;Clear Decimal Flag
JMP PUTCHR ;Print Hex Digit and Return
;Set Non-Maskable Interrupt Handler
SETNMI: STY NMIHI
STX NMILO
RTS
;Set Reset Handler
SETRST: STY RSTHI
STX RSTLO
RTS
;Set Maskable Interrupt Handler
SETIRQ: STY IRQHI
STX IRQLO
RTS

View File

@ -16,17 +16,17 @@ START: JMP MAIN ;Execute Program
;Delete Previous Character ;Delete Previous Character
DELCHR: JSR DELCHB ;Print Backspace DELCHR: JSR DELCHB ;Print Backspace
LDA #$20 ;Load Space into Accumulater LDA #$20 ;Load Space into Accumulater
JSR PRCHR ; and Print it JSR PUTCHR ; and Print it
DELCHB: LDA #$08 ;Load Backspace into Accumulator DELCHB: LDA #$08 ;Load Backspace into Accumulator
BNE PRCHR ; and Print it BNE PUTCHR ; and Print it
;Advance Character to Next line ;Advance Character to Next line
NEWLIN: LDA #$0D ;Load C/R into Accumulator NEWLIN: LDA #$0D ;Load C/R into Accumulator
JSR PRCHR ; and Print it JSR PUTCHR ; and Print it
LDA #$0A ;Load L/F into Accumulater LDA #$0A ;Load L/F into Accumulater
; and fall into PRCHR ; and fall into PRCHR
;Print Character to Console ;Print Character to Console
PRCHR: STA PUTCON ;Write Character to Console PUTCHR STA PUTCON ;Write Character to Console
RTS RTS
;Poll Keyboard for Keypress ;Poll Keyboard for Keypress
@ -34,8 +34,8 @@ PLKEY: LDA GETCON ;Read Character from Console
RTS RTS
;Wait for Character from Console ;Wait for Character from Console
RDKEY: JSR PLKEY ;Read Character from Console GETCHR: JSR POLKEY ;Read Character from Console
BEQ RDKEY ; Loop if None Received BEQ GETCHR ; Loop if None Received
RTS RTS
EXIT: BRK ;Return to Monitor EXIT: BRK ;Return to Monitor

View File

@ -11,8 +11,8 @@ char getc; //Read Character from Console
//System Subroutines //System Subroutines
void newlin(); //Advance cursor to beginning of next line void newlin(); //Advance cursor to beginning of next line
void delchr(); //Delete previous character void delchr(); //Delete previous character
char plkey(); //Poll Console for character char polkey(); //Poll Console for character
char rdkey(); //Wait for character from Console char getchr(); //Wait for character from Console
char getkey(); //Read ASCII character from Console char getkey(); //Read ASCII character from Console
void prchr(); //Print ASCII character to Console char putchr(); //Print ASCII character to Console

View File

@ -55,26 +55,26 @@ PLKEYX: RTS
GETKEY ;Same As RDKEY GETKEY ;Same As RDKEY
;Wait for Character from Console ;Wait for Character from Console
RDKEY: JSR PLKEY ;Read Character from Console GETCHR: JSR POLKEY ;Read Character from Console
BEQ RDKEY ; Loop if None Received BEQ GETCHR ; Loop if None Received
RTS RTS
;Delete Previous Character ;Delete Previous Character
DELCHR: LDA #$08 ;Load Backspace into Accumulator DELCHR: LDA #$08 ;Load Backspace into Accumulator
JSR PRCHR ; and Print it JSR PUTCHR ; and Print it
LDA #$20 ;Load Space into Accumulater LDA #$20 ;Load Space into Accumulater
JSR PRCHR ; and Print it JSR PUTCHR ; and Print it
LDA #$08 ;Load Backspace into Accumulator LDA #$08 ;Load Backspace into Accumulator
JMP PRCHR ; and Print it JMP PUTCHR ; and Print it
;Advance Character to Next line ;Advance Character to Next line
NEWLIN: LDA #$0D ;Load C/R into Accumulator NEWLIN: LDA #$0D ;Load C/R into Accumulator
JSR PRCHR ; and Print it JSR PUTCHR ; and Print it
LDA #$0A ;Load L/F into Accumulater LDA #$0A ;Load L/F into Accumulater
; and fall into PRCHR ; and fall into PRCHR
;Print Character to Console ;Print Character to Console
PRCHR: STA PUTCON ;Write Character to Console PUTCHR STA PUTCON ;Write Character to Console
RTS RTS
EXIT: BRK ;Return to Monitor EXIT: BRK ;Return to Monitor
@ -96,4 +96,4 @@ PRHEX: AND #$0F ;Strip High Nybb
ADC #$90 ;Convert to $90-$99,$00-$05 ADC #$90 ;Convert to $90-$99,$00-$05
ADC #$40 ;Convert to $30-$39,$41-$46 ADC #$40 ;Convert to $30-$39,$41-$46
CLD ;Clear Decimal Flag CLD ;Clear Decimal Flag
JMP PRCHR ;Print Hex Digit and Return JMP PUTCHR ;Print Hex Digit and Return

View File

@ -0,0 +1,27 @@
;Keyboard Assembly Language Equates for Oric-1
;ASCII Keyboard Codes
KEYBCK EQU $00 Backspace
KEYBRK EQU $03 Break
KEYCLR EQU $0C Clear
KEYCPY EQU $0C Copy (Acorn Atom)
KEYDEL EQU $7F Delete
KEYDN EQU $0A Cursor Down
KEYESC EQU $1B Escape
KEYFN1 EQU $00 Function Key 1
KEYFN2 EQU $00 Function Key 2
KEYFN3 EQU $00 Function Key 3
KEYFN4 EQU $00 Function Key 4
KEYFN5 EQU $00 Function Key 5
KEYFN6 EQU $00 Function Key 6
KEYFN7 EQU $00 Function Key 7
KEYFN8 EQU $00 Function Key 8
KEYFN9 EQU $00 Function Key 9
KEYFNA EQU $00 Function Key 10
KEYHOM EQU $00 Home
KEYINS EQU $00 Insert
KEYLFT EQU $08 Cursor Left
KEYRGT EQU $09 Cursor Right
KEYRTN EQU $0D Return
KEYTAB EQU $09 Tab
KEYUP EQU $0B Cursor Up

View File

@ -95,20 +95,4 @@ NEWLIN: LDX #0 ;Store 0
STX $D3 ;in Cursor Column and STX $D3 ;in Cursor Column and
JMP $E8C3 ;Execute NXTLINE Routine JMP $E8C3 ;Execute NXTLINE Routine
;Print Byte as Two-Digit Hex Number to Console INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
PRBYTE: PHA ;Save Accumulater
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR PRHEX ; and Print it
PLA ;Restore Accumulator
; and fall into prhex
;Print Low Nybble as Hex Digit to Console
PRHEX: AND #$0F ;Strip High Nybble
CMP #$0A ;If Low Nybble >= 10
BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return

124
include/vic/color.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/color.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();