refactor scrollbar -- correct with any legal number of carts now
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmFlI7MACgkQO3+8IhRO Y5iZiw//eeODivAjkuxL/LE6CTMo9gBzv15VBAdZOvTiOHuIfib4tJDL6e9ePKHZ RL3aXXpcuXSamBKcTpSEvgMjloZjgWFx2qQqFXEhR1RPAUvVq5EdqfDMv8GKHip5 /CUQsoY+r/b/Us/L0GjxRz2O8VKKlpkVFuw6pS3xplfIv31qmACtITKGAd608RE3 1X6rg01yTGC41081itDdclFdrq8sVSOw5WA1sxRr5nWhSXBZSc1vjYKuBtJJ49aC GCF45p2cVtSfR4aKtGl8TCZKPJltebTcxmo0PVsv7xgE1o1j+WoKSfmp68Iox62C jFiG322v2h+YF9mQnId+TSUOazAYiiE6BnQa0NpaykDLTgiwvyXjI2WYJqnSnQ4u 2z0S8sX7l9vtkEhhKYtGYhUJzVrk+HepGfLXFMmCxt2Yi0A+1E2lpattGvJHMON2 cwQzN9q/MTQGU1Iykw10LdBLNvRdByeWj70mCsA1r3yuUb3aNPLSDwrZD+uhP06D ptCRUMVAnpxX3X2ZqTrEUJtmYiDTTl4DX3j5NzK6bMyNGtQlleVXdsbeo2QQfc4V Q3GFofrEZEgAjsa5YoGH+N/CN3WiLsulyWHdjqIJIkML+tgsYoMPejNR8OtThSOv YLzKLF3YQAxB9/XRofXHFK4SJdlCAmLG6HVik0nVPNxrMJ6V0bQ= =ZxBY -----END PGP SIGNATURE-----
1 files changed,
32 insertions(+),
27 deletions(-)
jump to
M
uxn-client/xrxs.tal
→
uxn-client/xrxs.tal
@@ -53,6 +53,9 @@ @list-height $1
@select-index $1 @ncarts $1 @btn-state $1 +@sb-len $1 +@sb-pos $1 +@sb-step $1 @cart $32 @realm $32@@ -548,49 +551,41 @@ #02
RTN -( this scrollbar breaks down with about 2x as many cartridges as the scren - has room for. A better method would be keeping track of the height, step, - and position ) - @draw-scrollbar ( -> ) .Screen/width DEI2 #0048 SUB2 .Screen/x DEO2 #0028 .Screen/y DEO2 - - &trough-only + ( draw the trough no matter what ) ;scrollbar-trough .Screen/addr DEO2 .list-height LDZ #00 - &while-trough-only EQUk ,&end-trough-only JCN + &while-trough EQUk ,&end-trough JCN #81 .Screen/sprite DEO INC-Y - INC ,&while-trough-only JMP &end-trough-only POP2 + INC ,&while-trough JMP &end-trough POP2 + ( stop here if there is no overflow ) .ncarts LDZ .list-height LDZ LTH ,&no-handle JCN - ,&start-loop JMP + ,&draw-handle JMP &no-handle RTN - &start-loop + ( if there are more carts than will fit in the view area, draw the handle ) + &draw-handle #0028 .Screen/y DEO2 - ( store the number of carts per tile of the scroll bar ) - .ncarts LDZ .list-height LDZ DIV STH - - .list-height LDZ #00 - &while EQUk ,&end JCN - ( trough top ) - DUP INC STHrk MUL .list-top LDZ GTH ,&handle JCN - INC - INC-Y - ,&while JMP - &handle - DUP INC INC STHrk .ncarts LDZ [ .list-top LDZ .list-height LDZ ADD ] SUB MUL ADD .list-height LDZ GTH ,&trough-bottom JCN - ;scrollbar .Screen/addr DEO2 - #81 .Screen/sprite DEO - &trough-bottom - INC-Y - INC ,&while JMP &end POP2 POPr + ( store the number of carts per tile of the scrollbar ) + .ncarts LDZ .list-height LDZ DIV .sb-step STZ + + ( set the length of the scrollbar ) + .list-height LDZ .ncarts LDZ .list-height LDZ SUB .sb-step LDZ DIV SUB .sb-len STZ + + ;scrollbar .Screen/addr DEO2 + #0028 .sb-pos LDZ #30 SFT TOS ADD2 .Screen/y DEO2 + .sb-len LDZ #00 &while-handle EQUk ,&end-handle JCN + .Screen/y DEI2 .Screen/height DEI2 #0028 SUB2 EQU2 ,&end-handle JCN + #81 .Screen/sprite DEO + INC INC-Y ,&while-handle JMP &end-handle POP2 RTN@@ -632,6 +627,7 @@ .ncarts LDZ .list-height LDZ LTH ,&no-scroll-up JCN
.list-top LDZ #00 EQU ,&no-scroll-up JCN .list-top LDZ #01 SUB .list-top STZ &no-scroll-up + ;update-sb-pos JSR2 RTN @try-scroll-down-mouse ( -> )@@ -639,6 +635,7 @@ .ncarts LDZ .list-height LDZ LTH ,&no-scroll-down JCN
.list-top LDZ .list-height LDZ ADD .ncarts LDZ #01 ADD EQU ,&no-scroll-down JCN .list-top LDZ INC .list-top STZ &no-scroll-down + ;update-sb-pos JSR2 RTN@@ -648,6 +645,7 @@ DUP .list-top LDZ NEQ ,&no-scroll-up JCN
.list-top LDZ #00 EQU ,&no-scroll-up JCN .list-top LDZ #01 SUB .list-top STZ &no-scroll-up + ;update-sb-pos JSR2 RTN @try-scroll-down ( -> )@@ -656,6 +654,13 @@ DUP .list-top LDZ .list-height LDZ ADD #01 SUB NEQ ,&no-scroll-down JCN
.list-top LDZ .list-height LDZ ADD .ncarts LDZ #01 ADD EQU ,&no-scroll-down JCN .list-top LDZ INC .list-top STZ &no-scroll-down + ;update-sb-pos JSR2 +RTN + +@update-sb-pos ( -> ) + + .list-top LDZ .sb-step LDZ DIV .sb-pos STZ + RTN @get-select-idx-by-key ( -> )