# Rear Gunner XL – Part 4 – Movement

So far we’ve setup the variables we need, and drawn our sights and the enemy into the screen.  We still can’t really play the game though, as we need to have some way of moving around,  This is handled in lines 90 to 140:

```; 90 IF INKEY\$=“5” THEN LET B=B-1
; 100 IF INKEY\$=“8” THEN LET B=B+1
; 110 IF INKEY\$=“7” THEN LET A=A-1
; 120 IF INKEY\$=“6” THEN LET A=A+1
; 130 IF INKEY\$=“0” THEN GOTO 150
; 140 GOTO 50```

# Rear Gunner XL – Part 3 – Drawing

Having converted the first five lines of the game in the last post, which setup the positions of the player and enemy, we can move onto the next four lines, which are concerned with drawing both the player’s sights and enemy:

```; 50 PRINT AT D,C;”(graphic G)”
; 60 PRINT AT A,B;” + “
; 70 PRINT AT A-1,B;”   “
; 80 PRINT AT A+1,B;”   “```

Line 50 is drawing the enemy sights, and 60-80 the player.  It’s interesting to note that the player is drawn in the middle of a 3×3 square, surrounded by spaces, so when the player moves it erases the previous position as it goes.

# Rear Gunner XL – Part 2 – Setting up

I think the best way to do this conversion is type in the BASIC listing as comments, and then add our Z80 conversion of each line as we go.  This will all be stored in our main.z80 file.  That way it will be obvious what code each line translates to, and hopefully be easier to follow.

Note that this isn’t going to be the most optimal or efficient solution to converting the game, as optimising everything often leaves the code being somewhat unreadable.  I’ll offer some thoughts on how it can be improved, but I’ll leave that up to the reader 🙂

# Rear Gunner XL – Part 1 – Getting started

The development environment for doing ZX81 games is the same as for the Spectrum, just that you need a ZX81 emulator to see the results on.  You can still use whatever text-editor/project solution you are used to, and the same assembler – it’s just Z80 again after all.  For the emulator I’d recommend using either EightyOne – which is very accurate – or No\$ZX81 – which is much faster to boot, but not quite as exact.  I personally use No\$ZX81 for day-to-day development & testing, given it’s quick turnaround, and EightyOne for final testing.

# Going back in time…

I’ve been ask by a few people to write about my experiences with programming the ZX81, and with the grounding of using Z80 on the ZX Spectrum now largely covered it would seem the right time to step back a little in time to the Speccy’s predecessor…

With the Zeddy being based upon the ’81 most of the concepts are actually very similar, if not identical, between the two machines.  Obviously, out of the box, it lacks sounds and colour (so that’s two less things to worry about straight off) but the main differences are really only how the display works, it’s relative lack of memory, and that it’s slower than it’s big brother.  But if, like me, you stick to using the low-res ‘chunky pixel’ graphics that it’s known for then you actually need much less memory to store graphics, and because the screen takes less memory you can fill it faster, so it’s very much swings and roundabouts.

# Pick a key, any key…

Finally!  The mythical keyboard post!!  Sorry it’s taken so long, but SokoBAArn was taking it’s time (along with a large & overgrown garden back in the real world). Anyway, we’re here now, woohoo!!

Back in the depths of time I did a short piece on how to detect if a key is pressed, which used the following code:

```WAITFORKEY:
ld a, 0
in a, (254)
cpl
and %00011111
jp z, WAITFORKEY```

That’s actually the basis for all keyboard reading, and as complicated as it gets, just that we were doing a particular and simple case – testing for any key being pressed.

# Normal service to be resumed…

Now that SokoBAArn has been released, I’ll have a bit more time to devote to this blog, starting with that mythical keyboard handling post!

In case you haven’t seen SokoBAArn yet, take a look here…

https://bobs-stuff.itch.io/sokobaarn