# HG changeset patch # User Daniel Serpell # Date 1259203355 10800 # Branch trunk # Node ID c5ae840a3ca60b1594f147ffcdbdf867c450dcae # Parent 6a9ba841516ee26395eca94b88be63d13b29b5fe Change ucase_fn to use buffer already reserved at getdefdev. diff --git a/libsrc/atari/getdefdev.s b/libsrc/atari/getdefdev.s --- a/libsrc/atari/getdefdev.s +++ b/libsrc/atari/getdefdev.s @@ -92,4 +92,6 @@ .bss __defdev: .res 4 - +.ifdef UCASE_FILENAME + .res 128 +.endif diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -21,7 +21,6 @@ .import __oserror .importzp tmp4,tmp2 .ifdef UCASE_FILENAME - .importzp tmp3 .import ucase_fn .endif @@ -128,11 +127,6 @@ tya pha -.ifdef UCASE_FILENAME - ldy tmp3 ; get size - jsr addysp ; free used space on the stack -.endif ; defined UCASE_FILENAME - jsr incsp4 ; clean up stack pla diff --git a/libsrc/atari/sysmkdir.s b/libsrc/atari/sysmkdir.s --- a/libsrc/atari/sysmkdir.s +++ b/libsrc/atari/sysmkdir.s @@ -13,7 +13,6 @@ .import findfreeiocb .importzp tmp4 .ifdef UCASE_FILENAME - .importzp tmp3 .import ucase_fn .endif .export __sysmkdir @@ -71,15 +70,6 @@ sta ICBLH,x jsr CIOV -.ifdef UCASE_FILENAME - tya - pha - ldy tmp3 ; get size - jsr addysp ; free used space on the stack - pla - tay -.endif ; defined UCASE_FILENAME - bmi cioerr lda #0 rts diff --git a/libsrc/atari/sysremove.s b/libsrc/atari/sysremove.s --- a/libsrc/atari/sysremove.s +++ b/libsrc/atari/sysremove.s @@ -9,8 +9,6 @@ .import findfreeiocb .importzp tmp4 .ifdef UCASE_FILENAME - .importzp tmp3 - .import addysp .import ucase_fn .endif .export __sysremove @@ -61,15 +59,6 @@ sta ICBLH,x jsr CIOV -.ifdef UCASE_FILENAME - tya - pha - ldy tmp3 ; get size - jsr addysp ; free used space on the stack - pla - tay -.endif ; defined UCASE_FILENAME - bmi cioerr lda #0 rts diff --git a/libsrc/atari/ucase_fn.s b/libsrc/atari/ucase_fn.s --- a/libsrc/atari/ucase_fn.s +++ b/libsrc/atari/ucase_fn.s @@ -9,23 +9,20 @@ ; AX - points to filename ; Return parameters: ; C - 0/1 for OK/Error (filename too long) -; AX - points to uppercased version of the filename on the stack -; tmp3 - amount of bytes used on the stack (needed for cleanup) +; AX - points to uppercased version of the filename ; Uses: ; ptr4 - scratch pointer used to remember original AX pointer ; ; .include "atari.inc" + .include "ctype.inc" .ifdef DEFAULT_DEVICE .importzp tmp2 -.ifdef DYNAMIC_DD - .import __defdev .endif -.endif - .importzp tmp3,ptr4,sp - .import _strupr,subysp + .importzp ptr4 + .import __defdev, __ctype .export ucase_fn .proc ucase_fn @@ -52,64 +49,44 @@ hasdev: .endif - ; now we need the length of the name + ; copy the filename to the buffer at __defdev+3. ldy #0 loop: lda (ptr4),y + sta __defdev+3,y ; store in __defdev+3 beq str_end ; cmp #ATEOL ; we also accept Atari EOF char as end of string (not!) ; beq str_end - iny - bne loop ; not longer than 255 chars (127 real limit) + ; following code copied from strupper.s + tax + lda __ctype,x ; get character classification + and #CT_LOWER ; lower case char? + beq L1 ; jump if no + txa ; get character back into accu + eor #<('A'-'a') ; make upper case char, assume ASCII chars + sta __defdev+3,y ; store in __defdev+3 +L1: iny ; next char + bpl loop ; we only can handle lenght < 128 toolong:sec ; indicate error rts str_end:iny ; room for terminating zero bmi toolong ; we only can handle lenght < 128 - sty tmp3 ; save size - jsr subysp ; make room on the stack - - ; copy filename to the temp. place on the stack - lda #0 ; end-of-string - sta (sp),y ; Y still contains length + 1 - dey -loop2: lda (ptr4),y - sta (sp),y - dey - bpl loop2 ; bpl: this way we only support a max. length of 127 .ifdef DEFAULT_DEVICE lda tmp2 cmp #1 ; was device present in passed string? beq hasdev2 ; yes, don't prepend something + ; leave A and X pointing to the modified filename with default drive letter + lda #<__defdev + ldx #>__defdev + clc ; indicate success + rts - inc tmp3 ; no, prepend "D:" - inc tmp3 ; adjust stack size used - inc tmp3 - ldy #3 - jsr subysp ; adjust stack pointer - ldy #2 - lda #':' - sta (sp),y ; insert ':' - dey -.ifdef DYNAMIC_DD - lda __defdev+1 -.else - lda #'0'+DEFAULT_DEVICE -.endif - sta (sp),y ; insert device number - dey - lda #'D' - sta (sp),y ; insert 'D' hasdev2: .endif - ; uppercase the temp. filename - ldx sp+1 - lda sp - jsr _strupr - - ; leave A and X pointing to the modified filename - lda sp - ldx sp+1 + ; leave A and X pointing to the modified filename without default drive letter + lda #<__defdev+3 + ldx #>__defdev+3 clc ; indicate success rts