2001-12-27 20:37:52 +00:00
|
|
|
;
|
|
|
|
; Christian Groessler, Dec-2001
|
|
|
|
;
|
|
|
|
; ucase_fn
|
|
|
|
; helper routine to convert a string (file name) to uppercase
|
|
|
|
; used by open.s and remove.s
|
|
|
|
;
|
|
|
|
; Calling parameters:
|
|
|
|
; AX - points to filename
|
|
|
|
; Return parameters:
|
|
|
|
; C - 0/1 for OK/Error (filename too long)
|
|
|
|
; AX - points to uppercased version of the filename on the stack
|
|
|
|
; tmp3 - amount of bytes used on the stack (needed for cleanup)
|
|
|
|
; Uses:
|
|
|
|
; ptr4 - scratch pointer used to remember original AX pointer
|
2003-11-10 10:01:27 +00:00
|
|
|
;
|
2001-12-27 20:37:52 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
.include "atari.inc"
|
2003-11-10 10:01:27 +00:00
|
|
|
|
2003-11-14 22:41:01 +00:00
|
|
|
.ifdef DEFAULT_DEVICE
|
|
|
|
.importzp tmp2
|
2004-12-16 22:43:47 +00:00
|
|
|
.import __defdev
|
2003-11-14 22:41:01 +00:00
|
|
|
.endif
|
2001-12-27 20:37:52 +00:00
|
|
|
.importzp tmp3,ptr4,sp
|
2009-12-07 18:58:32 +00:00
|
|
|
.import subysp,addysp
|
2001-12-27 20:37:52 +00:00
|
|
|
.export ucase_fn
|
|
|
|
|
2003-11-10 10:01:27 +00:00
|
|
|
.proc ucase_fn
|
2001-12-27 20:37:52 +00:00
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2003-11-14 22:41:01 +00:00
|
|
|
.ifdef DEFAULT_DEVICE
|
|
|
|
ldy #1
|
|
|
|
sty tmp2 ; initialize flag: device present in passed string
|
|
|
|
lda #':'
|
|
|
|
cmp (ptr4),y
|
|
|
|
beq hasdev
|
|
|
|
iny
|
|
|
|
cmp (ptr4),y
|
|
|
|
beq hasdev
|
2009-01-28 21:54:02 +00:00
|
|
|
sta tmp2 ; set flag: no device in passed string
|
2003-11-14 22:41:01 +00:00
|
|
|
hasdev:
|
|
|
|
.endif
|
|
|
|
|
2009-12-07 18:58:32 +00:00
|
|
|
ldy #128
|
2001-12-27 20:37:52 +00:00
|
|
|
sty tmp3 ; save size
|
|
|
|
jsr subysp ; make room on the stack
|
|
|
|
|
2009-12-07 18:58:32 +00:00
|
|
|
; copy filename to the temp. place on the stack, also uppercasing it
|
|
|
|
ldy #0
|
|
|
|
|
2001-12-27 20:37:52 +00:00
|
|
|
loop2: lda (ptr4),y
|
|
|
|
sta (sp),y
|
2009-12-07 18:58:32 +00:00
|
|
|
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
|
2001-12-27 20:37:52 +00:00
|
|
|
bpl loop2 ; bpl: this way we only support a max. length of 127
|
|
|
|
|
2009-12-07 18:58:32 +00:00
|
|
|
; Filename too long
|
|
|
|
jsr addysp ; restore the stack
|
|
|
|
sec ; indicate error
|
|
|
|
rts
|
|
|
|
|
|
|
|
copy_end:
|
|
|
|
|
2003-11-14 22:41:01 +00:00
|
|
|
.ifdef DEFAULT_DEVICE
|
|
|
|
lda tmp2
|
|
|
|
cmp #1 ; was device present in passed string?
|
|
|
|
beq hasdev2 ; yes, don't prepend something
|
|
|
|
|
2009-12-07 18:58:32 +00:00
|
|
|
ldy #128+3 ; no, prepend "D:" (or other device)
|
|
|
|
sty tmp3 ; adjust stack size used
|
2004-12-16 22:19:46 +00:00
|
|
|
ldy #3
|
2003-11-14 22:41:01 +00:00
|
|
|
jsr subysp ; adjust stack pointer
|
|
|
|
dey
|
2009-12-07 18:58:32 +00:00
|
|
|
cpdev: lda __defdev,y
|
|
|
|
sta (sp),y ; insert device name, number and ':'
|
2004-12-16 22:19:46 +00:00
|
|
|
dey
|
2009-12-07 18:58:32 +00:00
|
|
|
bpl cpdev
|
2003-11-14 22:41:01 +00:00
|
|
|
hasdev2:
|
|
|
|
.endif
|
2001-12-27 20:37:52 +00:00
|
|
|
|
2009-01-28 21:54:02 +00:00
|
|
|
; leave A and X pointing to the modified filename
|
2001-12-27 20:37:52 +00:00
|
|
|
lda sp
|
|
|
|
ldx sp+1
|
|
|
|
clc ; indicate success
|
|
|
|
rts
|
|
|
|
|
2003-11-10 10:01:27 +00:00
|
|
|
.endproc
|