Sunday, November 22, 2015

NES Gameplay Trilogies

There are certain games, that while they are not part of an official series, in many respects could have been.  In these cases, the gameplay across the three games is similar.  In this blog entry I will identify groups of games which I believe share certain gameplay traits that make them an unofficial trilogy.

Gradius - Lifeforce - Jackal


All three of these games were developed by Konami and encompass what I call the Konami Shooter Trilogy.  Unlike Japan, the US did not receive a version of Gradius 2 or Parodius, but Europe never saw Jackal either.  I note that Stinger was also released by Konami, but while it is a fine game in its own right I do not consider it to be in the same league in terms of popularity or adolescent-focused pure shooting action as these games.


All three of these games began life as arcade machines.  Gradius received a very faithful Arcade-to-NES port, although it lacks a bit in the flash and polish department. Jackal is also arcade-faithful as well, but Konami truly excelled here at bringing the fast-paced destruction of this game to the less capable hardware of the NES.  Nothing essential is lost in porting.  In fact, the game is substantially  improved by end-level bosses and level transitions.  As I mentioned elsewhere, Life Force is in certain respects a better game than its arcade original, Salamander.


Of course, I cannot go without mentioning the two player simultaneous gameplay of Jackal and Life Force. Two-player simultaneous gameplay was somewhat uncommon in the days of the NES due to the hardware limitations.  64 sprites get used up very quickly, and the 8 sprites per line limitation of the NES leads to flickering very quickly.  Konami was one of the few developers who consistently could do it right with Jackal, Life Force, Contra and Super C.

Zanac - The Guardian Legend - Gun+Nac

Here we have the Compile Shooter Trilogy.  Zanac and GunNac (note the similarity of the names) are similar in that their basic gameplay model is that of the vertical shooter.  The Guardian Legend combines vertical shooting stages with exploration-style bird's eye view stages like The Legend of Zelda.


Zanac has three principal strengths.  First, it has a wide variety of powerups (eight) that have their own strengths and weaknesses.  Second, it has very solid gameplay, especially for a somewhat early title.  It is a fairly fast paced game, the controls are very responsive, rapid fire is present.  Even though it lacks varied bosses, it feels very modern.  The graphics are good and the music is excellent.  Third, the game adapts itself to the power ups you choose and reportedly your skill level.  It is not simply a randomizer, the game will behave in somewhat predictable ways, in terms of the enemies it will throw at you, based on the active weapon powerup you possess.  This mechanic makes it never quite the same game twice. You can continue at the last area by pressing start and select at the same time on the title screen (this is in the manual).


The Guardian Legend tweaks the formula quite a bit by adding overhead exploration.  You collect chips to buy items from the Blue Landers, fight bosses in special rooms and collect keys to open "corridors" to vertical shooting stages.  Your character is not just a ship but a female android (which the US version took some pains to obfuscate).  It has a password feature for restoring your game, and it is pretty long by NES standards.  There are several themes to individual areas, like water, plants and mountains, and the graphics change accordingly.  The music is some of the best on the NES.  Shooting stage bosses are varied and some are really tough (blue Optomon will make you throw your controller against the TV screen) and others are much more reasonable (even the red Clawbot and Bombarder are reasonable).  Finally, you gain many weapons and you can switch between them as often as you like, but you use up chips by using them.  Fortunately, the game is fairly generous with supplying you with chips and health items when you need them.  By inputting the password TGL, you can play the game as a straight shooter.


Gun+Nac is as to Zanac as Parodius is as to Gradius.  Unfortunately, Gun+Nac is not as well-known as it deserves to be because it was released rather late in the NES's lifespan.  Gun+Nac plays like Zanac with more powerups.  You still collect the Compile "P" chips, but you also collect money so you can upgrade your ship and buy extra lives during the levels.  GunNac is cute and goofy with rabbit and cat enemies, but do not let that fool you into thinking the game is a cakewalk, it is not.  Graphics and sound are excellent.

Golgo 13: Top Secret Episode - The Mafat Conspiracy -  WURM: Journey to the Center of the Earth







