Highway Robbery

See all articles from SYNC v4 n1

Highway Robbery is a fast-paced machine code driving game specifically designed to fit into a basic 1K machine. With no modifications it can also be run on 2K and greater.

Loading the Machine Code

Entering the program will be done in a series of six steps, and, if you are a good typist, possibly only three steps. Follow the instructions exactly and do not do anything that is not mentioned, especially LISTing. LISTing a program when you are not supposed to could be hazardous. SAVE frequently.

Step 1

Type in Listing 2, the hex loader. There are 294 X’s in line 10 so it is best to use the FAST mode. RUN the program and in response to each “” at the bottom of the screen type in a hex code from Listing 1. Type the codes off the list from left to right and top to bottom line-by-line. When typing the hex codes proceed slowly! Beware of 8’s and B’s which look a lot alike.

Should you enter a code incorrectly press ENTER, instead of typing the next code in the list, and the program will stop with 3/50. In the immediate mode type

LET A=A-1

Then type

GOTO 40

to restart the program and give you another chance to enter the code. When the code has been entered, it will be scrolled off the top of the screen, so you may not see it, but it has been changed. Continue entering the rest of the hex codes.

When all the codes have been entered and the program has finished with report 0/70, make several SAVEs of the program. In case something should go wrong in upcoming steps you will not have to re-enter the codes. Do not list the program.

Listing 1. The hex codes.

HEX CODES FOR "HIGHWAY ROBBERY"

8D 80 AD AE AC AD BC A6
BE 80 B7 B4 A7 A7 AA B7
BE 80 8D 80 80 80 80 80
80 80 80 80 8D 9C 9C 9C
00 00 00 00 00 00 00 3A
34 40 32 A8 40 06 90 3E
80 D7 D7 10 FC 01 20 00
ED 5B 0C 40 13 21 82 40
ED B0 1B ED 53 A5 40 2A
0C 40 11 94 00 19 22 A2
40 3E 04 32 A4 40 3E 08
2A A5 40 23 23 E5 D1 23
01 1F 00 ED B0 EB 36 80
EB 3D 20 F0 2A A2 40 7E
32 A7 40 36 92 3A A8 40
4F CB 27 CB 27 47 CB 27
CB 27 80 81 C6 0D 5F 32
A8 40 0E 08 AF 06 08 CB
13 17 91 30 03 81 10 F7
3C 2A A5 40 11 21 00 19
3D 20 FC 3A 34 40 CB 6F
3E 88 28 02 C6 05 77 01
0F FF 10 FE 0D 20 FB 3A
A7 40 FE 88 28 12 FE 8D
20 2D 2A A5 40 34 7E FE
A6 20 24 36 9C 2B 18 F5
0E 85 2A A2 40 E5 D1 36
12 06 05 13 2B 71 EB 71
EB 10 F8 3A 25 40 FE F7
C8 79 EE 80 4F 18 E3 11
21 00 2A A2 40 36 80 3A
25 40 FE FD 28 07 FE BF
28 14 C3 D8 40 3A A4 40
FE 08 28 F6 19 22 A2 40
3C 32 A4 40 18 EC 3A A4
40 3D 28 E6 32 A4 40 ED
52 22 A2 40 18 EB

TOTAL = 30051

Listing 2. The hex loader.

10 REM XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX
20 FOR A=16514 TO 16807
30 SCROLL
40 INPUT A$
50 POKE A,(CODE A$-28)*16+CODE
A$(2)-28
60 PRINT A;" ";A$
70 NEXT A

Step 2

Without deleting the current listing, type in Listing 3, which will overwrite the previous program. RUN the program. The program is finished with report 0/70. If the number at the top of the screen is exactly the same as the TOTAL noted at the bottom of Listing 1, proceed to Step 3. If not, you made a mistake in entering the hex codes and should proceed to Step 4.

Listing 3. Validity check.

20 POKE 16510,0
30 LET T=0
40 FOR A=16514 TO 16807
50 LET T=T+PEEK A
60 NEXT A
70 PRINT T

Step 3

Without deleting Listing 3, type in Listing 4. Now delete Listing 3. (The reason for this is that if line 20 is deleted without Listing 3 present, line 0 will attempt to list. In a 1K machine there is not enough room on the screen for the line to appear and the program will crash.) Make several SAVEs of the program. After this is done, the game is ready to be RUN. Use SLOW mode.

Listing 4. The Basic program.

1 RAND USR 16553
2 CLS
3 GOTO 1

Step 4

