Subject: Determine whether PRG file is BASIC

From: "Michael Zapf" <[email-masked]>
Date: Sun, 19 Dec 2010 22:41:02 -0000

Hi all,

given a PROGRAM file (memory image), how can one safely tell whether it is (TI/Extended) BASIC program - without trying to load it in BASIC, just by looking at the contents?

Are there magic bytes (i.e. which indicate the file format)? For UTIL files one can at least guess with good chance that it is a UTIL file by looking at the first six bytes and at the file length. 

Michael

---

From: Barry Peterson <[email-masked]>
Date: Sun, 19 Dec 2010 19:08:33 -0700

On Sun, Dec 19, 2010 at 3:41 PM, Michael Zapf <[email-masked]> wrote:

>
>
> Hi all,
>
> given a PROGRAM file (memory image), how can one safely tell whether it is
> (TI/Extended) BASIC program
>

I'm sure there's a way but I don't know what it is; I have a program that
reads a directory and tells what each file-type is.

---

From: ti99_forever <[email-masked]>
Date: Sun, 19 Dec 2010 19:23:12 -0800 (PST)

A while back I did work with a guy named Jonno Downes, and he wrote some software called Peekbot that allows you to browse content of disk files via the web - he was adding support for the TI.
Anyway, he worked on a method of determining file types...
The work went totally unnoticed in the TI community - but I'd suggest you look there, because this was one of the last things he struggled with - but it works...http://peekbot.jamtronix.com/

--- On Sun, 12/19/10, Michael Zapf <[email-masked]> wrote:

From: Michael Zapf <[email-masked]>
Subject: [TI994A] Determine whether PRG file is BASIC
To: [email-masked]
Date: Sunday, December 19, 2010, 5:41 PM

Hi all,

Michael

------------------------------------

Yahoo! Groups Links

---

From: "Klaus L" <[email-masked]>
Date: Mon, 20 Dec 2010 14:33:43 -0000

Peekbot is great!
My congratulations for this!
Really great tool!

But there are programs that are compatible with both, TI Basic and XB. How would the detection work here?

Is another header written whether I save a prog in Basic or in XB?

br, Klaus

--- In [email-masked], ti99_forever <ti99_forever@...> wrote:
> --- On Sun, 12/19/10, Michael Zapf <newsmail09@...> wrote:
> 
> From: Michael Zapf <newsmail09@...>

---

From: ti99_forever <[email-masked]>
Date: Mon, 20 Dec 2010 09:12:53 -0800 (PST)

No, I don't think another header is written. The header contains info about length, of course, which is why if you try to load a program from cassette that is too long it stops loading after the first second with an error instead of waiting until everything is read. Don't know about any flag bytes...
Someone recently posted this:http://www.youtube.com/watch?v=UGC083G6G68An early version of a program to detect file types called LOADMASTER

--- On Mon, 12/20/10, Klaus L <[email-masked]> wrote:

From: Klaus L <[email-masked]>
Subject: [TI994A] Re: Determine whether PRG file is BASIC
To: [email-masked]
Date: Monday, December 20, 2010, 9:33 AM

Peekbot is great!

br, Klaus

Yahoo! Groups Links

---

From: "computerclassics2000" <[email-masked]>
Date: Tue, 21 Dec 2010 14:14:43 -0000

Wonder how Tony McGovern did it in DiskReview? Don't have FunnelWeb up and running anymore, but it seems like DR listed BASIC versus XB?

BillG

--- In [email-masked], ti99_forever <ti99_forever@...> wrote:
> --- On Mon, 12/20/10, Klaus L <ticlub_austria@...> wrote:
> 
> From: Klaus L <ticlub_austria@...>
> --- In [email-masked], ti99_forever <ti99_forever@> wrote:
> >
> > --- On Sun, 12/19/10, Michael Zapf <newsmail09@> wrote:
> > 
> > From: Michael Zapf <newsmail09@>

---

From: "jacques" <[email-masked]>
Date: Tue, 21 Dec 2010 11:17:44 -0400

Bill,

I do not believe that DiskReview distinguishes between Basic and Extended 
Basic programs. It labels both as XB to differentiate them from EA programs.

Years ago I recall reading that someone was promoting the use of PI to 
distinguish the two. PI is a token and a reserved word in XB but can be used 
as a variable in Basic. I don't remember the details but it involved 
printing PI.

Regards,

Jacques

----- Original Message ----- 
From: "computerclassics2000" <[email-masked]>
To: <[email-masked]>
Sent: Tuesday, December 21, 2010 10:14 AM
Subject: [TI994A] Re: Determine whether PRG file is BASIC

> Wonder how Tony McGovern did it in DiskReview? Don't have FunnelWeb up and 
> running anymore, but it seems like DR listed BASIC versus XB?
>
> BillG
>
>> No, I don't think another header is written. The header contains info 
>> about length, of course, which is why if you try to load a program from 
>> cassette that is too long it stops loading after the first second with an 
>> error instead of waiting until everything is read. Don't know about any 
>> flag bytes...
>> Someone recently posted this:http://www.youtube.com/watch?v=UGC083G6G68An 
>> early version of a program to detect file types called LOADMASTER
>>
>> > A while back I did work with a guy named Jonno Downes, and he wrote 
>> > some software called Peekbot that allows you to browse content of disk 
>> > files via the web - he was adding support for the TI.
>> > The work went totally unnoticed in the TI community - but I'd suggest 
>> > you look there, because this was one of the last things he struggled 
>> > with - but it works...http://peekbot.jamtronix.com/
>> >
>> > given a PROGRAM file (memory image), how can one safely tell whether it 
>> > is (TI/Extended) BASIC program - without trying to load it in BASIC, 
>> > just by looking at the contents?
>> >
>> > Are there magic bytes (i.e. which indicate the file format)? For UTIL 
>> > files one can at least guess with good chance that it is a UTIL file by 
>> > looking at the first six bytes and at the file length.
>> >
>> > Michael
>> >
>> >
>> >

---

From: "Michael Zapf" <[email-masked]>
Date: Wed, 22 Dec 2010 13:04:09 -0000

Hi all,

answering myself ...

0000: EndOfLNT XOR StartOfLNT
0002: EndOfLNT
0004: StartOfLNT
0006: MAXMEM
...
last byte: 0

LNT=Line number table

So for a valid basic program (PROGRAM file format), the end of the LNT must be greater than the start of the LNT, and both must be below MAXMEM (37d7 for files=3). As all lines are null-terminated, the last byte must be 0.

This should rule out most of the UTIL files, and this may be enough for a simple check. If that does not suffice, one could analyse the LNT starting at byte 8, with pairs of lineNumber/VDPaddress, where the sequence of lineNumber should be strictly decreasing, while the sequence of VDPaddress should be strictly increasing.

Michael

---

From: "Michael Zapf" <[email-masked]>
Date: Thu, 23 Dec 2010 01:01:57 -0000

> where the sequence of lineNumber should be strictly decreasing, 
> while the sequence of VDPaddress should be strictly increasing.

which is not true in general, as I just saw. The VDP addresses need not be increasing, probably due to resequencing. However, the sequence of line numbers is decreasing which ensures that the lines are correctly ordered.

Michael