MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts)

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
majikeyric
Vic 20 Afficionado
Posts: 349
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts)

Post by majikeyric »

Current version : 0.9.5 Beta

MKLOADER is a Win32 command line tool which allows to automatically generate LOADER script files to use with the Final Expansion 3 on the VIC20.

It generates LOADER files accordingly to the content of your SD Card.

It uses PETCAT and C1541 from the VICE distribution and Exomizer by Magnus Lind. They are included in the archive.

Simply copy all 4 files into your "Path" and launch MKLOADER into the root of your SD Card.

MKLOADER first creates a "loader.bas" text file and then tokenizes it into a "LOADER" VIC20 program file.

MKLOADER checks if a file has a valid BASIC header and then creates an entry in loader.bas with the needed configuration and +RUN command.

If the file has no BASIC header but if the file has a one of these load adresses : $4000, $5000, $6000, $7000, $b0000. An entry is added with a +SYS command.

If the address is $a000, a +BLKP 0,1,2,3,5 and a +RESET commands are added instead to deal with cartridge images.

if a disk image (d64,d71,d81) is encountered, either the first valid file in the directory is added to the LOADER or all the valid files of the disk image are added (accordingly to the "/A" option).

Accordingly to the "/T" option: if a text file (.TXT/.NFO/.DIZ/.SEQ) is encountered, a VIC20 executable is generated including a viewer and the
formatted text so you can read it directly on VIC20 from the FE3 disk loader. Exomizer is used to compress the executable.

Directories starting with a "_" character are not processed, it can help protect a "branch" from files generation temporarily.

if you want to modify the loader on PC before tokenizing it to a VIC20 basic prg :

- set /K option to keep "loader.bas" files instead of deleting them and launch MKLOADER
- edit loader.bas with your fave text editor and apply your modifications
- invoke petcat to tokenize loader.bas to a LOADER file :

Code: Select all

petcat -w2 -l 1201 -o LOADER -- loader.bas

Code: Select all

MKLOADER options:
-----------------
Usage:   MKLOADER [/S] [/O] [/I=nn] [/K] [/T] [/A] [/TAB=nn] [/?]

/S       Process all directory structure recursively (use with caution)
/O       Force overwrite of existing "LOADER" files
/I=nn    loader line numbering increment (default=10)
/K       Keep "loader.bas" files (they are deleted by default)
/T       Create executable viewers with text of files (.TXT/.NFO/.DIZ/.SEQ)
/A       List all valid disk image entries (in D64,D71,D81 files) instead
         of just the first one
/TAB=nn  Tab lenght for executable text viewers (default=4)
/?       Display this help
The generated LOADER files will not be perfect (if some programs have special configuration) but it will help a lot I hope :)
Last edited by majikeyric on Wed Apr 22, 2020 11:32 pm, edited 7 times in total.
User avatar
majikeyric
Vic 20 Afficionado
Posts: 349
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by majikeyric »

package updated.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by Mike »

One thing beforehand: this thread here should go into the 'Emulation & Crossdevelopment' section, because it involves at least one program *not* running on the VIC-20 itself. Furthermore, that section also is intended to discuss issues about data transfer between the VIC-20 and PC storage (including VICE).

That being said, I tried out both the 'alpha' and the current 0.9.0 beta without much success.

I use the following directory structure:

Code: Select all

\work
  |
  +-- \bin
  |
  +-- \files
  |
  +-- setenv.cmd
where 'files' is supposed to contain the SD card contents and 'bin' is supposed to contain the MKLOADER binaries. These are supposed to be added to the path by executing 'setenv.cmd' from within a command shell with 'work' as current working directory. 'setenv.cmd' contains just a single line:

Code: Select all

PATH %PATH%;%CD%\bin
I then go into the 'files' directory and execute mkloader from there. These were the results:

With the alpha version, I just had an example text file within 'files' - my main aim was to check how you did the one-filing process. The one-filed program was indeed generated, however a 'loader.bas' was not written and mkloader exited with the following error message:

Code: Select all

mkloader [...]
Error : unable to launch PETCAT executable
Anyway, I could test out the result program converted from the text file, which has several issues: Behind the BASIC stub, you save away nearly 4K of an empty bitmap up to $20xx, where the executable of MINIGRAFIK is located (read: buried within the file). Then follows a partial copy of the main program, and then the text display library. The text file is attached behind that, but it isn't formatted in any sensible way: it isn't sufficient to just do a round up to the next multiple of 40 chars (and pad with spaces) when a line feed is encountered. The file load routine of the text display library also performs word wrap, expands TABs and filters away non-displayable characters.

In the 0.9.0 beta, and with the now required '/T' option, additionally a stub 'loader.bas' file was created, however the text executable still has the same issues, and mkloader also still exits with '... unable to launch PETCAT executable'.

I'm running this on Win Vista.
User avatar
majikeyric
Vic 20 Afficionado
Posts: 349
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by majikeyric »

Mike wrote:I use the following directory structure:

Code: Select all

\work
  |
  +-- \bin
  |
  +-- \files
  |
  +-- setenv.cmd
where 'files' is supposed to contain the SD card contents and 'bin' is supposed to contain the MKLOADER binaries. These are supposed to be added to the path by executing 'setenv.cmd' from within a command shell with 'work' as current working directory. 'setenv.cmd' contains just a single line:

Code: Select all

PATH %PATH%;%CD%\bin
I then go into the 'files' directory and execute mkloader from there. These were the results:

