1990 · System 3

Last Ninja Remix

This minisite was contributed by air, 64kramsystem. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/last-ninja-remix with me to Gold.

Every area of New York is assembled from small pictures, often more than a hundred of them, drawn one at a time. The lock at the end of the game opens to the time the clock showed when the player finished the fourth level.

01 · The game

Armakuni in New York

Last Ninja Remix is System 3's 1990 reissue of Last Ninja 2. The ninja Armakuni is pulled through time into twentieth-century New York, where he has to find and defeat the shogun Kunitoki. The Remix added an intro, changed some of the graphics and replaced the music with new arrangements by Reyn Ouwehand.

The city is seen from above and to one side. Each of the seven levels (Central Park, The Street, The Sewers, The Basement, The Office, The Mansion and the Final Battle) is a set of areas, one screen each, joined at their edges. Armakuni walks from area to area, fights the enemy waiting in some of them, and picks up the objects he finds, some of which the way ahead needs: Central Park cannot be finished without four of them, nor The Street without two.

Armakuni on the bandstand in Central Park, with the status panel below and to the right
Central Park, the first level. Armakuni stands on the bandstand. The panel at the bottom holds the two energy spirals, the score and the clock; the one on the right shows the weapon he is using and the object he has found.

02 · The tunes

Music: each level's tune arrives with its title card

The music is the remix in the name: a tune for the intro and one for each level but the last, which plays The Mansion's again.

The player runs in the built site, which serves the listings the tunes come from.

Each button runs the tune's own player in the page and plays what it writes to the sound chip through a model of the SID. A level's player and tune are the bytes $4000-$4DFF of its first load; the intro's are $B000-$BC41.

A level's tune sits at $4000 in the level's first load, with its player: a call to $4000 starts it and a call to $4003 plays one frame. The engine's raster interrupt makes that call every frame ($1F0E), and so does the loader while the title card waits for Space or fire ($111D), so the music starts with the title card. The loader turns the volume down before it unpacks the rest of the level. On an NTSC machine the interrupt comes 60 times a second, and the engine skips the call on one frame in six ($1EFB) to keep the tunes at their PAL speed.

The intro's tune has a player of its own at $B000, with different formats for its patterns and instruments. The Mansion and the Final Battle load the same tune, byte for byte.

Each level's tune holds a line of text at $400C, just after the player's first instructions, that the game never reads. Every one credits Reyn Ouwehand with the music and Falco Paul with the player, in different words:

LevelThe text at $400C
Central ParkMUSIC BY R. OUWEHAND AND PLAYER BY F. PAUL
The StreetINCREDIBLE REMIX BY REYN OUWEHAND, PLAYER AND SOUNDS BY FALCO PAUL
The SewersCOOL REMIX BY REYN OUWEHAND AND PLAYER/SOUNDS BY FALCO PAUL
The BasementTHIS TUNE IS COMPOSED BY REYN OUWEHAND! THE PLAYER AND SOUNDS ARE DONE BY FALCO PAUL
The OfficeMUSIC BY REYN OUWEHAND & FALCO PAUL. PLAYER/SOUNDS BY FALCO PAUL
The Mansion, the Final BattleMUSIC COMPOSED BY REYN OUWEHAND WHILE BEING BUGGED BY FALCO, RICHARD & JOHN! PLAYER/SOUNDS BY FALCO

03 · Weapons

One throwing star knocks any enemy down

Armakuni starts with his fists. Central Park hides a staff, a pair of nunchakus in two halves and nine throwing stars, and The Street a sword. Whatever he holds, fire and the stick give the same moves, but each weapon changes how hard a blow lands and how far it reaches.

The blows are drawn in the built site, which serves the listings they come from.

Armakuni's frames are built by a port of ComposeSprites ($BBC0 in Central Park) and timed by a port of AnimationInterpreter ($A802), one game tick to about a fiftieth of a second; the move each button picks comes from a port of InterpretNormalizedControls ($A640). The box is where the enemy's position must be when the blow lands, from a port of TestActorCombatOverlap ($AC7A), and the grey figure is Armakuni's own standing frame at the furthest reach. The blue cross marks his position. The picture beside them is the panel's USING box, drawn by the level's own DrawUiImageRecord ($B411) into the frame of section 04. The cells a picture leaves empty show the screen's background colour, which each area sets: the bandstand's light grey here, the colour of the letters of USING too.

