]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/ucase_fn.s
Marked files to be excluded from build.
[cc65] / libsrc / atari / ucase_fn.s
index 18d1be06a8f9626546343d80b5f793e82427e774..79f16167f6d4e249c29663c2e5af1057c119202b 100644 (file)
 
 .ifdef DEFAULT_DEVICE
        .importzp tmp2
-.ifdef DYNAMIC_DD
        .import __defdev
-.endif
 .endif
        .importzp tmp3,ptr4,sp
-       .import _strupr,subysp
+       .import subysp,addysp
        .export ucase_fn
 
 .proc   ucase_fn
        iny
        cmp     (ptr4),y
        beq     hasdev
-       sta     tmp2            ; set flag: no device is passed string
+       sta     tmp2            ; set flag: no device in passed string
 hasdev:
 .endif
 
-       ; now we need the length of the name
-       ldy     #0
-loop:  lda     (ptr4),y
-       beq     str_end
-       cmp     #ATEOL          ; we also accept Atari EOF char as end of string
-       beq     str_end
-       iny
-       bne     loop            ; not longer than 255 chars (127 real limit)
-toolong:sec                    ; indicate error
-       rts
-
-str_end:iny                    ; room for terminating zero
-       cpy     #128            ; we only can handle lenght < 128
-       bcs     toolong
+       ldy     #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
+       ; copy filename to the temp. place on the stack, also uppercasing it
+       ldy     #0
+
 loop2: lda     (ptr4),y
        sta     (sp),y
-       dey
+       beq     copy_end
+       bmi     L1              ; Not lowercase (also, invalid, should reject)
+       cmp     #'a'
+       bcc     L1              ; Not lowercase
+       and     #$DF            ; make upper case char, assume ASCII chars
+       sta     (sp),y          ; store back
+L1:
+       iny
        bpl     loop2           ; bpl: this way we only support a max. length of 127
 
+       ; Filename too long
+       jsr     addysp          ; restore the stack
+       sec                     ; indicate error
+       rts
+
+copy_end:
+
 .ifdef DEFAULT_DEVICE
        lda     tmp2
        cmp     #1              ; was device present in passed string?
        beq     hasdev2         ; yes, don't prepend something
 
-       inc     tmp3            ; no, prepend "D:"
-       inc     tmp3            ; adjust stack size used
+       ldy     #128+3          ; no, prepend "D:" (or other device)
+       sty     tmp3            ; adjust stack size used
        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
+cpdev: lda     __defdev,y
+       sta     (sp),y          ; insert device name, number and ':'
        dey
-       lda     #'D'
-       sta     (sp),y          ; insert 'D'
+       bpl     cpdev
 hasdev2:
 .endif
-       ; uppercase the temp. filename
-       ldx     sp+1
-       lda     sp
-       jsr     _strupr
 
-       ; leave X and Y pointing to the modified filename
+       ; leave A and X pointing to the modified filename
        lda     sp
        ldx     sp+1
        clc                     ; indicate success