Opinions are not those of the University of Birmingham or the School of Computer Science. Address any queries to the author of these pages, Damien Burke.

Level loader trap

There exists a facility in the unix Spectrum emulator xzx and the PC Spectrum emulator Z80 to load files from disk. This is known as the level loader trap, or ED/FB trap.

Loading headerless files on the Spectrum can be carried out with the following piece of Z80 code:


LD	IX,destination address

LD	DE,number of bytes to load

SCF

CALL	#0556

Many games use just this method, and the Z80 emulator traps it automatically, enabling the use of TAP files (see the Z80 documentation). However many games, particularly multiloaders, either use their own loader or are difficult to make a TAP file of because it's fiddly to rewind a TAP file to `side 2', for instance. Most importantly, only Z80 can use TAP files.

The level loader trap enables both Z80 and xzx to support multiload games. Instead of the above code, the following piece does the job:


LD	HL,destination address

LD	A,number of file to load

DEFB	#ED,#FB

Now, presuming the snapshot file is called GAME.SNA (or GAME.Z80), if this piece of code is executed...


LD	HL,#4000

LD	A,#01

DEFB	#ED,#FB

...then a file called GAME1.Z80 will be loaded to the address 4000 hex, or 16384 decimal (the screen area). And that's it really. It's more portable a method of storing a multiload game, but it can create some directory clutter if there are lots of levels to be loaded.


Back to my Spectrum software list...