Saturday, 26 October 2019

RetroChallenge 2019/10: Akalabeth Converted to TRS-80 Coco



I've finished condensing the code of my MC-10 MCX conversion of the Akalabeth source code and have edited it so it will work on the Coco. It is running in the video above on VCC using the high speed poke, which is line 415 (the end of the program):
415 GOSUB11:NEXT:POKE65497,0:GOTO14
For the coco 2 use POKE 65495,0 instead.

The box fill routine is slower on the Coco than in MCX Basic. Looks a bit like a cinematic wipe. Curtis Boyle mentioned in a comment on Youtube that it might be possible to speed up the screen clear by poking a small assembly routine into the cassette buffer area to do "a stack blast clear or two." If anyone wants to try to hack the code, the upper screen clear routine is on line 7:
7 IFG1 THENLINE(0,0)-(255,159),PRESET,BF:RETURN
I used  my son Charlie's idea for converting the LINE statements for drawing the monsters to DATA  statements and then just using a single draw routine.  After doing this I was able to get Akalabeth to fit in the 25K left on a Coco after it is configured for a PMODE2 graphics screen. Thanks Charlie!

The problem was that LINE statements on the Coco require using the PSET command to designate the color attribute rather than a number literal like "1", which would have taken up even more space.  Since I was already maxed out, this would have been a disaster.  But using DATA statements allowed me to shrink everything down to a point that I even had almost 1000 bytes to spare.

I used a routine provided to me by Pippa (from the IF Solutions Archive) that allows me to PEEK and POKE back in the address pointer for the READ statement used with DATA. This allowed me to simply move the pointer to the beginning of the DATA that needed to be read for each monster. On the MC-10 the pointer address is stored at 173 and 174, but I was able to look up the equivalent locations in a Coco ROM Disassembly, which are 51 and 52.  Here is a little demo of Pippa's routines:
1 GOSUB8:PRINTJ:GOSUB9:GOTO1
8 OD=PEEK(173)+256*PEEK(174):READJ:RETURN
9 POKE174,INT(OD/256):POKE173,OD-256*PEEK(174):RETURN
10 DATA 1
The following table clearly shows how much memory is saved by switching to DATA statements:

Here’s a test routine that uses the DATA
Here’s the original routine
0 B=100:C=127:D=1:PMODE2,1:SCREEN1,1:
1 FORZZ=1TO10:PCLS:GOSUB9
2 IFINKEY$=""THEN2
3 NEXT:
4 GOTO4

9 READT,A,G,Q:IFT=99THENRETURN
10 LINE(C+T/D,B+A/D)-(C+G/D,B+Q/D),PSET:GOTO9

74 DATA-23,,-15,,-15,,-15,-15,-15,-15,-8,-30,-8,-30,8,-30,8,-30,15,-15,15,-15,15,,15,,23,,,-26,,-65,-2,-38,2,-38,-3,-45,3,-45,-5,-53,5,-53,-23,-56,-30,-53,-30,-53,-23,-45,-23,-45,-23,-53,-23,-53,-8,-38,-15,-45,-8,-60,-8,-60,8
75 DATA-60,8,-60,15,-45,15,-42,15,-57,12,-45,20,-45,,-75,-5,-80,-5,-80,-8,-75,-8,-75,-5,-65,-5,-65,5,-65,5,-65,5,-68,5,-68,-5,-68,-5,-68,-5,-65,-5,-65,5,-65,5,-65,8,-75,8,-75,5,-80,5,-80,-5,-80,-3,-72,-2,-72,3,-72,4,-72,99,,,

80 DATA,-56,,-8,,-8,10,,10,,30,,30,,30,-45,30,-45,10,-64,10,-64,,-56,,-56,-10,-64,-10,-64,-30,-45,-30,-45,-30,,-30,,-10,,-10,,,-8,-10,-64,-10,-75,-10,-75,,-83,,-83,10,-75
81 DATA10,-75,,-79,,-79,-10,-75,-10,-75,,-60,,-60,10,-75,10,-75,10,-64,99,,,

82 DATA5,-30,,-25,,-25,-5,-30,-5,-30,-15,-5,-15,-5,-10,,-10,,10,,10,,15,-5,15,-5,20,-5,20,-5,10,,10,,15,-5,15,-5,5,-30,5,-30,10,-40,10,-40,3,-35,3,-35,-3,-35,-3,-35,-10,-40,-10,-40,-5,-30
84 DATA-5,-33,-3,-30,5,-33,3,-30,-5,-20,-5,-15,5,-20,5,-15,-7,-20,-7,-15,7,-20,7,-15,99,,,

86 DATA,,-15,,-15,,-8,-8,-8,-8,-8,-15,-8,-15,-15,-23,-15,-23,-15,-15,-15,-15,-23,-23,-23,-23,-23,-45,-23,-45,-15,-53,-15,-53,-8,-53,-8,-53,-15,-68,-15,-68,-8,-75,-8,-75,,-75
88 DATA,,15,,15,,8,-8,8,-8,8,-15,8,-15,15,-23,15,-23,15,-15,15,-15,23,-23,23,-23,23,-45,23,-45,15,-53,15,-53,8,-53,8,-53,15,-68,15,-68,8,-75,8,-75,,-75
90 DATA-15,-68,15,-68,-8,-53,8,-53,-23,-15,8,-45,-8,-68,,-60,,-60,8,-68,8,-68,8,-60,8,-60,-8,-60,-8,-60,-8,-68,,-38,-8,-38,-8,-38,8,-53,8,-53,8,-45,8,-45,15,-45,15,-45,,-30,,-30,,-38,99,,,

93 DATA-10,-15,-10,-30,-10,-30,-15,-20,-15,-20,-15,-1,-15,-1,-15,,-15,,15,,15,,15,-15,15,-15,-15,-15,-15,-10,15,-10,-15,-5,15,-5,,-15,-5,-20,-5,-20,-5,-35,-5,-35,5,-35,5,-35,5,-20,5,-20,10,-15,-5,-20,5,-20,-5,-25,5,-25
97 DATA-5,-30,5,-30,-10,-35,-10,-40,-10,-40,-5,-45,-5,-45,5,-45,5,-45,10,-40,10,-40,10,-35,-10,-40,,-45,,-45,10,-40,-5,-40,5,-40,5,-40,15,-30,15,-30,,-40,,-40,-15,-30,-15,-30,-5,-40,99,,,

101 DATA-20,-88,-30,-83,-30,-83,-30,-78,20,-88,30,-83,30,-83,40,-83,-15,-86,-20,-83,-20,-83,-20,-78,-20,-78,-30,-73,-30,-73,-30,-68,-30,-68,-20,-63,-10,-83,-10,-58,-10,-58,,-50,10,-83,10,-78,10,-78,20,-73,20,-73,20,-40
104 DATA15,-85,20,-78,20,-78,30,-76,30,-76,30,-60,,-83,,-73,,-73,10,-68,10,-68,10,-63,10,-63,,-58,99,,,

106 DATA5,-10,-5,-10,-5,-10,,-15,,-15,10,-20,10,-20,5,-15,5,-15,5,-10,5,-10,7,-6,7,-6,5,-3,5,-3,-5,-3,-5,-3,-7,-6,-7,-6,-5,-10,2,-3,5,,5,,8,,-2,-3,-5,,-5,,-8,,3,-8,3,-8,-3,-8,-3,-8,3,-5,-3,-5,99,,,

111 DATA99,,,

112 DATA-14,-46,-12,-37,-12,-37,-20,-32,-20,-32,-30,-32,-30,-32,-22,-24,-22,-24,-40,-17,-40,-17,-40,-7,-40,-7,-38,-5,-38,-5,-40,-3,-40,-3,-40,,-40,,-36,,-36,,-34,-2,-34,-2,-32,,-32
113 DATA,-28,,-28,,-28,-3,-28,-3,-30,-5,-30,-5,-28,-7,-28,-7,-28,-15,-28,-15,,-27,14,-46,12,-37,12,-37,20,-32,20,-32,30,-32,30,-32,22,-24,22,-24,40,-17,40,-17,40,-7,40,-7,38,-5,38,-5,40,-3,40,-3,40,
115 DATA40,,36,,36,,34,-2,34,-2,32,,32,,28,,28,,28,-3,28,-3,30,-5,30,-5,28,-7,28,-7,28,-15,28,-15,,-27,6,-48,38,-41,38,-41,40,-42,40,-42,18,-56,18,-56,12,-56,12,-56,10,-57,10,-57,8,-56,8,-56,-8,-56,-8,-56,-10,-58
116 DATA-10,-58,14,-58,14,-58,16,-59,16,-59,8,-63,8,-63,6,-63,6,-63,2,-70,2,-70,2,-63,2,-63,-2,-63,-2,-63,-2,-70,-2,-70,-6,-63,-6,-63,-8,-63,-8,-63,-16,-59,-16,-59,-14,-58,-14,-58,10,-57,10,-57,-12,-56,-12,-56,-18,-56,-18
117 DATA-56,-36,-47,-36,-47,-36,-39,-36,-39,-28,-41,-28,-41,-28,-46,-28,-46,-20,-50,-20,-50,-18,-50,-18,-50,-14,-46,-28,-41,30,-55,28,-58,22,-56,22,-56,22,-53,22,-53,28,-52,28,-52,34,-54,34,-54,20,-50,20,-50,26,-47
118 DATA10,-58,10,-61,10,-61,4,-58,-10,-58,-10,-61,-10,-61,-4,-58,40,-9,50,-12,50,-12,40,-7,-8,-25,6,-7,6,-7,28,-7,28,-7,28,-9,28,-9,20,-9,20,-9,6,-25,99,,,

