Sunday 27 June 2021

Walter Bright's "Empire" in Basic

I've made a version of Walter Bright's 4X Ur game "Empire" re-coded in Micro Color BASIC for the TRS-80 MC-10. It's for two players. The control is by arrow and Enter key and Yes or No prompts.  Running into enemy units initiates combat or other actions, such as repairs.  My re-code is based on a description of the game play and unit stats found  here: https://web.archive.org/web/20210418112142/http://www.catb.org/~esr/vms-empire/vms-empire.html


The most important information from that site was the details about the units and about how combat is carried on. The units are as follows:

PieceYouEnemyMovesHitsStrCost
ArmyAa1115(6)
FighterFf81110(12)
Patrol BoatPp41115(18)
DestroyerDd23120(24)
SubmarineSs22320(24)
Troop TransportTt21130(36)
Aircraft CarrierCc28130(36)
BattleshipBb210240(48)
SatelliteZz10----50(60)

I think I have all the basics of combat working.  In brief, you have a 50/50 chance of doing your strength ("Str")  worth of "Hits" damage to an opposing unit.

Saving and Loading Games

If you hit Enter when your cursor is on open land or sea, you will be prompted to end your turn.  Hit Y to let the other player have their turn, or N to continue with your turn.  If you hit Q you will be prompted to save the game.

The program creates two files when you select Q: The self-modified game program (EMPGAME) and a data file (EMPDATA) for the main array. By this method, games should be able to be played across the Net by sharing these two files between two people with VMC10. My son Charlie is moving to Halifax. I hope we can have a few long distance "mail-chess"-like games to keep in touch.  When you CLOAD and RUN the EMPGAME program file, just select N in response to the "New Game" prompt, and then hit Enter to load the EMPDATA file created along with that specific EMPGAME file.  Don't mix and match these files, or the game will be confused and not work.

The self-modification of the game source is to a 30 element string array with 64 character long strings.  There are three such array structures.  One for the base map.  The other two for storing the "fog of war" that each player sees.  There is also a 2 X 50 array for the Unit information for each player, with the base 0 element for storing basic info about what is under each unit being moved.  So each player can have a max of 50 units.  The original game had a 100 by 60 map, which apparently was the largest matrix that could be printed on a DEC printer of the time.  But compromises had to be made to fit the map into a 20K Tandy MC-10.  Still, I don't think it feels particularly cramped.


Movement

A feature that also might not have been in the original is map edge wrapping.  When your cursor or units move across the edges of the map (64X30) they wrap around to the other side.  As Charlie pointed out, this is hardly like a real globe represented in 2D, but again compromises had to be made.  In my version, the satellites take advantage of this feature to be able to engage in continuous diagonal movement to reveal portions of the map.  Also, in my version, you have to activate satellites each turn for them to make their 10 move sweeps.  This is perhaps something that should be done at the beginning of a turn.

There is also no dynamic updating of the fog of war (so a satellite might be especially handy). Your units only see what they last saw in the 8 units around them as they moved in your last turn.  In between your turn and your opponent's turn, this information might become "outdated," which can cause some ghosting of enemy units.  However, whenever you select one of your units, it will re-scan the immediate surroundings.  It's up to you to figure this all out, by careful use of units to get updated information.  The Fighter is particularly useful for getting up-to-date information, since it can move 8 spaces each turn.  But be careful it runs out of gas after 32 total moves.  So gas up regularly at cities or aircraft carriers.

The movement uses Greg Dionne's trick for key sensing, which makes it possible also hit two keys together (from the AWSZ keys) to get diagonal cursor movement.  However, you have to to be careful to hit both keys simultaneously.  Motion is reasonably fluid (given all the fog of war stuff) and the keys can be held down for continuous movement.

Unit Reports

Messaging and other flourishes have been kept to a minimum since so much memory is used for all the string and numeric array data.  There are no explosion sounds or verbose messages.  Destroyed units just disappear.  Old messages stay on the bottom of the screen until replaced by new ones.  The messages are terse.  When you select units you will usually see:

UNITNAME #

The # is the amount of hit points/strength the unit has left.  Many units simply have 1 unit of strength, and are one-hit-kills, so this info is only useful for units like Carriers and Battleships.

Loading and Unloading Transports

