Technology sprites - Part 5: Structure sprite blocks (both co-exist in memory sprite and mask, what data to help us quickly find the address of the sprite in memory, and much more.)

ZX Forum #04
   STRUCTURE sprite BLOCKS


   This is perhaps one of the most
bulk and intricate parts
this narrative. In it I
talk about how to coexist in
memory sprite and a mask, which
data help us to quickly
find the address of the sprite in memory
and much more.

   Finally I will touch on in his
story we have found other sprites. Look at them,
they do not happen to have different
form. This seemingly insignificant fact, as
mask, located on different sides of the sprite, is not a minor. 
It was from her location relative to the sprite which affects 
the speed print sprite, as well as the appearance and

playability of the program.

   Let's look at the sprite
from the game 3D BATMAN. Here, the mask
and Sprite are separate
sprites and printed at a time - this is quite a common way
Storage sprites, but the seal of the sprite is time consuming 
(of course, this notion respect, and everything depends on

talent of the programmer). Next
sprite from the program ELEFANT-1
interesting is the fact that it is a somewhat unclear what, in 
fact, it shows. Well, but if you try and connect

among themselves or, more precisely, put
order with no spaces, familiarity 1, 3, 5, and next to them, 2
4, 6. Is not it true, now all
understandable and even beautiful.

   This is another way of storing
in the memory mask and sprite, which, in my opinion, the most
successful, and in print spends very little time. This is 
because say, chess storage method sprite when alternate

byte mask, and byte sprite.

   Program JAK THE NIPPER-2
offers us another way
Storage sprites, when the mask and
Sprite is a great
sprite. In this case, the program works pretty print
quickly, though inferior to the previous method.

   On the character format, I will not tell because of the
This much has been written. You can
read more about this format in the journals "ZX-Revue" or the 
book "How to write a game in assembly "

by "Peter". There you will find a program to print such
sprites.

   Now, what data
to help us in our work with
sprites.

   I can distinguish two types of blocks noncharacter sprites 
(hereinafter I will only talk about noncharacter sprites, so I 
will use the word sprites) - it blocks consisting of sprites

the same size, and the second
type - blocks of dissimilar sprites. In the first case, the 
title of Sprite is minimal - it is 2 bytes - length and height 
of the sprites, and also 2 bytes (often enough

1) - the length of one sprite in bytes. These data are 
sufficient, to quickly locate desired

sprite into memory, and just as quickly
to print them.

   A second type of blocks harder then four bytes at
the whole block did not get off. In this
If there are two ways:
1) before the unit sprites drawn up a table in which each 
sprite allocated 4 bytes - 2 bytes in length and height of the 
sprite and another 2 bytes - the address of the sprite in

memory. Instead of a specific address sometimes indicate the 
shift to sprite, in this case, sprites

You can move in memory. This type of table let's call
individual, 2) a second type of table can be called a 
cross-cutting. Here No single table, but before

Each sprite put all the same
4 bytes with a slight difference: 2
bytes - the length and height of sprite
(It) and 2 bytes - address / offset to the NEXT sprite.

   As a separate table
was described by the first of it we
First we'll talk. Similar
header format is the best because it provides
the fastest access to sprite
whereas the second method requires
special program to determine the location of the sprite
memory. We must note one more
moment - with direct addressing
(When given a specific address
sprite) moving sprites
memory becomes impossible, and
header block sprites completed another 2 bytes (for all
block), who report address
fixation, it is relatively
some addresses were fixed
sprites.

   In some games, the sprites are not
monochrome and color, so
In addition to the mask and sprite to them
join another, and data attributes. Attributes are stored in the
same format as the sprites, but
there is one thing - for
Mask attributes is no need, pay attention to it so as not to
spend the extra memory.

   Another recommendation - the height of the sprite is best to 
immediately set in pixels, in order to print does not spend its 
computation time. 

   After reviewing all the major issues, the format of sprites, 
we turn to the practical side of, and consider different 
procedures for printing sprites.