2 ; Christian Groessler, Dec-2001
5 ; helper routine to convert a string (file name) to uppercase
6 ; used by open.s and remove.s
9 ; AX - points to filename
11 ; C - 0/1 for OK/Error (filename too long)
12 ; AX - points to uppercased version of the filename on the stack
13 ; tmp3 - amount of bytes used on the stack (needed for cleanup)
15 ; ptr4 - scratch pointer used to remember original AX pointer
27 .importzp tmp3,ptr4,sp
28 .import _strupr,subysp
33 ; we make sure that the filename doesn't contain lowercase letters
34 ; we copy the filename we got onto the stack, uppercase it and use this
35 ; one to open the iocb
36 ; we're using tmp3, ptr4
38 ; save the original pointer
44 sty tmp2 ; initialize flag: device present in passed string
51 sta tmp2 ; set flag: no device in passed string
55 ; now we need the length of the name
59 cmp #ATEOL ; we also accept Atari EOF char as end of string
62 bne loop ; not longer than 255 chars (127 real limit)
63 toolong:sec ; indicate error
66 str_end:iny ; room for terminating zero
67 cpy #128 ; we only can handle lenght < 128
70 jsr subysp ; make room on the stack
72 ; copy filename to the temp. place on the stack
73 lda #0 ; end-of-string
74 sta (sp),y ; Y still contains length + 1
79 bpl loop2 ; bpl: this way we only support a max. length of 127
83 cmp #1 ; was device present in passed string?
84 beq hasdev2 ; yes, don't prepend something
86 inc tmp3 ; no, prepend "D:"
87 inc tmp3 ; adjust stack size used
90 jsr subysp ; adjust stack pointer
93 sta (sp),y ; insert ':'
98 lda #'0'+DEFAULT_DEVICE
100 sta (sp),y ; insert device number
103 sta (sp),y ; insert 'D'
106 ; uppercase the temp. filename
111 ; leave A and X pointing to the modified filename
114 clc ; indicate success