Miscellaneous identification

This commit is contained in:
Joshua Bell 2018-05-26 09:53:55 -07:00
parent bcdeabb7d3
commit 3fff12d1f3
4 changed files with 185 additions and 153 deletions

View File

@ -465,7 +465,7 @@ L0B72: lda selected_file_count
beq L0B7F beq L0B7F
lda path_index lda path_index
beq L0B7F beq L0B7F
jmp L0BF5 jmp compare_selection_orders
L0B7F: L0B7F:
ldax ptr2 ldax ptr2
@ -549,115 +549,122 @@ type: .byte 0
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Compare selection order of icons; order returned in carry.
;;; Handles either icon being not selected.
.proc compare_selection_orders
entry_ptr := $10
filename := $06
filename2 := $08
.proc L0BF5
ldx selected_file_count ldx selected_file_count
L0BF8: dex loop: dex
bmi L0C4A bmi L0C4A
;; Look up next icon, compare length.
lda selected_file_list,x lda selected_file_list,x
asl a asl a
tay tay
add16 file_table,y, #9, $10 add16 file_table,y, #IconEntry::len, entry_ptr
ldy #$00 ldy #0
lda ($10),y lda (entry_ptr),y
sec sec
sbc #$02 sbc #2 ; remove leading/trailing space
sta L0C24 sta cmp_len
inc16 $10 inc16 entry_ptr ; points at start of name
lda ($06),y
and #$0F
L0C24 := *+1 lda (filename),y
cmp #$0 and #NAME_LENGTH_MASK
cmp_len := *+1
bne L0BF8
sta L0C47
L0C2A: iny
lda ($10),y
and #CHAR_MASK
cmp #'a'
bcc L0C35
and #CASE_MASK ; make upper-case
L0C35: sta L0C43
lda ($06),y
and #CHAR_MASK
cmp #'a'
bcc L0C42
and #CASE_MASK ; make upper-case
L0C43 := *+1
L0C42: cmp #0
bne L0BF8
L0C47 := *+1
cpy #0
bne L0C2A
L0C4A: stx L0CBC
ldx selected_file_count
L0C50: dex
bmi L0CA2
lda selected_file_list,x
asl a
tay
add16 file_table,y, #9, $10
ldy #$00
lda ($10),y
sec
sbc #$02
sta L0C7C
inc16 $10
lda ($08),y
and #$0F
L0C7C := *+1
cmp #0 cmp #0
bne loop ; lengths don't match, so not a match
bne L0C50 ;; Bytewise compare names.
sta L0C9F sta cpy_len
L0C82: iny next: iny ; skip leading space
lda ($10),y lda (entry_ptr),y
and #CHAR_MASK and #CHAR_MASK
cmp #'a' cmp #'a'
bcc L0C8D bcc :+
and #CASE_MASK and #CASE_MASK ; make upper-case
L0C8D: sta L0C9B : sta cmp_char
lda ($08),y lda (filename),y
and #CHAR_MASK and #CHAR_MASK
cmp #'a' cmp #'a'
bcc L0C9A bcc :+
and #CASE_MASK and #CASE_MASK ; make upper-case
cmp_char := *+1
L0C9B := *+1 : cmp #0
L0C9A: cmp #0 bne loop ; no match - try next icon
cpy_len := *+1
bne L0C50
L0C9F := *+1
cpy #0 cpy #0
bne next
bne L0C82 L0C4A: stx match ; match, or $FF if none
L0CA2: stx L0CBD
lda L0CBC
and L0CBD
cmp #$FF
beq L0CBA
lda L0CBD
cmp L0CBC
beq L0CBA
rts
ldx selected_file_count
loop2: dex
bmi L0CA2
;; Look up next icon, compare length.
lda selected_file_list,x
asl a
tay
add16 file_table,y, #IconEntry::len, entry_ptr
ldy #0
lda (entry_ptr),y ; len
sec
sbc #2 ; remove leading/trailing space
sta cmp_len2
inc16 entry_ptr ; points at start of name
lda (filename2),y
and #NAME_LENGTH_MASK
cmp_len2 := *+1
cmp #0
bne loop2 ; lengths don't match, so not a match
;; Bytewise compare names.
sta cpy_len2
next2: iny
lda (entry_ptr),y
and #CHAR_MASK
cmp #'a'
bcc :+
and #CASE_MASK ; make upper-case
: sta cmp_char2
lda (filename2),y
and #CHAR_MASK
cmp #'a'
bcc :+
and #CASE_MASK ; make upper-case
cmp_char2 := *+1
: cmp #0
bne loop2 ; no match - try next icon
cpy_len2 := *+1
cpy #0
bne next2
L0CA2: stx match2 ; match, or $FF if none
lda match
and match2
cmp #$FF ; if either didn't match
beq clear
lda match2
cmp match
beq clear ; if they're the same
rts ; otherwise carry is order
;; No match
sec sec
rts rts
L0CBA: clc clear: clc
rts rts
L0CBC: .byte 0 match: .byte 0
L0CBD: .byte 0 match2: .byte 0
.endproc .endproc
;;; ============================================================ ;;; ============================================================

