Jump to content
IGNORED

BASIC game books: how to make them work on the TI-99/4A


xabin

Recommended Posts

I found an archive of game-related books in digital format, and quite a few of them are BASIC game books, one of which I remember from my childhood, called Cats of Castle Mountain. I want to try them out, but they don't have the TI listed as a compatible computer. Is there a way to get these game books working in the computer's version of BASIC?

Link to comment
Share on other sites

That was the description of my first 4 years with the machine... ;)

 

If all you have is TI BASIC, you'll be somewhat limited. But the overly vague steps would be:

 

- break multi statement lines up into separate lines. TI BASIC doesn't support multiple statements per line. (XB does). Most programs step line numbers by 10s, so you can put the additional statements on 1s. For instance:

 

10 PRINT "HELLO":GOTO 10

 

can become two lines:

 

10 PRINT "HELLO"

11 GOTO 10

 

It's very rare that you will need more than 10 statements... if you do, then be careful with changing line numbers of existing stuff - you have to make sure nothing else uses that original number. ;)

 

- TI BASIC doesn't have the LEFT$/MID$/RIGHT$ string handling statements. All it has is SEG$, which is the same as MID$. So, you need to replace:

 

MID$(A$,X,Y) -> SEG$(A$,X,Y) -- (direct substitution)

LEFT$(A$,X) -> SEG$(A$,1,X) -- (almost direct)

RIGHT$(A$,X) -> SEG$(A$,LEN(A$)-X+1,X) -- (bit of math needed)

 

- RND is done differently - most basics use RND(0) or RND(1) to generate a random number. Sometimes one or the other is to initialize the seed. The TI only uses "RND". Any program with RND in it, you should insert a "RANDOMIZE" as the first statement of the program (for instance, line 1), otherwise it will always generate the same results. There are a few BASICs that generate a random number from 0 to (X-1) with "RND(X)". You have to know if you are porting from one of these (they are less common). In that case the replacement is "INT(RND*X)"

 

- DEF is used rarely, but is different. A few other basics use "DEF FN NAME(X) = X*10" -- where 'NAME' is the name of the function, and the formula to the right of the equals sign is how to use it. TI BASIC doesn't use the 'FN' part, so just "DEF NAME(X) = X*10"

 

- IF..THEN..ELSE is the absolute worst. TI BASIC only supports line numbers for the cases, while most other BASICs support statements and even multiple statements. You need to break it up and you'll need to plan your line number usage a bit, as well as insert GOTOs to skip over any ELSE case. Fortunately, most cases still fit in the gaps between the lines. For instance:

 

100 IF A=1 THEN A=A+1  -- an easy case

110 ... next line

 

becomes

 

100 IF A<>1 THEN 110 -- invert the test - be careful as this can get tricky with more complex tests

101 A=A+1

110 ... next line

 

alternately, if you are not confident with changing the test, you can do it this way:

 

100 IF A=1 THEN 102

101 GOTO 110

102 A=A+1

110 ... next line

 

For a trickier one:

 

100 IF A$="YES" THEN PRINT "ACCEPTED":GOSUB 1000 ELSE PRINT "REJECTED"

110 ... next line

 

you can try...

 

100 IF A$="YES" THEN 103

101 PRINT "REJECTED"        -- the test skips over this part, so the ELSE comes first

102 GOTO 110                    -- don't forget to leave room for the GOTO!

103 PRINT "ACCEPTED"       -- now the first case
104 GOSUB 1000

110 ... next line

 

Watch out for this tricky one that people sometimes sneak in:

 

100 IF A=1 THEN GOTO 500  -- the GOTO keyword here is optional in all BASICs but illegal in TI BASIC

 

just drop the optional GOTO... but make sure it's not a GOSUB! That means something different!

 

100 IF A=1 THEN 500

- IF..THEN isn't done yet! Most BASICs also allow "AND" and "OR" in the comparisons. TI BASIC, of course, does not. But they can be simulated by combining boolean logic with math. A TRUE comparison results in -1, and a FALSE comparison results in 0. "AND" maps well enough to multiplication (any value times 0 results in 0, and 0 is FALSE). "OR" maps well enough to addition (since we always add -1 or 0, any non-zero value will result in a non-zero value). Use parentheses to control order of operations as well as keep it a little more readable. So:

 

IF A=1 OR B=2 THEN 500

 

becomes...

 

IF (A=1)+(B=2) THEN 500

 

and...

 

IF A=1 AND B=2 THEN 500

 

becomes...

 

IF (A=1)*(B=2) THEN 500

 

Complex:

 