Golgo 13 and its sequel the Mafat Conspiracy are a logical choices because they use the Golgo-13 character, but WURM?  It is not as far fetched as you think.  Golgo 13 advertised multiple styles of play.  First, there are side-scrolling areas with some platform (enemy bases) and some free form (underwater) elements like Super Mario Bros.  Second, there are first person, 360 degree mode instances where you have to kill all the enemies that are ambushing you. Third, there are horizontal shooter stages when you fly a helicopter. Fourth, there are first person maze stages with traps, items and enemies to shoot.  Finally, there are dialogue and cinematic sequences when you charm the ladies.






The Mafat Conspiracy has more of the same, mostly.  In exchange for the horizontal shooting mode, you get a driving mode that looks very close to Rad Racer.  There is also a more involved sniping mode and the game is much more cinematic overall.  The mazes are still as annoying as hell, but in the manuals for both games there are maps.  Also, the platforming stages are still a bit stiff in terms of your character's control scheme but there have been some improvements from the first game.  One big one is that now button B shoots and button A jumps, it was swapped for Golgo 13.






WURM shares the jack-of-all-trades gameplay style of the Golgo-13 games.  It starts you out with a horizontal shooter stage.  You will see more than one of these and your vehicle has and can acquire several different abilities and powerups.   Second, you will have a 360 degree first person mode where you fight boss monsters.  Third, you will explore various areas as Moby in side-scrolling stages.  Moby has a gun and can kick and she controls very similarly to Golgo-13.  Like Golgo-13, the enemies on these stages are not known for their variety.  Fourth comes vertical shooter stages, which are a bit more rudimentary than the horizontal stages.  Fifth, there are also cinematic cutscenes, but these suffer from a lot of repetition in terms of dialogue and artwork.  You also have dialogue during boss fights.  Similarly to Golgo-13, you can also engage in dialogue during the side-scrolling stages.

Golgo 13 and WURM share the same designer, Shoichi Yoshikawa, and he acknowledges that he took inspiration from the earlier game.  He even made a direct reference by including the "G-13" robot in the game.   However, WURM has an unfinished feel to it that cannot be said for the Golgo-13 games.

Friday, November 20, 2015

Arkanoid and Arkanoid Again

Arkanoid, that timeless classic from Taito, breathed new life into the Breakout-style of gameplay.  It was ported to the IBM PC compatible platform by Novalogic for Taito in 1988.  What I did not know was that this Novalogic port was based off an earlier port by Imagine.

Imagine was a British software developer in the mid 1980s that went bankrupt.  Ocean Software bought the name and used it on a label for several arcade game ports.  This port of Arkanoid is the only PC port I am aware of which used the Imagine label.  This port was released in 1987.  This PC port was ported from the more colorful ZX Spectrum version, which may be why the Imagine label was left on it.  It only supports CGA graphics and keyboard controls.

Taito had Novalogic port the game again with the mandate to include better hardware support.  Novalogic did not start from scratch, as you will see.  They upgraded the graphics to 16-color EGA and Tandy support,  which required redoing the CGA graphics.  They also included mouse and joystick support and Tandy 3-voice support for music.  Sound effects were still PC Speaker based.

If you compare screenshots of the Imagine and Taito versions, you will see many, many similarities.  Let's start with the Imagine version of Arkanoid :






Now let us compare the CGA graphics of Taito's version :




And here are the customary 16-color graphics for reference :






Both disks are copy protected, but in very different ways.  Taito's executable protected with the Softguard protection.  The executable is encrypted and the loader program makes multiple checks for errors on a track of the disk, then if it is sufficiently satisfied that the errors exist, it will decrypt and run the real executable. Imagine's disk appears as a 180KB single sided disk but is really a double sided disk.  The executable is located on the second side of the disk.  DOS cannot see or execute the executable, but the game's loader reads the data directly through Int 13h read sector commands.  

The Imagine port uses tweaked PC speaker music to get more than one voice out of the PC speaker.  The Taito port uses simple PC speaker music.  The Taito 3-voice music is not particularly more complex or impressive compared to the PC speaker music.  However, unlike the Imagine port, the Taito port is not quite as speed sensitive.  It is almost certain that the Imagine port was developed on or for an Amstrad PC-1512, which uses an 8MHz 8086 and a built-in enhanced CGA graphics adapter.  Both versions quit the game by pressing Esc, then Q, which is weird for PC games but not so much for the small keyboard of the ZX Spectrum.

