mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
more space improvements by Daniel Serpell
git-svn-id: svn://svn.cc65.org/cc65/trunk@4503 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
a467095216
commit
2bca737f57
@ -79,6 +79,7 @@ OBJS = _scrsize.o \
|
||||
do_oserr.o \
|
||||
dosdetect.o \
|
||||
fdtable.o \
|
||||
fdtab.o \
|
||||
fdtoiocb.o \
|
||||
getargs.o \
|
||||
getdefdev.o \
|
||||
|
30
libsrc/atari/fdtab.s
Normal file
30
libsrc/atari/fdtab.s
Normal file
@ -0,0 +1,30 @@
|
||||
;
|
||||
; Christian Groessler, Oct-2000
|
||||
; Daniel Serpell, Dec-2009
|
||||
;
|
||||
; the fdtable itself is defined here
|
||||
;
|
||||
|
||||
.include "fd.inc"
|
||||
|
||||
.export fd_table,fd_index
|
||||
.export ___fd_table,___fd_index ; for test(debug purposes only
|
||||
|
||||
.data
|
||||
|
||||
___fd_index:
|
||||
fd_index: ; fd number is index into this table, entry's value specifies the fd_table entry
|
||||
.byte 0,0,0 ; at start, three first files are stdin/stdout/stderr.
|
||||
.res MAX_FD_INDEX-3,$ff
|
||||
|
||||
___fd_table:
|
||||
fd_table: ; each entry represents an open iocb
|
||||
.byte 3,0,'E',0 ; system console, app starts with opened iocb #0 for E:
|
||||
.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
|
||||
|
@ -26,10 +26,6 @@
|
||||
|
||||
__getdefdev:
|
||||
|
||||
.ifdef DEFAULT_DEVICE
|
||||
lda #'0'+DEFAULT_DEVICE
|
||||
sta __defdev+1
|
||||
.endif
|
||||
lda __dos_type ; which DOS?
|
||||
cmp #ATARIDOS
|
||||
beq finish
|
||||
@ -86,5 +82,9 @@ finish: lda #<__defdev
|
||||
; Default device
|
||||
|
||||
__defdev:
|
||||
.ifdef DEFAULT_DEVICE
|
||||
.byte 'D', '0'+DEFAULT_DEVICE, ':', 0
|
||||
.else
|
||||
.byte "D1:", 0
|
||||
.endif
|
||||
|
||||
|
@ -2,56 +2,18 @@
|
||||
; Christian Groessler, Oct-2000
|
||||
;
|
||||
; allocates a new fd in the indirection table
|
||||
; the fdtable itself is defined here
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.include "fd.inc"
|
||||
.include "_file.inc"
|
||||
.importzp tmp1
|
||||
.import fd_table, fd_index
|
||||
|
||||
.export fdt_to_fdi,getfd
|
||||
.export fd_table,fd_index
|
||||
.export ___fd_table,___fd_index ; for test(debug purposes only
|
||||
|
||||
.constructor initfds,24
|
||||
|
||||
.data
|
||||
|
||||
___fd_index:
|
||||
fd_index: ; fd number is index into this table, entry's value specifies the fd_table entry
|
||||
.res MAX_FD_INDEX,$ff
|
||||
|
||||
___fd_table:
|
||||
fd_table: ; each entry represents an open iocb
|
||||
.byte 0,0,'E',0 ; system console, app starts with opened iocb #0 for E:
|
||||
.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
|
||||
|
||||
.code
|
||||
|
||||
; set stdio stream handles
|
||||
|
||||
.proc initfds
|
||||
|
||||
lda #0
|
||||
jsr getfd
|
||||
sta __filetab + (0 * .sizeof(_FILE)); setup stdin
|
||||
lda #0
|
||||
jsr getfd
|
||||
sta __filetab + (1 * .sizeof(_FILE)); setup stdout
|
||||
lda #0
|
||||
jsr getfd
|
||||
sta __filetab + (2 * .sizeof(_FILE)); setup stderr
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
; fdt_to_fdi
|
||||
; returns a fd_index entry pointing to the given ft_table entry
|
||||
; get fd_table entry in A
|
||||
|
@ -23,7 +23,7 @@
|
||||
.import __defdev
|
||||
.endif
|
||||
.importzp tmp3,ptr4,sp
|
||||
.import _strupr,subysp
|
||||
.import subysp,addysp
|
||||
.export ucase_fn
|
||||
|
||||
.proc ucase_fn
|
||||
@ -50,56 +50,48 @@
|
||||
hasdev:
|
||||
.endif
|
||||
|
||||
; 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 (not!)
|
||||
; beq str_end
|
||||
iny
|
||||
bne loop ; not longer than 255 chars (127 real limit)
|
||||
toolong:sec ; indicate error
|
||||
rts
|
||||
|
||||
str_end:iny ; room for terminating zero
|
||||
bmi toolong ; we only can handle lenght < 128
|
||||
ldy #128
|
||||
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
|
||||
; copy filename to the temp. place on the stack, also uppercasing it
|
||||
ldy #0
|
||||
|
||||
loop2: lda (ptr4),y
|
||||
sta (sp),y
|
||||
dey
|
||||
beq copy_end
|
||||
bmi L1 ; Not lowercase (also, invalid, should reject)
|
||||
cmp #'a'
|
||||
bcc L1 ; Not lowercase
|
||||
and #$DF ; make upper case char, assume ASCII chars
|
||||
sta (sp),y ; store back
|
||||
L1:
|
||||
iny
|
||||
bpl loop2 ; bpl: this way we only support a max. length of 127
|
||||
|
||||
; Filename too long
|
||||
jsr addysp ; restore the stack
|
||||
sec ; indicate error
|
||||
rts
|
||||
|
||||
copy_end:
|
||||
|
||||
.ifdef DEFAULT_DEVICE
|
||||
lda tmp2
|
||||
cmp #1 ; was device present in passed string?
|
||||
beq hasdev2 ; yes, don't prepend something
|
||||
|
||||
inc tmp3 ; no, prepend "D:" (or other device)
|
||||
inc tmp3 ; adjust stack size used
|
||||
inc tmp3
|
||||
ldy #128+3 ; no, prepend "D:" (or other device)
|
||||
sty tmp3 ; adjust stack size used
|
||||
ldy #3
|
||||
jsr subysp ; adjust stack pointer
|
||||
ldy #2
|
||||
lda #':'
|
||||
sta (sp),y ; insert ':'
|
||||
dey
|
||||
lda __defdev+1
|
||||
sta (sp),y ; insert device number
|
||||
cpdev: lda __defdev,y
|
||||
sta (sp),y ; insert device name, number and ':'
|
||||
dey
|
||||
lda __defdev
|
||||
sta (sp),y ; insert device name (normally 'D' or 'H')
|
||||
bpl cpdev
|
||||
hasdev2:
|
||||
.endif
|
||||
; uppercase the temp. filename
|
||||
ldx sp+1
|
||||
lda sp
|
||||
jsr _strupr
|
||||
|
||||
; leave A and X pointing to the modified filename
|
||||
lda sp
|
||||
|
Loading…
x
Reference in New Issue
Block a user