With the alpha version, I just had an example text file within 'files' - my main aim was to check how you did the one-filing process. The one-filed program was indeed generated, however a 'loader.bas' was not written and mkloader exited with the following error message:

Code: Select all

mkloader [...]
Error : unable to launch PETCAT executable
I tried your test case and It does work for me (Win7)

Anyone else can confirm ?
Mike wrote:but it isn't formatted in any sensible way: it isn't sufficient to just do a round up to the next multiple of 40 chars (and pad with spaces) when a line feed is encountered. The file load routine of the text display library also performs word wrap, expands TABs
The thing I'm actually missing is word wrapping

What do you mean by "expand TAB" ?
Mike wrote:and filters away non-displayable characters.
Actually, I only keep characters >=chr(32) And <=chr(126)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by Mike »

majikeyric wrote:The thing I'm actually missing is word wrapping
That's quite a big omission. It was one of the main intentions of MG Browse not just to 'throw' text on the screen, but also present it in an acceptable manner. Leaving that feature out, but telling people you used my library, makes MG Browse look bad even if the error really was on your side.
What do you mean by "expand TAB"?
When the displayed columns are counted from 0 to 39, code 9 (TAB) moves the cursor to the next column that is a multiple of 8, unless it is positioned at the imaginary 40th column - then it just acts as line break and starts the next line at column 0.
Actually, I only keep characters >=chr(32) And <=chr(126)
At least the first version of your one-filing process didn't do that and printed blotchy characters, when characters outside that range were present in the text file. I didn't bother to test that for the 0.9.0 beta, though.

In the source of the MG Browse text library, the two routines 'TFormat' and 'TWordWrap' contain the entire machinery that reads in the text file, and performs the formatting as I described above. Everything is controlled by the two values 'text_col' and 'last_space' and it shouldn't be too difficult to reimplement the algorithm in another language of your choice.

...

If you get that right, you also should reconsider whether it is a good thing to incorporate the entire code of MINIGRAFIK into the executables. MG contains a lot of code, which just isn't used for that specific application - but which of course is still appropriate, when the text display is part of a bigger program. I already pointed you to the minimal code to set up the graphics screen, and then a translation of the original BASIC main program to machine language and a memory move routine (to avoid the 4K 'hole' at the beginning) would be the way to minimize waste of memory - if you insist on one-filing.

Another approach could be just providing the boot loader, MINIGRAFIK, the library code, and a BASIC main program extended with a file browser fabricated for all text files found in that directory. Then, you'd only have one copy of the relevant code for each directory.
User avatar
majikeyric
Vic 20 Afficionado
Posts: 349
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by majikeyric »

MG browse removed.
User avatar
majikeyric
Vic 20 Afficionado
Posts: 349
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by majikeyric »

0.9.2 update:
----------------
- The search for external tools has been modified. Copy all the files of the archive in the same directory as MKLOADER.

- I have written my viewer prg, it was easier for me than adapt mg browse to my needs (Thanks to Mike for his help and for his charset I reused).

- Exomizer has been added to the archive, the VIC executable including viewer+text are now compressed.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by Mike »

majikeyric wrote:- I have written my viewer prg, it was easier for me than adapt mg browse to my needs (Thanks to Mike for his help and for his charset I reused).
Well, you reused not only the font I suppose. The scrolling and the text line plotter routines also make a re-appearance - even if the latter now sports some tables for slightly faster glyph data access, and self-modifying code. ;)

I see you outsourced the text formatting process into the mkloader executable. There's still some work left: when a word ends exactly at the end of a line, with the following space in the imaginary 41st column, the following line starts with that space instead of dropping that blank and aligning the first letter of the next word into the first column.

Furthermore, on NTSC the VIC registers aren't correctly programmed. The display window is shifted to the bottom/right corner. I didn't point you to the @ON code of MINIGRAFIK without reason: it takes the default VIC register values from the KERNAL ROM at $EDE4 (which *are* different between PAL and NTSC VICs) and applies offsets to set up and correctly (re-)center the graphics screen.

And yes, the other Denial fellows are a lousy bunch of beta testers. :P

P.S. Sadly, I couldn't get even your lastest version to work. I still get the 'unable to launch' error. For the time, I strongly suspect Vista's UAC being the culprit - however I am not even prompted whether I want to run the other executables. :(
User avatar
majikeyric
Vic 20 Afficionado
Posts: 349
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

Re: MKLOADER 0.9 Beta (MaKe final expansion 3 LOADER scripts

Post by majikeyric »

Mike wrote:Furthermore, on NTSC the VIC registers aren't correctly programmed. The display window is shifted to the bottom/right corner. I didn't point you to the @ON code of MINIGRAFIK without reason: it takes the default VIC register values from the KERNAL ROM at $EDE4 (which *are* different between PAL and NTSC VICs) and applies offsets to set up and correctly (re-)center the graphics screen.
Thanks for the trick! I didn't know these useful memory locations :)
Mike wrote:And yes, the other Denial fellows are a lousy bunch of beta testers. :P
I see, I see :lol:
Mike wrote:P.S. Sadly, I couldn't get even your lastest version to work. I still get the 'unable to launch' error. For the time, I strongly suspect Vista's UAC being the culprit - however I am not even prompted whether I want to run the other executables. :(
I don't know Vista behaviour. However it should work if you copy all execs into the root of your SD card, no ?
Post Reply