While neither port will win any prizes for "Best Port of Arkanoid", Taito's version is the better version.  Although it only gives you 3 lives to Imagine's 5, the control responsiveness from the mouse, the joystick or even the keyboard of the Taito version is far superior to the keyboard controls of the Imagine version.  The Imagine's paddle will frequently jerk to the left or the right when you change direction instead of giving a proper smooth movement.  The hit detection between the ball and paddle is more consistent in the Taito version.  Finally, the Imagine version does not seem to have the enemies appear from the top of the screen.  I could not see them in the first two rounds.  Note that the best joystick for the Taito version is one where you can turn the self-centering off, as you can on the boxy Kraft or Tandy Deluxe joysticks.

The real Arkanoid in the arcades used a "spinner", which is a rotary dial.  A rotary dial works by phase shifted quadrature encoding.  There are a pair of optical sensors on either side of a wheel with spokes and holes.  There is an invisible beam between the optical sensors, which are positioned off center from each other.  When the wheel is turned one way, the optical sensor sends a signal.  When it is turned the other way, it sends a mirror image of that signal.  The signal is made up of 1s and 0s sent in a waveform out of phase with each other, and the signal that goes from low to high or high to low first determines the direction.  

The rotary encoder used by Arkanoid was a huge improvement over the resistor capacitor design of older paddle control knobs.  The resistor/capacitor scheme was never especially accurate because it relied on the tolerances of the passive components which could very widely.  Moveover, a potentiometer in a paddle does not have a 360 degree range of movement.  A rotary encoder put out a pure digital signal, the only analog element of the design was how fast the player twisted the knob.  

Your standard ball mouse uses two rotary controllers.  It is by far the closest control to an arcade Arkanoid cabinet as you can get on the PC without buying a MAME controller.  Most MAME controllers are USB based these days, and classic computers tend to be rather incompatible with USB controllers.  

I thought of adapting an Atari 2600 driving controller to a PC mouse interface, because it is essentially half of a mouse.  However, the driving controller puts out a pure quadrature signal.  Serial mice collect the quadrature signals from the movement and the button presses with a microcontroller built into the mouse and send them out in byte-packets to the serial port.  A bus mouse interface like the Microsoft InPort interface may be possible because it accepts quadrature signals from the mouse and has the microcontroller on a PC card.  But an Atari 2600 driving controller only has 16 positions in a complete revolution while your average comptuer mouse has double the number of positions.  The 2600 controller would not be sufficiently fine tuned for games that expect a mouse like Arkanoid and Arkanoid 2: Revenge of DOH, or Cyberball Plus.  

The Imagine version of Arkanoid that has been given to me to write about came on a compilation package called  "La Collection Amstrad PC."  This Collection contains four titles distributed by U.S. Gold: World Class Leader Board from Access Software, World Games from Epyx, Arkanoid (originally from Taito) and "Super Tennis".  "Super Tennis" shares the disk with Arkanoid and boots to this menu :


I know World Class Leader Board and World Games well enough because they came from U.S. companies, but I was not immediately familiar with "Super Tennis".  "Super Tennis" uses French in game and only supports CGA and PC Speaker.  Fortunately its limited hardware selection made it easy enough to track its source, which is Tournament Tennis, originally from Imagic and originally in English. Tournament Tennis has some support for CGA composite color graphics, which would have been unheard of for a European developed title, which cannot support CGA composite graphics because of the lack of NTSC monitors.  Like Arkanoid, Super Tennis appears to be speed adjusted for an 8MHz 8086 machine.  

Here are some screenshots games from Super Tennis :






And here are screenshots from Tournament Tennis as translated into French :



Thursday, November 19, 2015

Atari Hardware Explained

The Atari 2600 is a very compact system, even though this may not be reflected in the standard woodgrain case in which it is housed.  Inside each system are three chips, the CPU, the Television Interface Adapter (TIA) and the RAM, Input, Output & Timer (RIOT).  These three chips work together along with a cartridge, switches and a controller to display games to a TV.  Lets discuss how the design of these chips influences the games that were produced.

CPU