View File

@ -166,7 +166,7 @@ file_table := $DD9F ; file address table
;;; .res 17 name (name, with a space before and after) ;;; .res 17 name (name, with a space before and after)
.struct IconEntry .struct IconEntry
index .byte id .byte
state .byte state .byte
win_type .byte win_type .byte
iconx .word iconx .word

View File

@ -415,10 +415,12 @@ L949D: ldx highlight_count
lda (ptr),y ; icon num lda (ptr),y ; icon num
ldx #1 ; new position ldx #1 ; new position
jsr change_highlight_index jsr change_highlight_index
ldy #0
lda (ptr),y ldy #IconEntry::id
ldx #1 lda (ptr),y ; icon num
jsr LA2E3 ldx #1 ; new position
jsr change_icon_index
jsr L9F9F jsr L9F9F
return #0 ; Highlighted return #0 ; Highlighted
.endproc .endproc
@ -509,10 +511,12 @@ found: asl a
: jsr calc_icon_poly : jsr calc_icon_poly
MGTK_CALL MGTK::SetPenMode, pencopy_2 MGTK_CALL MGTK::SetPenMode, pencopy_2
jsr draw_icon jsr draw_icon
ldy #0
lda (ptr),y ldy #IconEntry::id
ldx num_icons lda (ptr),y ; icon num
jsr LA2E3 ldx num_icons ; new position
jsr change_icon_index
dec num_icons dec num_icons
lda #0 lda #0
ldx num_icons ldx num_icons
@ -616,7 +620,7 @@ loop: lda icon_table,x
bne :+ bne :+
;; Append icon number to buffer. ;; Append icon number to buffer.
ldy #0 ldy #IconEntry::id
lda (ptr),y lda (ptr),y
ldy icon ldy icon
sta buffer,y sta buffer,y
@ -706,10 +710,13 @@ L96E5: dec L96D6
ldy #0 ldy #0
cmp ($06),y cmp ($06),y
bne L96DD bne L96DD
ldy #0
lda ($08),y ;; Move to end of icon list
ldx num_icons ldy #IconEntry::id
jsr LA2E3 lda ($08),y ; icon num
ldx num_icons ; icon index
jsr change_icon_index
dec num_icons dec num_icons
lda #0 lda #0
ldx num_icons ldx num_icons
@ -851,13 +858,15 @@ L97F6: .byte 0
sta L982A sta L982A
tya tya
sta ($06),y sta ($06),y
ldy #4 ldy #4
L9803: lda ($06),y : lda ($06),y
sta L9C8D,y sta L9C8D,y
sta L9C91,y sta L9C91,y
dey dey
cpy #0 cpy #0
bne L9803 bne :-
jsr push_zp_addrs jsr push_zp_addrs
lda L982A lda L982A
jsr L9EB4 jsr L9EB4
@ -962,29 +971,33 @@ L9909: sta L9834
cmp highlight_count cmp highlight_count
beq L9936 beq L9936
jsr push_zp_addrs jsr push_zp_addrs
lda $08 lda $08
sec sec
sbc #$22 sbc #icon_poly_size
sta $08 sta $08
bcs L992D bcs L992D
dec $08+1 dec $08+1
L992D: ldy #IconEntry::state L992D: ldy #IconEntry::state
lda #$80 ; Highlighted lda #$80 ; Highlighted
sta ($08),y sta ($08),y
jsr pop_zp_addrs jsr pop_zp_addrs
L9936: ldx #$21 L9936: ldx #icon_poly_size-1
ldy #$21 ldy #icon_poly_size-1
L993A: lda poly,x L993A: lda poly,x
sta ($08),y sta ($08),y
dey dey
dex dex
bpl L993A bpl L993A
lda #8 lda #8
ldy #0 ldy #0
sta ($08),y sta ($08),y
lda $08 lda $08
clc clc
adc #$22 adc #icon_poly_size
sta $08 sta $08
bcc L9954 bcc L9954
inc $08+1 inc $08+1
@ -1056,12 +1069,12 @@ L99C7: dey
sta L9C7C sta L9C7C
iny iny
L99E1: iny L99E1: iny
cpy #$22 cpy #icon_poly_size
bne L9974 bne L9974
ldy #IconEntry::state ldy #IconEntry::state
lda ($08),y lda ($08),y
beq L99FC beq L99FC
add16 $08, #34, $08 add16 $08, #icon_poly_size, $08
jmp L9972 jmp L9972
L99FC: MGTK_CALL MGTK::SetPattern, checkerboard_pattern2 L99FC: MGTK_CALL MGTK::SetPattern, checkerboard_pattern2
@ -1176,14 +1189,14 @@ L9B62: lda ($08),y
adc L9C99 adc L9C99
sta ($08),y sta ($08),y
iny iny
cpy #$22 cpy #icon_poly_size
bne L9B62 bne L9B62
ldy #IconEntry::state ldy #IconEntry::state
lda ($08),y lda ($08),y
beq L9B9C beq L9B9C
lda $08 lda $08
clc clc
adc #$22 adc #icon_poly_size
sta $08 sta $08
bcc L9B99 bcc L9B99
inc $08+1 inc $08+1
@ -1264,7 +1277,7 @@ L9C29: lda highlight_list,x
pha pha
lda $08 lda $08
clc clc
adc #$22 adc #icon_poly_size
sta $08 sta $08
bcc L9C60 bcc L9C60
inc $08+1 inc $08+1
@ -1476,7 +1489,7 @@ start: lda has_highlight
;; Move it to the end of the highlight list ;; Move it to the end of the highlight list
: ldx highlight_count ; new position : ldx highlight_count ; new position
ldy #0 ldy #IconEntry::id
lda (ptr),y ; icon num lda (ptr),y ; icon num
jsr change_highlight_index jsr change_highlight_index
@ -1738,6 +1751,8 @@ LA189: rts
;;; ;;;
;;; (Label is always at least as wide as the icon) ;;; (Label is always at least as wide as the icon)
icon_poly_size := (8 * .sizeof(MGTK::Point)) + 2
.proc calc_icon_poly .proc calc_icon_poly
entry_ptr := $6 entry_ptr := $6
bitmap_ptr := $8 bitmap_ptr := $8
@ -1917,38 +1932,47 @@ LA2DD: pla
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; A = icon number to move
;;; X = position in highlight list
.proc LA2E3 .proc change_icon_index
stx LA322 stx new_pos
sta LA323 sta icon_num
;; Find position of icon in icon table
ldx #0 ldx #0
LA2EB: lda icon_table,x : lda icon_table,x
cmp LA323 cmp icon_num
beq LA2FA beq :+
inx inx
cpx num_icons cpx num_icons
bne LA2EB bne :-
rts rts
LA2FA: lda icon_table+1,x ;; Shift items down
: lda icon_table+1,x
sta icon_table,x sta icon_table,x
inx inx
cpx num_icons cpx num_icons
bne LA2FA bne :-
;; Shift items up
ldx num_icons ldx num_icons
LA309: cpx LA322 : cpx new_pos
beq LA318 beq place
lda icon_table-2,x lda icon_table-2,x
sta icon_table-1,x sta icon_table-1,x
dex dex
jmp LA309 jmp :-
LA318: ldx LA322 ;; Place at new position
lda LA323 place: ldx new_pos
lda icon_num
sta icon_table-1,x sta icon_table-1,x
rts rts
LA322: .byte 0
LA323: .byte 0 new_pos: .byte 0
icon_num: .byte 0
.endproc .endproc
;;; ============================================================ ;;; ============================================================
@ -1959,7 +1983,7 @@ LA323: .byte 0
stx new_pos stx new_pos
sta icon_num sta icon_num
;; Find position of icon A in highlight list ;; Find position of icon in highlight list
ldx #0 ldx #0
: lda highlight_list,x : lda highlight_list,x
cmp icon_num cmp icon_num
@ -1979,13 +2003,14 @@ LA323: .byte 0
;; Shift items up ;; Shift items up
ldx highlight_count ldx highlight_count
: cpx new_pos : cpx new_pos
beq LA359 beq place
lda highlight_list-2,x lda highlight_list-2,x
sta highlight_list-1,x sta highlight_list-1,x
dex dex
jmp :- jmp :-
LA359: ldx new_pos ;; Place at new position
place: ldx new_pos
lda icon_num lda icon_num
sta highlight_list-1,x sta highlight_list-1,x
rts rts
@ -2165,7 +2190,7 @@ LA466: txa
;; Is icon highlighted? ;; Is icon highlighted?
lda has_highlight lda has_highlight
beq LA49D beq LA49D
ldy #0 ; icon num ldy #IconEntry::id ; icon num
lda (ptr),y lda (ptr),y
ldx #0 ldx #0
: cmp highlight_list,x : cmp highlight_list,x
@ -2174,7 +2199,7 @@ LA466: txa
cpx highlight_count cpx highlight_count
bne :- bne :-
LA49D: ldy #0 ; icon num LA49D: ldy #IconEntry::id ; icon num
lda (ptr),y lda (ptr),y
sta LA3AE sta LA3AE
bit LA3B7 bit LA3B7
@ -3263,8 +3288,8 @@ LBA0B: sta grafport3_viewloc_xcoord,x
sta grafport3_cliprect_x1,x sta grafport3_cliprect_x1,x
dex dex
bpl LBA0B bpl LBA0B
copy16 #$226, grafport3_cliprect_x2 copy16 #550, grafport3_cliprect_x2
copy16 #$B9, grafport3_cliprect_y2 copy16 #185, grafport3_cliprect_y2
MGTK_RELAY2_CALL MGTK::SetPort, grafport3 MGTK_RELAY2_CALL MGTK::SetPort, grafport3
addr_call_indirect LBF8B, portmap::viewloc::xcoord addr_call_indirect LBF8B, portmap::viewloc::xcoord
sty LBFCA sty LBFCA
@ -3308,12 +3333,12 @@ LBAE5: cmp alert_table,y
beq LBAEF beq LBAEF
dey dey
bpl LBAE5 bpl LBAE5
ldy #$00 ldy #0
LBAEF: tya LBAEF: tya
asl a asl a
tay tay
copy16 prompt_table,y, prompt_addr copy16 prompt_table,y, prompt_addr
cpx #$00 cpx #0
beq LBB0B beq LBB0B
txa txa
and #$FE and #$FE
@ -3359,7 +3384,7 @@ LBB9A: cmp #MGTK::event_kind_key_down
bne LBBC3 bne LBBC3
MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR
MGTK_RELAY2_CALL MGTK::PaintRect, cancel_rect MGTK_RELAY2_CALL MGTK::PaintRect, cancel_rect
lda #$01 lda #1
jmp LBC55 jmp LBC55
LBBC3: bit alert_action LBBC3: bit alert_action
@ -3368,7 +3393,7 @@ LBBC3: bit alert_action
bne LBBE3 bne LBBE3
LBBCC: MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR LBBCC: MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR
MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect
lda #$00 lda #0
jmp LBC55 jmp LBC55
LBBE3: cmp #'A' LBBE3: cmp #'A'
@ -3381,7 +3406,7 @@ LBBEE: cmp #CHAR_RETURN
bne LBC09 bne LBC09
MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR
MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect
lda #$02 lda #2
jmp LBC55 jmp LBC55
LBC09: jmp LBB87 LBC09: jmp LBB87
@ -3417,7 +3442,7 @@ LBC55: pha
LBC6D: MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR LBC6D: MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR
MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect
lda #$00 lda #0
sta LBCE8 sta LBCE8
LBC84: MGTK_RELAY2_CALL MGTK::GetEvent, event_params LBC84: MGTK_RELAY2_CALL MGTK::GetEvent, event_params
lda event_kind lda event_kind
@ -3448,13 +3473,13 @@ LBCDB: lda LBCE8
beq LBCE3 beq LBCE3
jmp LBB87 jmp LBB87
LBCE3: lda #$00 LBCE3: lda #0
jmp LBC55 jmp LBC55
LBCE8: .byte 0 LBCE8: .byte 0
LBCE9: MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR LBCE9: MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR
MGTK_RELAY2_CALL MGTK::PaintRect, cancel_rect MGTK_RELAY2_CALL MGTK::PaintRect, cancel_rect
lda #$00 lda #0
sta LBD64 sta LBD64
LBD00: MGTK_RELAY2_CALL MGTK::GetEvent, event_params LBD00: MGTK_RELAY2_CALL MGTK::GetEvent, event_params
lda event_kind lda event_kind
@ -3485,11 +3510,11 @@ LBD57: lda LBD64
beq LBD5F beq LBD5F
jmp LBB87 jmp LBB87
LBD5F: lda #$01 LBD5F: lda #1
jmp LBC55 jmp LBC55
LBD64: .byte 0 LBD64: .byte 0
LBD65: lda #$00 LBD65: lda #0
sta LBDE0 sta LBDE0
MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR MGTK_RELAY2_CALL MGTK::SetPenMode, penXOR
MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect MGTK_RELAY2_CALL MGTK::PaintRect, try_again_rect
@ -3522,7 +3547,7 @@ LBDD3: lda LBDE0
beq LBDDB beq LBDDB
jmp LBB87 jmp LBB87
LBDDB: lda #$02 LBDDB: lda #2
jmp LBC55 jmp LBC55
.endproc .endproc
show_alert_dialog := show_alert_dialog_impl::start show_alert_dialog := show_alert_dialog_impl::start
@ -3576,7 +3601,7 @@ LBE5C: .byte 0
ldx LBFCD ldx LBFCD
ldy LBFCE ldy LBFCE
lda #$FF lda #$FF
cpx #$00 cpx #0
beq LBE78 beq LBE78
LBE73: clc LBE73: clc
rol a rol a
@ -3776,7 +3801,7 @@ LBFCF: .byte $00
ptr := $06 ptr := $06
stax ptr stax ptr
ldy #$00 ldy #0
lda (ptr),y ; Check length lda (ptr),y ; Check length
beq end beq end
sta ptr+2 sta ptr+2

View File

@ -8613,7 +8613,7 @@ selected_device_icon:
;; Assign icon number ;; Assign icon number
ldx cached_window_icon_count ldx cached_window_icon_count
dex dex
ldy #IconEntry::index ldy #IconEntry::id
lda (icon_ptr),y lda (icon_ptr),y
sta cached_window_icon_list,x sta cached_window_icon_list,x
jsr pop_zp_addrs jsr pop_zp_addrs