Text file viewer

Basic and Machine Language

Moderator: Moderators

Post Reply
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Text file viewer

Post by Bobbi »

I am wondering if there an existing text file viewer which works with SD2IEC drives?

The SD card I use with my VIC has a mirror of the zimmers.net site on it, including text files. It would be nice to be able to read the text files on the VIC ...

I started out with a simple BASIC prototype that can open a SEQ file and print it to the screen - either directly (for PETSCII files) or with uppercase and lowercase swapped (for ASCII files from the net.) It works nicely but is as slow as you would imagine. Actually it would work nicely as a Tel-e-Prompt machine - it prints at about human reading speed!

So I did a quickie assembly language version calling the KERNAL routines SETNAM, SETLFS, OPEN, CHKIN, CHRIN, READST, CLOSE etc. It is, of course, much faster, especially if I pre-load SJLOAD! It is also nice in that it doesn't care about file length - I can display files of any length I believe (have tried a 170KB ASCII file anyhow.)

A couple of questions sprint to mind. Is there any way to seek into an existing text file to allow jumping around in the file, or do I have to read it sequentially? I guess if we can seek then we can no longer handle super-long files!

Also, any easy way to integrate with SJLOAD so I don't have to manually pre-load it, reset and then SYS45056 ... ?
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Text file viewer

Post by Mike »

Bobbi wrote:I am wondering if there an existing text file viewer which works with SD2IEC drives?
Sure there is. MG Browse. I didn't point you to this in my PM without reason.
A couple of questions sprint to mind. Is there any way to seek [...]
No. At least not for SEQ files (or PRG or USR files, either, for that matter) in a way cross-compatible between real CBM DOS drives and SD2IEC devices. Those files can only be read from the beginning. The only other non-trivial seek procedure is available when writing with ",A" (Append), which seeks to the end of the current file. That's what I meant in my other post when I wrote about over-sized files being "a chapter in itself".

For this reason, MG Browse reads in the whole file - while formatting it - into RAM. Gives the random access, but of course you're restricted by RAM size. An older version could also read unlimited sized files, but only sequential.

Looks like you're now asking the relevant questions. :)

REL files allow for random access, record based. However they'd need to be "constructed" from the original SEQ file for input. The column width of 40 characters as with MG Browse leads to a natural record size of 40.

Now guess what? That implementation of MG Browse is sitting in my drawer for nearly 5 years now. I wrote it as part of a collaboration with Kananga when he wrote the FE3 RAM disk. There, the REL file support allows to put a text file of more than 400 KB for random access into the banked expansion RAM. It also works (for users without FE3) on real drive hardware, Kananga tested it out with a 1541. During the formatting procedure, there happen a lot of head movements. :lol: But when the text has been put into the REL file, viewing and scrolling is not much slower than from RAM - just 40 bytes file I/O (not including the P-command) for each scrolled line. MG Browse scrolls with ~10 lines/second which translates to 400 bytes/second and that is pretty much the same speed as the standard IEC protocol delivers anyway. If you hook up a 1581 as second drive for the REL file storage, it could store ~800 KB of formatted text.

Too bad the sd2iec firmware (still) doesn't support write access to REL files in disc images. And REL file access in the host file system uses an incompatible variant of the "P" DOS command. :(


Before you ask: I've long ago decided to keep that REL version of MG Browse in the drawer, and that won't change anytime soon.
Last edited by Mike on Tue Nov 08, 2016 3:00 am, edited 3 times in total.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Text file viewer

Post by Mike »

Bobbi wrote:Also, any easy way to integrate with SJLOAD so I don't have to manually pre-load it, reset and then SYS45056 ... ?
You could always prepend a smallish boot loader, which first loads in and then starts SJLOAD (preferably upon prompting the user) and then the client program.

I did so in my Mah Jongg game. Here's the file "SPLASH" inside the *.d64 image:

Code: Select all

1 DN=PEEK(186):PRINT"{DOWN}USE SJLOAD? Y/N"
2 GETA$:IFA$="N"THEN5
3 IFA$<>"Y"THEN2
4 SYS57809"SJ-B000",DN,1:POKE780,0:SYS65493:SYS45056
5 @LOAD"TITLE",DN:T1=TI
6 GETA$:IFA$=""ANDTI-T1<600THEN6
7 @RETURN:POKE36879,25:PRINT"{WHT}LOAD"CHR$(34)"MAIN"CHR$(34)","MID$(STR$(DN),2)
8 POKE631,19:POKE632,131:POKE198,2
... with line 4 doing what you asked for.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: Text file viewer

Post by Bobbi »

Thanks for your response Mike! The situation is more or less as I thought from my reading of the 1541 manual.

I will check out MG Browse.

For my own code, I guess I will stick with sequential reading from the beginning, and buffer as much as I can in memory.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: Text file viewer

Post by Boray »

Check out my "vic disk menu":
http://www.boray.se/commodore/vicmenu.html
It uses basic to detect if SJLOAD is present in memory (at three different locations/blocks) and if it's found, it's started.

I once (11 years ago it seems) also made a special version of the "vic disk menu" together with a simple html viewer:
http://www.boray.se/commodore/htmlwalker.html

If a html file is selected in the menu, the html reader is loaded and the filename is passed to it (with help of the keyboard buffer).
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: Text file viewer

Post by Bobbi »

Thanks Boray, will check it out!
Post Reply