First, lets start with the CPU, which is a MOS 6507 (a.k.a. C010745).  The 6507 is a budget version of the 6502 an in the Atari 2600 it runs at 1.19MHz (1/3 of the NTSC color clock frequency).  It is a fully-functional 6502 in a 28-pin package.  The full 6502 comes in a 40-pin package.  As a result of the size reduction there is no support for hardware interrupts and the 6507 only has 13 (of a maximum of 16) address lines.  This limits the amount of addressable memory that the CPU can access directly to 8KB (kilobytes).  Unlike the NES's 6502 variant, the 6507 has a functional binary-coded decimal mode.  The TIA is connected to the CPU's RDY line, so it can halt the processor.

RIOT

Next comes the RIOT chip, which is an MOS 6532 Peripheral Interface Adapter (a.k.a. C010750).  This 40-pin chip contains a programmable timer, 128 bytes of RAM and two 8-bit parallel input and output ports.  It has 9 registers, some of which are read only, some write and some can do both.  The timer counts down an 8-bit value by one of four orders of magnitude.  128 bytes of RAM substantially limits the complexity of games because that is where all a program's variables must live.  In addition, this RAM is also used by the stack.  The stack is vital for subroutines, which can be many in a game.  On the plus side, the RAM is located in the 6507's zero page, so accessing it will be fast.

One of the I/O ports is exclusively used for input from the five switches on the console, one bit for each switch.  Each bit of the second I/O port can be set to be an input or an output.  As an input, it reads the four directions from each joystick (one direction per bit), the paddle button from each of the four paddles or the position of the driving controller.  As an output, it strobes the keyboard controllers.  This I/O port can also be used to write to and read from more modern port peripherals like the AtariVox.

TIA - Input and Sound

Finally we come to the TIA, the most complex chip in the system.  This is a custom 40-pin Atari chip C010444D which Atari strangely never got around to patenting, leading to cloned chips from Mattel and Coleco later in the 2600's life.  It was never an off-the-shelf chip, unlike the 6507 and 6532.  The TIA handles all graphics and interfacing with the TV, all sound and handles the remainder of the inputs.  It is also mapped into the zero page of the 2600's memory map.  It contains 45 write-only registers and 14 read-only registers.  Let's discuss its features in inverse order of complexity.

The TIA has four input ports, each dedicated to the input from a single paddle.  Paddles are read in a way similar to how a joystick is on the IBM PC.  A write to a certain register discharges the a capacitor and the position of a connected potentiomer dictates how long it takes to charge the capacitor.  The length of time it takes the capacitor to charge dictates the position of the paddle.  These registers also are used to read the keyboard controllers.  Essentially the keyboard controllers act like paddles set to a specified resistance value.  It also has two ports for reading the state of the joystick switches or the driving controller buttons.

Sound on the 2600 is geared more toward creating interesting sound effect than music.  Each of the two audio channels can emit a pure square wave tone, but there are only five bits to divide the frequency. The range of the 2600 is from 30,000Hz (divide by 1) to 937.5Hz (divide by 32).  Even the less than impressive TI SN 76489/96 has 11-bits of frequency control.  There are 4-bits of volume control, but the 2600 is just not very musical.  Even so, some games like Gyruss, Mountain King and Supercharger Frogger have impressive music.  The noise is based off a polynomial counter tweaked by various settings. There are 16 combinations (10 unique) of tone and noise to choose from in the 2600, and they are much more geared to sound effects.  You can hear what each selection and frequency sounds like here : http://www.randomterrain.com/atari-2600-memories-batari-basic-music-toy.html

TIA - Graphics

Most of the CPU's time is spent drawing the graphics, line by line.  The 2600 does not have a frame buffer and it does not have dedicated video memory.  More modern game consoles write the graphics data into a frame buffer and into sprite memory and let the video display chip take care of drawing it to the screen.