120 DATA6,-60,30,-90,30,-90,60,-30,60,-30,60,-10,60,-10,30,-40,30,-40,15,-40,-6,-60,-30,-90,-30,-90,-60,-30,-60,-30,-60,-10,-60,-10,-30,-40,-30,-40,-15,-40,,-25,6,-25,6,-25,10,-20,10,-20,12,-10,12,-10
122 DATA10,-6,10,-6,10,,10,,14,,14,,15,-5,15,-5,16,,16,,20,,20,,20,-6,20,-6,18,-10,18,-10,18,-20,18,-20,15,-30,15,-30,15,-45,15,-45,40,-60,40,-60,40,-70,40,-70,10,-55,10,-55,6,-60,6,-60,10,-74,10,-74,6,-80,6,-80
124 DATA4,-80,4,-80,3,-82,3,-82,2,-80,2,-80,,-80,,-25,-6,-25,-6,-25,-10,-20,-10,-20,-12,-10,-12,-10,-10,-6,-10,-6,-10,,-10,,-14,,-14,,-15,-5,-15,-5,-16,,-16,,-20,,-20,,-20,-6,-20,-6,-18,-10,-18,-10
126 DATA-18,-20,-18,-20,-15,-30,-15,-30,-15,-45,-15,-45,-40,-60,-40,-60,-40,-70,-40,-70,-10,-55,-10,-55,-6,-60,-6,-60,-10,-74,-10,-74,-6,-80,-6,-80,-4,-80,-4,-80,-3,-82,-3,-82,-2,-80,-2,-80,,-80
128 DATA-6,-25,,-6,,-6,10,,10,,4,-8,4,-8,6,-25,-40,-64,-40,-90,-40,-90,-52,-80,-52,-80,-52,-40,40,-86,38,-92,38,-92,42,-92,42,-92,40,-86,40,-86,40,-50,4,-70,6,-74,-4,-70,-6,-74,,-64,,-60,99,,,


