From 9d9d5b25a8d072df9526a60664c047d26068f237 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sat, 5 Jan 2019 20:57:42 -0800 Subject: [PATCH] disasm: drive refreshing, volume icon creation --- desktop/desktop_main.s | 224 +++++++++++++++++++++++------------------ 1 file changed, 126 insertions(+), 98 deletions(-) diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index 91b77cb..6e20f1d 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -1709,7 +1709,7 @@ L4CD6: pha bpl :+ jmp redraw_windows_and_desktop -: addr_call L6FAF, path_buf4 +: addr_call find_window_for_path, path_buf4 beq :+ pha jsr L6F0D @@ -1726,7 +1726,7 @@ L4CF3: iny iny : dey sty path_buf4 - addr_call L6FB7, path_buf4 + addr_call find_windows_for_prefix, path_buf4 ldax #path_buf4 ldy path_buf4 jsr L6F4B @@ -1824,7 +1824,7 @@ L4D9D: pha : addr_call find_last_path_segment, path_buf3 sty path_buf3 - addr_call L6FAF, path_buf3 + addr_call find_window_for_path, path_buf3 beq L4DC2 pha jsr L6F0D @@ -1841,7 +1841,7 @@ L4DC2: ldy #1 iny : dey sty path_buf3 - addr_call L6FB7, path_buf3 + addr_call find_windows_for_prefix, path_buf3 ldax #path_buf3 ldy path_buf3 jsr L6F4B @@ -2091,7 +2091,7 @@ success: yax_call invoke_dialog_proc, index_new_folder_dialog, new_folder_dialog_params addr_call find_last_path_segment, path_buffer sty path_buffer - addr_call L6FAF, path_buffer + addr_call find_window_for_path, path_buffer beq done jsr select_and_refresh_window @@ -2617,18 +2617,18 @@ not_done: lda ($06),y tay lda $06 - jsr L6FB7 - lda L704B + jsr find_windows_for_prefix + lda found_windows_count beq next_icon -L53EF: dec L704B - ldx L704B - lda L704C,x +L53EF: dec found_windows_count + ldx found_windows_count + lda found_windows_list,x cmp active_window_id beq L5403 sta findwindow_window_id jsr handle_inactive_window_click L5403: jsr close_window - lda L704B + lda found_windows_count bne L53EF jmp next_icon @@ -3295,7 +3295,7 @@ L594A: ldy devlst_index lda #0 sta device_to_icon_map,y lda DEVLST,y - jsr create_volume_icon + jsr create_volume_icon ; A = unit num, Y = device num cmp #ERR_DUPLICATE_VOLUME bne :+ lda #ERR_DUPLICATE_VOL_NAME @@ -3342,6 +3342,9 @@ pending_alert: .proc cmd_check_single_drive + ;; index in DEVLST + devlst_index := menu_click_params::item_num + ;; Check Drive command by_menu: lda #$00 @@ -3374,8 +3377,8 @@ start: sta check_drive_flags dey bpl :- -: sty icon_num_to_refresh - sty menu_click_params::item_num +: sty previous_icon_count ; BUG: overwritten? + sty devlst_index jmp common ;;; -------------------------------------------------- @@ -3390,8 +3393,8 @@ after_format_erase: dey bpl :- iny -: sty icon_num_to_refresh ; misnamed ??? - sty menu_click_params::item_num +: sty previous_icon_count ; BUG: overwritten? + sty devlst_index jmp common ;;; -------------------------------------------------- @@ -3402,102 +3405,121 @@ explicit_command: lda menu_click_params::item_num sec sbc #3 - sta menu_click_params::item_num + sta devlst_index ;;; -------------------------------------------------- common: - ldy menu_click_params::item_num + ldy devlst_index lda device_to_icon_map,y - bne L59FE - jmp L5A4C + bne :+ + jmp not_in_map -L59FE: jsr icon_entry_lookup + ;; Close any associated windows. + + ;; A = icon number +: jsr icon_entry_lookup addax #IconEntry::len, $06 + ptr := $06 + path_buf := $1F00 + + ;; Copy volume path to $1F00 ldy #0 - lda ($06),y + lda (ptr),y tay -: lda ($06),y - sta $1F00,y +: lda (ptr),y + sta path_buf,y dey bpl :- - dec $1F00 + ;; Find all windows with path as prefix, and close them. + dec path_buf lda #'/' - sta $1F00+1 - ldax #$1F00 - ldy $1F00 - jsr L6FB7 - lda L704B - beq L5A4C -L5A2F: ldx L704B - beq L5A4C + sta path_buf+1 + ldax #path_buf + ldy path_buf + jsr find_windows_for_prefix + lda found_windows_count + beq not_in_map + +close_loop: + ldx found_windows_count + beq not_in_map dex - lda L704C,x + lda found_windows_list,x cmp active_window_id - beq L5A43 + beq :+ sta findwindow_window_id jsr handle_inactive_window_click -L5A43: jsr close_window - dec L704B - jmp L5A2F -L5A4C: jsr redraw_windows_and_desktop +: jsr close_window + dec found_windows_count + jmp close_loop + +not_in_map: + + jsr redraw_windows_and_desktop jsr clear_selection copy #0, cached_window_id jsr DESKTOP_COPY_TO_BUF - lda menu_click_params::item_num + + lda devlst_index tay pha lda device_to_icon_map,y sta icon_param - beq L5A7F + beq :+ + jsr remove_icon_from_window dec icon_count lda icon_param jsr DESKTOP_FREE_ICON jsr reset_grafport3 DESKTOP_RELAY_CALL DT_REMOVE_ICON, icon_param -L5A7F: lda cached_window_icon_count - sta icon_num_to_refresh + +: lda cached_window_icon_count + sta previous_icon_count inc cached_window_icon_count inc icon_count pla tay lda DEVLST,y - jsr create_volume_icon + jsr create_volume_icon ; A = unit num, Y = device num bit check_drive_flags - bmi L5AA9 + bmi add_icon ;; Explicit command - and #$FF - beq L5AA9 - cmp #'/' - beq L5AA9 + and #$FF ; check create_volume_icon results + beq add_icon + cmp #$2F ; there was an error ($2F = ???) + beq add_icon pha jsr DESKTOP_COPY_FROM_BUF pla jsr DESKTOP_SHOW_ALERT0 rts -L5AA9: lda cached_window_icon_count - cmp icon_num_to_refresh +add_icon: + lda cached_window_icon_count + cmp previous_icon_count beq :+ + + ;; If a new icon was added, more work is needed. ldx cached_window_icon_count dex lda cached_window_icon_list,x jsr icon_entry_lookup ldy #DT_ADD_ICON jsr DESKTOP_RELAY ; icon entry addr in A,X + : jsr DESKTOP_COPY_FROM_BUF jmp redraw_windows_and_desktop - ;; For format/erase, this is index in DEVLST ??? -icon_num_to_refresh: +previous_icon_count: .byte 0 -L5AC7: .res 9, 0 ; ??? +L5AC7: .res 9, 0 ; unused ??? ;;; 0 = command, $80 = format/erase, $C0 = open/eject/rename check_drive_flags: @@ -5013,7 +5035,7 @@ L6A5C: lda (ptr),y ldax #path_buf ldy path_buf - jsr L6FB7 + jsr find_windows_for_prefix ldax #path_buf ldy path_buf jmp L6F4B @@ -5541,7 +5563,7 @@ loop: iny ; start at 2nd character found: dey finish: sty pathlen - addr_call_indirect L6FB7, ptr ; ??? + addr_call_indirect find_windows_for_prefix, ptr ; ??? ldax pathptr ldy pathlen jmp L6F4B @@ -5566,12 +5588,12 @@ pathlen: .byte 0 jsr get_vol_free_used bne L6F8F - lda L704B + lda found_windows_count beq L6F8F -L6F64: dec L704B +L6F64: dec found_windows_count bmi L6F8F - ldx L704B - lda L704C,x + ldx found_windows_count + lda found_windows_list,x sec sbc #1 asl a @@ -5622,7 +5644,7 @@ slash: cpy #1 ;;; ============================================================ ;; If 'set' version called, length in Y; otherwise use str len -.proc L6FBD +.proc find_windows ptr := $6 set: stax ptr @@ -5632,8 +5654,8 @@ set: stax ptr unset: stax ptr lda #0 -start: sta flag - bit flag +start: sta exact_match_flag + bit exact_match_flag bpl :+ ldy #0 ; Use full length lda (ptr),y @@ -5651,25 +5673,26 @@ start: sta flag addr_call capitalize_string, path_buffer lda #0 - sta L704B - sta L7049 + sta found_windows_count + sta window_num -loop: inc L7049 - lda L7049 +loop: inc window_num + lda window_num cmp #9 ; windows are 1-8 - bcc L6FF6 - bit flag - bpl L6FF5 + bcc check_window + bit exact_match_flag + bpl :+ lda #0 -L6FF5: rts +: rts -L6FF6: jsr window_lookup +check_window: + jsr window_lookup stax ptr ldy #MGTK::Winfo::status lda (ptr),y beq loop - lda L7049 + lda window_num jsr window_path_lookup stax ptr ldy #0 @@ -5678,7 +5701,7 @@ L6FF6: jsr window_lookup cmp path_buffer beq :+ - bit flag + bit exact_match_flag bmi loop ldy path_buffer iny @@ -5693,25 +5716,28 @@ L6FF6: jsr window_lookup dey bne :- - bit flag + bit exact_match_flag bmi done - ldx L704B - lda L7049 - sta L704C,x - inc L704B + ldx found_windows_count + lda window_num + sta found_windows_list,x + inc found_windows_count jmp loop -done: return L7049 +done: return window_num -L7049: .byte 0 -flag: .byte 0 +window_num: + .byte 0 +exact_match_flag: + .byte 0 .endproc - L6FAF := L6FBD::set - L6FB7 := L6FBD::unset + find_window_for_path := find_windows::set + find_windows_for_prefix := find_windows::unset - -L704B: .byte 0 -L704C: .res 8 +found_windows_count: + .byte 0 +found_windows_list: + .res 8 ;;; ============================================================ @@ -8718,7 +8744,9 @@ pos_win: .word 0, 0 .endproc ;;; ============================================================ -;;; Create Volume Icon. unit_number passed in A +;;; Create Volume Icon +;;; Input: A = unit number, Y = device number (index in DEVLST) +;;; Output: 0 on success, ProDOS error code on failure cvi_data_buffer := $800 @@ -8726,14 +8754,14 @@ pos_win: .word 0, 0 .proc create_volume_icon sta unit_number - sty device_num + sty devlst_index and #$F0 sta on_line_params::unit_num MLI_RELAY_CALL ON_LINE, on_line_params beq success error: pha ; save error - ldy device_num ; remove unit from list + ldy devlst_index ; remove unit from list lda #0 sta device_to_icon_map,y dec cached_window_icon_count @@ -8753,7 +8781,7 @@ create_icon: jsr push_pointers jsr DESKTOP_ALLOC_ICON - ldy device_num + ldy devlst_index sta device_to_icon_map,y jsr icon_entry_lookup stax icon_ptr @@ -8846,10 +8874,10 @@ selected_device_icon: ldy #IconEntry::win_type lda #0 sta (icon_ptr),y - inc device_num + inc devlst_index ;; Assign icon coordinates - lda device_num + lda devlst_index asl a ; device num * 4 is coordinates index asl a tax @@ -8869,12 +8897,11 @@ selected_device_icon: sta cached_window_icon_list,x jsr pop_pointers return #0 -.endproc ;;; ============================================================ unit_number: .byte 0 -device_num: .byte 0 +devlst_index: .byte 0 desktop_icon_coords_table: DEFINE_POINT 0,0 @@ -8888,11 +8915,12 @@ desktop_icon_coords_table: DEFINE_POINT 220,160 DEFINE_POINT 130,160 DEFINE_POINT 40,160 - - DEFINE_GET_PREFIX_PARAMS get_prefix_params, prefix_buffer +.endproc ;;; ============================================================ + DEFINE_GET_PREFIX_PARAMS get_prefix_params, prefix_buffer + .proc remove_icon_from_window ldx cached_window_icon_count dex @@ -15474,7 +15502,7 @@ process_volume: inc cached_window_icon_count inc icon_count lda DEVLST,y - jsr desktop_main::create_volume_icon + jsr desktop_main::create_volume_icon ; A = unit number, Y = device number sta cvi_result MGTK_RELAY_CALL MGTK::CheckEvents