The weapons are four of the game's items, numbered 1 to 4: the sword, the staff, the nunchakus and the shuriken. Space, or the second fire button, picks the next one Armakuni has and shows its picture in the panel's USING box at once ($951B), but not while a star is in flight. The next time he stands still he plays a short animation, and the weapon in his hand ($70) changes at its middle frame (event 1, $AAA4). The game never takes a weapon away. The shuriken's item holds the number of stars left, nine when it is picked up ($C028); each throw takes one, and the last puts Armakuni back to his fists and empties the USING box ($B70B). Space passes over a shuriken with no stars left.

With fire held, the stick picks a move by its direction on the screen, whichever way Armakuni faces (normalized_control_direction, $A69C): up a thrust, right a low thrust, down a kick, left a swing over the shoulder, each struck the way he faces. Without a weapon, or with the shuriken, up, right and left all punch, and with the shuriken right and left also throw a star. Either diagonal up blocks; either diagonal down crouches, the move that picks things up. The game starts the move once the stick has stayed in one direction for 4 ticks, or 8 for a diagonal (player_action_delay_by_heading, $A694).

Each move's animation raises an event on one frame, and only then does the game look for the enemy. The move and the way Armakuni faces give his mode ($6D), and the mode's class with the weapon picks a row of four small tables (combat_horizontal_min, $AD46, and the three after it): the enemy must stand inside them, across and up or down the screen, measured between the two fighters' positions. A hit takes the row's number from the enemy's 44 (player_attack_enemy_damage, $ABBA) and adds ten points for each to the score. An enemy who is blocking, facing the other way, turns it aside ($AD16).

The areas are drawn in the built site, which serves the listings they are drawn from.

Each area is drawn by the level's own renderer, with the objects not yet taken (DrawInactiveObject), as in section 05. The box is the object record's: the position Armakuni must stand at as he takes the weapon (object_record_00, $C0D0 in Central Park, $B9B3 in The Street). Where the box is small he is drawn in it, from his own frames, at the moment the weapon is taken, in front of everything in the area.

Each level's object records list what can be taken in each area: a box Armakuni must stand in, the heading he must face, if any, and the frame of the crouch at which the item is taken (ObjectEngine, $BFC3). The staff and the sword lie in plain sight. The game draws nothing where the shuriken and the halves of the nunchakus are: only the boxes say where they are. Taking either half when the other is already held gives the nunchakus ($C1B0). Every weapon taken adds 500 points. As Armakuni leaves Central Park the game checks for the staff, the nunchakus, the shuriken and one other object, and as he leaves The Street for the sword and one other; without them it asks ARE YOU SURE YOU ARE PREPARED FOR THE NEXT LEVEL (ResolveLevelCompletion, $904F).

With the sword, the staff or the nunchakus the low thrust lands hardest; with bare fists the kick does. The later levels have tables of their own, and their blows are weaker. In The Office and The Mansion a weapon's thrusts and swing take up to 2 less, while punches and kicks take the same. In the Final Battle every blow takes 1 to 3. The tables give what one blow takes from the enemy's 44:

WeaponFire and upFire and rightFire and downFire and left
Central Park, The Street, The Sewers, The Basement
Fists or shuriken2232
Sword5938
Staff3736
Nunchakus5837
The Office, The Mansion
Fists or shuriken2232
Sword4736
Staff3534
Nunchakus4635
The Final Battle
Fists or shuriken1111
Sword2313
Staff2313
Nunchakus2313

The reach is the same in every level. The staff reaches furthest, but both its thrusts miss an enemy closer than 18 pixels. The distances below are across the screen, in the sprites' pixels, from Armakuni's position to the enemy's when he faces right; facing left, the game measures them 2 pixels shorter ($ACA2):

WeaponFire and upFire and rightFire and downFire and left
Fists or shuriken9 to 229 to 229 to 229 to 22
Sword14 to 3714 to 389 to 229 to 32
Staff20 to 4518 to 479 to 2210 to 39
Nunchakus15 to 3516 to 389 to 2210 to 31

A star thrown with the shuriken flies on by itself, and when it reaches an enemy it takes 44, his whole spiral, in every level (UpdateProjectiles, $B8B9): one star knocks him down, unless he is already down or somersaulting. Only one star flies at a time ($B6E0).

04 · The screen

A window for the city, framed by the status panel

