“Folders” on home screen?

Use this section to showcase your programming examples. Or to ask members for programming suggestions
User avatar
Martin
Global Admin
Posts: 423
Joined: Mon Jan 02, 2023 5:18 pm

“Folders” on home screen? - Cracked It!

Post by Martin »

(DUPLICATE?) Hi Martin... this seems to work fine.... Thank you...
MartinP wrote: Sun Feb 16, 2025 11:23 am Martin,
So you could use the second variable in the usr() command, as suggested by Zenerdiode, but this time put the address of the filename string there:
usr(addr(mc%()),addr(f$))
EDITED after comment from MartinP below

Code: Select all

TRY:
LOCAL f$(8),A%(4),m%

REM TRY to access database from a Top Level Menu List
REM NONE.odb does not exist Reports an error (try it)
REM CTEST is on Rampak C: TEST and MORE are on A:
REM As before 1st [ON/CLEAR] closes xFiles (cursor off)
REM 2nd [ON/CLEAR] Returns

TOP::
DO
m%=MENU("CTEST,TEST,MORE,NONE")
IF m%=0 :RETURN
ELSEIF m%=1 :f$="CTEST"
ELSEIF m%=2 :f$="TEST"
ELSEIF m%=3 :f$="MORE"
ELSEIF m%=4 :f$="NONE"
ENDIF
UNTIL m%>0

REM should check length of f$=LEFT$(f$,8)

REM XFILES
A%(1)=$DD41 :REM STD $41 store pointer to filename in $41-$42 (utw_s0)
A%(2)=$C603 :REM Function 3 - Find a file as from top-level menu.
A%(3)=$3FA8 :REM REM SWI $A8 XF$ENTR
A%(4)=$3901 :REM RTS, NOP
USR(ADDR(A%()),ADDR(f$))

GOTO TOP::
Daren wrote: Thu Feb 13, 2025 1:57 am Is it possible to use the menu function in opl to give a folder like function?
Daren, you could adapt this, don't forget to add some error trapping... I figure that if you don't know the name of the database to put it in the MENU then you will probably use xFiles anyway.

Sincerely and in good faith
Martin


PS Thanks everyone I enjoyed that..
.
MartinP
Posts: 68
Joined: Wed Jan 04, 2023 7:51 pm

Re: “Folders” on home screen?

Post by MartinP »

Martin,
I was surprised this works without intentionally loading the address of f$ into utw_s0 ($41 and $42), it seems that by chance, utw_s0 is already loaded with the correct address, perhaps USR() also uses utw_s0, to load the D register?
See this screenshot form Paul Robson's debugger, which shows that utw_s0 is already loaded at the start of the code execution (breakpoint and program counter Pc at start):
try_debug.PNG
To be safe, and load utw_s0 intentionally, I would modify the machine code to this:

Code: Select all

A%(1)=$DD41 REM STD $41 store pointer to filename in $41-$42 (utw_s0)
A%(2)=$C603 REM LDAB #$03
A%(3)=$3FA8 REM SWI $A8 XF$ENTR
A%(4)=$3901 REM RTS, NOP
Edit: this also shows that trying pokew() was a bad suggestion because there are probably lots of processes that could overwrite utw_s0 between the poke and the code execution.

Martin P
You do not have the required permissions to view the files attached to this post.
User avatar
Martin
Global Admin
Posts: 423
Joined: Mon Jan 02, 2023 5:18 pm

“Folders” on home screen? - an edit

Post by Martin »

Martin... You will see (in the post above) I've added the extra line now A%(1) to A%(4)..

I don't really understand how $DD41 knows the filename address of (in this case) f$! But it works and I'm not going to question it as I wouldn't understand the answer.

Again thanks for keeping an eye on me.
Sincerely
Martin
Daren
Posts: 113
Joined: Tue Jan 03, 2023 10:03 pm

Re: “Folders” on home screen?

Post by Daren »

Very interesting, thanks everyone for your suggestions and help - it makes me now wonder what other UI enhancements could be made, a can of worms perhaps, or maybe another interesting discussion to have. I have successfully managed a couple of things that make the Psion work better for me - the key click thing, and a better more efficient timer for LZ, which I will post once finished, so I’m often thinking along these lines, even if I don’t always know how to tackle them, but the learning is fun.

I think I will try this example, after first doing a full backup, because knowing me I’ll likely end up getting something wrong.
User avatar
Martin
Global Admin
Posts: 423
Joined: Mon Jan 02, 2023 5:18 pm

Spares

Post by Martin »

Daren wrote: Mon Feb 17, 2025 12:52 am I think I will try this example, after first doing a full backup, because knowing me I’ll likely end up getting something wrong.
Hi Daren... I know what you mean!... I 'bit the bullet' and got a spare LZ(32) and a Rampack from Peter... It makes 'playing' a lot less stressful..

Sincerely
Martin
amenjet
Posts: 405
Joined: Tue Jan 03, 2023 7:54 pm

Re: “Folders” on home screen?