IF (A=1 AND B=2) OR C=3 THEN 500

 

becomes...

 

IF ((A=1)*(B=2))+(C=3) THEN 500

 

As an aside to this, very few programs sometimes used this sort of boolean logic in their calculations. If you see lines that contain comparisons in the middle of math in the original code, be aware that some BASICs make equality 1 instead of -1. You may need to debug those statements if they don't work correctly.

 

And finally.. NOT is also used in some statements to invert the result of a test (FALSE becomes TRUE, TRUE becomes FALSE). TI BASIC doesn't support NOT either - you have to invert those comparisons yourself.

 

IF NOT (A=1) THEN 500

 

becomes

 

IF A<>1 THEN 500

 

... that's all I remember off the top of my head. I ported most of the Ahl 'BASIC COMPUTER GAMES' books to TI BASIC back in the day, cause it was all I had. :)

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Oh, I should probably also add that if the program has sound or graphics, then porting it is a much larger exercise. Every computer did those differently, and you'll need to understand both systems to do it.

 

I should also mention that if you have Extended BASIC, nearly all of the above restrictions go away. Multiple statements are separated with two colons instead of one (::), and the string function is still only SEG$, but XB adds the multiple statements, AND/OR/NOT, and IF..THEN..ELSE statements :)

 

Edited by Tursi
  • Like 1
Link to comment
Share on other sites

10 hours ago, xabin said:

I found an archive of game-related books in digital format, and quite a few of them are BASIC game books, one of which I remember from my childhood, called Cats of Castle Mountain. I want to try them out, but they don't have the TI listed as a compatible computer. Is there a way to get these game books working in the computer's version of BASIC?

I have one related book from Micro Adventure, when they had multiple BASIC versions inside, including TI-99/4A: Jungle Quest.

The programs are used to represent puzzles you face in the adventure book (which was a branching 2nd person storyline).

 

If the book already has multiple BASIC versions inside, they might try to take advantage of custom features like graphics and sound.

 

 

Best thing to do is take Tursi's translation tips, and jump in.

 

Link to comment
Share on other sites

Hmm. Well, this is the book I was talking about: https://ia600707.us.archive.org/31/items/RetroGamingBooksFiction/AMagicMicroAdventure-TheCatsOfCastleMountain.pdf

 

It doesn't have the TI listed, so I guess it's not compatible? I noticed that the books made after 1984 dropped the TI from their compatibility list, so maybe that's why?

Edited by xabin
Link to comment
Share on other sites

5 minutes ago, xabin said:

Hmm. Well, this is the book I was talking about: https://ia600707.us.archive.org/31/items/RetroGamingBooksFiction/AMagicMicroAdventure-TheCatsOfCastleMountain.pdf

 

It doesn't have the TI listed, so I guess it's not compatible?

looking at the  book, I'd say it is compatible*, but one needs to know what they are programming inorder to make a suitable fix


*extended basic compatible

Link to comment
Share on other sites

These programs all look like generic Microsoft BASIC programs.  Aside from breaking up the multiple statement lines. it should not be too hard to translate to TI BASIC.  It looks like towards the back of the book are line changes specific to each dialect of BASIC.  These look like they print things on the screen in specific places.  These will be a bit harder to translate (Extended BASIC would make it much easier).

 

When you see a statement like HTAB X:VTAB Y:PRINT - that's just positioning the cursor to a given place and printing text.  Extended BASIC equivalent would be DISPLAY AT(X,Y):"SOME STRING"

 

For TI BASIC, it takes a bit more work:

1000 R=X

1010 C=Y

1020 S$="SOME STRING"

1030 FOR I=1 TO LEN(S$)

1040 CALL HCHAR(R,C+I-1,ASC(SEG$(S$,I,1)))

1050 NEXT I

 

This will plot the character string in the proper place on the screen.  It's easier to make this a subroutine that you set the R,C and S$ values and then GOSUB.  

 

For Apple - if you see PRINT CHR$(7) - that's a Ctrl-G character which beeps the speaker for 1/10th of second.  The exact same effect can be made in TI BASIC with CALL SOUND(100,1000,0).  Extended BASIC has a BEEP option on the DISPLAY statement that does pretty much the same thing.

 

Nothing else looked too complicated in here, but please ask if you get stuck and we can all offer pointers.  I did not see any graphics statements in the programs - just text and character plotting.

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

There is also a book out there that gives a command by command guide of statements across verious dialects of BASIC. TI BASIC was one of the ones included--but I didn't find it in the Hexbus archive. I have a copy of it somewhere. I'll try and get the title and see if there is an online version of it.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...