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:
2
libsrc/.cvsignore
Normal file
2
libsrc/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
libr65.tmp
|
||||
*.lib
|
||||
120
libsrc/Makefile
Normal file
120
libsrc/Makefile
Normal file
@@ -0,0 +1,120 @@
|
||||
#
|
||||
# makefile for CC65 runtime library
|
||||
#
|
||||
|
||||
.SUFFIXES: .o .obj .s .c
|
||||
|
||||
# Defines used by the submakes:
|
||||
export CC = ../../src/cc65/cc65
|
||||
export AS = ../../src/ca65/ca65
|
||||
|
||||
# Define used within this makefile
|
||||
AR = ../src/ar65/ar65
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
all : apple2lib c64lib c128lib cbm610lib geoslib petlib plus4lib
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Apple ][
|
||||
|
||||
apple2lib:
|
||||
export CFLAGS="-Osir -g -t apple2 -I../../include";\
|
||||
for i in apple2 common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv apple2/crt0.o apple2.o
|
||||
for i in apple2 common runtime conio dbg; do \
|
||||
$(AR) a apple2.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Atari
|
||||
|
||||
atarilib:
|
||||
export CFLAGS="-Osir -g -t atari -I../../include";\
|
||||
for i in atari common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv atari/crt0.o atari.o
|
||||
for i in atari common runtime conio dbg; do \
|
||||
$(AR) a atari.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# C64
|
||||
|
||||
c64lib:
|
||||
export CFLAGS="-Osir -g -t c64 -I../../include";\
|
||||
for i in c64 cbm common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv c64/crt0.o c64.o
|
||||
for i in c64 cbm common runtime conio dbg; do \
|
||||
$(AR) a c64.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# C128
|
||||
|
||||
c128lib:
|
||||
export CFLAGS="-Osir -g -t c128 -I../../include";\
|
||||
for i in c128 cbm common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv c128/crt0.o c128.o
|
||||
for i in c128 cbm common runtime conio dbg; do \
|
||||
$(AR) a c128.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# PET-II series
|
||||
|
||||
cbm610lib:
|
||||
export CFLAGS="-Osir -g -t cbm610 -I../../include";\
|
||||
for i in cbm610 cbm common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv cbm610/crt0.o cbm610.o
|
||||
for i in cbm610 cbm common runtime conio dbg; do \
|
||||
$(AR) a cbm610.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# GEOS on the C64/128
|
||||
|
||||
geoslib:
|
||||
export CFLAGS="-Osir -g -t geos -I../../include";\
|
||||
for i in geos common runtime; do $(MAKE) -C $$i; done
|
||||
for i in common runtime; do \
|
||||
$(AR) a geos.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# CBM PET machines
|
||||
|
||||
petlib:
|
||||
export CFLAGS="-Osir -g -t pet -I../../include";\
|
||||
for i in pet cbm common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv pet/crt0.o pet.o
|
||||
for i in pet cbm common runtime conio dbg; do \
|
||||
$(AR) a pet.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Commodore C116, C16 and Plus/4
|
||||
|
||||
plus4lib:
|
||||
export CFLAGS="-Osir -g -t plus4 -I../../include";\
|
||||
for i in plus4 cbm common runtime conio dbg; do $(MAKE) -C $$i; done
|
||||
mv plus4/crt0.o plus4.o
|
||||
for i in plus4 cbm common runtime conio dbg; do \
|
||||
$(AR) a plus4.lib $$i/*.o;\
|
||||
done
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Dummy targets
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@for i in apple2 atari c128 c64 cbm cbm610 common conio dbg geos pet plus4 runtime; do \
|
||||
$(MAKE) -C $$i clean; \
|
||||
done
|
||||
|
||||
.PHONY: zap
|
||||
zap: clean
|
||||
@rm -f *.lib
|
||||
|
||||
|
||||
|
||||
|
||||
29
libsrc/apple2/Makefile
Normal file
29
libsrc/apple2/Makefile
Normal 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
libsrc/apple2/apple2.inc
Normal file
43
libsrc/apple2/apple2.inc
Normal 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
libsrc/apple2/break.s
Normal file
109
libsrc/apple2/break.s
Normal 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
libsrc/apple2/cclear.s
Normal file
30
libsrc/apple2/cclear.s
Normal 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
libsrc/apple2/cgetc.s
Normal file
25
libsrc/apple2/cgetc.s
Normal 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
libsrc/apple2/chline.s
Normal file
30
libsrc/apple2/chline.s
Normal 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
libsrc/apple2/clrscr.s
Normal file
10
libsrc/apple2/clrscr.s
Normal file
@@ -0,0 +1,10 @@
|
||||
;;
|
||||
;; Kevin Ruland
|
||||
;;
|
||||
;; void clrscr (void);
|
||||
|
||||
.export _clrscr
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
_clrscr = HOME
|
||||
20
libsrc/apple2/color.s
Normal file
20
libsrc/apple2/color.s
Normal 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
libsrc/apple2/cputc.s
Normal file
85
libsrc/apple2/cputc.s
Normal 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
libsrc/apple2/crt0.s
Normal file
112
libsrc/apple2/crt0.s
Normal 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
libsrc/apple2/ctype.s
Normal file
309
libsrc/apple2/ctype.s
Normal 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
libsrc/apple2/cvline.s
Normal file
30
libsrc/apple2/cvline.s
Normal 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
libsrc/apple2/kbhit.s
Normal file
18
libsrc/apple2/kbhit.s
Normal 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
libsrc/apple2/read.s
Normal file
52
libsrc/apple2/read.s
Normal 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
libsrc/apple2/revers.s
Normal file
25
libsrc/apple2/revers.s
Normal 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
libsrc/apple2/where.s
Normal file
18
libsrc/apple2/where.s
Normal 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
libsrc/apple2/write.s
Normal file
53
libsrc/apple2/write.s
Normal 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
|
||||
32
libsrc/atari/Makefile
Normal file
32
libsrc/atari/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# makefile for CC65 Atari runtime library
|
||||
#
|
||||
|
||||
ATARIDEFS = -DDIRECT_SCREEN
|
||||
|
||||
.SUFFIXES: .o .s .c
|
||||
|
||||
%.o: %.c
|
||||
@echo $<
|
||||
@$(CC) $(CFLAGS) $(ATARIDEFS) $<
|
||||
@$(AS) -o $@ $(AFLAGS) $(*).s
|
||||
|
||||
%.o: %.s
|
||||
@echo $<
|
||||
@$(AS) -g -o $@ $(AFLAGS) $(ATARIDEFS) $<
|
||||
|
||||
C_OBJS =
|
||||
|
||||
S_OBJS = crt0.o kbhit.o conio.o clrscr.o cputc.o ctype.o chline.o cvline.o \
|
||||
color.o gotoxy.o cclear.o revers.o readjoy.o break.o where.o write.o \
|
||||
gotox.o gotoy.o savevec.o rwcommon.o cgetc.o read.o getargs.o close.o \
|
||||
open.o oserror.o fdtable.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
|
||||
|
||||
1028
libsrc/atari/atari.inc
Normal file
1028
libsrc/atari/atari.inc
Normal file
File diff suppressed because it is too large
Load Diff
106
libsrc/atari/break.s
Normal file
106
libsrc/atari/break.s
Normal file
@@ -0,0 +1,106 @@
|
||||
;
|
||||
; Christian Groessler, 27-Feb-2000
|
||||
;
|
||||
; 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 "atari.inc"
|
||||
|
||||
|
||||
.bss
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
|
||||
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 VBREAK
|
||||
sta oldvec
|
||||
lda VBREAK+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 VBREAK
|
||||
lda #>brk_handler
|
||||
sta VBREAK+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; Reset the break vector
|
||||
.proc _reset_brk
|
||||
|
||||
lda oldvec
|
||||
sta VBREAK
|
||||
lda oldvec+1
|
||||
sta VBREAK+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
; Break handler, called if a break occurs
|
||||
|
||||
.proc brk_handler
|
||||
|
||||
sty _brk_y
|
||||
stx _brk_x
|
||||
pla
|
||||
sta _brk_a
|
||||
pla
|
||||
and #$EF ; Clear break bit
|
||||
sta _brk_sr
|
||||
pla ; PC low
|
||||
sec
|
||||
sbc #2 ; Point to start of brk
|
||||
sta _brk_pc
|
||||
pla ; PC high
|
||||
sbc #0
|
||||
sta _brk_pc+1
|
||||
|
||||
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
|
||||
|
||||
|
||||
34
libsrc/atari/cclear.s
Normal file
34
libsrc/atari/cclear.s
Normal file
@@ -0,0 +1,34 @@
|
||||
;
|
||||
; 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
|
||||
.ifdef DIRECT_SCREEN
|
||||
L1: lda #0 ; Blank - screen code
|
||||
.else
|
||||
L1: lda #$20 ; Blank
|
||||
.endif
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
17
libsrc/atari/cgetc.s
Normal file
17
libsrc/atari/cgetc.s
Normal file
@@ -0,0 +1,17 @@
|
||||
;
|
||||
; get a kbd char.
|
||||
;
|
||||
; char cgetc(void)
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.export _cgetc
|
||||
|
||||
_cgetc:
|
||||
lda KEYBDV+5
|
||||
pha
|
||||
lda KEYBDV+4
|
||||
pha
|
||||
rts
|
||||
ldx #0
|
||||
rts
|
||||
34
libsrc/atari/chline.s
Normal file
34
libsrc/atari/chline.s
Normal file
@@ -0,0 +1,34 @@
|
||||
;
|
||||
; 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
|
||||
.ifdef DIRECT_SCREEN
|
||||
L1: lda #$12+64 ; Horizontal line, screen code
|
||||
.else
|
||||
L1: lda #$12 ; Horizontal line
|
||||
.endif
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
36
libsrc/atari/close.s
Normal file
36
libsrc/atari/close.s
Normal file
@@ -0,0 +1,36 @@
|
||||
;
|
||||
; Christian Groessler, May-2000
|
||||
;
|
||||
; int close(int fd);
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.export _close
|
||||
.import __do_oserror,popax,__oserror
|
||||
.import fdtoiocb_down,__inviocb
|
||||
|
||||
.proc _close
|
||||
jsr popax
|
||||
jsr fdtoiocb_down ; get iocb index into X and decr. usage count
|
||||
bmi inverr
|
||||
bne ok ; not last one -> don't close yet
|
||||
; asl a
|
||||
; asl a
|
||||
; asl a
|
||||
; asl a
|
||||
; tax
|
||||
lda #CLOSE
|
||||
sta ICCOM,x
|
||||
jsr CIOV
|
||||
bpl ok
|
||||
jmp __do_oserror
|
||||
|
||||
ok: ldx #0
|
||||
stx __oserror ; clear system specific error code
|
||||
txa
|
||||
rts
|
||||
|
||||
inverr: jmp __inviocb
|
||||
|
||||
.endproc
|
||||
|
||||
47
libsrc/atari/clrscr.s
Normal file
47
libsrc/atari/clrscr.s
Normal file
@@ -0,0 +1,47 @@
|
||||
;
|
||||
; Christian Groessler, Apr-2000
|
||||
;
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
.ifdef DIRECT_SCREEN
|
||||
|
||||
.importzp ptr1
|
||||
|
||||
_clrscr:lda SAVMSC ; screen memory
|
||||
sta ptr1
|
||||
lda SAVMSC+1
|
||||
clc
|
||||
adc #>(40*24)
|
||||
sta ptr1+1
|
||||
lda #0 ; screen code of space char
|
||||
ldy #<(40*24) ; 40x24: size of default atari screen
|
||||
ldx #>(40*24)
|
||||
_clr1: sta (ptr1),y
|
||||
dey
|
||||
bne _clr1
|
||||
sta (ptr1),y
|
||||
dex
|
||||
bmi done
|
||||
ldy ptr1+1
|
||||
dey
|
||||
sty ptr1+1
|
||||
ldy #255
|
||||
jmp _clr1
|
||||
|
||||
done: sta COLCRS
|
||||
sta ROWCRS
|
||||
rts
|
||||
|
||||
.else
|
||||
|
||||
.import putchar
|
||||
_clrscr:
|
||||
lda #ATCLR
|
||||
jmp putchar
|
||||
|
||||
.endif
|
||||
33
libsrc/atari/color.s
Normal file
33
libsrc/atari/color.s
Normal file
@@ -0,0 +1,33 @@
|
||||
;
|
||||
; 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
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
_textcolor:
|
||||
ldx COLOR1 ; get old value
|
||||
sta COLOR1 ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bgcolor:
|
||||
ldx COLOR2 ; get old value
|
||||
sta COLOR2 ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bordercolor:
|
||||
ldx COLOR4 ; get old value
|
||||
sta COLOR4 ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
20
libsrc/atari/conio.s
Normal file
20
libsrc/atari/conio.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Christian Groessler
|
||||
;
|
||||
; Low level stuff for screen output/console input
|
||||
;
|
||||
|
||||
.export initconio
|
||||
.import xsize, ysize, plot
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
.code
|
||||
|
||||
initconio:
|
||||
ldx #40
|
||||
ldy #24
|
||||
stx xsize
|
||||
sty ysize
|
||||
rts
|
||||
|
||||
190
libsrc/atari/cputc.s
Normal file
190
libsrc/atari/cputc.s
Normal file
@@ -0,0 +1,190 @@
|
||||
;
|
||||
; Mark Keates, Christian Groessler
|
||||
;
|
||||
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc
|
||||
.export plot, cputdirect, putchar
|
||||
.import popa, _gotoxy
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
.ifdef DIRECT_SCREEN
|
||||
|
||||
.importzp tmp4,ptr4
|
||||
|
||||
_cputc:
|
||||
cmp #$0D ; CR
|
||||
bne L4
|
||||
lda #0
|
||||
sta COLCRS
|
||||
beq plot ; return
|
||||
|
||||
L4: cmp #$0A ; LF
|
||||
beq newline
|
||||
cmp #ATEOL ; Atari-EOL?
|
||||
beq newline
|
||||
|
||||
tay
|
||||
rol a
|
||||
rol a
|
||||
rol a
|
||||
rol a
|
||||
and #3
|
||||
tax
|
||||
tya
|
||||
and #$9f
|
||||
ora ataint,x
|
||||
|
||||
cputdirect: ; accepts screen code
|
||||
jsr putchar
|
||||
|
||||
; advance cursor
|
||||
inc COLCRS
|
||||
lda COLCRS
|
||||
cmp #40
|
||||
bcc plot
|
||||
lda #0
|
||||
sta COLCRS
|
||||
|
||||
.export newline
|
||||
newline:
|
||||
inc ROWCRS
|
||||
lda ROWCRS
|
||||
cmp #24
|
||||
bne plot
|
||||
lda #0
|
||||
sta ROWCRS
|
||||
plot: ldy COLCRS
|
||||
ldx ROWCRS
|
||||
rts
|
||||
|
||||
putchar:
|
||||
pha ; save char
|
||||
lda #0
|
||||
sta tmp4
|
||||
lda ROWCRS
|
||||
asl a
|
||||
rol tmp4
|
||||
asl a
|
||||
rol tmp4 ; row * 4
|
||||
adc ROWCRS
|
||||
bcc L1
|
||||
inc tmp4 ; row * 5
|
||||
L1: asl a
|
||||
rol tmp4 ; row * 10
|
||||
asl a
|
||||
rol tmp4
|
||||
asl a
|
||||
rol tmp4 ; row * 40
|
||||
L3: clc
|
||||
adc SAVMSC ; add start of screen memory
|
||||
sta ptr4
|
||||
lda tmp4
|
||||
adc SAVMSC+1
|
||||
sta ptr4+1
|
||||
pla ; get char again
|
||||
ora INVFLG
|
||||
ldy COLCRS
|
||||
sta (ptr4),y
|
||||
rts
|
||||
|
||||
.rodata
|
||||
ataint: .byte 64,0,32,96
|
||||
|
||||
;****************************************************************
|
||||
.else ;***** above DIRECT_SCREEN, below thru OS ***************
|
||||
;****************************************************************
|
||||
|
||||
.import __do_oserror,cursor,__oserror
|
||||
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
_cputc: cmp #$0D ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta COLCRS
|
||||
beq plot ; Recalculate pointers
|
||||
|
||||
; don't know whether this is needed. the compiler generates
|
||||
; already ATEOL chars for \n
|
||||
|
||||
L1: cmp #$0A ; LF?
|
||||
bne L2
|
||||
lda #ATEOL
|
||||
|
||||
; Printable char of some sort
|
||||
|
||||
L2:
|
||||
cputdirect:
|
||||
pha
|
||||
and #$7f
|
||||
cmp #32 ; control char?
|
||||
bcs goon
|
||||
lda #$1b
|
||||
jsr putchar
|
||||
goon: pla
|
||||
jsr putchar ; Write the character to the screen
|
||||
|
||||
plot: ldy COLCRS
|
||||
ldx ROWCRS
|
||||
rts
|
||||
|
||||
; Write one character to the screen without doing anything else, return X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
.if 0
|
||||
tax
|
||||
lda #>(retr-1)
|
||||
pha
|
||||
lda #<(retr-1)
|
||||
pha
|
||||
lda ICPTH
|
||||
pha
|
||||
lda ICPTL
|
||||
pha
|
||||
lda #0
|
||||
sta LOGCOL
|
||||
txa
|
||||
rts
|
||||
retr:
|
||||
.endif
|
||||
.if 1
|
||||
pha
|
||||
ldx #0 ; iocb #0 (screen editor)
|
||||
txa
|
||||
sta ICBLL,x
|
||||
sta ICBLH,x
|
||||
sta ICBAL,x
|
||||
sta ICBAH,x
|
||||
lda #PUTCHR
|
||||
sta ICCOM,x
|
||||
lda cursor
|
||||
beq putc7
|
||||
lda #0
|
||||
beq putc8
|
||||
putc7: lda #1
|
||||
putc8: sta CRSINH
|
||||
pla
|
||||
jsr CIOV
|
||||
bpl putc9
|
||||
jmp __do_oserror ; update system specific error code
|
||||
|
||||
putc9: tya
|
||||
ldx #0
|
||||
stx __oserror
|
||||
ldy COLCRS
|
||||
.endif
|
||||
rts
|
||||
|
||||
.endif ; not defined DIRECT_SCREEN
|
||||
191
libsrc/atari/crt0.s
Normal file
191
libsrc/atari/crt0.s
Normal file
@@ -0,0 +1,191 @@
|
||||
;
|
||||
; Startup code for cc65 (ATARI version)
|
||||
;
|
||||
; Contributing authors:
|
||||
; Mark Keates
|
||||
; Freddy Offenga
|
||||
; Christian Groessler
|
||||
;
|
||||
; This must be the *first* file on the linker command line
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.import getargs, argc, argv
|
||||
.import __hinit, initconio, zerobss, pushax, doatexit
|
||||
.import _main,__filetab
|
||||
.import __CODE_LOAD__, __BSS_LOAD__
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Define and export the ZP variables for the runtime
|
||||
|
||||
.exportzp sp, sreg, regsave
|
||||
.exportzp ptr1, ptr2, ptr3, ptr4
|
||||
.exportzp tmp1, tmp2, tmp3, tmp4
|
||||
.exportzp fntemp, regbank, zpspace
|
||||
|
||||
sp = $D2 ; (2bytes) stack pointer
|
||||
sreg = $D4 ; (2bytes) secondary register/high 16 bit for longs
|
||||
regsave = $D6 ; (4bytes) slot to save/restore (E)AX into
|
||||
ptr1 = $DA ; (2bytes)
|
||||
ptr2 = $DC ; (2bytes)
|
||||
ptr3 = $DE ; (2bytes)
|
||||
ptr4 = $E0 ; (2bytes)
|
||||
tmp1 = $E2 ; (1byte)
|
||||
tmp2 = $E3 ; (1byte)
|
||||
tmp3 = $E4 ; (1byte)
|
||||
tmp4 = $E5 ; (1byte)
|
||||
fntemp = $E6 ; (2bytes) pointer to file name
|
||||
regbank = $E8 ; (6bytes) 6 byte register bank
|
||||
zpspace = $EE - sp ; Zero page space allocated
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; EXE header
|
||||
|
||||
.segment "EXEHDR"
|
||||
.word $FFFF
|
||||
.word __CODE_LOAD__
|
||||
.word __BSS_LOAD__ - 1
|
||||
.code
|
||||
.reloc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Actual code
|
||||
|
||||
rts ; fix for SpartaDOS / OS/A+
|
||||
; they first call the entry point from AUTOSTRT and
|
||||
; then the load addess (this rts here).
|
||||
; We point AUTOSTRT directly after the rts.
|
||||
|
||||
; Real entry point:
|
||||
|
||||
; Save the zero page locations we need
|
||||
|
||||
ldy #zpspace-1
|
||||
L1: lda sp,y
|
||||
sta zpsave,y
|
||||
dey
|
||||
bpl L1
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
|
||||
; setup the stack
|
||||
|
||||
tsx
|
||||
stx spsave
|
||||
|
||||
; report memory usage and initialize stack pointer
|
||||
|
||||
lda APPMHI
|
||||
sta appmsav
|
||||
lda APPMHI+1
|
||||
sta appmsav+1
|
||||
|
||||
lda #<$8000
|
||||
sta sp
|
||||
sta APPMHI
|
||||
lda #>$8000
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
sta APPMHI+1
|
||||
|
||||
; set left margin to 0
|
||||
|
||||
lda LMARGN
|
||||
sta old_lmargin
|
||||
lda #0
|
||||
sta LMARGN
|
||||
|
||||
; set keyb to upper/lowercase mode
|
||||
|
||||
ldx SHFLOK
|
||||
stx old_shflok
|
||||
sta SHFLOK
|
||||
|
||||
; Initialize the heap
|
||||
|
||||
jsr __hinit
|
||||
|
||||
; Initialize conio stuff
|
||||
|
||||
jsr initconio
|
||||
|
||||
lda #$FF
|
||||
sta CH
|
||||
|
||||
; ugly hack for now: set stdio stream handles
|
||||
; all to iocb #0
|
||||
; until we know where to go with fd<->iocb relation
|
||||
; this won't stay here!
|
||||
|
||||
lda #0
|
||||
sta __filetab + 2
|
||||
sta __filetab + 4
|
||||
|
||||
; Pass command line if present
|
||||
|
||||
jsr getargs
|
||||
|
||||
lda argc
|
||||
ldx argc+1
|
||||
jsr pushax ; argc
|
||||
lda #<argv
|
||||
ldx #>argv
|
||||
jsr pushax ; argv
|
||||
|
||||
ldy #4 ; Argument size
|
||||
jsr _main ; call the users code
|
||||
|
||||
; fall thru to exit...
|
||||
|
||||
_exit: jsr doatexit ; call exit functions
|
||||
|
||||
ldx spsave
|
||||
txs ; Restore stack pointer
|
||||
|
||||
; restore left margin
|
||||
|
||||
lda old_lmargin
|
||||
sta LMARGN
|
||||
|
||||
; restore kb mode
|
||||
|
||||
lda old_shflok
|
||||
sta SHFLOK
|
||||
|
||||
; restore APPMHI
|
||||
|
||||
lda appmsav
|
||||
sta APPMHI
|
||||
lda appmsav+1
|
||||
sta APPMHI+1
|
||||
|
||||
; Copy back the zero page stuff
|
||||
|
||||
ldy #zpspace-1
|
||||
L2: lda zpsave,y
|
||||
sta sp,y
|
||||
dey
|
||||
bpl L2
|
||||
|
||||
; Back to DOS
|
||||
|
||||
rts
|
||||
|
||||
.data
|
||||
|
||||
zpsave: .res zpspace
|
||||
|
||||
.bss
|
||||
|
||||
spsave: .res 1
|
||||
appmsav: .res 1
|
||||
old_shflok: .res 1
|
||||
old_lmargin: .res 1
|
||||
|
||||
.segment "AUTOSTRT"
|
||||
.word $02E0
|
||||
.word $02E1
|
||||
.word __CODE_LOAD__ + 1
|
||||
309
libsrc/atari/ctype.s
Normal file
309
libsrc/atari/ctype.s
Normal 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 ___________
|
||||
|
||||
35
libsrc/atari/cvline.s
Normal file
35
libsrc/atari/cvline.s
Normal file
@@ -0,0 +1,35 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 08.08.1998
|
||||
;
|
||||
; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
|
||||
; void cvline (unsigned char length);
|
||||
;
|
||||
.include "atari.inc"
|
||||
|
||||
.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 COLCRS
|
||||
pha
|
||||
lda #$7C ; Vertical bar
|
||||
jsr putchar ; Write, no cursor advance
|
||||
pla
|
||||
sta COLCRS
|
||||
inc ROWCRS
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
103
libsrc/atari/fdtable.s
Normal file
103
libsrc/atari/fdtable.s
Normal file
@@ -0,0 +1,103 @@
|
||||
;
|
||||
; Christian Groessler, May-2000
|
||||
;
|
||||
; fd indirection table & helper functions
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.export fdtoiocb
|
||||
.export fdtoiocb_down
|
||||
.export fd_table
|
||||
|
||||
.data
|
||||
|
||||
fd_table:
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
.byte 0,$ff,0,0
|
||||
|
||||
MAX_FD_VAL = (* - fd_table) / 4
|
||||
|
||||
ft_usa = 0 ; usage counter
|
||||
ft_iocb = 1 ; iocb index (0,$10,$20,etc.), $ff for empty entry
|
||||
ft_dev = 2 ; device of open iocb
|
||||
ft_flag = 3 ; flags
|
||||
|
||||
.code
|
||||
|
||||
; gets fd in ax, decrements usage counter
|
||||
; return iocb index in X
|
||||
; return N bit set for invalid fd
|
||||
; return Z bit set if last user
|
||||
; all registers destroyed
|
||||
.proc fdtoiocb_down
|
||||
|
||||
cpx #0
|
||||
bne inval
|
||||
cmp #MAX_FD_VAL
|
||||
bcs inval
|
||||
asl a ; create index into fd table
|
||||
asl a
|
||||
tax
|
||||
lda #$ff
|
||||
cmp fd_table+ft_iocb,x ; entry in use?
|
||||
beq inval ; no, return error
|
||||
lda fd_table+ft_usa,x ; get usage counter
|
||||
beq ok_notlast ; 0?
|
||||
sec
|
||||
sbc #1 ; decr usage counter
|
||||
sta fd_table+ft_usa,x
|
||||
retiocb:php
|
||||
txa
|
||||
tay
|
||||
lda fd_table+ft_iocb,x ; get iocb
|
||||
tax
|
||||
plp
|
||||
bne cont
|
||||
php
|
||||
lda #$ff
|
||||
sta fd_table+ft_iocb,y ; clear table entry
|
||||
plp
|
||||
cont: rts
|
||||
|
||||
ok_notlast:
|
||||
lda #1 ; clears Z
|
||||
jmp retiocb
|
||||
|
||||
.endproc
|
||||
|
||||
inval: ldx #$ff ; sets N
|
||||
rts
|
||||
|
||||
|
||||
; gets fd in ax
|
||||
; return iocb index in X
|
||||
; return N bit set for invalid fd
|
||||
; all registers destroyed
|
||||
.proc fdtoiocb
|
||||
|
||||
cpx #0
|
||||
bne inval
|
||||
cmp #MAX_FD_VAL
|
||||
bcs inval
|
||||
asl a ; create index into fd table
|
||||
asl a
|
||||
tax
|
||||
lda #$ff
|
||||
cmp fd_table+ft_iocb,x ; entry in use?
|
||||
beq inval ; no, return error
|
||||
lda fd_table+ft_usa,x ; get usage counter
|
||||
beq inval ; 0? should not happen
|
||||
lda fd_table+ft_iocb,x ; get iocb
|
||||
rts
|
||||
|
||||
.endproc
|
||||
220
libsrc/atari/getargs.s
Normal file
220
libsrc/atari/getargs.s
Normal file
@@ -0,0 +1,220 @@
|
||||
; get arguments from command line (when DOS supports it)
|
||||
; and supply function to get default device: char *getdefdev(void);
|
||||
|
||||
; Freddy Offenga, 4/21/2000
|
||||
|
||||
; SpartaDOS:
|
||||
; the ZCRNAME routine is only used to get the default drive because
|
||||
; ZCRNAME has two disadvantages:
|
||||
; 1. It will convert D: into D1: instead of Dn: (n = default drive)
|
||||
; 2. It will give a 'no arguments' status if it detects something
|
||||
; like Dn: (without filename).
|
||||
|
||||
; OS/A+ DOS:
|
||||
; ZCRNAME is slightly different from SpartaDOS. It will convert D:
|
||||
; into Dn: where n is the default drive.
|
||||
|
||||
MAXARGS = 16 ; max. amount of arguments in arg. table
|
||||
CL_SIZE = 64 ; command line buffer size
|
||||
SPACE = 32 ; SPACE char.
|
||||
|
||||
.include "atari.inc"
|
||||
.export getargs, argc, argv
|
||||
.export _getdefdev ; get default device (e.g. "D1:")
|
||||
.importzp ptr1
|
||||
|
||||
; Get command line
|
||||
|
||||
getargs:
|
||||
lda #0
|
||||
sta argc
|
||||
sta argc+1
|
||||
sta argv
|
||||
sta argv+1
|
||||
|
||||
jsr detect
|
||||
bcs argdos ; carry set = DOS supports arguments
|
||||
rts
|
||||
|
||||
; Move SpartaDOS command line to our own buffer
|
||||
|
||||
argdos: lda DOSVEC
|
||||
clc
|
||||
adc #<LBUF
|
||||
sta ptr1
|
||||
lda DOSVEC+1
|
||||
adc #>LBUF
|
||||
sta ptr1+1
|
||||
|
||||
ldy #0
|
||||
cpcl: lda (ptr1),y
|
||||
sta ourcl,y
|
||||
iny
|
||||
cmp #ATEOL
|
||||
beq movdon
|
||||
cpy #CL_SIZE
|
||||
bne cpcl
|
||||
|
||||
movdon: lda #0
|
||||
sta ourcl,y ; null terminate behind ATEOL
|
||||
|
||||
; Get default device (LBUF will be destroyed!!)
|
||||
|
||||
ldy #BUFOFF
|
||||
lda #0
|
||||
sta (DOSVEC),y ; reset buffer offset
|
||||
|
||||
; Store dummy argument
|
||||
|
||||
ldy #LBUF
|
||||
lda dumpar1
|
||||
sta (DOSVEC),y
|
||||
iny
|
||||
lda dumpar2
|
||||
sta (DOSVEC),y
|
||||
|
||||
; One extra store to avoid the buggy sequence from OS/A+ DOS:
|
||||
; <D><RETURN><:> => drive number = <RETURN>
|
||||
|
||||
iny
|
||||
sta (DOSVEC),y
|
||||
|
||||
; Create crunch vector
|
||||
|
||||
ldy #ZCRNAME+1
|
||||
lda (DOSVEC),y
|
||||
sta crvec+1
|
||||
iny
|
||||
lda (DOSVEC),y
|
||||
sta crvec+2
|
||||
|
||||
crvec: jsr $FFFF ; will be set to crunch vector
|
||||
|
||||
; Get default device
|
||||
|
||||
ldy #COMFNAM ; COMFNAM is always "Dn:"
|
||||
lda (DOSVEC),y
|
||||
sta defdev
|
||||
iny
|
||||
lda (DOSVEC),y
|
||||
sta defdev+1
|
||||
|
||||
; Turn command line into argv table
|
||||
|
||||
ldy #0
|
||||
eatspc: lda ourcl,y ; eat spaces
|
||||
cmp #ATEOL
|
||||
beq finargs
|
||||
cmp #SPACE
|
||||
bne rpar ; begin of argument found
|
||||
iny
|
||||
cpy #CL_SIZE
|
||||
bne eatspc
|
||||
beq finargs ; only spaces is no argument
|
||||
|
||||
; Store argument vector
|
||||
|
||||
rpar: lda argc ; low-byte
|
||||
asl
|
||||
tax ; table index
|
||||
tya ; ourcl index
|
||||
clc
|
||||
adc #<ourcl
|
||||
sta argv,x
|
||||
lda #>ourcl
|
||||
adc #0
|
||||
sta argv+1,x
|
||||
ldx argc
|
||||
inx
|
||||
stx argc
|
||||
cpx #MAXARGS
|
||||
beq finargs
|
||||
|
||||
; Skip this arg.
|
||||
|
||||
skiparg:
|
||||
ldx ourcl,y
|
||||
cpx #ATEOL ; end of line?
|
||||
beq eopar
|
||||
cpx #SPACE
|
||||
beq eopar
|
||||
iny
|
||||
cpy #CL_SIZE
|
||||
bne skiparg
|
||||
|
||||
; End of arg. -> place 0
|
||||
|
||||
eopar:
|
||||
lda #0
|
||||
sta ourcl,y
|
||||
iny ; y behind arg.
|
||||
cpx #ATEOL ; was it the last arg?
|
||||
bne eatspc
|
||||
|
||||
; Finish args
|
||||
|
||||
finargs:
|
||||
lda argc
|
||||
asl
|
||||
tax
|
||||
lda #0
|
||||
sta argv,x
|
||||
sta argv+1,x
|
||||
rts
|
||||
|
||||
; DOS type detection
|
||||
|
||||
detect:
|
||||
lda DOS
|
||||
cmp #$53 ; "S" (SpartaDOS)
|
||||
beq spdos
|
||||
|
||||
ldy #COMTAB
|
||||
lda #$4C
|
||||
cmp (DOSVEC),y
|
||||
bne nordos
|
||||
|
||||
ldy #ZCRNAME
|
||||
cmp (DOSVEC),y
|
||||
bne nordos
|
||||
|
||||
ldy #6 ; OS/A+ has a jmp here
|
||||
cmp (DOSVEC),y
|
||||
beq nordos
|
||||
|
||||
spdos: sec ; SpartaDOS, OS/A+ or DOS XL
|
||||
rts
|
||||
|
||||
nordos: clc ; normal DOS (no args) detected
|
||||
rts
|
||||
|
||||
; Get default device (set by getargs routine)
|
||||
|
||||
_getdefdev:
|
||||
lda #<defdev
|
||||
ldx #>defdev
|
||||
rts
|
||||
|
||||
.data
|
||||
|
||||
; Dummy argument to get default device
|
||||
|
||||
dumpar1:
|
||||
.byte "X"
|
||||
dumpar2:
|
||||
.byte ATEOL
|
||||
|
||||
; Buffer for command line / argv strings
|
||||
|
||||
ourcl: .res CL_SIZE
|
||||
.byte ATEOL
|
||||
|
||||
; Default device
|
||||
|
||||
defdev:
|
||||
.byte "D1:", 0
|
||||
|
||||
.bss
|
||||
|
||||
argc: .res 2
|
||||
argv: .res (1 + MAXARGS) * 2
|
||||
14
libsrc/atari/gotox.s
Normal file
14
libsrc/atari/gotox.s
Normal file
@@ -0,0 +1,14 @@
|
||||
;
|
||||
; Christian Groessler, 19-Feb-2000
|
||||
;
|
||||
; void gotox (unsigned char x);
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.export _gotox
|
||||
|
||||
_gotox:
|
||||
sta COLCRS ; Set X
|
||||
lda #0
|
||||
sta COLCRS+1
|
||||
rts
|
||||
18
libsrc/atari/gotoxy.s
Normal file
18
libsrc/atari/gotoxy.s
Normal file
@@ -0,0 +1,18 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; void gotoxy (unsigned char x, unsigned char y);
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
.export _gotoxy
|
||||
.import popa
|
||||
|
||||
_gotoxy: ; Set the cursor position
|
||||
sta ROWCRS ; Set Y
|
||||
jsr popa ; Get X
|
||||
sta COLCRS ; Set X
|
||||
lda #0
|
||||
sta COLCRS+1 ;
|
||||
rts
|
||||
12
libsrc/atari/gotoy.s
Normal file
12
libsrc/atari/gotoy.s
Normal file
@@ -0,0 +1,12 @@
|
||||
;
|
||||
; Christian Groessler, 19-Feb-2000
|
||||
;
|
||||
; void gotoy (unsigned char y);
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.export _gotoy
|
||||
|
||||
_gotoy:
|
||||
sta ROWCRS ; Set Y
|
||||
rts
|
||||
21
libsrc/atari/kbhit.s
Normal file
21
libsrc/atari/kbhit.s
Normal file
@@ -0,0 +1,21 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; int kbhit (void);
|
||||
;
|
||||
|
||||
.export _kbhit
|
||||
.import return0, return1
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
_kbhit:
|
||||
lda CH ; Get number of characters
|
||||
cmp #$FF
|
||||
bne L1
|
||||
jmp return1
|
||||
L1: jmp return0
|
||||
|
||||
|
||||
|
||||
|
||||
208
libsrc/atari/open.s
Normal file
208
libsrc/atari/open.s
Normal file
@@ -0,0 +1,208 @@
|
||||
;
|
||||
; Christian Groessler, May-2000
|
||||
;
|
||||
; int open(const char *name,int flags,...);
|
||||
; returns fd
|
||||
;
|
||||
|
||||
UCASE_FILENAME = 1 ; comment it out if filename shouldn't be uppercased
|
||||
|
||||
.include "atari.inc"
|
||||
.include "../common/fmode.inc"
|
||||
.include "../common/errno.inc"
|
||||
.export _open
|
||||
.import __do_oserror,__seterrno,incsp4
|
||||
.import ldaxysp,addysp,subysp
|
||||
.import _strupr,__oserror
|
||||
.importzp tmp4,sp
|
||||
.ifdef UCASE_FILENAME
|
||||
.importzp tmp3,ptr4
|
||||
.endif
|
||||
|
||||
.proc _open
|
||||
|
||||
cpy #4 ; correct # of arguments (bytes)?
|
||||
beq parmok ; parameter count ok
|
||||
tya ; parm count < 4 shouldn't be needed to be checked
|
||||
sec ; (it generates a c compiler warning)
|
||||
sbc #4
|
||||
tay
|
||||
jsr addysp ; fix stack, throw away unused parameters
|
||||
|
||||
parmok: jsr findfreeiocb
|
||||
beq iocbok ; we found one
|
||||
|
||||
lda #<EMFILE ; "too many open files"
|
||||
ldx #>EMFILE
|
||||
seterr: jsr __seterrno
|
||||
jsr incsp4 ; clean up stack
|
||||
lda #$FF
|
||||
tax
|
||||
rts ; return -1
|
||||
|
||||
; process the mode argument
|
||||
; @@@TODO: append not handled yet!
|
||||
|
||||
iocbok: stx tmp4
|
||||
jsr clriocb ; init with zero
|
||||
ldy #1
|
||||
jsr ldaxysp ; get mode
|
||||
ldx tmp4
|
||||
cmp #O_RDONLY
|
||||
bne l1
|
||||
lda #OPNIN
|
||||
set: sta ICAX1,x
|
||||
bne cont
|
||||
|
||||
l1: cmp #O_WRONLY
|
||||
bne l2
|
||||
lda #OPNOT
|
||||
bne set
|
||||
|
||||
l2: ; O_RDWR
|
||||
lda #OPNOT|OPNIN
|
||||
bne set
|
||||
|
||||
; process the filename argument
|
||||
|
||||
cont: ldy #3
|
||||
jsr ldaxysp
|
||||
|
||||
.ifdef UCASE_FILENAME
|
||||
; we make sure that the filename doesn't contain lowercase letters
|
||||
; we copy the filename we got onto the stack, uppercase it and use this
|
||||
; one to open the iocb
|
||||
; we're using tmp3, ptr4
|
||||
|
||||
; save the original pointer
|
||||
sta ptr4
|
||||
stx ptr4+1
|
||||
|
||||
; now we need the length of the name
|
||||
ldy #0
|
||||
loop: lda (ptr4),y
|
||||
beq str_end
|
||||
cmp #ATEOL ; we also accept Atari EOF char as end of string
|
||||
beq str_end
|
||||
iny
|
||||
bne loop ; not longer than 255 chars (127 real limit)
|
||||
toolong:lda #<EINVAL ; file name is too long
|
||||
ldx #>EINVAL
|
||||
jmp seterr
|
||||
|
||||
str_end:iny ; room for terminating zero
|
||||
cpy #128 ; we only can handle lenght < 128
|
||||
bcs toolong
|
||||
sty tmp3 ; save size
|
||||
jsr subysp ; make room on the stack
|
||||
|
||||
; copy filename to the temp. place on the stack
|
||||
lda #0 ; end-of-string
|
||||
sta (sp),y ; Y still contains length + 1
|
||||
dey
|
||||
loop2: lda (ptr4),y
|
||||
sta (sp),y
|
||||
dey
|
||||
bpl loop2 ; bpl: this way we only support a max. length of 127
|
||||
|
||||
; uppercase the temp. filename
|
||||
ldx sp+1
|
||||
lda sp
|
||||
jsr _strupr
|
||||
|
||||
; leave X and Y pointing to the modified filename
|
||||
lda sp
|
||||
ldx sp+1
|
||||
|
||||
.endif ; defined UCASE_FILENAME
|
||||
|
||||
ldy tmp4
|
||||
|
||||
jsr newfd ; maybe we don't need to open and can reuse an iocb
|
||||
bcc noopen
|
||||
|
||||
sta ICBAL,y
|
||||
txa
|
||||
sta ICBAH,y
|
||||
ldx tmp4
|
||||
lda #OPEN
|
||||
sta ICCOM,x
|
||||
jsr CIOV
|
||||
|
||||
; clean up the stack
|
||||
|
||||
php
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
|
||||
.ifdef UCASE_FILENAME
|
||||
ldy tmp3 ; get size
|
||||
jsr addysp ; free used space on the stack
|
||||
.endif ; defined UCASE_FILENAME
|
||||
|
||||
jsr incsp4 ; clean up stack
|
||||
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
plp
|
||||
|
||||
bpl ok
|
||||
jmp __do_oserror
|
||||
|
||||
ok: txa
|
||||
lsr a
|
||||
lsr a
|
||||
lsr a
|
||||
lsr a
|
||||
ldx #0
|
||||
stx __oserror
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; find a free iocb
|
||||
; no entry parameters
|
||||
; return ZF = 0/1 for not found/found
|
||||
; index in X if found
|
||||
; all registers destroyed
|
||||
|
||||
.proc findfreeiocb
|
||||
|
||||
ldx #0
|
||||
ldy #$FF
|
||||
loop: tya
|
||||
cmp ICHID,x
|
||||
beq found
|
||||
txa
|
||||
clc
|
||||
adc #$10
|
||||
tax
|
||||
cmp #$80
|
||||
bcc loop
|
||||
inx ; return ZF cleared
|
||||
found: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; clear iocb except for ICHID field
|
||||
; expects X to be index to IOCB (0,$10,$20,etc.)
|
||||
; all registers destroyed
|
||||
|
||||
.proc clriocb
|
||||
|
||||
inx ; don't clear ICHID
|
||||
ldy #15
|
||||
lda #0
|
||||
loop: sta ICHID,x
|
||||
dey
|
||||
inx
|
||||
bne loop
|
||||
rts
|
||||
|
||||
.endproc
|
||||
85
libsrc/atari/oserror.s
Normal file
85
libsrc/atari/oserror.s
Normal file
@@ -0,0 +1,85 @@
|
||||
;
|
||||
; Christian Groessler, May-2000
|
||||
;
|
||||
; os specific error code mapping
|
||||
; int __fastcall__ _osmaperrno (unsigned char oserror);
|
||||
;
|
||||
|
||||
.include "../common/errno.inc"
|
||||
.export __osmaperrno
|
||||
|
||||
.proc __osmaperrno
|
||||
|
||||
cmp #$80 ; error or success
|
||||
bcs errcode ; error, jump
|
||||
|
||||
lda #0 ; no error, return 0
|
||||
tax
|
||||
rts
|
||||
|
||||
errcode:and #$7f ; create index from error number
|
||||
tax
|
||||
cpx #MAX_OSERR_VAL ; valid number?
|
||||
bcs inverr ; no
|
||||
|
||||
lda maptable,x
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
inverr: lda #<EUNKNOWN
|
||||
ldx #>EUNKNOWN
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
.rodata
|
||||
|
||||
maptable:
|
||||
.byte EINTR ;BRKABT = 128 ;($80) BREAK key abort
|
||||
.byte EBUSY ;PRVOPN = 129 ;($81) IOCB already open error
|
||||
.byte ENODEV ;NONDEV = 130 ;($82) nonexistent device error
|
||||
.byte EACCES ;WRONLY = 131 ;($83) IOCB opened for write only error
|
||||
.byte ENOSYS ;NVALID = 132 ;($84) invalid command error
|
||||
.byte EINVAL ;NOTOPN = 133 ;($85) device/file not open error
|
||||
.byte EINVAL ;BADIOC = 134 ;($86) invalid IOCB index error
|
||||
.byte EACCES ;RDONLY = 135 ;($87) IOCB opened for read only error
|
||||
.byte EINVAL ;EOFERR = 136 ;($88) end of file error (should never come,
|
||||
; specially handled by read.s)
|
||||
.byte EIO ;TRNRCD = 137 ;($89) truncated record error
|
||||
.byte EIO ;TIMOUT = 138 ;($8A) peripheral device timeout error
|
||||
.byte EIO ;DNACK = 139 ;($8B) device does not acknowledge command
|
||||
.byte EIO ;FRMERR = 140 ;($8C) serial bus framing error
|
||||
.byte EINVAL ;CRSROR = 141 ;($8D) cursor overrange error
|
||||
.byte EIO ;OVRRUN = 142 ;($8E) serial bus data overrun error
|
||||
.byte EIO ;CHKERR = 143 ;($8F) serial bus checksum error
|
||||
.byte EIO ;DERROR = 144 ;($90) device done (operation incomplete)
|
||||
.byte EINVAL ;BADMOD = 145 ;($91) bad screen mode number error
|
||||
.byte ENOSYS ;FNCNOT = 146 ;($92) function not implemented in handler
|
||||
.byte ENOMEM ;SCRMEM = 147 ;($93) insufficient memory for screen mode
|
||||
; codes below taken from "Mein Atari Computer" (german version of "Your Atari Computer")
|
||||
.byte EUNKNOWN ; 148 - haven't found documentation
|
||||
.byte EUNKNOWN ; 149 - haven't found documentation
|
||||
.byte EBUSY ; 150 - serial port already open
|
||||
.byte EACCES ; 151 - concurrent mode I/O not enabled (serial)
|
||||
.byte EINVAL ; 152 - invalid buffer address for concurrent mode
|
||||
.byte EAGAIN ; 153 - concurrent mode enabled (and another access tried)
|
||||
.byte EACCES ; 154 - concurrent mode I/O not active (serial)
|
||||
.byte EUNKNOWN ; 155 - haven't found documentation
|
||||
.byte EUNKNOWN ; 156 - haven't found documentation
|
||||
.byte EUNKNOWN ; 157 - haven't found documentation
|
||||
.byte EUNKNOWN ; 158 - haven't found documentation
|
||||
.byte EUNKNOWN ; 159 - haven't found documentation
|
||||
.byte ENOENT ; 160 - drive number error (DOS)
|
||||
.byte EMFILE ; 161 - too many open files
|
||||
.byte ENOSPC ; 162 - disk full
|
||||
.byte EIO ; 163 - unrecoverable system data I/O error
|
||||
.byte ESPIPE ; 164 - file number mismatch (inv. seek or disk data strucs damaged)
|
||||
.byte ENOENT ; 165 - invalid file name (e.g. lowercase)
|
||||
.byte ESPIPE ; 166 - point data length error
|
||||
.byte EACCES ; 167 - file locked (read-only)
|
||||
.byte ENOSYS ; 168 - command invalid
|
||||
.byte ENOSPC ; 169 - directory full
|
||||
.byte ENOENT ; 170 - file not found
|
||||
.byte ESPIPE ; 171 - point command invalid
|
||||
|
||||
MAX_OSERR_VAL = (* - maptable)
|
||||
33
libsrc/atari/read.s
Normal file
33
libsrc/atari/read.s
Normal file
@@ -0,0 +1,33 @@
|
||||
;
|
||||
; Christian Groessler, Apr-2000
|
||||
;
|
||||
; int read(int fd,void *buf,int count)
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.import __rwsetup,__do_oserror,__inviocb,__oserror
|
||||
.export _read
|
||||
|
||||
_read: jsr __rwsetup ; do common setup for read and write
|
||||
beq done ; if size 0, it's a no-op
|
||||
cpx #$FF ; invalid iocb?
|
||||
beq _inviocb
|
||||
lda #GETCHR ; iocb command code
|
||||
sta ICCOM,x
|
||||
jsr CIOV ; read it
|
||||
bpl done
|
||||
cpy #EOFERR ; eof is treated specially
|
||||
beq done
|
||||
jmp __do_oserror ; update errno
|
||||
|
||||
done: lda ICBLL,x ; buf len lo
|
||||
pha ; save
|
||||
lda ICBLH,x ; get buf len hi
|
||||
tax ; to X
|
||||
lda #0
|
||||
sta __oserror ; clear system dependend error code
|
||||
pla ; get buf len lo
|
||||
rts
|
||||
|
||||
_inviocb:
|
||||
jmp __inviocb
|
||||
30
libsrc/atari/readjoy.s
Normal file
30
libsrc/atari/readjoy.s
Normal file
@@ -0,0 +1,30 @@
|
||||
;
|
||||
; Christian Groessler
|
||||
;
|
||||
; unsigned readjoy (unsigned char joy);
|
||||
;
|
||||
|
||||
.export _readjoy
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
|
||||
.proc _readjoy
|
||||
|
||||
and #3 ; fix joystick number
|
||||
tax ; Joystick number (0-3) into X
|
||||
|
||||
; Read joystick
|
||||
|
||||
lda STRIG0,x ; get button
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
ora STICK0,x ; add position information
|
||||
eor #$1F
|
||||
ldx #0 ; fix X
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
23
libsrc/atari/revers.s
Normal file
23
libsrc/atari/revers.s
Normal file
@@ -0,0 +1,23 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 07.08.1998
|
||||
;
|
||||
; unsigned char revers (unsigned char onoff);
|
||||
;
|
||||
.include "atari.inc"
|
||||
|
||||
.export _revers
|
||||
|
||||
_revers:
|
||||
ldx #$00 ; Assume revers off
|
||||
tay ; Test onoff
|
||||
beq L1 ; Jump if off
|
||||
ldx #$80 ; Load on value
|
||||
L1: ldy #$00 ; Assume old value is zero
|
||||
lda INVFLG ; Load old value
|
||||
stx INVFLG ; Set new value
|
||||
beq L2 ; Jump if old value zero
|
||||
iny ; Make old value = 1
|
||||
L2: ldx #$00 ; Load high byte of result
|
||||
tya ; Load low byte, set CC
|
||||
rts
|
||||
|
||||
77
libsrc/atari/rwcommon.s
Normal file
77
libsrc/atari/rwcommon.s
Normal file
@@ -0,0 +1,77 @@
|
||||
;
|
||||
; common iocb setup routine for read, write
|
||||
; expects parameters (int fd,void *buf,int count)
|
||||
;
|
||||
.include "atari.inc"
|
||||
.include "../common/errno.inc"
|
||||
.importzp tmp2,tmp3
|
||||
.import incsp6,ldaxysp
|
||||
.import __errno,__oserror
|
||||
.import fdtoiocb
|
||||
|
||||
.export __rwsetup
|
||||
|
||||
__rwsetup:
|
||||
|
||||
ldy #5
|
||||
jsr ldaxysp ; get fd
|
||||
jsr fdtoiocb ; convert to iocb
|
||||
bmi iocberr
|
||||
; asl a ; iocb # --> iocb index
|
||||
; asl a
|
||||
; asl a
|
||||
; asl a
|
||||
sta tmp3 ; save it
|
||||
ldy #1
|
||||
jsr ldaxysp ; get size
|
||||
php ; save cond codes, for zero-ness
|
||||
stx tmp2
|
||||
ldx tmp3 ; iocb
|
||||
cpx #$80 ; iocb must be 0...7
|
||||
bcs iocberr
|
||||
sta ICBLL,x
|
||||
lda tmp2 ; size hi
|
||||
sta ICBLH,x
|
||||
ldy #3 ; get buf addr (was 2 in orig. version)
|
||||
jsr ldaxysp
|
||||
stx tmp2
|
||||
ldx tmp3
|
||||
sta ICBAL,x
|
||||
lda tmp2
|
||||
sta ICBAH,x
|
||||
jsr incsp6 ; pop args
|
||||
plp
|
||||
rts
|
||||
|
||||
iocberr:jsr incsp6 ; pop args
|
||||
plp ; throw away
|
||||
ldx #$FF ; indicate error + clear ZF
|
||||
rts
|
||||
|
||||
|
||||
;
|
||||
; this routine updates errno. do a JMP here right after calling
|
||||
; CIOV. we expect status in Y.
|
||||
;
|
||||
.export __do_oserror,__seterrno,__inviocb
|
||||
__do_oserror:
|
||||
sty __oserror ; save os dependent error code
|
||||
retminus:
|
||||
lda #$FF
|
||||
tax ; return -1
|
||||
rts
|
||||
|
||||
__seterrno:
|
||||
sta __errno
|
||||
stx __errno+1
|
||||
rts
|
||||
|
||||
;
|
||||
; sets EINVAL error code and returns -1
|
||||
;
|
||||
|
||||
__inviocb:
|
||||
lda #<EINVAL
|
||||
ldx #>EINVAL
|
||||
jsr __seterrno
|
||||
jmp retminus ; return -1
|
||||
105
libsrc/atari/savevec.s
Normal file
105
libsrc/atari/savevec.s
Normal file
@@ -0,0 +1,105 @@
|
||||
;
|
||||
; save and restore system vectors
|
||||
; originally by Mark Keates
|
||||
;
|
||||
; void save_vecs(void);
|
||||
; void rest_vecs(void);
|
||||
;
|
||||
|
||||
.export _save_vecs,_rest_vecs
|
||||
.include "atari.inc"
|
||||
|
||||
.bss
|
||||
|
||||
old_dli: .res 2
|
||||
old_dlist: .res 2
|
||||
old_vbi: .res 2
|
||||
old_vbd: .res 2
|
||||
old_gra: .res 1
|
||||
old_dma: .res 1
|
||||
old_prior: .res 1
|
||||
old_cols: .res 8
|
||||
old_set: .res 1
|
||||
old_rmargin: .res 1 ; lmargin saved in startup code
|
||||
|
||||
.code
|
||||
|
||||
.proc _save_vecs
|
||||
|
||||
lda VDSLST
|
||||
sta old_dli
|
||||
lda VDSLST+1
|
||||
sta old_dli+1
|
||||
lda SDLSTL
|
||||
sta old_dlist
|
||||
lda SDLSTL+1
|
||||
sta old_dlist+1
|
||||
lda VVBLKI
|
||||
sta old_vbi
|
||||
lda VVBLKI+1
|
||||
sta old_vbi+1
|
||||
lda VVBLKD
|
||||
sta old_vbd
|
||||
lda VVBLKD+1
|
||||
sta old_vbd+1
|
||||
lda GRACTL
|
||||
sta old_gra
|
||||
lda SDMCTL
|
||||
sta old_dma
|
||||
lda GPRIOR
|
||||
sta old_prior
|
||||
lda CHBAS
|
||||
sta old_set
|
||||
lda RMARGN
|
||||
sta old_rmargin
|
||||
|
||||
ldy #7
|
||||
SETUP1:
|
||||
lda PCOLR0,y
|
||||
sta old_cols,y
|
||||
dey
|
||||
bpl SETUP1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
.proc _rest_vecs
|
||||
|
||||
lda #6
|
||||
ldx old_vbi+1
|
||||
ldy old_vbi
|
||||
jsr SETVBV
|
||||
lda #7
|
||||
ldx old_vbd+1
|
||||
ldy old_vbd
|
||||
jsr SETVBV
|
||||
lda old_dli
|
||||
sta VDSLST
|
||||
lda old_dli+1
|
||||
sta VDSLST+1
|
||||
lda old_dlist
|
||||
sta SDLSTL
|
||||
lda old_dlist+1
|
||||
sta SDLSTL+1
|
||||
lda old_gra
|
||||
sta GRACTL
|
||||
lda old_prior
|
||||
sta GPRIOR
|
||||
lda old_dma
|
||||
sta SDMCTL
|
||||
lda old_set
|
||||
sta CHBAS
|
||||
lda old_rmargin
|
||||
sta RMARGN
|
||||
lda #$FF
|
||||
sta CH
|
||||
ldy #7
|
||||
SETUP2:
|
||||
lda old_cols,Y
|
||||
sta PCOLR0,Y
|
||||
dey
|
||||
bpl SETUP2
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
27
libsrc/atari/where.s
Normal file
27
libsrc/atari/where.s
Normal file
@@ -0,0 +1,27 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; unsigned char wherex (void);
|
||||
; unsigned char wherey (void);
|
||||
|
||||
.export _wherex, _wherey
|
||||
.import plot
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
_wherex:
|
||||
sec
|
||||
jsr plot ; Get cursor position
|
||||
tya
|
||||
rts
|
||||
|
||||
_wherey:
|
||||
sec
|
||||
jsr plot ; Get cursor position
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
29
libsrc/atari/write.s
Normal file
29
libsrc/atari/write.s
Normal file
@@ -0,0 +1,29 @@
|
||||
;
|
||||
; write(iocb, buf, nbytes)->nbytes written
|
||||
;
|
||||
.include "atari.inc"
|
||||
.import __rwsetup,__do_oserror,__inviocb,__oserror
|
||||
.export _write
|
||||
_write:
|
||||
jsr __rwsetup ; do common setup
|
||||
beq write9 ; if size 0, it's a no-op
|
||||
cpx #$FF ; invalid iocb?
|
||||
beq _inviocb
|
||||
lda #PUTCHR
|
||||
sta ICCOM,x
|
||||
jsr CIOV
|
||||
bpl write9
|
||||
jmp __do_oserror ; update errno
|
||||
|
||||
write9:
|
||||
lda ICBLL,x ; get buf len lo
|
||||
pha
|
||||
lda ICBLH,x ; buf len hi
|
||||
tax
|
||||
lda #0
|
||||
sta __oserror ; clear system dependend error code
|
||||
pla
|
||||
rts
|
||||
|
||||
_inviocb:
|
||||
jmp __inviocb
|
||||
28
libsrc/c128/Makefile
Normal file
28
libsrc/c128/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# 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 = crt0.o conio.o kbhit.o clrscr.o cgetc.o readjoy.o\
|
||||
color.o cputc.o break.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
|
||||
|
||||
127
libsrc/c128/break.s
Normal file
127
libsrc/c128/break.s
Normal file
@@ -0,0 +1,127 @@
|
||||
;
|
||||
; 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
|
||||
.importzp ptr1
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
.bss
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
|
||||
oldvec: .res 2 ; Old vector
|
||||
|
||||
|
||||
.data
|
||||
uservec: jmp $FFFF ; Patched at runtime
|
||||
|
||||
.code
|
||||
|
||||
; Where will we put the break stub?
|
||||
stub_addr = $0E00 ; BASIC sprite area
|
||||
|
||||
|
||||
|
||||
; 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 L2 ; Jump if we installed the handler already
|
||||
|
||||
lda BRKVec
|
||||
sta oldvec
|
||||
lda BRKVec+1
|
||||
sta oldvec+1 ; Save the old vector
|
||||
|
||||
ldy #stub_size-1 ; Copy our stub into the low mem area
|
||||
L1: lda brk_stub,y
|
||||
sta stub_addr,y
|
||||
dey
|
||||
bpl L1
|
||||
|
||||
lda #<_reset_brk
|
||||
ldx #>_reset_brk
|
||||
jsr _atexit ; Install an exit handler
|
||||
|
||||
L2: lda #<stub_addr ; Set the break vector to our stub
|
||||
sta BRKVec
|
||||
lda #>stub_addr
|
||||
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
|
||||
|
||||
pla
|
||||
sta _brk_y
|
||||
pla
|
||||
sta _brk_x
|
||||
pla
|
||||
sta _brk_a
|
||||
pla
|
||||
and #$EF ; Clear break bit
|
||||
sta _brk_sr
|
||||
pla ; PC low
|
||||
sec
|
||||
sbc #2 ; Point to start of brk
|
||||
sta _brk_pc
|
||||
pla ; PC high
|
||||
sbc #0
|
||||
sta _brk_pc+1
|
||||
|
||||
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
|
||||
|
||||
|
||||
brk_stub:
|
||||
.org stub_addr
|
||||
pla ; Get original MMU value
|
||||
sta MMU_CR ; Re-enable our config
|
||||
jmp brk_handler ; Jump to the user handler
|
||||
.reloc
|
||||
|
||||
stub_size = * - brk_stub
|
||||
185
libsrc/c128/c128.inc
Normal file
185
libsrc/c128/c128.inc
Normal file
@@ -0,0 +1,185 @@
|
||||
;
|
||||
; C64 generic definitions. Stolen from Elite128
|
||||
;
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Zero page, Commodore stuff
|
||||
|
||||
ST = $90 ; IEC status byte
|
||||
|
||||
FNAM_LEN = $B7 ; Length of filename
|
||||
SECADR = $B9 ; Secondary address
|
||||
DEVNUM = $BA ; Device number
|
||||
FNAM_BANK = $C7 ; Bank for filename
|
||||
FNAM_LO = $BB ; Address of filename
|
||||
FNAM_HI = $BC
|
||||
KEY_COUNT = $D0 ; Number of keys in input buffer
|
||||
MODE = $D7 ; 40/80 column mode flag
|
||||
CURS_X = $EC ; Cursor column
|
||||
CURS_Y = $EB ; Cursor row
|
||||
SCREEN_PTR = $E0 ; Pointer to current char in text screen
|
||||
CRAM_PTR = $E2 ; Pointer to current char in color RAM
|
||||
|
||||
CHARCOLOR = $F1
|
||||
FKEY_COUNT = $D1 ; Characters for function key
|
||||
FKEY_LEN = $1000 ; Function key lengths
|
||||
FKEY_TEXT = $100A ; Function key texts
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Kernal routines
|
||||
|
||||
; Direct entries
|
||||
CURS_ON = $CD6F
|
||||
CURS_OFF = $CD9F
|
||||
CLRSCR = $C142
|
||||
KBDREAD = $C006
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Vectors
|
||||
|
||||
IRQVec = $0314
|
||||
BRKVec = $0316
|
||||
NMIVec = $0318
|
||||
KeyStoreVec = $033C
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: VIC
|
||||
|
||||
VIC = $D000
|
||||
VIC_SPR0_X = $D000
|
||||
VIC_SPR0_Y = $D001
|
||||
VIC_SPR1_X = $D002
|
||||
VIC_SPR1_Y = $D003
|
||||
VIC_SPR2_X = $D004
|
||||
VIC_SPR2_Y = $D005
|
||||
VIC_SPR3_X = $D006
|
||||
VIC_SPR3_Y = $D007
|
||||
VIC_SPR4_X = $D008
|
||||
VIC_SPR4_Y = $D009
|
||||
VIC_SPR5_X = $D00A
|
||||
VIC_SPR5_Y = $D00B
|
||||
VIC_SPR6_X = $D00C
|
||||
VIC_SPR6_Y = $D00D
|
||||
VIC_SPR7_X = $D00E
|
||||
VIC_SPR7_Y = $D00F
|
||||
VIC_SPR_HI_X = $D010
|
||||
VIC_SPR_ENA = $D015
|
||||
VIC_SPR_EXP_X = $D017
|
||||
VIC_SPR_EXP_Y = $D01D
|
||||
VIC_SPR_MCOLOR = $D01C
|
||||
VIC_SPR_BG_PRIO = $D01B
|
||||
|
||||
VIC_SPR_MCOLOR0 = $D025
|
||||
VIC_SPR_MCOLOR1 = $D026
|
||||
|
||||
VIC_SPR0_COLOR = $D027
|
||||
VIC_SPR1_COLOR = $D028
|
||||
VIC_SPR2_COLOR = $D029
|
||||
VIC_SPR3_COLOR = $D02A
|
||||
VIC_SPR4_COLOR = $D02B
|
||||
VIC_SPR5_COLOR = $D02C
|
||||
VIC_SPR6_COLOR = $D02D
|
||||
VIC_SPR7_COLOR = $D02E
|
||||
|
||||
VIC_CTRL1 = $D011
|
||||
VIC_CTRL2 = $D016
|
||||
|
||||
VIC_HLINE = $D012
|
||||
|
||||
VIC_VIDEO_ADR = $D018
|
||||
|
||||
VIC_IRR = $D019 ; Interrupt request register
|
||||
VIC_IMR = $D01A ; Interrupt mask register
|
||||
|
||||
VIC_BORDERCOLOR = $D020
|
||||
VIC_BG_COLOR0 = $D021
|
||||
VIC_BG_COLOR1 = $D022
|
||||
VIC_BG_COLOR2 = $D023
|
||||
VIC_BG_COLOR3 = $D024
|
||||
|
||||
; 128 stuff:
|
||||
VIC_KBD_128 = $D02F ; Extended kbd bits (visible in 64 mode)
|
||||
VIC_CLK_128 = $D030 ; Clock rate register (visible in 64 mode)
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: SID
|
||||
|
||||
SID = $D400
|
||||
SID_S1Lo = $D400
|
||||
SID_S1Hi = $D401
|
||||
SID_PB1Lo = $D402
|
||||
SID_PB1Hi = $D403
|
||||
SID_Ctl1 = $D404
|
||||
SID_AD1 = $D405
|
||||
SID_SUR1 = $D406
|
||||
|
||||
SID_S2Lo = $D407
|
||||
SID_S2Hi = $D408
|
||||
SID_PB2Lo = $D409
|
||||
SID_PB2Hi = $D40A
|
||||
SID_Ctl2 = $D40B
|
||||
SID_AD2 = $D40C
|
||||
SID_SUR2 = $D40D
|
||||
|
||||
SID_S3Lo = $D40E
|
||||
SID_S3Hi = $D40F
|
||||
SID_PB3Lo = $D410
|
||||
SID_PB3Hi = $D411
|
||||
SID_Ctl3 = $D412
|
||||
SID_AD3 = $D413
|
||||
SID_SUR3 = $D414
|
||||
|
||||
SID_FltLo = $D415
|
||||
SID_FltHi = $D416
|
||||
SID_FltCtl = $D417
|
||||
SID_Amp = $D418
|
||||
SID_ADConv1 = $D419
|
||||
SID_ADConv2 = $D41A
|
||||
SID_Noise = $D41B
|
||||
SID_Read3 = $D41C
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: VDC (128 only)
|
||||
|
||||
VDC_INDEX = $D600
|
||||
VDC_DATA = $D601
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: CIAs
|
||||
|
||||
CIA1 = $DC00
|
||||
CIA1_PRA = $DC00
|
||||
CIA1_PRB = $DC01
|
||||
CIA1_DDRA = $DC02
|
||||
CIA1_DDRB = $DC03
|
||||
CIA1_ICR = $DC0D
|
||||
CIA1_CRA = $DC0E
|
||||
CIA1_CRB = $DC0F
|
||||
|
||||
CIA2 = $DD00
|
||||
CIA2_PRA = $DD00
|
||||
CIA2_PRB = $DD01
|
||||
CIA2_DDRA = $DD02
|
||||
CIA2_DDRB = $DD03
|
||||
CIA2_ICR = $DD0D
|
||||
CIA2_CRA = $DD0E
|
||||
CIA2_CRB = $DD0F
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: MMU
|
||||
|
||||
MMU_CR = $FF00
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Super CPU
|
||||
|
||||
SCPU_VIC_Bank1 = $D075
|
||||
SCPU_Slow = $D07A
|
||||
SCPU_Fast = $D07B
|
||||
SCPU_EnableRegs = $D07E
|
||||
SCPU_DisableRegs= $D07F
|
||||
SCPU_Detect = $D0BC
|
||||
|
||||
|
||||
31
libsrc/c128/cgetc.s
Normal file
31
libsrc/c128/cgetc.s
Normal file
@@ -0,0 +1,31 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; char cgetc (void);
|
||||
;
|
||||
|
||||
.export _cgetc
|
||||
.import cursor
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L2 ; Jump if there are already chars waiting
|
||||
|
||||
; Switch on the cursor if needed
|
||||
|
||||
lda cursor
|
||||
beq L1
|
||||
jsr CURS_ON
|
||||
jmp L2
|
||||
L1: lda #$01
|
||||
jsr CURS_OFF
|
||||
L2: lda KEY_COUNT ; Check characters again
|
||||
beq L2
|
||||
jsr CURS_OFF ; Switch cursor off, if characters available
|
||||
|
||||
jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
14
libsrc/c128/clrscr.s
Normal file
14
libsrc/c128/clrscr.s
Normal file
@@ -0,0 +1,14 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
_clrscr = CLRSCR
|
||||
|
||||
|
||||
|
||||
33
libsrc/c128/color.s
Normal file
33
libsrc/c128/color.s
Normal file
@@ -0,0 +1,33 @@
|
||||
;
|
||||
; 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
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
_textcolor:
|
||||
ldx CHARCOLOR ; get old value
|
||||
sta CHARCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bgcolor:
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BG_COLOR0 ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bordercolor:
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BORDERCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
50
libsrc/c128/conio.s
Normal file
50
libsrc/c128/conio.s
Normal file
@@ -0,0 +1,50 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; Low level stuff for screen output/console input
|
||||
;
|
||||
|
||||
.export initconio, doneconio
|
||||
.exportzp CURS_X, CURS_Y
|
||||
.import xsize, ysize
|
||||
|
||||
.include "c128.inc"
|
||||
.include "../cbm/cbm.inc"
|
||||
|
||||
.bss
|
||||
keyvec: .res 2
|
||||
|
||||
|
||||
.code
|
||||
|
||||
initconio:
|
||||
jsr SCREEN
|
||||
inx
|
||||
stx xsize
|
||||
iny
|
||||
sty ysize
|
||||
|
||||
; Save the old vector
|
||||
|
||||
lda KeyStoreVec
|
||||
sta keyvec
|
||||
lda KeyStoreVec+1
|
||||
sta keyvec+1
|
||||
|
||||
; Set the new vector. I can only hope that this works for other C128
|
||||
; versions...
|
||||
|
||||
lda #<$C6B7
|
||||
ldx #>$C6B7
|
||||
|
||||
SetVec: sei
|
||||
sta KeyStoreVec
|
||||
stx KeyStoreVec+1
|
||||
cli
|
||||
rts
|
||||
|
||||
doneconio:
|
||||
lda keyvec
|
||||
ldx keyvec+1
|
||||
bne SetVec
|
||||
|
||||
105
libsrc/c128/cputc.s
Normal file
105
libsrc/c128/cputc.s
Normal file
@@ -0,0 +1,105 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export advance, newline, plot
|
||||
.import popa, _gotoxy
|
||||
.import xsize, revers
|
||||
|
||||
.include "c128.inc"
|
||||
.include "../cbm/cbm.inc"
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
_cputc: cmp #$0D ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta CURS_X
|
||||
beq plot ; Recalculate pointers
|
||||
|
||||
L1: cmp #$0A ; LF?
|
||||
bne L2
|
||||
ldy CURS_Y
|
||||
iny
|
||||
bne newline ; Recalculate pointers
|
||||
|
||||
; Printable char of some sort
|
||||
|
||||
L2: cmp #' '
|
||||
bcc cputdirect ; Other control char
|
||||
tay
|
||||
bmi L10
|
||||
cmp #$60
|
||||
bcc L3
|
||||
and #$DF
|
||||
bne cputdirect ; Branch always
|
||||
L3: and #$3F
|
||||
|
||||
cputdirect:
|
||||
jsr putchar ; Write the character to the screen
|
||||
|
||||
; Advance cursor position
|
||||
|
||||
advance:
|
||||
iny
|
||||
cpy xsize
|
||||
bne L9
|
||||
ldy #0 ; new line
|
||||
newline:
|
||||
clc
|
||||
lda xsize
|
||||
adc SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
bcc L4
|
||||
inc SCREEN_PTR+1
|
||||
L4: clc
|
||||
lda xsize
|
||||
adc CRAM_PTR
|
||||
sta CRAM_PTR
|
||||
bcc L5
|
||||
inc CRAM_PTR+1
|
||||
L5: inc CURS_Y
|
||||
L9: sty CURS_X
|
||||
rts
|
||||
|
||||
; Handle character if high bit set
|
||||
|
||||
L10: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L11
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L11: ora #$40
|
||||
bne cputdirect
|
||||
|
||||
|
||||
|
||||
; Set cursor position, calculate RAM pointers
|
||||
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
clc
|
||||
jmp PLOT ; Set the new cursor
|
||||
|
||||
|
||||
|
||||
; Write one character to the screen without doing anything else, return X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora revers ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
rts
|
||||
141
libsrc/c128/crt0.s
Normal file
141
libsrc/c128/crt0.s
Normal file
@@ -0,0 +1,141 @@
|
||||
;
|
||||
; Startup code for cc65 (C128 version)
|
||||
;
|
||||
; This must be the *first* file on the linker command line
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.import __hinit, initconio, doneconio, zerobss
|
||||
.import push0, doatexit, _main
|
||||
|
||||
.include "c128.inc"
|
||||
.include "../cbm/cbm.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
|
||||
|
||||
sp = $02 ; stack pointer
|
||||
sreg = $04 ; secondary register/high 16 bit for longs
|
||||
regsave = $06 ; slot to save/restore (E)AX into
|
||||
ptr1 = $0A ;
|
||||
ptr2 = $0C
|
||||
ptr3 = $0E
|
||||
ptr4 = $10
|
||||
tmp1 = $12
|
||||
tmp2 = $13
|
||||
tmp3 = $14
|
||||
tmp4 = $15
|
||||
regbank = $16 ; 6 byte register bank
|
||||
zpspace = $1A ; Zero page space allocated
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; BASIC header with a SYS call
|
||||
|
||||
.org $1BFF
|
||||
.word Head ; Load address
|
||||
Head: .word @Next
|
||||
.word 1000 ; Line number
|
||||
.byte $9E,"7181" ; SYS 7181
|
||||
.byte $00 ; End of BASIC line
|
||||
@Next: .word 0 ; BASIC end marker
|
||||
.reloc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Actual code
|
||||
|
||||
ldy #zpspace-1
|
||||
L1: lda sp,y
|
||||
sta zpsave,y ; save the zero page locations we need
|
||||
dey
|
||||
bpl L1
|
||||
|
||||
; Close open files
|
||||
|
||||
jsr CLRCH
|
||||
|
||||
; Switch to second charset
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Get the current MMU setting and save it. Set new memory config.
|
||||
|
||||
lda MMU_CR ; Get current memory configuration...
|
||||
pha ; ...and save it for later
|
||||
lda #$0E ; Bank0 with kernal ROM
|
||||
sta MMU_CR
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
|
||||
; Save system stuff and setup the stack
|
||||
|
||||
pla ; Get MMU setting
|
||||
sta mmusave
|
||||
|
||||
tsx
|
||||
stx spsave ; save system stk ptr
|
||||
|
||||
lda #<$C000
|
||||
sta sp
|
||||
lda #>$C000
|
||||
sta sp+1
|
||||
|
||||
; Initialize the heap
|
||||
|
||||
jsr __hinit
|
||||
|
||||
; Initialize conio stuff
|
||||
|
||||
jsr initconio
|
||||
|
||||
; 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: jsr doatexit ; call exit functions
|
||||
|
||||
; Reset the conio stuff
|
||||
|
||||
jsr doneconio
|
||||
|
||||
; Reset stack and the MMU
|
||||
|
||||
ldx spsave ; Patched at runtime
|
||||
txs
|
||||
lda mmusave ; Patched at runtime
|
||||
sta MMU_CR
|
||||
|
||||
; Copy back the zero page stuff
|
||||
|
||||
ldy #zpspace-1
|
||||
L2: lda zpsave,y
|
||||
sta sp,y
|
||||
dey
|
||||
bpl L2
|
||||
|
||||
; Done
|
||||
|
||||
jmp RESTOR
|
||||
|
||||
.data
|
||||
zpsave: .res zpspace
|
||||
|
||||
.bss
|
||||
spsave: .res 1
|
||||
mmusave:.res 1
|
||||
|
||||
|
||||
|
||||
24
libsrc/c128/dbgbreak.s
Normal file
24
libsrc/c128/dbgbreak.s
Normal file
@@ -0,0 +1,24 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 10.08.1998
|
||||
;
|
||||
; unsigned DbgSetBreakVec (unsigned Addr);
|
||||
;
|
||||
|
||||
.export _DbgSetBreakVec
|
||||
.import popax, utstax
|
||||
|
||||
.include "../cbm/cbm.inc"
|
||||
|
||||
_DbgSetBreakVec:
|
||||
jsr popax ; Get the new address
|
||||
ldy BRKVec
|
||||
sta BRKVec
|
||||
lda BRKVec+1
|
||||
stx BRKVec+1
|
||||
tax
|
||||
tya
|
||||
jmp utstax
|
||||
|
||||
|
||||
|
||||
|
||||
21
libsrc/c128/kbhit.s
Normal file
21
libsrc/c128/kbhit.s
Normal file
@@ -0,0 +1,21 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 18.08.1998
|
||||
;
|
||||
; int kbhit (void);
|
||||
;
|
||||
|
||||
.export _kbhit
|
||||
.import return0, return1
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
_kbhit:
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
; ora FKEY_COUNT ; Or with number of chars from function keys
|
||||
bne L1
|
||||
jmp return0
|
||||
L1: jmp return1
|
||||
|
||||
|
||||
|
||||
|
||||
41
libsrc/c128/readjoy.s
Normal file
41
libsrc/c128/readjoy.s
Normal file
@@ -0,0 +1,41 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 23.09.1998
|
||||
;
|
||||
; unsigned readjoy (unsigned char joy);
|
||||
;
|
||||
|
||||
.export _readjoy
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
.proc _readjoy
|
||||
|
||||
tax ; Joystick number into X
|
||||
bne joy2
|
||||
|
||||
; Read joystick 1
|
||||
|
||||
joy1: lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 2
|
||||
|
||||
joy2: ldx #0
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
28
libsrc/c64/Makefile
Normal file
28
libsrc/c64/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# 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 = crt0.o read.o write.o kbhit.o conio.o clrscr.o mouse.o\
|
||||
cputc.o cgetc.o color.o readjoy.o break.o rs232.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
|
||||
|
||||
108
libsrc/c64/break.s
Normal file
108
libsrc/c64/break.s
Normal file
@@ -0,0 +1,108 @@
|
||||
;
|
||||
; 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 "c64.inc"
|
||||
|
||||
|
||||
.bss
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
|
||||
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
|
||||
|
||||
pla
|
||||
sta _brk_y
|
||||
pla
|
||||
sta _brk_x
|
||||
pla
|
||||
sta _brk_a
|
||||
pla
|
||||
and #$EF ; Clear break bit
|
||||
sta _brk_sr
|
||||
pla ; PC low
|
||||
sec
|
||||
sbc #2 ; Point to start of brk
|
||||
sta _brk_pc
|
||||
pla ; PC high
|
||||
sbc #0
|
||||
sta _brk_pc+1
|
||||
|
||||
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
|
||||
|
||||
|
||||
194
libsrc/c64/c64.inc
Normal file
194
libsrc/c64/c64.inc
Normal file
@@ -0,0 +1,194 @@
|
||||
;
|
||||
; C64 generic definitions. Stolen from Elite128
|
||||
;
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Zero page, Commodore stuff
|
||||
|
||||
ST = $90 ; IEC status byte
|
||||
|
||||
FNAM_LEN = $B7 ; Length of filename
|
||||
SECADR = $B9 ; Secondary address
|
||||
DEVNUM = $BA ; Device number
|
||||
KEY_COUNT = $C6 ; Number of keys in input buffer
|
||||
CURS_FLAG = $CC ; 1 = cursor off
|
||||
CURS_BLINK = $CD ; Blink counter
|
||||
CURS_CHAR = $CE ; Character under the cursor
|
||||
CURS_COLOR = $287 ; Color under the cursor
|
||||
CURS_STATE = $CF ; Cursor blink state
|
||||
SCREEN_PTR = $D1 ; Pointer to current char in text screen
|
||||
CURS_X = $D3 ; Cursor column
|
||||
CURS_Y = $D6 ; Cursor row
|
||||
CRAM_PTR = $F3 ; Pointer to current char in color RAM
|
||||
|
||||
CHARCOLOR = $286
|
||||
PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Kernal routines
|
||||
|
||||
; Direct entries
|
||||
CLRSCR = $E544
|
||||
KBDREAD = $E5B4
|
||||
NAMED_OPEN = $F3D5
|
||||
NAMED_CLOSE = $F642
|
||||
PLOTCHAR = $EA1C ; Char in A, color in X
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Vector and other locations
|
||||
|
||||
IRQVec = $0314
|
||||
BRKVec = $0316
|
||||
NMIVec = $0318
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: VIC
|
||||
|
||||
VIC = $D000
|
||||
VIC_SPR0_X = $D000
|
||||
VIC_SPR0_Y = $D001
|
||||
VIC_SPR1_X = $D002
|
||||
VIC_SPR1_Y = $D003
|
||||
VIC_SPR2_X = $D004
|
||||
VIC_SPR2_Y = $D005
|
||||
VIC_SPR3_X = $D006
|
||||
VIC_SPR3_Y = $D007
|
||||
VIC_SPR4_X = $D008
|
||||
VIC_SPR4_Y = $D009
|
||||
VIC_SPR5_X = $D00A
|
||||
VIC_SPR5_Y = $D00B
|
||||
VIC_SPR6_X = $D00C
|
||||
VIC_SPR6_Y = $D00D
|
||||
VIC_SPR7_X = $D00E
|
||||
VIC_SPR7_Y = $D00F
|
||||
VIC_SPR_HI_X = $D010
|
||||
VIC_SPR_ENA = $D015
|
||||
VIC_SPR_EXP_X = $D017
|
||||
VIC_SPR_EXP_Y = $D01D
|
||||
VIC_SPR_MCOLOR = $D01C
|
||||
VIC_SPR_BG_PRIO = $D01B
|
||||
|
||||
VIC_SPR_MCOLOR0 = $D025
|
||||
VIC_SPR_MCOLOR1 = $D026
|
||||
|
||||
VIC_SPR0_COLOR = $D027
|
||||
VIC_SPR1_COLOR = $D028
|
||||
VIC_SPR2_COLOR = $D029
|
||||
VIC_SPR3_COLOR = $D02A
|
||||
VIC_SPR4_COLOR = $D02B
|
||||
VIC_SPR5_COLOR = $D02C
|
||||
VIC_SPR6_COLOR = $D02D
|
||||
VIC_SPR7_COLOR = $D02E
|
||||
|
||||
VIC_CTRL1 = $D011
|
||||
VIC_CTRL2 = $D016
|
||||
|
||||
VIC_HLINE = $D012
|
||||
|
||||
VIC_VIDEO_ADR = $D018
|
||||
|
||||
VIC_IRR = $D019 ; Interrupt request register
|
||||
VIC_IMR = $D01A ; Interrupt mask register
|
||||
|
||||
VIC_BORDERCOLOR = $D020
|
||||
VIC_BG_COLOR0 = $D021
|
||||
VIC_BG_COLOR1 = $D022
|
||||
VIC_BG_COLOR2 = $D023
|
||||
VIC_BG_COLOR3 = $D024
|
||||
|
||||
; 128 stuff:
|
||||
VIC_KBD_128 = $D02F ; Extended kbd bits (visible in 64 mode)
|
||||
VIC_CLK_128 = $D030 ; Clock rate register (visible in 64 mode)
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: SID
|
||||
|
||||
SID = $D400
|
||||
SID_S1Lo = $D400
|
||||
SID_S1Hi = $D401
|
||||
SID_PB1Lo = $D402
|
||||
SID_PB1Hi = $D403
|
||||
SID_Ctl1 = $D404
|
||||
SID_AD1 = $D405
|
||||
SID_SUR1 = $D406
|
||||
|
||||
SID_S2Lo = $D407
|
||||
SID_S2Hi = $D408
|
||||
SID_PB2Lo = $D409
|
||||
SID_PB2Hi = $D40A
|
||||
SID_Ctl2 = $D40B
|
||||
SID_AD2 = $D40C
|
||||
SID_SUR2 = $D40D
|
||||
|
||||
SID_S3Lo = $D40E
|
||||
SID_S3Hi = $D40F
|
||||
SID_PB3Lo = $D410
|
||||
SID_PB3Hi = $D411
|
||||
SID_Ctl3 = $D412
|
||||
SID_AD3 = $D413
|
||||
SID_SUR3 = $D414
|
||||
|
||||
SID_FltLo = $D415
|
||||
SID_FltHi = $D416
|
||||
SID_FltCtl = $D417
|
||||
SID_Amp = $D418
|
||||
SID_ADConv1 = $D419
|
||||
SID_ADConv2 = $D41A
|
||||
SID_Noise = $D41B
|
||||
SID_Read3 = $D41C
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: VDC (128 only)
|
||||
|
||||
VDC_INDEX = $D600
|
||||
VDC_DATA = $D601
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; I/O: CIAs
|
||||
|
||||
CIA1 = $DC00
|
||||
CIA1_PRA = $DC00
|
||||
CIA1_PRB = $DC01
|
||||
CIA1_DDRA = $DC02
|
||||
CIA1_DDRB = $DC03
|
||||
CIA1_ICR = $DC0D
|
||||
CIA1_CRA = $DC0E
|
||||
CIA1_CRB = $DC0F
|
||||
|
||||
CIA2 = $DD00
|
||||
CIA2_PRA = $DD00
|
||||
CIA2_PRB = $DD01
|
||||
CIA2_DDRA = $DD02
|
||||
CIA2_DDRB = $DD03
|
||||
CIA2_ICR = $DD0D
|
||||
CIA2_CRA = $DD0E
|
||||
CIA2_CRB = $DD0F
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Super CPU
|
||||
|
||||
SCPU_VIC_Bank1 = $D075
|
||||
SCPU_Slow = $D07A
|
||||
SCPU_Fast = $D07B
|
||||
SCPU_EnableRegs = $D07E
|
||||
SCPU_DisableRegs= $D07F
|
||||
SCPU_Detect = $D0BC
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Processor Port at $01
|
||||
|
||||
LORAM = $01 ; Enable the basic rom
|
||||
HIRAM = $02 ; Enable the kernal rom
|
||||
IOEN = $04 ; Enable I/O
|
||||
CASSDATA = $08 ; Cassette data
|
||||
CASSPLAY = $10 ; Cassette: Play
|
||||
CASSMOT = $20 ; Cassette motor on
|
||||
TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
|
||||
|
||||
RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF
|
||||
|
||||
|
||||
61
libsrc/c64/cgetc.s
Normal file
61
libsrc/c64/cgetc.s
Normal file
@@ -0,0 +1,61 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; char cgetc (void);
|
||||
;
|
||||
|
||||
.export _cgetc
|
||||
.import cursor
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L3 ; Jump if there are already chars waiting
|
||||
|
||||
; Switch on the cursor if needed
|
||||
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda KEY_COUNT
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
|
||||
L3: jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
; Switch the cursor on or off
|
||||
|
||||
.proc setcursor
|
||||
|
||||
tax ; On or off?
|
||||
bne seton ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne crs9 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
beq crs8 ; Jump if no
|
||||
ldy CURS_X ; Get the character column
|
||||
lda (SCREEN_PTR),y ; Get character
|
||||
eor #$80
|
||||
sta (SCREEN_PTR),y ; Store character back
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store color back
|
||||
crs8: lda #0
|
||||
sta CURS_STATE ; Cursor not displayed
|
||||
crs9: rts
|
||||
|
||||
seton: lda #0
|
||||
sta CURS_FLAG
|
||||
rts
|
||||
|
||||
.endproc
|
||||
14
libsrc/c64/clrscr.s
Normal file
14
libsrc/c64/clrscr.s
Normal file
@@ -0,0 +1,14 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_clrscr = CLRSCR
|
||||
|
||||
|
||||
|
||||
33
libsrc/c64/color.s
Normal file
33
libsrc/c64/color.s
Normal file
@@ -0,0 +1,33 @@
|
||||
;
|
||||
; 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
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_textcolor:
|
||||
ldx CHARCOLOR ; get old value
|
||||
sta CHARCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bgcolor:
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BG_COLOR0 ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bordercolor:
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BORDERCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
23
libsrc/c64/conio.s
Normal file
23
libsrc/c64/conio.s
Normal file
@@ -0,0 +1,23 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; Low level stuff for screen output/console input
|
||||
;
|
||||
|
||||
.export initconio
|
||||
.exportzp CURS_X, CURS_Y
|
||||
.import xsize, ysize
|
||||
|
||||
.include "../cbm/cbm.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
.code
|
||||
|
||||
initconio:
|
||||
jsr SCREEN
|
||||
stx xsize
|
||||
sty ysize
|
||||
rts
|
||||
|
||||
|
||||
|
||||
105
libsrc/c64/cputc.s
Normal file
105
libsrc/c64/cputc.s
Normal file
@@ -0,0 +1,105 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export advance, newline, plot
|
||||
.import popa, _gotoxy
|
||||
.import xsize, revers
|
||||
|
||||
.include "c64.inc"
|
||||
.include "../cbm/cbm.inc"
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
_cputc: cmp #$0D ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta CURS_X
|
||||
beq plot ; Recalculate pointers
|
||||
|
||||
L1: cmp #$0A ; LF?
|
||||
bne L2
|
||||
ldy CURS_Y
|
||||
iny
|
||||
bne newline ; Recalculate pointers
|
||||
|
||||
; Printable char of some sort
|
||||
|
||||
L2: cmp #' '
|
||||
bcc cputdirect ; Other control char
|
||||
tay
|
||||
bmi L10
|
||||
cmp #$60
|
||||
bcc L3
|
||||
and #$DF
|
||||
bne cputdirect ; Branch always
|
||||
L3: and #$3F
|
||||
|
||||
cputdirect:
|
||||
jsr putchar ; Write the character to the screen
|
||||
|
||||
; Advance cursor position
|
||||
|
||||
advance:
|
||||
iny
|
||||
cpy xsize
|
||||
bne L9
|
||||
ldy #0 ; new line
|
||||
newline:
|
||||
clc
|
||||
lda xsize
|
||||
adc SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
bcc L4
|
||||
inc SCREEN_PTR+1
|
||||
L4: clc
|
||||
lda xsize
|
||||
adc CRAM_PTR
|
||||
sta CRAM_PTR
|
||||
bcc L5
|
||||
inc CRAM_PTR+1
|
||||
L5: inc CURS_Y
|
||||
L9: sty CURS_X
|
||||
rts
|
||||
|
||||
; Handle character if high bit set
|
||||
|
||||
L10: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L11
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L11: ora #$40
|
||||
bne cputdirect
|
||||
|
||||
|
||||
|
||||
; Set cursor position, calculate RAM pointers
|
||||
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
clc
|
||||
jmp PLOT ; Set the new cursor
|
||||
|
||||
|
||||
|
||||
; Write one character to the screen without doing anything else, return X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora revers ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
rts
|
||||
132
libsrc/c64/crt0.s
Normal file
132
libsrc/c64/crt0.s
Normal file
@@ -0,0 +1,132 @@
|
||||
;
|
||||
; Startup code for cc65 (C64 version)
|
||||
;
|
||||
; This must be the *first* file on the linker command line
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.import __hinit, initconio, zerobss, push0, doatexit
|
||||
.import _main
|
||||
|
||||
.include "c64.inc"
|
||||
.include "../cbm/cbm.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
|
||||
|
||||
sp = $02 ; stack pointer
|
||||
sreg = $04 ; secondary register/high 16 bit for longs
|
||||
regsave = $06 ; slot to save/restore (E)AX into
|
||||
ptr1 = $0A ;
|
||||
ptr2 = $0C
|
||||
ptr3 = $0E
|
||||
ptr4 = $10
|
||||
tmp1 = $12
|
||||
tmp2 = $13
|
||||
tmp3 = $14
|
||||
tmp4 = $15
|
||||
regbank = $16 ; 6 byte register bank
|
||||
zpspace = $1A ; Zero page space allocated
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; BASIC header with a SYS call
|
||||
|
||||
.org $7FF
|
||||
.word Head ; Load address
|
||||
Head: .word @Next
|
||||
.word 1000 ; Line number
|
||||
.byte $9E,"2061" ; SYS 2061
|
||||
.byte $00 ; End of BASIC line
|
||||
@Next: .word 0 ; BASIC end marker
|
||||
.reloc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Actual code
|
||||
|
||||
ldy #zpspace-1
|
||||
L1: lda sp,y
|
||||
sta zpsave,y ; Save the zero page locations we need
|
||||
dey
|
||||
bpl L1
|
||||
|
||||
; Close open files
|
||||
|
||||
jsr CLRCH
|
||||
|
||||
; Switch to second charset
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
|
||||
; Save system stuff and setup the stack
|
||||
|
||||
tsx
|
||||
stx spsave ; Save the system stack ptr
|
||||
|
||||
lda $01
|
||||
sta mmusave ; Save the memory configuration
|
||||
lda $01
|
||||
and #$F8
|
||||
ora #$06 ; Enable kernal+I/O, disable basic
|
||||
sta $01
|
||||
|
||||
lda #<$D000
|
||||
sta sp
|
||||
lda #>$D000
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
|
||||
; Initialize the heap
|
||||
|
||||
jsr __hinit
|
||||
|
||||
; Initialize conio stuff
|
||||
|
||||
jsr initconio
|
||||
|
||||
; 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: jsr doatexit ; call exit functions
|
||||
|
||||
ldx spsave
|
||||
txs ; Restore stack pointer
|
||||
lda mmusave
|
||||
sta $01 ; Restore memory configuration
|
||||
|
||||
; 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
|
||||
mmusave:.res 1
|
||||
20
libsrc/c64/kbhit.s
Normal file
20
libsrc/c64/kbhit.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; int kbhit (void);
|
||||
;
|
||||
|
||||
.export _kbhit
|
||||
.import return0, return1
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_kbhit:
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
bne L1
|
||||
jmp return0
|
||||
L1: jmp return1
|
||||
|
||||
|
||||
|
||||
|
||||
384
libsrc/c64/mouse.s
Normal file
384
libsrc/c64/mouse.s
Normal file
@@ -0,0 +1,384 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 24.04.1999
|
||||
;
|
||||
; Routines for the 1351 proportional mouse. Parts of the code are from
|
||||
; the Commodore 1351 mouse users guide.
|
||||
;
|
||||
|
||||
.export _mouse_init, _mouse_done
|
||||
.export _mouse_hide, _mouse_show
|
||||
.export _mouse_box, _mouse_info
|
||||
.export _mouse_move
|
||||
|
||||
.import popa, popsreg, addysp1
|
||||
.importzp sp, sreg
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
.code
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void __fastcall__ mouse_init (unsigned char port, unsigned char sprite);
|
||||
;
|
||||
|
||||
_mouse_init:
|
||||
tax ; Save sprite number
|
||||
jsr popa ; Get the port number
|
||||
|
||||
ldy OldIRQ+1 ; Already initialized?
|
||||
bne Done ; Jump if yes
|
||||
|
||||
stx MouseSprite ; Remember the sprite number
|
||||
sta MousePort ; Remember the port number
|
||||
|
||||
; Initialize variables
|
||||
|
||||
ldx #0
|
||||
stx XPos
|
||||
stx XPos+1
|
||||
stx YPos
|
||||
stx YPos+1
|
||||
stx OldPotX
|
||||
stx OldPotY
|
||||
stx XMin
|
||||
stx XMin+1
|
||||
stx YMin
|
||||
stx YMin+1
|
||||
stx YMax+1
|
||||
inx ; X = 1
|
||||
stx Visible ; Mouse *not* visible
|
||||
stx XMax+1 ; >320
|
||||
ldx #<320
|
||||
stx XMax
|
||||
ldx #200
|
||||
stx YMax
|
||||
|
||||
; Remember the old IRQ vector
|
||||
|
||||
lda IRQVec
|
||||
sta OldIRQ
|
||||
lda IRQVec+1
|
||||
sta OldIRQ+1
|
||||
|
||||
; Set our own IRQ vector
|
||||
|
||||
lda #<MouseIRQ
|
||||
ldx #>MouseIRQ
|
||||
bne SetIRQ
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void mouse_done (void);
|
||||
;
|
||||
|
||||
_mouse_done:
|
||||
lda OldIRQ ; Initialized?
|
||||
ldx OldIRQ+1
|
||||
beq Done ; Jump if no
|
||||
ldy #0
|
||||
sty OldIRQ+1 ; Reset the initialized flag
|
||||
SetIRQ: sei ; Disable interrupts
|
||||
sta IRQVec ; Set the new/old vector
|
||||
stx IRQVec+1
|
||||
cli ; Enable interrupts
|
||||
Done: rts
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void mouse_hide (void);
|
||||
;
|
||||
|
||||
_mouse_hide:
|
||||
lda Visible ; Get the flag
|
||||
bne @L1 ; Jump if already invisible
|
||||
ldx MouseSprite ; Sprite defined?
|
||||
beq @L1 ; Jump if no
|
||||
|
||||
lda BitMask-1,x ; Get bit mask
|
||||
eor #$FF ; We must clear the bit
|
||||
|
||||
sei ; Disable interrupts
|
||||
and VIC_SPR_ENA
|
||||
sta VIC_SPR_ENA ; Disable sprite
|
||||
cli ; Enable interrupts
|
||||
|
||||
@L1: inc Visible ; Set the flag to invisible
|
||||
rts
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void mouse_show (void);
|
||||
;
|
||||
|
||||
_mouse_show:
|
||||
dec Visible ; Get the flag
|
||||
bne @L1 ; Jump if still invisible
|
||||
ldx MouseSprite ; Sprite defined?
|
||||
beq @L1 ; Jump if no
|
||||
|
||||
lda BitMask-1,x ; Get bit mask
|
||||
sei ; Disable interrupts
|
||||
ora VIC_SPR_ENA
|
||||
sta VIC_SPR_ENA ; Enable sprite
|
||||
cli ; Enable interrupts
|
||||
|
||||
@L1: rts
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
|
||||
;
|
||||
|
||||
_mouse_box:
|
||||
sei ; Disable interrupts
|
||||
|
||||
sta YMax
|
||||
stx YMax+1 ; maxy
|
||||
|
||||
ldy #0
|
||||
lda (sp),y
|
||||
sta XMax
|
||||
iny
|
||||
lda (sp),y
|
||||
sta XMax+1 ; maxx
|
||||
|
||||
iny
|
||||
lda (sp),y
|
||||
sta YMin
|
||||
iny
|
||||
lda (sp),y
|
||||
sta YMin+1 ; miny
|
||||
|
||||
iny
|
||||
lda (sp),y
|
||||
sta XMin
|
||||
iny
|
||||
lda (sp),y
|
||||
sta XMin+1 ; minx
|
||||
|
||||
cli ; Enable interrupts
|
||||
|
||||
jmp addysp1 ; Drop params, return
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void mouse_info (...);
|
||||
;
|
||||
|
||||
_mouse_info:
|
||||
rts
|
||||
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; void __fastcall__ mouse_move (int x, int y);
|
||||
;
|
||||
|
||||
_mouse_move:
|
||||
jsr popsreg ; Get X
|
||||
sei ; Disable interrupts
|
||||
|
||||
sta YPos
|
||||
stx YPos+1
|
||||
lda sreg
|
||||
ldx sreg+1
|
||||
sta XPos
|
||||
stx XPos+1 ; Set new position
|
||||
|
||||
lda Visible ; Mouse visible?
|
||||
bne @L9 ; Jump if no
|
||||
lda MouseSprite ; Sprite defined?
|
||||
beq @L9
|
||||
|
||||
jsr MoveSprite ; Move the sprite to the mouse pos
|
||||
|
||||
@L9: cli ; Enable interrupts
|
||||
rts
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Mouse interrupt handler
|
||||
;
|
||||
|
||||
MouseIRQ:
|
||||
cld
|
||||
lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
sty OldPotX
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
clc
|
||||
adc XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin+1
|
||||
bne @L1
|
||||
cmp XMin
|
||||
@L1: bpl @L2
|
||||
ldy XMin
|
||||
lda XMin+1
|
||||
jmp @L4
|
||||
|
||||
@L2: cpy XMax+1
|
||||
bne @L3
|
||||
cmp XMax
|
||||
beq @L4
|
||||
@L3: bmi @L4
|
||||
ldy XMax
|
||||
lda XMax+1
|
||||
@L4: sty XPos
|
||||
sta XPos+1
|
||||
|
||||
; Calculate the Y movement vector
|
||||
|
||||
lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
sty OldPotY
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
clc
|
||||
adc YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin+1
|
||||
bne @L5
|
||||
cmp YMin
|
||||
@L5: bpl @L6
|
||||
ldy YMin
|
||||
lda YMin+1
|
||||
jmp @L8
|
||||
|
||||
@L6: cpy YMax+1
|
||||
bne @L7
|
||||
cmp YMax
|
||||
beq @L8
|
||||
@L7: bmi @L8
|
||||
ldy YMax
|
||||
lda YMax+1
|
||||
@L8: sty YPos
|
||||
sta YPos+1
|
||||
|
||||
; Jump to the next IRQ handler
|
||||
|
||||
jmp (OldIRQ)
|
||||
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Move check routine, called for both coordinates.
|
||||
;
|
||||
; Entry: y = old value of pot register
|
||||
; a = current value of pot register
|
||||
; Exit: y = value to use for old value
|
||||
; x/a = delta value for position
|
||||
;
|
||||
|
||||
MoveCheck:
|
||||
sty OldValue
|
||||
sta NewValue
|
||||
ldx #$00
|
||||
|
||||
sec ; a = mod64 (new - old)
|
||||
sbc OldValue
|
||||
and #%01111111
|
||||
cmp #%01000000 ; if (a > 0)
|
||||
bcs @L1 ;
|
||||
lsr a ; a /= 2;
|
||||
beq @L2 ; if (a != 0)
|
||||
ldy NewValue ; y = NewValue
|
||||
rts ; return
|
||||
|
||||
@L1: ora #%11000000 ; else or in high order bits
|
||||
cmp #$FF ; if (a != -1)
|
||||
beq @L2
|
||||
sec
|
||||
ror a ; a /= 2
|
||||
ldx #$FF ; high byte = -1
|
||||
ldy NewValue
|
||||
rts
|
||||
|
||||
@L2: lda #0
|
||||
rts
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
;
|
||||
; Move the mouse sprite to the current mouse position. Must be called
|
||||
; with interrupts off.
|
||||
;
|
||||
|
||||
MoveSprite:
|
||||
lda Visible ; Mouse pointer visible?
|
||||
bne @L9 ; Jump if no
|
||||
ldx MouseSprite ; Sprite defined?
|
||||
beq @L9 ; Jump if no
|
||||
ldy BitMask-1,x ; Get high bit mask
|
||||
txa
|
||||
asl a ; Index*2
|
||||
tax
|
||||
|
||||
; Set the X position
|
||||
|
||||
lda XPos+1 ; Negative?
|
||||
bmi @L2 ; Jump if yes
|
||||
beq @L1
|
||||
tya ; Load high position bit
|
||||
@L1: ora VIC_SPR_HI_X ; Set high bit
|
||||
sta VIC_SPR_HI_X
|
||||
lda XPos
|
||||
sta VIC_SPR0_X,x ; Set low byte
|
||||
|
||||
; Set the Y position
|
||||
|
||||
@L2: ldy YPos+1 ; Negative or too large?
|
||||
bne @L9 ; Jump if yes
|
||||
lda YPos
|
||||
sta VIC_SPR0_Y,x ; Set Y position
|
||||
|
||||
; Done
|
||||
|
||||
@L9: rts
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Data
|
||||
|
||||
.bss
|
||||
|
||||
OldIRQ: .res 2 ; Old IRQ vector
|
||||
MousePort: .res 1 ; Port used for the mouse
|
||||
MouseSprite: .res 1 ; Number of sprite to control
|
||||
OldValue: .res 1 ; Temp for MoveCheck routine
|
||||
NewValue: .res 1 ; Temp for MoveCheck routine
|
||||
|
||||
Visible: .res 1 ; Is the mouse visible?
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
|
||||
.data
|
||||
|
||||
BitMask: .byte $01, $02, $04, $08, $10, $20, $40, $80
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
48
libsrc/c64/read.s
Normal file
48
libsrc/c64/read.s
Normal file
@@ -0,0 +1,48 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 30.05.1998
|
||||
;
|
||||
; int read (int fd, void* buf, int count);
|
||||
;
|
||||
; THIS IS A HACK!
|
||||
;
|
||||
|
||||
.export _read
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, ptr3
|
||||
|
||||
.include "../cbm/cbm.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 BASIN
|
||||
ldy #0
|
||||
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
|
||||
|
||||
|
||||
|
||||
41
libsrc/c64/readjoy.s
Normal file
41
libsrc/c64/readjoy.s
Normal file
@@ -0,0 +1,41 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 23.09.1998
|
||||
;
|
||||
; unsigned readjoy (unsigned char joy);
|
||||
;
|
||||
|
||||
.export _readjoy
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
.proc _readjoy
|
||||
|
||||
tax ; Joystick number into X
|
||||
bne joy2
|
||||
|
||||
; Read joystick 1
|
||||
|
||||
joy1: lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 2
|
||||
|
||||
joy2: ldx #0
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
699
libsrc/c64/rs232.s
Normal file
699
libsrc/c64/rs232.s
Normal file
@@ -0,0 +1,699 @@
|
||||
;
|
||||
; SwiftLink/Turbo-232 v0.90 device driver, by Craig Bruce, 14-Apr-1998.
|
||||
;
|
||||
; This software is Public Domain. It is in Buddy assembler format.
|
||||
;
|
||||
; This device driver uses the SwiftLink RS-232 Serial Cartridge, available from
|
||||
; Creative Micro Designs, Inc, and also supports the extensions of the Turbo232
|
||||
; Serial Cartridge. Both devices are based on the 6551 ACIA chip. It also
|
||||
; supports the "hacked" SwiftLink with a 1.8432 MHz crystal.
|
||||
;
|
||||
; The code assumes that the kernal + I/O are in context. On the C128, call
|
||||
; it from Bank 15. On the C64, don't flip out the Kernal unless a suitable
|
||||
; NMI catcher is put into the RAM under then Kernal. For the SuperCPU, the
|
||||
; interrupt handling assumes that the 65816 is in 6502-emulation mode.
|
||||
;
|
||||
;--------------------------------------------------------------------------
|
||||
;
|
||||
; Adapted for the use with the cc65 runtime library by
|
||||
; Ullrich von Bassewitz (uz@musoftware.de) 02-May-1999.
|
||||
;
|
||||
; All external functions are C callable, the return value is an error code.
|
||||
;
|
||||
|
||||
|
||||
.importzp ptr1, ptr2, tmp1, tmp2
|
||||
.import popa, popax
|
||||
.export _rs232_init, _rs232_params, _rs232_done, _rs232_get
|
||||
.export _rs232_put, _rs232_pause, _rs232_unpause, _rs232_status
|
||||
|
||||
|
||||
useC64 = 1
|
||||
.if useC64
|
||||
NmiExit = $febc ;exit address for nmi
|
||||
.else
|
||||
NmiExit = $ff33 ;exit address for nmi
|
||||
.endif
|
||||
|
||||
ACIA = $DE00
|
||||
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; Global variables
|
||||
;
|
||||
|
||||
.bss
|
||||
DropCnt: .res 4 ; Number of bytes lost from rx buffer full
|
||||
Initialized: .res 1 ; Flag indicating driver is initialized
|
||||
Stopped: .res 1 ; Flow-stopped flag
|
||||
RtsOff: .res 1 ;
|
||||
Errors: .res 1 ; Number of bytes received in error, low byte
|
||||
Turbo232: .res 1 ; Flag indicating turbo-232
|
||||
HackedFlag: .res 1 ; Flag indicating hacked-crystal swiftlink
|
||||
CpuSpeed: .res 1 ; In MHz
|
||||
RecvHead: .res 1 ; Head of receive buffer
|
||||
RecvTail: .res 1 ; Tail of receive buffer
|
||||
RecvFreeCnt: .res 1 ; Number of bytes in receive buffer
|
||||
SendHead: .res 1 ; Head of send buffer
|
||||
SendTail: .res 1 ; Tail of send buffer
|
||||
SendFreeCnt: .res 1 ; Number of bytes free in send buffer
|
||||
BaudCode: .res 1 ; Current baud in effect
|
||||
|
||||
; Send and receive buffers: 256 bytes each
|
||||
RecvBuf: .res 256
|
||||
SendBuf: .res 256
|
||||
|
||||
.data
|
||||
NmiContinue: .byte $4c ; JMP instruction for NMI save -- continue
|
||||
NmiSave: .res 2 ; normal NMI handler
|
||||
|
||||
; Switftlink register offsets
|
||||
RegData = 0 ; Data register
|
||||
RegStatus = 1 ; Status register
|
||||
RegCommand = 2 ; Command register
|
||||
RegControl = 3 ; Control register
|
||||
RegClock = 7 ; Turbo232 external baud-rate generator
|
||||
|
||||
; Error codes. Beware: The codes must match the codes in the C header file
|
||||
ErrNotInitialized = $01
|
||||
ErrBaudTooFast = $02
|
||||
ErrBaudNotAvail = $03
|
||||
ErrNoData = $04
|
||||
ErrOverflow = $05
|
||||
|
||||
|
||||
.code
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_init (char hacked);
|
||||
; /* Initialize the serial port, install the interrupt handler. The parameter
|
||||
; * must be true (non zero) for a hacked swiftlink and false (zero) otherwise.
|
||||
; */
|
||||
;
|
||||
|
||||
_rs232_init:
|
||||
bit Initialized ;** shut down if started
|
||||
bpl @L1
|
||||
pha
|
||||
jsr _rs232_done
|
||||
pla
|
||||
|
||||
;** set hacked-crystal
|
||||
|
||||
@L1: sta HackedFlag
|
||||
|
||||
;** check for turbo-232
|
||||
|
||||
lda #$00
|
||||
sta ACIA+RegControl
|
||||
tax
|
||||
lda ACIA+RegClock
|
||||
beq @L3
|
||||
dex
|
||||
@L3: stx Turbo232
|
||||
|
||||
;** get C128/C64 cpu speed
|
||||
.if useC64
|
||||
lda #1
|
||||
sta CpuSpeed
|
||||
.else
|
||||
lda $d030
|
||||
and #$01
|
||||
clc
|
||||
adc #1
|
||||
sta CpuSpeed
|
||||
.endif
|
||||
|
||||
;** check for super-cpu at 20 MHz
|
||||
|
||||
bit $d0bc
|
||||
bmi @L4
|
||||
bit $d0b8
|
||||
bvs @L4
|
||||
lda #20
|
||||
sta CpuSpeed
|
||||
|
||||
;** initialize buffers & control
|
||||
|
||||
@L4: lda #0
|
||||
sta RecvHead
|
||||
sta SendHead
|
||||
sta RecvTail
|
||||
sta SendTail
|
||||
sta Errors
|
||||
sta Stopped
|
||||
lda #255
|
||||
sta RecvFreeCnt
|
||||
sta SendFreeCnt
|
||||
|
||||
;** set up nmi's
|
||||
|
||||
lda $318
|
||||
ldy $319
|
||||
sta NmiSave+0
|
||||
sty NmiSave+1
|
||||
lda #<NmiHandler
|
||||
ldy #>NmiHandler
|
||||
sta $318
|
||||
sty $319
|
||||
|
||||
;** set default to 2400-8N1, enable interrupts
|
||||
|
||||
lda ACIA+RegData
|
||||
lda ACIA+RegStatus
|
||||
lda #$18
|
||||
bit HackedFlag
|
||||
bpl @L5
|
||||
lda #$1a
|
||||
@L5: sta ACIA+RegControl
|
||||
|
||||
lda #$01
|
||||
sta RtsOff
|
||||
ora #$08
|
||||
sta ACIA+RegCommand
|
||||
lda #$06
|
||||
sta BaudCode
|
||||
|
||||
;** return
|
||||
lda #$ff
|
||||
sta Initialized
|
||||
lda #$00
|
||||
tax
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
|
||||
; /* Set the port parameters. Use a combination of the #defined values above. */
|
||||
;
|
||||
; Set communication parameters.
|
||||
;
|
||||
; baud rates stops word | parity
|
||||
; --------------------- ----- ----- | ---------
|
||||
; $00=50 $08=9600 $00=1 $00=8 | $00=none
|
||||
; $01=110 $09=19200 $80=2 $20=7 | $20=odd
|
||||
; $02=134.5 $0a=38400 $40=6 | $60=even
|
||||
; $03=300 $0b=57600 $60=5 | $A0=mark
|
||||
; $04=600 $0c=115200 | $E0=space
|
||||
; $05=1200 $0d=230400
|
||||
; $06=2400 $0e=future
|
||||
; $07=4800 $0f=future
|
||||
;
|
||||
|
||||
_rs232_params:
|
||||
jsr CheckInitialized ;** check initialized
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
; Save new parity
|
||||
|
||||
@L1: and #%11100000
|
||||
ora #%00000001
|
||||
sta tmp2
|
||||
|
||||
; Check cpu speed against baud rate
|
||||
|
||||
jsr popa
|
||||
sta tmp1
|
||||
and #$0f
|
||||
cmp #$0c
|
||||
bcc @L3
|
||||
ldx CpuSpeed
|
||||
cpx #1+1
|
||||
bcc @L2
|
||||
cmp #$0c
|
||||
beq @L3
|
||||
cpx #4
|
||||
bcs @L3
|
||||
@L2: lda #ErrBaudTooFast
|
||||
bne @L9
|
||||
|
||||
; Set baud/parameters
|
||||
|
||||
@L3: lda tmp1
|
||||
and #$0f
|
||||
tax
|
||||
lda NormBauds,x
|
||||
bit HackedFlag
|
||||
bpl @L4
|
||||
lda HackBauds,x
|
||||
@L4: cmp #$ff
|
||||
bne @L5
|
||||
lda #ErrBaudNotAvail
|
||||
bne @L9
|
||||
|
||||
@L5: tax
|
||||
and #$30
|
||||
beq @L6
|
||||
bit Turbo232
|
||||
bmi @L6
|
||||
lda #ErrBaudNotAvail
|
||||
bne @L9
|
||||
|
||||
@L6: lda tmp1
|
||||
and #$0f
|
||||
sta BaudCode
|
||||
lda tmp1
|
||||
and #%11100000
|
||||
ora #%00010000
|
||||
sta tmp1
|
||||
txa
|
||||
and #$0f
|
||||
ora tmp1
|
||||
sta ACIA+RegControl
|
||||
txa
|
||||
and #%00110000
|
||||
beq @L7
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
eor #%00000011
|
||||
sta ACIA+RegClock
|
||||
|
||||
; Set new parity
|
||||
|
||||
@L7: lda tmp2
|
||||
sta RtsOff
|
||||
ora #%00001000
|
||||
sta ACIA+RegCommand
|
||||
lda #0
|
||||
@L9: ldx #0
|
||||
rts
|
||||
|
||||
.rodata
|
||||
|
||||
NormBauds:
|
||||
.byte $ff,$ff,$ff,$05,$06,$07,$08,$0a,$0c,$0e,$0f,$10,$20,$30,$ff,$ff
|
||||
HackBauds:
|
||||
.byte $01,$03,$04,$06,$07,$08,$0a,$0c,$0e,$0f,$ff,$ff,$00,$ff,$ff,$ff
|
||||
;in: 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
;baud50 110 134 3 6 12 24 48 96 19 38 57 115 230 exp exp
|
||||
;out masks: $0F=Baud, val$FF=err
|
||||
; $30=t232ExtBaud: $00=none, $10=57.6, $20=115.2, $30=230.4
|
||||
.code
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_done (void);
|
||||
; /* Close the port, deinstall the interrupt hander. You MUST call this function
|
||||
; * before terminating the program, otherwise the machine may crash later. If
|
||||
; * in doubt, install an exit handler using atexit(). The function will do
|
||||
; * nothing, if it was already called.
|
||||
; */
|
||||
;
|
||||
|
||||
|
||||
_rs232_done:
|
||||
bit Initialized ;** check initialized
|
||||
bpl @L9
|
||||
|
||||
; Stop interrupts, drop DTR
|
||||
|
||||
lda RtsOff
|
||||
and #%11100010
|
||||
ora #%00000010
|
||||
sta ACIA+RegCommand
|
||||
|
||||
; Restore NMI vector
|
||||
|
||||
lda NmiSave+0
|
||||
ldy NmiSave+1
|
||||
sta $318
|
||||
sty $319
|
||||
|
||||
; Flag uninitialized
|
||||
|
||||
@L9: lda #$00
|
||||
sta Initialized
|
||||
tax
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_get (char* B);
|
||||
; /* Get a character from the serial port. If no characters are available, the
|
||||
; * function will return RS_ERR_NO_DATA, so this is not a fatal error.
|
||||
; */
|
||||
;
|
||||
|
||||
_rs232_get:
|
||||
jsr CheckInitialized ; Check if initialized
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
; Check for bytes to send
|
||||
|
||||
@L1: sta ptr1
|
||||
stx ptr1+1 ; Store pointer to received char
|
||||
ldx SendFreeCnt
|
||||
cpx #$ff
|
||||
beq @L2
|
||||
lda #$00
|
||||
jsr TryToSend
|
||||
|
||||
; Check for buffer empty
|
||||
|
||||
@L2: lda RecvFreeCnt
|
||||
cmp #$ff
|
||||
bne @L3
|
||||
lda #ErrNoData
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
; Check for flow stopped & enough free: release flow control
|
||||
|
||||
@L3: ldx Stopped
|
||||
beq @L4
|
||||
cmp #63
|
||||
bcc @L4
|
||||
lda #$00
|
||||
sta Stopped
|
||||
lda RtsOff
|
||||
ora #%00001000
|
||||
sta ACIA+RegCommand
|
||||
|
||||
; Get byte from buffer
|
||||
|
||||
@L4: ldx RecvHead
|
||||
lda RecvBuf,x
|
||||
inc RecvHead
|
||||
inc RecvFreeCnt
|
||||
ldx #$00
|
||||
sta (ptr1,x)
|
||||
txa ; Return code = 0
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_put (char B);
|
||||
; /* Send a character via the serial port. There is a transmit buffer, but
|
||||
; * transmitting is not done via interrupt. The function returns
|
||||
; * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
|
||||
; */
|
||||
;
|
||||
|
||||
_rs232_put:
|
||||
jsr CheckInitialized ; Check initialized
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
; Try to send
|
||||
|
||||
@L1: ldx SendFreeCnt
|
||||
cpx #$ff
|
||||
beq @L2
|
||||
pha
|
||||
lda #$00
|
||||
jsr TryToSend
|
||||
pla
|
||||
|
||||
; Put byte into send buffer & send
|
||||
|
||||
@L2: ldx SendFreeCnt
|
||||
bne @L3
|
||||
lda #ErrOverflow
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
@L3: ldx SendTail
|
||||
sta SendBuf,x
|
||||
inc SendTail
|
||||
dec SendFreeCnt
|
||||
lda #$ff
|
||||
jsr TryToSend
|
||||
lda #$00
|
||||
tax
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_pause (void);
|
||||
; /* Assert flow control and disable interrupts. */
|
||||
;
|
||||
|
||||
_rs232_pause:
|
||||
; Check initialized
|
||||
jsr CheckInitialized
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
; Assert flow control
|
||||
|
||||
@L1: lda RtsOff
|
||||
sta Stopped
|
||||
sta ACIA+RegCommand
|
||||
|
||||
; Delay for flow stop to be received
|
||||
|
||||
ldx BaudCode
|
||||
lda PauseTimes,x
|
||||
jsr DelayMs
|
||||
|
||||
; Stop rx interrupts
|
||||
|
||||
lda RtsOff
|
||||
ora #$02
|
||||
sta ACIA+RegCommand
|
||||
lda #0
|
||||
tax
|
||||
rts
|
||||
|
||||
|
||||
.rodata
|
||||
; Delay times: 32 byte-receive times in milliseconds, or 100 max.
|
||||
; Formula = 320,000 / baud
|
||||
PauseTimes:
|
||||
.byte 100,100,100,100,100,100,100,067,034,017,009,006,003,002,001,001
|
||||
;in: 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
;baud50 110 134 3 6 12 24 48 96 19 38 57 115 230 exp exp
|
||||
.code
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_unpause (void);
|
||||
; /* Re-enable interrupts and release flow control */
|
||||
;
|
||||
|
||||
_rs232_unpause:
|
||||
; Check initialized
|
||||
jsr CheckInitialized
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
; Re-enable rx interrupts & release flow control
|
||||
|
||||
@L1: lda #$00
|
||||
sta Stopped
|
||||
lda RtsOff
|
||||
ora #%00001000
|
||||
sta ACIA+RegCommand
|
||||
|
||||
; Poll for stalled char & exit
|
||||
|
||||
jsr PollReceive
|
||||
lda #0
|
||||
tax
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; unsigned char __fastcall__ rs232_status (unsigned char* status,
|
||||
; unsigned char* errors);
|
||||
; /* Return the serial port status. */
|
||||
;
|
||||
|
||||
_rs232_status:
|
||||
sta ptr2
|
||||
stx ptr2+1
|
||||
jsr popax
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
jsr CheckInitialized
|
||||
bcs @L9
|
||||
|
||||
; Get status
|
||||
|
||||
lda ACIA+RegStatus
|
||||
ldy #0
|
||||
sta (ptr1),y
|
||||
jsr PollReceive ; bug-recovery hack
|
||||
lda Errors
|
||||
sta (ptr2),y
|
||||
tya
|
||||
tax
|
||||
@L9: rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; NMI handler
|
||||
; C128 NMI overhead=76 cycles: int=7, maxLatency=6, ROMenter=33, ROMexit=30
|
||||
; C64 NMI overhead=76 cycles: int=7, maxLatency=6, ROMenter=34, ROMexit=29
|
||||
;
|
||||
; timing: normal=76+43+9=128 cycles, assertFlow=76+52+9=137 cycles
|
||||
;
|
||||
; C128 @ 115.2k: 177 cycles avail (fast)
|
||||
; C64 @ 57.6k: 177 cycles avail, worstAvail=177-43? = 134
|
||||
; SCPU @ 230.4k: 868 cycles avail: for a joke!
|
||||
;
|
||||
|
||||
NmiHandler:
|
||||
.if useC64
|
||||
pha
|
||||
lda ACIA+RegStatus ;(4) ;status ;check for byte received
|
||||
and #$08 ;(2)
|
||||
beq @L9 ;(2*)
|
||||
cld
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
.else
|
||||
lda ACIA+RegStatus ;(4) ;status ;check for byte received
|
||||
and #$08 ;(2)
|
||||
beq NmiNorm ;(2*)
|
||||
.endif
|
||||
lda ACIA+RegStatus ;(4) opt ;status ;check for receive errors
|
||||
and #$07 ;(2) opt
|
||||
beq @L1 ;(3*)opt
|
||||
inc Errors ;(5^)opt
|
||||
@L1: lda ACIA+RegData ;(4) ;data ;get byte and put into receive buffer
|
||||
ldy RecvTail ;(4)
|
||||
ldx RecvFreeCnt ;(4)
|
||||
beq @L3 ;(2*)
|
||||
sta RecvBuf,y ;(5)
|
||||
inc RecvTail ;(6)
|
||||
dec RecvFreeCnt ;(6)
|
||||
cpx #33 ;(2) ;check for buffer space low
|
||||
bcc @L2 ;(2*)
|
||||
jmp NmiExit ;(3)
|
||||
|
||||
; Assert flow control
|
||||
|
||||
@L2: lda RtsOff ;(3) ;assert flow control if buffer space too low
|
||||
sta ACIA+RegCommand ;(4) ;command
|
||||
sta Stopped ;(3)
|
||||
jmp NmiExit ;(3)
|
||||
|
||||
; Drop this char
|
||||
|
||||
@L3: inc DropCnt+0 ;not time-critical
|
||||
bne @L4
|
||||
inc DropCnt+1
|
||||
bne @L4
|
||||
inc DropCnt+2
|
||||
bne @L4
|
||||
inc DropCnt+3
|
||||
@L4: jmp NmiExit
|
||||
|
||||
@L9:
|
||||
.if useC64
|
||||
pla
|
||||
.endif
|
||||
jmp NmiContinue
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; CheckInitialized - internal check if initialized
|
||||
; Set carry and an error code if not initialized, clear carry and do not
|
||||
; change any registers if initialized.
|
||||
;
|
||||
|
||||
CheckInitialized:
|
||||
bit Initialized
|
||||
bmi @L1
|
||||
lda #ErrNotInitialized
|
||||
ldx #0
|
||||
sec
|
||||
rts
|
||||
|
||||
@L1: clc
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Try to send a byte. Internal routine. A = TryHard
|
||||
|
||||
TryToSend:
|
||||
sta tmp1 ; Remember tryHard flag
|
||||
@L0: lda SendFreeCnt
|
||||
cmp #$ff
|
||||
beq @L3 ; Bail out
|
||||
|
||||
; Check for flow stopped
|
||||
|
||||
@L1: lda Stopped
|
||||
bne @L3 ; Bail out
|
||||
|
||||
;** check that swiftlink is ready to send
|
||||
|
||||
@L2: lda ACIA+RegStatus
|
||||
and #$10
|
||||
bne @L4
|
||||
bit tmp1 ;keep trying if must try hard
|
||||
bmi @L0
|
||||
@L3: rts
|
||||
|
||||
;** send byte and try again
|
||||
|
||||
@L4: ldx SendHead
|
||||
lda SendBuf,x
|
||||
sta ACIA+RegData
|
||||
inc SendHead
|
||||
inc SendFreeCnt
|
||||
jmp @L0
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; PollReceive - poll for rx char
|
||||
; This function is useful in odd cases where the 6551 has a character in
|
||||
; it but it fails to raise an NMI. It might be edge-triggering conditions?
|
||||
; Actually, I'm not entirely sure that this condition can still arrise, but
|
||||
; calling this function does no harm.
|
||||
;
|
||||
|
||||
PollReceive:
|
||||
lda #$08
|
||||
and ACIA+RegStatus
|
||||
beq @L9
|
||||
and ACIA+RegStatus
|
||||
beq @L9
|
||||
lda ACIA+RegData
|
||||
ldx RecvFreeCnt
|
||||
beq @L9
|
||||
ldx RecvTail
|
||||
sta RecvBuf,x
|
||||
inc RecvTail
|
||||
dec RecvFreeCnt
|
||||
@L9: rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
; DelayMs : delay for given number of milliseconds
|
||||
; This implementation isn't very rigerous; it merely delays for the
|
||||
; approximate number of clock cycles for the processor speed.
|
||||
; Algorithm:
|
||||
; repeat for number of milliseconds:
|
||||
; repeat for number of MHz of cpu speed:
|
||||
; delay for 1017 clock cycles
|
||||
;
|
||||
|
||||
DelayMs: ;( .A=milliseconds )
|
||||
@L1: ldy CpuSpeed
|
||||
@L2: ldx #203 ;(2)
|
||||
@L3: dex ;(2)
|
||||
bne @L3 ;(3) // 1017 cycles
|
||||
dey
|
||||
bne @L2
|
||||
sec
|
||||
sbc #1
|
||||
bne @L1
|
||||
rts
|
||||
|
||||
.end
|
||||
|
||||
|
||||
|
||||
47
libsrc/c64/write.s
Normal file
47
libsrc/c64/write.s
Normal file
@@ -0,0 +1,47 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 30.05.1998
|
||||
;
|
||||
; int write (int fd, const void* buf, int count);
|
||||
;
|
||||
; THIS IS A HACK!
|
||||
;
|
||||
|
||||
.export _write
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, ptr3
|
||||
|
||||
.include "../cbm/cbm.inc"
|
||||
|
||||
_write: jsr popax ; get count
|
||||
sta ptr2
|
||||
stx ptr2+1 ; save it for later
|
||||
sta ptr3
|
||||
stx ptr3+1 ; save for function result
|
||||
jsr popax ; get buf
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
jsr popax ; get fd and discard it
|
||||
|
||||
L1: lda ptr2
|
||||
ora ptr2+1 ; count zero?
|
||||
beq L9
|
||||
ldy #0
|
||||
lda (ptr1),y
|
||||
jsr BSOUT
|
||||
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
|
||||
|
||||
32
libsrc/cbm/Makefile
Normal file
32
libsrc/cbm/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# 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 = ctype.o getenv.o gotoxy.o gotox.o gotoy.o where.o\
|
||||
clock.o chline.o cvline.o cclear.o revers.o\
|
||||
c_readst.o c_close.o c_open.o c_ckout.o c_clrch.o c_bsout.o\
|
||||
c_basin.o c_clall.o c_iobase.o c_setnam.o c_setlfs.o c_acptr.o\
|
||||
c_ciout.o c_untlk.o c_unlsn.o c_listen.o c_talk.o c_load.o\
|
||||
oserror.o
|
||||
|
||||
all: $(C_OBJS) $(S_OBJS)
|
||||
|
||||
clean:
|
||||
@rm -f *~
|
||||
@rm -f $(C_OBJS:.c=.s)
|
||||
@rm -f $(C_OBJS)
|
||||
@rm -f $(S_OBJS)
|
||||
|
||||
16
libsrc/cbm/c_acptr.s
Normal file
16
libsrc/cbm/c_acptr.s
Normal file
@@ -0,0 +1,16 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned char __fastcall__ cbm_acptr (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_acptr
|
||||
|
||||
_cbm_acptr:
|
||||
jsr ACPTR
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
16
libsrc/cbm/c_basin.s
Normal file
16
libsrc/cbm/c_basin.s
Normal file
@@ -0,0 +1,16 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned char __fastcall__ cbm_basin (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_basin
|
||||
|
||||
_cbm_basin:
|
||||
jsr BASIN
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
14
libsrc/cbm/c_bsout.s
Normal file
14
libsrc/cbm/c_bsout.s
Normal file
@@ -0,0 +1,14 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_bsout (unsigned char C);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_bsout
|
||||
|
||||
_cbm_bsout = BSOUT
|
||||
|
||||
|
||||
|
||||
13
libsrc/cbm/c_ciout.s
Normal file
13
libsrc/cbm/c_ciout.s
Normal file
@@ -0,0 +1,13 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_ciout (unsigned char C);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_ciout
|
||||
|
||||
_cbm_ciout = CIOUT
|
||||
|
||||
|
||||
24
libsrc/cbm/c_ckout.s
Normal file
24
libsrc/cbm/c_ckout.s
Normal file
@@ -0,0 +1,24 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned __fastcall__ cbm_ckout (unsigned char FN);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_ckout
|
||||
|
||||
_cbm_ckout:
|
||||
tax
|
||||
jsr CKOUT
|
||||
ldx #0
|
||||
bcc @Ok
|
||||
inx
|
||||
rts
|
||||
@Ok: txa
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
13
libsrc/cbm/c_clall.s
Normal file
13
libsrc/cbm/c_clall.s
Normal file
@@ -0,0 +1,13 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_clall (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_clall
|
||||
|
||||
_cbm_clall = CLALL
|
||||
|
||||
|
||||
15
libsrc/cbm/c_close.s
Normal file
15
libsrc/cbm/c_close.s
Normal file
@@ -0,0 +1,15 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_close (unsigned char FN);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_close
|
||||
|
||||
_cbm_close:
|
||||
clc
|
||||
jmp CLOSE
|
||||
|
||||
|
||||
12
libsrc/cbm/c_clrch.s
Normal file
12
libsrc/cbm/c_clrch.s
Normal file
@@ -0,0 +1,12 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_clrch (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_clrch
|
||||
|
||||
_cbm_clrch = CLRCH
|
||||
|
||||
20
libsrc/cbm/c_iobase.s
Normal file
20
libsrc/cbm/c_iobase.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned __fastcall__ cbm_iobase (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_iobase
|
||||
|
||||
_cbm_iobase:
|
||||
jsr IOBASE
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
tax
|
||||
pla
|
||||
rts
|
||||
|
||||
|
||||
16
libsrc/cbm/c_listen.s
Normal file
16
libsrc/cbm/c_listen.s
Normal file
@@ -0,0 +1,16 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_listen (unsigned char dev);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_listen
|
||||
|
||||
_cbm_listen = LISTEN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
26
libsrc/cbm/c_load.s
Normal file
26
libsrc/cbm/c_load.s
Normal file
@@ -0,0 +1,26 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned __fastcall__ cbm_load (unsigned char flag, unsigned addr);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_load
|
||||
.import popa
|
||||
.importzp ptr1
|
||||
|
||||
_cbm_load:
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
jsr popa ; get flag
|
||||
ldx ptr1
|
||||
ldy ptr1+1
|
||||
jsr LOAD
|
||||
ldx #0
|
||||
bcc @Ok
|
||||
inx
|
||||
rts
|
||||
@Ok: txa
|
||||
rts
|
||||
|
||||
19
libsrc/cbm/c_open.s
Normal file
19
libsrc/cbm/c_open.s
Normal file
@@ -0,0 +1,19 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned __fastcall__ cbm_open (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_open
|
||||
|
||||
_cbm_open:
|
||||
jsr OPEN
|
||||
ldx #0
|
||||
bcc @Ok
|
||||
inx
|
||||
rts
|
||||
@Ok: txa
|
||||
rts
|
||||
|
||||
15
libsrc/cbm/c_readst.s
Normal file
15
libsrc/cbm/c_readst.s
Normal file
@@ -0,0 +1,15 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; unsigned __fastcall__ cbm_readst (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_readst
|
||||
|
||||
_cbm_readst:
|
||||
jsr READST
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
23
libsrc/cbm/c_setlfs.s
Normal file
23
libsrc/cbm/c_setlfs.s
Normal file
@@ -0,0 +1,23 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_setlfs (unsigned char LFN,
|
||||
; unsigned char DEV,
|
||||
; unsigned char SA);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_setlfs
|
||||
.import popa
|
||||
.importzp tmp1
|
||||
|
||||
_cbm_setlfs:
|
||||
sta tmp1 ; Save SA
|
||||
jsr popa ; Get DEV
|
||||
tax
|
||||
jsr popa ; Get LFN
|
||||
ldy tmp1 ; Get SA
|
||||
jmp SETLFS
|
||||
|
||||
|
||||
24
libsrc/cbm/c_setnam.s
Normal file
24
libsrc/cbm/c_setnam.s
Normal file
@@ -0,0 +1,24 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_setnam (const char* Name);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_setnam
|
||||
.importzp ptr1
|
||||
|
||||
_cbm_setnam:
|
||||
sta ptr1 ; Store pointer to file name
|
||||
stx ptr1+1
|
||||
ldy #$FF
|
||||
@Loop: iny ; Get length of name
|
||||
lda (ptr1),y
|
||||
bne @Loop
|
||||
|
||||
tya ; Length
|
||||
ldx ptr1
|
||||
ldy ptr1+1
|
||||
jmp SETNAM
|
||||
|
||||
18
libsrc/cbm/c_talk.s
Normal file
18
libsrc/cbm/c_talk.s
Normal file
@@ -0,0 +1,18 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_talk (unsigned char dev);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_talk
|
||||
|
||||
_cbm_talk = TALK
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
libsrc/cbm/c_unlsn.s
Normal file
16
libsrc/cbm/c_unlsn.s
Normal file
@@ -0,0 +1,16 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_unlsn (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_unlsn
|
||||
|
||||
_cbm_unlsn = UNLSN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
13
libsrc/cbm/c_untlk.s
Normal file
13
libsrc/cbm/c_untlk.s
Normal file
@@ -0,0 +1,13 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 03.06.1999
|
||||
;
|
||||
; void __fastcall__ cbm_untlk (void);
|
||||
;
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
.export _cbm_untlk
|
||||
|
||||
_cbm_untlk = UNTLK
|
||||
|
||||
|
||||
46
libsrc/cbm/cbm.inc
Normal file
46
libsrc/cbm/cbm.inc
Normal file
@@ -0,0 +1,46 @@
|
||||
;
|
||||
; Subroutines available in the CBM jump table
|
||||
;
|
||||
|
||||
|
||||
CINT = $FF81
|
||||
IOINIT = $FF84
|
||||
RAMTAS = $FF87
|
||||
RESTOR = $FF8A
|
||||
VECTOR = $FF8D
|
||||
SETMSG = $FF90
|
||||
SECOND = $FF93
|
||||
TKSA = $FF96
|
||||
MEMTOP = $FF99
|
||||
MEMBOT = $FF9C
|
||||
SCNKEY = $FF9F
|
||||
SETTMO = $FFA2
|
||||
ACPTR = $FFA5
|
||||
CIOUT = $FFA8
|
||||
UNTLK = $FFAB
|
||||
UNLSN = $FFAE
|
||||
LISTEN = $FFB1
|
||||
TALK = $FFB4
|
||||
READST = $FFB7
|
||||
SETLFS = $FFBA
|
||||
SETNAM = $FFBD
|
||||
OPEN = $FFC0
|
||||
CLOSE = $FFC3
|
||||
CHKIN = $FFC6
|
||||
CKOUT = $FFC9
|
||||
CLRCH = $FFCC
|
||||
BASIN = $FFCF
|
||||
BSOUT = $FFD2
|
||||
LOAD = $FFD5
|
||||
SAVE = $FFD8
|
||||
SETTIM = $FFDB
|
||||
RDTIM = $FFDE
|
||||
STOP = $FFE1
|
||||
GETIN = $FFE4
|
||||
CLALL = $FFE7
|
||||
UDTIM = $FFEA
|
||||
SCREEN = $FFED
|
||||
PLOT = $FFF0
|
||||
IOBASE = $FFF3
|
||||
|
||||
|
||||
30
libsrc/cbm/cclear.s
Normal file
30
libsrc/cbm/cclear.s
Normal 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
|
||||
|
||||
|
||||
|
||||
|
||||
30
libsrc/cbm/chline.s
Normal file
30
libsrc/cbm/chline.s
Normal 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 #64 ; Horizontal line, screen code
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
22
libsrc/cbm/clock.s
Normal file
22
libsrc/cbm/clock.s
Normal file
@@ -0,0 +1,22 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 21.09.1998
|
||||
;
|
||||
; clock_t clock (void);
|
||||
;
|
||||
|
||||
.export _clock
|
||||
.importzp sreg
|
||||
|
||||
.include "cbm.inc"
|
||||
|
||||
|
||||
.proc _clock
|
||||
|
||||
lda #0 ; Byte 3 is always zero
|
||||
sta ::sreg+1
|
||||
jsr RDTIM
|
||||
sty ::sreg
|
||||
rts ; Don't set CC, this has no meaning here
|
||||
|
||||
.endproc
|
||||
|
||||
311
libsrc/cbm/ctype.s
Normal file
311
libsrc/cbm/ctype.s
Normal file
@@ -0,0 +1,311 @@
|
||||
;
|
||||
; 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 a lower case char to make it an upper case
|
||||
; char (example: for ASCII, this must be $E0).
|
||||
|
||||
|
||||
.export __cdiff
|
||||
|
||||
__cdiff:
|
||||
.byte $80
|
||||
|
||||
|
||||
; 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
|
||||
|
||||
|
||||
; The table is taken from Craig S. Bruce technical docs for the ACE os
|
||||
|
||||
.export __ctype
|
||||
|
||||
__ctype:
|
||||
.byte $10 ; 0/00 ___rvs_@___
|
||||
.byte $10 ; 1/01 ___rvs_a___
|
||||
.byte $10 ; 2/02 ___rvs_b___
|
||||
.byte $10 ; 3/03 ___rvs_c___
|
||||
.byte $10 ; 4/04 ___rvs_d___
|
||||
.byte $10 ; 5/05 ___rvs_e___
|
||||
.byte $10 ; 6/06 ___rvs_f___
|
||||
.byte $10 ; 7/07 _BEL/rvs_g_
|
||||
.byte $10 ; 8/08 ___rvs_h___
|
||||
.byte $D0 ; 9/09 _TAB/rvs_i_
|
||||
.byte $50 ; 10/0a _BOL/rvs_j_
|
||||
.byte $10 ; 11/0b ___rvs_k___
|
||||
.byte $10 ; 12/0c ___rvs_l___
|
||||
.byte $50 ; 13/0d _CR_/rvs_m_
|
||||
.byte $10 ; 14/0e ___rvs_n___
|
||||
.byte $10 ; 15/0f ___rvs_o___
|
||||
.byte $10 ; 16/10 ___rvs_p___
|
||||
.byte $50 ; 17/11 _VT_/rvs_q_
|
||||
.byte $10 ; 18/12 ___rvs_r___
|
||||
.byte $10 ; 19/13 ___rvs_s___
|
||||
.byte $50 ; 20/14 _BS_/rvs_t_
|
||||
.byte $10 ; 21/15 ___rvs_u___
|
||||
.byte $10 ; 22/16 ___rvs_v___
|
||||
.byte $10 ; 23/17 ___rvs_w___
|
||||
.byte $10 ; 24/18 ___rvs_x___
|
||||
.byte $10 ; 25/19 ___rvs_y___
|
||||
.byte $10 ; 26/1a ___rvs_z___
|
||||
.byte $10 ; 27/1b ___rvs_[___
|
||||
.byte $10 ; 28/1c ___rvs_\___
|
||||
.byte $10 ; 29/1d ___rvs_]___
|
||||
.byte $10 ; 30/1e ___rvs_^___
|
||||
.byte $10 ; 31/1f _rvs_under_
|
||||
.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 $09 ; 65/41 _____a_____
|
||||
.byte $09 ; 66/42 _____b_____
|
||||
.byte $09 ; 67/43 _____c_____
|
||||
.byte $09 ; 68/44 _____d_____
|
||||
.byte $09 ; 69/45 _____e_____
|
||||
.byte $09 ; 70/46 _____f_____
|
||||
.byte $01 ; 71/47 _____g_____
|
||||
.byte $01 ; 72/48 _____h_____
|
||||
.byte $01 ; 73/49 _____i_____
|
||||
.byte $01 ; 74/4a _____j_____
|
||||
.byte $01 ; 75/4b _____k_____
|
||||
.byte $01 ; 76/4c _____l_____
|
||||
.byte $01 ; 77/4d _____m_____
|
||||
.byte $01 ; 78/4e _____n_____
|
||||
.byte $01 ; 79/4f _____o_____
|
||||
.byte $01 ; 80/50 _____p_____
|
||||
.byte $01 ; 81/51 _____q_____
|
||||
.byte $01 ; 82/52 _____r_____
|
||||
.byte $01 ; 83/53 _____s_____
|
||||
.byte $01 ; 84/54 _____t_____
|
||||
.byte $01 ; 85/55 _____u_____
|
||||
.byte $01 ; 86/56 _____v_____
|
||||
.byte $01 ; 87/57 _____w_____
|
||||
.byte $01 ; 88/58 _____x_____
|
||||
.byte $01 ; 89/59 _____y_____
|
||||
.byte $01 ; 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 _A`_grave__
|
||||
.byte $00 ; 97/61 _A'_acute__
|
||||
.byte $00 ; 98/62 _A^_circum_
|
||||
.byte $00 ; 99/63 _A~_tilde__
|
||||
.byte $00 ; 100/64 _A"_dieres_
|
||||
.byte $00 ; 101/65 _A__ring___
|
||||
.byte $00 ; 102/66 _AE________
|
||||
.byte $00 ; 103/67 _C,cedilla_
|
||||
.byte $00 ; 104/68 _E`_grave__
|
||||
.byte $00 ; 105/69 _E'_acute__
|
||||
.byte $00 ; 106/6a _E^_circum_
|
||||
.byte $00 ; 107/6b _E"_dieres_
|
||||
.byte $00 ; 108/6c _I`_grave__
|
||||
.byte $00 ; 109/6d _I'_acute__
|
||||
.byte $00 ; 110/6e _I^_circum_
|
||||
.byte $00 ; 111/6f _I"_dieres_
|
||||
.byte $00 ; 112/70 _D-_Eth_lr_
|
||||
.byte $00 ; 113/71 _N~_tilde__
|
||||
.byte $00 ; 114/72 _O`_grave__
|
||||
.byte $00 ; 115/73 _O'_acute__
|
||||
.byte $00 ; 116/74 _O^_circum_
|
||||
.byte $00 ; 117/75 _O~_tilde__
|
||||
.byte $00 ; 118/76 _O"_dieres_
|
||||
.byte $00 ; 119/77 __multiply_
|
||||
.byte $00 ; 120/78 _O/_slash__
|
||||
.byte $00 ; 121/79 _U`_grave__
|
||||
.byte $00 ; 122/7a _U'_acute__
|
||||
.byte $00 ; 123/7b _U^_circum_
|
||||
.byte $00 ; 124/7c _U"_dieres_
|
||||
.byte $00 ; 125/7d _Y'_acute__
|
||||
.byte $00 ; 126/7e _cap_thorn_
|
||||
.byte $00 ; 127/7f _Es-sed_B__
|
||||
|
||||
.byte $00 ; 128/80 __bullet___
|
||||
.byte $00 ; 129/81 __v_line___
|
||||
.byte $00 ; 130/82 __h_line___
|
||||
.byte $00 ; 131/83 ___cross___
|
||||
.byte $00 ; 132/84 _tl_corner_
|
||||
.byte $00 ; 133/85 _tr_corner_
|
||||
.byte $00 ; 134/86 _bl_corner_
|
||||
.byte $00 ; 135/87 _br_corner_
|
||||
.byte $00 ; 136/88 ___l_tee___
|
||||
.byte $00 ; 137/89 ___r_tee___
|
||||
.byte $00 ; 138/8a ___t_tee___
|
||||
.byte $00 ; 139/8b ___b_tee___
|
||||
.byte $00 ; 140/8c ___heart___
|
||||
.byte $00 ; 141/8d __diamond__
|
||||
.byte $00 ; 142/8e ___club____
|
||||
.byte $00 ; 143/8f ___spade___
|
||||
.byte $00 ; 144/90 _s_circle__
|
||||
.byte $00 ; 145/91 __circle___
|
||||
.byte $00 ; 146/92 ___pound___
|
||||
.byte $10 ; 147/93 _CLS/check_
|
||||
.byte $00 ; 148/94 ____pi_____
|
||||
.byte $00 ; 149/95 ____+/-____
|
||||
.byte $00 ; 150/96 __divide___
|
||||
.byte $00 ; 151/97 __degree___
|
||||
.byte $00 ; 152/98 _c_checker_
|
||||
.byte $00 ; 153/99 _f_checker_
|
||||
.byte $00 ; 154/9a _solid_sq__
|
||||
.byte $00 ; 155/9b __cr_char__
|
||||
.byte $00 ; 156/9c _up_arrow__
|
||||
.byte $00 ; 157/9d _down_arro_
|
||||
.byte $00 ; 158/9e _left_arro_
|
||||
.byte $00 ; 159/9f _right_arr_
|
||||
.byte $00 ; 160/a0 _req space_
|
||||
.byte $00 ; 161/a1 _!_invertd_
|
||||
.byte $00 ; 162/a2 ___cent____
|
||||
.byte $00 ; 163/a3 ___pound___
|
||||
.byte $00 ; 164/a4 __currency_
|
||||
.byte $00 ; 165/a5 ____yen____
|
||||
.byte $00 ; 166/a6 _|_broken__
|
||||
.byte $00 ; 167/a7 __section__
|
||||
.byte $00 ; 168/a8 __umulaut__
|
||||
.byte $00 ; 169/a9 _copyright_
|
||||
.byte $00 ; 170/aa __fem_ord__
|
||||
.byte $00 ; 171/ab _l_ang_quo_
|
||||
.byte $00 ; 172/ac ____not____
|
||||
.byte $00 ; 173/ad _syl_hyphn_
|
||||
.byte $00 ; 174/ae _registerd_
|
||||
.byte $00 ; 175/af _overline__
|
||||
.byte $00 ; 176/b0 __degrees__
|
||||
.byte $00 ; 177/b1 ____+/-____
|
||||
.byte $00 ; 178/b2 _2_supersc_
|
||||
.byte $00 ; 179/b3 _3_supersc_
|
||||
.byte $00 ; 180/b4 ___acute___
|
||||
.byte $00 ; 181/b5 ____mu_____
|
||||
.byte $00 ; 182/b6 _paragraph_
|
||||
.byte $00 ; 183/b7 __mid_dot__
|
||||
.byte $00 ; 184/b8 __cedilla__
|
||||
.byte $00 ; 185/b9 _1_supersc_
|
||||
.byte $00 ; 186/ba __mas_ord__
|
||||
.byte $00 ; 187/bb _r_ang_quo_
|
||||
.byte $00 ; 188/bc ____1/4____
|
||||
.byte $00 ; 189/bd ____1/2____
|
||||
.byte $00 ; 190/be ____3/4____
|
||||
.byte $00 ; 191/bf _?_invertd_
|
||||
|
||||
.byte $00 ; 192/c0 _____`_____
|
||||
.byte $0A ; 193/c1 _____A_____
|
||||
.byte $0A ; 194/c2 _____B_____
|
||||
.byte $0A ; 195/c3 _____C_____
|
||||
.byte $0A ; 196/c4 _____D_____
|
||||
.byte $0A ; 197/c5 _____E_____
|
||||
.byte $0A ; 198/c6 _____F_____
|
||||
.byte $02 ; 199/c7 _____G_____
|
||||
.byte $02 ; 200/c8 _____H_____
|
||||
.byte $02 ; 201/c9 _____I_____
|
||||
.byte $02 ; 202/ca _____J_____
|
||||
.byte $02 ; 203/cb _____K_____
|
||||
.byte $02 ; 204/cc _____L_____
|
||||
.byte $02 ; 205/cd _____M_____
|
||||
.byte $02 ; 206/ce _____N_____
|
||||
.byte $02 ; 207/cf _____O_____
|
||||
.byte $02 ; 208/d0 _____P_____
|
||||
.byte $02 ; 209/d1 _____Q_____
|
||||
.byte $02 ; 210/d2 _____R_____
|
||||
.byte $02 ; 211/d3 _____S_____
|
||||
.byte $02 ; 212/d4 _____T_____
|
||||
.byte $02 ; 213/d5 _____U_____
|
||||
.byte $02 ; 214/d6 _____V_____
|
||||
.byte $02 ; 215/d7 _____W_____
|
||||
.byte $02 ; 216/d8 _____X_____
|
||||
.byte $02 ; 217/d9 _____Y_____
|
||||
.byte $02 ; 218/da _____Z_____
|
||||
.byte $00 ; 219/db _____{_____
|
||||
.byte $00 ; 220/dc _____|_____
|
||||
.byte $00 ; 221/dd _____}_____
|
||||
.byte $00 ; 222/de _____~_____
|
||||
.byte $00 ; 223/df ___HOUSE___
|
||||
.byte $00 ; 224/e0 _a`_grave__
|
||||
.byte $00 ; 225/e1 _a'_acute__
|
||||
.byte $00 ; 226/e2 _a^_circum_
|
||||
.byte $00 ; 227/e3 _a~_tilde__
|
||||
.byte $00 ; 228/e4 _a"_dieres_
|
||||
.byte $00 ; 229/e5 _a__ring___
|
||||
.byte $00 ; 230/e6 _ae________
|
||||
.byte $00 ; 231/e7 _c,cedilla_
|
||||
.byte $00 ; 232/e8 _e`_grave__
|
||||
.byte $00 ; 233/e9 _e'_acute__
|
||||
.byte $00 ; 234/ea _e^_circum_
|
||||
.byte $00 ; 235/eb _e"_dieres_
|
||||
.byte $00 ; 236/ec _i`_grave__
|
||||
.byte $00 ; 237/ed _i'_acute__
|
||||
.byte $00 ; 238/ee _i^_circum_
|
||||
.byte $00 ; 239/ef _i"_dieres_
|
||||
.byte $00 ; 240/f0 _o^x_Eth_s_
|
||||
.byte $00 ; 241/f1 _n~_tilda__
|
||||
.byte $00 ; 242/f2 _o`_grave__
|
||||
.byte $00 ; 243/f3 _o'_acute__
|
||||
.byte $00 ; 244/f4 _o^_circum_
|
||||
.byte $00 ; 245/f5 _o~_tilde__
|
||||
.byte $00 ; 246/f6 _o"_dieres_
|
||||
.byte $00 ; 247/f7 __divide___
|
||||
.byte $00 ; 248/f8 _o/_slash__
|
||||
.byte $00 ; 249/f9 _u`_grave__
|
||||
.byte $00 ; 250/fa _u'_acute__
|
||||
.byte $00 ; 251/fb _u^_circum_
|
||||
.byte $00 ; 252/fc _u"_dieres_
|
||||
.byte $00 ; 253/fd _y'_acute__
|
||||
.byte $00 ; 254/fe _sm_thorn__
|
||||
.byte $00 ; 255/ff _y"_dieres_
|
||||
|
||||
30
libsrc/cbm/cvline.s
Normal file
30
libsrc/cbm/cvline.s
Normal 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 #93 ; Vertical bar
|
||||
jsr putchar ; Write, no cursor advance
|
||||
jsr newline ; Advance cursor to next line
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user