Enter Listing 5 and the one currently in memory will be overwritten. Do not worry about deleting line 10 with the one in Listing 5, the machine code was moved to line 0 by Listing 3. RUN the program. It will display 8 bytes of program and their addresses at a time. These should be checked against those in hex listing. Any that differ should be noted on a piece of paper as to the address of the offending code and the correct hex code that should be placed at that address. After 8 bytes are displayed and checked, press the ENTER key and 8 more bytes will be displayed. (This program will also display the bytes at addresses 16808 and 16809, before ending with report 0/80. These bytes can be ignored as the machine code program ends at address 16807.)

Listing 5. Code displayer.

10 FOR A=16514 TO 16807 STEP 8
20 FOR O=0 TO 7
30 LET D=PEEK (A+O)
40 PRINT A+O;" ";CHR$ (INT (D
/16)+28)+CHR$ ((D/16-INT (D/16))
*16+28)
50 NEXT O
60 PAUSE 50000
70 CLS
80 NEXT A

Step 5

Enter Listing 6, overwriting the listing already in memory. This program, when RUN, will allow changing offending hex codes. In response to ADDRESS, type the address (in decimal) of the incorrect code. Then, in response to HEX, type the correct hex code that should be at this address. If there are more codes to change, press the ENTER key, if not, press BREAK.

Listing 6. Code changer.

 10 CLS
20 PRINT "ADDRESS ";
30 INPUT A
40 PRINT A
50 PRINT "HEX ";
60 INPUT H$
70 PRINT H$
80 POKE A,(CODE H$-28)*16+CODE
H$(2)-28
90 PAUSE 50000
100 GOTO 10

Step 6

In the immediate mode type

POKE 16546,118

and

POKE 16547,118

Delete lines 10, 80, 90, and 100 of Listing 6. (Note that when you are deleting the lines, all that will appear on the screen is a REmark statement in line 0 giving the title of the program.) When the lines have been eliminated in the immediate mode type

POKE 16546

and

POKE 16547

proceed to Step 2.

Playing the Game

You are presented with a bird’s eye view of an eight-lane unmarked highway and your car, a Greater Than Mobile (inverse >). Due to the speed at which you are cruising, everything appears to be moving past you. To move your car up a lane, press either the A, S, D, F, or G keys. To move down a lane, press H, J, K, L, or ENTER keys. (The reason for the vast array of keys is due to a limited keyboard checking routine which checks only for a key-press in a specific row, rather than a specific key. This method saves memory and allows the advantage of choosing where to place your fingers.)

The object of the game is to move your car from lane to lane to pick up dollar bills lying on the road. Collecting a dollar simply requires you to move your car over top of one. You get one point, or should I say dollar, for each bill collected. Beware of the brick walls (graphic H). If you hit one of those, your car explodes and the game ends. Pressing either the 1, 2, 3, 4, or 5 keys will start the game again.

Variations

Changes to the basic game should be made only when you have succeeded in creating a working version of the program.

Those who live in the United Kingdom may want to enter Listing 7 in the immediate mode to change the dollar into pound sterling.

Listing 7. Pound Sterling modification.

POKE 16514,140   POKE 16532,140
POKE 16542,140 POKE 16687,4
POKE 16705,140

Currently your car is an inverse greater than symbol. This can be changed to any symbol you wish by using Listing 8 in the immediate mode. The codes 148 and 20 will change the car into an equals sign.

Listing 8. Car symbol modification.

POKE 16630,(CODE OF THE INVERSE
CAR SYMBOL)

POKE 16730,(CODE OF THE NORMAL
CAR SYMBOL)

Presently your car is located in the middle of the screen. This is accomplished by the value held at address 16589, which contains a 148. A lower value will move the car closer to the left edge of the screen giving more time to plan your “path of movement.” A higher value will provide a more challenging game by moving the car closer to the right edge of the television screen. POKE values at this location must range from 138 to 159, or the program may crash or fail to operate properly.

The speed of the car is set by the value at address 166690. Presently it is set at 15. If you like speeding, decreasing this value will increase the speed of the car. If you feel the game is too fast as it is, a larger value will slow it down.

In order to make modifications after the game has started, you must get back into Basic. To do this, wait until you lose. As soon as you press the key to restart, press the BREAK key. Then make the modifications you want.

For those who want to study the inner workings of the program a disassembly is provided.

Label     Instruction        Comment
CAR-POS ;position of car on screen.
CAR-LIN ;line of screen car is on.
SCORE ;position of ones digit of score.
CAR-STAT ;status of current car position.
SEED ;random number generator seed.

START LD A,(FRAMES) ;place a number in the SEED holder.
LD (SEED),A

BLACK LD B,90h ;set up counter to black in top
LD A,80h nine lines of screen.
RST 10h ;black in two characters at a time
RST 10h and continue until 9 lines are
DJNZ,BLACK blackened.

