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
10 ; tmp2 - 0/$80 for don't/do prepend default device if no device
11 ; is present in the passed string (only .ifdef DEFAULT_DEVICE)
13 ; C - 0/1 for OK/Error (filename too long)
14 ; AX - points to uppercased version of the filename on the stack
15 ; tmp3 - amount of bytes used on the stack (needed for cleanup)
17 ; ptr4 - scratch pointer used to remember original AX pointer
27 .importzp tmp3,ptr4,sp
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 beq hasdev ; don't fiddle with device part
45 ; bit #0 of tmp2 is used as an additional flag whether device name is present in passed string (1 = present, 0 = not present)
47 inc tmp2 ; initialize flag: device present
54 dec tmp2 ; set flag: no device in passed string
60 jsr subysp ; make room on the stack
62 ; copy filename to the temp. place on the stack, while uppercasing it
68 bmi L1 ; Not lowercase (also, invalid, should reject)
70 bcc L1 ; Not lowercase
71 and #$DF ; make upper case char, assume ASCII chars
72 sta (sp),y ; store back
75 bpl loop2 ; bpl: this way we only support a max. length of 127
78 jsr addysp ; restore the stack
86 bit tmp2 ; is a device present in the string?
87 bne hasdev2 ; yes, don't prepend something
88 bpl hasdev2 ; check input parameter (tmp2 != $80)
90 ldy #128+3 ; no, prepend "Dn:" (__defdev)
91 sty tmp3 ; adjust stack size used
93 jsr subysp ; adjust stack pointer
96 sta (sp),y ; insert device name, number and ':'
102 ; leave A and X pointing to the modified filename
105 clc ; indicate success