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.

The manual says a wounded unit loses morale. The code that would take it is there, and can never run; and a byte that should have been $22 sends the Water Dwellers' charge after the wrong enemy.

01 · Bug

Bug: a wound never costs a unit morale

The manual says morale falls when a unit is wounded. The routine that would lower it is in the game, after a test that always sends the program back.

$8208  3A 98 5D     LD A,($5D98)     ; the damage
$820B  B7           OR A
$820C  C8           RET Z            ; none: done
$820D  DD CB 25 66  BIT 4,(IX+$25)   ; is the unit out of play?
$8211  B7           OR A             ; ... the flags set again, by the damage
$8212  C0           RET NZ           ; always taken: the damage is not 0
$8213  47           LD B,A           ; never reached: B, the damage
$8214  DD 7E 07     LD A,(IX+$07)    ;   the unit's most health
$8217  CD 19 6B     CALL divRound    ;   C = most health / damage
$821A  DD 7E 0C     LD A,(IX+$0C)    ;   its morale
$821D  41           LD B,C
$821E  CD 19 6B     CALL divRound    ;   C = morale / C
$8221  DD 7E 0C     LD A,(IX+$0C)
$8224  91           SUB C
$8225  DD 77 0C     LD (IX+$0C),A    ;   the morale, less C
$8228  C9           RET

The end of takeDamage, after the health has gone down by the damage, from the engine's listing.

BIT 4 sets the zero flag by whether the unit is out of play, and the RET NZ two instructions on was meant to skip the units that are. Between them, OR A sets the flags again, from A, which holds the damage. The damage cannot be 0 there, because the RET Z above has already left on 0, so the zero flag is always clear and every call returns before the morale is touched. The 22 bytes after it, which would take the same share off the unit's morale as the damage took off its most health, are never run.

Morale still moves when units die, on both sides, by the dead unit's morale value. A wounded unit keeps its nerve, however badly it is hurt.

02 · Bug

Bug: the Water Dwellers measure their charge from above the map

In Paradise Valley a Water Dweller that sees enemies runs at one of them. It means to pick the nearest, and a single wrong byte measures from somewhere else. Drag the Water Dweller (W), the player's units (A, B and C) or the red mark on the top edge.

The top 34 rows of Paradise Valley's map, drawn by the Play tab's port, and the scenario's own aiCanGo, ported, run on the pieces as the game runs it in the Water Dweller's turn: the units it can see listed at $5B97, and the column the last measure left at $A54C set by the red mark. The yellow arrow is the unit it runs at, the red dots the measure that chose it, and the green arrow the nearest, which it meant.

$BE56  3E FF        LD A,$FF
$BE58  32 25 BE     LD (CHARGE_D),A  ; the nearest so far: none
$BE5B  06 0A        LD B,$0A         ; ten entries of the enemies in sight
$BE5D  2A 24 5D     LD HL,($5D24)    ; the unit's square
$BE60  32 4B A5     LD ($A54B),A     ; stores A, $FF, where HL was meant
         ...
$BE79  CD 50 A5     CALL distance    ; from ($A54B, $A54C) to the enemy

From Paradise Valley's copy of aiCanGo, from the scenario's listing. $32 is LD (nn),A; $22, one bit away, is LD (nn),HL.

The routine loads the unit's square into HL and then stores A, which still holds the $FF it has just used, in its place. The measure from the unit to each enemy in sight therefore starts from row 255, with the column left over from the last distance the computer measured. distance works in single bytes, so row 255 behaves as row −1, a row above the top edge of the map.

The charge goes to the enemy nearest that point rather than the one nearest the Water Dweller. With one enemy in sight it makes no difference; with two or more, it runs at the one nearest a point just above the map's top row, in the column the computer last measured from, wherever the Water Dweller stands.

03 · Bug

Bug: damaging the scenery raises the morale of whichever side made the last kill

Three scenarios pay victory points for damage to terrain, with a jolt to morale. The jolt goes to the side that made the last kill, not the side that did the damage.

$9201  3A 04 B7     LD A,($B704)     ; does the first side score for damage?
         ...
