Add "Preview DAs", allow opening text/graphics directly (Issue #101)

This commit is contained in:
Joshua Bell 2019-01-20 20:28:54 -08:00
parent 467cc1d73a
commit a8599e5c68
29 changed files with 249 additions and 133 deletions

View File

@ -23,6 +23,8 @@ before_deploy:
CADIUS="/tmp/cadius/bin/release/cadius" res/package.sh
- cd $TRAVIS_BUILD_DIR/desk.acc/ &&
CADIUS="/tmp/cadius/bin/release/cadius" res/package.sh
- cd $TRAVIS_BUILD_DIR/preview/ &&
CADIUS="/tmp/cadius/bin/release/cadius" res/package.sh
- cd $TRAVIS_BUILD_DIR/ &&
CADIUS="/tmp/cadius/bin/release/cadius" res/package.sh
@ -34,7 +36,8 @@ deploy:
- $TRAVIS_BUILD_DIR/out/A2DeskTop.po
- $TRAVIS_BUILD_DIR/desktop/out/DeskTop.po
- $TRAVIS_BUILD_DIR/desk.acc/out/DeskAccessories.po
- $TRAVIS_BUILD_DIR/desk.acc/res/README_DAS.txt
- $TRAVIS_BUILD_DIR/desk.acc/out/Preview.po
- $TRAVIS_BUILD_DIR/res/README.txt
skip_cleanup: true
on:
repo: inexorabletash/a2d

21
APIs.md
View File

@ -251,19 +251,18 @@ DeskTop's state - selection, windows, icons - is only partially accessible
via APIs. Operations such as opening the selected file requires accessing
internal data structures directly.
### Selection
* `path_index` (byte) - id of active window in `path_table`
* `selected_file_count` (byte) - number of selected icons
* `selected_file_list` (array of bytes) - ids of selected icons
### Window - representing an open directory
* `path_index` (byte) - id of active window in `path_table`
* `path_table` (array of addrs) - maps window id to window record address
Window record: 65-byte pathname buffer; it is a length-prefixed
absolute path (e.g. `/HD/GAMES`)
absolute path (e.g. `/VOL/GAMES`)
### Selection
* `selected_file_count` (byte) - number of selected icons
* `selected_file_list` (array of bytes) - ids of selected icons
### Icon - representing a file (in a window) or volume (on the desktop)
@ -273,16 +272,16 @@ Icon record: 27-byte structure optimized for rendering the file/volume icon.
```
.byte icon icon index
.byte ??
.byte state $80 = highlighted, 0 = otherwise
.byte type/window_id
(bits 0-3 window_id)
(bits 4,5,6)
000 = directory
001 = system
010 = binary
010 = binary (maybe runnable)
011 = basic
100 = (unused)
101 = text/generic
101 = data (text/generic/...)
110 = (unused)
111 = trash
(bit 7 = open flag)

View File

@ -18,11 +18,10 @@
* DAs with high bit in aux-type set are skipped. (#102)
* Icons for volumes positioned more predictably and sensibly. (#94)
* GS/OS filenames (supported by ProDOS 2.5) are shown with correct case. (#64)
* Text and Graphics files can be previewed without leaving DeskTop (File > Open, or double-click).
### Additional Desk Accessories
* Show Image File
* Select an image file (8k Hires or 16k Double Hires, aux-first), then choose DA to view it.
* This Apple
* Gives details about the computer, expanded memory, and what's in each slot. (#29)
* Eyes
@ -37,6 +36,10 @@
Note that several of the new Desk Accessories will not work with older versions
of Apple II DeskTop/MouseDesk, due to dependence on new APIs.
The former "Show Text File" DA is now part of automatic preview
functionality (just use File > Open), and resides in the new `PREVIEW`
subdirectory.
### Notable Fixes
* Dates 00-39 are treated as 2000-2039; dates 100-127 are treated as 2000-2027. (#15)

View File

@ -3,13 +3,11 @@ Disassembly of the original desk accessories:
* [Calculator](calculator.s) - complete!
* [Date](date.s) - complete!
* [Puzzle](puzzle.s) - complete!
* [Show Text File](show.text.file.s) - in progress! 95% complete
* [Show Text File](show.text.file.s) - in progress! 95% complete - moved to [preview](../preview/)
* [Sort Directory](sort.directory.s) - in progress! 60% complete
New desk accessories:
* [Show Image File](show.image.file.s)
* Select an image file (8k Hires or 16k Double Hires), then choose this DA to preview it.
* [This Apple](this.apple.s)
* Gives details about the computer, expanded memory, and what's in each slot.
* [Eyes](eyes.s)

View File

@ -1,9 +1,7 @@
calculator
show.text.file
date
puzzle
sort.directory
show.image.file
this.apple
eyes
screen.dump

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,51 +0,0 @@
Apple II Desktop - Desk Accessories
===================================
Installation
------------
If using a physical Apple II with actual floppy disks, transfer the
DeskAccessories.po. file to a floppy using ADTPro. If using a floppy
emulator, copy the file to your storage medium.
1. Boot into Apple II Desktop.
2. Insert the disk with the desk accessories.
3. Drag the files into your A2.DESKTOP/DESK.ACC folder.
4. Reboot.
Tip: You can use the Sort Directory DA to order the files, which controls
the menu order:
* Open the A2.DESKTOP/DESK.ACC folder
* Hold Open-Apple and click on each file in the desired order
* Select Sort Directory from the Apple menu, and verify the order
* Restart
Source code can be found at: https://github.com/inexorabletash/a2d
Show Image File
---------------
In Apple II Desktop, select an image file. Unfortunately, these are
hard to identify in A2D; they appear as a binary file (icon is <01>)
and are usually either 17 (single hi-res) or 33 (double hi-res) blocks
- you can check View > By Name or use Special > Get Info... to see the
size.
Then select Show Image File from the Apple menu. The image should
appear. If garbage appears, it was probably not an image file. You can
move the mouse pointer while the image is displayed. Click the mouse
button or press Escape to return to the DeskTop.
This Apple
----------
Select this item from the Apple menu to see an overview of the model
of computer, the CPU, an estimate of RamWorks memory expansion (if
present), and what cards can be identified in each slot.
Eyes
----
Select this for a demo showing two eyes that follow the mouse cursor.
The window can be moved and resized.

View File

@ -45,13 +45,13 @@ start:
;; Get active window's path
jsr get_win_path
beq :+
lda #$FA ; "This file cannot be run" - not perfect
lda #ERR_FILE_NOT_OPENABLE
bne fail
;; Find BASIC.SYSTEM
: jsr check_basic_system
beq :+
lda #$FE ; "BASIC.SYSTEM not found"
lda #ERR_BASIC_SYS_NOT_FOUND
bne fail
;; Restore system state: devices, /RAM, ROM/ZP banks.

View File

@ -69,7 +69,7 @@ JUMP_TABLE_RESTORE_SYS := $4048 ; Exit DHR, restore devices and /RAM, bank in R
;;; Error codes used for alerts which are not ProDOS errors
ERR_DUPLICATE_VOL_NAME = $F9
ERR_FILE_NOT_RUNNABLE = $FA
ERR_FILE_NOT_OPENABLE = $FA
ERR_NAME_TOO_LONG = $FB
ERR_INSERT_SRC_DISK = $FC
ERR_INSERT_DST_DISK = $FD

View File

@ -3321,7 +3321,7 @@ err_52: PASCAL_STRING "This is not a ProDOS disk."
err_57: PASCAL_STRING "There is another volume with that name on the desktop."
;; Below are internal (not ProDOS MLI) error codes.
err_F9: PASCAL_STRING "There are 2 volumes with the same name."
err_FA: PASCAL_STRING "This file cannot be run."
err_FA: PASCAL_STRING "This file cannot be opened."
err_FB: PASCAL_STRING "That name is too long."
err_FC: PASCAL_STRING "Please insert source disk"
err_FD: PASCAL_STRING "Please insert destination disk"

View File

@ -941,7 +941,15 @@ begin:
cmp #FT_S16
beq launch
lda #ERR_FILE_NOT_RUNNABLE
cmp #FT_GRAPHICS
bne :+
addr_jump invoke_desk_acc, str_preview_fot
: cmp #FT_TEXT
bne :+
addr_jump invoke_desk_acc, str_preview_txt
: lda #ERR_FILE_NOT_OPENABLE
jsr show_alert_and_fail
launch: DESKTOP_RELAY_CALL DT_UNHIGHLIGHT_ALL
@ -955,8 +963,6 @@ launch: DESKTOP_RELAY_CALL DT_UNHIGHLIGHT_ALL
: copy buf_filename2,x, INVOKER_FILENAME,x
dex
bpl :-
addr_call upcase_string, $280
addr_call upcase_string, path
copy16 #INVOKER, reset_and_invoke_target
jmp reset_and_invoke
@ -1026,22 +1032,9 @@ str_basic_system:
;;; --------------------------------------------------
.proc upcase_string
ptr := $06
stax ptr
ldy #0
lda (ptr),y
tay
loop: lda (ptr),y
jsr upcase_char
sta (ptr),y
dey
bne loop
rts
.endproc
.endproc
;;; ============================================================
.proc upcase_char
cmp #'a'
@ -1249,7 +1242,7 @@ L4A0F: lda ($06),y
sta buf_win_path,y
dey
bpl L4A0F
;; fall throigh
;; fall through
.proc launch_buf_win_path
;; Find last '/'
@ -1525,8 +1518,11 @@ prefix_length:
.proc cmd_deskacc_impl
ptr := $6
zp_use_flag1:
.byte $80
.define prefix "Desk.acc/"
prefix_length = .strlen(prefix)
str_desk_acc:
PASCAL_STRING prefix, prefix_length + 15
start: jsr reset_grafport3
jsr set_watch_cursor
@ -1543,7 +1539,7 @@ start: jsr reset_grafport3
lda (ptr),y
tay
clc
adc prefix_length
adc #prefix_length
pha
tax
@ -1566,6 +1562,18 @@ start: jsr reset_grafport3
nope: dex
bne :-
ldax #str_desk_acc
;; fall through
.endproc
cmd_deskacc := cmd_deskacc_impl::start
;;; ============================================================
;;; Invoke Desk Accessory
;;; Input: A,X = address of pathnane buffer
.proc invoke_desk_acc
stax open_pathname
;; Load the DA
jsr open
bmi done
@ -1604,8 +1612,12 @@ read: yxa_jump MLI_RELAY, READ, read_params
close: yxa_jump MLI_RELAY, CLOSE, close_params
DEFINE_OPEN_PARAMS open_params, str_desk_acc, DA_IO_BUFFER
zp_use_flag1:
.byte $80
DEFINE_OPEN_PARAMS open_params, 0, DA_IO_BUFFER
open_ref_num := open_params::ref_num
open_pathname := open_params::pathname
DEFINE_READ_PARAMS read_params, DA_LOAD_ADDRESS, DA_MAX_SIZE
read_ref_num := read_params::ref_num
@ -1613,16 +1625,7 @@ close: yxa_jump MLI_RELAY, CLOSE, close_params
DEFINE_CLOSE_PARAMS close_params
close_ref_num := close_params::ref_num
.define prefix "Desk.acc/"
prefix_length:
.byte .strlen(prefix)
str_desk_acc:
PASCAL_STRING prefix, .strlen(prefix) + 15
.endproc
cmd_deskacc := cmd_deskacc_impl::start
;;; ============================================================
@ -1828,16 +1831,17 @@ done: rts
ldy #IconEntry::win_type
lda (ptr),y
and #icon_entry_type_mask
bne not_dir
cmp #icon_entry_type_trash
beq next_file
cmp #icon_entry_type_dir
bne maybe_open_file
;; Directory
ldy #0
lda (ptr),y
jsr open_folder_or_volume_icon
inc dir_count
jmp next_file
not_dir:
cmp #%01000000 ; type <= %0100 = basic, binary, or system
bcc maybe_open_file
next_file:
pla
@ -1845,6 +1849,7 @@ next_file:
inx
jmp L4DEC
;; File (executable or data)
maybe_open_file:
sta L4E71
lda selected_icon_count
@ -3902,22 +3907,21 @@ handle_double_click:
ldy #IconEntry::win_type
lda ($06),y
and #icon_entry_type_mask
cmp #icon_entry_type_system
beq L5E28
cmp #icon_entry_type_binary
beq L5E28
cmp #icon_entry_type_basic
beq L5E28
cmp #icon_entry_type_trash
beq done
cmp #icon_entry_type_dir
bne :+
bne file
lda icon_num ; handle directory
;; Directory
lda icon_num
jsr open_folder_or_volume_icon
bmi :+
bmi done
jmp L5DEC
: rts
done: rts
L5E28: sta L5E77
;; File (executable or data)
file: sta L5E77
lda active_window_id
jsr window_path_lookup
stax $06
@ -9393,6 +9397,8 @@ open: MLI_RELAY_CALL OPEN, open_params
done: rts
.endproc
;;; ============================================================
.proc set_color_mode
;; AppleColor Card - Mode 2 (Color 140x192)
sta SET80VID
@ -9460,10 +9466,6 @@ done: rts
rts
.endproc
;;; ============================================================
PAD_TO $8F00
;;; ============================================================
;;; Operations performed on selection
;;;
@ -12365,6 +12367,13 @@ RAMSLOT := DEVADR + $16 ; Slot 3, Drive 2
driver: jmp (RAMSLOT)
.endproc
str_preview_fot:
PASCAL_STRING "Preview/show.image.file"
str_preview_txt:
PASCAL_STRING "Preview/show.text.file"
;;; ============================================================
PAD_TO $A500

30
preview/Makefile Normal file
View File

@ -0,0 +1,30 @@
CC65 = ~/dev/cc65/bin
CAFLAGS = --target apple2enh --list-bytes 0
CCFLAGS = --config apple2-asm.cfg
OUTDIR = out
HEADERS = $(wildcard ../*.inc) $(wildcard ../inc/*.inc) $(wildcard *.inc)
DAS = $(shell cat TARGETS)
TARGETS = $(patsubst %,$(OUTDIR)/%.built,$(DAS))
.PHONY: clean all
all: $(OUTDIR) $(TARGETS)
$(OUTDIR):
mkdir -p $(OUTDIR)
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/*.list
rm -f $(TARGETS)
$(OUTDIR)/%.o: %.s $(HEADERS)
$(CC65)/ca65 $(CAFLAGS) --listing $(basename $@).list -o $@ $<
# Desk Accessory Files
$(OUTDIR)/%.built: $(OUTDIR)/%.o
$(CC65)/ld65 $(CCFLAGS) -o '$@' $<

22
preview/README.md Normal file
View File

@ -0,0 +1,22 @@
# Preview
These files are a special class of Desk Accessory which reside in
the `PREVIEW` subdirectory relative to `DESKTOP2` (next to `DESK.ACC`).
These DAs will be invoked automatically for certain file types when
File > Open is run or the files are double-clicked.
* [show.text.file](show.text.file.s)
* Handles text files (TXT $04)
* [show.image.file](show.image.file.s)
* Handles image files (FOT $08)
* 8k Hires or 16k Double Hires images are supported
The files can optionally be copied into the `DESK.ACC` directory to
allow direct invocation from the Apple menu. This can be useful to
preview files of different file types e.g. image files saved as BIN
$06.
See [API.md](../desk.acc/API.md) for programming details.
See the DA [README.md](../desk.acc/README.md) for build and installation
details.

2
preview/TARGETS Normal file
View File

@ -0,0 +1,2 @@
show.text.file
show.image.file

9
preview/res/go.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# Run this from the desk.acc directory
set -e
source "../res/util.sh"
#do_make clean
do_make all

38
preview/res/package.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# Use Cadius to create a disk image for distribution
# https://github.com/mach-kernel/cadius
set -e
CADIUS="${CADIUS:-$HOME/dev/cadius/bin/release/cadius}"
DAS=$(cat TARGETS)
PACKDIR="out/package"
FINFO="$PACKDIR/_FileInformation.txt"
IMGFILE="out/Preview.po"
VOLNAME="PREVIEW"
mkdir -p "$PACKDIR"
echo "" > "$FINFO"
# Prepare _FileInformation.txt file with extra ProDOS file entry data
# and copy renamed files into package directory.
for file in $DAS; do
ucfile=$(echo $file | tr a-z A-Z)
echo "$ucfile=Type(F1),AuxType(0640),VersionCreate(00),MinVersion(B9),Access(E3),FolderInfo1(000000000000000000000000000000000000),FolderInfo2(000000000000000000000000000000000000)" >> "$FINFO"
cp "out/$file.built" "out/package/$ucfile"
done
# Create a new disk image.
$CADIUS CREATEVOLUME $IMGFILE $VOLNAME 143KB
# Add the files into the disk image.
for file in $DAS; do
ucfile=$(echo $file | tr a-z A-Z)
$CADIUS ADDFILE $IMGFILE "/$VOLNAME" $PACKDIR/$ucfile
done

51
res/README.txt Normal file
View File

@ -0,0 +1,51 @@
Apple II DeskTop
================
A2DeskTop.po is an 800k image containing the full application and
all accessories. It can be transferred to an 3.5" floppy using ADTPro.
DeskTop.po, DeskAccessories.po and Preview.po are 140k images
containing different parts of the application, and can be trasnferred to
5.25" floppies using ADTPro.
Installation
------------
This is a ProDOS 8 application, and works best on a mass storage
device or at least an 800k floppy. Running from 140k is possible
(without desk accessories) but is not recommended.
An Apple II DeskTop installation has the following structure on a mass
storage device:
* `A2.DESKTOP/` - any name is allowed, can be in any subdirectory
* `DESKTOP.SYSTEM` - invoked to launch DeskTop
* `DESKTOP2` - application file
* `DESK.ACC/` - contains Desk Accessories (DAs)
* `PREVIEW/` - contains file preview handlers (special type of DAs)
At runtime, other files will be created within the application
directory:
* `QUIT.TMP` holds the original ProDOS quit routine.
* `SELECTOR.LIST` holds the Selector menu entries, which allow
for quick launching of other applications.
Other Files
-----------
The `RAM.SYSTEM` file will create a RAM Disk on RamWorks drives. It can
be run manually before launching `DeskTop`
Tips and Tricks
---------------
You can use the Sort Directory DA to order the files, which controls
the menu order:
* Open the A2.DESKTOP/DESK.ACC folder
* Hold Open-Apple and click on each file in the desired order
* Select Sort Directory from the Apple menu, and verify the order
* Restart
Source code can be found at: https://github.com/inexorabletash/a2d

View File

@ -5,7 +5,7 @@
set -e
source "res/util.sh"
for i in desktop desk.acc desktop.system ram.system; do
for i in desktop desk.acc preview desktop.system ram.system; do
cecho yellow Building: $i
cd $i
res/go.sh

View File

@ -30,14 +30,19 @@ function mount_sys {
|| (cecho red "failed to mount $dst" ; return 1)
}
targets=$(cat desk.acc/TARGETS)
mkdir -p mount
echo "Copying files to mount/"
for file in $targets; do
mount_f1 "$file" "desk.acc" "mount/desk.acc"
done
mkdir -p mount
mount_f1 "desktop2" "desktop" "mount"
mount_sys "desktop.system" "desktop.system" "mount"
mount_sys "ram.system" "ram.system" "mount"
mkdir -p mount/desk.acc
for file in $(cat desk.acc/TARGETS); do
mount_f1 "$file" "desk.acc" "mount/desk.acc"
done
mkdir -p mount/preview
for file in $(cat preview/TARGETS); do
mount_f1 "$file" "preview" "mount/preview"
done