]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/ucase_fn.s
New module eeprom.s
[cc65] / libsrc / atari / ucase_fn.s
index 4f866dda8567b67d4c881ec0aa5db56dcae1eee3..c52de8ef7577bf838ad7df07b468cf4af2e1c78f 100644 (file)
 ;      tmp3 - amount of bytes used on the stack (needed for cleanup)
 ; Uses:
 ;       ptr4 - scratch pointer used to remember original AX pointer
-; 
+;
 ;
 
        .include        "atari.inc"
-       
+
+.ifdef DEFAULT_DEVICE
+       .importzp tmp2
+.endif
        .importzp tmp3,ptr4,sp
        .import _strupr,subysp
        .export ucase_fn
 
-ucase_fn:      .proc
+.proc   ucase_fn
 
        ; we make sure that the filename doesn't contain lowercase letters
        ; we copy the filename we got onto the stack, uppercase it and use this
@@ -33,6 +36,19 @@ ucase_fn:    .proc
        sta     ptr4
        stx     ptr4+1
 
+.ifdef DEFAULT_DEVICE
+       ldy     #1
+       sty     tmp2            ; initialize flag: device present in passed string
+       lda     #':'
+       cmp     (ptr4),y
+       beq     hasdev
+       iny
+       cmp     (ptr4),y
+       beq     hasdev
+       sta     tmp2            ; set flag: no device is passed string
+hasdev:
+.endif
+
        ; now we need the length of the name
        ldy     #0
 loop:  lda     (ptr4),y
@@ -59,6 +75,23 @@ loop2:       lda     (ptr4),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
+
+       inc     tmp3            ; no, prepend "D:"
+       inc     tmp3            ; adjust stack size used
+       ldy     #2
+       jsr     subysp          ; adjust stack pointer
+       ldy     #1
+       lda     #':'
+       sta     (sp),y          ; insert ':'
+       dey
+       lda     #'D'
+       sta     (sp),y          ; insert 'D'
+hasdev2:
+.endif
        ; uppercase the temp. filename
        ldx     sp+1
        lda     sp
@@ -70,4 +103,4 @@ loop2:       lda     (ptr4),y
        clc                     ; indicate success
        rts
 
-ucase_fn:      .endproc
+.endproc