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
43 ; bit #0 of tmp2 is used as a flag whether device name is present in passed string (1 = present, 0 = not present)
45 inc tmp2 ; initialize flag: device present
52 dec tmp2 ; set flag: no device in passed string
58 jsr subysp ; make room on the stack
60 ; copy filename to the temp. place on the stack, while uppercasing it
66 bmi L1 ; Not lowercase (also, invalid, should reject)
68 bcc L1 ; Not lowercase
69 and #$DF ; make upper case char, assume ASCII chars
70 sta (sp),y ; store back
73 bpl loop2 ; bpl: this way we only support a max. length of 127
76 jsr addysp ; restore the stack
85 bne hasdev2 ; yes, don't prepend something
88 ldy #128+3 ; no, prepend "D:" (or other device)
89 sty tmp3 ; adjust stack size used
91 jsr subysp ; adjust stack pointer
94 sta (sp),y ; insert device name, number and ':'
100 ; leave A and X pointing to the modified filename
103 clc ; indicate success