Created: 27th November 1999
Last Modified: 28th November 1999
This page will demonstrate the usage of ZMR, the most popular full-blown sprite routine.
ZMR is a routine that draws a clipped sprite anywhere on the screen. The routine itself is easy to use, it is very similar to the one on the previous page. The inputs are slightly different, as shown below. The actual routine is very complicated and I won't even attempt to explain how it works. I've left in the original comments but I haven't added any - it would be pointless as some of the stuff done in the routine is impossible to understand without having read the entire z80 documentation over at least ten times... By the way, ZMR stands for Zoomin' Mob Routine. The name comes from the fact that it is twice as fast as its predecessor, ASCR (Advanced Sprite Clipping Routine).
ZMR was written by Dux Gregis of ACZ. Don't bother emailing him asking how it works. If you don't understand it by looking at the code then you don't know enough assembly anyway :). There is a zip file on ACZ somewhere containing all the original code, you can also get a copy of it here, the file is about 4Kb so it won't take long to download if you're online. The file is in a folder called 'files' if you've downloaded the tutorial.
ZMR is actually three routines in one. It contains the usual findpixel routine, a routine called PutSprite and one called ClearSprite.
PutSprite draws an 8x8 sprite to the screen. However, it also saves whatever was in the place it is drawing to to another 8 byte memory location, called by some people 'background storage'. This is useful, for example, if you are doing a Zelda style game with dirt (some dots) on the floor. It takes the following inputs:
ld ix,LocationOfSprite).It destroys every register except bc, which contains its initial value.
ClearSprite uses some of the same code as PutSprite but it does not store the background anywhere. It can be used to restore the background or just to draw a normal sprite anywhere without saving the background. It takes the following inputs:
Again, all registers except bc are destroyed.
There is a file in the zip file containing a demonstration of how to use ZMR. I never use ZMR myself, so I can't really help you. Email me if you're really stuck, but I don't know much about it really.