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:
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
|
||||
Reference in New Issue
Block a user