1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-26 13:18:31 +00:00

This commit was generated by cvs2svn to compensate for changes in r2,

which included commits to RCS files with non-trunk default branches.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2000-05-28 13:40:48 +00:00
parent 579491e8a4
commit 53dd513176
847 changed files with 91345 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#
# makefile for CC65 runtime library
#
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
S_OBJS = break.o clrscr.o cclear.o cgetc.o chline.o color.o \
cputc.o crt0.o ctype.o \
cvline.o kbhit.o read.o revers.o where.o write.o
all: $(C_OBJS) $(S_OBJS)
clean:
@rm -f $(C_OBJS:.c=.s)
@rm -f $(C_OBJS)
@rm -f $(S_OBJS)
@rm -f crt0.o
+43
View File
@@ -0,0 +1,43 @@
; Break vector
BRKVec = $03F0
; Goto Dos
RESTOR = $03D0
; Top of available memory
; This is actually for DOS 3.3 need to change it for ProDos
TOPMEM = $9600
; Soft switches
;
; write to USEROM to enable apple rom C000-CFFF
USEROM = $C007
; 80 column card switches
C80ON = $C00C
C80OFF = $C00D
RD80COL = $C01F
PG2OFF = $C054
PG2ON = $C055
RDPAGE2 = $C01C
; Text routines
MIN_X = $20
MAX_X = $21
MIN_Y = $22
MAX_Y = $23
CH = $24
CV = $25
BASL = $28
TEXTTYP = $32
HOME = $FC58
VTABZ = $FC24
COUT = $FDED
; Keyboard entries
RDKEY = $FD0C
CLEAR_KEY_STROBE = $C010
KEY_STROBE = $C000
; Game controller
OPEN_APPLE = $C061
CLOSED_APPLE = $C062
+109
View File
@@ -0,0 +1,109 @@
;
; Ullrich von Bassewitz, 27.09.1998
;
; void set_brk (unsigned Addr);
; void reset_brk (void);
;
.export _set_brk, _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit
.include "apple2.inc"
_brk_a = $45
_brk_x = $46
_brk_y = $47
_brk_sr = $48
_brk_sp = $49
_brk_pc = $3A
.bss
oldvec: .res 2 ; Old vector
.data
uservec: jmp $FFFF ; Patched at runtime
.code
; Set the break vector
.proc _set_brk
sta uservec+1
stx uservec+2 ; Set the user vector
lda oldvec
ora oldvec+1 ; Did we save the vector already?
bne L1 ; Jump if we installed the handler already
lda BRKVec
sta oldvec
lda BRKVec+1
sta oldvec+1 ; Save the old vector
lda #<_reset_brk
ldx #>_reset_brk
jsr _atexit ; Install an exit handler
L1: lda #<brk_handler ; Set the break vector to our routine
sta BRKVec
lda #>brk_handler
sta BRKVec+1
rts
.endproc
; Reset the break vector
.proc _reset_brk
lda oldvec
sta BRKVec
lda oldvec+1
sta BRKVec+1
rts
.endproc
; Break handler, called if a break occurs
.proc brk_handler
sec
lda _brk_pc
sbc #$02 ; Point to start of brk
sta _brk_pc
lda _brk_pc+1
sbc #$00
sta _brk_pc+1
clc
lda _brk_sp
adc #$04 ; Adjust stack pointer
sta _brk_sp
lda _brk_sr ; Clear brk
and #$EF
sta _brk_sr
jsr uservec ; Call the user's routine
lda _brk_pc+1
pha
lda _brk_pc
pha
lda _brk_sr
pha
ldx _brk_x
ldy _brk_y
lda _brk_a
rti ; Jump back...
.endproc
+30
View File
@@ -0,0 +1,30 @@
;
; Ullrich von Bassewitz, 08.08.1998
;
; void cclearxy (unsigned char x, unsigned char y, unsigned char length);
; void cclear (unsigned char length);
;
.export _cclearxy, _cclear
.import popa, _gotoxy, cputdirect
.importzp tmp1
_cclearxy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cclear
_cclear:
cmp #0 ; Is the length zero?
beq L9 ; Jump if done
sta tmp1
L1: lda #$20 ; Blank - screen code
jsr cputdirect ; Direct output
dec tmp1
bne L1
L9: rts
+25
View File
@@ -0,0 +1,25 @@
;;
;; Kevin Ruland
;;
;; char cgetc (void);
;;
;; If open_apple key is pressed then the high-bit of the
;; key is set.
.export _cgetc
.include "apple2.inc"
_cgetc:
lda KEY_STROBE
bpl _cgetc ; if < 128, no key pressed
;; At this time, the high bit of the key pressed
;; is set
sta CLEAR_KEY_STROBE; clear keyboard strobe
bit OPEN_APPLE ; check if OpenApple is down
bmi pressed
and #$7F ; If not down, then clear high bit
pressed:
ldx #0
rts
+30
View File
@@ -0,0 +1,30 @@
;
; Ullrich von Bassewitz, 08.08.1998
;
; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
; void chline (unsigned char length);
;
.export _chlinexy, _chline
.import popa, _gotoxy, cputdirect
.importzp tmp1
_chlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
pla ; Restore the length
_chline:
cmp #0 ; Is the length zero?
beq L9 ; Jump if done
sta tmp1
L1: lda #$2D ; Horizontal line, screen code
jsr cputdirect ; Direct output
dec tmp1
bne L1
L9: rts
+10
View File
@@ -0,0 +1,10 @@
;;
;; Kevin Ruland
;;
;; void clrscr (void);
.export _clrscr
.include "apple2.inc"
_clrscr = HOME
+20
View File
@@ -0,0 +1,20 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ textcolor (unsigned char color);
; unsigned char __fastcall__ bgcolor (unsigned char color);
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _textcolor, _bgcolor, _bordercolor
.import return0, _revers
.include "apple2.inc"
_textcolor = _revers
_bgcolor = return0
_bordercolor = return0
+85
View File
@@ -0,0 +1,85 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
.export _cputcxy, _cputc
.export _gotoxy, cputdirect
.export newline, putchar
.import popa
.include "apple2.inc"
; Plot a character - also used as internal function
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy
pla ; Restore C
_cputc:
cmp #$0D ; Test for \r = carrage return
bne L1
lda #$00 ; Goto left edge of screen
sta CH
rts ; That's all we do
L1:
cmp #$0A ; Test for \n = line feed
beq newline
cputdirect:
jsr putchar
;; Bump to next column
inc CH
lda CH
cmp MAX_X
bne return
lda #$00
sta CH
return:
rts
putchar:
ora #$80 ; Turn on high bit
and TEXTTYP ; Apply normal, inverse, flash
ldy CH
ldx RD80COL ; In 80 column mode?
bpl col40 ; No, in 40 cols
pha
tya
lsr ; Div by 2
tay
pla
bcs col40 ; odd cols go in 40 col memory
sta PG2ON
col40: sta (BASL),Y
sta PG2OFF
rts
newline:
lda CH
pha
inc CV
lda CV
cmp MAX_Y
bne L2
lda #$00
sta CV
L2:
jsr VTABZ
pla
sta CH
rts
_gotoxy:
sta CV ; Store Y
jsr VTABZ
jsr popa ; Get X
sta CH ; Store X
rts
+112
View File
@@ -0,0 +1,112 @@
;
; Startup code for cc65 (Apple2 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.import __hinit
.import zerobss, push0, doatexit
.import _main
.include "apple2.inc"
; ------------------------------------------------------------------------
; Define and export the ZP variables for the C64 runtime
.exportzp sp, sreg, regsave
.exportzp ptr1, ptr2, ptr3, ptr4
.exportzp tmp1, tmp2, tmp3, tmp4
.exportzp regbank, zpspace
; These zero page entries overlap with the sweet-16 registers.
; must be changed if sweet-16 is to be supported
sp = $00 ; stack pointer
sreg = $02 ; secondary register/high 16 bit for longs
regsave = $04 ; slot to save/restore (E)AX into
ptr1 = $08 ;
ptr2 = $0A
ptr3 = $0C
ptr4 = $0E
tmp1 = $10
tmp2 = $11
tmp3 = $12
tmp4 = $13
regbank = $14 ; 6 byte register bank
zpspace = $1A ; Zero page space allocated
; ------------------------------------------------------------------------
; Actual code
ldy #zpspace-1
L1: lda sp,y
sta zpsave,y ; Save the zero page locations we need
dey
bpl L1
; Clear the BSS data
jsr zerobss
; Save system stuff and setup the stack
tsx
stx spsave ; Save the system stack ptr
lda #<TOPMEM
sta sp
lda #>TOPMEM
sta sp+1 ; Set argument stack ptr
; Initialize the heap
jsr __hinit
; Initialize conio stuff
lda #$ff
sta TEXTTYP
; Set up to use Apple ROM $C000-$CFFF
;; sta USEROM
; Pass an empty command line
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main ; call the users code
; fall thru to exit...
_exit:
lda #$ff
sta TEXTTYP
jsr doatexit ; call exit functions
ldx spsave
txs ; Restore stack pointer
; Copy back the zero page stuff
ldy #zpspace-1
L2: lda zpsave,y
sta sp,y
dey
bpl L2
; Reset changed vectors, back to basic
jmp RESTOR
.data
zpsave: .res zpspace
.bss
spsave: .res 1
+309
View File
@@ -0,0 +1,309 @@
;
; Ullrich von Bassewitz, 02.06.1998
;
; Character specification table.
;
; The tables are readonly, put them into the code segment
.code
; Value that must be added to an upper case char to make it lower case
; char (example: for ASCII, this must be $E0).
.export __cdiff
__cdiff:
.byte $E0
; The following 256 byte wide table specifies attributes for the isxxx type
; of functions. Doing it by a table means some overhead in space, but it
; has major advantages:
;
; * It is fast. If it were'nt for the slow parameter passing of cc65, one
; could even define macros for the isxxx functions (this is usually
; done on other platforms).
;
; * It is highly portable. The only unportable part is the table itself,
; all real code goes into the common library.
;
; * We save some code in the isxxx functions.
;
;
; Bit assignments:
;
; 0 - Lower case char
; 1 - Upper case char
; 2 - Numeric digit
; 3 - Hex digit (both, lower and upper)
; 4 - Control character
; 5 - The space character itself
; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v')
; 7 - Space or tab character
.export __ctype
__ctype:
.byte $10 ; 0/00 ___ctrl_@___
.byte $10 ; 1/01 ___ctrl_A___
.byte $10 ; 2/02 ___ctrl_B___
.byte $10 ; 3/03 ___ctrl_C___
.byte $10 ; 4/04 ___ctrl_D___
.byte $10 ; 5/05 ___ctrl_E___
.byte $10 ; 6/06 ___ctrl_F___
.byte $10 ; 7/07 ___ctrl_G___
.byte $10 ; 8/08 ___ctrl_H___
.byte $D0 ; 9/09 ___ctrl_I___
.byte $50 ; 10/0a ___ctrl_J___
.byte $50 ; 11/0b ___ctrl_K___
.byte $50 ; 12/0c ___ctrl_L___
.byte $50 ; 13/0d ___ctrl_M___
.byte $10 ; 14/0e ___ctrl_N___
.byte $10 ; 15/0f ___ctrl_O___
.byte $10 ; 16/10 ___ctrl_P___
.byte $10 ; 17/11 ___ctrl_Q___
.byte $10 ; 18/12 ___ctrl_R___
.byte $10 ; 19/13 ___ctrl_S___
.byte $10 ; 20/14 ___ctrl_T___
.byte $10 ; 21/15 ___ctrl_U___
.byte $10 ; 22/16 ___ctrl_V___
.byte $10 ; 23/17 ___ctrl_W___
.byte $10 ; 24/18 ___ctrl_X___
.byte $10 ; 25/19 ___ctrl_Y___
.byte $10 ; 26/1a ___ctrl_Z___
.byte $10 ; 27/1b ___ctrl_[___
.byte $10 ; 28/1c ___ctrl_\___
.byte $10 ; 29/1d ___ctrl_]___
.byte $10 ; 30/1e ___ctrl_^___
.byte $10 ; 31/1f ___ctrl_____
.byte $A0 ; 32/20 ___SPACE___
.byte $00 ; 33/21 _____!_____
.byte $00 ; 34/22 _____"_____
.byte $00 ; 35/23 _____#_____
.byte $00 ; 36/24 _____$_____
.byte $00 ; 37/25 _____%_____
.byte $00 ; 38/26 _____&_____
.byte $00 ; 39/27 _____'_____
.byte $00 ; 40/28 _____(_____
.byte $00 ; 41/29 _____)_____
.byte $00 ; 42/2a _____*_____
.byte $00 ; 43/2b _____+_____
.byte $00 ; 44/2c _____,_____
.byte $00 ; 45/2d _____-_____
.byte $00 ; 46/2e _____._____
.byte $00 ; 47/2f _____/_____
.byte $0C ; 48/30 _____0_____
.byte $0C ; 49/31 _____1_____
.byte $0C ; 50/32 _____2_____
.byte $0C ; 51/33 _____3_____
.byte $0C ; 52/34 _____4_____
.byte $0C ; 53/35 _____5_____
.byte $0C ; 54/36 _____6_____
.byte $0C ; 55/37 _____7_____
.byte $0C ; 56/38 _____8_____
.byte $0C ; 57/39 _____9_____
.byte $00 ; 58/3a _____:_____
.byte $00 ; 59/3b _____;_____
.byte $00 ; 60/3c _____<_____
.byte $00 ; 61/3d _____=_____
.byte $00 ; 62/3e _____>_____
.byte $00 ; 63/3f _____?_____
.byte $00 ; 64/40 _____@_____
.byte $0A ; 65/41 _____A_____
.byte $0A ; 66/42 _____B_____
.byte $0A ; 67/43 _____C_____
.byte $0A ; 68/44 _____D_____
.byte $0A ; 69/45 _____E_____
.byte $0A ; 70/46 _____F_____
.byte $02 ; 71/47 _____G_____
.byte $02 ; 72/48 _____H_____
.byte $02 ; 73/49 _____I_____
.byte $02 ; 74/4a _____J_____
.byte $02 ; 75/4b _____K_____
.byte $02 ; 76/4c _____L_____
.byte $02 ; 77/4d _____M_____
.byte $02 ; 78/4e _____N_____
.byte $02 ; 79/4f _____O_____
.byte $02 ; 80/50 _____P_____
.byte $02 ; 81/51 _____Q_____
.byte $02 ; 82/52 _____R_____
.byte $02 ; 83/53 _____S_____
.byte $02 ; 84/54 _____T_____
.byte $02 ; 85/55 _____U_____
.byte $02 ; 86/56 _____V_____
.byte $02 ; 87/57 _____W_____
.byte $02 ; 88/58 _____X_____
.byte $02 ; 89/59 _____Y_____
.byte $02 ; 90/5a _____Z_____
.byte $00 ; 91/5b _____[_____
.byte $00 ; 92/5c _____\_____
.byte $00 ; 93/5d _____]_____
.byte $00 ; 94/5e _____^_____
.byte $00 ; 95/5f _UNDERLINE_
.byte $00 ; 96/60 ___grave___
.byte $09 ; 97/61 _____a_____
.byte $09 ; 98/62 _____b_____
.byte $09 ; 99/63 _____c_____
.byte $09 ; 100/64 _____d_____
.byte $09 ; 101/65 _____e_____
.byte $09 ; 102/66 _____f_____
.byte $01 ; 103/67 _____g_____
.byte $01 ; 104/68 _____h_____
.byte $01 ; 105/69 _____i_____
.byte $01 ; 106/6a _____j_____
.byte $01 ; 107/6b _____k_____
.byte $01 ; 108/6c _____l_____
.byte $01 ; 109/6d _____m_____
.byte $01 ; 110/6e _____n_____
.byte $01 ; 111/6f _____o_____
.byte $01 ; 112/70 _____p_____
.byte $01 ; 113/71 _____q_____
.byte $01 ; 114/72 _____r_____
.byte $01 ; 115/73 _____s_____
.byte $01 ; 116/74 _____t_____
.byte $01 ; 117/75 _____u_____
.byte $01 ; 118/76 _____v_____
.byte $01 ; 119/77 _____w_____
.byte $01 ; 120/78 _____x_____
.byte $01 ; 121/79 _____y_____
.byte $01 ; 122/7a _____z_____
.byte $00 ; 123/7b _____{_____
.byte $00 ; 124/7c _____|_____
.byte $00 ; 125/7d _____}_____
.byte $00 ; 126/7e _____~_____
.byte $40 ; 127/7f ____DEL____
.byte $00 ; 128/80 ___________
.byte $00 ; 129/81 ___________
.byte $00 ; 130/82 ___________
.byte $00 ; 131/83 ___________
.byte $00 ; 132/84 ___________
.byte $00 ; 133/85 ___________
.byte $00 ; 134/86 ___________
.byte $00 ; 135/87 ___________
.byte $00 ; 136/88 ___________
.byte $00 ; 137/89 ___________
.byte $00 ; 138/8a ___________
.byte $00 ; 139/8b ___________
.byte $00 ; 140/8c ___________
.byte $00 ; 141/8d ___________
.byte $00 ; 142/8e ___________
.byte $00 ; 143/8f ___________
.byte $00 ; 144/90 ___________
.byte $00 ; 145/91 ___________
.byte $00 ; 146/92 ___________
.byte $10 ; 147/93 ___________
.byte $00 ; 148/94 ___________
.byte $00 ; 149/95 ___________
.byte $00 ; 150/96 ___________
.byte $00 ; 151/97 ___________
.byte $00 ; 152/98 ___________
.byte $00 ; 153/99 ___________
.byte $00 ; 154/9a ___________
.byte $00 ; 155/9b ___________
.byte $00 ; 156/9c ___________
.byte $00 ; 157/9d ___________
.byte $00 ; 158/9e ___________
.byte $00 ; 159/9f ___________
.byte $00 ; 160/a0 ___________
.byte $00 ; 161/a1 ___________
.byte $00 ; 162/a2 ___________
.byte $00 ; 163/a3 ___________
.byte $00 ; 164/a4 ___________
.byte $00 ; 165/a5 ___________
.byte $00 ; 166/a6 ___________
.byte $00 ; 167/a7 ___________
.byte $00 ; 168/a8 ___________
.byte $00 ; 169/a9 ___________
.byte $00 ; 170/aa ___________
.byte $00 ; 171/ab ___________
.byte $00 ; 172/ac ___________
.byte $00 ; 173/ad ___________
.byte $00 ; 174/ae ___________
.byte $00 ; 175/af ___________
.byte $00 ; 176/b0 ___________
.byte $00 ; 177/b1 ___________
.byte $00 ; 178/b2 ___________
.byte $00 ; 179/b3 ___________
.byte $00 ; 180/b4 ___________
.byte $00 ; 181/b5 ___________
.byte $00 ; 182/b6 ___________
.byte $00 ; 183/b7 ___________
.byte $00 ; 184/b8 ___________
.byte $00 ; 185/b9 ___________
.byte $00 ; 186/ba ___________
.byte $00 ; 187/bb ___________
.byte $00 ; 188/bc ___________
.byte $00 ; 189/bd ___________
.byte $00 ; 190/be ___________
.byte $00 ; 191/bf ___________
.byte $02 ; 192/c0 ___________
.byte $02 ; 193/c1 ___________
.byte $02 ; 194/c2 ___________
.byte $02 ; 195/c3 ___________
.byte $02 ; 196/c4 ___________
.byte $02 ; 197/c5 ___________
.byte $02 ; 198/c6 ___________
.byte $02 ; 199/c7 ___________
.byte $02 ; 200/c8 ___________
.byte $02 ; 201/c9 ___________
.byte $02 ; 202/ca ___________
.byte $02 ; 203/cb ___________
.byte $02 ; 204/cc ___________
.byte $02 ; 205/cd ___________
.byte $02 ; 206/ce ___________
.byte $02 ; 207/cf ___________
.byte $02 ; 208/d0 ___________
.byte $02 ; 209/d1 ___________
.byte $02 ; 210/d2 ___________
.byte $02 ; 211/d3 ___________
.byte $02 ; 212/d4 ___________
.byte $02 ; 213/d5 ___________
.byte $02 ; 214/d6 ___________
.byte $02 ; 215/d7 ___________
.byte $02 ; 216/d8 ___________
.byte $02 ; 217/d9 ___________
.byte $02 ; 218/da ___________
.byte $02 ; 219/db ___________
.byte $02 ; 220/dc ___________
.byte $02 ; 221/dd ___________
.byte $02 ; 222/de ___________
.byte $00 ; 223/df ___________
.byte $01 ; 224/e0 ___________
.byte $01 ; 225/e1 ___________
.byte $01 ; 226/e2 ___________
.byte $01 ; 227/e3 ___________
.byte $01 ; 228/e4 ___________
.byte $01 ; 229/e5 ___________
.byte $01 ; 230/e6 ___________
.byte $01 ; 231/e7 ___________
.byte $01 ; 232/e8 ___________
.byte $01 ; 233/e9 ___________
.byte $01 ; 234/ea ___________
.byte $01 ; 235/eb ___________
.byte $01 ; 236/ec ___________
.byte $01 ; 237/ed ___________
.byte $01 ; 238/ee ___________
.byte $01 ; 239/ef ___________
.byte $01 ; 240/f0 ___________
.byte $01 ; 241/f1 ___________
.byte $01 ; 242/f2 ___________
.byte $01 ; 243/f3 ___________
.byte $01 ; 244/f4 ___________
.byte $01 ; 245/f5 ___________
.byte $01 ; 246/f6 ___________
.byte $01 ; 247/f7 ___________
.byte $01 ; 248/f8 ___________
.byte $01 ; 249/f9 ___________
.byte $01 ; 250/fa ___________
.byte $01 ; 251/fb ___________
.byte $01 ; 252/fc ___________
.byte $01 ; 253/fd ___________
.byte $01 ; 254/fe ___________
.byte $00 ; 255/ff ___________
+30
View File
@@ -0,0 +1,30 @@
;
; Ullrich von Bassewitz, 08.08.1998
;
; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
; void cvline (unsigned char length);
;
.export _cvlinexy, _cvline
.import popa, _gotoxy, putchar, newline
.importzp tmp1
_cvlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cvline
_cvline:
cmp #0 ; Is the length zero?
beq L9 ; Jump if done
sta tmp1
L1: lda #$7C ; Vertical bar
jsr putchar ; Write, no cursor advance
jsr newline ; Advance cursor to next line
dec tmp1
bne L1
L9: rts
+18
View File
@@ -0,0 +1,18 @@
;;
;; Kevin Ruland
;;
;; int kbhit (void);
;;
.export _kbhit
.import return0, return1
.include "apple2.inc"
_kbhit:
bit KEY_STROBE ; Reading strobe checks for keypress
bmi L1 ; if KEY_STROBE > 127 key was pressed
jmp return0
L1:
jmp return1
+52
View File
@@ -0,0 +1,52 @@
;
; Ullrich von Bassewitz, 30.05.1998
;
; int read (int fd, void* buf, int count);
;
; THIS IS A HACK!
;
.export _read
.import popax, _cputc
.importzp ptr1, ptr2, ptr3
.include "apple2.inc"
_read: jsr popax ; get count
sta ptr2
stx ptr2+1 ; save it for later
jsr popax ; get buf
sta ptr1
stx ptr1+1
jsr popax ; get fd and discard it
lda #0
sta ptr3
sta ptr3+1 ; set count
L1: lda ptr2
ora ptr2+1 ; count zero?
beq L9
jsr RDKEY
and #$7f ; clear high bit.
pha
jsr _cputc
pla
ldy #0 ; offset into string
sta (ptr1),y ; save char
inc ptr1
bne L2
inc ptr1+1
L2: inc ptr3 ; increment count
bne L3
inc ptr3+1
L3: cmp #$0D ; CR?
bne L1
; Done, return the count
L9: lda ptr3
ldx ptr3+1
rts
+25
View File
@@ -0,0 +1,25 @@
;;
;; Kevin Ruland
;;
;; unsigned char __fastcall__ revers (unsigned char onoff)
;;
.export _revers
.include "apple2.inc"
_revers:
ldy TEXTTYP ; Stash old value
and #$FF ; Test for any bit
bne reverse ; Nothing set
lda #$FF
reverse:
ora #$3F
sta TEXTTYP
tya ; What was the old value?
eor #$FF ; Normal = $FF, Reverse = $3F
beq L2
lda #01
L2:
rts
+18
View File
@@ -0,0 +1,18 @@
;; Keivn Ruland
;;
;; unsigned char wherex( void );
;; unsigned char wherey( void );
.export _wherex, _wherey
.include "apple2.inc"
_wherex:
lda CH
rts
_wherey:
lda CV
rts
+53
View File
@@ -0,0 +1,53 @@
;;
;; Kevin Ruland
;;
;; int write (int fd, const void* buf, int count);
;;
;; for now will only write to fd = stdout
;;
.export _write
.import popax
.importzp ptr1, ptr2, ptr3
.include "apple2.inc"
_write:
jsr popax ; get count
sta ptr2
stx ptr2+1 ; save for later
sta ptr3
sta ptr3+1 ; save for result
jsr popax ; get buf
sta ptr1
stx ptr1+1
jsr popax ; get fd and discard
L1: lda ptr2
ora ptr2+1 ; count zero?
beq L9
ldy #0
lda (ptr1),y
cmp #$0A ; Check for \n = Crtl-j
bne rawout
lda #$0D ; Issue cr
rawout:
ora #$80
jsr COUT
inc ptr1
bne L2
inc ptr1+1
L2: lda ptr2
bne L3
dec ptr2
dec ptr2+1
jmp L1
L3: dec ptr2
jmp L1
; No error, return count
L9: lda ptr3
ldx ptr3+1
rts