Program launcher menu - design, questions

Program launcher menu - design, questions

Postby nojoopa » Thu Oct 26, 2006 2:06 pm

I'll start coding a program launcher menu for C64 (or DTV) with 1541-III(-DTV) in a couple of days. It will be done in ASM and the source will be released.

The idea is to:
1. Present a list of programs to the user in alphabetical order.
2. Let the user browse the available programs using next/previous, page-up/down and "jump to the first program starting with the letter X" controls
3. Let the user start a program by pressing enter/fire/etc.

The list of programs is constant (determined at compile) and includes data required to find the program from the SD/MMC. This data consist of:
1. The disk number as given by 1541-III when doing a LOAD"$0",8
2. The file name (in this case a number) of the program.

That last paragraph probably raises some questions, so I'll answer them before you can make them :)

Q: Why use a number as the file name instead of simply doing a LOAD"selected_program_name",8,1?
A: The reason is that I want to use the program to select games from the "Blast from the past" collection, which has it's own launcher program and files with the names of "1"..."9" (or less, depending on the number of games). The "Blast" laucher program doesn't seem to load the games on my DTV/1541-III-DTV combo; I assume it's using an incompatible disk turbo. Loading the individual games seems to work.

Q: Why rely on the disk number instead of checking for the disk name?
A: The reason again is "Blast from the past", which has disks named "blast001.d64"..."blast340.d64", which can be copied to the SD/MMC in order the make sure the disk number is correct.

The basic (and in BASIC) idea of loading the correct file should be (AFAIK):
1. OPEN1,8,2,"$x":CLOSE1 (or is it CLOSE2 ?)
2. LOAD"y",8,1
3. RUN
...where x = disk number ("1"..."511") and y = program number ("1".."9").

I haven't done any code (in BASIC or ASM) that uses disk/file operations, so I'd like some advise:
1. How to perform the OPEN...CLOSE? Using some kernal funtions?
2. How the LOAD and RUN the program? Do I copy the relevant part of code to stack/tape buffer and execute it there? Do I use kernal functions? Or could I just put LOAD"y",8,1<enter>RUN<enter> to the keyboard buffer and just RTS to BASIC?

Questions on the data format:
Should I use an array with fixed lengt entries to allow binary search for the "jump to program starting with X"? Or is a simple "for...next" type of loop fast enough with about 1900 entries? Or should the first programs starting with 0..9,A...Z indexed at start of the program (or even in the backgound while browsing)?

Ideas/suggestions/code are welcome :)
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby Grokk » Thu Oct 26, 2006 3:00 pm

1. How to perform the OPEN...CLOSE? Using some kernal funtions?

Yes, I can send you a private mail later and explain exactly how. It is easy. If you have it, read the "Programmers Reference Guide 3"
2. How the LOAD and RUN the program?

The load is also performed with kernal functions, similar to OPEN and CLOSE. (Since you were going to write in ASM) Then you can state load adresses and just jump into the code.
Grokk
 
Posts: 29
Joined: Tue Sep 26, 2006 12:53 pm
Location: Sweden

Postby nojoopa » Thu Oct 26, 2006 5:35 pm

Grokk wrote:Yes, I can send you a private mail later and explain exactly how. It is easy. If you have it, read the "Programmers Reference Guide 3"

Thanks! I will read the C64PRG.

Grokk wrote:The load is also performed with kernal functions, similar to OPEN and CLOSE. (Since you were going to write in ASM) Then you can state load adresses and just jump into the code.

I see two problems with this:
1. Loading the program might overwrite the program laucher code, but I think this can be avoided by copying the LOAD & RUN code to tapebuffer or stack and executing it from there.
2. The programs I would load seem use a BASIC stub (1 SYS 1234) so I cannot just JMP to the load address, and I think putting RUN<enter> to the keyboard buffer and returning to BASIC would be shorter and easier (if it actually works) than parsing the SYS address.

I'll finish up my Symbian homework and start on this project (hopefully) tomorrow.
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby Pyrofer » Thu Oct 26, 2006 5:39 pm

Cant you just convert the sys 49152 or whatever into hex to get the jmp address? or is there a memory bank issue?
Pyrofer
 
Posts: 139
Joined: Tue Sep 26, 2006 11:06 pm

Postby Grokk » Thu Oct 26, 2006 6:46 pm