The whole screen is one multicolour bitmap, in the same mode from top to bottom. The game draws each area into a window of 30 by 18 cells at the top left. The rest is the status panel, which arrives with the engine and stays in memory through every level.

Press a part of the screen above.

One frame of Central Park, drawn here by the site's renderer from the bitmap at $2000, the screen colours at $0400, colour RAM and the sprites. The game changes none of the video chip's registers while the frame is drawn.

05 · Drawing an area

An area is drawn one small picture at a time

A level stores no finished screens. Each area is a scene: a list of pieces, each placed at a column and a row, and each either a small picture or another scene. The level's renderer walks that tree and draws every picture into the window at its place. The slider replays the drawing of one area.

The areas are drawn in the built site, which serves the listings they are drawn from.

The level's own renderer runs in the page and stops at each call of RenderUiSceneRecord ($8B49 in Central Park), which draws one picture. A picture's record starts with its size, the width in cells in the high four bits and the height in the low four, then the eight bitmap bytes of every cell, the screen colours of every cell and the colour RAM byte of every cell, each kind in a block of its own. The outline is the box that size gives at the picture's column and row: in the 13,297 pictures the areas of the seven levels draw, not one pixel falls outside its box.

The same picture is often drawn many times in one area: a stretch of railing, a paving stone, a brick. A composite scene can also swap colours as it places its pieces, and draw them mirrored, so one set of pictures furnishes several areas. Some pictures leave the window unchanged, because they lie outside it or are drawn over pixels that were already the same.

Every area of every level, as the level starts, is on the Levels tab.

06 · The levels

A level is unpacked behind its title card

Each level is one packed file on the disk, which the engine's loader unpacks backwards, from the end, in two pieces. The first is the title card and the tune; the second, unpacked after the player presses Space or fire, is the level itself.

Each card is drawn in the page by the level's own DrawTitleCard ($4E00 in every first load), over the engine's memory. The panel is the engine's, coloured from the copy of colour RAM it keeps at $0800. The panel here shows what a new game starts with. On a later card it shows the score, the clock and the energy of the game played to reach it.

The first piece ends at $4E00, and the loader calls that address as soon as the piece is in ($1108). The routine there clears the window and draws the level's picture and name with a small copy of the scene renderer and a scene file of its own, beside the panel. The loader then starts the tune and plays it once a frame until Space or fire on either joystick port is pressed ($1113-$112D), turns the volume down and unpacks the second piece, which writes over the card's code.

The second piece holds the level's code, its scenes, its animations, its packed sprites and the pictures for the panel, up to near the top of memory, some of it in the RAM under the chips. The engine keeps pages 0 to 3, which hold the game's variables, at $0C00 during a load and puts them back after. Before level 3 it asks for the disk to be turned over ($172B: INSERT SIDE TWO, PRESS SPACE).

07 · The ninja and his enemies

Sprites with the zeros squeezed out

Armakuni and his enemies are drawn from parts. Each frame of an animation lists packed sprites, which the game unpacks one at a time into a 63-byte buffer and merges, mirrored when the fighter faces the other way, into the hardware sprites not on show.

The sprites are drawn in the built site, which serves the listing they come from.

a run of zeros$68 and a byte taken as it isa byte as it is

Central Park's 242 packed sprites: the 162 of the main pool (SpriteSourcePointers, $CE54) and the 40 of each of the two groups of extra pictures some enemies' figures are drawn with ($E979 and $F1B2). The unpacker on this page is ported from DecodeSpriteMaskRle63 ($BF3F).

Most of a sprite is empty, so the packing removes zeros. A byte from $69 to $6F stands for a run of one to seven zero bytes. A $68 says that the byte after it is to be copied as it is, which lets a sprite hold a byte from $68 to $6F of its own. Every other byte is copied as it is. Packed, the main pool takes 6,544 bytes, where its 162 sprites take 10,206 unpacked.

In the frame in section 04, Armakuni is three of the machine's eight sprites: two black ones, one above the other, and a third laid over the upper one that adds a few light red pixels.

The Graphics tab puts the parts together: every figure each level draws, Armakuni's, his enemies' and the level's own, moving as the game moves it.

08 · The enemy's energy

A beaten enemy gets its strength back while the player is away

Each area remembers when its enemy was knocked down. When Armakuni comes back, the game gives the enemy back energy for the time that has passed: none for the first two seconds, then a half-cell of the spiral for every 32 ticks of the game's clock, and the whole spiral after about 29 seconds.