Post by amenjet »

MartinP wrote: Sun Feb 16, 2025 4:59 pm See this screenshot form Paul Robson's debugger, which shows that utw_s0 is already loaded at the start of the code execution (breakpoint and program counter Pc at start):
Do you have a link to that debugger?
MartinP
Posts: 68
Joined: Wed Jan 04, 2023 7:51 pm

Re: “Folders” on home screen?

Post by MartinP »

I've attached the debugger, it was posted on the old forum, it runs in dosbox.
org2lz64.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Martin
Global Admin
Posts: 423
Joined: Mon Jan 02, 2023 5:18 pm

Re: “Folders” on home screen?

Post by Martin »

Daren wrote: Mon Feb 17, 2025 12:52 am I think I will try this example, after first doing a full backup, because knowing me I’ll likely end up getting something wrong.
Hi Daren

This is my version.. I called it Recce so you can put it on the main menu and just press [R] to start it...
(1) it scans all devices for database files (2) builds a menu of choices (3) fast tracks to xFiles with the 'choice' open

Code: Select all

RECCE:
LOCAL d$(1),f$(8,10),xf$(8),A%(4),m$(64),m%,d%,c%

REM ****** LZ organiser only can use xFiles ******
REM Place RECCE on the main menu & access press [R]
REM A% = variable for machine code store
REM d$ = device
rem d% = device character number
REM f$ = 8 files with max 10 characters (can increase)
REM xf$= filename to be passed to xFiles
REM c% = counter
REM m% = MENU item number
REM m$ = MENU string max 64 chrs (8x(10-2))

REM Find all database files except MAINs on all devices
REM and make into a MENU of choices
REM When returning from looking at a database
REM 1st [ON/CLEAR] closes xFiles (cursor off)
REM 2nd [ON/CLEAR] Returns to the MENU

REM GET database files on all devices
d%=65
c%=1
DO
 d$=CHR$(d%)
 TRAP OPEN d$+":MAIN",A,a$ :IF ERR=246 :GOTO SKIP:: :ENDIF :REM 246=NO PACK
 f$(c%)=DIR$(d$)
 IF LOC(f$(c%),"MAIN")=0 :c%=c%+1 :ENDIF  :REM Don't want MAIN files
 DO
  f$(c%)=DIR$("")
  IF f$(c%)="" :GOTO SKIP:: :ENDIF
  c%=c%+1
 UNTIL c%>10
 SKIP::
 d%=d%+1
UNTIL d%>67 OR c%>10

REM Generate MENU text m$
c%=1
m$=""
WHILE f$(c%)<>""
 f$(c%)=RIGHT$(f$(c%),LEN(f$(c%))-2)   :REM remove the A: etc
 m$=m$+f$(c%)+","                      :REM MENU items delimited with coma
 c%=c%+1
ENDWH

REM just in case there are no database files other than MAINs
IF m$="" :REM 1234567890123456789-1234567890123456789-
  CLS :PRINT " No database files  found on any device!" :GET :RETURN
ENDIF

REM display the menu of Database files
TOP::
DO
 UDG 0,0,10,0,17,14,0,0,31
 UDG 2,0,0,0,0,0,0,0,31
 PRINT CHR$(0);REPT$(CHR$(2),14) :CLOCK(1) :AT 1,2
 m%=MENUN(2,m$)
 IF m%=0 :RETURN :ENDIF     :REM [ON/CLEAR] quits
 xf$=f$(m%) :GOTO XF::
UNTIL m%=0

REM XFILES - With help from forum member MartinP
XF::
A%(1)=$DD41 :REM STD $41 store pointer to filename in $41-$42 (utw_s0)
A%(2)=$C603 :REM Function 3 - Find a file as from top-level menu.
A%(3)=$3FA8 :REM REM SWI $A8 XF$ENTR
A%(4)=$3901 :REM RTS, NOP
USR(ADDR(A%()),ADDR(xf$))

GOTO TOP::
If anyone tries it (or just reads it) I'd be interested to hear what you think.

Sincerely Martin

EDIT: If there are two files with the same name on different devices - It doesn't crash but it always opens the one on A; before B: and B: before C:
.
Daren
Posts: 113
Joined: Tue Jan 03, 2023 10:03 pm

Re: “Folders” on home screen?

Post by Daren »

Wow Martin, that’s quite a bit more sophisticated than my initial idea, I look forward to trying it out, a name suggestion ZFiles as it is a unlikely letter to be used or QFiles as in quick files maybe?

Great stuff and thanks!

PS The idea of having a “guinea pig” machine is something I should do to, I have a few spares so it seems daft not to thinking about it, I’ll just put a sticker on the guinea pig so I don’t get mixed up.

Test subject is a go!Image
You do not have the required permissions to view the files attached to this post.
User avatar
Martin
Global Admin
Posts: 423
Joined: Mon Jan 02, 2023 5:18 pm

guinea pig

Post by Martin »

Great stuff... next stop 2K Rampak
Martin
Post Reply