ZX Spectrum Assembly, Space Battle – 0x00 Introduction
We start a new assembly programming tutorial for ZX Spectrum. If you are new, I recommend that you first visit the tutorial where we see how to program a Pong clone for ZX Spectrum.
Translation by Felipe Monge Corbalán
Table of contents
- Space Battle
- Necessary tools
- Tutorial structure
- Working environment
- ZX-Spectrum Assembly, Space Battle
- Useful links
Space Battle
Space Battle is a simple Mars killer developed for the ZX Spectrum in assembly language. The graphics are single character, UDG (User-Defined Graphic) is used and the movement is character based, so the differences to ZX-Pong are obvious.
In Space Battle I use interrupts, which I don’t do in ZX-Pong. I also make more use of ROM routines, and when using UDG and RST $10 to paint, it is necessary to switch channels to paint at the top of the screen or on the command line.
The first steps will be to define the ship, move it around and continue with the enemies and shooting. Once this is done, we will implement the game mechanics, the collisions, the scores, the available lives, etc.
In the last steps we will implement the start menu, the choice of controls, the start and end of the game, markers, sound effects and generally decorate the final result a bit. Finally, the loading screen will be added.
Space Battle is compatible with the 16K, 48K and 128K models of the ZX Spectrum, can be controlled with keyboards and Sinclair and Kempston joysticks, and consists of thirty levels.
To say that it consists of thirty levels is perhaps a bit presumptuous, as the mechanics of the game do not change, although what does change are the enemies, with a total of thirty different enemies, one for each level.
The movement of the ship is horizontal, so I only need one graphic. The enemy movement is diagonal and I need four graphics:
- up/right
- top/left
- down/right
- down/left
The shooting of the ship is a single graphic, the explosion of the ship when it kills us is four graphics, and we will do a little animation when that happens.
We will define eight more graphics for the screen frame, and another empty graphic to erase the characters from the screen.
Much of what we will see has been explained before, so I will not give many instructions at times.
Don’t forget to create the SpaceBattle folder.
Necessary tools
- Text editor, either Notepad, Notepad++, Visual Studio Code or any other you are comfortable with.
- PASMO assembler compiler: it is available for Windows, Linux and Mac, and is compatible with Raspberry Pi OS, which is the system from which I am writing this tutorial.
- ZX Spectrum emulator: here you have several to choose from such as ZEsarUX, Fuse, Retro Virtual Machine, etc., depending on the operating system you use. In my case I choose ZEsarUX again.
Tutorial structure
Unlike ZX-Pong, Space Battle was not developed with the idea of making a tutorial, so the structure is different, I’m not going to go developing, doing and undoing as I did in ZX-Pong, this time I already have it finished and now it’s time to write «How it was done», although there are changes in the code with respect to what is published.
In the first steps we are going to define the ship, we are going to move it, then we are going to approach the enemies and the shooting. Once this is done, we will implement the game mechanics, the collisions, the scores, the available lives, etc.
In the last steps we will implement the start menu, the selection of controls, start and end of game, markers, sound effects and, in general, to decorate a little the final result.
The last thing will be to add a loading screen, let’s see how it goes this time.
Working environment
This time I’m not going to work under Windows, I’m going to use the recent gift I’ve been given, what some call the Spectrum of the 21st century, a Raspberry Pi 400.
The emulator I’m going to use is ZEsarUX, the PASMO compiler and the Visual Studio Code editor, so in this aspect I’m not changing anything with respect to ZX-Pong.
This time I’m going to show something that I didn’t show in the previous tutorial, the way to debug with ZEsarUX, which I hope will be useful, although we’ll leave it for the end.
ZX-Spectrum Assembly, Space Battle
In the next chapter of ZX Spectrum Assembly, we will define all the graphics used in Space Battle.
If you want to see the final result of this tutorial, you can download the .tap or .dsk file from itch.io.
Useful links
ZX Spectrum Assembly, Space Battle by Juan Antonio Rubio García.
Translation by Felipe Monge Corbalán.
This work is licensed to Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).
Any comments are always welcome.