Unify case adjust functions

This commit is contained in:
Joshua Bell 2018-12-14 20:46:42 -08:00
parent d632a7e999
commit e073d21bac

View File

@ -5560,7 +5560,7 @@ start: sta flag
bne :- bne :-
;; And capitalize ;; And capitalize
addr_call capitalize_string, path_buffer addr_call adjust_case, path_buffer
lda #0 lda #0
sta L704B sta L704B
@ -6155,7 +6155,7 @@ L7561: lda LE1B0,y
sta ($08),y sta ($08),y
dey dey
bpl L7561 bpl L7561
L7569: addr_call_indirect capitalize_string, $08 L7569: addr_call_indirect adjust_case, $08
lda cached_window_id lda cached_window_id
jsr window_lookup jsr window_lookup
stax $06 stax $06
@ -6469,7 +6469,7 @@ got_type:
tya tya
jsr find_icon_details_for_file_type jsr find_icon_details_for_file_type
addr_call capitalize_string, name_tmp addr_call adjust_case, name_tmp
ldy #IconEntry::len ldy #IconEntry::len
ldx #0 ldx #0
L77F0: lda name_tmp,x L77F0: lda name_tmp,x
@ -7700,7 +7700,7 @@ loop: lda LEC43,x
lda #' ' lda #' '
sta text_buffer2::data sta text_buffer2::data
inc text_buffer2::length inc text_buffer2::length
addr_call capitalize_string, text_buffer2::length addr_call adjust_case, text_buffer2::length
rts rts
.endproc .endproc
@ -8225,50 +8225,6 @@ exit: rts
rts rts
.endproc .endproc
;;; ============================================================
.proc capitalize_string
ptr := $A
stx ptr+1
sta ptr
ldy #0
lda (ptr),y
tay
bne next
rts
next: dey
beq done
bpl :+
done: rts
: lda (ptr),y
and #CHAR_MASK ; convert to ASCII
cmp #'/'
beq skip
cmp #' ' ; (these two lines are not present
beq skip ; in most filename case adjust procs)
cmp #'.'
bne check_alpha
skip: dey
jmp next
check_alpha:
iny
lda (ptr),y
and #CHAR_MASK
cmp #'A'
bcc :+
cmp #'Z'+1
bcs :+
clc
adc #('a' - 'A') ; convert to lower case
sta (ptr),y
: dey
jmp next
.endproc
;;; ============================================================ ;;; ============================================================
;;; Pushes two words from $6/$8 to stack ;;; Pushes two words from $6/$8 to stack
@ -8326,7 +8282,7 @@ addr: .addr 0
;;; ============================================================ ;;; ============================================================
port_copy: port_copy:
.res .sizeof(MGTK::GrafPort)+1 .res .sizeof(MGTK::GrafPort)+1, 0
.proc copy_window_portbits .proc copy_window_portbits
ptr := $6 ptr := $6
@ -8550,7 +8506,7 @@ create_icon:
lda cvi_data_buffer lda cvi_data_buffer
and #$0F and #$0F
sta cvi_data_buffer sta cvi_data_buffer
addr_call capitalize_string, cvi_data_buffer addr_call adjust_case, cvi_data_buffer
ldy #IconEntry::name ldy #IconEntry::name
copy #' ', (icon_ptr),y ; leading space copy #' ', (icon_ptr),y ; leading space
@ -13430,21 +13386,22 @@ LB76C: stax $06
rts rts
;;; ============================================================ ;;; ============================================================
;;; Adjust case in a filename (input buf A,X, output buf $A) ;;; Adjust case in a pathname (input buf A,X, output buf $A)
;;; Called from ovl2
.proc adjust_case .proc adjust_case
.assert * = $B781, error, "Entry point used by overlay" .assert * = $B781, error, "Entry point used by overlay"
ptr := $A ptr := $A
stx ptr+1 stax ptr
sta ptr
ldy #0 ldy #0
lda (ptr),y lda (ptr),y
tay tay
bne loop beq done
rts
;; Walk backwards through string. At char N, check char N-1
;; to see if it is a symbol. If it is, and char N is a letter,
;; lower-case it.
loop: dey loop: dey
beq done beq done
@ -13453,11 +13410,9 @@ done: rts
: lda (ptr),y : lda (ptr),y
and #CHAR_MASK ; convert to ASCII and #CHAR_MASK ; convert to ASCII
cmp #'/' cmp #'0' ; <'0' includes '.', '/' and ' '
beq next bcs check_alpha
cmp #'.' dey
bne check_alpha
next: dey
jmp loop jmp loop
check_alpha: check_alpha:
@ -13468,13 +13423,14 @@ check_alpha:
bcc :+ bcc :+
cmp #'Z'+1 cmp #'Z'+1
bcs :+ bcs :+
clc ora #(~CASE_MASK & $FF)
adc #('a' - 'A') ; convert to lower case
sta (ptr),y sta (ptr),y
: dey : dey
jmp loop jmp loop
.endproc .endproc
PAD_TO $B7B9 ; Maintain previous addresses
;;; ============================================================ ;;; ============================================================
.proc set_port_from_window_id .proc set_port_from_window_id
@ -14890,7 +14846,7 @@ is_da: inc desk_acc_num
dey dey
bne :- bne :-
addr_call_indirect desktop_main::capitalize_string, da_ptr addr_call_indirect desktop_main::adjust_case, da_ptr
;; Convert periods to spaces ;; Convert periods to spaces
lda (da_ptr),y lda (da_ptr),y