mirror of
https://github.com/mi57730/a2d.git
synced 2025-02-20 02:29:11 +00:00
Add MGTK Font file support for Preview.
Correct docs for some DeskTop icon APIs, and improve resilience of some of the APIs to having atypical grafports selected when called.
This commit is contained in:
parent
6e96eae7ed
commit
157c6a3f0c
16
APIs.md
16
APIs.md
@ -178,13 +178,13 @@ Removes an icon by number.
|
|||||||
|
|
||||||
Parameters: { byte window_id }
|
Parameters: { byte window_id }
|
||||||
|
|
||||||
Highlights (selects) all icons in a window.
|
Highlights (selects) all icons in specified window (0 = desktop).
|
||||||
|
|
||||||
### `DT_UNHIGHLIGHT_ALL` ($06)
|
### `DT_REMOVE_ALL` ($06)
|
||||||
|
|
||||||
Parameters: _N/A_
|
Parameters: { byte window_id }
|
||||||
|
|
||||||
Unhighlights (deselects) all icons.
|
Removes all icons from specified window (0 = desktop).
|
||||||
|
|
||||||
### `DT_CLOSE_WINDOW` ($07)
|
### `DT_CLOSE_WINDOW` ($07)
|
||||||
|
|
||||||
@ -234,13 +234,11 @@ Parameters: { byte icon, rect bounds }
|
|||||||
|
|
||||||
Tests to see if the given icon (by number) overlaps the passed rect.
|
Tests to see if the given icon (by number) overlaps the passed rect.
|
||||||
|
|
||||||
### `DT_REDRAW_ICON_IDX` ($0E)
|
### `DT_ERASE_ICON` ($0E)
|
||||||
|
|
||||||
Parameters: { byte icon_index }
|
Parameters: { byte icon }
|
||||||
|
|
||||||
Redraws the icon at the given index in the icon list. Note that this
|
|
||||||
is not the same as the icon number.
|
|
||||||
|
|
||||||
|
Erases the specified icon by number. No error checking is done.
|
||||||
|
|
||||||
|
|
||||||
<!-- ============================================================ -->
|
<!-- ============================================================ -->
|
||||||
|
@ -56,17 +56,21 @@ functionality (see below).
|
|||||||
|
|
||||||
### Automatic Preview
|
### Automatic Preview
|
||||||
|
|
||||||
Text and Graphics files with the correct file types can be previewed
|
Text, Graphics and Font files with the correct file types can be
|
||||||
without leaving DeskTop; select the file icon then select File > Open,
|
previewed without leaving DeskTop; select the file icon then select
|
||||||
or double-click the file icon. Text files must be type TXT ($04).
|
File > Open, or double-click the file icon.
|
||||||
Graphics files must be type FOT ($08), or BIN ($06) with an aux type
|
|
||||||
of $2000 or $4000 and 17 or 33 blocks (hi-res/double hi-res) or $5800
|
* Text files must be type TXT ($04).
|
||||||
and 3 blocks (Minipix a.k.a. Print Shop).
|
* Graphics files must be type FOT ($08), or BIN ($06) with an aux type
|
||||||
|
of $2000 or $4000 and 17 or 33 blocks (hi-res/double hi-res) or $5800
|
||||||
|
and 3 blocks (Minipix a.k.a. Print Shop).
|
||||||
|
* Font files must be MGTK fonts with type FNT ($07).
|
||||||
|
|
||||||
To preview files of other types, you can copy the preview handlers
|
To preview files of other types, you can copy the preview handlers
|
||||||
named `SHOW.TEXT.FILE` and `SHOW.IMAGE.FILE` from the `PREVIEW` folder
|
named `SHOW.TEXT.FILE`, `SHOW.IMAGE.FILE`, etc. from the `PREVIEW`
|
||||||
to the `DESK.ACC` folder, and restart DeskTop. To use them, select the
|
folder to the `DESK.ACC` folder, and restart DeskTop. To use them,
|
||||||
file, then select the appropriate command from the Apple menu.
|
select the file, then select the appropriate command from the Apple
|
||||||
|
menu.
|
||||||
|
|
||||||
### Notable Fixes
|
### Notable Fixes
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ DT_HIGHLIGHT_ICON = $02 ; { .byte icon }
|
|||||||
DT_REDRAW_ICON = $03 ; { .byte icon }
|
DT_REDRAW_ICON = $03 ; { .byte icon }
|
||||||
DT_REMOVE_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_REMOVE_ALL = $06 ; { .byte window_id }
|
||||||
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 }
|
||||||
@ -107,7 +107,7 @@ DT_DRAG_HIGHLIGHTED = $0A ; { .byte param }
|
|||||||
DT_UNHIGHLIGHT_ICON = $0B ; { .addr iconentry }
|
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_ERASE_ICON = $0E ; { .byte icon }
|
||||||
|
|
||||||
;;; `icon` is the icon number, i.e. first field in icon entry
|
;;; `icon` is the icon number, i.e. first field in icon entry
|
||||||
;;; `icon_index` is the index in the icon table
|
;;; `icon_index` is the index in the icon table
|
||||||
|
@ -402,7 +402,7 @@ desktop_jump_table:
|
|||||||
.addr REDRAW_ICON_IMPL
|
.addr REDRAW_ICON_IMPL
|
||||||
.addr REMOVE_ICON_IMPL
|
.addr REMOVE_ICON_IMPL
|
||||||
.addr HIGHLIGHT_ALL_IMPL
|
.addr HIGHLIGHT_ALL_IMPL
|
||||||
.addr UNHIGHLIGHT_ALL_IMPL
|
.addr REMOVE_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
|
||||||
@ -410,7 +410,7 @@ desktop_jump_table:
|
|||||||
.addr UNHIGHLIGHT_ICON_IMPL
|
.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 ERASE_ICON_IMPL
|
||||||
|
|
||||||
.macro DESKTOP_DIRECT_CALL op, addr, label
|
.macro DESKTOP_DIRECT_CALL op, addr, label
|
||||||
jsr DESKTOP_DIRECT
|
jsr DESKTOP_DIRECT
|
||||||
@ -521,6 +521,8 @@ sub: ldx num_icons ; ???
|
|||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; HIGHLIGHT_ICON IMPL
|
;;; HIGHLIGHT_ICON IMPL
|
||||||
|
|
||||||
|
;;; param is pointer to icon id
|
||||||
|
|
||||||
.proc HIGHLIGHT_ICON_IMPL
|
.proc HIGHLIGHT_ICON_IMPL
|
||||||
PARAM_BLOCK params, $06
|
PARAM_BLOCK params, $06
|
||||||
ptr_icon: .addr 0
|
ptr_icon: .addr 0
|
||||||
@ -541,7 +543,7 @@ bail1: return #1 ; Not found
|
|||||||
|
|
||||||
: asl a
|
: asl a
|
||||||
tax
|
tax
|
||||||
copy16 icon_ptrs,x, ptr
|
copy16 icon_ptrs,x, ptr ; ptr now points at IconEntry
|
||||||
ldy #IconEntry::state
|
ldy #IconEntry::state
|
||||||
lda (ptr),y
|
lda (ptr),y
|
||||||
bne :+ ; Already set ??? Routine semantics are incorrect ???
|
bne :+ ; Already set ??? Routine semantics are incorrect ???
|
||||||
@ -582,13 +584,23 @@ L949D: ldx highlight_count
|
|||||||
ldx #1 ; new position
|
ldx #1 ; new position
|
||||||
jsr change_icon_index
|
jsr change_icon_index
|
||||||
|
|
||||||
jsr paint_icon_highlighted
|
;; Redraw
|
||||||
|
ldy #IconEntry::id
|
||||||
|
lda (ptr),y ; icon num
|
||||||
|
sta icon
|
||||||
|
DESKTOP_DIRECT_CALL DT_REDRAW_ICON, icon
|
||||||
return #0 ; Highlighted
|
return #0 ; Highlighted
|
||||||
|
|
||||||
|
;; DT_REDRAW_ICON params
|
||||||
|
icon: .byte 0
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; REDRAW_ICON IMPL
|
;;; REDRAW_ICON IMPL
|
||||||
|
|
||||||
|
;;; * Assumes correct grafport already selected/maprect specified
|
||||||
|
;;; * Does not erase background
|
||||||
|
|
||||||
.proc REDRAW_ICON_IMPL
|
.proc REDRAW_ICON_IMPL
|
||||||
PARAM_BLOCK params, $06
|
PARAM_BLOCK params, $06
|
||||||
ptr_icon: .addr 0
|
ptr_icon: .addr 0
|
||||||
@ -672,7 +684,7 @@ found: asl a
|
|||||||
|
|
||||||
;; Unhighlight
|
;; Unhighlight
|
||||||
: jsr calc_icon_poly
|
: jsr calc_icon_poly
|
||||||
jsr draw_icon
|
jsr erase_icon
|
||||||
|
|
||||||
;; Move it to the end of the icon list
|
;; Move it to the end of the icon list
|
||||||
ldy #IconEntry::id
|
ldy #IconEntry::id
|
||||||
@ -723,9 +735,9 @@ done: return #0 ; Unhighlighted
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; REDRAW_ICON_IDX IMPL
|
;;; ERASE_ICON IMPL
|
||||||
|
|
||||||
.proc REDRAW_ICON_IDX_IMPL
|
.proc ERASE_ICON_IMPL
|
||||||
PARAM_BLOCK params, $06
|
PARAM_BLOCK params, $06
|
||||||
ptr_icon_idx: .addr 0
|
ptr_icon_idx: .addr 0
|
||||||
END_PARAM_BLOCK
|
END_PARAM_BLOCK
|
||||||
@ -736,7 +748,7 @@ ptr_icon_idx: .addr 0
|
|||||||
asl a
|
asl a
|
||||||
tax
|
tax
|
||||||
copy16 icon_ptrs,x, ptr
|
copy16 icon_ptrs,x, ptr
|
||||||
jmp draw_icon
|
jmp erase_icon
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
@ -821,35 +833,47 @@ loop2: lda buffer,x
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; UNHIGHLIGHT_ALL IMPL
|
;;; REMOVE_ALL IMPL
|
||||||
|
|
||||||
.proc UNHIGHLIGHT_ALL_IMPL
|
;;; param is window id (0 = desktop)
|
||||||
jmp L9697
|
|
||||||
|
|
||||||
L9695: .byte 0
|
.proc REMOVE_ALL_IMPL
|
||||||
L9696: .byte 0
|
jmp start
|
||||||
|
|
||||||
L9697: lda num_icons
|
PARAM_BLOCK params, $06
|
||||||
sta L9696
|
ptr_window_id: .addr 0
|
||||||
L969D: ldx L9696
|
END_PARAM_BLOCK
|
||||||
|
|
||||||
|
icon_ptr := $08
|
||||||
|
|
||||||
|
;; DT_REMOVE_ICON params
|
||||||
|
icon: .byte 0
|
||||||
|
|
||||||
|
count: .byte 0
|
||||||
|
|
||||||
|
start: lda num_icons
|
||||||
|
sta count
|
||||||
|
|
||||||
|
loop: ldx count
|
||||||
cpx #0
|
cpx #0
|
||||||
beq L96CF
|
beq done
|
||||||
dec L9696
|
dec count
|
||||||
dex
|
dex
|
||||||
lda icon_table,x
|
lda icon_table,x
|
||||||
sta L9695
|
sta icon
|
||||||
asl a
|
asl a
|
||||||
tax
|
tax
|
||||||
copy16 icon_ptrs,x, $08
|
copy16 icon_ptrs,x, icon_ptr
|
||||||
ldy #IconEntry::win_type
|
ldy #IconEntry::win_type
|
||||||
lda ($08),y
|
lda (icon_ptr),y
|
||||||
and #icon_entry_winid_mask
|
and #icon_entry_winid_mask
|
||||||
ldy #0
|
ldy #0
|
||||||
cmp ($06),y
|
cmp (params::ptr_window_id),y
|
||||||
bne L969D
|
bne loop
|
||||||
DESKTOP_DIRECT_CALL DT_REMOVE_ICON, L9695
|
DESKTOP_DIRECT_CALL DT_REMOVE_ICON, icon
|
||||||
jmp L969D
|
jmp loop
|
||||||
L96CF: return #0
|
|
||||||
|
done: return #0
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
@ -1392,7 +1416,7 @@ L9BF3: dex
|
|||||||
tax
|
tax
|
||||||
copy16 icon_ptrs,x, $06
|
copy16 icon_ptrs,x, $06
|
||||||
jsr calc_icon_poly
|
jsr calc_icon_poly
|
||||||
jsr draw_icon
|
jsr erase_icon
|
||||||
pla
|
pla
|
||||||
tax
|
tax
|
||||||
jmp L9BF3
|
jmp L9BF3
|
||||||
@ -1612,18 +1636,12 @@ L9EB4: asl a
|
|||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; UNHIGHLIGHT_ICON IMPL
|
;;; UNHIGHLIGHT_ICON IMPL
|
||||||
|
|
||||||
;;; param is pointer to icon entry
|
;;; param is pointer to IconEntry
|
||||||
|
|
||||||
.proc UNHIGHLIGHT_ICON_IMPL
|
.proc UNHIGHLIGHT_ICON_IMPL
|
||||||
PARAM_BLOCK params, $06
|
PARAM_BLOCK params, $06
|
||||||
ptr_iconent: .addr 0
|
ptr_iconent: .addr 0
|
||||||
END_PARAM_BLOCK
|
END_PARAM_BLOCK
|
||||||
ptr := $06 ; Overwrites param
|
|
||||||
|
|
||||||
jmp start
|
|
||||||
|
|
||||||
;; DT_REDRAW_ICON params
|
|
||||||
icon: .byte 0
|
|
||||||
|
|
||||||
start: lda has_highlight
|
start: lda has_highlight
|
||||||
bne :+
|
bne :+
|
||||||
@ -1642,15 +1660,18 @@ start: lda has_highlight
|
|||||||
dec highlight_count
|
dec highlight_count
|
||||||
lda highlight_count
|
lda highlight_count
|
||||||
bne :+
|
bne :+
|
||||||
lda #0
|
lda #0 ; Clear flag if no more highlighted
|
||||||
sta has_highlight
|
sta has_highlight
|
||||||
|
|
||||||
;; Redraw
|
;; Redraw
|
||||||
: ldy #0
|
: ldy #IconEntry::id
|
||||||
lda (params::ptr_iconent),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
|
||||||
|
|
||||||
|
;; DT_REDRAW_ICON params
|
||||||
|
icon: .byte 0
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
@ -1704,7 +1725,9 @@ L9F8F: return #1
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
|
;;; Paint icon
|
||||||
|
;;; * Assumes grafport selected and maprect configured
|
||||||
|
;;; * Does not erase background
|
||||||
|
|
||||||
icon_flags: ; bit 7 = highlighted, bit 6 = volume icon
|
icon_flags: ; bit 7 = highlighted, bit 6 = volume icon
|
||||||
.byte 0
|
.byte 0
|
||||||
@ -1808,8 +1831,10 @@ highlighted: copy #$80, icon_flags ; is highlighted
|
|||||||
|
|
||||||
bit icon_flags ; volume icon (on desktop) ?
|
bit icon_flags ; volume icon (on desktop) ?
|
||||||
bvc do_paint ; nope
|
bvc do_paint ; nope
|
||||||
|
;; TODO: This depends on a previous proc having adjusted
|
||||||
|
;; the grafport (for window maprect and window's items/used/free bar)
|
||||||
|
|
||||||
;; Redraw desktop background
|
;; Volume (i.e. icon on desktop)
|
||||||
MGTK_CALL MGTK::InitPort, grafport
|
MGTK_CALL MGTK::InitPort, grafport
|
||||||
jsr set_port_for_vol_icon
|
jsr set_port_for_vol_icon
|
||||||
: jsr calc_window_intersections
|
: jsr calc_window_intersections
|
||||||
@ -2055,6 +2080,10 @@ LA2AA: jsr pop_pointers
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
LA2AE: jsr push_pointers
|
LA2AE: jsr push_pointers
|
||||||
|
|
||||||
|
MGTK_CALL MGTK::InitPort, icon_grafport
|
||||||
|
MGTK_CALL MGTK::SetPort, icon_grafport
|
||||||
|
|
||||||
ldx num_icons
|
ldx num_icons
|
||||||
dex
|
dex
|
||||||
LA2B5: bmi LA2AA
|
LA2B5: bmi LA2AA
|
||||||
@ -2221,8 +2250,9 @@ stash: .word 0
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
|
;;; Erase an icon; redraws overlapping icons as needed
|
||||||
|
|
||||||
draw_icon:
|
erase_icon:
|
||||||
MGTK_CALL MGTK::InitPort, icon_grafport
|
MGTK_CALL MGTK::InitPort, icon_grafport
|
||||||
MGTK_CALL MGTK::SetPort, icon_grafport
|
MGTK_CALL MGTK::SetPort, icon_grafport
|
||||||
jmp LA3B9
|
jmp LA3B9
|
||||||
@ -2259,13 +2289,13 @@ window_id: .byte 0
|
|||||||
;; File (i.e. icon in window)
|
;; File (i.e. icon in window)
|
||||||
copy #$80, LA3B7
|
copy #$80, LA3B7
|
||||||
MGTK_CALL MGTK::SetPattern, white_pattern
|
MGTK_CALL MGTK::SetPattern, white_pattern
|
||||||
MGTK_CALL MGTK::FrontWindow, frontwindow_params
|
MGTK_CALL MGTK::FrontWindow, frontwindow_params ; Use window's port
|
||||||
lda frontwindow_params::window_id
|
lda frontwindow_params::window_id
|
||||||
sta getwinport_params::window_id
|
sta getwinport_params::window_id
|
||||||
MGTK_CALL MGTK::GetWinPort, getwinport_params
|
MGTK_CALL MGTK::GetWinPort, getwinport_params
|
||||||
jsr LA4CC
|
jsr LA4CC
|
||||||
jsr shift_port_down
|
jsr shift_port_down ; Further offset by window's items/used/free bar
|
||||||
jsr erase_icon
|
jsr erase_window_icon
|
||||||
jmp LA446
|
jmp LA446
|
||||||
|
|
||||||
;; Volume (i.e. icon on desktop)
|
;; Volume (i.e. icon on desktop)
|
||||||
@ -2291,7 +2321,7 @@ volume:
|
|||||||
;; fall through
|
;; fall through
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
.proc erase_icon
|
.proc erase_window_icon
|
||||||
copy16 poly::v0::ycoord, LA3B1
|
copy16 poly::v0::ycoord, LA3B1
|
||||||
copy16 poly::v6::xcoord, LA3AF
|
copy16 poly::v6::xcoord, LA3AF
|
||||||
COPY_BLOCK poly::v4, LA3B3
|
COPY_BLOCK poly::v4, LA3B3
|
||||||
@ -2312,6 +2342,7 @@ LA446: jsr push_pointers
|
|||||||
bne LA466
|
bne LA466
|
||||||
bit LA3B7 ; no, almost done
|
bit LA3B7 ; no, almost done
|
||||||
bpl :+
|
bpl :+
|
||||||
|
;; TODO: Is this restoration necessary?
|
||||||
MGTK_CALL MGTK::InitPort, icon_grafport
|
MGTK_CALL MGTK::InitPort, icon_grafport
|
||||||
MGTK_CALL MGTK::SetPort, icon_grafport
|
MGTK_CALL MGTK::SetPort, icon_grafport
|
||||||
: jsr pop_pointers
|
: jsr pop_pointers
|
||||||
@ -2895,7 +2926,7 @@ vert: cmp16 win_t, cr_t
|
|||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
|
|
||||||
.proc shift_port_down
|
.proc shift_port_down
|
||||||
;; For window's used/free space bar
|
;; For window's items/used/free space bar
|
||||||
offset = 15
|
offset = 15
|
||||||
|
|
||||||
add16 icon_grafport::viewloc::ycoord, #offset, icon_grafport::viewloc::ycoord
|
add16 icon_grafport::viewloc::ycoord, #offset, icon_grafport::viewloc::ycoord
|
||||||
|
@ -920,6 +920,10 @@ begin:
|
|||||||
bne :+
|
bne :+
|
||||||
addr_jump invoke_desk_acc, str_preview_txt
|
addr_jump invoke_desk_acc, str_preview_txt
|
||||||
|
|
||||||
|
: cmp #FT_FONT
|
||||||
|
bne :+
|
||||||
|
addr_jump invoke_desk_acc, str_preview_fnt
|
||||||
|
|
||||||
: cmp #DA_FILE_TYPE
|
: cmp #DA_FILE_TYPE
|
||||||
bne :+
|
bne :+
|
||||||
addr_jump invoke_desk_acc, path
|
addr_jump invoke_desk_acc, path
|
||||||
@ -927,7 +931,7 @@ begin:
|
|||||||
: lda #ERR_FILE_NOT_OPENABLE
|
: lda #ERR_FILE_NOT_OPENABLE
|
||||||
jsr show_alert_and_fail
|
jsr show_alert_and_fail
|
||||||
|
|
||||||
launch: DESKTOP_RELAY_CALL DT_UNHIGHLIGHT_ALL
|
launch: DESKTOP_RELAY_CALL DT_REMOVE_ALL, 0 ; volume icons
|
||||||
MGTK_RELAY_CALL MGTK::CloseAll
|
MGTK_RELAY_CALL MGTK::CloseAll
|
||||||
MGTK_RELAY_CALL MGTK::SetMenu, blank_menu
|
MGTK_RELAY_CALL MGTK::SetMenu, blank_menu
|
||||||
ldx buf_win_path
|
ldx buf_win_path
|
||||||
@ -10812,7 +10816,7 @@ L969E: lda #$40
|
|||||||
ldx L9706
|
ldx L9706
|
||||||
lda selected_icon_list,x
|
lda selected_icon_list,x
|
||||||
sta icon_param2
|
sta icon_param2
|
||||||
yax_call JT_DESKTOP_RELAY, DT_REDRAW_ICON_IDX, icon_param2
|
yax_call JT_DESKTOP_RELAY, DT_ERASE_ICON, icon_param2
|
||||||
copy16 L9707, $08
|
copy16 L9707, $08
|
||||||
ldx L9706
|
ldx L9706
|
||||||
lda selected_icon_list,x
|
lda selected_icon_list,x
|
||||||
@ -15390,6 +15394,9 @@ reset_grafport3a:
|
|||||||
str_preview_fot:
|
str_preview_fot:
|
||||||
PASCAL_STRING "Preview/show.image.file"
|
PASCAL_STRING "Preview/show.image.file"
|
||||||
|
|
||||||
|
str_preview_fnt:
|
||||||
|
PASCAL_STRING "Preview/show.font.file"
|
||||||
|
|
||||||
str_preview_txt:
|
str_preview_txt:
|
||||||
PASCAL_STRING "Preview/show.text.file"
|
PASCAL_STRING "Preview/show.text.file"
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ str_desktop2:
|
|||||||
|
|
||||||
start: lda #$80
|
start: lda #$80
|
||||||
sta ptr
|
sta ptr
|
||||||
DESKTOP_RELAY_CALL DT_UNHIGHLIGHT_ALL
|
DESKTOP_RELAY_CALL DT_REMOVE_ALL, 0 ; volume icons
|
||||||
MGTK_RELAY_CALL MGTK::CloseAll
|
MGTK_RELAY_CALL MGTK::CloseAll
|
||||||
MGTK_RELAY_CALL MGTK::SetZP1, ptr
|
MGTK_RELAY_CALL MGTK::SetZP1, ptr
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ FT_TYPELESS = $00
|
|||||||
FT_BAD = $01
|
FT_BAD = $01
|
||||||
FT_TEXT = $04 ; ASCII Text File *
|
FT_TEXT = $04 ; ASCII Text File *
|
||||||
FT_BINARY = $06 ; Generic Binary File *
|
FT_BINARY = $06 ; Generic Binary File *
|
||||||
|
FT_FONT = $07 ; Font File
|
||||||
FT_GRAPHICS = $08 ; Graphics File
|
FT_GRAPHICS = $08 ; Graphics File
|
||||||
FT_DIRECTORY = $0F ; Directory *
|
FT_DIRECTORY = $0F ; Directory *
|
||||||
FT_ADB = $19 ; AppleWorks Database *
|
FT_ADB = $19 ; AppleWorks Database *
|
||||||
|
@ -10,6 +10,8 @@ File > Open is run or the files are double-clicked.
|
|||||||
* [show.image.file](show.image.file.s)
|
* [show.image.file](show.image.file.s)
|
||||||
* Handles image files (FOT $08)
|
* Handles image files (FOT $08)
|
||||||
* 8k Hires or 16k Double Hires images are supported
|
* 8k Hires or 16k Double Hires images are supported
|
||||||
|
* [show.font.file](show.font.file.s)
|
||||||
|
* Handles MGTK font files (FNT $07)
|
||||||
|
|
||||||
The files can optionally be copied into the `DESK.ACC` directory to
|
The files can optionally be copied into the `DESK.ACC` directory to
|
||||||
allow direct invocation from the Apple menu. This can be useful to
|
allow direct invocation from the Apple menu. This can be useful to
|
||||||
@ -20,3 +22,6 @@ See [API.md](../desk.acc/API.md) for programming details.
|
|||||||
|
|
||||||
See the DA [README.md](../desk.acc/README.md) for build and installation
|
See the DA [README.md](../desk.acc/README.md) for build and installation
|
||||||
details.
|
details.
|
||||||
|
|
||||||
|
NOTE: ProDOS file type FNT $07 is reserved for Apple /// SOS font
|
||||||
|
files, but given their scarcity the type is re-used here.
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
show.text.file
|
show.text.file
|
||||||
show.image.file
|
show.image.file
|
||||||
|
show.font.file
|
||||||
|
450
preview/show.font.file.s
Normal file
450
preview/show.font.file.s
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
.feature string_escapes
|
||||||
|
.setcpu "6502"
|
||||||
|
|
||||||
|
.include "apple2.inc"
|
||||||
|
.include "../macros.inc"
|
||||||
|
.include "../inc/apple2.inc"
|
||||||
|
.include "../inc/prodos.inc"
|
||||||
|
.include "../mgtk.inc"
|
||||||
|
.include "../desktop.inc"
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.org $800
|
||||||
|
|
||||||
|
jmp entry
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
pathbuf: .res 65, 0
|
||||||
|
|
||||||
|
font_buffer := $D00
|
||||||
|
io_buf := WINDOW_ICON_TABLES
|
||||||
|
read_length = WINDOW_ICON_TABLES-font_buffer
|
||||||
|
|
||||||
|
DEFINE_OPEN_PARAMS open_params, pathbuf, io_buf
|
||||||
|
DEFINE_READ_PARAMS read_params, font_buffer, read_length
|
||||||
|
DEFINE_CLOSE_PARAMS close_params
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
;;; Get filename by checking DeskTop selected window/icon
|
||||||
|
|
||||||
|
entry:
|
||||||
|
|
||||||
|
.proc get_filename
|
||||||
|
;; Check that an icon is selected
|
||||||
|
lda #0
|
||||||
|
sta pathbuf
|
||||||
|
lda selected_file_count
|
||||||
|
beq abort ; some file properties?
|
||||||
|
lda path_index ; prefix index in table
|
||||||
|
bne :+
|
||||||
|
abort: rts
|
||||||
|
|
||||||
|
;; Copy path (prefix) into pathbuf.
|
||||||
|
: src := $06
|
||||||
|
dst := $08
|
||||||
|
|
||||||
|
asl a ; (since address table is 2 bytes wide)
|
||||||
|
tax
|
||||||
|
copy16 path_table,x, src
|
||||||
|
ldy #0
|
||||||
|
lda (src),y
|
||||||
|
tax
|
||||||
|
inc src
|
||||||
|
bne :+
|
||||||
|
inc src+1
|
||||||
|
: copy16 #pathbuf+1, dst
|
||||||
|
jsr copy_pathbuf ; copy x bytes (src) to (dst)
|
||||||
|
|
||||||
|
;; Append separator.
|
||||||
|
lda #'/'
|
||||||
|
ldy #0
|
||||||
|
sta (dst),y
|
||||||
|
inc pathbuf
|
||||||
|
inc dst
|
||||||
|
bne :+
|
||||||
|
inc dst+1
|
||||||
|
|
||||||
|
;; Get file entry.
|
||||||
|
: lda selected_file_list ; file index in table
|
||||||
|
asl a ; (since table is 2 bytes wide)
|
||||||
|
tax
|
||||||
|
copy16 file_table,x, src
|
||||||
|
|
||||||
|
;; Exit if a directory.
|
||||||
|
ldy #2 ; 2nd byte of entry
|
||||||
|
lda (src),y
|
||||||
|
and #icon_entry_type_mask
|
||||||
|
bne :+
|
||||||
|
rts ; 000 = directory
|
||||||
|
|
||||||
|
;; Set window title to point at filename (9th byte of entry)
|
||||||
|
;; (title includes the spaces before/after from the icon)
|
||||||
|
: clc
|
||||||
|
lda src
|
||||||
|
adc #IconEntry::len
|
||||||
|
sta winfo_title
|
||||||
|
lda src+1
|
||||||
|
adc #0
|
||||||
|
sta winfo_title+1
|
||||||
|
|
||||||
|
;; Append filename to path.
|
||||||
|
ldy #IconEntry::len
|
||||||
|
lda (src),y ; grab length
|
||||||
|
tax ; name has spaces before/after
|
||||||
|
dex ; so subtract 2 to get actual length
|
||||||
|
dex
|
||||||
|
clc
|
||||||
|
lda src
|
||||||
|
adc #11 ; 9 = length, 10 = space, 11 = name
|
||||||
|
sta src
|
||||||
|
bcc :+
|
||||||
|
inc src+1
|
||||||
|
: jsr copy_pathbuf ; copy x bytes (src) to (dst)
|
||||||
|
|
||||||
|
jmp load_file_and_run_da
|
||||||
|
|
||||||
|
.proc copy_pathbuf ; copy x bytes from src to dst
|
||||||
|
ldy #0 ; incrementing path length and dst
|
||||||
|
loop: lda (src),y
|
||||||
|
sta (dst),y
|
||||||
|
iny
|
||||||
|
inc pathbuf
|
||||||
|
dex
|
||||||
|
bne loop
|
||||||
|
tya
|
||||||
|
clc
|
||||||
|
adc dst
|
||||||
|
sta dst
|
||||||
|
bcc end
|
||||||
|
inc dst+1
|
||||||
|
end: rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
;;; Load the file
|
||||||
|
|
||||||
|
.proc load_file_and_run_da
|
||||||
|
;; TODO: Ensure there's enough room, fail if not
|
||||||
|
|
||||||
|
;; NOTE: This only leaves $1000-$1AFF (2816 bytes)
|
||||||
|
;; which is not enough for all the wide fonts.
|
||||||
|
|
||||||
|
;; --------------------------------------------------
|
||||||
|
;; Load the file
|
||||||
|
|
||||||
|
sta ALTZPOFF
|
||||||
|
MLI_CALL OPEN, open_params ; TODO: Check for error
|
||||||
|
lda open_params::ref_num
|
||||||
|
sta read_params::ref_num
|
||||||
|
sta close_params::ref_num
|
||||||
|
MLI_CALL READ, read_params ; TODO: Check for error
|
||||||
|
MLI_CALL CLOSE, close_params
|
||||||
|
sta ALTZPON
|
||||||
|
|
||||||
|
|
||||||
|
;; --------------------------------------------------
|
||||||
|
;; Copy the DA code and loaded data to AUX
|
||||||
|
|
||||||
|
lda ROMIN2
|
||||||
|
copy16 #DA_LOAD_ADDRESS, STARTLO
|
||||||
|
copy16 #WINDOW_ICON_TABLES-1, ENDLO
|
||||||
|
copy16 #DA_LOAD_ADDRESS, DESTINATIONLO
|
||||||
|
sec ; main>aux
|
||||||
|
jsr AUXMOVE
|
||||||
|
lda LCBANK1
|
||||||
|
lda LCBANK1
|
||||||
|
|
||||||
|
;; --------------------------------------------------
|
||||||
|
;; Run the DA from Aux, back to Main when done
|
||||||
|
|
||||||
|
sta RAMRDON
|
||||||
|
sta RAMWRTON
|
||||||
|
jsr init
|
||||||
|
sta RAMRDOFF
|
||||||
|
sta RAMWRTOFF
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
da_window_id = 60
|
||||||
|
da_width = 380
|
||||||
|
da_height = 140
|
||||||
|
da_left = (screen_width - da_width)/2
|
||||||
|
da_top = (screen_height - da_height)/2
|
||||||
|
|
||||||
|
.proc winfo
|
||||||
|
window_id: .byte da_window_id
|
||||||
|
options: .byte MGTK::Option::go_away_box
|
||||||
|
title: .addr 0 ; overwritten to point at filename
|
||||||
|
hscroll: .byte MGTK::Scroll::option_none
|
||||||
|
vscroll: .byte MGTK::Scroll::option_none
|
||||||
|
hthumbmax: .byte 32
|
||||||
|
hthumbpos: .byte 0
|
||||||
|
vthumbmax: .byte 32
|
||||||
|
vthumbpos: .byte 0
|
||||||
|
status: .byte 0
|
||||||
|
reserved: .byte 0
|
||||||
|
mincontwidth: .word da_width
|
||||||
|
mincontlength: .word da_height
|
||||||
|
maxcontwidth: .word da_width
|
||||||
|
maxcontlength: .word da_height
|
||||||
|
port:
|
||||||
|
viewloc: DEFINE_POINT da_left, da_top
|
||||||
|
mapbits: .addr MGTK::screen_mapbits
|
||||||
|
mapwidth: .word MGTK::screen_mapwidth
|
||||||
|
maprect: DEFINE_RECT 0, 0, da_width, da_height
|
||||||
|
pattern: .res 8, $FF
|
||||||
|
colormasks: .byte MGTK::colormask_and, MGTK::colormask_or
|
||||||
|
penloc: DEFINE_POINT 0, 0
|
||||||
|
penwidth: .byte 2
|
||||||
|
penheight: .byte 1
|
||||||
|
penmode: .byte 0
|
||||||
|
textback: .byte $7F
|
||||||
|
textfont: .addr font_buffer
|
||||||
|
nextwinfo: .addr 0
|
||||||
|
.endproc
|
||||||
|
winfo_title := winfo::title
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.proc event_params
|
||||||
|
kind: .byte 0
|
||||||
|
;;; EventKind::key_down
|
||||||
|
key := *
|
||||||
|
modifiers := * + 1
|
||||||
|
;;; EventKind::update
|
||||||
|
window_id := *
|
||||||
|
;;; otherwise
|
||||||
|
xcoord := *
|
||||||
|
ycoord := * + 2
|
||||||
|
.res 4
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc findwindow_params
|
||||||
|
mousex: .word 0
|
||||||
|
mousey: .word 0
|
||||||
|
which_area: .byte 0
|
||||||
|
window_id: .byte 0
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc trackgoaway_params
|
||||||
|
clicked: .byte 0
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc dragwindow_params
|
||||||
|
window_id: .byte 0
|
||||||
|
dragx: .word 0
|
||||||
|
dragy: .word 0
|
||||||
|
moved: .byte 0
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc winport_params
|
||||||
|
window_id: .byte da_window_id
|
||||||
|
port: .addr grafport
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc grafport
|
||||||
|
viewloc: DEFINE_POINT 0, 0
|
||||||
|
mapbits: .word 0
|
||||||
|
mapwidth: .word 0
|
||||||
|
cliprect: DEFINE_RECT 0, 0, 0, 0
|
||||||
|
pattern: .res 8, 0
|
||||||
|
colormasks: .byte 0, 0
|
||||||
|
penloc: DEFINE_POINT 0, 0
|
||||||
|
penwidth: .byte 0
|
||||||
|
penheight: .byte 0
|
||||||
|
penmode: .byte 0
|
||||||
|
textback: .byte 0
|
||||||
|
textfont: .addr 0
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc drawtext_params_char
|
||||||
|
.addr char_label
|
||||||
|
.byte 1
|
||||||
|
.endproc
|
||||||
|
char_label: .byte 0
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.proc init
|
||||||
|
MGTK_CALL MGTK::OpenWindow, winfo
|
||||||
|
jsr draw_window
|
||||||
|
MGTK_CALL MGTK::FlushEvents
|
||||||
|
;; fall through
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc input_loop
|
||||||
|
MGTK_CALL MGTK::GetEvent, event_params
|
||||||
|
bne exit
|
||||||
|
lda event_params::kind
|
||||||
|
cmp #MGTK::EventKind::button_down ; was clicked?
|
||||||
|
bne :+
|
||||||
|
jmp handle_down
|
||||||
|
|
||||||
|
|
||||||
|
: cmp #MGTK::EventKind::key_down ; any key?
|
||||||
|
bne :+
|
||||||
|
jmp handle_key
|
||||||
|
|
||||||
|
|
||||||
|
: jmp input_loop
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
.proc exit
|
||||||
|
MGTK_CALL MGTK::CloseWindow, winfo
|
||||||
|
DESKTOP_CALL DT_REDRAW_ICONS
|
||||||
|
rts ; exits input loop
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.proc handle_key
|
||||||
|
lda event_params::key
|
||||||
|
cmp #CHAR_ESCAPE
|
||||||
|
bne :+
|
||||||
|
jmp exit
|
||||||
|
: jmp input_loop
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.proc handle_down
|
||||||
|
copy16 event_params::xcoord, findwindow_params::mousex
|
||||||
|
copy16 event_params::ycoord, findwindow_params::mousey
|
||||||
|
MGTK_CALL MGTK::FindWindow, findwindow_params
|
||||||
|
bpl :+
|
||||||
|
jmp exit
|
||||||
|
: lda findwindow_params::window_id
|
||||||
|
cmp winfo::window_id
|
||||||
|
bpl :+
|
||||||
|
jmp input_loop
|
||||||
|
: lda findwindow_params::which_area
|
||||||
|
cmp #MGTK::Area::close_box
|
||||||
|
beq handle_close
|
||||||
|
cmp #MGTK::Area::dragbar
|
||||||
|
beq handle_drag
|
||||||
|
jmp input_loop
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.proc handle_close
|
||||||
|
MGTK_CALL MGTK::TrackGoAway, trackgoaway_params
|
||||||
|
lda trackgoaway_params::clicked
|
||||||
|
bne :+
|
||||||
|
jmp input_loop
|
||||||
|
: jmp exit
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.proc handle_drag
|
||||||
|
copy winfo::window_id, dragwindow_params::window_id
|
||||||
|
copy16 event_params::xcoord, dragwindow_params::dragx
|
||||||
|
copy16 event_params::ycoord, dragwindow_params::dragy
|
||||||
|
MGTK_CALL MGTK::DragWindow, dragwindow_params
|
||||||
|
lda dragwindow_params::moved
|
||||||
|
bpl :+
|
||||||
|
|
||||||
|
;; Draw DeskTop's windows (from Main)
|
||||||
|
sta RAMRDOFF
|
||||||
|
sta RAMWRTOFF
|
||||||
|
jsr JUMP_TABLE_REDRAW_ALL
|
||||||
|
sta RAMRDON
|
||||||
|
sta RAMWRTON
|
||||||
|
|
||||||
|
;; Draw DA's window
|
||||||
|
jsr draw_window
|
||||||
|
|
||||||
|
;; Draw DeskTop icons
|
||||||
|
DESKTOP_CALL DT_REDRAW_ICONS
|
||||||
|
|
||||||
|
: jmp input_loop
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
line1: PASCAL_STRING "\x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0A \x0B \x0C \x0D \x0E \x0F"
|
||||||
|
line2: PASCAL_STRING "\x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1F"
|
||||||
|
line3: PASCAL_STRING " ! \x22 # $ % & ' ( ) * + , - . /"
|
||||||
|
line4: PASCAL_STRING "0 1 2 3 4 5 6 7 8 9 : ; < = > ?"
|
||||||
|
line5: PASCAL_STRING "@ A B C D E F G H I J K L M N O"
|
||||||
|
line6: PASCAL_STRING "P Q R S T U V W X Y Z [ \x5C ] ^ _"
|
||||||
|
line7: PASCAL_STRING "` a b c d e f g h i j k l m n o"
|
||||||
|
line8: PASCAL_STRING "p q r s t u v w x y z { | } ~ \x7F"
|
||||||
|
|
||||||
|
line_count = 8
|
||||||
|
line_addrs:
|
||||||
|
.addr line1, line2, line3, line4, line5, line6, line7, line8
|
||||||
|
|
||||||
|
pos: DEFINE_POINT 0,0, pos
|
||||||
|
|
||||||
|
initial_y = 5
|
||||||
|
line_height = 15
|
||||||
|
|
||||||
|
|
||||||
|
.proc draw_window
|
||||||
|
ptr := $06
|
||||||
|
|
||||||
|
PARAM_BLOCK params, $06
|
||||||
|
data: .addr 0
|
||||||
|
len: .byte 0
|
||||||
|
width: .word 0
|
||||||
|
END_PARAM_BLOCK
|
||||||
|
|
||||||
|
MGTK_CALL MGTK::GetWinPort, winport_params
|
||||||
|
cmp #MGTK::Error::window_obscured
|
||||||
|
bne :+
|
||||||
|
rts
|
||||||
|
|
||||||
|
: MGTK_CALL MGTK::SetPort, grafport
|
||||||
|
MGTK_CALL MGTK::HideCursor
|
||||||
|
|
||||||
|
copy16 #initial_y, pos::ycoord
|
||||||
|
|
||||||
|
|
||||||
|
copy #0, index
|
||||||
|
loop: lda index
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
copy16 line_addrs,x, ptr
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
lda (ptr),y ; length
|
||||||
|
sta params::len
|
||||||
|
add16 ptr, #1, params::data ; offset past length
|
||||||
|
|
||||||
|
;; Position the string
|
||||||
|
MGTK_CALL MGTK::TextWidth, params
|
||||||
|
sub16 #da_width, params::width, pos::xcoord ; center it
|
||||||
|
lsr16 pos::xcoord
|
||||||
|
add16 pos::ycoord, #line_height, pos::ycoord ; next row
|
||||||
|
|
||||||
|
MGTK_CALL MGTK::MoveTo, pos
|
||||||
|
MGTK_CALL MGTK::DrawText, params
|
||||||
|
|
||||||
|
inc index
|
||||||
|
lda index
|
||||||
|
cmp #line_count
|
||||||
|
bne loop
|
||||||
|
|
||||||
|
MGTK_CALL MGTK::ShowCursor
|
||||||
|
rts
|
||||||
|
|
||||||
|
index: .byte 0
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
.assert * < font_buffer, error, "DA too big"
|
Loading…
x
Reference in New Issue
Block a user