$920F  AF           XOR A
$9210  32 4D 5D     LD ($5D4D),A     ; the side: 0
$9213  3A 8C 5D     LD A,($5D8C)     ; the damage done
$9216  CD 9E 82     CALL moraleShock ; ... which reads the side from $5DA0
         ...
$9226  3E 01        LD A,$01
$9228  32 4D 5D     LD ($5D4D),A     ; the side: 1
$922B  3A 8C 5D     LD A,($5D8C)
$922E  CD 9E 82     CALL moraleShock

From scoreDamage in the engine's listing. moraleShock ($829E) raises the morale of every unit of side $5DA0 and lowers the other side's.

When a unit dies, unitDies puts the side that scores for it in $5DA0 and calls moraleShock, and the right side cheers. scoreDamage sets the side in $5D4D instead, which moraleShock never reads, so the morale for broken terrain goes by whoever made the last kill. The Assassins and Moonbase Assault pay the first side for damage, and The Cyber Hordes pays the droids. In Moonbase Assault, once a defender has killed an attacker, every databank the attackers then blow up lifts the defenders' morale and lowers their own.

$5DA0 is not cleared for a new game. It starts at 0, the first side, when the program loads, and after that it keeps the last kill of whatever game was played before.

04 · Bug

Bug: the shop never refuses armour

Armour is chosen unit by unit before the weapons. The price is taken when the credits cover it, and the armour is fitted either way.

$9FAE  7E           LD A,(HL)        ; the type's front armour
$9FAF  DD 77 0D     LD (IX+$0D),A    ;   fitted to the unit
         ...                         ; left, right, rear, weight and room
$9FCC  7E           LD A,(HL)        ; the type's price
$9FCD  CD 27 9E     CALL payCredits  ; carry set if paid, clear if not
$9FD0  21 89 5D     LD HL,$5D89      ; ... and the carry is never looked at

From chooseArmour in the engine's listing.

payCredits takes the price only when the side has enough and says which it did in the carry flag. Buying a weapon looks at the flag. Choosing armour fits the unit's four sides, its weight and its room to carry before paying, and goes on to the next unit whatever the flag says. A side whose credits run out partway through its squad gives every later unit the armour it picks for nothing, though it is left with too little for weapons: at level 7 of Moonbase Assault the first side's 155 credits buy seven suits of the heaviest armour, at 20 each, and the eighth is fitted free with 15 credits still in hand.

05 · Secret

Secret: the computer's skill level only sets how long it remembers a unit it has seen

The level chosen against the computer sets a number called its skill. The skill is used in one way only: how long the computer goes on hunting a unit it has seen.

The skill is read from the scenario's table at $B655, one byte a level, into $5DF8. Three places read it, and all three set a unit's byte, in a table of twenty at $B63A, to the skill: when one of the computer's units sees the unit in the computer's turn, when the unit fires where one of the computer's units can see the shot, and in Rescue from the Mines, when the unit carrying the video key turns the cameras on at the vidi-screen. Each of the player's half-turns counts every byte down by one. The computer hunts a unit only while its byte is above 0, and adds what is left of the byte to the unit's score when it chooses whom to go after.

Its aim and its use of cover do not change with the level. A higher level gives the computer more units and the player fewer credits (the Maps tab has each level's numbers), and with this one byte lets the computer's units keep after the player's for more of their turns: one at level 1 of The Assassins, nine at level 7 of Paradise Valley. The cameras show the player every unit on the map, and the price is that the computer knows where the unit that turned them on is standing.

06 · Leftovers

Six droids that never play, and the Spectrum's font in three scenarios

The Assassins has records for twenty units, as every scenario does, and six of them, all named COMBAT DROID, have no bit set for any game: not two players and not any level. They are taken out of play before the first turn, every time. The droids numbered 6 to 8 play only at the higher levels.

The last bytes of three scenario blocks are not the scenario's at all. Rescue from the Mines ends with 61 bytes, Paradise Valley with 18 and The Cyber Hordes with 11 that match the 48K ROM's character set, the tail end of its letters from N to U. They were in memory when each scenario was saved, and nothing reads them except the random numbers, whose pointer reads every byte of memory in turn.