Loading the program might overwrite the program laucher code, but I think this can be avoided by copying the LOAD & RUN code to tapebuffer or stack and executing it from there.

Thats a good idéa, if you cannot find another space that is always free. You can use the screen also :)
On the DTV you also have the ability which I use in my DTVBASIC to make your own ROMS. You can replace the basic ROM with your own ROM image from upper ram. This gives you the possibility to actually load data UNDER your own code which I think is a bit cool...
returning to BASIC would be shorter and easier (if it actually works) than parsing the SYS address.

True, but I thougt you were going to make lists of lodeable programs, and then you could have the jump adresses in the same table.
Parsing the SYS is not all that difficult either. search for token $9e (if I remember correctly).
I think putting RUN<enter> to the keyboard buffer and returning to BASIC would be shorter and easier (if it actually works)

It works. You can also jump to the BASIC:s RUN function. I don't think you need to relink the basic program since the first instruction is a SYS.
Grokk
 
Posts: 29
Joined: Tue Sep 26, 2006 12:53 pm
Location: Sweden

Postby nojoopa » Fri Oct 27, 2006 10:46 am

Grokk wrote:You can use the screen also :)

Wow, why I didn't think of that myself? Thanks again.

Grokk wrote:On the DTV you also have the ability which I use in my DTVBASIC to make your own ROMS. You can replace the basic ROM with your own ROM image from upper ram. This gives you the possibility to actually load data UNDER your own code which I think is a bit cool...

The program will be compatible with C64 and 1541-III. I could use detection routines to see if the hardware is a DTV and act accordingly, but it would just complicate things.

Grokk wrote:True, but I thougt you were going to make lists of lodeable programs, and then you could have the jump adresses in the same table.

That's true, but these's two problems:
1. One jump address = 2 bytes, and for example the "Blast" collection has about 1900 games...and that's just 340 disks.
2. How to automate the jump address extraction? I'm not going to LOAD & LIST a couple of thousand games in Vice. :) I also want to make this program easily modifiable for different "collections" and I don't think anyone would want to manually extract/enter jump addresses.

Grokk wrote:Parsing the SYS is not all that difficult either. search for token $9e (if I remember correctly).

The problem is that this doesn't work with BASIC games or games that have some code before the SYS. I think the RUN-trick would be the perfect solution.

You can also jump to the BASIC:s RUN function. I don't think you need to relink the basic program since the first instruction is a SYS.

Jumping to the RUN function makes more sense :)
But relinking the basic program? The loaded program's stub? What if it's not just a SYS? I'd like some more info on this.

Thanks for all the help!
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby Grokk » Fri Oct 27, 2006 12:23 pm

The program will be compatible with C64

Ahh, I see, I didn't get that.

But relinking the basic program?


Hmmm, I am a bit on ice here, but i know basic does more than just loading. It moves pointers and re-links the program before start.
One of the reasons I suggested KERNAL load was that I was thinking this was unnesseacary with machine code games.

I didn't get that some of the programs was BASIC programs.
Maybe I am just complicating things instead of helping, but I will read the basic LOAD routine again tonight and might be able to give some more answers.
Grokk
 
Posts: 29
Joined: Tue Sep 26, 2006 12:53 pm
Location: Sweden

Postby nojoopa » Sun Oct 29, 2006 1:36 pm

Here's version 0.2 (prg+src):
http://student.forssa.hamk.fi/~fonuotiha/zselect.zip

I haven't tested it much because I'm having some problems with my USB card reader, but I have succesfully loaded all programs I tested. I wish Vice had a 1541-III emulator :)

Notes on this version:
- zselect.prg is compressed, uzselect.prg is not.
- Use joystick in port 2: up/down = prev/next, left/right = page up/down, fire = select
- The device number is 8. If yours if different, you need to recompile.
- The scrolling is SLOW. It will be fixed later.
- When you select a program, some garbage (LOAD&RUN code) appears on the top of the screen and the loading begins. If your 1541-III's LED is lit, it is loading the program. If the open & load work properly, the program will be run when loaded. If there's an error, the menu MIGHT restart (as there is no proper error detection at this moment and it still performs a RUN).
- The default menu contains some example entries. The first one does something like LOAD"$1",8:LOAD"*",8,1:RUN, so it should work if your SD/MMC card contains a .d64 file as the first entry. The second one does the same, except for "$3". The other entries require special .d64 files in special disk number locations, so they probably wont work with your card.

