From 3f15d12eb1fc4317e2676961beab37fa1f432791 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sun, 27 May 2018 09:31:43 -0700 Subject: [PATCH] DeskTop: Internal API noodling --- APIs.md | 11 ++++++-- desktop.inc | 4 +-- desktop/desktop_aux.s | 59 +++++++++++++++++++++++++----------------- desktop/desktop_main.s | 4 +-- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/APIs.md b/APIs.md index f81bf1b..1056aa3 100644 --- a/APIs.md +++ b/APIs.md @@ -159,11 +159,11 @@ Parameters: { byte icon } Redraws an icon by number. -### `DT_HIGHLIGHT_ICON` ($04) +### `DT_REMOVE_ICON` ($04) Parameters: { byte icon } -Unhighlights (deselects) an icon by number. +Removes an icon by number. ### `DT_HIGHLIGHT_ALL` ($05) @@ -195,6 +195,13 @@ Parameters: { word mousex, word mousey, (out) byte result } Find the icon number at the given coordinates. +### `DT_UNHIGHLIGHT_ICON` ($0B) + +Parameters: { addr iconentry } + +Unhighlights the specified icon. Note that the address of the icon +entry is passed, not the number. + ### `DT_REDRAW_ICONS` ($0C) Parameters: none (pass $0000 as address) diff --git a/desktop.inc b/desktop.inc index 2de80f4..ad72acc 100644 --- a/desktop.inc +++ b/desktop.inc @@ -58,14 +58,14 @@ DESKTOP := $8E00 DT_ADD_ICON := $01 ; { .addr icondata } DT_HIGHLIGHT_ICON := $02 ; { .byte icon } DT_REDRAW_ICON := $03 ; { .byte icon } -DT_UNHIGHLIGHT_ICON := $04 ; { .byte icon } +DT_REMOVE_ICON := $04 ; { .byte icon } DT_HIGHLIGHT_ALL := $05 ; { .byte window_id } DT_UNHIGHLIGHT_ALL := $06 DT_CLOSE_WINDOW := $07 ; { .byte window_id } DT_GET_HIGHLIGHTED := $08 ; { .res 20 } DT_FIND_ICON := $09 ; { .word mousex, .word mousey, .byte result } ;; $0A ??? - ;; $0B ??? +DT_UNHIGHLIGHT_ICON := $0B ; { .addr iconentry } DT_REDRAW_ICONS := $0C ; Repaints desktop icons * DT_ICON_IN_RECT := $0D ; { .byte icon, rect bounds } DT_REDRAW_ICON_IDX := $0E ; { .byte icon_index } diff --git a/desktop/desktop_aux.s b/desktop/desktop_aux.s index afe47d6..d11bfea 100644 --- a/desktop/desktop_aux.s +++ b/desktop/desktop_aux.s @@ -235,18 +235,18 @@ notpenBIC_2: .byte 7 ;;; DESKTOP command jump table desktop_jump_table: - .addr 0 ; $00 + .addr 0 .addr ADD_ICON_IMPL .addr HIGHLIGHT_ICON_IMPL .addr REDRAW_ICON_IMPL - .addr UNHIGHLIGHT_ICON_IMPL + .addr REMOVE_ICON_IMPL .addr HIGHLIGHT_ALL_IMPL .addr UNHIGHLIGHT_ALL_IMPL .addr CLOSE_WINDOW_IMPL .addr GET_HIGHLIGHTED_IMPL .addr FIND_ICON_IMPL .addr L97F7 ; $0A - .addr L9EBE ; $0B + .addr UNHIGHLIGHT_ICON_IMPL .addr REDRAW_ICONS_IMPL .addr ICON_IN_RECT_IMPL .addr REDRAW_ICON_IDX_IMPL @@ -476,9 +476,11 @@ done: jsr L9F98 .endproc ;;; ============================================================ -;;; UNHIGHLIGHT_ICON IMPL +;;; REMOVE_ICON IMPL -.proc UNHIGHLIGHT_ICON_IMPL +;;; param is pointer to icon number + +.proc REMOVE_ICON_IMPL PARAM_BLOCK params, $06 ptr_icon: .addr 0 END_PARAM_BLOCK @@ -512,40 +514,48 @@ found: asl a MGTK_CALL MGTK::SetPenMode, pencopy_2 jsr draw_icon + ;; Move it to the end of the icon list ldy #IconEntry::id lda (ptr),y ; icon num ldx num_icons ; new position jsr change_icon_index + ;; Remove it from the list dec num_icons lda #0 ldx num_icons sta icon_table,x + + ;; Clear its flag ldy #IconEntry::state lda #0 sta (ptr),y + lda has_highlight beq done + ;; Find it in the highlight list ldx highlight_count dex ldy #0 lda (ptr),y -L9566: cmp highlight_list,x - beq L9571 +: cmp highlight_list,x + beq found2 dex - bpl L9566 + bpl :- + jmp done ; not found - jmp done - -L9571: ldx highlight_count ; new position + ;; Move it to the end of the highlight list +found2: ldx highlight_count ; new position jsr change_highlight_index + + ;; Remove it from the highloight list and update flag dec highlight_count lda highlight_count - bne L9584 + bne :+ lda #0 sta has_highlight -L9584: lda #0 +: lda #0 ldx highlight_count sta highlight_list,x @@ -677,7 +687,7 @@ L969D: ldx L9696 ldy #0 cmp ($06),y bne L969D - DESKTOP_DIRECT_CALL DT_UNHIGHLIGHT_ICON, L9695 + DESKTOP_DIRECT_CALL DT_REMOVE_ICON, L9695 jmp L969D L96CF: return #0 .endproc @@ -1468,12 +1478,17 @@ L9EB4: asl a .endproc ;;; ============================================================ +;;; UNHIGHLIGHT_ICON IMPL -;;; DESKTOP $0B IMPL +;;; param is pointer to icon entry + +.proc UNHIGHLIGHT_ICON_IMPL + PARAM_BLOCK params, $06 +ptr_iconent: .addr 0 + END_PARAM_BLOCK + ptr := $06 ; Overwrites param - ;; Deselect icon ??? -.proc L9EBE jmp start .byte 0 ; ??? @@ -1481,8 +1496,6 @@ L9EB4: asl a ;; DT_REDRAW_ICON params icon: .byte 0 - ptr := $6 - start: lda has_highlight bne :+ return #1 ; No selection @@ -1490,16 +1503,14 @@ start: lda has_highlight ;; Move it to the end of the highlight list : ldx highlight_count ; new position ldy #IconEntry::id - lda (ptr),y ; icon num + lda (params::ptr_iconent),y ; icon num jsr change_highlight_index - ;; Remove it from the list + ;; Remove it from the highlight list and update flag ldx highlight_count lda #0 sta highlight_count,x dec highlight_count - - ;; Update flag lda highlight_count bne :+ lda #0 @@ -1507,7 +1518,7 @@ start: lda has_highlight ;; Redraw : ldy #0 - lda (ptr),y + lda (params::ptr_iconent),y sta icon DESKTOP_DIRECT_CALL DT_REDRAW_ICON, icon return #0 diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index 785891d..c5d58e9 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -3142,7 +3142,7 @@ L5916: lda cached_window_icon_list,x sta icon_param lda #$00 sta cached_window_icon_list,x - DESKTOP_RELAY_CALL DT_UNHIGHLIGHT_ICON, icon_param + DESKTOP_RELAY_CALL DT_REMOVE_ICON, icon_param lda icon_param jsr DESKTOP_FREE_ICON dec cached_window_icon_count @@ -3289,7 +3289,7 @@ L5A4C: jsr redraw_windows_and_desktop lda icon_param jsr DESKTOP_FREE_ICON jsr reset_grafport3 - DESKTOP_RELAY_CALL DT_UNHIGHLIGHT_ICON, icon_param + DESKTOP_RELAY_CALL DT_REMOVE_ICON, icon_param L5A7F: lda cached_window_icon_count sta L5AC6 inc cached_window_icon_count