73 LINE(C-23/D,B)-(C-15/D,B),1:LINE-(C-15/D,B-15/D),1:LINE-(C-8/D,B-30/D),1:LINE-(C+8/D,B-30/D),1:LINE-(C+15/D,B-15/D),1:LINE-(C+15/D,B),1:LINE-(C+23/D,B),1
74 LINE(C,B-26/D)-(C,B-65/D),1:LINE(C-2/D+.5,B-38/D)-(C+2/D+.5,B-38/D),1:LINE(C-3/D+.5,B-45/D)-(C+3/D+.5,B-45/D),1:LINE(C-5/D+.5,B-53/D)-(C+5/D+.5,B-53/D),1
75 LINE(C-23/D,B-56/D)-(C-30/D,B-53/D),1:LINE-(C-23/D,B-45/D),1:LINE-(C-23/D,B-53/D),1:LINE-(C-8/D,B-38/D),1
76 LINE(C-15/D,B-45/D)-(C-8/D,B-60/D),1:LINE-(C+8/D,B-60/D),1:LINE-(C+15/D,B-45/D),1:LINE(C+15/D,B-42/D)-(C+15/D,B-57/D),1:LINE(C+12/D,B-45/D)-(C+20/D,B-45/D),1
77 LINE(C,B-75/D)-(C-5/D+.5,B-80/D),1:LINE-(C-8/D,B-75/D),1:LINE-(C-5/D+.5,B-65/D),1:LINE-(C+5/D+.5,B-65/D),1:LINE-(C+5/D+.5,B-68/D),1:LINE-(C-5/D+.5,B-68/D),1:LINE-(C-5/D+.5,B-65/D),1
78 LINE-(C+5/D+.5,B-65/D),1:LINE-(C+8/D,B-75/D),1:LINE-(C+5/D+.5,B-80/D),1:LINE-(C-5/D+.5,B-80/D),1:PSET(C-5/D+.5,B-72/D):PSET(C+5/D+.5,B-72/D):GOTO131
79 LINE(C,B-56/D)-(C,B-8/D),1:LINE-(C+10/D,B),1:LINE-(C+30/D,B),1:LINE-(C+30/D,B-45/D),1:LINE-(C+10/D,B-64/D),1:LINE-(C,B-56/D),1
80 LINE-(C-10/D,B-64/D),1:LINE-(C-30/D,B-45/D),1:LINE-(C-30/D,B),1:LINE-(C-10/D,B),1:LINE-(C,B-8/D),1:LINE(C-10/D,B-64/D)-(C-10/D,B-75/D),1:LINE-(C,B-83/D),1:LINE-(C+10/D,B-75/D),1
81 LINE-(C,B-79/D),1:LINE-(C-10/D,B-75/D),1:LINE-(C,B-60/D),1:LINE-(C+10/D,B-75/D),1:LINE-(C+10/D,B-64/D),1:GOTO131
82 LINE(C+5/D,B-30/D)-(C,B-25/D),1:LINE-(C-5/D,B-30/D),1:LINE-(C-15/D,B-5/D),1:LINE-(C-10/D,B),1:LINE-(C+10/D,B),1:LINE-(C+15/D,B-5/D),1
83 LINE-(C+20/D,B-5/D),1:LINE-(C+10/D,B),1:LINE-(C+15/D,B-5/D),1:LINE-(C+5/D,B-30/D),1:LINE-(C+10/D,B-40/D),1:LINE-(C+3/D+.5,B-35/D),1:LINE-(C-3/D+.5,B-35/D),1:LINE-(C-10/D,B-40/D),1:LINE-(C-5/D,B-30/D),1
84 LINE(C-5/D,B-33/D)-(C-3/D+.5,B-30/D),1:LINE(C+5/D,B-33/D)-(C+3/D+.5,B-30/D),1:LINE(C-5/D,B-20/D)-(C-5/D,B-15/D),1
85 LINE(C+5/D,B-20/D)-(C+5/D,B-15/D),1:LINE(C-7+D,B-20/D)-(C-7/D,B-15/D),1:LINE(C+7/D,B-20/D)-(C+7/D,B-15/D),1:GOTO131
86 LINE(C,B)-(C-15/D,B),1:LINE-(C-8/D,B-8/D),1:LINE-(C-8/D,B-15/D),1:LINE-(C-15/D,B-23/D),1:LINE-(C-15/D,B-15/D),1:LINE-(C-23/D,B-23/D),1
87 LINE-(C-23/D,B-45/D),1:LINE-(C-15/D,B-53/D),1:LINE-(C-8/D,B-53/D),1:LINE-(C-15/D,B-68/D),1:LINE-(C-8/D,B-75/D),1:LINE-(C,B-75/D),1
88 LINE(C,B)-(C+15/D,B),1:LINE-(C+8/D,B-8/D),1:LINE-(C+8/D,B-15/D),1:LINE-(C+15/D,B-23/D),1:LINE-(C+15/D,B-15/D),1:LINE-(C+23/D,B-23/D),1
89 LINE-(C+23/D,B-45/D),1:LINE-(C+15/D,B-53/D),1:LINE-(C+8/D,B-53/D),1:LINE-(C+15/D,B-68/D),1:LINE-(C+8/D,B-75/D),1:LINE-(C,B-75/D),1
90 LINE(C-15/D,B-68/D)-(C+15/D,B-68/D),1:LINE(C-8/D,B-53/D)-(C+8/D,B-53/D),1:LINE(C-23/D,B-15/D)-(C+8/D,B-45/D),1
91 LINE(C-8/D,B-68/D)-(C,B-60/D),1:LINE-(C+8/D,B-68/D),1:LINE-(C+8/D,B-60/D),1:LINE-(C-8/D,B-60/D),1:LINE-(C-8/D,B-68/D),1
92 LINE(C,B-38/D)-(C-8/D,B-38/D),1:LINE-(C+8/D,B-53/D),1:LINE-(C+8/D,B-45/D),1:LINE-(C+15/D,B-45/D),1:LINE-(C,B-30/D),1:LINE-(C,B-38/D),1:GOTO131
93 LINE(C-10/D,B-15/D)-(C-10/D,B-30/D),1:LINE-(C-15/D,B-20/D),1:LINE-(C-15/D,B-15/D),1:LINE-(C-15/D,B),1:LINE-(C+15/D,B),1:LINE-(C+15/D,B-15/D),1:LINE  -(C-15/D,B-15/D),1
94 LINE(C-15/D,B-10/D)-(C+15/D,B-10/D),1:LINE(C-15/D,B-5/D)-(C+15/D,B-5/D),1
95 LINE(C,B-15/D)-(C-5/D,B-20/D),1:LINE-(C-5/D,B-35/D),1:LINE-(C+5/D,B-35/D),1:LINE-(C+5/D,B-20/D),1:LINE-(C+10/D,B-15/D),1
96 LINE(C-5/D,B-20/D)-(C+5/D,B-20/D),1:LINE(C-5/D,B-25/D)-(C+5/D,B-25/D),1:LINE(C-5/D,B-30/D)-(C+5/D,B-30/D),1
97 LINE(C-10/D,B-35/D)-(C-10/D,B-40/D),1:LINE-(C-5/D,B-45/D),1:LINE-(C+5/D,B-45/D),1:LINE-(C+10/D,B-40/D),1:LINE-(C+10/D,B-35/D),1
98 LINE(C-10/D,B-40/D)-(C,B-45/D),1:LINE-(C+10/D,B-40/D),1
99 LINE(C-5/D,B-40/D)-(C+5/D,B-40/D),1:LINE-(C+15/D,B-30/D),1:LINE-(C,B-40/D),1:LINE-(C-15/D,B-30/D),1:LINE-(C-5/D+.5,B-40/D),1:GOTO131
100 LINE(C-20/D,79-Y(D))-(C-20/D,B-88/D),1:LINE-(C-10/D,B-83/D),1:LINE-(C+10/D,B-83/D),1:LINE-(C+20/D,B-88/D),1:LINE-(C+20/D,79-Y(D)),1:LINE-(C-20/D,79-Y(D)),1
101 LINE(C-20/D,B-88/D)-(C-30/D,B-83/D),1:LINE-(C-30/D,B-78/D),1:LINE(C+20/D,B-88/D)-(C+30/D,B-83/D),1:LINE-(C+40/D,B-83/D),1
102 LINE(C-15/D,B-86/D)-(C-20/D,B-83/D),1:LINE-(C-20/D,B-78/D),1:LINE-(C-30/D,B-73/D),1:LINE-(C-30/D,B-68/D),1:LINE-(C-20/D,B-63/D),1
103 LINE(C-10/D,B-83/D)-(C-10/D,B-58/D),1:LINE-(C,B-50/D),1:LINE(C+10/D,B-83/D)-(C+10/D,B-78/D),1:LINE-(C+20/D,B-73/D),1:LINE-(C+20/D,B-40/D),1
104 LINE(C+15/D,B-85/D)-(C+20/D,B-78/D),1:LINE-(C+30/D,B-76/D),1:LINE-(C+30/D,B-60/D),1
105 LINE(C,B-83/D)-(C,B-73/D),1:LINE-(C+10/D,B-68/D),1:LINE-(C+10/D,B-63/D),1:LINE-(C,B-58/D),1:GOTO131
106 LINE(C+5/D+.5,B-10/D)-(C-5/D+.5,B-10/D),1:LINE-(C,B-15/D),1:LINE-(C+10/D,B-20/D),1:LINE-(C+5/D+.5,B-15/D),1:LINE-(C+5/D+.5,B-10/D),1
107 LINE-(C+7/D+.5,B-6/D),1:LINE-(C+5/D+.5,B-3/D),1:LINE-(C-5/D+.5,B-3/D),1:LINE-(C-7/D+.5,B-6/D),1:LINE-(C-5/D+.5,B-10/D),1:LINE(C+2/D+.5,B-3/D)-(C+5/D+.5,B),1:LINE-(C+8/D,B),1
108 LINE(C-2/D+.5,B-3/D)-(C-5/D+.5,B),1:LINE-(C-8/D,B),1:PSET(C+3/D+.5,B-8/D):PSET(C-3/D+.5,B-8/D):LINE(C+3/D+.5,B-5/D)-(C-3/D+.5,B-5/D),1:GOTO131
109 LINE(127-10/D,E(D,3))-(127-10/D,E(D,3)-10/D),1:LINE-(127+10/D,E(D,3)-10/D),1:LINE-(127+10/D,E(D,3)),1:LINE-(127-10/D,E(D,3)),1
110 LINE(127-10/D,E(D,3)-10/D)-(127-5/D,E(D,3)-15/D),1:LINE-(127+15/D,E(D,3)-15/D),1:LINE-(127+15/D,E(D,3)-5/D),1:LINE-(127+10/D,E(D,3)),1
111 LINE(127+10/D,E(D,3)-10/D)-(127+15/D,E(D,3)-15/D),1:GOTO131
112 LINE(C-14/D,B-46/D)-(C-12/D,B-37/D),1:LINE-(C-20/D,B-32/D),1:LINE-(C-30/D,B-32/D),1:LINE-(C-22/D,B-24/D),1:LINE-(C-40/D,B-17/D),1:LINE-(C-40/D,B-7/D),1:LINE-(C-38/D,B-5/D),1:LINE-(C-40/D,B-3/D),1:LINE-(C-40/D,B),1
113 LINE-(C-36/D,B),1:LINE-(C-34/D,B-2/D),1:LINE-(C-32/D,B),1:LINE-(C-28/D,B),1:LINE-(C-28/D,B-3/D),1:LINE-(C-30/D,B-5/D),1:LINE-(C-28/D,B-7/D),1:LINE-(C-28/D,B-15/D),1:LINE-(C,B-27/D),1
114 LINE(C+14/D,B-46/D)-(C+12/D,B-37/D),1:LINE-(C+20/D,B-32/D),1:LINE-(C+30/D,B-32/D),1:LINE-(C+22/D,B-24/D),1:LINE-(C+40/D,B-17/D),1:LINE-(C+40/D,B-7/D),1:LINE-(C+38/D,B-5/D),1:LINE-(C+40/D,B-3/D),1:LINE-(C+40/D,B),1
115 LINE-(C+36/D,B),1:LINE-(C+34/D,B-2/D),1:LINE-(C+32/D,B),1:LINE-(C+28/D,B),1:LINE-(C+28/D,B-3/D),1:LINE-(C+30/D,B-5/D),1:LINE-(C+28/D,B-7/D),1:LINE-(C+28/D,B-15/D),1:LINE-(C,B-27/D),1
116 LINE(C+6/D,B-48/D)-(C+38/D,B-41/D),1:LINE-(C+40/D,B-42/D),1:LINE-(C+18/D,B-56/D),1:LINE-(C+12/D,B-56/D),1:LINE-(C+10/D,B-57/D),1:LINE-(C+8/D,B-56/D),1:LINE-(C-8/D,B-56/D),1:LINE-(C-10/D,B-58/D),1:LINE-(C+14/D,B-58/D),1
117 LINE-(C+16/D,B-59/D),1:LINE-(C+8/D,B-63/D),1:LINE-(C+6/D,B-63/D),1:LINE-(C+2/D+.5,B-70/D),1:LINE-(C+2/D+.5,B-63/D),1:LINE-(C-2/D+.5,B-63/D),1:LINE-(C-2/D+.5,B-70/D),1:LINE-(C-6/D,B-63/D),1:LINE-(C-8/D,B-63/D),1
118 LINE-(C-16/D,B-59/D),1:LINE-(C-14/D,B-58/D),1:LINE-(C+10/D,B-57/D),1:LINE-(C-12/D,B-56/D),1:LINE-(C-18/D,B-56/D),1:LINE-(C-36/D,B-47/D),1:LINE-(C-36/D,B-39/D),1:LINE-(C-28/D,B-41/D),1:LINE-(C-28/D,B-46/D),1
119 LINE-(C-20/D,B-50/D),1:LINE-(C-18/D,B-50/D),1:LINE-(C-14/D,B-46/D),1:GOTO242
120 LINE(C+6/D,B-60/D)-(C+30/D,B-90/D),1:LINE-(C+60/D,B-30/D),1:LINE-(C+60/D,B-10/D),1:LINE-(C+30/D,B-40/D),1:LINE-(C+15/D,B-40/D),1
121 LINE(C-6/D,B-60/D)-(C-30/D,B-90/D),1:LINE-(C-60/D,B-30/D),1:LINE-(C-60/D,B-10/D),1:LINE-(C-30/D,B-40/D),1:LINE-(C-15/D,B-40/D),1
122 LINE(C,B-25/D)-(C+6/D,B-25/D),1:LINE-(C+10/D,B-20/D),1:LINE-(C+12/D,B-10/D),1:LINE-(C+10/D,B-6/D),1:LINE-(C+10/D,B),1:LINE-(C+14/D,B),1:LINE-(C+15/D,B-5/D),1:LINE-(C+16/D,B),1:LINE-(C+20/D,B),1
123 LINE-(C+20/D,B-6/D),1:LINE-(C+18/D,B-10/D),1:LINE-(C+18/D,B-20/D),1:LINE-(C+15/D,B-30/D),1:LINE-(C+15/D,B-45/D),1:LINE-(C+40/D,B-60/D),1:LINE-(C+40/D,B-70/D),1
124 LINE-(C+10/D,B-55/D),1:LINE-(C+6/D,B-60/D),1:LINE-(C+10/D,B-74/D),1:LINE-(C+6/D,B-80/D),1:LINE-(C+4/D+.5,B-80/D),1:LINE-(C+3/D+.5,B-82/D),1:LINE-(C+2/D+.5,B-80/D),1:LINE-(C,B-80/D),1
125 LINE(C,B-25/D)-(C-6/D,B-25/D),1:LINE-(C-10/D,B-20/D),1:LINE-(C-12/D,B-10/D),1:LINE-(C-10/D,B-6/D),1:LINE-(C-10/D,B),1:LINE-(C-14/D,B),1:LINE-(C-15/D,B-5/D),1:LINE-(C-16/D,B),1:LINE-(C-20/D,B),1
126 LINE-(C-20/D,B-6/D),1:LINE-(C-18/D,B-10/D),1:LINE-(C-18/D,B-20/D),1:LINE-(C-15/D,B-30/D),1:LINE-(C-15/D,B-45/D),1:LINE-(C-40/D,B-60/D),1:LINE-(C-40/D,B-70/D),1
127 LINE-(C-10/D,B-55/D),1:LINE-(C-6/D,B-60/D),1:LINE-(C-10/D,B-74/D),1:LINE-(C-6/D,B-80/D),1:LINE-(C-4/D+.5,B-80/D),1:LINE-(C-3/D+.5,B-82/D),1:LINE-(C-2/D+.5,B-80/D),1:LINE-(C,B-80/D),1
128 LINE(C-6/D,B-25/D)-(C,B-6/D),1:LINE-(C+10/D,B),1:LINE-(C+4/D+.5,B-8/D),1:LINE-(C+6/D,B-25/D),1:LINE(C-40/D,B-64/D)-(C-40/D,B-90/D),1:LINE-(C-52/D,B-80/D),1:LINE-(C-52/D,B-40/D),1
129 LINE(C+40/D,B-86/D)-(C+38/D,B-92/D),1:LINE-(C+42/D,B-92/D),1:LINE-(C+40/D,B-86/D),1:LINE-(C+40/D,B-50/D),1
130 LINE(C+4/D+.5,B-70/D)-(C+6/D,B-74/D),1:LINE(C-4/D+.5,B-70/D)-(C-6/D,B-74/D),1:LINE(C,B-64/D)-(C,B-60/D),1


