Wednesday, 26 June 2019

"Coup D'Etat" for the Sharp MZ80


The Sharp MZ is a series of personal computers sold in Japan and Europe (particularly Germany and Great Britain) by Sharp beginning in 1978. In a 2017 posting on AtariAge some people were discussing possible games they would like to see ported to TI99. Oracle Jedi made a  few suggestions:
Coup d'Etat - a Sharp MZ80 magazine listing game published back in 1982. Wraithchild was going to take a stab at converting it to the 8-bit Atari.Subspace Striker - a ZX81/VIC20 game from Pixel.
Trader - a three-part "adventure" for the ZX81 and VIC20 - also from Pixel.
Football Manager (the VIC version had no graphics)
Looking forward to trying Oregon Trail when I get my TI out next.
A little searching on the Net didn't turn up any scans of the particular magazine.  However I found an interesting reference in a users magazine for fans of the Sharp 8-bit systems. The magazine had some grainy pictures of the original article, but the details of the listing were unreadable.  However, the author's comments confirmed that the program had been well thought of.


However, I was still no closer to getting a listing. I thought I would try looking for a version of the program possibly converted to another system. The Sharp was a 40 column screen machine, so I thought I would try to see if there had been a Commodore conversion. Sure enough I found a loadable cassette version for the C64. I was able to use WinVice to load it up and print it to a text file.

Now I had the code, but it was obviously, as the Sharp fan went on to note, a "huge" program. The bulk of the listing was taken up with a dozen very detailed full screen character-graphic pictures of the various locations in the simulation ranging from the President's Palace to the TV Station-- Well over 30K. I'd have to bump off over 10K to get it to fit into an MC-10. There was also a very elaborate intro screen with a graphic of a Tank, which would turn its turret to point at the viewer before firing and the display would then switch to a large letters spelling the title. Cutting out all of these pictures and title screen stuff got me down to around 20K. Then I just had to spend a few hours condensing the code, such as taking multiple lines and putting them on one line separated by colons. Distinct line numbers for single commands really eats a lot memory. These old games, typed in using primitive editors, really prevented such efficiencies, since it was so difficult to move code around.  Some of the IF statement lines were also doubled up, probably because the C64 has an 80 character line length, which severely limited what could be done with one IF command. All this got me the space I needed for the variables and arrays used in the program.

I found a number of annoying bugs in the program, such as lines that would never be reached in program flow. For example, there was a funny remark, about your "liberation" of a "case of beer" that was missed. Sometimes this was just because a random number wasn't big enough to trigger all the possibilities in ON/GOTO commands, in other cases, lines were orphaned by the way checks for IF commands occurred. Again, such aspects could easily be lost when one only had easy access to a program via an awkward line editor, which doesn't really allow for a bird's eye view of the code (printouts might... but few would bother continually printing out code as they developed it). However, there was what appeared to be a catastrophic error in the C64 which would prevent one from winning:
389 if(ac=1)*(bz=0)thenprint".....";me$;"been wiped out":goto392
I thought the variable bz was a typo because it was never used anywhere else in the program (I did a search).  It will always contain a zero and therefore trigger the result that "your men" are "wiped out" no matter what happens in your attack on the palace of El Presidente. You could "take" the Palace, but your men would still be wiped out and you would be taken to the losing screen. However, after (finally) getting a copy of the original MZ80 source from Wrathchild on the Atari forums, I discovered that the original source set bz to 1 when you take the barracks and capture a Bazooka.  The Commodore source also sometimes transcribes the "FO" variable for "FD," which means food boxes will not be handled correctly. 

The attack routine also seemed a little messed up. For one thing, there was no difference between the "Capture" and the "Raid" options, except that you wouldn't take control of the site under the Raid option, even if your attack succeeded. I made the RAID option use the same attack routine as assassinate, except you choose the number of soldiers involved rather than a standard 30.  The casualties for both of these types of attack are consistently reported back to their calling routines for the various locations which can be attacked (Bank, Barracks, Police Station, Prison, Palace). There seemed to be an error in the C64 and MZ80 source involving the variable FA for a failed Capture attack. In some cases the variable used in the checks after the return from the attack subroutine was "A" and not "FA." I think this was a typo.


Another apparently incoherent aspect of the code was the management of the various observation towers of the game (see the numbered items in the C64 screenshot above). They were supposed to be attached to specific sites, but the locations didn't seem to match the map, which you occasionally are allowed to view in the game revealing the numbers for each tower. This meant that choosing to destroy a specific tower based on the map wouldn't necessarily aid you in your attacks on a specific location. I thought this was a result of an incompletely implemented system for shuffling the towers locations from game to game. There was an array PT(13) assigned this task, and randomized list of the tower numbers were assigned to it at startup, but then no other major references were made to that array. It turned out after seeing Wrathchild's source file, that I had simply hacked out the complex poke routines attached to the original map. However, this mistake worked to my advantage, as the MC10 version of the map that I made was too crowded to handle possible two digit numbers being displayed next to all the towers by a reshuffling routine. I rejigged the combat routines and other references to towers to use fixed locations of the towers. Your chances of taking a site are reduced if you do not subdue its specific tower.


I was also able to create some simple graphics for each location. Icons really. They're not full screen text graphic wonders like the original, but they get the job done. There were also some simple text graphics displayed when you win and lose: A firing squad for when you lose and you being carried in litter by two lackies, from which you get un-ceremoniously dumped (by mistake I'm sure) when you reach the right side of the screen. Since I was still somewhat pressed for memory I replaced the litter routine with a re-display of the statue of "the leader" displayed when you visit the "Square." The game now concludes with the observation that the statue the people erect to you in gratitude looks a lot like the one for the old El Presidente.

Even with these changes and fixes the game seemed extremely hard to win, so I added a level option and used it to nerf many of the hazards you face and to increase the magnitude of the possible benefits. I have now been able to win on level one (see below). However, this is using my intimate knowledge of the program. I suspect it will be harder for the uninitiated to figure out the optimal strategies needed.  But if you want to play the game like the original author intended, try level 3 but it seems way too hard to me. One benefit I added for all levels, was main menu option to visit the Towers. On any level it is pretty important to blow up towers as you seek to take-over various sites, and the random appearance of the option for attack towers, which only happened when visiting the barracks, were simply too rare in my opinion. So now there are 0-13 options for the main menu, which make for a slightly more balanced menu screen display.


If you view the video at the start of this article, you will notice that I changed the map slightly from my original. This was a result of trying to make it more clear which towers are connected with which specific sites. Unlike the original, I have attached only a single tower to each site.

Hopefully now there is a winnable version of this imaginative type-in  simulation from the early 1980s. My version can be played on-line using the MC-10 Javascript emulator provided by Mike Tinnes (with some additions by Greg Dionne:


P.S. I added some "flag" graphics. When the flag is controlled by the regime, the colour is cyan.  When you take a site over, the flag becomes red. "The workers flag is deepest red!"  Vive la revolution!

P.P.S I added back a "partial shuffling" of the location numbers (the single digit important locations).

No comments:

Post a Comment