1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2026-04-21 01:16:46 +00:00

Separated cursor movement code into 'screen' module

This commit is contained in:
Curtis F Kaylor
2018-09-16 20:30:25 -04:00
parent 35377b5807
commit 3f9b4484c1
23 changed files with 579 additions and 687 deletions
+32 -98
View File
@@ -1,113 +1,47 @@
Screen Control Functions for C02
This is a prototype definition for a library providing functions
to manipulate the screen and move the cursor. Since this code is
highly system dependent, a separate library will need to be
created for each system type.
This module contains functions for screen and cursor manipulation.
The accompanying assembly code vary by platform, 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 <screen.h02>
The following functions should be defined:
clrscn(); Clears the screen and returns the cursor to the
home position.
Note: May call a system routine, or may print
"clear screen" character sequence.
crsrhm(); Moves cursor to home position (upper left corner
of the screen).
clrscn(); Clears the screen and returns the cursor to the home
position.
Note: May call mvcrsr(0,0); or may print "cursor
home" character sequence.
crsrlf(); Moves cursor one column to the left. May or may not
screen wrap, depending on system.
Returns with no action if the platform does not
support the clear screen action.
Note: May call mvcrsr; or may print "cursor left"
character sequence.
crsrhm(); Moves cursor to home position (upper left corner
of the screen).
crsrrt(); Moves cursor one column to the right. May or may not
screen wrap, depending on system.
Note: May call mvcrsr; or may print "cursor right"
character sequence.
Returns with no action if the platform does not
support cursor positioning.
crsrup(); Moves cursor one row up.
Note: May call mvcrsr; or may print "cursor up"
character sequence.
setpos(c,r); Moves cursor to column c on row r. The topmost row
and leftmost column are numbered 0.
crsrdn(); Moves cursor one row down.
Note: May call mvcrsr; or may print "cursor down"
character sequence.
Returns with no action if the platform does not
support cursor positioning.
mvcrsr(r, c); Moves cursor to row r, column c.
c,r = getpos(); Returns the current row and column of the cursor. The
topmost row and leftmost column are numbered 0.
Note: May call system routine, or set system variables.
h = scnhgt(); Returns screen height in rows.
Note: May call system routine, or read system variable.
w = scnwid(); Returns screen width in columns.
Note: May call system routine, or read system variable.
c = scncol(); Returns current screen column.
Note: May call system routine, or read system variable.
r = scnrow(); Returns current screen row.
Note: May call system routine, or read system variable.
txtclr(c); Sets text color to system color c.
Note: May call system routine or may print color change
sequence.
Note: Returns 255 for both the width and height if
the platform does not support cursor positioning.
bkgclr(c); Sets background color to system color c.
Note: May call system routine or may print color change
sequence.
Assembly Constants (Defined in System Header file)
BLACK Code for color Black
BLUE Code for color Blue
GREEN Code for color Green
CYAN Code for color Cyan
RED Code for color Red
MAGNTA Code for color Magenta
YELLOW Code for color Yellow
WHITE Code for color White
BREAK ASCII code for Break/Stop Key
BCKSPC ASCII code for Backspace key
CLEAR ASCII code for Clear Key
DELETE ASCII code for Delete key
DOWN ASCII code for Cursor Down Key
ENTER ASCII code for Return/Enter key (usually CR)
ESCAPE ASCII code for Escape/Abort key (usually ESC)
FNx ASCII code for Function Key x
HOME ASCII code for Home Key
INSERT ASCII code for Insert Key
LEFT ASCII code for Cursor Left Key
RIGHT ASCII code for Cursor Left Key
TAB ASCII code for Tab Key
UP ASCII code for Cursor Up Key
BTMLFT ASCII code for Box Drawing Bottom Left Corner
BTMRGT ASCII code for Box Drawing Bottom Right Corner
BTMTEE ASCII code for Box Drawing Bottom to Cetter Tee
CTRCRS ASCII code for Box Drawing Center Cross
HRZLIN ASCII code for Box Drawing Horizontal Line
LFTTEE ASCII code for Box Drawing Left To Center T
RGHTEE ASCII code for Box Drawing Right To Center T
TOPLFT ASCII code for Box Drawing Top Left Corner
TOPRGT ASCII code for Box Drawing Top Right Corner
TOPTEE ASCII code for Box Drawing Top to Center T
VRTLIN ASCII code for Box Drawing Verical Line
w,h = getsiz (); Returns the current screen or window width and height
in rows and columns.
Note: Returns 255 for both the width and height if
the platform does not support any sort of screen display.
Returns 0 for width or height if either or both are
variable and the current value cannot be determined via
software.
-14
View File
@@ -93,17 +93,3 @@ DELCHR: LDA #DELKEY ;Load Underscore Character
;Advance Character to Next line
NEWLIN: LDA #$0D ;Load C/R into Accumulator
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
-3
View File
@@ -42,10 +42,7 @@ void prhex(); //Print Low Nybble of Accumulator as Hex Digit
//System Subroutines
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
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
+17
View File
@@ -0,0 +1,17 @@
;Screen Control Assembly Lanuage Routines for Apple 1
;Clear the Screen
CLRSCR: RTS ;Do Nothing (Drop to RTS)
;Move Cursor to Specified Coordinates
SETPOS EQU CLRSCR ;No Action
;Get Cursor Position
GETPOS: LDA #$FF ;Return Error
TAY
RTS
;Get Screen Size
GETSIZ: LDA #40 ;40 Columns
LDY #24 ;24 Lines
RTS
+24
View File
@@ -0,0 +1,24 @@
/********************************************
* screen - Screen Control Routines for C02 *
********************************************/
/* Clear the Screen */
void clrscn();
/* Move Cursor to Top Left of Screen */
void crsrhm();
/* Get Current Cursor Position *
* Returns: cursor column *
* cursor row */
char getpos();
/* Get Screen Size *
* Returns: width in columns *
* height in rows */
char getsiz();
/* Move Cursor to Specified Position *
* Args: column - screen column (0 = left) *
* row - screen line (0 = top) */
void setpos();
-18
View File
@@ -76,21 +76,3 @@ 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
+24
View File
@@ -0,0 +1,24 @@
;Screen Control Assembly Lanuage Routines for Apple II
;Clear the Screen
CLRSCR: EQU $FC58 ;Applesoft Routine HOME
;Move Cursor To Home Position
CRSRHM LDA #0 ;Set Column to 0
TAY ;Set Row to 0
;and Fall into SETPOS
;Move Cursor to Specified Coordinates
SETPOS: STA $24 ;Store Column in CH
TYA ;Transfer Row to Accumulator
JMP $FB5B ;Exectute 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
+24
View File
@@ -0,0 +1,24 @@
/********************************************
* screen - Screen Control Routines for C02 *
********************************************/
/* Clear the Screen */
void clrscn();
/* Move Cursor to Top Left of Screen */
void crsrhm();
/* Get Current Cursor Position *
* Returns: cursor column *
* cursor row */
char getpos();
/* Get Screen Size *
* Returns: width in columns *
* height in rows */
char getsiz();
/* Move Cursor to Specified Position *
* Args: column - screen column (0 = left) *
* row - screen line (0 = top) */
void setpos();
+103
View File
@@ -0,0 +1,103 @@
;Screen Control Assembly Language Routines for Oric-1
; 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 (|)
;Set Background Color
;Args: A = Atari 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
+73 -257
View File
@@ -1,293 +1,109 @@
; c02 Program Initialization Code for Unexpanded VIC-20
;System Specific ASCII Key Mappings
DELKEY EQU $7F ;Delete/Backspace Key (Delete)
;PETSCII Key Mappings
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
;Zero Page Locations
; EQU $00 ;USR JMP
adray1 EQU $03 ;Vector: Convert Floating Point to Signed Integer
adray2 EQU $05 ;Vector: Convert Integet to Floating Point
charac EQU $07 ;Search Character for Scanning BASIC Text Input
endchr EQU $08 ;Search Character for Statement Terminator or Quote
trmpos EQU $09 ;Column Position of Cursor before Last SPC or TAB
verckb EQU $0A ;Flag: Load or Verify (BASIC)
count EQU $0B ;Index into Text Input Buffer/Number of Array Subscripts
dimflg EQU $0C ;Flags for Routines that Locate or Build an Array
valtyp EQU $0D ;Type of Data (String or Numeric)
intflg EQU $0E ;Type of Numeric Data (Integer or Floating Point)
garbfl EQU $0F ;Flag for LIST, Garbage Collection, and Program Terminators
subflg EQU $10 ;Subscript Reference to Array or User Defined Function Call
inpflg EQU $11 ;Is Data Input to GET, READ, or INPUT?
tansgn EQU $12 ;Sign of Result of TAN or SIN Function
channl EQU $13 ;Current I/O Channel (CMD Logical File) Number
linnum EQU $14 ;Integer Line Number Value
temppt EQU $16 ;Pointer to Next Availabale Space in Temporary String Stack
lastpt EQU $17 ;Pointer to Address of Last String in Temporary String Stack
tempst EQU $19 ;Descriptor Stack for Temporary Strings
index EQU $22 ;Miscellaneous Temporary Pointers and Save Area
; $24
resho EQU $26 ;Floating Point Multiplication Work Area
txttab EQU $2B ;Pointer to Start of BASIC Program Text
vartab EQU $2D ;Pointer to Start of BASIC Variable Storage Area
arytab EQU $2F ;Pointer to Start of BASIC Array Storage Area
strend EQU $31 ;Pointer to Start of Free RAM
fretop EQU $33 ;Pointer to Bottom of String Text Storage Area
frespc EQU $35 ;Temporary Pointer for Strings
memsiz EQU $37 ;Pointer to Highest Address Used by BASIC
curlin EQU $39 ;Current BASIC Line Number
oldlin EQU $3B ;Previous BASIC Line Number
oldtxt EQU $3D ;Pointer to Address of Current BASIC Statement
datlin EQU $3F ;Current DATA Line Number
datptr EQU $41 ;Pointer to Address of Current DATA Item
inpptr EQU $43 ;Pointer to Source of GET, READ, or INPUT Information
varnam EQU $45 ;Current Variable Name
varpnt EQU $47 ;Pointer to Current BASIC Variable Value
forpnt EQU $49 ;Temporary Pointer to Index Variable Used by FOR
opptr EQU $4B ;Math Operator Table Displacement
opmask EQU $4D ;Mask for Comparison Operator
defpnt EQU $4E ;Pointer to Current FN Descriptor
dscpnt EQU $50 ;Temporary Pointer to Current String Descriptor
; $52 ;current string length
four6 EQU $53 ;Constant for Garbage Collection
jmper EQU $54 ;Jump to Function Instruction
; $57 ;BASIC Numeric Work Area
fac1 EQU $61 ;Floating Point Accumulator #1
facexp EQU $61 ;Floating Point Accumulator #1: Exponent
facho EQU $62 ;Floating Point Accumulator #1: Mantissa
facsgn EQU $66 ;Floating Point Accumulator #1: Sign
sgnflg EQU $67 ;Number of Terms in Series Evaluation
bits EQU $68 ;Floating Point Accumulator #1: Overflow Digit
fac2 EQU $69 ;Floating Point Accumulator #2
argexp EQU $69 ;Floating Point Accumulator #2: Exponent
argho EQU $6E ;Floating Point Accumulator #2: Mantissa
argsgn EQU $6F ;Floating Point Accumulator #2: Sign
facov EQU $70 ;Low Order Mantissa Byte of Floating Point Accumulator #1
fbufpt EQU $71 ;Series Evaluation Pointer
chrget EQU $73 ;Subroutine: Get Next BASIC Text Character
chrgot EQU $79 ;Entry Point: Get Current BASIC Text Character
txtptr EQU $7A ;Pointer to Current BASIC Text Character
pointb EQU $7C ;Entry Point: Test Character in Accumulator
exit EQU $8A ;RTS at end of CHRGET, CHRGOT, and POINTB Routines
rndx EQU $8B ;RND Function Seed Value
status EQU $90 ;Kernal I/O Status Word
stkey EQU $91 ;Flag: Was STOP Key Pressed
svxt EQU $92 ;Timing Constant for Tape Reads
verck EQU $93 ;Flag: Load or Verify (Kernal)
c3po EQU $94 ;Flag: Serial Bus - Output Character was Buffered
bsour EQU $95 ;Buffered Character for Serial Bus
syno EQU $96 ;Cassette Block Synchronization Number
xsav EQU $97 ;Temporary .X Register Save Area
ldtnd EQU $98 ;Number of Open I/O Files, Index to End of File Tables
dfltn EQU $99 ;Default Input Device (Set to 0 for Keyboard)
dflto EQU $9A ;Default Output (CMD) Device (Set to 3 for Screen)
prty EQU $9B ;Tape Character Parity
dpsw EQU $9C ;Flag: Tape Byte Received
msflg EQU $9D ;Flag: Kernal Message Control
ptr1 EQU $9E ;Tape Pass 1 Error Log Index
ptr2 EQU $9F ;Tape Pass 2 Error Log Correction Index
time EQU $A0 ;Software Jiffy Clock
; EQU $A3 ;Temporary Data Storage Area
cntdn EQU $A5 ;Cassette Synchronization Character Countdown
bufpnt EQU $A6 ;Count of Characters in Tape I/O Buffer
inbit EQU $A7 ;RS-232 Input Bits/Tape I/O Miscellaneous Flag
bitci EQU $A8 ;RS-232 Input Bit Count/Tape Error Flag
rinone EQU $A9 ;RS-232 Flag: Check for Start Bit/Tape Character Type Flag
ridata EQU $AA ;RS-232 Input Byte Buffer
riprty EQU $AB ;RS-232 Input Parity/Cassette Leader Counter
sal EQU $AC ;Pointer to Starting Address of Load/Screen Scrolling
eal EQU $AE ;Pointer to Ending Address of Load (End of Program)
cmp0 EQU $B0 ;Used to Determine Value of SVXT
; EQU $B1 ;Used in Timing of Tape Reads
tape1 EQU $B2 ;Pointer: Start of Tape Buffer
bitts EQU $B4 ;RS-232 Output Bit Count/Tape Load Receive Flag
nxtbit EQU $B5 ;RS-232 Next Bit to Send/Tape EOT Flag
rodata EQU $B6 ;RS-232 Output Byte Buffer
fnlen EQU $B7 ;Length of Current Filename
la EQU $B8 ;Current Logical File Number
sa EQU $B9 ;Current Secondary Address
fa EQU $BA ;Current Device Number
fnadr EQU $BB ;Pointer: Current Filename
roprt EQU $BD ;RS-232 Output Parity/Tape Character Being Read or Sent
fsblk EQU $BE ;Cassette Read/Write Block Count
mych EQU $BF ;Tape Input Byte Buffer
cas1 EQU $C0 ;Tape Motor Interlock
stal EQU $C1 ;I/O Start Address
memuss EQU $C3 ;Tape Load Temporary Address
lste EQU $C5 ;Matrix Coordinate of Last Key Pressed
ndx EQU $C6 ;Number of Characters in Keyboard Buffer
rvs EQU $C7 ;Flag: Print Reverse Characters
indx EQU $C8 ;Pointer: End of Logical Line for Input
lxsp EQU $C9 ;Cursor X.Y Position at Start of Input
sfdx EQU $CB ;Matrix Coordinate of Current Key Pressed
blnsw EQU $CC ;Cursor Blink Enable
blnct EQU $CD ;Timer Countdown to Blink Cursor
gdbln EQU $CE ;Character Under Cursor
blnon EQU $CF ;Flag: Was Last Cursor Blink On or Off
crsw EQU $D0 ;Flag: Input from Keyboard or Screen
pnt EQU $D1 ;Pointer to Address of Current Screen Line
pntr EQU $D3 ;Cursor Column on Current Line
qtsw EQU $D4 ;Flag: Editor in Quote Mode?
lnmx EQU $D5 ;Maximum Length of Physical Screen Line
tblx EQU $D6 ;Current Cursor Physical Line Number
; EQU $D7 ;Temporary Storage for ASCII Value of Last Character Printed
insrt EQU $D8 ;Insert Mode (Number of Inserts)
ldtb1 EQU $D9 ;Screen Line Link Table
user EQU $F3 ;Pointer to Address of Current Screen Color RAM Location
keytab EQU $F5 ;Vector: Keyboard Decode Table
ribuf EQU $F7 ;Pointer: RS-232 Input Buffer
robuf EQU $F8 ;Pointer: RS-232 Output Buffer
frekzp EQU $FB ;Four Free Bytes of Zero Page for User Programs
baszpt EQU $FF ;BASIC Temporary Data for Floating Point to ASCII Conversion
;Zero Page Variables
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
RDSEED EQU $A2 ;Random Seed [Software Jiffy Clock (Low Byte)]
TEMP0 EQU $FB ;Temporary Variable [Unused Byte]
TEMP1 EQU $FC ;Temporary Variable [Unused Byte]
TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
;Page 1 Locations
bad EQU $0100 ;Tape Input Error Log
; EQU $013F ;Microprocessor Stack
;System Variables
USER3 EQU $0313 ;Free Byte for User Programs
;Basic and Kernal Working Storage
buf EQU $0200 ;BASIC Line Editor Input Buffer
lat EQU $0259 ;Kernal Table of Active Logical File Numbers
fat EQU $0263 ;Kernal Table of Device Numbers for Each Logical File
sat EQU $026D ;Kernal Table of Secondary Addressed for Each Logical File
keyd EQU $0277 ;Keyboard Buffer (Queue)
memstr EQU $0281 ;Pointer: Operating System Start of Memory
memsiz EQU $0283 ;Pointer: Operating System End of Memory
timout EQU $0285 ;Flag: Kernal Variable for IEEE Timeout
color EQU $0286 ;Current Foreground Color Text
gdcol EQU $0287 ;Color of Character Under Cursor
hibase EQU $0288 ;Top Page of Screen Memory
xmax EQU $0289 ;Maximum Keyboard Buffer Size
rptflg EQU $028A ;Flag: Which Key Will Repeat?
kount EQU $028B ;Counter for Timing Delay Between Key Repeats
delay EQU $028C ;Counter for Timing Delay Until First Key Repeat Begins
shflag EQU $028D ;Flag: SHIFT/CTRL/Logo Keypress
lstshf EQU $028E ;Last Pattern SHIFT/CTRL/Logo Keypress
keylog EQU $028F ;Vector to Keyboard Table Setup Routine
mode EQU $0291 ;Flag: Change Character Sets with SHIFT/Logo Keypress
autodn EQU $0292 ;Flag: Screen Scroll Enabled
m51ctr EQU $0293 ;RS-232: Mock 6551 Control Register
m51cdr EQU $0294 ;RS-232: Mock 6551 Command Register
m51adj EQU $0295 ;RS-232: Non-Standard Bit Timing (Not Implemented)
rsstat EQU $0297 ;RS-232: Mock 6551 Status Register
bitnum EQU $0298 ;RS-232: Number of Bits Left to be Sent/Received
baudof EQU $0299 ;RS-232: Time Required to Send a Bit
ridbe EQU $029B ;RS-232: Index to End of Receive Buffer
ridbs EQU $029C ;RS-232: Index to Start of Receive Buffer
rodbs EQU $029D ;RS-232: Index to Start of Transmit Buffer
rodbe EQU $029E ;RS-232: Index to End of Transmit Buffer
irqtmp EQU $029F ;Save Area for IRQ Vector During Cassette I/O
enabl EQU $02A1 ;RS-232 Interrupts Enabled
; EQU $02A2 ;CIA #1 Control Register B Activity During Cassette I/O
; EQU $02A3 ;Save Area for CIA #1 Interrupt Control Register
; EQU $02A4 ;Save Area for CIA #1 Control Register A
; EQU $02A5 ;Temporary Index to Next Line for Screen Scrolling
; EQU $02A6 ;PAL/NTSC Flag
; EQU $02A7 ;Unused
; EQU $02C0 ;Sprite 11
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
BLKELO EQU $0336 ;Block Start MSB [Unused Byte]
BLKEHI EQU $0337 ;Block End MSB [Unused Byte]
BLKLEN EQU $0338 ;Block Length [Unused Byte]
;BASIC Indirect Vector Table
ierror EQU $0300 ;Vector to Print BASIC Error Message Routine
imain EQU $0302 ;Vector to Main BASIC Program Loop
icrnch EQU $0304 ;Vector to Crunch ASCII Keyword into Tokens
iqplop EQU $0306 ;Vector to List BASIC Token as ASCII Text
igone EQU $0308 ;Vector to Execute Next BASIC Token
ieval EQU $030A ;Vector to Evaluate Single-Term Arithmetic Expression
RANDOM EQU $0339 ;Random Number Storage [Unused Byte]
STKSAV EQU $033A ;Machine Stack Storage [Unused Byte]
USER11 EQU $033B ;Free Byte for User Programs
TBFFR EQU $033C ;Cassette I/O Buffer
;Register Storage Area
sareg EQU $030C ;Storage Area for .A Register (Accumulator)
sxreg EQU $030D ;Storage Area for .X Index Register
syreg EQU $030E ;Storage Area for .Y Index Register
spreg EQU $030F ;Storage Area for .P (Status) Register
STKSLO EQU $03FC ;Stack Start LSB [Unused Byte]
STKSHI EQU $03FD ;Stack Start MSB [Unused Byte]
STKELO EQU $03FE ;Stack End LSB [Unused Byte]
STKEHI EQU $03FF ;Stack End MSB [Unused Byte]
;Miscellaneous Vectors
usrpok EQU $0310 ;JMP Instruction for User Function
usradd EQU $0311 ;Address of USR Routine
; EQU $0313 ;Unused
cinv EQU $0314 ;Vector to IRQ Interrupt Routine
cbinv EQU $0316 ;Vector: BRK Instruction Interrupt
nminv EQU $0318 ;Vector: Non-Maskabke Interrupt
;Kernal Indirect Vectors
iopen EQU $031A ;Vector to Kernal OPEN Routine
iclose EQU $031C ;Vector to Kernal CLOSE Routine
ichkin EQU $031E ;Vector to Kernal CHKIN Routine
ickout EQU $0320 ;Vector to Kernal CKOUT Routine
iclrch EQU $0322 ;Vector to Kernal CLRCHN Routine
ibasin EQU $0324 ;Vector to Kernal CHRIN Routine
ibsout EQU $0326 ;Vector to Kernal CHROUT Routine
istop EQU $0328 ;Vector to Kernal STOP Routine
igetin EQU $032A ;Vector to Kernal GETIN Routine
iclall EQU $032C ;Vector to Kernal CLALL Routine
usrcmd EQU $032E ;Vector to User Defined Command (Unused)
iload EQU $0330 ;Vector to Kernal LOAD Routine
isave EQU $0332 ;Vector to Kernal SAVE Routine
; $0334 ;Unused
tbuffer EQU $033C ;Cassette I/O Buffer
; $03FC ;Unused
vicscn EQU $0400 ;Video Screen Memory Area
; $07F8 ;Sprite Shape Data Pointers
; $0800 ;BASIC Program Text
; $8000 ;Autostart ROM Cartridge
vicclr EQU $D800 ;Color RAM
;Video RAM and ROM
VICSCN EQU $0400 ;Video Screen Memory Area (Unexpanded)
CHRROM EQU $D000 ;Character Generator ROM
VICCLR EQU $D800 ;Color RAM (Unexpanded)
;Kernal Routines
chrin EQU $FFCF ;Input Character to Channel
chrout EQU $FFD2 ;Output Character to Channel
getin EQU $FFE4 ;Read Character from Keyboard Buffer
;Machine Language Basic Stub
ORG $1001 ;Start Directly Above Stack
basic: DC $0C, $10 ; Pointer to Next Line (4109)
DC $00, $00 ; Line Number (0)
DC $9E ; SYS
DC $20 ; ' '
DC $34, $31, $31 ,$30 ; "4110"
ORG $0801 ;Start of Basic Program
BASIC: DC $0C, $10 ;Pointer to Next Line (4109)
DC $00, $00 ;Line Number (0)
DC $9E ;SYS
DC $20 ;' '
DC $32, $30, $36 ,$32 ;"2062"
DC $00 ;End of Line Marker
DC $00, $00 ;End of Basic Program
JMP main ;Execute Program
START: TSX ;Get Stack Pointer
STX STKSAV ;and Save for Exit
JMP MAIN ;Execute Program
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
TXS ;and Restore It
RTS ;Return to BASIC
;Poll Keyboard for Character
plkey EQU getin ;Read Character from Keyboard Buffer
POLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
;Read Character from Console
;Get Character from Keyboard
GETKEY EQU POLKEY ;Get Key From Keybord
;Wait for Character from Console
getkey: JSR plkey ;Poll Keyboard
BEQ getkey ;If No Key, Loop
;Wait for Character from Keyboard
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 $E716 ;Aliased to SRCNOUT Routine
;Delete Previous Character
delchr: RTS
DELCHR: LDA #DELKEY ;Load Delete Character
JMP PUTCHR ;Print and Return
;Advance Character to Next line
newlin: LDA #$0D ;Load C/R into Accumulator
;Print Character to Console
prchr EQU chrout ;
NEWLIN: LDX #0 ;Store 0
STX $D3 ;in Cursor Column and
JMP $E87C ;Execute NXTLINE Routine
;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
LSR
LSR
JSR prhex ; and Print it
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
PRHEX: AND #$0F ;Strip High Nybble
CMP #$0A ;If Low Nybble >= 10
BCC prhexc ;
BCC PRHEXC ;
ADC #$06 ; Convert ':' to 'A'...
prhexc: ADC #$30 ;Convert to ASCII Character
JMP prchr ;Print Hex Digit and Return
exit: RTS ;Return to Monitor
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return
+34
View File
@@ -0,0 +1,34 @@
/* Platform Specific Header file for Commodore 64 */
/* Platform Specific Constants */
#define DELKEY $14 //Delete/Backspace Key (DEL)
#define ESCKEY $03 //Escape/Break Key (STOP)
#define RTNKEY $0D //Return/Enter Key (RETURN)
/* 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
/* 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 Storage
/* System Subroutines */
void delchr(); //Delete previous character
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
+22
View File
@@ -0,0 +1,22 @@
;Screen Control Assembly Lanuage Routines for VIC-20
;Clear the Screen
CLRSCR EQU $E544 ;Aliased to CLSR Routine
;Move Cursor To Home Position
CRSRHM EQU $E566 ;Aliased to HOME Routine
;Move Cursor to Specified Coordinates
SETPOS: STA $D3 ;Save Cursor Column
STY $D6 ;Save Cursor Row
JMP $E56C ;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
+24
View File
@@ -0,0 +1,24 @@
/*****************************************************
* Screen Control Functions and Constants for VIC-20 *
*****************************************************/
/* Clear the Screen */
void clrscn();
/* Move Cursor to Top Left of Screen */
void crsrhm();
/* Get Current Cursor Position *
* Returns: cursor column *
( cursor row */
char getpos();
/* Get Screen Size *
* Returns: width in columns *
* height in rows */
char getsiz();
/* Move Cursor to Specified Position *
* Args: column - screen column (0 = left) *
* row - screen line (0 = top) */
void setpos();
+41
View File
@@ -0,0 +1,41 @@
;Screen Control Assembly Lanuage Routines for Oric-1
;Clear the Screen
CLRSCR EQU $CC0A ;Basic CLS Routine (Atmos = $CCCE)
;Move Cursor to Home Position
CRSRHM: LDA #0 ;Set Args to 0,0
TAY ;and Fall into SETPOS
;Set Cursor Position
SETPOS: CLC
ADC #2 ;Add 2 to Column
PHA ;and Save It
INY ;Add 1 to Row
TYA ;and Save It
PHA
LDA #0 ;Turn Cursor Off
JSR $F7CB
PLA ;Retrieve Row
STA $0268 ;and Store in CURROW
PLA ;Retrieve Column
STA $0269 ;and Store in CURCOL
JSR $F67D ;Recalculate Screen Pointers
LDA #0 ;Turn Cursor On
JMP $F7CB ;and Return
;Get Cursor Position
GETPOS: LDA $0269 ;Load Column from CURCOL
SEC
SBC #2 ;Subtract 2
BPL GETPOY ;If Negative
LDA #0 ;set to 0
GETPOY: LDY $0268 ;Load Row from CURROW
DEY ;and Subtract 1
RTS
;Get Screen Size
GETSIZ: LDA #38 ;38 Columns (First 2 are Protected)
LDY #27 ;27 Rows
RTS
+24
View File
@@ -0,0 +1,24 @@
/***************************************
* Screen Control Functions for Oric-1 *
***************************************/
/* Clear the Screen */
void clrscn();
/* Move Cursor to Top Left of Screen */
void crsrhm();
/* Get Current Cursor Position *
* Returns: cursor column *
( cursor row */
char getpos();
/* Get Screen Size *
* Returns: width in columns *
* height in rows */
char getsiz();
/* Move Cursor to Specified Position *
* Args: column - screen column (0 = left) *
* row - screen line (0 = top) */
void setpos();
+37 -14
View File
@@ -1,4 +1,4 @@
; py65mon program initialization code for c02 programs
;py65mon program initialization code for c02 programs
;System Specific ASCII Key Mappings
DELKEY EQU $08 ;Delete/Backspace Key (Backspace)
@@ -35,21 +35,29 @@ STKELO EQU $4E ;Stack End Address
STKEHI EQU $4F
;Memory Mapped I/O
PUTCON EQU $F001 ;Write Character to Console
GETCON EQU $F004 ;Read Character from Console
PUTCON EQU $F001 ;Write Character to 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
START: JMP MAIN ;Execute Program
;Poll Character from Keyboard
PLKEY: 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
CMP #$E0
BEQ PLKEYX ;If Not E0 Extended Key
BEQ POLKEX ;If Not E0 Extended Key
ORA #$00 ; Set Status Flags
RTS ; and Return
PLKEYX: LDA GETCON ;Else Get Second Byte
POLKEX: LDA GETCON ;Else Get Second Byte
ORA #$80 ; Set High Byte
RTS ; and Return
@@ -57,26 +65,26 @@ PLKEYX: LDA GETCON ;Else Get Second Byte
GETKEY ;Same As RDKEY
;Wait for Character from Console
RDKEY: JSR PLKEY ;Read Character from Console
BEQ RDKEY ; Loop if None Received
GETCHR: JSR POLKEY ;Read Character from Console
BEQ GETCHR ; Loop if None Received
RTS
;Delete Previous Character
DELCHR: LDA #$08 ;Load Backspace into Accumulator
JSR PRCHR ; and Print it
JSR PUTCHR ; and Print it
LDA #$20 ;Load Space into Accumulater
JSR PRCHR ; and Print it
JSR PUTCHR ; and Print it
LDA #$08 ;Load Backspace into Accumulator
JMP PRCHR ; and Print it
JMP PUTCHR ; and Print it
;Advance Character to Next line
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
; and fall into PRCHR
;Print Character to Console
PRCHR: STA PUTCON ;Write Character to Console
PUTCHR STA PUTCON ;Write Character to Console
RTS
EXIT: BRK ;Return to Monitor
@@ -98,4 +106,19 @@ PRHEX: AND #$0F ;Strip High Nybb
ADC #$90 ;Convert to $90-$99,$00-$05
ADC #$40 ;Convert to $30-$39,$41-$46
CLD ;Clear Decimal Flag
JMP PRCHR ;Print Hex Digit and Return
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
+3 -3
View File
@@ -25,11 +25,11 @@ char putcon; //Write Character to Console
char getcomn; //Read Character from Console
//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
+19
View File
@@ -0,0 +1,19 @@
;Screen Control Assembly Lanuage Routines for C02
;Skeleton Code for Systems with no Screen Control
;Clear the Screen
CLRSCR: RTS ;No Action
;Move Cursor Home
CRSRHM EQU CLRSCR ;No Action
;Move Cursor to Specified Coordinates
SETPOS EQU CLRSCR ;No Action
;Get Cursor Position
GETPOS: LDA #$FF ;Return Error
TAY
RTS
;Get Screen Size
GETSIZ EQU GETPOS ;Return Error
+12 -43
View File
@@ -2,54 +2,23 @@
* screen - Screen Control Routines for C02 *
********************************************/
/* Set Background Color *
* Args: color - background color code */
void bkgclr();
/* Clear the Screen */
/* Clear the Screen */
void clrscn();
/* Move Cursor Down */
void crsrdn();
/* Move Cursor to Top Left of Screen */
/* Move Cursor to Top Left of Screen */
void crsrhm();
/* Move Cursor Left */
void crsrlf();
/* Get Current Cursor Position *
* Returns: cursor column *
* cursor row */
char getpos();
/* Move Cursor Right */
void crsrrt();
/* Get Screen Size *
* Returns: width in columns *
* height in rows */
char getsiz();
/* Move Cursor Up */
void crsrup();
/* Get Character at Current Position *
* Returns: ASCII code of character */
char curchr();
/* Move Cursor to Specified Coordinates *
/* Move Cursor to Specified Position *
* Args: column - screen column (0 = left) *
* row - screen line (0 = top) */
void mvcrsr();
/* Get Cursor Horizontal Position *
* Returns: current cursor column */
char scncol();
/* Get Screen Height in Columns *
* Returns: screen height */
char scnhgt();
/* Get Cursor Vertical Position *
* Returns: current cursor row */
char scnrow();
/* Get Screen Width in Columns *
* Returns: screen width */
char scnwid();
/* Set Text Color *
* Args: color - text color code */
void txtclr();
void setpos();
+40 -50
View File
@@ -14,29 +14,33 @@ BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
RDSEED EQU $2A ;Random Seed [Software Jiffy Clock (Low Byte)]
RDSEED EQU $A2 ;Random Seed [Software Jiffy Clock (Low Byte)]
TEMP0 EQU $FB ;Temporary Variable [Unused Byte]
TEMP1 EQU $FC ;Temporary Variable [Unused Byte]
TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
;System Variables
USER0 EQU $0310 ;Free Byte for User Programs
RANDOM EQU $0311 ;Random Number Storage [Unused Byte]
STKSAV EQU $0312 ;Machine Stack Storage [Unused Byte]
STKSLO EQU $0313 ;Stack Start LSB [Unused Byte]
STKSHI EQU $0334 ;Stack Start MSB [Unused Byte]
STKELO EQU $0335 ;Stack End LSB [Unused Byte]
STKEHI EQU $0336 ;Stack End MSB [Unused Byte]
BLKSLO EQU $0337 ;Block Start LSB [Unused Byte]
BLKSHI EQU $0338 ;Block Start MSB [Unused Byte]
BLKELO EQU $0339 ;Block Start MSB [Unused Byte]
BLKEHI EQU $033A ;Block End MSB [Unused Byte]
BLKLEN EQU $033B ;Block Length [Unused Byte]
USER1 EQU $0311 ;Free Byte for User Programs
USER2 EQU $0312 ;Free Byte for User Programs
USER3 EQU $0313 ;Free Byte for User Programs
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
BLKELO EQU $0336 ;Block Start MSB [Unused Byte]
BLKEHI EQU $0337 ;Block End MSB [Unused Byte]
BLKLEN EQU $0338 ;Block Length [Unused Byte]
RANDOM EQU $0339 ;Random Number Storage [Unused Byte]
STKSAV EQU $033A ;Machine Stack Storage [Unused Byte]
USER11 EQU $033B ;Free Byte for User Programs
TBFFR EQU $033C ;Cassette I/O Buffer
USER12 EQU $03FC ;Free Byte for User Programs
USER13 EQU $03FD ;Free Byte for User Programs
USER14 EQU $03FE ;Free Byte for User Programs
USER15 EQU $03FF ;Free Byte for User Programs
STKSLO EQU $03FC ;Stack Start LSB [Unused Byte]
STKSHI EQU $03FD ;Stack Start MSB [Unused Byte]
STKELO EQU $03FE ;Stack End LSB [Unused Byte]
STKEHI EQU $03FF ;Stack End MSB [Unused Byte]
START: TSX ;Get Stack Pointer
STX STKSAV ;and Save for Exit
@@ -50,19 +54,22 @@ EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
POLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
;Get Character from Keyboard
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
GETKEY EQU POLKEY ;Get Key From Keybord
;Get Character from Keyboard
;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
@@ -77,33 +84,16 @@ GETCHR: JSR GETKEY ;Poll Keyboard
;Print Character to Console
;uses direct call to SCRNOUT instead of CHROUT
PUTCHR EQU $E742 ;Aliased to SRCNOUT Routine
PUTCHR EQU $E742 ;Aliased to SRCNOUT Routine
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Delete Character
JMP PUTCHR ;Print and Return
;Advance Character to Next line
NEWLIN: LDA #RTNKEY ;Load C/R into Accumulator
JMP PUTCHR ;Print and Return
;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
NEWLIN: LDX #0 ;Store 0
STX $D3 ;in Cursor Column and
JMP $E8C3 ;Execute NXTLINE Routine
;Print Byte as Two-Digit Hex Number to Console
PRBYTE: PHA ;Save Accumulater
+10 -112
View File
@@ -1,124 +1,22 @@
;Screen Control Assembly Lanuage Routines for C02
;Screen Control Assembly Lanuage Routines for VIC-20
;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
;Clear the Screen
CLRSCR EQU $E55F ;Aliased to CLSR Routine
;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
CRSRHM EQU $E581 ;Aliased to HOME Routine
;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
SETPOS: STA $D3 ;Save Cursor Column
STY $D6 ;Save Cursor Row
JMP $E587 ;Set Screen Poiners 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
GETPOS: LDY $D6 ;Load Cursor Row
LDA $D3 ;Load Cursor Column
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
GETSIZ: JSR $FFED ;Call SCREEN Kernal Routine
TXA ;Transfer Width to Accumulator
RTS
+16 -75
View File
@@ -2,82 +2,23 @@
* Screen Control Functions and Constants for VIC-20 *
*****************************************************/
/* Display Colors */
enum {BLACK, WHITE, RED, CYAN, MAGENT, GREEN, BLUE, YELLOW};
/* Clear the Screen */
void clrscn();
/* PETSCII Color Code Table */
const char clrtbl = {144, 5, 28, 159, 156, 30, 32, 158};
/* Move Cursor to Top Left of Screen */
void crsrhm();
;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
/* Get Current Cursor Position *
* Returns: cursor column *
( cursor row */
char getpos();
/* Get Screen Size *
* Returns: width in columns *
* height in rows */
char getsiz();
/* 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();
/* Move Cursor to Specified Position *
* Args: column - screen column (0 = left) *
* row - screen line (0 = top) */
void setpos();