DeskTop: Internal API noodling

This commit is contained in:
Joshua Bell
2018-05-27 09:31:43 -07:00
parent 3fff12d1f3
commit 3f15d12eb1
4 changed files with 48 additions and 30 deletions

11
APIs.md
View File

@@ -159,11 +159,11 @@ Parameters: { byte icon }
Redraws an icon by number. Redraws an icon by number.
### `DT_HIGHLIGHT_ICON` ($04) ### `DT_REMOVE_ICON` ($04)
Parameters: { byte icon } Parameters: { byte icon }
Unhighlights (deselects) an icon by number. Removes an icon by number.
### `DT_HIGHLIGHT_ALL` ($05) ### `DT_HIGHLIGHT_ALL` ($05)
@@ -195,6 +195,13 @@ Parameters: { word mousex, word mousey, (out) byte result }
Find the icon number at the given coordinates. 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) ### `DT_REDRAW_ICONS` ($0C)
Parameters: none (pass $0000 as address) Parameters: none (pass $0000 as address)

View File

@@ -58,14 +58,14 @@ DESKTOP := $8E00
DT_ADD_ICON := $01 ; { .addr icondata } DT_ADD_ICON := $01 ; { .addr icondata }
DT_HIGHLIGHT_ICON := $02 ; { .byte icon } DT_HIGHLIGHT_ICON := $02 ; { .byte icon }
DT_REDRAW_ICON := $03 ; { .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_HIGHLIGHT_ALL := $05 ; { .byte window_id }
DT_UNHIGHLIGHT_ALL := $06 DT_UNHIGHLIGHT_ALL := $06
DT_CLOSE_WINDOW := $07 ; { .byte window_id } DT_CLOSE_WINDOW := $07 ; { .byte window_id }
DT_GET_HIGHLIGHTED := $08 ; { .res 20 } DT_GET_HIGHLIGHTED := $08 ; { .res 20 }
DT_FIND_ICON := $09 ; { .word mousex, .word mousey, .byte result } DT_FIND_ICON := $09 ; { .word mousex, .word mousey, .byte result }
;; $0A ??? ;; $0A ???
;; $0B ??? DT_UNHIGHLIGHT_ICON := $0B ; { .addr iconentry }
DT_REDRAW_ICONS := $0C ; Repaints desktop icons * DT_REDRAW_ICONS := $0C ; Repaints desktop icons *
DT_ICON_IN_RECT := $0D ; { .byte icon, rect bounds } DT_ICON_IN_RECT := $0D ; { .byte icon, rect bounds }
DT_REDRAW_ICON_IDX := $0E ; { .byte icon_index } DT_REDRAW_ICON_IDX := $0E ; { .byte icon_index }

View File

@@ -235,18 +235,18 @@ notpenBIC_2: .byte 7
;;; DESKTOP command jump table ;;; DESKTOP command jump table
desktop_jump_table: desktop_jump_table:
.addr 0 ; $00 .addr 0
.addr ADD_ICON_IMPL .addr ADD_ICON_IMPL
.addr HIGHLIGHT_ICON_IMPL .addr HIGHLIGHT_ICON_IMPL
.addr REDRAW_ICON_IMPL .addr REDRAW_ICON_IMPL
.addr UNHIGHLIGHT_ICON_IMPL .addr REMOVE_ICON_IMPL
.addr HIGHLIGHT_ALL_IMPL .addr HIGHLIGHT_ALL_IMPL
.addr UNHIGHLIGHT_ALL_IMPL .addr UNHIGHLIGHT_ALL_IMPL
.addr CLOSE_WINDOW_IMPL .addr CLOSE_WINDOW_IMPL
.addr GET_HIGHLIGHTED_IMPL .addr GET_HIGHLIGHTED_IMPL
.addr FIND_ICON_IMPL .addr FIND_ICON_IMPL
.addr L97F7 ; $0A .addr L97F7 ; $0A
.addr L9EBE ; $0B .addr UNHIGHLIGHT_ICON_IMPL
.addr REDRAW_ICONS_IMPL .addr REDRAW_ICONS_IMPL
.addr ICON_IN_RECT_IMPL .addr ICON_IN_RECT_IMPL
.addr REDRAW_ICON_IDX_IMPL .addr REDRAW_ICON_IDX_IMPL
@@ -476,9 +476,11 @@ done: jsr L9F98
.endproc .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 PARAM_BLOCK params, $06
ptr_icon: .addr 0 ptr_icon: .addr 0
END_PARAM_BLOCK END_PARAM_BLOCK
@@ -512,40 +514,48 @@ found: asl a
MGTK_CALL MGTK::SetPenMode, pencopy_2 MGTK_CALL MGTK::SetPenMode, pencopy_2
jsr draw_icon jsr draw_icon
;; Move it to the end of the icon list
ldy #IconEntry::id ldy #IconEntry::id
lda (ptr),y ; icon num lda (ptr),y ; icon num
ldx num_icons ; new position ldx num_icons ; new position
jsr change_icon_index jsr change_icon_index
;; Remove it from the list
dec num_icons dec num_icons
lda #0 lda #0
ldx num_icons ldx num_icons
sta icon_table,x sta icon_table,x
;; Clear its flag
ldy #IconEntry::state ldy #IconEntry::state
lda #0 lda #0
sta (ptr),y sta (ptr),y
lda has_highlight lda has_highlight
beq done beq done
;; Find it in the highlight list
ldx highlight_count ldx highlight_count
dex dex
ldy #0 ldy #0
lda (ptr),y lda (ptr),y
L9566: cmp highlight_list,x : cmp highlight_list,x
beq L9571 beq found2
dex dex
bpl L9566 bpl :-
jmp done ; not found
jmp done ;; Move it to the end of the highlight list
found2: ldx highlight_count ; new position
L9571: ldx highlight_count ; new position
jsr change_highlight_index jsr change_highlight_index
;; Remove it from the highloight list and update flag
dec highlight_count dec highlight_count
lda highlight_count lda highlight_count
bne L9584 bne :+
lda #0 lda #0
sta has_highlight sta has_highlight
L9584: lda #0 : lda #0
ldx highlight_count ldx highlight_count
sta highlight_list,x sta highlight_list,x
@@ -677,7 +687,7 @@ L969D: ldx L9696
ldy #0 ldy #0
cmp ($06),y cmp ($06),y
bne L969D bne L969D
DESKTOP_DIRECT_CALL DT_UNHIGHLIGHT_ICON, L9695 DESKTOP_DIRECT_CALL DT_REMOVE_ICON, L9695
jmp L969D jmp L969D
L96CF: return #0 L96CF: return #0
.endproc .endproc
@@ -1468,12 +1478,17 @@ L9EB4: asl a
.endproc .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 jmp start
.byte 0 ; ??? .byte 0 ; ???
@@ -1481,8 +1496,6 @@ L9EB4: asl a
;; DT_REDRAW_ICON params ;; DT_REDRAW_ICON params
icon: .byte 0 icon: .byte 0
ptr := $6
start: lda has_highlight start: lda has_highlight
bne :+ bne :+
return #1 ; No selection return #1 ; No selection
@@ -1490,16 +1503,14 @@ 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 #IconEntry::id ldy #IconEntry::id
lda (ptr),y ; icon num lda (params::ptr_iconent),y ; icon num
jsr change_highlight_index jsr change_highlight_index
;; Remove it from the list ;; Remove it from the highlight list and update flag
ldx highlight_count ldx highlight_count
lda #0 lda #0
sta highlight_count,x sta highlight_count,x
dec highlight_count dec highlight_count
;; Update flag
lda highlight_count lda highlight_count
bne :+ bne :+
lda #0 lda #0
@@ -1507,7 +1518,7 @@ start: lda has_highlight
;; Redraw ;; Redraw
: ldy #0 : ldy #0
lda (ptr),y lda (params::ptr_iconent),y
sta icon sta icon
DESKTOP_DIRECT_CALL DT_REDRAW_ICON, icon DESKTOP_DIRECT_CALL DT_REDRAW_ICON, icon
return #0 return #0

View File

@@ -3142,7 +3142,7 @@ L5916: lda cached_window_icon_list,x
sta icon_param sta icon_param
lda #$00 lda #$00
sta cached_window_icon_list,x 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 lda icon_param
jsr DESKTOP_FREE_ICON jsr DESKTOP_FREE_ICON
dec cached_window_icon_count dec cached_window_icon_count
@@ -3289,7 +3289,7 @@ L5A4C: jsr redraw_windows_and_desktop
lda icon_param lda icon_param
jsr DESKTOP_FREE_ICON jsr DESKTOP_FREE_ICON
jsr reset_grafport3 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 L5A7F: lda cached_window_icon_count
sta L5AC6 sta L5AC6
inc cached_window_icon_count inc cached_window_icon_count