From b9208870adc759ca4167fe97e08d90832ebbe074 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 15 Feb 2019 19:41:29 -0800 Subject: [PATCH 1/2] disasm: scroll and views --- desktop/desktop_main.s | 120 +++++++++++++++++++---------------------- desktop/desktop_res.s | 2 +- 2 files changed, 55 insertions(+), 67 deletions(-) diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index 6ae1ef1..9ef1b8b 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -248,13 +248,14 @@ L415B: sta active_window_id L41CB: ldx cached_window_id dex lda win_view_by_table,x - bpl L41E2 + bpl by_icon jsr L6C19 copy #0, draw_window_header_flag lda active_window_id jmp assign_window_portbits -L41E2: copy cached_window_id, getwinport_params2::window_id +by_icon: + copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 jsr cached_icons_window_to_screen @@ -620,7 +621,7 @@ L44A6: MGTK_RELAY_CALL MGTK::SelectWindow, findwindow_window_id ldx active_window_id dex lda win_view_by_table,x - and #$0F + and #$0F ; mask off menu item number sta checkitem_params::menu_item inc checkitem_params::menu_item copy #MGTK::checkitem_check, checkitem_params::check @@ -1954,39 +1955,43 @@ L4E71: .byte 0 L4E78: jsr clear_selection dec LEC2E - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable ldx active_window_id dex lda win_view_by_table,x - bmi L4EB4 + bmi iter ; list view, not icons + + ;; View by icon DESKTOP_RELAY_CALL DT_CLOSE_WINDOW, active_window_id + lda icon_count sec sbc cached_window_icon_count sta icon_count - ldx #$00 -L4EA5: cpx cached_window_icon_count - beq L4EB4 + + ldx #0 +: cpx cached_window_icon_count + beq iter lda cached_window_icon_list,x jsr FreeIcon inx - jmp L4EA5 + jmp :- -L4EB4: ldx #$00 +iter: ldx #$00 txa -L4EB7: sta cached_window_icon_list,x +: sta cached_window_icon_list,x cpx cached_window_icon_count beq L4EC3 inx - jmp L4EB7 + jmp :- L4EC3: sta cached_window_icon_count jsr StoreWindowIconTable copy #0, cached_window_id jsr LoadWindowIconTable MGTK_RELAY_CALL MGTK::CloseWindow, active_window_id + ldx active_window_id dex lda window_to_dir_icon_table,x @@ -2232,14 +2237,14 @@ start: : dex lda win_view_by_table,x - bne :+ + bne :+ ; not by icon rts + ;; View by icon entry: -: lda active_window_id - sta cached_window_id +: copy active_window_id, cached_window_id jsr LoadWindowIconTable - ldx #$00 + ldx #0 txa : cpx cached_window_icon_count beq :+ @@ -2304,9 +2309,9 @@ L51A7: jsr reset_grafport3 jsr StoreWindowIconTable jsr update_scrollbars lda selected_window_index - beq L51E3 + beq finish lda selected_icon_count - beq L51E3 + beq finish sta L51EF L51C0: ldx L51EF lda selected_icon_count,x @@ -2318,7 +2323,7 @@ L51C0: ldx L51EF jsr icon_screen_to_window dec L51EF bne L51C0 -L51E3: copy #0, cached_window_id +finish: copy #0, cached_window_id jmp LoadWindowIconTable L51EB: .word 0 @@ -2333,8 +2338,7 @@ L51EF: .byte 0 ldx active_window_id dex sta win_view_by_table,x - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable jsr sort_records jsr StoreWindowIconTable @@ -2484,8 +2488,7 @@ L5265: .byte 0 .proc close_active_window DESKTOP_RELAY_CALL DT_CLOSE_WINDOW, active_window_id - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable lda icon_count sec @@ -2702,11 +2705,11 @@ L544D: L545A: tax dex lda win_view_by_table,x - bpl L5464 + bpl L5464 ; by icon jmp L54C5 -L5464: lda active_window_id - sta cached_window_id + ;; View by icon +L5464: copy active_window_id, cached_window_id jsr LoadWindowIconTable lda active_window_id jsr window_lookup @@ -2743,6 +2746,7 @@ L54B7: pla inx jmp L5485 + ;; No window icons L54BD: copy #0, cached_window_id jsr LoadWindowIconTable L54C5: ldx $1800 @@ -3127,8 +3131,7 @@ vertical: ;;; ============================================================ .proc L5803 - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable ldx active_window_id dex @@ -3598,8 +3601,7 @@ active_window_view_by: .byte 0 .proc handle_client_click - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable ldx active_window_id dex @@ -4045,8 +4047,7 @@ L5E77: .byte 0 jsr open_directory jsr cmd_view_by_icon::entry jsr StoreWindowIconTable - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable copy active_window_id, getwinport_params2::window_id jsr get_port2 @@ -4236,8 +4237,7 @@ L6112: ldy #$14 beq L6143 rts -L6143: lda active_window_id - sta cached_window_id +L6143: copy active_window_id, cached_window_id jsr LoadWindowIconTable ldx #$00 L614E: cpx cached_window_icon_count @@ -4275,8 +4275,7 @@ L6199: .word 0 sta event_params MGTK_RELAY_CALL MGTK::GrowWindow, event_params jsr redraw_windows_and_desktop - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable jsr cached_icons_window_to_screen jsr update_scrollbars @@ -4296,8 +4295,7 @@ handle_close_click: rts .proc close_window - lda active_window_id - sta cached_window_id + copy active_window_id, cached_window_id jsr LoadWindowIconTable jsr clear_selection ldx active_window_id @@ -5223,8 +5221,7 @@ L6BDA: lda L6C0E inc L6C0E jmp L6BDA -L6BF4: lda cached_window_id - sta active_window_id +L6BF4: copy cached_window_id, active_window_id jsr update_scrollbars jsr cached_icons_screen_to_window jsr StoreWindowIconTable @@ -5339,7 +5336,7 @@ L6CCD: lda cached_window_id COPY_BLOCK grafport2::cliprect, tmp_rect - ldx #$00 + ldx #0 txa pha L6CF3: cpx cached_window_icon_count @@ -5406,12 +5403,12 @@ L6D7D: lda L6DB0 inc L6DB0 jmp L6D7D -L6D9B: lda #$00 +L6D9B: lda #0 ldx selected_icon_count dex -L6DA1: sta selected_icon_list,x +: sta selected_icon_list,x dex - bpl L6DA1 + bpl :- sta selected_icon_count sta selected_window_index jmp reset_grafport3 @@ -5434,8 +5431,7 @@ L6DB0: .byte 0 jsr cached_icons_screen_to_window config_port: - lda active_window_id - sta getwinport_params2::window_id + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 ;; check horizontal bounds @@ -5445,20 +5441,16 @@ config_port: bmi activate_hscroll ;; deactivate horizontal scrollbar - lda #MGTK::Ctl::horizontal_scroll_bar - sta activatectl_which_ctl - lda #MGTK::activatectl_deactivate - sta activatectl_activate + copy #MGTK::Ctl::horizontal_scroll_bar, activatectl_which_ctl + copy #MGTK::activatectl_deactivate, activatectl_activate jsr activate_ctl jmp check_vscroll activate_hscroll: ;; activate horizontal scrollbar - lda #MGTK::Ctl::horizontal_scroll_bar - sta activatectl_which_ctl - lda #MGTK::activatectl_activate - sta activatectl_activate + copy #MGTK::Ctl::horizontal_scroll_bar, activatectl_which_ctl + copy #MGTK::activatectl_activate, activatectl_activate jsr activate_ctl jsr update_hthumb @@ -5470,20 +5462,16 @@ check_vscroll: bmi activate_vscroll ;; deactivate vertical scrollbar - lda #MGTK::Ctl::vertical_scroll_bar - sta activatectl_which_ctl - lda #MGTK::activatectl_deactivate - sta activatectl_activate + copy #MGTK::Ctl::vertical_scroll_bar, activatectl_which_ctl + copy #MGTK::activatectl_deactivate, activatectl_activate jsr activate_ctl rts activate_vscroll: ;; activate vertical scrollbar - lda #MGTK::Ctl::vertical_scroll_bar - sta activatectl_which_ctl - lda #MGTK::activatectl_activate - sta activatectl_activate + copy #MGTK::Ctl::vertical_scroll_bar, activatectl_which_ctl + copy #MGTK::activatectl_activate, activatectl_activate jsr activate_ctl jmp update_vthumb @@ -6472,7 +6460,7 @@ L76A4: lda cached_window_id L76AA: lda L7625 cmp L7764 beq L76BB - jsr L7768 + jsr alloc_and_populate_file_icon inc L7625 jmp L76AA @@ -6518,7 +6506,7 @@ L7710: ldy #$20 L7739: addr_jump L7744, $0032 -L7740: ldax #$6C +L7740: ldax #108 L7744: ldy #$22 sta ($06),y txa @@ -6543,7 +6531,7 @@ L7767: .byte $14 ;;; ============================================================ ;;; Create icon -.proc L7768 +.proc alloc_and_populate_file_icon file_entry := $6 icon_entry := $8 name_tmp := $1800 diff --git a/desktop/desktop_res.s b/desktop/desktop_res.s index 271faa7..ee4005f 100644 --- a/desktop/desktop_res.s +++ b/desktop/desktop_res.s @@ -1232,7 +1232,7 @@ LE6C1: .addr winfo8title_ptr ;; (low nibble must match menu order) - view_by_icon = $80 + view_by_icon = $00 view_by_name = $81 view_by_date = $82 view_by_size = $83 From bc56de6ce2ca59a34f106ae114c18c60b1e403a8 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sun, 17 Feb 2019 17:20:49 +1100 Subject: [PATCH 2/2] disasm: scrollbars and ports --- desktop/desktop_main.s | 191 ++++++++++++++++++++++------------------- mgtk.inc | 6 +- 2 files changed, 108 insertions(+), 89 deletions(-) diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index 9ef1b8b..9e95a12 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -257,6 +257,7 @@ L41CB: ldx cached_window_id by_icon: copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr cached_icons_window_to_screen COPY_BLOCK grafport2::cliprect, tmp_rect @@ -273,9 +274,11 @@ L41FE: lda L4241 : inc L4241 jmp L41FE -L4227: copy #$00, draw_window_header_flag +L4227: copy #0, draw_window_header_flag + copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr cached_icons_screen_to_window lda active_window_id jsr assign_window_portbits @@ -2288,9 +2291,10 @@ L516D: lda L51EB,x lda active_window_id jsr create_file_icon_ep2 - lda active_window_id - sta getwinport_params2::window_id + + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr cached_icons_window_to_screen copy #0, L51EF L518D: lda L51EF @@ -3079,7 +3083,7 @@ L578D: .byte 0 ;;; Keyboard-based scrolling of window contents .proc cmd_scroll - jsr L5803 + jsr get_active_window_scroll_info loop: jsr get_event lda event_kind cmp #MGTK::EventKind::button_down @@ -3130,18 +3134,20 @@ vertical: ;;; ============================================================ -.proc L5803 +.proc get_active_window_scroll_info copy active_window_id, cached_window_id jsr LoadWindowIconTable ldx active_window_id dex lda win_view_by_table,x sta active_window_view_by - jsr L58C3 - stax L585F + jsr get_active_window_hscroll_info + sta horiz_scroll_pos + stx horiz_scroll_max sty horiz_scroll_flag - jsr L58E2 - stax L5861 + jsr get_active_window_vscroll_info + sta vert_scroll_pos + stx vert_scroll_max sty vert_scroll_flag rts .endproc @@ -3149,126 +3155,132 @@ vertical: ;;; ============================================================ scroll_right: ; elevator right / contents left - ldax L585F - jsr L5863 - sta L585F + lda horiz_scroll_pos + ldx horiz_scroll_max + jsr do_scroll_right + sta horiz_scroll_pos rts scroll_left: ; elevator left / contents right - lda L585F - jsr L587E - sta L585F + lda horiz_scroll_pos + jsr do_scroll_left + sta horiz_scroll_pos rts scroll_down: ; elevator down / contents up - ldax L5861 - jsr L5893 - sta L5861 + lda vert_scroll_pos + ldx vert_scroll_max + jsr do_scroll_down + sta vert_scroll_pos rts scroll_up: ; elevator up / contents down - lda L5861 - jsr L58AE - sta L5861 + lda vert_scroll_pos + jsr do_scroll_up + sta vert_scroll_pos rts horiz_scroll_flag: .byte 0 ; can scroll horiz? vert_scroll_flag: .byte 0 ; can scroll vert? -L585F: .word 0 -L5861: .word 0 +horiz_scroll_pos: .byte 0 +horiz_scroll_max: .byte 0 +vert_scroll_pos: .byte 0 +vert_scroll_max: .byte 0 -.proc L5863 - stx L587D - cmp L587D +.proc do_scroll_right + stx max + cmp max beq :+ sta updatethumb_stash inc updatethumb_stash - lda #MGTK::Ctl::horizontal_scroll_bar - sta updatethumb_which_ctl - jsr L5C54 + copy #MGTK::Ctl::horizontal_scroll_bar, updatethumb_which_ctl + jsr update_scroll_thumb lda updatethumb_stash : rts -L587D: .byte 0 +max: .byte 0 .endproc -.proc L587E +.proc do_scroll_left beq :+ sta updatethumb_stash dec updatethumb_stash - lda #MGTK::Ctl::horizontal_scroll_bar - sta updatethumb_which_ctl - jsr L5C54 + copy #MGTK::Ctl::horizontal_scroll_bar, updatethumb_which_ctl + jsr update_scroll_thumb lda updatethumb_stash : rts .byte 0 .endproc -.proc L5893 - stx L58AD - cmp L58AD +.proc do_scroll_down + stx max + cmp max beq :+ sta updatethumb_stash inc updatethumb_stash - lda #MGTK::Ctl::vertical_scroll_bar - sta updatethumb_which_ctl - jsr L5C54 + copy #MGTK::Ctl::vertical_scroll_bar, updatethumb_which_ctl + jsr update_scroll_thumb lda updatethumb_stash : rts -L58AD: .byte 0 +max: .byte 0 .endproc -.proc L58AE +.proc do_scroll_up beq :+ sta updatethumb_stash dec updatethumb_stash - lda #MGTK::Ctl::vertical_scroll_bar - sta updatethumb_which_ctl - jsr L5C54 + copy #MGTK::Ctl::vertical_scroll_bar, updatethumb_which_ctl + jsr update_scroll_thumb lda updatethumb_stash : rts .byte 0 .endproc -.proc L58C3 +;;; Output: A = hscroll pos, X = hscroll max, Y = hscroll active flag (high bit) +.proc get_active_window_hscroll_info + ptr := $06 + lda active_window_id jsr window_lookup - stax $06 - ldy #$06 - lda ($06),y + stax ptr + ldy #MGTK::Winfo::hthumbmax + lda (ptr),y tax - iny - lda ($06),y + iny ; hthumbpos + lda (ptr),y pha - ldy #$04 - lda ($06),y - and #$01 + ldy #MGTK::Winfo::hscroll + lda (ptr),y + and #$01 ; active flag clc ror a - ror a + ror a ; shift to high bit tay pla rts .endproc -.proc L58E2 +;;; Output: A = vscroll pos, X = vscroll max, Y = vscroll active flag (high bit) +.proc get_active_window_vscroll_info + ptr := $06 + lda active_window_id jsr window_lookup - stax $06 - ldy #$08 - lda ($06),y + stax ptr + ldy #MGTK::Winfo::vthumbmax + lda (ptr),y tax iny - lda ($06),y + lda (ptr),y pha - ldy #$05 - lda ($06),y - and #$01 + ldy #MGTK::Winfo::vscroll + lda (ptr),y + and #$01 ; active flag clc ror a - ror a + ror a ; shift to high bit tay pla rts @@ -3633,7 +3645,7 @@ active_window_view_by: and #$01 bne :+ jmp done_client_click -: jsr L5803 +: jsr get_active_window_scroll_info lda findcontrol_which_part cmp #MGTK::Part::thumb bne :+ @@ -3679,7 +3691,7 @@ horiz: lda active_window_id and #$01 bne :+ jmp done_client_click -: jsr L5803 +: jsr get_active_window_scroll_info lda findcontrol_which_part cmp #MGTK::Part::thumb bne :+ @@ -3731,7 +3743,7 @@ done_client_click: lda trackthumb_thumbmoved bne :+ rts -: jsr L5C54 +: jsr update_scroll_thumb jsr StoreWindowIconTable copy #0, cached_window_id jmp LoadWindowIconTable @@ -3739,18 +3751,18 @@ done_client_click: ;;; ============================================================ -.proc L5C54 - lda updatethumb_stash - sta updatethumb_thumbpos +.proc update_scroll_thumb + copy updatethumb_stash, updatethumb_thumbpos MGTK_RELAY_CALL MGTK::UpdateThumb, updatethumb_params jsr L6523 jsr L84D1 bit active_window_view_by - bmi :+ + bmi :+ ; list view, no icons jsr cached_icons_screen_to_window -: lda active_window_id - sta getwinport_params2::window_id + +: copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + MGTK_RELAY_CALL MGTK::PaintRect, grafport2::cliprect jsr reset_grafport3 jmp L6C19 @@ -3832,15 +3844,18 @@ replace: inc selected_icon_count copy active_window_id, selected_window_index - copy active_window_id, getwinport_params2::window_id + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + copy icon_num, icon_param jsr icon_window_to_screen jsr offset_grafport2_and_set DESKTOP_RELAY_CALL DT_HIGHLIGHT_ICON, icon_param + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + lda icon_num jsr icon_screen_to_window jsr reset_grafport3 @@ -3900,9 +3915,10 @@ desktop: : cpx #$FF beq L5DF7 - lda active_window_id - sta getwinport_params2::window_id + + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr cached_icons_window_to_screen jsr offset_grafport2_and_set @@ -3918,9 +3934,9 @@ desktop: dex bpl :- - lda active_window_id - sta getwinport_params2::window_id + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr update_scrollbars jsr cached_icons_screen_to_window jsr reset_grafport3 @@ -4016,6 +4032,7 @@ L5E77: .byte 0 : copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr set_penmode_copy MGTK_RELAY_CALL MGTK::PaintRect, grafport2::cliprect ldx active_window_id @@ -5204,9 +5221,9 @@ L6BB8: jsr L744B ldy #MGTK::OpenWindow jsr MGTK_RELAY - lda active_window_id - sta getwinport_params2::window_id + copy active_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr draw_window_header jsr cached_icons_window_to_screen copy #0, L6C0E @@ -5249,9 +5266,10 @@ L6C0E: .byte 0 jmp L6CCD L6C25: jsr push_pointers - lda cached_window_id - sta getwinport_params2::window_id + + copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 + bit draw_window_header_flag bmi :+ jsr draw_window_header @@ -5325,9 +5343,9 @@ rows_done: .byte 0 .endproc -L6CCD: lda cached_window_id - sta getwinport_params2::window_id +L6CCD: copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 + bit draw_window_header_flag bmi :+ jsr draw_window_header @@ -5343,9 +5361,10 @@ L6CF3: cpx cached_window_icon_count bne L6D09 pla jsr reset_grafport3 - lda cached_window_id - sta getwinport_params2::window_id + + copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 + jsr cached_icons_screen_to_window rts diff --git a/mgtk.inc b/mgtk.inc index 235924e..bfcf41c 100644 --- a/mgtk.inc +++ b/mgtk.inc @@ -376,10 +376,10 @@ SetMark = $37 .struct Winfo window_id .byte - options .byte ; option_* + options .byte ; Option::* title .addr - hscroll .byte ; scroll_option_* - vscroll .byte ; scroll_option_* + hscroll .byte ; Scroll::option_* + vscroll .byte ; Scroll::option_* hthumbmax .byte hthumbpos .byte vthumbmax .byte