disasm: prompt/input key handling

This commit is contained in:
Joshua Bell 2019-02-22 11:34:02 +11:00
parent f2830f2140
commit ea44e37814
2 changed files with 186 additions and 115 deletions

View File

@ -10,13 +10,6 @@
.proc desktop_main .proc desktop_main
.scope format_erase_overlay
L0CB8 := $0CB8
L0CD7 := $0CD7
L0CF9 := $0CF9
L0D14 := $0D14
.endscope
dst_path_buf := $1FC0 dst_path_buf := $1FC0
dynamic_routine_800 := $0800 dynamic_routine_800 := $0800
@ -12580,47 +12573,50 @@ LA6F7: jsr LB9B8
.proc prompt_key_handler .proc prompt_key_handler
lda event_modifiers lda event_modifiers
cmp #MGTK::event_modifier_solid_apple cmp #MGTK::event_modifier_solid_apple
bne LA71A bne no_mods
;; Modifier key down.
lda event_key lda event_key
and #CHAR_MASK and #CHAR_MASK
cmp #CHAR_LEFT cmp #CHAR_LEFT
bne LA710 bne :+
jmp LA815 jmp left_with_mod
LA710: cmp #CHAR_RIGHT : cmp #CHAR_RIGHT
bne LA717 bne done
jmp LA820 jmp right_with_mod
LA717: return #$FF done: return #$FF
LA71A: lda event_key ;; No modifier key down.
no_mods:
lda event_key
and #CHAR_MASK and #CHAR_MASK
cmp #CHAR_LEFT cmp #CHAR_LEFT
bne LA72E bne LA72E
bit format_erase_overlay_flag bit format_erase_overlay_flag
bpl :+ bpl :+
jmp format_erase_overlay::L0CB8 jmp format_erase_overlay_prompt_handle_key_left
: jmp handle_key_left
: jmp LA82B
LA72E: cmp #CHAR_RIGHT LA72E: cmp #CHAR_RIGHT
bne LA73D bne LA73D
bit format_erase_overlay_flag bit format_erase_overlay_flag
bpl :+ bpl :+
jmp format_erase_overlay::L0CD7 jmp format_erase_overlay_prompt_handle_key_right
: jmp handle_key_right
: jmp LA83E
LA73D: cmp #CHAR_RETURN LA73D: cmp #CHAR_RETURN
bne LA749 bne LA749
bit LD8E7 bit LD8E7
bvs LA717 bvs done
jmp LA851 jmp LA851
LA749: cmp #CHAR_ESCAPE LA749: cmp #CHAR_ESCAPE
bne LA755 bne LA755
bit LD8E7 bit LD8E7
bmi LA717 bmi done
jmp LA86F jmp LA86F
LA755: cmp #CHAR_DELETE LA755: cmp #CHAR_DELETE
@ -12630,18 +12626,16 @@ LA755: cmp #CHAR_DELETE
LA75C: cmp #CHAR_UP LA75C: cmp #CHAR_UP
bne LA76B bne LA76B
bit format_erase_overlay_flag bit format_erase_overlay_flag
bmi LA768 bmi :+
jmp LA717 jmp done
: jmp format_erase_overlay_prompt_handle_key_up
LA768: jmp format_erase_overlay::L0D14
LA76B: cmp #CHAR_DOWN LA76B: cmp #CHAR_DOWN
bne LA77A bne LA77A
bit format_erase_overlay_flag bit format_erase_overlay_flag
bmi LA777 bmi :+
jmp LA717 jmp done
: jmp format_erase_overlay_prompt_handle_key_down
LA777: jmp format_erase_overlay::L0CF9
LA77A: bit LD8E7 LA77A: bit LD8E7
bvc LA79B bvc LA79B
@ -12666,32 +12660,32 @@ LA79B: bit LD8F5
beq LA7D8 beq LA7D8
cmp #'0' cmp #'0'
bcs LA7AB bcs LA7AB
jmp LA717 jmp done
LA7AB: cmp #'z'+1 LA7AB: cmp #'z'+1
bcc LA7B2 bcc LA7B2
jmp LA717 jmp done
LA7B2: cmp #'9'+1 LA7B2: cmp #'9'+1
bcc LA7D8 bcc LA7D8
cmp #'A' cmp #'A'
bcs LA7BD bcs LA7BD
jmp LA717 jmp done
LA7BD: cmp #'Z'+1 LA7BD: cmp #'Z'+1
bcc LA7DD bcc LA7DD
cmp #'a' cmp #'a'
bcs LA7DD bcs LA7DD
jmp LA717 jmp done
LA7C8: cmp #' ' LA7C8: cmp #' '
bcs LA7CF bcs LA7CF
jmp LA717 jmp done
LA7CF: cmp #'~' LA7CF: cmp #'~'
beq LA7DD beq LA7DD
bcc LA7DD bcc LA7DD
jmp LA717 jmp done
LA7D8: ldx path_buf1 LA7D8: ldx path_buf1
beq LA7E5 beq LA7E5
@ -12712,33 +12706,41 @@ do_all: jsr set_penmode_xor2
MGTK_RELAY_CALL MGTK::PaintRect, desktop_aux::all_button_rect MGTK_RELAY_CALL MGTK::PaintRect, desktop_aux::all_button_rect
return #PromptResult::all return #PromptResult::all
LA815: lda has_input_field_flag .proc left_with_mod
beq LA81D lda has_input_field_flag
jsr LBC5E beq :+
LA81D: return #$FF jsr input_field_ip_start
: return #$FF
.endproc
LA820: lda has_input_field_flag .proc right_with_mod
beq LA828 lda has_input_field_flag
jsr LBCC9 beq :+
LA828: return #$FF jsr input_field_ip_end
: return #$FF
.endproc
LA82B: lda has_input_field_flag .proc handle_key_left
beq LA83B lda has_input_field_flag
bit format_erase_overlay_flag beq done
bpl LA838 bit format_erase_overlay_flag ; BUG? Should never be set here based on caller test.
jmp format_erase_overlay::L0CD7 bpl :+
jmp format_erase_overlay_prompt_handle_key_right
LA838: jsr LBBA4 : jsr input_field_ip_left
LA83B: return #$FF done: return #$FF
.endproc
LA83E: lda has_input_field_flag .proc handle_key_right
beq LA84E lda has_input_field_flag
bit format_erase_overlay_flag beq done
bpl LA84B bit format_erase_overlay_flag ; BUG? Should never be set here based on caller test.
jmp format_erase_overlay::L0CB8 bpl :+
jmp format_erase_overlay_prompt_handle_key_left
LA84B: jsr LBC03 : jsr input_field_ip_right
LA84E: return #$FF done: return #$FF
.endproc
LA851: lda winfo_alert_dialog LA851: lda winfo_alert_dialog
jsr set_port_from_window_id jsr set_port_from_window_id
@ -13629,7 +13631,7 @@ LB2FD: jsr prompt_input_loop
bne LB313 bne LB313
lda path_buf1 lda path_buf1
beq LB2FD beq LB2FD
jsr LBCC9 jsr input_field_ip_end
ldy #<path_buf1 ldy #<path_buf1
ldx #>path_buf1 ldx #>path_buf1
return #0 return #0
@ -14459,7 +14461,7 @@ LBA42:
cmp path_buf2 cmp path_buf2
bcc LBA4F bcc LBA4F
dec path_buf2 dec path_buf2
jmp LBCC9 jmp input_field_ip_end
LBA4F: ldx #2 LBA4F: ldx #2
ldy path_buf1 ldy path_buf1
@ -14506,7 +14508,7 @@ LBA7C: dey
lda textlen lda textlen
cmp #1 cmp #1
bcs :- bcs :-
jmp LBC5E jmp input_field_ip_start
;; Copy the text to the right of the click to split_buf ;; Copy the text to the right of the click to split_buf
: inc textlen : inc textlen
@ -14615,8 +14617,10 @@ param: .byte 0
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Move IP one character left.
.proc LBBA4 .proc input_field_ip_left
;; Any characters to left of IP?
lda path_buf1 lda path_buf1
bne :+ bne :+
rts rts
@ -14627,17 +14631,23 @@ param: .byte 0
: ldx path_buf2 : ldx path_buf2
cpx #1 cpx #1
beq LBBBC beq finish
LBBB1: lda path_buf2,x
;; Shift right up by a character.
loop: lda path_buf2,x
sta path_buf2+1,x sta path_buf2+1,x
dex dex
cpx #1 cpx #1
bne LBBB1 bne loop
LBBBC: ldx path_buf1
;; Copy character left to right and adjust lengths.
finish: ldx path_buf1
lda path_buf1,x lda path_buf1,x
sta path_buf2+2 sta path_buf2+2
dec path_buf1 dec path_buf1
inc path_buf2 inc path_buf2
;; Redraw (just the right part)
jsr measure_path_buf1 jsr measure_path_buf1
stax xcoord stax xcoord
copy16 name_input_textpos::ycoord, ycoord copy16 name_input_textpos::ycoord, ycoord
@ -14651,28 +14661,36 @@ LBBBC: ldx path_buf1
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Move IP one character right.
.proc LBC03 .proc input_field_ip_right
;; Any characters to right of IP?
lda path_buf2 lda path_buf2
cmp #$02 cmp #2
bcs LBC0B bcs :+
rts rts
LBC0B: ldx path_buf1 ;; Copy char from right to left and adjust lengths.
: ldx path_buf1
inx inx
lda path_buf2+2 lda path_buf2+2
sta path_buf1,x sta path_buf1,x
inc path_buf1 inc path_buf1
ldx path_buf2 ldx path_buf2
cpx #$03 cpx #3
bcc LBC2D bcc finish
ldx #$02
LBC21: lda path_buf2+1,x ;; Shift right string down.
ldx #2
loop: lda path_buf2+1,x
sta path_buf2,x sta path_buf2,x
inx inx
cpx path_buf2 cpx path_buf2
bne LBC21 bne loop
LBC2D: dec path_buf2
;; Redraw (the whole thing)
finish: dec path_buf2
MGTK_RELAY_CALL MGTK::MoveTo, name_input_textpos MGTK_RELAY_CALL MGTK::MoveTo, name_input_textpos
MGTK_RELAY_CALL MGTK::SetPortBits, name_input_mapinfo MGTK_RELAY_CALL MGTK::SetPortBits, name_input_mapinfo
addr_call draw_text1, path_buf1 addr_call draw_text1, path_buf1
@ -14684,28 +14702,38 @@ LBC2D: dec path_buf2
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Move IP to start of input field.
.proc LBC5E .proc input_field_ip_start
;; Any characters to left of IP?
lda path_buf1 lda path_buf1
bne LBC64 bne :+
rts rts
LBC64: ldx path_buf2 ;; Any characters to right of IP?
cpx #$01 : ldx path_buf2
beq LBC79 cpx #1
LBC6B: lda path_buf2,x beq move
;; Preserve right characters up to make room.
;; TODO: Why not just shift them up???
loop1: lda path_buf2,x
sta split_buf-1,x sta split_buf-1,x
dex dex
cpx #$01 cpx #1
bne LBC6B bne loop1
ldx path_buf2 ldx path_buf2
LBC79: dex
;; Move characters left to right
move: dex
stx split_buf stx split_buf
ldx path_buf1 ldx path_buf1
LBC80: lda path_buf1,x loop2: lda path_buf1,x
sta path_buf2+1,x sta path_buf2+1,x
dex dex
bne LBC80 bne loop2
;; Adjust lengths.
lda str_insertion_point+1 lda str_insertion_point+1
sta path_buf2+1 sta path_buf2+1
inc path_buf1 inc path_buf1
@ -14716,48 +14744,58 @@ LBC80: lda path_buf1,x
adc split_buf adc split_buf
tay tay
pha pha
;; Append right right characters again if needed.
ldx split_buf ldx split_buf
beq LBCB3 beq finish
LBCA6: lda split_buf,x loop3: lda split_buf,x
sta path_buf2,y sta path_buf2,y
dex dex
dey dey
cpy path_buf2 cpy path_buf2
bne LBCA6 bne loop3
LBCB3: pla
finish: pla
sta path_buf2 sta path_buf2
copy #0, path_buf1 copy #0, path_buf1
MGTK_RELAY_CALL MGTK::MoveTo, name_input_textpos MGTK_RELAY_CALL MGTK::MoveTo, name_input_textpos ; Seems unnecessary???
jsr draw_filename_prompt jsr draw_filename_prompt
rts rts
.endproc .endproc
;;; ============================================================ ;;; ============================================================
;;; Move IP to end of input field.
.proc LBCC9 .proc input_field_ip_end
;; Any characters to right of IP?
lda path_buf2 lda path_buf2
cmp #$02 cmp #2
bcs LBCD1 bcs LBCD1
rts rts
;; Compute new lengths.
LBCD1: ldx path_buf2 LBCD1: ldx path_buf2
dex dex
txa txa
clc clc
adc path_buf1 adc path_buf1
pha pha
;; Move characters from right to left.
tay tay
ldx path_buf2 ldx path_buf2
LBCDF: lda path_buf2,x loop: lda path_buf2,x
sta path_buf1,y sta path_buf1,y
dex dex
dey dey
cpy path_buf1 cpy path_buf1
bne LBCDF bne loop
;; Adjust lengths and redraw.
pla pla
sta path_buf1 sta path_buf1
copy #1, path_buf2 copy #1, path_buf2
MGTK_RELAY_CALL MGTK::MoveTo, name_input_textpos MGTK_RELAY_CALL MGTK::MoveTo, name_input_textpos ; Seems unnecessary???
jsr draw_filename_prompt jsr draw_filename_prompt
rts rts
.endproc .endproc

