Espamática
ZX SpectrumRetro ParlaZ80 Assembly

ZX Spectrum Assembly, Pong – 0x0D Loading screen

In this ZX Spectrum Assembly chapter, we will add a loading screen to ZX-Pong.

Translation by Felipe Monge Corbalán

Table of contents

Loading screen

We left adding a loading screen for ZX-Pong until the end.

Create the folder Step13 and copy all .asm files from the folder Step12.

First download the loading screen I prepared or make your own. I’m not a graphic designer, so don’t expect much, but it serves the purpose of this chapter.

We implement the loader

To create the loader we will not start from scratch, we will copy the loader that PASMO creates with the –tapbas option.

BASIC
10 CLEAR 23981
20 POKE 23610,255
30 LOAD ""CODE
40 RANDOMIZE USR 23981

We are going to edit the first line, for which we will move the cursor up and once selected, press Shift + 1 to edit.

We are going to change the address where the program starts, because as we put more BASIC in, it is necessary to load the program in a higher memory location. We are going to change the CLEAR 23980 to CLEAR 24200. Next we are going to change line 40 to put the memory address where the program is loaded, so that RANDOMIZE USR 23981 we leave it as RANDOMIZE USR 24200.

Now we are going to extend line 20. We will edit it, go to the end and add a colon by pressing Ctrl + Z. After the colon we will add POKE 23624, 0, which we get with the O key. With this POKE we set the ink and black background in the ZX Spectrum command line part, we also set the border in black; address 23624 is where the system variable BORDCR is located.

We continue on line 20 and we put another POKE (don’t forget the colon) to put a value in the system variable where the permanent attributes of the screen are set, POKE 23693, 0, to set the ink to black and the background to black on the whole screen.

Finally, we add another colon and CLS, pressing V.

VB
10 CLEAR 24200
20 POKE 23610,255: POKE 23624,0: POKE 23693,0: CLS
30 LOAD ""CODE
40 RANDOMIZE USR 24200

Let’s modify line 30, just before LOAD «»CODE, add LOAD «»SCREEN$: (LOAD by pressing J and SCREEN$ Control + K in extended mode).

After SCREEN$, we will add another POKE so that the rest of the blocks to be loaded are not displayed on the screen, and so that they do not erase part of the loading screen. I borrowed this POKE from one of AsteroideZX’s videos, POKE 23739, 111.

It’s time to record the changes to a tape, in this particular case we’ll call it PongCargador.tap, as we’ll be creating two other tapes: one for the loading screen and one for the programme.

To record we set SAVE «Loader» LINE 10. SAVE is obtained by pressing S and LINE is obtained by pressing Ctrl + 3 in extended mode. This will record the programme to tape and when we load it with LOAD «» it will run from line 10.

VB
10 CLEAR 24200
20 POKE 23610,255: POKE 23624,0: POKE 23693,0: CLS
30 LOAD ""SCREEN$: POKE 23739,111: LOAD ""CODE
40 RANDOMIZE USR 24200

Restart the emulator and try the recorded file, you will see that it runs automatically and waits for the rest to load. Press Escape to stop the execution and press B, then 7 and Enter to make the border white. Then, in extended mode, press Control + C, then 7 and Enter, and we have the main screen background in white.

We add the loading screen

I designed the loading screen with ZX Paintbrush and exported it as PongScr.tap; it asked me to name the block and I called it PongScr.

It is very important to export as tap and not save as tap. If we record as tap, we will not be asked for the name of the header and it will not be loaded.

Now we are going to link the loader and the screen with Copy, in the command prompt (in my case it’s Windows), don’t forget to be in the working directory.

ShellScript
copy /b loader.tap+PongScr.tap ZX-Pong.tap

If you use Linux, it would be:

ShellScript
cat loader.tap PongScr.tap > ZX-Pong.tap

We concatenated loader.tap and PongScr.tap and wrote the result to ZX-Pong.tap.

The next step is to load the ZX-Pong.tap file into the emulator and see if it loads our screen.

Including ZX-Pong

Now we just have to compile our ZX-Pong with PASMO, without generating the BASIC loader.

First we open the file main.asm and change in the first line the ORG $5dad to ORG $5e88 (24200), the address where our program should be loaded, as we specified in the loader.

It’s time to compile with PASMO, but change the –tapbas we used so far to –tap.

ShellScript
pasmo --name ZX-Pong --tap main.asm pong.tap

Now we compile, but PASMO does not create a BASIC loader for us.

Finally we link the three files into one and check if our ZX-Pong still works.

ShellScript
copy /b loader.tap+PongScr.tap+pong.tap ZX-Pong.tap

cat loader.tap PongScr.tap pong.tap > ZX-Pong.tap

If all goes well, we load into the emulator and, after the loading screen, our programme loads, ready to play.

ZX Spectrum Assembly, Pong

Download the source code from here.

If you have any doubts, you might be interested in watching the videos of the online workshop I did in collaboration with Retro Parla (Spanish).

ZX Spectrum Assembly, Pong 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.



Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continúa navegando está dando su consentimiento para la aceptación de las mencionadas cookies y la aceptación de nuestra política de cookies, pinche el enlace para mayor información.plugin cookies

ACEPTAR
Aviso de cookies

Descubre más desde Espamática

Suscríbete ahora para seguir leyendo y obtener acceso al archivo completo.

Seguir leyendo