I think this is the end of my main RetroChallenge activity for this month. I also did a little work on another classic dungeon crawl game "Stronghold of the Dwarven Lords" from Tim Hartnell's book Giant Book of Computer Games (1984), subtitled "For most popular home computers that use BASIC."  I used OCR from a version of the book for the VZ200 computer, but it was missing a page, so I had to use another version for the TI99/4a to type in what was missing.  After some correcting and adjustments for the MC-10 it seemed to work fine.


Maybe next year I will try converting Akalabeth to BASIC09 under NitrsOS9.

Working directory on Github for this project: https://github.com/jggames/trs80mc10/tree/master/quicktype/MCX/Akalabeth

Sunday, 13 October 2019

RetroChallenge 2019/10: Akalabeth fully functional on MCX


Listened to Stevie Strowbridge's webcast yesterday. Curtis reported on my progress. He suggested that I was having trouble fitting the full program into the MCX.  I think he might be thinking of some of my prior posts about the game Telengard, where I had to make some edits that cut out a few features of the program (Mysterious Cubes and thrones, for example) to get it to fit in the regular 20K expansion pack. But the only compromises I have made in the MCX expansion pack version of Akalabeth is to shorten some messages. This was done in the name of speed and also memory conservation, but otherwise the program is fully functional. I don't think anything of major importance was lost in terms of information, except a few aspects of the ye-olde medieval flavour of some of the messages.  Otherwise, the 28K memory space provided by MCX (as implemented on the VMC10 emulator) is sufficient.

I have taken the much slimmed version I developed for the Coco and ported it back to MC-10, and I can report that it is now even faster in its screen drawing. I also now have 1K to spare after all the variables are declared.  I'll post it shortly after having my son go at it a little for bug testing.  My son also helped me figure out a way to slim the program even further, which will I hope allow it to fit in the more confined 25K space of Extended Color Basic (after PCLEAR2). The routine for drawing the creatures is the biggest chunk of drawing commands:

73 LINE(C-23/D,B)-(C-15/D,B),1:LINE-(C-15/D,B-15/D),1:LINE-(C-8/D,B-30/D),1:LINE-(C+8/D,B-30/D),1:LINE-(C+15/D,B-15/D),1:LINE-(C+15/D,B),1:LINE-(C+23/D,B),1
74 LINE(C,B-26/D)-(C,B-65/D),1:LINE(C-2/D+.5,B-38/D)-(C+2/D+.5,B-38/D),1:LINE(C-3/D+.5,B-45/D)-(C+3/D+.5,B-45/D),1:LINE(C-5/D+.5,B-53/D)-(C+5/D+.5,B-53/D),1
75 LINE(C-23/D,B-56/D)-(C-30/D,B-53/D),1:LINE-(C-23/D,B-45/D),1:LINE-(C-23/D,B-53/D),1:LINE-(C-8/D,B-38/D),1
76 LINE(C-15/D,B-45/D)-(C-8/D,B-60/D),1:LINE-(C+8/D,B-60/D),1:LINE-(C+15/D,B-45/D),1:LINE(C+15/D,B-42/D)-(C+15/D,B-57/D),1:LINE(C+12/D,B-45/D)-(C+20/D,B-45/D),1
77 LINE(C,B-75/D)-(C-5/D+.5,B-80/D),1:LINE-(C-8/D,B-75/D),1:LINE-(C-5/D+.5,B-65/D),1:LINE-(C+5/D+.5,B-65/D),1:LINE-(C+5/D+.5,B-68/D),1:LINE-(C-5/D+.5,B-68/D),1:LINE-(C-5/D+.5,B-65/D),1
78 LINE-(C+5/D+.5,B-65/D),1:LINE-(C+8/D,B-75/D),1:LINE-(C+5/D+.5,B-80/D),1:LINE-(C-5/D+.5,B-80/D),1:PSET(C-5/D+.5,B-72/D):PSET(C+5/D+.5,B-72/D):GOTO131
79 LINE(C,B-56/D)-(C,B-8/D),1:LINE-(C+10/D,B),1:LINE-(C+30/D,B),1:LINE-(C+30/D,B-45/D),1:LINE-(C+10/D,B-64/D),1:LINE-(C,B-56/D),1
80 LINE-(C-10/D,B-64/D),1:LINE-(C-30/D,B-45/D),1:LINE-(C-30/D,B),1:LINE-(C-10/D,B),1:LINE-(C,B-8/D),1:LINE(C-10/D,B-64/D)-(C-10/D,B-75/D),1:LINE-(C,B-83/D),1:LINE-(C+10/D,B-75/D),1
81 LINE-(C,B-79/D),1:LINE-(C-10/D,B-75/D),1:LINE-(C,B-60/D),1:LINE-(C+10/D,B-75/D),1:LINE-(C+10/D,B-64/D),1:GOTO131
82 LINE(C+5/D,B-30/D)-(C,B-25/D),1:LINE-(C-5/D,B-30/D),1:LINE-(C-15/D,B-5/D),1:LINE-(C-10/D,B),1:LINE-(C+10/D,B),1:LINE-(C+15/D,B-5/D),1
83 LINE-(C+20/D,B-5/D),1:LINE-(C+10/D,B),1:LINE-(C+15/D,B-5/D),1:LINE-(C+5/D,B-30/D),1:LINE-(C+10/D,B-40/D),1:LINE-(C+3/D+.5,B-35/D),1:LINE-(C-3/D+.5,B-35/D),1:LINE-(C-10/D,B-40/D),1:LINE-(C-5/D,B-30/D),1
84 LINE(C-5/D,B-33/D)-(C-3/D+.5,B-30/D),1:LINE(C+5/D,B-33/D)-(C+3/D+.5,B-30/D),1:LINE(C-5/D,B-20/D)-(C-5/D,B-15/D),1
85 LINE(C+5/D,B-20/D)-(C+5/D,B-15/D),1:LINE(C-7+D,B-20/D)-(C-7/D,B-15/D),1:LINE(C+7/D,B-20/D)-(C+7/D,B-15/D),1:GOTO131
86 LINE(C,B)-(C-15/D,B),1:LINE-(C-8/D,B-8/D),1:LINE-(C-8/D,B-15/D),1:LINE-(C-15/D,B-23/D),1:LINE-(C-15/D,B-15/D),1:LINE-(C-23/D,B-23/D),1
87 LINE-(C-23/D,B-45/D),1:LINE-(C-15/D,B-53/D),1:LINE-(C-8/D,B-53/D),1:LINE-(C-15/D,B-68/D),1:LINE-(C-8/D,B-75/D),1:LINE-(C,B-75/D),1
88 LINE(C,B)-(C+15/D,B),1:LINE-(C+8/D,B-8/D),1:LINE-(C+8/D,B-15/D),1:LINE-(C+15/D,B-23/D),1:LINE-(C+15/D,B-15/D),1:LINE-(C+23/D,B-23/D),1
89 LINE-(C+23/D,B-45/D),1:LINE-(C+15/D,B-53/D),1:LINE-(C+8/D,B-53/D),1:LINE-(C+15/D,B-68/D),1:LINE-(C+8/D,B-75/D),1:LINE-(C,B-75/D),1
90 LINE(C-15/D,B-68/D)-(C+15/D,B-68/D),1:LINE(C-8/D,B-53/D)-(C+8/D,B-53/D),1:LINE(C-23/D,B-15/D)-(C+8/D,B-45/D),1
91 LINE(C-8/D,B-68/D)-(C,B-60/D),1:LINE-(C+8/D,B-68/D),1:LINE-(C+8/D,B-60/D),1:LINE-(C-8/D,B-60/D),1:LINE-(C-8/D,B-68/D),1
92 LINE(C,B-38/D)-(C-8/D,B-38/D),1:LINE-(C+8/D,B-53/D),1:LINE-(C+8/D,B-45/D),1:LINE-(C+15/D,B-45/D),1:LINE-(C,B-30/D),1:LINE-(C,B-38/D),1:GOTO131
93 LINE(C-10/D,B-15/D)-(C-10/D,B-30/D),1:LINE-(C-15/D,B-20/D),1:LINE-(C-15/D,B-15/D),1:LINE-(C-15/D,B),1:LINE-(C+15/D,B),1:LINE-(C+15/D,B-15/D),1:LINE  -(C-15/D,B-15/D),1
94 LINE(C-15/D,B-10/D)-(C+15/D,B-10/D),1:LINE(C-15/D,B-5/D)-(C+15/D,B-5/D),1
95 LINE(C,B-15/D)-(C-5/D,B-20/D),1:LINE-(C-5/D,B-35/D),1:LINE-(C+5/D,B-35/D),1:LINE-(C+5/D,B-20/D),1:LINE-(C+10/D,B-15/D),1
96 LINE(C-5/D,B-20/D)-(C+5/D,B-20/D),1:LINE(C-5/D,B-25/D)-(C+5/D,B-25/D),1:LINE(C-5/D,B-30/D)-(C+5/D,B-30/D),1
97 LINE(C-10/D,B-35/D)-(C-10/D,B-40/D),1:LINE-(C-5/D,B-45/D),1:LINE-(C+5/D,B-45/D),1:LINE-(C+10/D,B-40/D),1:LINE-(C+10/D,B-35/D),1
98 LINE(C-10/D,B-40/D)-(C,B-45/D),1:LINE-(C+10/D,B-40/D),1
99 LINE(C-5/D,B-40/D)-(C+5/D,B-40/D),1:LINE-(C+15/D,B-30/D),1:LINE-(C,B-40/D),1:LINE-(C-15/D,B-30/D),1:LINE-(C-5/D+.5,B-40/D),1:GOTO131
100 LINE(C-20/D,79-Y(D))-(C-20/D,B-88/D),1:LINE-(C-10/D,B-83/D),1:LINE-(C+10/D,B-83/D),1:LINE-(C+20/D,B-88/D),1:LINE-(C+20/D,79-Y(D)),1:LINE-(C-20/D,79-Y(D)),1
101 LINE(C-20/D,B-88/D)-(C-30/D,B-83/D),1:LINE-(C-30/D,B-78/D),1:LINE(C+20/D,B-88/D)-(C+30/D,B-83/D),1:LINE-(C+40/D,B-83/D),1
102 LINE(C-15/D,B-86/D)-(C-20/D,B-83/D),1:LINE-(C-20/D,B-78/D),1:LINE-(C-30/D,B-73/D),1:LINE-(C-30/D,B-68/D),1:LINE-(C-20/D,B-63/D),1
103 LINE(C-10/D,B-83/D)-(C-10/D,B-58/D),1:LINE-(C,B-50/D),1:LINE(C+10/D,B-83/D)-(C+10/D,B-78/D),1:LINE-(C+20/D,B-73/D),1:LINE-(C+20/D,B-40/D),1
104 LINE(C+15/D,B-85/D)-(C+20/D,B-78/D),1:LINE-(C+30/D,B-76/D),1:LINE-(C+30/D,B-60/D),1
105 LINE(C,B-83/D)-(C,B-73/D),1:LINE-(C+10/D,B-68/D),1:LINE-(C+10/D,B-63/D),1:LINE-(C,B-58/D),1:GOTO131
106 LINE(C+5/D+.5,B-10/D)-(C-5/D+.5,B-10/D),1:LINE-(C,B-15/D),1:LINE-(C+10/D,B-20/D),1:LINE-(C+5/D+.5,B-15/D),1:LINE-(C+5/D+.5,B-10/D),1
107 LINE-(C+7/D+.5,B-6/D),1:LINE-(C+5/D+.5,B-3/D),1:LINE-(C-5/D+.5,B-3/D),1:LINE-(C-7/D+.5,B-6/D),1:LINE-(C-5/D+.5,B-10/D),1:LINE(C+2/D+.5,B-3/D)-(C+5/D+.5,B),1:LINE-(C+8/D,B),1
108 LINE(C-2/D+.5,B-3/D)-(C-5/D+.5,B),1:LINE-(C-8/D,B),1:PSET(C+3/D+.5,B-8/D):PSET(C-3/D+.5,B-8/D):LINE(C+3/D+.5,B-5/D)-(C-3/D+.5,B-5/D),1:GOTO131
109 LINE(127-10/D,E(D,3))-(127-10/D,E(D,3)-10/D),1:LINE-(127+10/D,E(D,3)-10/D),1:LINE-(127+10/D,E(D,3)),1:LINE-(127-10/D,E(D,3)),1
110 LINE(127-10/D,E(D,3)-10/D)-(127-5/D,E(D,3)-15/D),1:LINE-(127+15/D,E(D,3)-15/D),1:LINE-(127+15/D,E(D,3)-5/D),1:LINE-(127+10/D,E(D,3)),1
111 LINE(127+10/D,E(D,3)-10/D)-(127+15/D,E(D,3)-15/D),1:GOTO131
112 LINE(C-14/D,B-46/D)-(C-12/D,B-37/D),1:LINE-(C-20/D,B-32/D),1:LINE-(C-30/D,B-32/D),1:LINE-(C-22/D,B-24/D),1:LINE-(C-40/D,B-17/D),1:LINE-(C-40/D,B-7/D),1:LINE-(C-38/D,B-5/D),1:LINE-(C-40/D,B-3/D),1:LINE-(C-40/D,B),1
113 LINE-(C-36/D,B),1:LINE-(C-34/D,B-2/D),1:LINE-(C-32/D,B),1:LINE-(C-28/D,B),1:LINE-(C-28/D,B-3/D),1:LINE-(C-30/D,B-5/D),1:LINE-(C-28/D,B-7/D),1:LINE-(C-28/D,B-15/D),1:LINE-(C,B-27/D),1
114 LINE(C+14/D,B-46/D)-(C+12/D,B-37/D),1:LINE-(C+20/D,B-32/D),1:LINE-(C+30/D,B-32/D),1:LINE-(C+22/D,B-24/D),1:LINE-(C+40/D,B-17/D),1:LINE-(C+40/D,B-7/D),1:LINE-(C+38/D,B-5/D),1:LINE-(C+40/D,B-3/D),1:LINE-(C+40/D,B),1
115 LINE-(C+36/D,B),1:LINE-(C+34/D,B-2/D),1:LINE-(C+32/D,B),1:LINE-(C+28/D,B),1:LINE-(C+28/D,B-3/D),1:LINE-(C+30/D,B-5/D),1:LINE-(C+28/D,B-7/D),1:LINE-(C+28/D,B-15/D),1:LINE-(C,B-27/D),1
116 LINE(C+6/D,B-48/D)-(C+38/D,B-41/D),1:LINE-(C+40/D,B-42/D),1:LINE-(C+18/D,B-56/D),1:LINE-(C+12/D,B-56/D),1:LINE-(C+10/D,B-57/D),1:LINE-(C+8/D,B-56/D),1:LINE-(C-8/D,B-56/D),1:LINE-(C-10/D,B-58/D),1:LINE-(C+14/D,B-58/D),1
117 LINE-(C+16/D,B-59/D),1:LINE-(C+8/D,B-63/D),1:LINE-(C+6/D,B-63/D),1:LINE-(C+2/D+.5,B-70/D),1:LINE-(C+2/D+.5,B-63/D),1:LINE-(C-2/D+.5,B-63/D),1:LINE-(C-2/D+.5,B-70/D),1:LINE-(C-6/D,B-63/D),1:LINE-(C-8/D,B-63/D),1
118 LINE-(C-16/D,B-59/D),1:LINE-(C-14/D,B-58/D),1:LINE-(C+10/D,B-57/D),1:LINE-(C-12/D,B-56/D),1:LINE-(C-18/D,B-56/D),1:LINE-(C-36/D,B-47/D),1:LINE-(C-36/D,B-39/D),1:LINE-(C-28/D,B-41/D),1:LINE-(C-28/D,B-46/D),1
119 LINE-(C-20/D,B-50/D),1:LINE-(C-18/D,B-50/D),1:LINE-(C-14/D,B-46/D),1:GOTO242
120 LINE(C+6/D,B-60/D)-(C+30/D,B-90/D),1:LINE-(C+60/D,B-30/D),1:LINE-(C+60/D,B-10/D),1:LINE-(C+30/D,B-40/D),1:LINE-(C+15/D,B-40/D),1
121 LINE(C-6/D,B-60/D)-(C-30/D,B-90/D),1:LINE-(C-60/D,B-30/D),1:LINE-(C-60/D,B-10/D),1:LINE-(C-30/D,B-40/D),1:LINE-(C-15/D,B-40/D),1
122 LINE(C,B-25/D)-(C+6/D,B-25/D),1:LINE-(C+10/D,B-20/D),1:LINE-(C+12/D,B-10/D),1:LINE-(C+10/D,B-6/D),1:LINE-(C+10/D,B),1:LINE-(C+14/D,B),1:LINE-(C+15/D,B-5/D),1:LINE-(C+16/D,B),1:LINE-(C+20/D,B),1
123 LINE-(C+20/D,B-6/D),1:LINE-(C+18/D,B-10/D),1:LINE-(C+18/D,B-20/D),1:LINE-(C+15/D,B-30/D),1:LINE-(C+15/D,B-45/D),1:LINE-(C+40/D,B-60/D),1:LINE-(C+40/D,B-70/D),1
124 LINE-(C+10/D,B-55/D),1:LINE-(C+6/D,B-60/D),1:LINE-(C+10/D,B-74/D),1:LINE-(C+6/D,B-80/D),1:LINE-(C+4/D+.5,B-80/D),1:LINE-(C+3/D+.5,B-82/D),1:LINE-(C+2/D+.5,B-80/D),1:LINE-(C,B-80/D),1
125 LINE(C,B-25/D)-(C-6/D,B-25/D),1:LINE-(C-10/D,B-20/D),1:LINE-(C-12/D,B-10/D),1:LINE-(C-10/D,B-6/D),1:LINE-(C-10/D,B),1:LINE-(C-14/D,B),1:LINE-(C-15/D,B-5/D),1:LINE-(C-16/D,B),1:LINE-(C-20/D,B),1
126 LINE-(C-20/D,B-6/D),1:LINE-(C-18/D,B-10/D),1:LINE-(C-18/D,B-20/D),1:LINE-(C-15/D,B-30/D),1:LINE-(C-15/D,B-45/D),1:LINE-(C-40/D,B-60/D),1:LINE-(C-40/D,B-70/D),1
127 LINE-(C-10/D,B-55/D),1:LINE-(C-6/D,B-60/D),1:LINE-(C-10/D,B-74/D),1:LINE-(C-6/D,B-80/D),1:LINE-(C-4/D+.5,B-80/D),1:LINE-(C-3/D+.5,B-82/D),1:LINE-(C-2/D+.5,B-80/D),1:LINE-(C,B-80/D),1
128 LINE(C-6/D,B-25/D)-(C,B-6/D),1:LINE-(C+10/D,B),1:LINE-(C+4/D+.5,B-8/D),1:LINE-(C+6/D,B-25/D),1:LINE(C-40/D,B-64/D)-(C-40/D,B-90/D),1:LINE-(C-52/D,B-80/D),1:LINE-(C-52/D,B-40/D),1
129 LINE(C+40/D,B-86/D)-(C+38/D,B-92/D),1:LINE-(C+42/D,B-92/D),1:LINE-(C+40/D,B-86/D),1:LINE-(C+40/D,B-50/D),1
130 LINE(C+4/D+.5,B-70/D)-(C+6/D,B-74/D),1:LINE(C-4/D+.5,B-70/D)-(C-6/D,B-74/D),1:LINE(C,B-64/D)-(C,B-60/D),1