View File

@ -295,7 +295,7 @@ L0BBB: lda L0C1F
lda LD887 lda LD887
bmi L0BD9 bmi L0BD9
lda LD887 lda LD887
jsr L0C20 jsr hilight_volume_label
lda #$FF lda #$FF
sta LD887 sta LD887
L0BD9: return #$FF L0BD9: return #$FF
@ -313,10 +313,10 @@ L0C03: rts
L0C04: sta L0C1E L0C04: sta L0C1E
lda LD887 lda LD887
bmi L0C0F bmi L0C0F
jsr L0C20 jsr hilight_volume_label
L0C0F: lda L0C1E L0C0F: lda L0C1E
sta LD887 sta LD887
jsr L0C20 jsr hilight_volume_label
jsr desktop_main::detect_double_click2 jsr desktop_main::detect_double_click2
beq L0BE6 beq L0BE6
rts rts
@ -328,14 +328,15 @@ L0C1F: .byte 0
;;; Hilight volume label ;;; Hilight volume label
;;; Input: A = volume index ;;; Input: A = volume index
L0C20: ldy #39 .proc hilight_volume_label
ldy #39
sty select_volume_rect::x1 sty select_volume_rect::x1
ldy #0 ldy #0
sty select_volume_rect::x1+1 sty select_volume_rect::x1+1
tax tax
lsr a ; / 4 lsr a ; / 4
lsr a lsr a
sta L0CA9 ; columne (0, 1, or 2) sta L0CA9 ; column (0, 1, or 2)
beq L0C5B beq L0C5B
add16 select_volume_rect::x1, #120, select_volume_rect::x1 add16 select_volume_rect::x1, #120, select_volume_rect::x1
lda L0CA9 lda L0CA9
@ -362,14 +363,23 @@ L0C5B: asl L0CA9 ; * 4
rts rts
L0CA9: .byte 0 L0CA9: .byte 0
L0CAA: lda LD887 .endproc
bmi L0CB7
jsr L0C20 ;;; ============================================================
.proc L0CAA
lda LD887
bmi :+
jsr hilight_volume_label
copy #$FF, LD887 copy #$FF, LD887
L0CB7: rts : rts
.endproc
;;; ============================================================
;; Called from desktop_main ;; Called from desktop_main
L0CB8: lda LD887 .proc prompt_handle_key_left
lda LD887
bpl L0CC1 bpl L0CC1
lda #0 lda #0
beq L0CCE beq L0CCE
@ -381,9 +391,14 @@ L0CC1: clc
jsr L0CAA jsr L0CAA
pla pla
L0CCE: sta LD887 L0CCE: sta LD887
jsr L0C20 jsr hilight_volume_label
L0CD4: return #$FF L0CD4: return #$FF
.endproc
;;; ============================================================
;; Called from desktop_main
.proc prompt_handle_key_right
lda LD887 lda LD887
bpl L0CE6 bpl L0CE6
lda LD890 lda LD890
@ -394,28 +409,38 @@ L0CD4: return #$FF
jmp L0CF0 jmp L0CF0
L0CE6: sec L0CE6: sec
sbc #$04 sbc #4
bmi L0CF6 bmi L0CF6
pha pha
jsr L0CAA jsr L0CAA
pla pla
L0CF0: sta LD887 L0CF0: sta LD887
jsr L0C20 jsr hilight_volume_label
L0CF6: return #$FF L0CF6: return #$FF
.endproc
;;; ============================================================
;; Called from desktop_main
.proc prompt_handle_key_down
lda LD887 lda LD887
clc clc
adc #$01 adc #1
cmp LD890 cmp LD890
bcc L0D06 bcc L0D06
lda #$00 lda #0
L0D06: pha L0D06: pha
jsr L0CAA jsr L0CAA
pla pla
sta LD887 sta LD887
jsr L0C20 jsr hilight_volume_label
return #$FF return #$FF
.endproc
;;; ============================================================
;; Called from desktop_main
.proc prompt_handle_key_up
lda LD887 lda LD887
bmi L0D1E bmi L0D1E
sec sec
@ -428,8 +453,11 @@ L0D23: pha
jsr L0CAA jsr L0CAA
pla pla
sta LD887 sta LD887
jsr L0C20 jsr hilight_volume_label
return #$FF return #$FF
.endproc
;;; ============================================================
L0D31: ldx DEVCNT L0D31: ldx DEVCNT
inx inx
@ -1533,3 +1561,8 @@ L1A6D: lda on_line_params::unit_num
PAD_TO $1C00 PAD_TO $1C00
.endproc ; format_erase_overlay .endproc ; format_erase_overlay
format_erase_overlay_prompt_handle_key_left := format_erase_overlay::prompt_handle_key_left
format_erase_overlay_prompt_handle_key_right := format_erase_overlay::prompt_handle_key_right
format_erase_overlay_prompt_handle_key_down := format_erase_overlay::prompt_handle_key_down
format_erase_overlay_prompt_handle_key_up := format_erase_overlay::prompt_handle_key_up