Atari 2600 graphics have to be fed into the TIA each and every line that the TV draws.  Whatever time is left over during horizontal blanking (the time it takes for the TV's electron beam to return from the right side of the screen to the left) is spent on setting up the graphics for the next line.  This is what is called racing the beam.  The vertical blanking period, (the time it takes for the beam to return to the top left portion of the screen from the bottom right) is typically used for game logic, sound and input reading.

The Atari 2600 is capable of displaying 128 colors, 8 of which are solely grayscale from black to white.  The remainder are spread across the NTSC color wheel with a great variety of variation.  The horizontal resolution of the Atari 2600 is always 160 pixels.  The vertical resolution of the Atari 2600 is not fixed but typically is 192 lines.  It is up to the programmer to start the vertical retrace period.

The graphics are made up of seven elements, a background color, a playfield, two players, two missiles and a ball object.  The background and the playfield make up what would be known in later consoles as the background graphics and the player, missile and ball objects would later be known as the sprite graphics.

Combat - Note the reflected playfield and the two players.  Each player fires a missle with the same color
The background color a single color that is set for the entire TV area, unless changed on a particular scanline.  When the color is changed it can be masked by the playfield.  Air-Sea Battle has frequent changes of the background color.

The playfield consists of 20 bits per line.  If a bit is on, the playfield color is displayed.  If the color is off, then the background color is displayed.  Each bit of the playfield is four pixels wide, giving the backgrounds to Atari 2600 games a characteristic low resolution look.  Additionally, those 20-bits only cover the left side of the screen, so the right side of the screen displays a duplicate or a mirror image of the left side of the screen.  This tends to give the backgrounds a symmetrical look in many Atari 2600 games.

Combat - Note the second copy of Player 2, the repeated playfield and that the playfield has priority over the players
When you see counters or scores on the top of the screen, these are usually playfield graphics.  But as I mentioned, there is only enough room in the playfield registers for half the screen, so what happens when one side's 0 turns into a 1?  You can time your writes to the playfield registers in mid scanline so you get a different playfield on the right side as opposed to the left side.  You can also set the colors of each side to the colors of the player 1 and player 2 objects.

Video Olympics - The ball object is used, and the scores are playfield bits changed in midscanline
The ball object is a one pixel object that can be placed anywhere on a scanline.  It uses the same color as the playfield on the same scanline.  The ball was intended to make Pong games like Video Olympics possible on the 2600.

The player objects are up to eight pixels wide, with a 1 bit showing the player color and a 0 bit showing a background or playfield color.  Two players, two colors.  Each player has a one pixel missile object associated with it which is the same color as the player.  Each player and missle object can also be placed anywhere on a scanline.  Multi-colored objects are accomplished by changing the color of the player object each line.  These graphics are best suited for Tank-line games like Combat.

Space Invaders - The player cannon is stretched, and each invader is a player copied twice, the copy is removed when shot
Ball and missile objects can be stretched to 2, 4 or 8 pixels.  Each player object can have one or two additional copies spaced at set intervals.  This is what makes Space Invaders possible.  The player can be stretched 2x or 3x horizontally and be reflected (to face left instead of right).  Players and missiles are typically displayed over the playfield graphics, but can be set to have the playfield graphics displayed over them.

In many games like Space Invaders and Ms. Pac Man, you will see a serrated series of lines across the left border of the screen.  These lines are used to delay the start of the graphics drawing, giving the programmer more time to write graphics to the next line.  In the 2600, you always have to be one line ahead of the raster. In fact, the standard Activision practice was to blank out the entire left column of the screen for 8 pixels or so.

Pitfall - Player, missile, ball and playfield graphics all combine on various scanlines to make a complex background
In Video Checkers, there are four pieces per row, three of which are provided by a player object and one provided by a stretched missile object.  Lucky for Atari standard checkers is played with a maximum of four pieces per row.  However, the same effect is insufficient for Chess.  Atari used a Venetian Blinds effect used in Video Chess.  This is necessary because each player object can only draw three objects on a line, and you need eight in chess.  So in Video Chess, they alternated the drawing of the chess pieces every other line. This eliminated flickering.  They also had to alter the player graphics in mid-frame in order to make the king's row pieces distinct for each side.

Yar's Revenge - The Neutral Zone is a visual representation of the game's code
Color cycling was one of the hallmarks of Atari graphics, from the Chalice in Adventure to the Neutral Zone in Yar's Revenge.  The color registers are often updated many times per second.  In Yar's Revenge, the bit pattern of the code in ROM was used to give a pseudo-random appearance to the Neutral Zone.  Color cycling was also done for many of the early 2600 games because this was believed to reduce screen burn-in if the TV and the 2600 were left on.

Video Checkers - Each Player has two copies and stretched missiles make up the fourth checker on each row
Scrolling the screen was uncommon on the 2600 because there were no scrolling registers, everything had to be done in software.  Vertical scrolling was easier due to the line-based nature of Atari graphics and because the programmer could tell the TIA when to stop drawing scanlines.  Raiders of the Lost Ark, Jr. Pac-Man and Haunted House all have vertical scrolling.  Horizontal scrolling was a bit trickier, but it could be done.  Mountain King, Stargate/Defender II and Dragonstomper all do it well.

Video Checkers - Each piece is a Player object is staggered compared to the next and drawn every other line.  The background is very large to give the programmer more time to update the individual pixel patterns without flickering
There are hardware collision registers for each combination between the six objects.  Reading a register will tell you if there was an intersection between player 1 and missile 2, for example.  While this saves the programmer from having to determine the collision by having to compare the position values of the two characters, it can also lead to too-strict hit control.  If a missile hit a non-visible player pixel, it will still register a hit.

The Stella emulator can turn on and off each of the objects at will.  If you ever wonder how so few objects can make up the screen, try turning off some.  Collisions can be disabled as well, people tend to use this to cheat.

Cartridges and Memory

Standard Atari 2600 Cartridges contain a 2KB or 4KB ROM chip.  4KB is the maximum amount of ROM the 2600 can address without any bankswitching hardware.  To address more ROM, you had to include additional hardware in the cartridge to handle the swapping.  Most bankswitching schemes reserve certain addresses.  When you write a value to the reserved address, it swaps in another 4KB section of the ROM. Some schemes are more complicated, but this is the general idea.

Asteroids was the first commercially released game to use more than 4KB.  Approximately 20% of Atari 2600 games used more than 4KB of ROM, and almost none used more than 16KB.  However, most Atari 2600 games did not have title screens because they always require precious space in ROM to program.  The title on the cartridge should have been enough for everybody, or so the thinking went.  Also, if you wanted to know what the differences between the various game options are, you have to look in the manual or figure it out through observation.  There was no space for the game itself to explain options.

Some Atari 2600 Cartridges also include additional RAM, usually 128 or 256 bytes.  This RAM is mapped somewhere into the cartridge space and one set of 128 or 256 byte addresses is used for reading and a second set is used for writing.  This is because there is no read/write line sent to the cartridge slot.

The most unique game device for the 2600 was the Starpath Supercharger, which transferred binary data played on cassette tapes to a large cartridge which contained 6KB of RAM and a ADC.  I have discussed this device's operation in more detail elsewhere : http://nerdlypleasures.blogspot.com/2014/06/arcadiastarpath-supercharger-cassette.html

The B&W switch on the 2600 does nothing if the program ignores it.  If the program responds to the B&W switch as it was meant to be used, it will set the graphics to use colors that will show up better on a B&W TV.  B&W TVs only understand the eight levels of luminance the Atari 2600 provides.  However, there is nothing special about the B&W switch or any of the other non-power switches, and the B&W switch was used for other purposes on occasion : http://nerdlypleasures.blogspot.com/2015/03/the-forgotten-switch-atari-2600s-b.html

Enhancements

The TIA contains two audio channels that operate identically but are mixed together outside the chip.  The 2600 was originally planned to be a stereo console with two speakers installed in the 2600's case, but this idea was scrapped as being too costly.  Some of the earliest games (Combat) and a few homebrews (Medieval Mayhem) support stereo audio, but you have to modify your system to hear stereo audio.

The Atari 2600 outputs RF video only, which is less than desirable in the year 2015 for many people.  The chip outputs the color, c-sync and three luminance levels on separate lines.  The luminance levels are mixed and balanced with an R2R network and mixed with the other signals and sent to the RF modulator.  Composite and S-Video mods have existed for years.  However, S-Video is the best you can get from the TIA without substantial additional hardware.

There is an Atari 2600RGB adapter which will provide RGB video. It requires removing the TIA chip and inserting it into a custom board.  The board has an FPGA that will take the values in the color registers and translate them into RGB values.  It will also provide S-Video and Composite Video output.  Because there are only six graphical objects and the background color and four color palettes to keep track of, the FPGA can keep track of this by snooping on writes to these color palette registers.  In order to keep track of the objects as the pixels are displayed, each set of objects is assigned a different black and white palette and intercepts all writes to the palette registers.

Because of the non-standardized method (every game can do it differently) the 2600 uses to indicate that it is time to do vertical blank to the TV, some games may have some trouble when upscaled with an X-RGB Mini Framemeister. The original Warlords is one such game and there is a patch available.