Charlie pointed out that it probably represents 7K+ of repeated draw commands.  His idea is to turn all those commands into lists of DATA for each creature that can then just get processed with a subroutine to process and display the line draw vectors.  Here's an example of a line I have converted:

73 LINE(C-23/D,B)-(C-15/D,B),1:LINE-(C-15/D,B-15/D),1:LINE-(C-8/D,B-30/D),1:LINE-(C+8/D,B-30/D),1:LINE-(C+15/D,B-15/D),1
:LINE-(C+15/D,B),1:LINE-(C+23/D,B),1

73 DATA-23,,-15,,-15,,-15,-15,-15,-15,-8,-30,-8,-30,8,-30,8,-30,15,-15,15,-15,15,,15,0,23,0,99,99,99,99

Then I can just use some kind of simple subroutine to plot these 2 groups of 2 coordinates for each LINE command like this:

10 READW,X,Y,Z:IFW=999THEN131
20 LINE(C+W/D,B+X/D)-(C+Y/D,B+Z/D),PSET:GOTO50

This will be critical in pairing down all the individual LINE commands. This is especially important because I discovered that unlike MCX Basic, ECB doesn't allow a literal number for the line color argument. You have to specify PSET, or PRESET and then set the color beforehand using the COLOR command. This means I'll have to swap a bunch of 1s for PSETs.  This would be fatal if I had to do it for the chunk of code above.

Hopefully with Charlie's idea.  I'll get it all to work in 25K on a Coco.

Stay tuned.

Saturday, 12 October 2019

RetroChallenge 2019/10: Extended Color Basic Akalabeth a Possibility


Akalabeth being played on real MCX Hardware

I was perhaps a little hasty in predicting that a Extended Color Basic version of Akalabeth might not be possible.  With a little coaxing and some suggestions from L. Curtis Boyle, I looked into some "slimming" techniques that could be used on the code.  By replacing some heavily used double character variables for single character variables, and renumbering the program using an increment of 1 for lines numbers, I was able to get the code down to about 25K.  Here are some of the main switches in variable names:

MM==>M
X1==>P
Y1==>O
DI==>D
GO==>G1 (this is just because Extended Color Basic doesn't like the word "GO" being used)

It also turned out to be fairly easy finding and inserting the places where Extended Color requires spaces before Basic keywords.  These didn't turn out to be needed in too many places, so the code only grew a little after doing this.  I was able to move the text of the source onto a Coco .DSK image and load it up.  However, it produced an OM error when it hit the array variable declarations.  I might need to find a few more K.

One possibility will be to remove the "Adventurer Shop" section and then chain the programs together and then load any shared variables needed between them.  However, the Shop component already doubles as the Items report, so this tactic might not be possible, or save as much memory as I expect.  I'll have to do some careful testing to get a better sense of how much more memory I need for variables.  But at least things are looking a little more positive than my last post.


Thursday, 10 October 2019

RetroChallenge 2019/10 Coco Version Akalabeth on the Rocks?

On to a new project?
The amount of memory reported by MCX Basic running on the emulator is 28703.  I think you get even more memory on real hardware. And you don't have to clear memory for use by hires commands.  It's just reserved automatically. The amount of memory reported by Coco Basic if I PCLEAR 2 (2 X 1.5 memory pages), which is needed for the PMODE2 screen leaves only 25889 bytes.  I'm starting to fear that the program won't fit on the Coco.

I have only a few hundred bytes free after all the array variables and other variables are declared in the MCX version.  In the Coco version I will also have to insert spaces in all the following instances of variable names touching directly on Basic command keywords:
ON T_GOSUB
FORT=D_TO10
IF A>D_THEN
IF P_ANDP_OR
B_STEP
The MC-10's Basic is fixed to be able to search in a way that it can differentiate between variable names and Basic keywords.  This means you don't need to put any spaces between commands and variables, which is really handy for saving memory and squeezing programs into the MC-10.

I don't think 25K will be enough to run this very large program.  This will leave it to Curtis to bring the game to Coco in the form of a Basic09 program. There might be some troubles here too, as I remember that memory management, as least on level 1 Basic09 can be a little tricky.  I think the largest program I ever compiled was one that needed me to use the #32 argument when running Basic09.  Probably easier in level 2 to get all the Graphics routines loaded up.  Hope so. I'd really like to see this game ported to a windowed program running under Nitros09.

So this might be the end of my Akalabeth porting project. I've been play testing a bit, and the program seems pretty stable.  However, my son Charlie is coming home this weekend for Canadian Thanksgiving, so I'll abuse my fatherly authority and position as family cook to extort some game testing out of him.  He's always really good at sniffing out bugs and takes great relish in pushing programs into situations where conditions are generated that reveal bugs.  I think it's his way of getting some revenge for me making him do beta testing of my crappy old Basic games.

So it might be onto the next project for me. I'm thinking of taking the example program "Mazies and Crazies" for the TRS-80 and typing it in and porting it to MC-10.  I haven't found a working version available anywhere on the Net.  Just the scan of the book by Frank De Costa, "Writing Basic Adventure Programs for the TRS-80" in which it appears.  Or maybe a text adventure of some kind.  Hmmm....

Tuesday, 8 October 2019

RetroChallenge 2019/10: Comparisons with the Original Apple Akalabeth

The resolution of PMODE2 which is the maximum resolution the TRS-80 MCX can handle, is bit courser than the 256 horizontal resolution of the MSX standard (which Nanochess converted the Apple source to).  However, it might be closer to what things look like on the original Apple version, which I think was something like 180X192, with the bottom 4 rows reserved for text.


Apple Versions









TRS-MC-10 Versions





PMODE2 halves the 256 horizontal resolution, so you have 128X192. However, every graphic command still uses the 256X192 resolution for plotting purposes, so I didn't have to convert the resolution of any of the commands from Nanochess's version.  I just had to add a few color numbers, which are not just assumed to be a certain default if not specified.

As Darren Atkinson points out about the limits of graphics on the MC-10:
Three of the 6847’s graphics modes are now available from Basic. Unfortunately, Tandy’s decision to limit the internal RAM to 4K means that modes RG6 and CG6 (aka PMODEs 3 and 4) can’t be displayed without wrap-around. For this reason, MCX Basic supports only RG2, CG3 and RG3 (aka PMODEs 0, 1 and 2). Although the maximum horizontal resolution in these modes is 128 pixels, MCX Basic has adopted the Extended Color Basic convention that all modes are addressed using horizontal coordinate values from 0 to 255 and vertical coordinate values from 0 to 191. These values are then scaled to fit the actual 128 x 96 or 128 x 192 screen size for the current mode.
One additional compromise made in the MCX version is that snow can appear on screen in the RG3 (PMODE2) resolution.  As Darren mentions:
A timing problem in the MC-10 can cause modes 0 and 2 to produce a very noisy display. This depends on whether the VDG syncs with the rising or falling edge of the clock. 
So any of you folks who run this program on real hardware, you might have to switch your machine on and off a number of times before you get the right timing.  Darren had a similar problem with his M/L Asteroids and provides these helpful instructions to work around the problem

ASTEROIDS for MC-10 When playing on a real MC-10 the monochrome graphics mode used for this game may display random sparkles on the screen. This is due to a defect in the design of the MC-10 hardware.
There is a 50% chance that the problem will occur and it depends on which edge of the clock the video chip synchronizes with when the computer is powered on.
You may want to check if the problem will occur before loading the game. You can preview the graphics mode by entering the command:
POKE 49151,120
If you see a lot of random white pixels moving across the entire screen then you should turn the computer off for several seconds and try again.
When the screen is mostly stable (just 2 or 3 rows where the pixels appear to be changing), press the RESET button to get back to the normal text screen. Then enter CLOADM to load the game and EXEC to run it.
Follow a similar procedure for AKALABET, or just consider the sparklies to be "dust" falling from the dungeon's ceiling or snow from the sky (i.e. treat it as an atmospheric feature, rather than a bug:).  It's just one of those limitations that one has to deal with in a beloved machine.  At least it won't be a problem when I port to the Coco as all its graphics modes work properly.  I haven't been able to locate my cable for plugging in my MC-10 to the RS232 port of my PC so I haven't been able to see the game on real hardware yet.  So many cable all stored in vast knots in my basement and attic... 


Sunday, 6 October 2019

RetroChallenge 2019/10: Akalabeth-- Another Error in the Original Code?


L Curtis Boyle (of Coco game list fame) suggested that I could speed up the text a little more by not reprinting all the labels in the lower windows.  It was a good idea. So now only the numbers for your FO, HP and GP are reprinted.  The labels remain. Similarly, the "Command" prompt is only reprinted if it gets erased.  I think I've got it to a very good speed now.  It's hardly frustrating at all!

While I was testing the new mods I ran across what I think is another error in the original code. If you use a playthrough trick I learned about from the website I mentioned in one of my prior posts, of choosing Mage and then using the Magic Amulet "Bad" spell to turn into a lizard man, your stats can get doubled or tripled.  If you do this *before* going to the castle to get your mission, when Lord British gives you your task, the program looks at your stats to determine the power of monster you will get next.  But in the case of the powerful lizard man, this seems to result in the calculation of a number higher than the max number of monsters in the dungeons, which is 10 (the Balrog).  This blows the lid off the monster array and causes an error.  So I put in a little code to detect if a monster # higher than 10 is generated, and if so to change it to 10.

Curtis says he's hoping to convert the game to Nitros9 and Basic09 to run in a window on a high res screen.  It will look pretty cool to see it running with other programs at the same time.  It will take a lot of work to convert all the graphics commands to GFX2 subroutine calls, but I have done some of this myself in the past with a minesweeper conversion and an Astronomy program for plotting the moons of Jupiter. It's tedious but can be done.  I might be able to help him.

Still not 100% sure that there are no more errors, but I will keep bug testing. I played down to a level to get the Balrog and then cheated myself back to the surface.  The routine of returning to Lord British's Castle seemed to work okay and recognized my accomplishment and then offered to bump me up to the next level of difficulty.  This game continues until you kill a Balrog on difficulty level 10. Then all you get is a measly "Congratulations!" and can keep playing some more. Achieving this would be pretty brutal without a game save feature.  Well, there's another mod I can consider doing--adding game saving!  But first, I'll try porting the program to Coco and Extended Color Basic.

I don't know who else is doing RetroChallenge this month.  All the best to anyone out there who is also doing the contest.  And thanks to anyone for reading!

I'm now up to AKALABETH_MCX13.TXT

See: https://github.com/jggames/trs80mc10/tree/master/quicktype/MCX/Akalabeth


RetroChallenge 2019/10: Akalabeth Text Routine Speed-up

First mission complete
Intro Screen
I've made the text routine faster again.  I realized that no single letter or number used more than 7 draw commands, and since I encode and use the actual numbers for each draw command, I could encode every character using only 7 digits instead of 9. That's a substantial reduction of processing for each character.

Here is the new routine:

0 CLS:CLEAR500:DIMT,A,G,A$,B$,A$(58),I,J,M$,P(5),C$(5),C(5),M$(10),ML(10,1),MZ(10,1):I=64:J=47:GOTO15
1 DRAW"BD6":FORG=1TOLEN(M$):A=ASC(MID$(M$,G)):IFA>ITHENA=(A-I)*7:FORT=ATOA+6:DRAWA$(ASC(MID$(A$,T))):NEXT:DRAW"BR8":NEXT:DRAW"BL255BD2":RETURN
2 IFA>JTHENA=(A-J)*7:FORT=ATOA+6:DRAWA$(ASC(MID$(B$,T))):NEXT:DRAW"BR8":NEXT:DRAW"BL255BD2":RETURN
3 DRAW"BR8":NEXT:DRAW"BL255BD2":RETURN
REM       A      B      C      D      E      F      G      H      I      J      K      L      M      N      O      P      Q      R      S      T      U      V      W      X      Y      Z
15 A$="      10345671256700123600014567001234670123070002345671250700900000014560001250780000008912345801234500123456012347000234570123400023567000000789120456024007091245609205078902045671340670"
16 B$="      123456000000891346700345670024507002356700123567034500001234567234570034000090000700"
17 A$(48)="":A$(49)="NU3":A$(50)="BU3U3BD6":A$(51)="BU6NR5BD6":A$(52)="BR5BU3U3BD6BL5":A$(53)="BR5NU3BL5":A$(54)="NR5":A$(55)="BU3NR5BD3":A$(56)="BU6BR3D3BD3BL3":A$(57)="BR3NU3BL3"

I'm now up to AKALABETH_MCX12.TXT in terms of versions of the source. I'm not sure if there are any other possible speed-ups hiding in the code, but you never know.  Also made some changes to the introductory screen to put all the questions on one screen.  Be nice to add some instructions too, but memory is at a premium.  In fact, I had to pare down some of the messages that get displayed when you enter Lord British's Castle for your various missions. So in case people were wondering, the arrow controls for movement are:

   I
J K L

And the other commands are as follows:

A=attack
S=stats
Space=pass turn (wait)
P=Turn pause combat messages on or off


Saturday, 5 October 2019

RetroChallenge 2019/10: Akalabeth Updates

Bug Chasing

I have been debugging my initial attempt to port of Akalabeth to MC-10 equipped with MCX.  I found a number of bugs I had put into the code, and possibly one that is from the original program.

The first bug that I discovered that was my fault was that I missed putting a few 1s at the end of LINE commands. In MS Basic for the MSX standard, you can leave off a number for the color of lines to be drawn by the LINE command. If it is left off the default color set by a COLOR command is used.  But with the Extended Color Basic of the MCX you have to supply either a color number or PSET or PRESET.  PSET is the way to designate the default color, PRESET provides the default background color.  So I had to add lots of 1s to all the LINE commands, and there are lots of them, so I missed a few in my initial edit.

I also found a place where I hadn't replaced a PRINT command with a call to my hires text routine.  When MCX BASIC hits a PRINT command while in hires mode it automatically bumps you out of hires and back into text mode.  This is different from regular extended basic, which can just print the text to the text screen, which is kept in a separate place in memory.  This happened in the Magic Amulet routine when you choose the BAD option and get turned into a Toad rather than a Lizard Man. You'd be switched to text mode and the message "You have been turned into a toad" would be printed on the text screen.  I fixed that problem.

I also noticed that I was down to only 240 bytes after all the main variables had been DIMed and the program had run through most of its routines.  So I decided to trim the program down a little more by consolidating a few more lines using colons and switching a few main array variables from two character long variable names to singles.  Now the DN() and TR()--dungeon and terrain variables are just D() and T().  I also changed the Stats to just three character shorthand (STR/INT/WIS/STA etc.).  This not only saves memory but provides more space on the setup screen, as I realized that Stats and Items can rise to the level of 3 digits, if not more.  Now there should be space for up to five digits for items and stats.

I found a number of errors with the Pause routine. I also added pauses and clear text window commands in a few places to improve the display of information in the bottom left "Command" window.

I found an interesting website that had playthrough information.  It was really helpful in allowing me to playtest and find some of these bugs:
I turns out there is a bit of trick for getting an easy win.  Just choose the Mage, rather than Fighter, and in the first battles, choose the BAD option of the Magical Amulet, which can possibly turn you into a super powerful lizard man.  If the Bad magic turns you into a Toad, then just re-start.  Using this technique and the high speed setting of the emulator allowed me to play through many attempts at getting down to lower levels to see most of the higher level monster.  This is how I noticed that I had missed putting 1s on a few LINE draw commands.  The high speed option of the VMC10 is really helpful for game testing.

Balrog which only appears at level 8 and deeper
I also sped up the text rendering by switching to using ASC to test component of the array that stores the info to draw the letters rather than using VAL. The text draw data takes the form of numbers 1-9.  Now this triggers references to an array with elements containing DRAW commands with those elements stored using numbers 48-57 rather than 0-9.  The nine drawing elements created a coarse set of letters and numbers from drawing element arranged like this:

+--3--+
|  |  |
2  8  4
|  |  |
+--7--+
|  |  |
1  9  5
|  |  |
+--6--+
This allows me to create characters like this lowercase G:
*******
|  *
8  *
|  *
*******
|  |  *
1  9  *
|  |  *
*******
All I have to do is encode 9 digits for each character, such as the G, as follows: 023456700
As you can see, the 1 location and the 8 and 9 locations are zeros and therefore render blanks.  The others using the ASC code will select for their appropriate draw string (48-57) for rendering that character.  By using ASC to do this I can also use a MID$ command without its length argument, since ASCII just send back the ASCII value of the first character of any string.  So this shaves off a further two characters in the command: From MID$(A$,T,1) to MID$(A$,T).  Every little bit helps and I think the ASC command probably is just faster than VAL command too.  I chose to render letters as lowercase because this seemed to give the most differentiation between letters and also generally used fewer lines. Again, every little bit helps.  Some of them like the K and X are a little abstract, but for the most part they seem basically readable.

A Bug that's not mine?

The bug in the original code that I think I found involves a rare condition in which all your items have been stolen (no weapons) and a thief is attacking and randomly stealing items. The routine for it to randomly select an item stored in your items array simply keeps looping back on itself if it finds an array element that is empty.  But if all the items are empty it just keeps looping back in an infinite search for something for the thief to steal-- freezing program execution and never triggering the "you starved to death" routing that will allow the game to end properly.  I fixed the problem by doing a check that all items aren't empty before allowing the program to proceed to the theft search.

I'm now up to AKALABETH_MCX11.TXT in my Github repository:
https://github.com/jggames/trs80mc10/tree/master/quicktype/MCX/Akalabeth


Thursday, 3 October 2019

Retrochallenge 2019/10: Akalabeth for the TRS-80 MC-10 MCX

Well, as usual, the projects that I described in my entry for this month's Retrochallenge have very little to do with what I have actually ended up doing.

I really can’t take much credit for this one project. The well-known retro programmer Oscar Toledo G. aka nanochess ported the Apple II source of Akalabeth World of Doom to MSX Basic.  This game was the forerunner to the Ultima Series and was programmed by Richard Garriott aka Lord British. I stumbled across a posting that Nanochess made about his project. Since the MSX1 standard, graphically speaking, works on 256 X 192 resolution and is pretty close in syntax to Extended Color Basic, it was pretty easy for me to fix up the source for running under the MCX (i.e. extended color basic) for the MC-10.  Here’s the link to Nanochess’s  page:

Here’s the link my Github dir for Akalabeth:
Akalabeth_MCX8.TXT is my latest as of this posting version.

The most important change that I had to make was to create a high-res text routine since MCX/Extended Color Basic has no built-in way for printing text on the screen.  The MSX graphic standard uses a later standard of Microsoft Basic that provides for printing text on the graphic screen.  My routine went through many iterations, of course, in which I tried to squeeze more and more speed out of Basic.  Hard to discern, but you might be able to notice a slight uptick in rendering from each of the following videos:


Here is a listing of the final routine:
0 CLS:CLEAR500:DIMT,A,G,A$,B$,A$(58),I,J,M$:I=64:J=47:GOTO15
1 DRAW"BD6":FORG=1TOLEN(M$):A=ASC(MID$(M$,G)):IFA>ITHENA=(A-I)*9:FORT=ATOA+8:DRAWA$(ASC(MID$(A$,T))):NEXT:DRAW"BR8":NEXT:DRAW"BL255BD2":RETURN
2 IFA>JTHENA=(A-J)*9:FORT=ATOA+8:DRAWA$(ASC(MID$(B$,T))):NEXT:DRAW"BR8":NEXT:DRAW"BL255BD2":RETURN
3 DRAW"BR8":NEXT:DRAW"BL255BD2":RETURN
REM         123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789
REM         A        B        C        D        E        F        G        H        I        J        K        L        M        N        O        P        Q        R        S        T        U        V        W        X        Y        Z
15 A$="        103456700120056700123006000100456700123406700123000700023456700120050700000000009100456000120050780000000089123450080123450000123456000123400700023450700123400000023056700000000789120456000020400709120456009020050789020456700103406700"
16 B$="        123456000000000089103406700003456700020450700023056700123056700003450000123456700023450700003400009000000700"
17 A$(48)="":A$(49)="NU3":A$(50)="BU3U3BD6":A$(51)="BU6NR5BD6":A$(52)="BR5BU3U3BD6BL5":A$(53)="BR5NU3BL5":A$(54)="NR5":A$(55)="BU3NR5BD3":A$(56)="BU6BR3D3BD3BL3":A$(57)="BR3NU3BL3"
This routine should be useful for Coco or MC-10. It's meant to render in PMODE2, which is the highest resolution available in the MC-10.  Not sure how it will look in other modes (PMODE 3 or PMODE 4).  It's a bit chunky and still a bit slow, but it gets the job done without having to resort to M/L code.

Curtis Boyle has contacted me about getting the source to try a conversion to Basic09.  This should be possible since the GFX module has all the routines you would need.  However, I think the X index is reversed, if I recall, from that of Extended Color Basic so that coordinate numbers do not go from top to bottom but bottom to top.