1988 · Blade Software

Laser Squad

This minisite was contributed by air. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/spectrum/laser-squad with me to Gold.

A squad game in which every step, turn and shot is paid for in action points, on maps of 4,000 squares loaded from tape, against a computer player each scenario carries its own copy of.

01 · The game

One engine, five battles loaded from tape

The shop before The Assassins: the assassin squad's five men, each with an M4000 auto-gun, and 150 credits to spendA turn in The Assassins: the view of the house, with the readout of the square under the cursor at the right

Two sides take turns on a map of 80 squares by 50. In each turn a side moves all of its units, one at a time, and every step, turn, shot and door costs the unit action points from an allowance that comes back at the start of the side's next turn. The game ends when a side reaches 100 victory points, which come from killing enemies and from whatever the scenario values, or when the last turn has been played.

The program on the tape is the engine: the rules, the drawing, the menus and the shop, 22,521 bytes at $5E28. Each battle is a scenario of 18,911 bytes loaded on top of it at $B621: its map, its units, its terrain and its messages, and its own code. Every scenario carries its own copy of the computer player, with changes for its battle, and eight hooks at its start that the engine calls at fixed moments, where a scenario adds its lifts, its prisoners, its terminals and its reinforcements.

Before a battle each side spends credits on armour and weapons for its units in the shop, and places them on the squares its scenario marks for it. The Maps tab has every scenario's map, its squares for placing and its units.

02 · The view

The map is one byte a square, and the screen shows 121 of them

Pick a scenario and drag the view, or use the arrows. Point at a square to read it. Every scenario's whole map is on the Maps tab.

Point at a square.

The view drawn by the Play tab's port of drawView ($612A) on the scenario as the tape loads it, before any unit is placed. Fire mode draws through the scenario's second table of squares, as the game does while a unit aims.

The map is 4,000 bytes at $D6BF, a byte for each square, 80 to a row. A byte below $6E is terrain, from $6E to $8B an object lying there, and from $8C to $9F one of the scenario's 20 units. Each byte has two bytes in the scenario's table of squares: its colours and its tile. A tile is 16 pixels by 16, two character cells by two, so each square has its own colours and nothing on the map ever clashes.

The name of every square comes from the same number. The scenario's messages are a list, and the name of map byte n is message n + 1 of it, which is how the readout beside the view in the game says WALL, BUSH or CORPORAL JONLAN under the cursor. A message is mostly the numbers of words in a dictionary the scenario carries, so WALL AND CABINET is four bytes: three words and a new line.

Fire mode swaps in a second table of squares at $E79F, which draws the map as a plan: walls as thin lines, trees, plants and furniture as round blobs, floors bare, and each unit as a blob, so the line of a shot shows against plain ground. The units stand on the map the same way in both: as their own byte, in place of the floor, which the unit's record keeps until it moves off. Every unit's tiles, in all eight facings and with each thing it can hold, are on the Graphics tab, with every other tile each scenario carries.

03 · Sound effects

Sound: thirteen effects from ten bytes each

Press an effect to hear it. There is no music: the game has thirteen effects, all on the beeper.

Pick an effect.

Each effect is the Play tab's port of sound ($B5BE), run when the button is pressed: its writes to port $FE at the T-states the game's loops take, played by the site's model of the beeper. The line above is the beeper's level over the whole effect. What plays each one is read from the code.

One routine makes every sound. sound copies the effect's ten bytes from the table at $B531 and playSound plays them: four tones, each a wait of its pitch byte and then a click of the speaker, round and round for the number of passes, and the whole repeated the number of times, with each pitch moved on by its own step after each time. A step of 0 holds a note.

The interrupts are off for the whole game, so nothing else happens while an effect plays. A shot's flight has a sound of its own, clicks that come closer together as it goes, with noise from the refresh register.

04 · Action points

Every step is priced by the ground and by who walks on it

A unit's action points come back at the start of its side's turn: its own allowance, less what its load costs, less a share for its wounds and its armour. The load costs half the allowance times the weight carried over the unit's strength, so a load as heavy as the unit is strong takes half its points. A unit that spent more than half its points last turn loses stamina, one that rested gets it back, and under 32 stamina it moves on half its points.

A step costs the ground's price for the unit's kind, plus the price of an object lying there, plus 2 for a diagonal, and the lot doubled for a step backwards; a turn of an eighth costs 1. Each terrain's record in the scenario has three prices, one for each kind of mover, and 255 means the kind cannot go there. In Paradise Valley the three kinds are the troopers, the Sectoids and Venomous Splurges, and the Water Dwellers:

Paradise Valley's groundTroopersSectoids, SplurgesWater Dwellers
Ground444
Water864
River bank44cannot
Marsh84cannot
Big bushcannot6cannot
Little bushcannot5cannot

Bytes 0 to 2 of each terrain's twelve at the scenario's table of terrain ($B726 points to it), read by stepCost ($6EBF) with the unit's byte $04.

The menus charge a share of the unit's whole allowance rather than a fixed price, so a slow unit pays fewer points for the same job. divRound works the share out, rounding to the nearest.

ActionPrice
Open or close a door, prime a grenadea fifth of the allowance
Lock or unlock a door, change what is in the hands, pick upa quarter (a half to pick up with the hands full)
Dropa tenth
Reloada half
Firethe weapon's own price for each kind of shot

05 · Blasts

A blast is eleven squares wide and loses strength at every square

Pick what goes off, then click a square of the view. It goes off as the game shows it, with its sound, and then the numbers are the strength that reached each square; yellow is the whole of it.

The Play tab's port of explode ($9696) run whole on the scenario's map, then the fires it lit, as the game sets off a primed grenade: a picture of the view each time the game's clock has moved on a frame, played at that rate with the routine's writes to the beeper, and the table of strengths it fills at $5B00 caught before the first square takes its blow. The view is where the game puts it, centred on the blast; the squares left without a number got nothing. Blasts add up until Start again.

An explosion has the strength of what went off: 90 for an AP50 grenade, 160 for a rocket or an AP75 grenade, 170 for the miners' explosive. explode sets out a box five squares each way from the centre, cut at the map's edges, and draws a line from the centre to every square of the box's edge (blastRay, $980E). Along each line the strength falls by two sixteenths of the blast's own strength at every straight step and three sixteenths at every diagonal one, and each square it crosses takes a toll as well, its terrain's byte $05. A square keeps the most that reached it by any line.

Then every square of the box takes the blow of its number. Terrain breaks when the blow is at least its byte $03, into the terrain its byte $04 names, and goes on breaking while the blow lasts. A wall in The Assassins needs 120 and takes 120 off a blast that crosses it, so a grenade cannot break one and nothing of it reaches the room behind; a rocket can. Terrain whose byte $08 is 7, a vidi-screen or a control console, catches fire as it breaks, and the fire goes off after the blast as a blast of its own. The first unit standing on a square is hurt through its armour, and an object lying there is destroyed by a blow of at least its kind's byte $11. A primed grenade goes off at the end of the half-turn its timer names, where it lies or wherever its carrier has walked to.

06 · The computer player

The computer walks the map by waypoints, and gives up on long routes

Pick a waypoint, then another: the scenario's own route search runs between them.

The map, darkened, with the scenario's areas (white rectangles), waypoints (dots) and the links between them (cyan), read from its tables as the computer reads them. The route is the scenario's own findRoute, ported, run on them.

The computer does not see the map square by square. Each scenario cuts its map into rectangular areas and strews it with waypoints, up to 94 of them, each with a list of links to its neighbours and what each link costs. When one of the computer's units hunts an enemy it has seen, it takes the waypoints from which that enemy can be seen, searches for the cheapest route to each from the waypoint nearest itself, and walks the cheapest. A route is kept as at most ten waypoints.

findRoute tries every route link by link, deepest first, and abandons one as soon as it costs more than the best so far. The first "best so far" is not a route at all: it is the cost the scenario's table of areas gives between the two waypoints' areas, or 25 when they share one, and a route dearer than that is never kept.

Three scenarios also stop the search at a depth: Rescue from the Mines tries no route of more than 9 links, The Cyber Hordes 15 and Paradise Valley 20. In Rescue from the Mines that limit leaves 1,858 of the 8,742 pairs of waypoints with no route at all, one in five. Paradise Valley's map is two maps, the valley and the caves under it, and no link joins a waypoint of one to a waypoint of the other, so the computer's units never plan a way between them.

07 · Random numbers

The dice read the whole of memory

Every chance in the game, a shot, a blow, a morale test, a scatter, goes through random ($80B1). It adds three things: the Z80's refresh register R, which counts the instructions the processor has fetched; the byte at a pointer that moves on one byte each time and walks through the whole of memory, the ROM, the screen and the game's own code included; and a count of how long the game has spent waiting for a key. The sum is tried again until it is below the limit asked for.

The count of the waits is the player's part. Each turn of the loops that wait for a key or for fire to be let go adds one to it, so the moment a player presses a key changes every number that follows.