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
24 .importzp tmp3,ptr4,sp
25 .import _strupr,subysp
30 ; we make sure that the filename doesn't contain lowercase letters
31 ; we copy the filename we got onto the stack, uppercase it and use this
32 ; one to open the iocb
33 ; we're using tmp3, ptr4
35 ; save the original pointer
41 sty tmp2 ; initialize flag: device present in passed string
48 sta tmp2 ; set flag: no device is passed string
52 ; now we need the length of the name
56 cmp #ATEOL ; we also accept Atari EOF char as end of string
59 bne loop ; not longer than 255 chars (127 real limit)
60 toolong:sec ; indicate error
63 str_end:iny ; room for terminating zero
64 cpy #128 ; we only can handle lenght < 128
67 jsr subysp ; make room on the stack
69 ; copy filename to the temp. place on the stack
70 lda #0 ; end-of-string
71 sta (sp),y ; Y still contains length + 1
76 bpl loop2 ; bpl: this way we only support a max. length of 127
80 cmp #1 ; was device present in passed string?
81 beq hasdev2 ; yes, don't prepend something
83 inc tmp3 ; no, prepend "D:"
84 inc tmp3 ; adjust stack size used
86 jsr subysp ; adjust stack pointer
89 sta (sp),y ; insert ':'
92 sta (sp),y ; insert 'D'
95 ; uppercase the temp. filename
100 ; leave X and Y pointing to the modified filename
103 clc ; indicate success