Skip to content

Commit

Permalink
DeskTop: Improve scrolling in directory windows. Resolves #711
Browse files Browse the repository at this point in the history
The previous scroll logic for windows made each increment 1/20th of
the scroll range, which made scrolling down in windows without tons of
icons absurdly slow. There were also numerous edge cases requiring
hacky fixes, and spaghetti code throughout DeskTop to implement it.

Rework scrolling entirely. A ScrollManager scope is introduced, which
exposes a much simplified set of entry points - actions on the
scrollbar (clicks or thumb moves) and adjusting the scrollbars
following a content change or resize. Callers are also
simplified/reworked.

Specific behavior changes:

* Scroll thumbs have full fidelity (up to 256 steps).

* Scroll arrows move by roughly 1/2 the grid spacing, when in icon
  view. When in list view they scroll vertically by a single row.

* Rows when in list view are now spaced out like list controls.

* Scroll position is reset when switching from icon to list view.

This ends up saving roughly 178 bytes.
  • Loading branch information
inexorabletash committed Sep 10, 2022
1 parent be9bbc0 commit 497ad03
Show file tree
Hide file tree
Showing 6 changed files with 628 additions and 849 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Project Page: https://github.com/a2stuff/a2d
* File > Copy a File... is now File > Copy To... and operates on current selection.
* File > Delete a File... is now File > Delete and operates on current selection.
* Support up to 14 devices. ([#712](https://github.com/a2stuff/a2d/issues/712))
* Improve scrolling in directory windows. ([#711](https://github.com/a2stuff/a2d/issues/711))

### Disk Copy

Expand Down
96 changes: 1 addition & 95 deletions desk.acc/show.text.file.s
Original file line number Diff line number Diff line change
Expand Up @@ -1239,102 +1239,8 @@ window_id: .byte kDAWindowId
.endproc

;;; ============================================================
;;; 32 bit by 32 bit division with 32 bit result
;;; Based on: https://www.reddit.com/r/asm/comments/nbu2dj/32_bit_division_subroutine_on_the_6502/gy21eog/

numerator := $10
denominator := $14
quotient := numerator

.proc Div_32_32
remainder := $18
temp := $1C

ldx #4-1
lda #0
: sta remainder,x
dex
bpl :-

ldx #32 ; bits
divloop:
asl numerator+0
rol numerator+1
rol numerator+2
rol numerator+3

rol remainder+0
rol remainder+1
rol remainder+2
rol remainder+3

sec
subtract:
lda remainder+0
sbc denominator+0
sta temp+0

lda remainder+1
sbc denominator+1
sta temp+1

lda remainder+2
sbc denominator+2
sta temp+2

lda remainder+3
sbc denominator+3
sta temp+3

bcc next ; remainder > divisor?
inc numerator ; yes

ldy #4-1 ; remainder = temp
: lda temp,y
sta remainder,y
dey
bpl :-

next: dex
bne divloop

rts
.endproc

;;; ============================================================
;;; 16 bit by 16 bit multiply with 32 bit product

multiplier := $10
multiplicand := $12
product := $14

.proc Mul_16_16
lda #0
sta product+2
sta product+3

ldx #16
shift:
lsr multiplier+1
ror multiplier
bcc rotate
lda product+2
clc
adc multiplicand
sta product+2
lda product+3
adc multiplicand+1
rotate:
ror a
sta product+3
ror product+2
ror product+1
ror product
dex
bne shift

rts
.endproc
.include "../lib/muldiv32.s"

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

Expand Down
19 changes: 16 additions & 3 deletions desktop/internal.inc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ kWindowHeaderHeight = 14

kFirstRowBaseline = 16
kListViewWidth = 410
kListViewRowHeight = kSystemFontHeight + 1

;;; --------------------------------------------------
;;; Icon views
Expand All @@ -85,16 +86,28 @@ kIconSpacingY = 32

;;; Bounding box padding, which defines icon placing, window sizing and
;;; scrollbars. This does not take into account the icon's actual width
;;; (bitmap or label size). The header is included to simplify
;;; calculations.
;;; (bitmap or label size).

;;; TODO: Rework callers to remove need for kWindowHeaderHeight.
kIconBBoxOffsetTop = kWindowHeaderHeight + 4
kIconBBoxOffsetLeft = 45
kIconBBoxOffsetBottom = kIconLabelHeight + 4
kIconBBoxOffsetRight = 37 + kIconWidth ; accommodate icon + label
;;; NOTE: kIconBBoxOffsetRight should probably be se to
;;; NOTE: kIconBBoxOffsetRight should probably be set to
;;; kIconBBoxOffsetLeft + kIconWidth but aesthetically that looks bad.

;;; --------------------------------------------------
;;; Scrolling

;;; Allow maximum fidelity
kScrollThumbMax = $FF

;;; Arbitrary - these feel good, but can be tweaked
kIconViewScrollTickH = kIconSpacingY
kIconViewScrollTickV = kIconSpacingY / 2
kListViewScrollTickH = kListViewRowHeight * 2
kListViewScrollTickV = kListViewRowHeight

;;; ============================================================
;;; Common Shortcuts

Expand Down
Loading

0 comments on commit 497ad03

Please sign in to comment.