[Coco] Special coding in WAR

Allen Huffman alsplace at pobox.com
Sat Jul 2 13:12:42 EDT 2022


> On Jul 2, 2022, at 8:56 AM, Robert Gault via Coco <coco at maltedmedia.com> wrote:
> 
> An author of games for Tandy, James Garon, put some lines in the Basic game WAR which is on colorcomputerarchive.com <http://colorcomputerarchive.com/> . The code is in lines 60000 and up which can't be LISTed with a CoCo3 but can be read with a CoCo2. 
> The lines in question contain PRINT commands which when listed with a CoCo2, look like the data inside the quotes have been converted into Basic commands. You can also see this if you use imgtool or wimgtool to extract the program from the .dsk image. 
> These lines generate PMODE graphics for the title screen. Do anyone have a clue as to how these Basic lines work?


Looking at this, the PRINT statement appears to just have the CHR$ values POKEd in to it.

I deleted all the lines before and after that 60000 PRINT line, and then made a program that displayed the bytes from start of basic to end of BASIC. To make it easier to find, I added a REM line that had a bunch of **** characters, that would show up as 42s to let me know where the line I was after was:

0 S=PEEK(25)*256+PEEK(26)
1 E=PEEK(27)*256+PEEK(28)
2 PRINT S,E
3 FOR A=S TO E:PRINT #-2,USING("### ");PEEK(A);:NEXT
4 END
6 '*****
60000 CLS:A$=STRING$(28,32):PRINT” …. stuff …."

The data shows this — trimming off the stuff before the 42s which I know isn’t the line in question:

42  42  42  42  42   0  38 172 234  96 158  58  65  36 179 255 161  40  50  56  44  51  50  41  58 135  34 143 143 159 159 175 175 191 191 207 207 223 223 239 239 255 255 143 143 159 159 175 175 191 191 207 207 223 223 239 239 255 255  34  59   0   0   0  83 

A quote is a 34 — CHR$(34) — so there is data for the line number, the token for CLS, etc. then a PRINT token and a quote, so the data starts after the 34 and to the next 34 (between quotes):

34 143 143 159 159 175 175 191 191 207 207 223 223 239 239 255 255 143 143 159 159 175 175 191 191 207 207 223 223 239 239 255 255  34

I can turn those in to DATA statements and READ/PRINT them:

0 REM WAR PRINT
10 READ A:IF A=-1 THEN END
20 PRINT CHR$(A);:GOTO 10
60000 DATA 143,143,159,159,175,175,191,191,207,207,223,223,239,239,255,255,143,143,159,159,175,175,191,191,207,207,223,223,239,239,255,255

That displays the set of CHR$ color blocks that is used on the title screen.

The actual code has those values which LIST does not honor, but here it is, with tokens being displayed instead of graphics characters:

60000 CLS:A$=STRING$(28,32):PRINT"RESTORERESTOREMOTORMOTOR^^SCREENSCREENDRIVEDRIVEDSKI$DSKI$!!!RESTORERESTOREMOTORMOTOR^^SCREENSCREENDRIVEDRIVEDSKI$DSKI$!!!";

A$ = 28 space characters, used later.

the PRINT prints a row of colored blocks along the top of the screen.

60005 FORI=1TO8:GOSUB60028:NEXT:FORI=1TO6:GOSUB60028:NEXT

This is weird. Why not just do 1 TO 14? Looks like 60028 is using I for positioning.

60010                             PRINT"MOTORMOTORRESTORERESTORE!!!DSKI$DSKI$DRIVEDRIVESCREENSCREEN^^MOTORMOTORRESTORERESTORE!!!DSKI$DSKI$DRIVEDRIVESCREENSCREEN^";

That line prints another full line, so we have drawn a box of colored blocks for the title “attract” screen.

Next, a POKE to 1535 puts the final character in the bottom right, since we cannot PRINT to that else the screen scrolls up a line.

60020 POKE1535,175:T$="WAR!":PRINT at 99,"A YOUNG PERSON'S CARD GAME";:PRINT at 80-LEN(T$)/2,T$;:PRINT at 175,"BY";:PRINT at 202,"JAMES  GARON";:PRINT at 263,"COPYRIGHT (C) 1982";:PRINT at 298,"DATASOFT INC.";:PRINT at 389,"LICENSED TO TANDY CORP.";:SCREEN0,1

There’s that SCREEN 0,1 to make it the orange/red/pink alternate color —
https://www.vintageisthenewold.com/the-cocos-lesser-known-screen-color

60025 GOSUB60030:I$=INKEY$:FORI=1TO300:FORJ=1TO30:NEXT:IFINKEY$=""THENEXECV:NEXT:RETURNELSERETURN

Above, the EXECV must be the routine that cycles the colors. Strangely, I just wrote some blog posts about doing something like this to speed up an attract mode in BASIC. It’s exactly what this is doing.  Notice the GOSUB 60030, which is another string, but instead of CHR$ blocks it has assembly code embedded in to it!

60028 PRINTSTRING$(2,127+16*(9-I))TAB(30)STRING$(2,127+16*I);:RETURN

This A$ has embedded 6809 assembly:

60030 A$="RUN!SUBELSE,NEXTENDFORTHENFORDIM/!9"

Then V gets the start of that string in program space, and returns it in V.

60060 V=VARPTR(A$):V=PEEK(V+2)*256+PEEK(V+3):RETURN

60062 END

60066 CLS 2:PRINT at 200,"SAVING war":CSAVE "WAR":MOTORON:FORT=1TO3000:NEXTT:MOTOROFF:CLS:PRINT at 200,"SAVE COMPLETE"


Interesting. Let me get the code from that line… Next post...

--
Allen Huffman - PO Box 7634 - Urbandale IA 50323 - 515-999-0227 (vmail/TXT only)
http://www.subethasoftware.com - https://www.facebook.com/subethasoftware




More information about the Coco mailing list