Here are a few comments about the code I modified for the MC-10 (on Github) of Jake Commander's "SPACE TREK" originally published in Color Computer Magazine (May 1983). Each comment refers to the code snippet just above it. My MC-10 version has removed all ELSE commands and changed all PLAY commands to simpler SOUND commands. Also, all string assignments using the special poke routine at the beginning of the program and all uses of the STRING$ command have been replaced by literal strings, since graphic characters can be input directly from the MC-10's keyboard. All PRINT USING commands have been replaced by combinations of INT, STR$ and MID$, RIGHT$ or LEFT$ commands to format numeric output.
2 IFMID$(M$,C2,1)<>""ANDMID$(M$,C2,1)<>" "THENC2=C2-1:GOTO2
The above is my 32 character word-wrap routine. I use it for all printed messages instead of inserting spaces in them. It's also more flexible when it comes to messages that change length, such as when you have STR$(numvar) numeric data being concatenated with a string.
If others want to port this code they will need adjust the speed of the game because of differences in their machines from the original Coco version. Change the 150 value above to something higher if your machine is slower or something lower if your machine is faster. This is the countdown for the "pings" of the view screen, as in the original Star Trek show.
The ON/GOTO in line 580 is in the middle of a FOR/NEXT loop. As far as I can tell, the jumps to 595 and 594 originally simply jumped out of the FOR/NEXT loop never to return. I just hate not closing NEXT loops on principle, and they can occasionally cause problems if they occur too often, so I added a temp (TM) variable and lines 595 and 594 to gracefully exit the loop before proceeding on to the original GOTO lines. I use the TM variable to re-assign the value of the NEXT loop to the variable after completing it properly, just in case the program relies on knowledge of what the value of the loop was.
There was a rare problem where a photon torpedo hit would seem to register twice (two explosions in a row). I think this may have been a result of not gracefully exiting the for next loop as soon as the "hit" Klingon is found (why keep searching for hits on the other Klingons?). So I added I=3 after the torpedo is found to have hit one of the 3 Klingons that can be in any Quadrant.
950 GOSUB1580:PRINT@320,;:M$="WELL DONE! STARBASE DESTROYED!":GOSUB1:B=B-1:BT=BT-1:M2=4:X=C:Y=D:GOSUB1550
951 PRINT@352,;:M$="THE EXPLOSION HAS THROWN YOU OFF COURSE":GOSUB1:GOSUB1350:PRINT@320,;:C=RND(...
I changed the word "DAMAGE" to "EXPLOSION." It seemed to make more sense. Also, I added a pause (GOSUB1350) and a PRINT@ statement after the message, since occasionally more messages might follow that fill the screen beyond the 16 line limit of the MC-10.
1090 PRINT@320,"LAST BATTLE-CRUISER DESTROYED!":GOSUB1700:PRINT"THE ";U$;" IS SAVED!!":GOSUB1700:SOUND75,5:SOUND80,5
1091 PRINT"YOUR EFFICIENCY RATING ="INT(K7/(T-T0)*1000):END
I added a call to line 1700 for a little noise/music when you win. It seemed anti-climatic otherwise. Line 1700 in the original listing seemed to be an orphan anyway, so I tweaked it for a more congratulatory sound.
1110 A=0:GOSUB380:PRINT@217,"OPT? ";
1150 O=0:AF=0:FORA=40TO266STEP32:PRINT@A,Y$;:NEXT:PRINT@41,"STATUS REPORT:";:PRINT@106,"KLINGONS ="KT;
1170 AF=0:PRINT@384,"ENTER START AND END CO-ORDINATES":PRINT@320,;:INPUT"(X,Y,X,Y)";CC,A,W,X
When in the computer OPT mode, if you select TORPEDO DATA and then select any other options besides GUIDED TORPEDO, you garble the variables used to store your TORPEDO DATA. So I added the AF (auto fire) variable switch to all the Computer options to turn off the GUIDED TORPEDO fire option if you don't select it right after selecting the TORPEDO DATA option. Now GUIDED TORPEDO will only work if you select it after selecting the TORPEDO DATA opt.
This line is the one added to the TORPEDO subroutine to prevent firing (and possible infinite loop) unless the AF variable is set to 1.
The above poke just switches the screen of the MC-10 to orange from regular green to give a flickering screen effect when you are hit.
This is the stardate countdown. It used to read T=T+1, but since the Coco is slower than an MC-10, I had to have it count more slowly (by .5s) or the game expected you to play at too high a speed to be fair.
1561 GOSUB1550:GOSUB1420:PRINT@R,"KLINGON AT"STR$(INT(X))","RIGHT$(STR$(INT(Y)),2)" DESTROYED";
I added the check in 1560 above to prevent the problem mentioned above of double explosions from torpedo hits on some Klingons. If the hit registered twice the K variable could go to a negative number which really messed up the modification of the 3 digit number (i.e. 100s, 10s, 1s) calculated in 1550 used to store each Quadrant's info G(Klingons, Starbases, Stars).
The peeks in this routine above 17024 and 17025 are simply the way for the MC-10 to determine the screen location of the current cursor location (0-511). It is used to print blanks of a particular length from that location to the second last position of the screen (i.e. to clear the message area but not print in the bottom right corner so as to cause a linefeed moving the entire screen up).
This line was an orphan in my listing of the program. So I modified it and use it in the win routine to provide a little sound.
And there are always tweaks and modifications that cry out for implementation...
For example, I changed the GUIDED TORPEDO routine to misfire on a 1 in 10 chance, just to moderate this lazy option. There has to be some disadvantages for relying on computers for everything!