Machine code analysis: CITY PATROL

Discussion about ZX80 / ZX81 Software
Post Reply
David G
Posts: 545
Joined: Thu Jul 17, 2014 7:58 am
Location: 48 North

Machine code analysis: CITY PATROL

Post by David G »

Last month I saw a youtube video about CITY PATROL and the reviewer said it was one of the most impressive games of 1982, because of the parallax scrolling

* 4 building layers with parallax scrolling
* 8-way direction movement (left/right, up/down and diagonals)

It was written by Don Priestly and is pure genious


How does it work?

The building data is carried in R$, generated for each game from random data. The screen representation is built from this data at run time

The city has four layers: Smaller buildings in back, larger buildings in front. The alien moves in-between layers 2 & 3. When you move left/right, the layers move correspodingly, but each layer moves a different amount.

; For each Left/Right movement:
; Layer 4 buildings (Closest) move by 7
; Layer 3 move by 3
; Layer 2 move by 2
; Layer 1 (furthest)

Cityscape is 84 chracters wide -- created in P$ for every frame. Then P$ is copied to the display several times a second

The part displayed on the screen is a window 30 characters wide and 21 rows high


I disassembled the code, and added comments and labels to it. During analysis I kept trying to get to various places in the game to correlate what I was seeing in the game with what the code was doing. Yes, it is a difficult game to play so I added a few options, including a "EASY" difficulty option with sparser buildings. The code will compile to match the P file exactly, unless the options are enabled. The original is the early version of CITY PATROL which is on ZX81 Collection. There is a also a newer version on WOS which is modified for tape drive SAVE

To test this game, here's a tip: When first starting, the alien ship starts on the top line in the center. Watch carefully at the start to see wether it moves to the left or the right. It will continue in the same direction and you'll need to chase it. Since the alien moves behind the closest buildings, he is very difficult to track

Challenge:
  • can you enlarge the gunsight to make it easier to hit the alien spaceship? Or just make it score a hit if it is close. The problem I ran into was the alien and city are in P$, yet the gunsight is only on the display. So I couldn't think of a way to detect a near-hit
  • modify game to indicate visually whether the alien craft is to the left of right
Attachments
ATTRACT Layer 3.png
ATTRACT Layer 3.png (11.7 KiB) Viewed 3858 times
ATTRACT Layer 2.png
ATTRACT Layer 1.png
PLAY.png
CP.asm
assembler file
(79.78 KiB) Downloaded 127 times
Post Reply