See zselect.a (near the end) for info on how to customize the menu for your own needs.

The source file(s) have unix EOL's. If that's a problem, open the file with EDIT, save and quit -> EOL's fixed.

Feedback, suggestions and test reports are welcome.

And again, some questions:
1. Does anyone know how to "autodetect" the device number? As the zselect.prg is probably loaded from the same device as the programs in the menu will be, the device number X of the command LOAD"zselect .prg",X,1 could still be somewhere in the memory when the program starts. Any ideas?
2. Is anyone willing to make a program/script for PC that reads the SC/MMC card directory (in the same order as 1541-III), scans all found d64's for files and creates a list of found programs (in source format, see blast.a) that can be used in zselect? This kind of program could be very useful :)
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby nojoopa » Sun Oct 29, 2006 5:59 pm

Answers to my own questions from the previous post:

1. tlr kindly informed me that the last used device can be found in $ba. I'll use it in the next version. Thanks!
2. Here is a script for Linux that does what I asked:
Code: Select all
#!/bin/bash

# makelistd64 - v.0.2 - 29.10.2006

# This script creates a zselect compatible list of programs
# inside d64 files in your SD/MMC card.

# Requires:
#  c1541 (from Vice)
#  bash, grep, sed, cut ... (basic GNU tools)

# Path to your SD/MMC card. Make sure this is correct!
SDCARD="/mnt/usb/"

# Usage: ("chmod u+x makelistd64.sh" if needed)
#  ./makelistd64.sh > mylist.a
# For alphabetically sorted list:
#  ./makelistd64.sh | sort > mylist.a


# --- The code

# Attempt to mount SD/MMC card
if ! $(mount "$SDCARD")
then
exit
fi

# File entry number
D64NUM=0

