Skip to content

Commit

Permalink
DeskTop: Remove 12 volume limit from Format/Erase picker
Browse files Browse the repository at this point in the history
The "Option Picker" logic used in Format/Erase (and DeskTop and
Selector's shortcut pickers) required a power-of-two number of rows
and dialog size constraints limited the Format/Erase dialog to 3
columns, so a maximum of 4*3=12 volumes could be shown. DeskTop
supports handling the ProDOS-8 maximum of 14 volumes, so some would be
elided.

Fix the Option Picker logic to handle arbitrary number of rows, and
tweak the dialog layout to allow up to 15 volumes to be shown in the
picker (although 14 is the max).
  • Loading branch information
inexorabletash committed Oct 4, 2023
1 parent 41899d3 commit 84f8d24
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 61 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Project Page: https://github.com/a2stuff/a2d
* Filetype and support for Vortex Tracker PT3 files.
* Added an easter egg. Can you find it?
* Improve layout of Add/Edit a Shortcut dialog.
* Remove 12 volume limit from Format/Erase picker.

### Selector

Expand Down
2 changes: 1 addition & 1 deletion desktop/auxmem.s
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ kDialogLabelRow6 = kDialogLabelBaseY + kDialogLabelHeight * 6
DEFINE_RECT_FRAME prompt_dialog_frame_rect, kPromptDialogWidth, kPromptDialogHeight

kPromptDialogInsetLeft = 8
kPromptDialogInsetTop = 25
kPromptDialogInsetTop = 20
kPromptDialogInsetRight = 8
kPromptDialogInsetBottom = 20
DEFINE_RECT clear_dialog_labels_rect, kPromptDialogInsetLeft, kPromptDialogInsetTop, kPromptDialogWidth-kPromptDialogInsetRight, kPromptDialogHeight-kPromptDialogInsetBottom
Expand Down
14 changes: 2 additions & 12 deletions desktop/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -14664,10 +14664,10 @@ params: .res 3
copy #0, text_input_buf

jsr OpenDialogWindow
jsr DrawOKButton
BTK_CALL BTK::Draw, ok_button_params
bit prompt_button_flags
bmi done
jsr DrawCancelButton
BTK_CALL BTK::Draw, cancel_button_params
done: rts
.endproc ; OpenPromptWindow

Expand Down Expand Up @@ -14780,11 +14780,6 @@ calc_y:

;;; ============================================================

.proc DrawOKButton
BTK_CALL BTK::Draw, ok_button_params
rts
.endproc ; DrawOKButton

.proc UpdateOKButton
bit format_erase_overlay_flag
IF_NS
Expand Down Expand Up @@ -14813,11 +14808,6 @@ set_state:
ret: rts
.endproc ; UpdateOKButton

.proc DrawCancelButton
BTK_CALL BTK::Draw, cancel_button_params
rts
.endproc ; DrawCancelButton

.proc EraseOKCancelButtons
jsr SetPenModeCopy
MGTK_CALL MGTK::PaintRect, ok_button_rec::rect
Expand Down
39 changes: 14 additions & 25 deletions desktop/ovl_format_erase.s
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

kDefaultFloppyBlocks = 280

kMaxVolumesInPicker = 12 ; 3 cols * 4 rows

;;; ============================================================

;; This must be page-aligned.
Expand All @@ -47,10 +45,6 @@ Exec:
selected_index:
.byte 0

;;; Number of volumes; min(DEVCNT+1, kMaxVolumesInPicker)
num_volumes:
.byte 0

;;; ============================================================
;;; Show the device prompt, name prompt, and confirmation.
;;; Input: A=operation flag, high bit set=erase, clear=format
Expand All @@ -77,12 +71,14 @@ num_volumes:
lda unit_num
bne skip_select

MGTK_CALL MGTK::MoveTo, vol_picker_select_pos
bit erase_flag
IF_NC
param_call main::DrawDialogLabel, 1, aux::str_select_format
ldax #aux::str_select_format
ELSE
param_call main::DrawDialogLabel, 1, aux::str_select_erase
ldax #aux::str_select_erase
END_IF
jsr main::DrawString

MGTK_CALL MGTK::SetPenMode, notpencopy
MGTK_CALL MGTK::MoveTo, vol_picker_line1_start
Expand Down Expand Up @@ -336,7 +332,6 @@ kOptionPickerItemWidth = kVolPickerItemWidth
kOptionPickerItemHeight = kVolPickerItemHeight
kOptionPickerLeft = kVolPickerLeft
kOptionPickerTop = kVolPickerTop
kOptionPickerRowShift = ::kVolPickerRowShift
option_picker_item_rect := vol_picker_item_rect

.include "../lib/option_picker.s"
Expand Down Expand Up @@ -380,9 +375,10 @@ ret: rts
;;; Input: A = index
;;; Output: A unchanged, Z=1 if valid, Z=0 if not valid
.proc IsIndexValid
cmp num_volumes
cmp DEVCNT
beq yes
bcs no
ldx #0 ; clear N
yes: ldx #0 ; clear N
rts
no: ldx #$FF ; set N
rts
Expand All @@ -392,21 +388,16 @@ no: ldx #$FF ; set N
;;; Draw volume labels

.proc DrawVolumeLabels
ldx DEVCNT ; number of volumes - 1
inx
cpx #kMaxVolumesInPicker
bcc :+
ldx #kMaxVolumesInPicker
: stx num_volumes

lda #0
sta vol

vol := *+1
loop: lda #SELF_MODIFIED_BYTE
cmp num_volumes
RTS_IF_EQ

cmp DEVCNT
bcc :+
beq :+
rts
:
jsr option_picker::GetOptionPos
addax #kVolPickerTextHOffset, vol_picker_item_rect::x1
tya
Expand All @@ -415,9 +406,8 @@ loop: lda #SELF_MODIFIED_BYTE
MGTK_CALL MGTK::MoveTo, vol_picker_item_rect::topleft

;; Reverse order, so boot volume is first
lda num_volumes
lda DEVCNT
sec
sbc #1
sbc vol
jsr GetDeviceNameForIndex
jsr main::DrawString
Expand All @@ -444,9 +434,8 @@ loop: lda #SELF_MODIFIED_BYTE

.proc GetSelectedUnitNum
;; Reverse order, so boot volume is first
lda num_volumes
lda DEVCNT
sec
sbc #1
sbc selected_index
tax
lda DEVLST,x
Expand Down
1 change: 0 additions & 1 deletion desktop/ovl_selector_pick.s
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ kOptionPickerItemWidth = kShortcutPickerItemWidth
kOptionPickerItemHeight = kShortcutPickerItemHeight
kOptionPickerLeft = kShortcutPickerLeft
kOptionPickerTop = kShortcutPickerTop
kOptionPickerRowShift = ::kShortcutPickerRowShift
option_picker_item_rect := entry_picker_item_rect

.include "../lib/option_picker.s"
Expand Down
9 changes: 5 additions & 4 deletions desktop/res.s
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ pensize_frame: .byte kBorderDX, kBorderDY
;; Options control metrics
kShortcutPickerCols = 3
kShortcutPickerRows = 8
kShortcutPickerRowShift = 3 ; log2(kShortcutPickerRows)
kShortcutPickerLeft = (winfo_entry_picker::kWidth - kShortcutPickerItemWidth * kShortcutPickerCols + 1) / 2
kShortcutPickerTop = 24
kShortcutPickerItemWidth = 104
Expand All @@ -390,15 +389,17 @@ pensize_frame: .byte kBorderDX, kBorderDY

;; Options control metrics
kVolPickerCols = 3
kVolPickerRows = 4
kVolPickerRowShift = 2 ; log2(kVolPickerRows)
kVolPickerRows = 5
kVolPickerLeft = (winfo_prompt_dialog::kWidth - kVolPickerItemWidth * kVolPickerCols + 1) / 2
kVolPickerTop = 44
kVolPickerTop = 34
kVolPickerItemWidth = 127
kVolPickerItemHeight = kListItemHeight
kVolPickerTextHOffset = 1
kVolPickerTextVOffset = kVolPickerItemHeight-1

;; Label pos
DEFINE_POINT vol_picker_select_pos, kDialogLabelDefaultX, kVolPickerTop - 4

;; Line endpoints
DEFINE_POINT vol_picker_line1_start, 7, kVolPickerTop - 2
DEFINE_POINT vol_picker_line1_end, winfo_prompt_dialog::kWidth - 8, kVolPickerTop - 2
Expand Down
3 changes: 2 additions & 1 deletion lib/muldiv.s
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ num2: .byte 0

;;; ============================================================
;;; Input: dividend in A,X, divisor in Y (all unsigned)
;;; Output: quotient in A,X (unsigned)
;;; Output: quotient in A,X (unsigned), Y = remainder

.proc Divide_16_8_16
result := dividend
Expand Down Expand Up @@ -65,6 +65,7 @@ loop: asl dividend
skip: dex
bne loop
ldax dividend
ldy remainder
rts

dividend:
Expand Down
25 changes: 11 additions & 14 deletions lib/option_picker.s
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
;;; * `kOptionPickerItemHeight` - const
;;; * `kOptionPickerLeft` - const
;;; * `kOptionPickerTop` - const
;;; * `kOptionPickerRowShift` - const - log2(rows)
;;; Required definitions:
;;; * `selected_index` - byte, $FF if no selection
;;; * `option_picker_item_rect` - MGTK::Rect
Expand All @@ -31,7 +30,6 @@
.scope option_picker_impl

kOptionPickerMaxEntries = kOptionPickerRows * kOptionPickerCols
.assert 1 << option_picker::kOptionPickerRowShift = kOptionPickerRows, error, "Rows/RowShift mismatch"

;;; ============================================================

Expand Down Expand Up @@ -95,11 +93,10 @@ ret: rts
;;; Input: A = volume index
;;; Output: A,X = x coordinate, Y = y coordinate
.proc GetOptionPos
sta index
.repeat option_picker::kOptionPickerRowShift
lsr ; lo
.endrepeat
ldx #0 ; hi
ldy #option_picker::kOptionPickerRows
jsr Divide_16_8_16
sty remainder
ldy #kOptionPickerItemWidth
jsr Multiply_16_8_16
clc
Expand All @@ -110,10 +107,9 @@ ret: rts
pha ; hi

;; Y coordinate
index := *+1
lda #SELF_MODIFIED_BYTE
and #kOptionPickerRows-1
ldx #0 ; hi
remainder := *+1
lda #SELF_MODIFIED_BYTE ; lo
ldx #0 ; hi
ldy #kOptionPickerItemHeight
jsr Multiply_16_8_16
clc
Expand Down Expand Up @@ -155,11 +151,12 @@ ret: rts
bcs done

;; Index
.repeat option_picker::kOptionPickerRowShift
asl
.endrepeat
ldx #0 ; hi
ldy #option_picker::kOptionPickerRows
jsr Multiply_16_8_16
clc
row := *+1
ora #SELF_MODIFIED_BYTE
adc #SELF_MODIFIED_BYTE
rts

done: return #$FF
Expand Down
2 changes: 1 addition & 1 deletion res/notes/testplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
* Launch DeskTop. Run the command. Select a disk (other than the startup disk) and click OK. Enter a name, but place the IP in the middle of the name (e.g. "exam|ple"). Click OK. Verify that the full name is used.
* Launch DeskTop. Run the command. Select an empty drive. Let the operation continue until it fails. Verify that an error message is shown.
* Configure a system with at least 9 volumes. Launch DeskTop. Run the command. Select a volume in the third column. Click OK. Verify that the selection rect is fully erased.
* Configure a system with 13 volumes, not counting /RAM. Launch DeskTop. Run the command. Verify that the boot device is excluded from the list so that only 12 devices are shown. Verify using the arrow keys that there aren't any overlapping volume entries.
* Configure a system with 13 volumes, not counting /RAM. Launch DeskTop. Run the command. Verify that all 13 volumes are shown.
* Launch DeskTop. Run the command. Select a slot/drive containing an existing volume. Enter a new name and click OK. Verify that the confirmation prompt shows the volume with adjusted case matching the volume's icon, with quotes around the name.
* Launch DeskTop. Run the command. Select a slot/drive containing an existing volume with a GS/OS-cased name and click OK. Enter a new name and click OK. Verify that the confirmation prompt shows the volume with the correct case matching the volume's icon, with quotes around the name.
* Launch DeskTop. Run the command. Select a slot/drive containing a Pascal disk. Enter a new name and click OK. Verify that the confirmation prompt shows the Pascal volume name (e.g. "TGP:"), with quotes around the name.
Expand Down
2 changes: 0 additions & 2 deletions selector/app.s
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ str_selector_title:
;; Options control metrics
kEntryPickerCols = 3
kEntryPickerRows = 8
kEntryPickerRowShift = 3 ; log2(kEntryPickerRows)
kEntryPickerLeft = (winfo::kWidth - kEntryPickerItemWidth * kEntryPickerCols + 1) / 2
kEntryPickerTop = 21
kEntryPickerItemWidth = 127
Expand Down Expand Up @@ -781,7 +780,6 @@ kOptionPickerItemWidth = kEntryPickerItemWidth
kOptionPickerItemHeight = kEntryPickerItemHeight
kOptionPickerLeft = kEntryPickerLeft
kOptionPickerTop = kEntryPickerTop
kOptionPickerRowShift = app::kEntryPickerRowShift
option_picker_item_rect := entry_picker_item_rect

.include "../lib/option_picker.s"
Expand Down

0 comments on commit 84f8d24

Please sign in to comment.