For units like the troop transport you first get a report of the number of armies contained and a prompt to unload if any are present.  The Fighter adds a prior # which represents the total range left before it must be refueled.  Armies can bump into your own Transports, at which point they will be loaded.  They can then be transported across water.  Just choose "Y" to the prompt to unload when you select transports to disembark armies on adjacent land.  You must do this for each army individual by reselecting the transport and hitting Y.  There must be available land in the surrounding 8 spaces.

Repairs and Refueling

Another compromise is that fighters can't be landed and moved around on carriers like armies can in transports.  Instead, fighters can accompany carriers and simply bump into them when they need to refuel. Similarly, when ships are damaged, they simply need to bump into a coastal city to get a repair point back.  They can only do this once per turn.

The two players are demarcated by different cursor colours. The first player is red, the second is cyan.  The first player has light green characters.  The second player has "reverse" characters (i.e. lowercase as in the table above).  You select units by moving the cursor over them and hitting Enter.  The cursor then disappears and you can just see the unit.  Move it using the arrow keys.  When you run out of moves, the cursor reappears.  You can end a turn early though by hitting Enter again.

City Menu

Selecting a city unit shows what is currently being produced by the city and the number of turns to go before it is ready.  If you hit a number from 1-9 you can see what else can be produced and how many turns they take (plus a additional amount for the first unit produced--see the last column in the table above).  You must hit Enter to make such a change in production.  Otherwise, hit 0 or any other key to abort the city function and return to cursor movement.

Winning

When one of the players destroys all the units of the opposing player, they are declared the winner.  To play again the program must be re-loaded because the array strings have been modified in the actual Basic source code.  To prevent possible confusion, a NEW command is issued at the end of the game to wipe the game from memory.

So, if you have a hankering for playing what Bright's attempt at originally coding the game in Basic might have been like before he abandoned it in order to code it in the "superior" language of Fortran, this is your game.  If you want to find out more about the history of the game, see Bright's page: http://www.classicempire.com/history.html

Wednesday 9 June 2021

APF and Some Matra Alice Stuff

I've been taking some inspiration from the APF Imagination Machine for many of my recent BASIC 10-Liner programs.  However, what got me on to the kick was working a much more substantial programming project.  This was a complete re-code, based on videos and documentation, of the APF program Mission Improbable: Operation Alpha.  I wandered into some videos on Youtube of someone playing APF games. There were some nice playthroughs of some of the best machine language arcade games for the system.  But there were also videos showing humbler programs, including many that could easily be implemented in BASIC (although on the APF they were machine language). Mission Improbable was one these.

