mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-25 06:31:25 +00:00
Added functions to module 'stdiox'
This commit is contained in:
parent
27b3636901
commit
ca3723e2a9
@ -2,16 +2,36 @@ Extended Input/Output Functions for C02 Programs
|
||||
|
||||
At the beginning of the program use the directives
|
||||
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <stdiox.h02>
|
||||
|
||||
The following functions are defined:
|
||||
|
||||
c = getprc(&s); Writes the string s, followed by a blank line,
|
||||
to the screen, then waits for a key to be pressed.
|
||||
|
||||
Returns the ASCII value of the key that was
|
||||
pressed.
|
||||
|
||||
Note: Calls the puts function, the newlin
|
||||
function twice, then the getc function.
|
||||
|
||||
c = getprc(&s); Writes the string "Press any key to continue...",
|
||||
followed by a blank line, to the screen, then waits
|
||||
for a key to be pressed.
|
||||
|
||||
Returns the ASCII value of the key that was
|
||||
pressed.
|
||||
|
||||
Note: Calls the getprc function, with a hard
|
||||
coded string.
|
||||
|
||||
putdec(b); Writes the decimal representation of byte b to the
|
||||
screen. The output will be between one and three
|
||||
digits with no leading spaces.
|
||||
|
||||
Note: Calls part of the ctoa() routine from stdlib
|
||||
Note: Calls part of the ctoa routine from stdlib
|
||||
which leaves the binary values of the ones, tens,
|
||||
and hundreds digits in variables temp0, temp1, and
|
||||
temp2, respectively.
|
||||
@ -21,7 +41,7 @@ The following functions are defined:
|
||||
with 1 space if b is between 10 and 99, or two spaces
|
||||
if b is less than 10.
|
||||
|
||||
Note: Calls putdec() and putspc(). Leaves the value
|
||||
Note: Calls putdec and putspc. Leaves the value
|
||||
of b in varible temp3.
|
||||
|
||||
putder(b); Writes the decimal representation of byte b to the
|
||||
@ -29,22 +49,22 @@ The following functions are defined:
|
||||
with 1 space if b is between 10 and 99, or two spaces
|
||||
if b is less than 10.
|
||||
|
||||
Note: Calls putdec() and putspc(). Leaves the value
|
||||
Note: Calls putdec and putspc. Leaves the value
|
||||
of b in varible temp3.
|
||||
|
||||
putdst(); Prints the destination string set by the setdst() or
|
||||
setstr() functions.
|
||||
putdst(); Prints the destination string set by the setdst or
|
||||
setstr functions.
|
||||
|
||||
This can be used to print the results of any function
|
||||
call that stores it's result in the destination string,
|
||||
such as strcat(), strcpy(), and strcut() in string,
|
||||
such as strcat, strcpy, and strcut in string,
|
||||
|
||||
Note: calls putc() and is called by printf() when
|
||||
Note: calls putc and is called by printf when
|
||||
processing a %S formatting tag.
|
||||
|
||||
putspc(b); Writes a space character to the screen.
|
||||
|
||||
Note: Used by the putdel() and putder() functions.
|
||||
Note: Used by the putdel and putder functions.
|
||||
|
||||
r = printf(b, &s): Writes the value of byte b to screen, formatting
|
||||
the output according the contents of string s.
|
||||
@ -61,16 +81,16 @@ The following functions are defined:
|
||||
%R - output b as a right justified decimal number
|
||||
%% - output a single % character
|
||||
|
||||
Unlike the printf() function in standard C, only
|
||||
Unlike the printf function in standard C, only
|
||||
one value argument may be passed and that value is
|
||||
used for each formatting tag in the format string.
|
||||
|
||||
One additional formatting tag is supported:
|
||||
%S - output the destination string
|
||||
|
||||
The destination string is set using the setdst() or
|
||||
strdst() functions (from the "string" library) before
|
||||
calling printf(). Multiple occurances of the %S tag
|
||||
The destination string is set using the setdst or
|
||||
strdst functions (from the "string" library) before
|
||||
calling printf. Multiple occurances of the %S tag
|
||||
will cause the destination string to be repeated.
|
||||
|
||||
When tag types are mixed, the %S tag will output the
|
||||
@ -82,8 +102,8 @@ The following functions are defined:
|
||||
lower case with either a 0 or 1 in the high bit.
|
||||
Unrecognized formatting tags are interpreted as %C.
|
||||
|
||||
Note: Calls putdec(), putdel(), putder(), prbyte(), or
|
||||
putdst() depending on which formatting tags are used.
|
||||
Note: Calls putdec, putdel, putder, prbyte, or
|
||||
putdst depending on which formatting tags are used.
|
||||
The value of b is left in variable temp3.
|
||||
|
||||
Note: This library expects the following functions to be defined:
|
||||
|
@ -4,7 +4,7 @@
|
||||
;External Variables
|
||||
;TEMP0, TEMP1, TEMP2
|
||||
|
||||
;Standard Constant Definitions
|
||||
;Constant Definitions
|
||||
TRUE EQU $FF ;Returned for Success or Failure
|
||||
FALSE EQU $00 ;by some Library Routines
|
||||
|
||||
|
@ -1,5 +1,17 @@
|
||||
; C02 library stdiox.h02 assembly language subroutines
|
||||
|
||||
ANYKEP: DC "Press any key to continue...",0
|
||||
|
||||
ANYKEY: JSR NEWLIN ;Start at Beginning of Next Line
|
||||
LDY #>ANYKEP ;Load Prompt High Byte
|
||||
LDX #<ANYKEP ;Load Prompt Low Byte
|
||||
;Drop into GETCPR
|
||||
|
||||
;Display Prompt and Wait for Character
|
||||
GETCPR: JSR PUTLN ;Print Prompt
|
||||
JSR NEWLIN ;Generate Blank Line
|
||||
JMP GETC ;Wait for and Return Keypress
|
||||
|
||||
;Print Byte as Left Justified Decimal Number
|
||||
;void putdel(b)
|
||||
;Args: A = number to print
|
||||
|
@ -2,6 +2,21 @@
|
||||
* stdiox - Extended I/O Routines for C02 *
|
||||
******************************************/
|
||||
|
||||
/* Display "Press any key to continue" *
|
||||
* prompt and wait fo keypress *
|
||||
* Returns: ASCII value of key pressed */
|
||||
void anykey();
|
||||
|
||||
/* Display prompt and wait for keypress *
|
||||
* Args: &s - string to display *
|
||||
* Returns: ASCII value of key pressed */
|
||||
void getcpr();
|
||||
|
||||
/* Print Formatted Byte to Screen *
|
||||
* Args: b - byte to format *
|
||||
* &s - formatting string */
|
||||
void printf();
|
||||
|
||||
/* Print Byte as Decimal Number *
|
||||
* Args: b - Number to print */
|
||||
void putdec();
|
||||
@ -20,7 +35,3 @@ void putdst();
|
||||
/* Print a Space Character */
|
||||
void putspc();
|
||||
|
||||
/* Print Formatted Byte to Screen *
|
||||
* Args: b - byte to format *
|
||||
* &s - formatting string */
|
||||
void printf();
|
||||
|
@ -199,7 +199,6 @@ UPBCD: LDA TEMP1 ;Get Low Byte
|
||||
STA TEMP1 ;Save in Tens
|
||||
RTS
|
||||
|
||||
|
||||
;ConVert number to packed Binary Coded Decimal
|
||||
;Args: A - Number to Convert
|
||||
;Destroys: TEMP0
|
||||
|
@ -3,6 +3,7 @@
|
||||
***********************************************/
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
@ -12,6 +13,8 @@ char s = "string";
|
||||
|
||||
main:
|
||||
|
||||
getcpr("Press any key to begin...");
|
||||
|
||||
i = 0;
|
||||
|
||||
putln("prtdec()");
|
||||
@ -55,10 +58,3 @@ newlin();
|
||||
|
||||
done:
|
||||
goto exit;
|
||||
|
||||
void anykey() {
|
||||
newlin();
|
||||
putln("Press any key...");
|
||||
c = getc();
|
||||
newlin();
|
||||
}
|
Loading…
Reference in New Issue
Block a user