Sunday, 14 April 2013

The House of Seven Gables Port

Well I've ported yet another of Greg Hassett's classic text adventure programs from TRS-80 Model 1 Basic to the MC-10.  As usual this required sifting out all the ELSE commands and replacing them with calls to subroutines to process the different branches of the IF/THEN/ELSE.

It also required shortening some lines.  I find the best way to process such long lines is to make my Wordpad Window a size that I know when I have roughly passed the 128 character limit.  Then I just make jumps to subroutines (because Hassett had programmed with very tight line numbering I couldn't simply add lines).

Another quirk of TRS-80 Model 1 Basic is the ability to drop the "THEN" command from IF statements.  Hassett did this quite a lot in this program.  I had to systematically go through and put THENs on all the IF statements.

Finally, I had to switch all the PRINT commands with messages longer than 32 characters to put their message into an M$ variable and then GOSUB my word wrap routine (lines 1-4).  If such messages contain numeric variables, these variables have to be put into a STR$() command and these have to be concatenated with the M$ string using a "+" symbols rather than the  ";" symbol normally used in PRINT commands.

I also had to convert the tape cassette save and load routines.  For the MC-10 the only way to save and load to tape is to use the CSAVE* and CLOAD* commands which can only save and load the contents of a numeric array.  So you need to expand one of the arrays (usually the largest one being saved) to accept any other single variables that are also being saved.  In this case the OB array is the bulk of the saved file data, so I simply expanded its size by 6 elements to contain the 6 extra unique variable elements.  The result is that the original load routine which looks like this:

74 CLS:INPUT"PRESS <ENTER> WHEN CASSETTE PREPARATIONS ARE MADE ";XX$
75 FORI=8TOLO:IFOB$(I)=""THEN77
76 INPUT#-1,OB(I,0)
77 NEXTI
78 INPUT#-1,CP,FF,ZZ,T,P(5,0),DF

must be converted for the MC-10 to look like this:

74 CLS:INPUT"PRESS <ENTER> WHEN CASSETTE     IS READY FOR LOADING";XX$
75 CLOAD*OB,"GABLEDAT"
76 CP=OB(41,0):FF=OB(42,0):ZZ=OB(43,0):T=OB(44,0):P(5,0)=OB(45,0):DF=OB(46,0)

For doing saves you simply reverse the process, so for example ZZ=OB(44,0) becomes OB(44,0)=ZZ, which you do for all the single variables before issuing the CSAVE*OB command.

There were also a number of places where Hassett used FOR/NEXT loops with IF statements that would break out of the loops without completing them.  I don't know if this can cause any real problems, but it strikes me as inelegant. I always take something like this:

10 FOR C=1 TO 10:IF P(C)=5 THEN F=C:GOTO100
20 NEXT
30 ...

And  change it to something like this to make sure FOR/NEXTs are always completed:

10 FOR C=1 TO 10:IF P(C)=5 THEN F=C:C=10:NEXT:GOTO100
20 NEXT
30 ...

If anyone can tell me if such finickyness on my part is pointless I would appreciate hearing from you.
Anyway, as usual all my programs can be found in the Emulator .c10 format at: https://github.com/jggames

No comments:

Post a Comment