Getting APF cassette games running on the emulators for the APF takes some struggle.  I found converting the files to WAVs helpful.  However, I couldn't get this one to load properly or run. So I don't know if some or all of it was made in Basic.  However, I decided that I could probably just re-program the game.  I took a slow and careful approach (unlike when I'm programming 10Liners).  First I developed the menu systems and all the complex mission selection stuff.  Then I drew the main screen graphic.  Then I converted a variation of minesweeper to replace the alternate escape route option of the original.  Finally, I made the main game itself.  You can find a demo of the finished product here:


The toughest part was getting the flashlight beam effect of the roving guard. Besides that, the movement and other animations are pretty standard fare from other games I've made. Finally, my son Charlie used his finely tuned musical ear to recreate the win refrain-- The Stars and Stripes forever, although it first sounded like "Be kind to your web footed friends" to me.

Besides altering the escape route I also slightly altered the missions. Especially the Assassinate option.  The original had some complex activity of going into a dark room and listening to tones to zero in on the hiding Commandant. The APF has better sound generation than the MC-10, so perhaps such an activity would work, but the main game screen was already a little faster than the original game, so I opted for a moving Commandant that forces you to try to get close to him before he moves again.  He also is always flanked by two machine guns, which get left behind when he moves.  So the map screen gets progressively more difficult to navigate without getting shot.  I think it's an adequate replacement for the original mission activity.  

The final step was tuning the timer to make for challenge, but without making it mission impossible.  I've hopefully hit the right balance.  I had to play quite a few games to satisfy myself.  I still don't know if I've got it right, but considering that I will likely be the only person to play the game, besides my increasingly reluctant beta-tester son Charlie, I eventually had to just pull the plug.  Since I played so much, it's often hard to tell if levels are too easy, or whether they just seem so because I've got so good (and as the programmer have inside knowledge).

Another system that I have taken actual source code from is the Matra Alice.  I'd seen "Coloric" listed for many years on Alice software sites, but as it was a puzzle game (and not an "action") game I always put it on the back-burner for porting.  However, I decided to finally get around to it.  Robert Sieg has been discussion Alice graphics on the Facebook group, and his comments reminded me that the Alice, despite its powerful new graphic chip, maintained a certain basic level of compatibility with the old MC-10 semigraphic 4 screen.  In other conversions I've found that there are often simpler MC-10 graphics hiding under what is essentially a thin veneer of extra special effect based on the new graphic chip.

This turned out to be the case with Coloric.  Although it was placed on 40X24 character Alice screen, it still used standard SET/RESET for a lot of the basic work..  I just had to shift things into the smaller 32X16 space.  I found that every thing fit.  I just had to omit some of the embellishments and minor extra instructions present on the screen.


Now the MC-10 has an interesting puzzle game from a French 8-bit computer, translated to English.  I don't think I've played anything like it.  The French, like the Japanese, make some interesting puzzle games.  Here are my translations of the instructions:

Jumping Jack: Yet Another 10Liner and Some Updates

Oops I did it again.  It's a dull time of the year.  I sit waiting for emails to come back from students who need advising for the next academic year.  Otherwise, I'm reading or attending virtual meetings. But to break up the monotony, and sometimes just to escape the heat, its nice to head down into the basement and do some Basic coding.

I've got a third entry for the ASCII Basic 10Liner Jam on itch.io. It's based on a game for the Sinclair Spectrum that I stumbled across called Jumping Jack.  I had originally envisioned a game using Semi-graphics 6 mode.  I'd even worked up an elaborate set of characters.  But when the 10Liner contest came along I decided to try for something less complex. Obviously, I put the SG6 version on the shelf because getting the game logic running would require more of a time investment than I'm willing to give right now.  I needed a simpler set of projects. The 10 line limitation really provides that.  Perhaps some day I'll work up a more full version in SG6 using Greg Dionne's Basic compiler.

In the meantime here is what my first stab at making little ASCII Basic version of the game looked like:

I eventually cleaned it up a little in terms of animation of the main character and his final jump up off the screen, along with some other tweaks, including the ability to type in a difficulty level from 1 to 3 at the "new game" prompt.  Here's a vid of the latest rendition:

If you want to compare it to the original Sinclair version the following is a Vid on Youtube showing the game play.  Mine is obviously a little more finicky than the original.  But that's what you get when you are limited to 10 Lines.  No frills.


JUMPJACK can be played online here using a JAVASCRIPT emulator.  Just select JUMPJACK from the cassette menu and type RUN in the main screen.

I also made some updates to my DFENDER entry (it can also be played at the link above).  I made the trail behind your cursor stay visible.  This makes more apparent where you have switched the background character to the ASCII values for the buff coloured semigraphic characters. This is all you have to do to explode the incoming missiles. When incoming missile characters are set into place, if they notice that the underlying character they are replaying is from the different colour set in the ASCII values above 128 (the 8 colors are represented in 8, 16 character sets) they explode and reset to the top of the screen.  So although you don't have to actually see the "trail" for this to work, people without knowledge of semigraphics might not be aware that, so I made the trail visible.  Now I'm thinking that it is like a trail of your anti-missile missile as it shoots through the sky.  I also added a little red explosion with the space saved in the code by removing the need to reset the pointer character, and some other reorganizing I did.


 Enjoy!


Monday 7 June 2021

Pac-Rat: 10-Liner Game for itchi.io Game Jam 2021

I have another game for the ASCII Basic 10Liner programming Jam. It's also inspired by the APF Imagination Machine. Since that early 8-bit computer/game system it shares the same video chip as the MC-10 (and the Coco and Dragon), it is a good place to look for inspiration for game ideas.  The original was a two player game, with each player using their paddles to steer their "rat" through a maze to get to the cheese first.  I thought it might be possible to get a very concise AI to play against.  But the 72 character line limit was just a wee bit too confining to get that in along with the maze and human player with movement.  In the end I settled for a simple game of collecting cheeses as quickly as possible.  They only stay in place a brief time, so you have to plan the quickest and most efficient routes to get to them before they disappear.  You get 30 cheeses, so that's your highest possible score.

The following is a video of the APF game.  It's a little slower in its movement.  It didn't take as much back in the 70s to impress.  The playing board is just made up of solid color characters from the character set above 128.


The game can be played from my website.  Just select the "PACRAT" from the cassette menu.  Then type RUN and hit <Enter>

http://faculty.cbu.ca/jgerrie/MC10/JG_MC10.html

The source can be viewed here: https://github.com/jggames/trs80mc10/tree/master/quicktype/APF_Imagination_Machine/PacRat

Saturday 5 June 2021

Defender: 10-Liner Game for itchi.io Game Jam 2021


Working on a project for the Basic 10-Liner Contest being run on itch.io based on the image of the city from a APF Imagination Machine TS-1000 1970s game console:


My version is written in Micro Color Basic on my favourite 8-bit computer, and the first computer I ever owned, the TRS-80 Micro Color Computer 10 or MC-10.  Some call it the Poco because it is the little brother to the Tandy Color Computer.  It's a budget 8-bit micro along the lines of the Sinclair ZX-81.

The game can be played at my website using Mike Tinnes TRS-80 MC-10 Javascript emulator. Just select DEFENDER from the cassette menu, and the type RUN in the main screen and hit <Enter>. Type list to see some instructions listed at the end as REM statements.

Here is the Basic code for the game:

0 D(T)=RND(0):I(T)=RND(31):J(T)=0:IFRND(2)=1THEND(T)=-D(T):I(T)=I(T)+32

1 CLS0:?@320,"€€€€€€€€€€€—’€€€€€€€€€€““’€€€€€€€€€€€€óÿò€‘››€€€€€€£££“›";

2 ?"›š€€€€€€€€óóò€ûúþú•——€ÞÞÞÞÚ««¯›››š€þþþú€€óûûûòûÿýú———’ÞÞÞÞÚ««¯›››š";

3 ?"€þþûú€€ûûûûúûþþú››››ÞÞÞÞÚ««¯›››šóûþûú€®ûûÿüúûþÿÿ›š•—ßÜßÜß««®››žŸþ÷";

4 A=-SGN(PEEK(2)ANDNOTPEEK(16946))+SGN(PEEK(2)ANDNOTPEEK(16948))

5 B=-SGN(PEEK(2)ANDNOTPEEK(16952))+SGN(PEEK(2)ANDNOTPEEK(16947))

6 RESET(X,Y):X=X+A:X=X-(X<0)+(X>63):Y=Y+B:Y=Y-(Y<0)+(Y>19):SET(X,Y,5)

7 IFPOINT(I(T),J(T))=5THENSOUND1,1:S=S+1:GOTO0

8 T=RND(5):I(T)=I(T)+D(T):J(T)=J(T)+1:IFPOINT(I(T),J(T))>1THENH=H+1:GOTO

9 SET(I(T),J(T),0):?@508,H;:ON-(H<10)GOTO4:?"SCORE"S;:INPUT"enter";A:RUN

10 REM   1         2         3         4         5         6         7  

11 REM789012345678901234567890123456789012345678901234567890123456789012

12 REM DEFENDER BY JIM GERRIE

12 REM ASCII BASIC GAMER

13 REM 10-LINER CONTEST 2021

14 REM USE A W S AND Z TO

15 REM MOVE WHITE TARGETTING

16 REM CURSOR & PAINT MISSILE

17 REM TO STOP IT. CITY CAN

18 REM ONLY TAKE 10 HITS

You'll notice in line 8 the GOTO has no line number.  I'm taking advantage of the fact that if no line number is provided then Basic assumes line 0, which is the line I want it to go to.  This keeps me under the 72 character limit.

Lines 1-3 are the ASCII characters in strings for the city.  These characters are from the different block characters in the Motorola MC6847 character set, values 128-255.

Line 0 sets random starting points for the incoming missiles.

Lines 4-5 peek the keyboard input buffer so I can get continuous input in 8 directions using the AWSZ keys.  If you hold down two at a time, you can get diagonal motion.

Key Input:

    AW      W       WS

           \      |      /

          A     +    W

            /     |     \ 

    AZ        Z        SZ


Lines 6-9 move the targeting cursor and the missiles.  Line 9 also has the restart instructions for the end of the game.

Enjoy.