DeskTop: Unify filename case adjusting procs

This commit is contained in:
Joshua Bell 2018-07-26 21:44:29 -07:00
parent c7c7d866e4
commit 8bb974200c
3 changed files with 65 additions and 53 deletions

View File

@ -8103,30 +8103,27 @@ next: dey
bpl :+ bpl :+
done: rts done: rts
;; Ignore punctuation
: lda (ptr),y : lda (ptr),y
and #CHAR_MASK and #CHAR_MASK ; convert to ASCII
cmp #'/' cmp #'/'
beq skip beq skip
cmp #' ' cmp #' ' ; (these two lines are not present
beq skip beq skip ; in most filename case adjust procs)
cmp #'.' cmp #'.'
bne check bne check_alpha
skip: dey skip: dey
jmp next jmp next
;; Look at previous character - is it a letter? check_alpha:
check: iny iny
lda (ptr),y lda (ptr),y
and #CHAR_MASK and #CHAR_MASK
cmp #'A' cmp #'A'
bcc :+ bcc :+
cmp #'Z'+1 cmp #'Z'+1
bcs :+ bcs :+
;; Yes - uppercase it.
clc clc
adc #$20 adc #('a' - 'A') ; convert to lower case
sta (ptr),y sta (ptr),y
: dey : dey
jmp next jmp next
@ -13219,18 +13216,19 @@ LB76C: stax $06
tay tay
bne loop bne loop
rts rts
loop: dey loop: dey
beq done beq done
bpl :+ bpl :+
done: rts done: rts
: lda (ptr),y : lda (ptr),y
and #CHAR_MASK and #CHAR_MASK ; convert to ASCII
cmp #'/' cmp #'/'
beq :+ beq next
cmp #'.' cmp #'.'
bne check_alpha bne check_alpha
: dey next: dey
jmp loop jmp loop
check_alpha: check_alpha:
@ -13242,7 +13240,7 @@ check_alpha:
cmp #'Z'+1 cmp #'Z'+1
bcs :+ bcs :+
clc clc
adc #('a' - 'A') ; Lowercase adc #('a' - 'A') ; convert to lower case
sta (ptr),y sta (ptr),y
: dey : dey
jmp loop jmp loop

View File

@ -874,7 +874,7 @@ LD77E: lda $1300
LD798: lda $1300 LD798: lda $1300
and #$0F and #$0F
sta $1300 sta $1300
addr_call LE0FE, $1300 addr_call adjust_case, $1300
jsr LE674 jsr LE674
jsr LE559 jsr LE559
LD7AD: lda LD417 LD7AD: lda LD417
@ -935,7 +935,7 @@ LD817: lda $1300
jmp LD83C jmp LD83C
LD82C: sta $1300 LD82C: sta $1300
addr_call LE0FE, $1300 addr_call adjust_case, $1300
ldx #$00 ldx #$00
ldy #$13 ldy #$13
lda #$02 lda #$02
@ -1724,40 +1724,50 @@ LE0B4: stax $06
rts rts
LE0FD: .byte 0 LE0FD: .byte 0
LE0FE: stx $0B
sta $0A ;;; ============================================================
ldy #$00
lda ($0A),y .proc adjust_case
ptr := $A
stx ptr+1
sta ptr
ldy #0
lda (ptr),y
tay tay
bne LE10A bne next
rts rts
LE10A: dey next: dey
beq LE10F beq done
bpl LE110 bpl :+
LE10F: rts done: rts
LE110: lda ($0A),y : lda (ptr),y
and #CHAR_MASK and #CHAR_MASK ; convert to ASCII
cmp #'/' cmp #'/'
beq LE11C beq skip
cmp #'.' cmp #'.'
bne LE120 bne check_alpha
LE11C: dey skip: dey
jmp LE10A jmp next
LE120: iny check_alpha:
lda ($0A),y iny
lda (ptr),y
and #CHAR_MASK and #CHAR_MASK
cmp #'A' cmp #'A'
bcc LE132 bcc :+
cmp #'Z'+1 cmp #'Z'+1
bcs LE132 bcs :+
clc clc
adc #('a' - 'A') adc #('a' - 'A') ; convert to lower case
sta ($0A),y sta (ptr),y
LE132: dey : dey
jmp LE10A jmp next
.endproc
;;; ============================================================
.byte 0 .byte 0
LE137: sta getwinport_params::window_id LE137: sta getwinport_params::window_id
@ -2026,7 +2036,7 @@ LE31B: sta LE399
sta $07 sta $07
lda $06 lda $06
ldx $07 ldx $07
jsr LE0FE jsr adjust_case
lda $06 lda $06
ldx $07 ldx $07
jsr draw_text jsr draw_text

View File

@ -1666,10 +1666,12 @@ L6128: .byte 0
;;; ============================================================ ;;; ============================================================
.proc adjust_filename_case .proc adjust_filename_case
stx $0A+1 ptr := $A
sta $0A
stx ptr+1
sta ptr
ldy #0 ldy #0
lda ($0A),y lda (ptr),y
tay tay
bne loop bne loop
rts rts
@ -1678,26 +1680,28 @@ loop: dey
beq done beq done
bpl :+ bpl :+
done: rts done: rts
: lda ($0A),y
: lda (ptr),y
and #CHAR_MASK ; convert to ASCII and #CHAR_MASK ; convert to ASCII
cmp #'/' cmp #'/'
beq next beq next
cmp #'.' cmp #'.'
bne check bne check_alpha
next: dey next: dey
jmp loop jmp loop
check: iny check_alpha:
lda ($0A),y iny
lda (ptr),y
and #CHAR_MASK and #CHAR_MASK
cmp #'A' cmp #'A'
bcc L615D bcc :+
cmp #'Z'+1 cmp #'Z'+1
bcs L615D bcs :+
clc clc
adc #$20 ; convert to lower case adc #('a' - 'A') ; convert to lower case
sta ($0A),y sta (ptr),y
L615D: dey : dey
jmp loop jmp loop
.endproc .endproc