The spiral is drawn in the built site, which serves the listings it comes from.

The energy is worked out by a port of RebuildEnemyMeterFromElapsedTicks ($B3D6), and the spiral coloured as the engine's interrupt leaves it ($1E69-$1EBA), in the panel of the frame in section 04.

When the enemy's energy reaches zero, DamageEnemy ($B568) keeps where it fell and the game's tick, the 16-bit count at $F0:$E2 that CIA 1's timer advances about 50.6 times a second, in tables with an entry for each area ($0175 and $0187). On entering an area whose enemy is down but will get up again, the game takes the ticks since then, counted round 65,536, divides them by 32 and takes away 2, keeping the result between 0 and 44 ($8F0B).

An enemy gets up only so many times. Each area's entry in the enemy tables gives, in its high four bits, how many knock-downs put its enemy down for good (enemy_heading_profile, $B6B5, read at $B641); DamageEnemy counts them in the area's byte at $012D, and at the last one marks the area $FF, an enemy that no longer comes back, and adds to the score a second time. The number rises level by level, and in the Final Battle, where it is 15, the game never puts an enemy down for good ($B5A5):

LevelKnock-downs before an enemy stays down
Central Park2, and 1 for the enemy of area 2
The Street3, and 4 for the enemies of areas 16 and 17
The Sewers4
The Basement5
The Office6
The Mansion7
The Final BattleEvery enemy gets up again

The spiral itself is 22 screen cells running in from the corner (enemy_energy_spiral_cells, $1D4B). Each cell is lit in two halves: the first 22 steps colour one half of each cell in turn, in brown, and the next 22 go round again adding the other half in orange. The raster interrupt moves the spiral one step toward the enemy's energy every other tick, so it grows and shrinks rather than jumps. The player's spiral is the same, mirrored, in red and light red.

09 · Controls

A second fire button picks weapons without the keyboard

The game reads a joystick in port 2 and a few keys. It also reads a second fire button, wired as on the three-button pad of Commodore's C64GS console, which picks weapons and objects without the keyboard.

ControlWhat it doesWhere
Joystick in port 2Armakuni's moves; the stick's five bits go into bits 0 to 4 of $7C$9418
Second buttonThe next weapon; with fire held as well, the next object$951B, $9497
SpaceThe next weapon$951B
F1Sound off and on$1EEA
F3, F5Step through the objects
F7Pause$02B7
JTurns the stick's directions through an eighth of a turn, in three settings, shown as MODE where the score is$03F3, $A50D
RUN/STOPArmakuni dies$0267

The second button is read from port 2's paddle line: the game sets $DC00 to select that port's paddles and reads $D419, where a value below $80 means pressed. Whichever button the player presses to start a level, at the credits card that opens it and comes back after a GAME OVER, becomes the fire button: if it was the second one, the game sets $AC ($8EE8-$8EF9) and from then on swaps the two buttons whenever only one of them is down.

Each press of J turns the meaning of the stick by an eighth of a turn, so that pushing up walks Armakuni in another of the city's directions than straight up the screen. The setting, 0 to 2, goes into $03F3 and is added to his heading ($A50D). The joystick also hides a way to end any level at once, which Discoveries walks through.

10 · The last lock

The code for the last door is read from the clock

The Final Battle's lock asks for four digits. They are the minutes and seconds the clock showed when the player finished The Basement, and The Office shows them on a note for anyone who picks it up.

The code is worked out in the built site, which serves the listings it comes from.

----

The code comes from the engine's clock by a port of CopyClockToCode ($B9B2 in The Basement).

The clock is three text records in the engine, hours, minutes and seconds, each digit kept as the number of its glyph. As The Basement ends, after its items and score are saved, the level copies the minutes' and seconds' glyphs into the four bytes of the lock code at $0297-$029A. The clock keeps running and is carried into the next level, so the code is the time at that one moment.

The Office prints the code in the panel's second box when Armakuni picks up the object in its area 3 (ObjectShowCode, $B8EF). A GAME OVER in The Office copies the clock into the code again ($B922), so a code noted before it no longer opens the lock. In the Final Battle the lock shows four zeros in the same box and stops the game while the player sets them with the joystick, left and right to move between digits and up and down to change one; with all four set it compares them with the code (EnterCodeCheck, $B381). A new game starts the code at 1111 ($0EAF), before any level has set it.