# - Main loop
# List files in correct order
for X in $(ls -fA "$SDCARD")
do
# ignore if not d64
if [ ${X##*.} == "d64" ]
then
# extract the list of files inside the d64
for Y in $(c1541 -attach "$SDCARD""$X" -list | grep prg | sed 's/  */\t/' | sed 's/\"  */"\,/' | cut -f2 | cut -d\, -f1 | sed 's/ /ö/g')
do
# zero-pad
LEN=${#Y}
while [ $LEN -lt 18 ]
do
Y="$Y,0"
LEN=$((LEN+1))
done
# output entry
echo "!tx $Y,<$D64NUM,>$D64NUM+(3<<9)+((%001)<<13)" | sed 's/ö/ /g'
done
fi
# increase disk number
D64NUM=$((D64NUM+1))
done

# unmount SD/MMC card
umount "$SDCARD"

exit

Note: the "for Y .... sed 's/ /ö/g')" between "# extract..." and "do" is a single line! Also the "echo "!tx..." between "# output ..." and "done"

Instructions:
Copy&paste to text editor, modify SDCARD (if needed), save, chmod u+x. Read comments for further instructions.

Quick customize-my-zselect-for-my-SD-card-HOWTO:
1. copy d64/prg files to SD/MMC
2. makelistd64 > mylist.tmp
3. edit mylist.tmp, remove highscore/level/etc files
4. sort mylist.tmp > mylist.a
5. modify zselect.a to use imported list "mylist.a"
6. compile
7. copy uzselect.prg to SD/MMC (zselect.prg doesn't work ATM)
The result is (in theory) a menu with all the programs (inside the d64s) in alphabetical order, with all the program runnable by selecting them and pressing fire.

I haven't tested this myself yet...I'll do it tomorrow.

Next question: Who will make the Windows version?

----
(Edit)
Fixed one bug in the script and made the "howto" a bit better.
I quickly tested the script & uzselect v.0.2...and it seems to work!
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby nojoopa » Mon Oct 30, 2006 4:02 pm

Same URL, new version (0.3):
http://student.forssa.hamk.fi/~fonuotiha/zselect.zip

zselect changes:
+ device number autodetection
+ fast scrolling
+ can launch programs from the root directory
+ makelistd64.sh included in zip

makelistd64.sh (v.0.3) changes:
+ includes prg files on the card itself to the generated list
+ a bit faster

still to do:
+ keys 0..9, a..z jump to first program starting with the number/letter
+ keyboard navigation
+ OPEN/LOAD error handling
+ status bar with disk number, device number etc...
+ print something when starting to OPEN/LOAD
+ use MSb's of entries for disknum&configbits data...maybe
+ (your requested feature here)

for someone else to do:
+ Windows version of makelistd64.sh
+ more testing

The zselect.prg in the zip can be used for some testing, but to really use this program you'll need to customize the menu and recompile with acme:
http://www.esw-heim.tu-clausthal.de/~marco/smorbrod/acme/

I have tested this version a bit and it seems to work OK.

Feedback is appreciated.
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby nojoopa » Wed Nov 01, 2006 2:13 am

And now...something completely different :)

sdbrowse v.0.1 - the SD/MMC card browser & program launcher:
http://student.forssa.hamk.fi/~fonuotiha/sdbrowse.zip

Instructions:
Use joystick in port 2.
UP/DOWN = previous/next
FIRE = load prg OR enter d64
LEFT = go back to root directory

Known bugs:
- The "BLOCK FREE" value is visible and selectable inside d64's

To do:
+ fast scrolling
+ keyboard navigation
+ status bar, info text etc...
+ testing

I tested this with a couple of programs. It should work.
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby jpilkinton » Wed Nov 01, 2006 7:58 am

Nojoopa,
I want to thank you for doing something like this. I will definitley use this on my Lynx DTV. As soon as I get it more completed, I will have time and sit down and think of some stuff that I would like added.

Thanks again!
jpilkinton
 
Posts: 67
Joined: Tue Sep 26, 2006 4:48 pm
Location: Jacksonville, AR

Postby nojoopa » Wed Nov 01, 2006 3:27 pm

sdbrowse v.0.2 (same URL):
http://student.forssa.hamk.fi/~fonuotiha/sdbrowse.zip

Changes:
+ fast scrolling
+ info text ("loading..."), disk name shown
+ color (customisable with constants & recompiling)
+ "BLOCK FREE" and some other bugs fixed

To do:
+ keyboard navigation (if anyone wants it)
+ (your feature request)

----

I'll start working on the Windows version of "makelistd64.sh". I did some research and it seems that some crazy hacks have to be used to get an integer variable to a ".bat" file; instead of "%d64num=%d64num+1", something like "helperapp %d64num: %d64num = errorlevel" (where helperapp just does a "return ++itoa(argc[1]); ") must be used. Please tell me I'm wrong and there's a simple way that I'm missing:)

----

Jpilkington,
it's always nice to know that someone actually uses (or at least plans to use) my programs. Feature requests (and test reports) are welcome.
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Postby jsaily » Sat Nov 04, 2006 3:12 pm

Nojoopa, the sdbrowser seems to work otherwise but it only displays the labels of about 23 titles. When scrolling beyond that the screen remains blank! If you scroll backwards then, the titles appear correctly from the top!

A feature request would be a small list (maybe 5) of quick start titles. The list could be updated from the sdbrowser using keyboard. Pressing 1-5 on the keyb would start the quickstart progs.
jsaily
 
Posts: 110
Joined: Wed Sep 27, 2006 2:33 pm
Location: Finland

Postby nojoopa » Mon Nov 06, 2006 9:51 am

jsaily wrote:Nojoopa, the sdbrowser seems to work otherwise but it only displays the labels of about 23 titles. When scrolling beyond that the screen remains blank! If you scroll backwards then, the titles appear correctly from the top!

Thanks for the bugreport. In response...

sdbrowse v.0.3:
http://student.forssa.hamk.fi/~fonuotiha/sdbrowse.zip

Changes:
+ >23-bug inside d64 fixed
+ remembers position on root directory

A feature request would be a small list (maybe 5) of quick start titles. The list could be updated from the sdbrowser using keyboard. Pressing 1-5 on the keyb would start the quickstart progs.

I'll have to think about this one. I'll try storing the list to "sdbrowse.prg" itself unless there are any objections. For a temporary solution, configure the "quick start titles" into zselect and start it from sdbrowse.

About the updating with keyboard...I think an easier and more user friendly approach would be to allow the quick start titles to be updated by similar means as starting a program, as in:
1. Use joystick to browse to prg or program inside d64
2. Press some_key to add selected prg/program to quick start list
3. Use joystick to select which quick start slot to use/overwrite
...and Press another_key to save list to SD/MMC. Would this be OK?
nojoopa
 
Posts: 60
Joined: Mon Oct 09, 2006 7:16 pm

Next

Return to 1541-III-DTV Software

Who is online

Users browsing this forum: No registered users and 0 guests

cron