Technology sprites - Part 6: preparation of data for publication.

ZX Forum #04
  PREPARING DATA FOR PRINTING


   Before you print
sprite on the screen, we have to prepare the necessary
data in order to print without being distracted by these 
details. 

   Let us isolate a few variables, which we will
stored data:


   COORD - print coordinates 1 -
Y, 2 - X.

   LENHGT - the length of the sprite (in
familiarity) and height (in
pixels).

   ADRSPR - data address sprite
in memory.


   And now let's see
how do we put the required data in these variables. Previously, 
we you have already talked about the different

how to store data and, correspondingly, different blocks
sprites and headers to them. For
beginning to fill these variables
for sprites of the same size. One of the parameters such
block is the full length of a sprite (length + length of the 
mask Sprite + (if any) length attributes):


   At the entrance to the register A must
be the number of sprites (numbered from
0). The output of the variable ADRSPR will address the sprite, 
in a variable LENHGT its length and height. 140.

ODINAK LD HL, SPRDATA +4; In HL address these sprites. Since
                           ; Since the first 4 bytes are Headers
                           ; Wok, we skip them.

        AND A; If the number of sprite 0, proceed.

        JR Z, ODINAK1

        LD B, A; organize cycle.

        LD DE, LINESPR; In DE the length of one sprite.

        ADD HL, DE; adds up.

        DJNZ $ -1; completes the cycle.
ODINAK1 LD (ADRSPR), HL; In a variable enters the address data

                           ; Sprite.

        LD HL, (ZAGOLOWOK); In HL length and height of the 
sprite, which 

                           , Indicated in the header block 
sprites 

                           ; (Remember, there must be those 
given                            ; Ones).


        LD (LENHGT), HL; variable in them.

        RET; Exit.
2

   We now turn to the second
type blocks sprite - sprite heterogeneous, ie sprites
This block can have different
sizes. Variables remained the
same as when entering the subroutine in
A register should be number
sprite (numbered from 0). To get started fill in the variables
Separate tables:
140.
OTDEL LD L, A; Writes sprite number in the register L.

       LD H, # 00; Zeroing H.

       ADD HL, HL; Since each sprite in the table of
                         ; Usual 4 bytes, multiply the number 
of valid                          ; That by 4.


       ADD HL, HL

       LD DE, SPRDATA; In DE address table.

       ADD HL, DE; obtain the HL data address on the sprite.

       LD E, (HL); Writes a DE address of the sprite to

                         , Which reads data at a Regis
                         ; Friction HL.

       INC HL

       LD D, (HL)

       INC HL

       PUSH HL
------------------------
       LD HL, SPRDATA; we have already said that, instead of to
                         ; Nkretnogo address sprites can decrees
                         ; Vatsya offset to sprite from the 
address 

                         ; Downloads. If it is set to offset

                         , Then in DE register with us to this 
model                          ; Cop is offset to the desired


                         ; We sprite. To get the address

                         ; Sprite, we add the offset to hell
                         ; Res downloads. Wondered if the 
address 

                         And these two lines must be removed.

       ADD HL, DE
------------------------ OTDEL1 LD (ADRSPR), HL; Writes to the 
variable address data 

                         ; Sprite.

       POP HL

140. LD C, (HL); Writes in BC length and height, on which
                         ; Rye points HL.

       INC HL

       LD B, (HL)

       LD (LENHGT), BC; Writes a variable length and height.

       RET; Exit.
2

   Now fill in the data for
CROSS-CUTTING table. Variables remained the same.
140.
SKWOZ LD HL, SPRDATA; In HL load address of sprites.

       AND A; If the number of sprite 0, proceed.

       JR Z, SKWOZ1

       LD B, A; The B number sprite, organize cycle.
SKWOZ2 LD E, (HL); Writes a DE address of the next sprite.

       INC HL

       LD D, (HL)

       EX DE, HL
------------------------
       LD DE, SPRDATA; we have already said that, instead of to
                         ; Nkretnogo address sprites can decrees
                         ; Vatsya offset to sprite from the 
address 

                         ; Downloads. If it is set to offset

                         , Then in DE register with us to this 
model                          ; Cop is offset to the desired


                         ; We sprite. To get the address

                         ; Sprite, we add the offset to hell
                         ; Res downloads. Wondered if the 
address 

                         And these two lines must be removed.

       ADD HL, DE
------------------------ SKWOZ3 DJNZ SKWOZ2; Close the loop.
SKWOZ1 INC HL; In the HL data address sprite.

       INC HL; Increment HL at two. Now HL indicated
                         , Shows the length and height of the 
sprite. Time                          ; Simultaneously store.


       PUSH HL

       INC HL; increasing the HL for 2, we get e

                         ; Data sprite.

       INC HL

       LD (ADRSPR), HL; In a variable enters the address data

                         ; Sprite.

       POP HL; Restore HL.

       LD C, (HL); In BC enters the length and height.

       INC HL

       LD B, (HL)

       LD (LENHGT), BC; variable in them.

       RET; Exit.
2

   Well, now you can work with almost any type of headings. The 
main difference between the different programs sprite formation 
is exactly in the format of the formed

their title. We reviewed
basic, and should not be difficult to alter these protsedurki 
for slightly modified types of headers.