2 ; Christian Groessler, 2013-07-24
4 ; unsigned char __fastcall__ _sysrename (const char* oldname, const char* newname);
9 .importzp tmp4, sp, ptr2, ptr3
10 .import incsp2, subysp, addysp, popax
22 pha ; save input parameter
27 beq iocbok ; we found one
33 lda #TMOF ; too many open files
36 iocbok: stx tmp4 ; remember IOCB index
39 sta ptr2+1 ; remember newname
43 jsr popax ; get oldname
46 sty sspc+1 ; initialize stack space
48 .ifndef UCASE_FILENAME
56 ; uppercase first (old) name and prepend device if needed
60 sty tmp2 ; set flag for ucase_fn
65 lda #183 ; see oserror.s
69 stx ptr3+1 ; remember pointer to uppercased old name
70 lda tmp3 ; # of bytes reserved on the stack
71 sta sspc ; remember...
73 ; uppercase second (new) name and don't prepend device
77 sty tmp2 ; set flag for ucase_fn
86 jsr addysp ; free used space on the stack
87 lda #183 ; see oserror.s
90 ucok2: sta ptr2 ; remember pointer to uppercased new name
93 ; update sspc -- # of bytes used on the stack
105 ; create a string on the stack with the old filename and the new filename separated by an invalid character (space in our case)
106 ; ptr2 - pointer to new name
107 ; ptr3 - pointer to old name
116 L1: jsr subysp ; make room on the stack
126 copyend:lda #$20 ; space
129 tya ; get current offset (beyond old name)
135 sta ptr3+1 ; ptr3 now contains pointer to space for new filename
181 .endproc ; __sysrename
185 sspc: .res 2 ; stack space used