LD BC,32 ;set up counter
LD DE,(D-FILE) and destination
INC DE and source pointers.
LD HL,16514
LDIR ;transfer game title to screen.

DEC DE ;save address representing the ones
LD (SCORE),DE digit of the on-screen score.

LD HL,(D-FILE) ;set up location of car on the
LD DE,148 screen and its starting line
ADD HL,DE and save data.
LD (CAR-POS),HL
LD A,4
LD (CAR-LIN),A

SCROLL LD A,8 ;set number of lines to scroll left.
LD HL,(SCORE) ;create the destination in HL
INC HL and then transfer it to DE
LINE INC HL
PUSH HL
POP DE
INC HL ;produce source in HL registers.
LD BC,31 ;set transfer count.
LDIR ;transfer the line left once.
EX DE,HL ;make the character in column 31
LD (HL),80h a black space
EX DE,HL
DEC A ;repeat until all lines have been
JR NZ,LINE scrolled.

LD HL,(CAR-POS) ;get the car's position
LD A,(HL) and get the status of the position.
LD (CAR-STAT),A ;save the status
LD (HL),92h and display the car.
LD A,(SEED) ;get the last seed and proceed
LD C,A to generate a new seed
SLA A and a random number.
SLA A
LD B,A
SLA A
SLA A
ADD A,B
ADD A,C
ADD A,0Dh
LD E,A
LD (SEED),A ;save the new seed.
LD C,8 ;proceed to divide random number
XOR A by 8.
LD B,8
DIVIDE RL E
RLA
SUB C
JR NC,+3
ADD A,C
DJNZ,DIVIDE ;the remainder is now in A which is
INC A pointer to a row (1 to 8).
LD HL,(SCORE) ;get the location of where to plot
LD DE,21h a dollar or a brick wall
POINT ADD HL,DE in the HL pair.
DEC A
JR NZ,POINT

LD A,(FRAMES) ;using the TV frames counter check
BIT 5,A whether to plot a brick wall
LD A,88h or a dollar bill
JR Z,BRICK
ADD A,
BRICK LD (HL),A and display the choice.%

TIME LD BC,FF01h ;load the timer
DJNZ,TIME and do not continue until
DEC C the timer runs out.
JR NZ,TIME

LD A, (CAR-STAT) ;analyze the status and if hit
CP 88h a brick wall go to explosion
JR Z,BOOM routine.
CP 8Dh ;if it is not a dollar then
JR NZ,KEY advance to keyboard check.
SCOREUP LD HL,(SCORE) ;get the score pointer and add one.
INC (HL)
LD A,(HL) ;if the score had not overflowed then
CP A6h do a keyboard check.
JR NZ,KEY
LD (HL),9Ch ;if overflowed then make digit a zero.
DEC HL ;point to next higher digit
JR SCOREUP and repeat

BOOM LD C,85h ;load blowup symbol in C register.
EXPLODE LD HL,(CAR-POS) ;load both HL and DE with
PUSH HL position of car.
POP DE
LD (HL),12h ;display normal car (not inversed).
LD B,5 ;explosion depth counter set.
DEPTH INC DE ;produce an explosion of symbols
DEC HL to the depth requested.
LD (HL),C
EX DE,HL
LD (HL),C
EX DE,HL
DJNZ,DEPTH
LD A,(LAST-K) ;get keyboard character
CP F7h and if 1,2,3,4, or 5 key is pressed
RET Z start a new game.
LD A,C ;redo explosion with a new symbol.
XOR 80h;LD C,A
JR EXPLODE

KEY LD DE,21h ;set movement value.
LD HL,(CAR-POS) ;turn off car symbol by erasing it
LD (HL),80h from the screen.
LD A,(LAST-K) ;get the keyboard status
CP FDh and if A,S,D,F, or G keys pressed
JR Z,DOWN then move car down a lane.
CP BFh ;if H,J,K,L, or ENTER keys are pressed
JR Z,UP then move car up a lane.
GAME JP SCROLL ;start game loop over.
DOWN LD A,(CAR-LIN) ;get current car line and if already
CP 8 on the bottom lane do not
JR Z,GAME move it any lower.
ADD HL,DE ;move car down one lane
LD (CAR-POS),HL and save the new location
INC A and the new lane.
SAVE LD (CAR-LIN),A
JR GAME
UP LD A,(CAR-LIN) ;get current car lane and if already
DEC A on the top lane, do not move it.
JR Z,GAME
LD (CAR-LIN),A ;save new car lane.
SBC HL,DE ;move car up one lane
LD (CAR-POS),HL and save new location.
JR SAVE

Tags