ZX Forum #04
19 ноября 1997

Technology sprites - Part 8: Printing sprites (coordinates are given in familiarity).

<b>Technology sprites</b> - Part 8: Printing sprites (coordinates are given in familiarity).
        PRINT Sprite

      (Coordinates are

        In the familiarity)


   Now we're with you, we consider
simple procedure for printing
sprites. All their simplicity lies in the fact that the 
coordinates are given in print familiarity. This the fastest 
and at the same time not are really necessary and the 
procedure, but we must consider them, because they provide the 
basis for all procedures for printing sprites.


   Consider the basic structure of the procedure. What is it
should be: let's look at the data that we have
There are at this point: it is
length and height of the sprite, its address in the box and the 
coordinates of the press. The first thing we need to get

address in the screen, which would correspond to the 
coordinates of our press, and it helps us to calculate the 
unpretentious files of: 140.

------------------------------------ 3 (C) 1994 A. Ivanov 
(ZX-Review N3 1994) ------------------------------------ ADR LD 
A, L 

     AND 7

     RRCA

     RRCA

     RRCA

     ADD A, H

     LD H, L

     LD L, A

     LD A, H

     AND # 18

     OR # 40

     LD H, A

     RET
2

   Now absolutely all data from
We have and we can do nothing except print a sprite
on the screen. We still have some data - is the length and 
height of the sprite. You have not thought about which of these 
numbers is more important? Now is the time think about it, 
because of This depends on the speed of

Your procedure. If you look at this earlier scheme for storing 
a sprite, you can easily answer this question. So, the 
important thing here is the height of the sprite, with her and 
we organize the first cycle of the press.

Now it was time to give all
procedure completely.
140.
SETSPR LD HL, (COORD); Writes in HL coordinates printing.

          CALL ADR; calculate the address on the screen.

          LD DE, (ADRSPR); In DE enters the address data sprite.

          LD A, (LENHGT +1); In case A enters the height of the 
sprite. 

          LD B, A; In case B the height of the sprite in the 
peak                            ; Mudflows.

SETSPR1 PUSH HL; Save the address on the screen.

          LD A, (LENHGT); In case A enters the length of the 
sprite. 

          LD C, A; In case C the length of the sprite as a sign 
of                            ; Places.

SETSPR2 LD A, (DE); Take a byte mask / sprite.
IZM AND (HL); impose on AND / OR for byte screening
                           ; On. It depends on what we ne
                           ; Chat - a mask or a sprite.

          LD (HL), A; Rewrite the screen.

          INC DE; proceed to the next byte masks -

                           ; Sprite

          INC HL; proceed to the next familiarity eq
                           ; Wound.

          DEC C; reduces the length of the sprite.

          JR NZ, SETSPR2; If the length is not 0, continue

                           ; Print in length.

          POP HL; Restore address on your screen.

          CALL DOWN; proceed to the next pixel is
                           ; Institute below.

          DJNZ SETSPR1; If the height is not equal to 0, 
continue 

                           ; Print.

          RET
--------------------------------------- 3 (C) 1995 Paul Starks 
(ZX-Review N4 1995) --------------------------------------- 
DOWN INC H 

          LD A, H

          AND # 07

          RET NZ

          LD A, L

          ADD A, # 20

          LD L, A

          RET C

          LD A, H

          SUB # 08

          LD H, A

          RET
2

   Now let's try to print on screen the sprite with the mask 
from the game 3D BATMAN. Look at how this will look Program:

140.
PRINSPR LD HL, (COORD); We take the coordinates of the press.

          CALL ADR; calculate the address on the screen.

          PUSH HL; Store.

          LD DE, (ADRSPR); In DE address of sprite in memory.

          CALL SETSPR; impose a mask.

          POP HL; Restore address on your screen.

          LD A, # B6; Change command AND (HL) on the OR (HL).

          LD (IZM), A

          CALL SETSPR; Print the sprite.

          LD A, # A6; Restore command AND (HL).

          LD (IZM), A

          RET
SETSPR LD A, (LENHGT +1)

          LD B, A
SETSPR1 PUSH HL

          LD A, (LENHGT)

          LD C, A
SETSPR2 LD A, (DE)
IZM AND (HL)

          LD (HL), A

          INC DE

          INC HL

          DEC C

          JR NZ, SETSPR2

          POP HL

          CALL DOWN

          DJNZ SETSPR1

          RET
2

   As seen from this program,
we printed a sprite like 2 times, that does not work very 
quickly and does not speak in favor of such storage format. 

   Now let's print it
sprite to the program ELEFANT-1:

140.PRINTSPR LD HL, (COORD)

          CALL ADR

          LD DE, SPRDATA

          LD B, HGT
SETSPR1 PUSH HL

          LD C, LEN
SETSPR2 LD A, (DE); Take a byte mask.

          AND (HL); combines it with the byte of the screen.

          INC DE; proceed to byte sprite.

          EX DE, HL; temporarily changes the HL and DE, in 
places, so 

                        , As OR (DE) no.

          OR (HL); Print the bytes in the sprite.

          EX DE, HL; Restore DE.

          LD (HL), A; redraw the screen.

          INC DE

          INC HL

          DEC C

          JR NZ, SETSPR2

          POP HL

          CALL DOWN

          DJNZ SETSPR1

          RET
2

   This is the fastest of all
given before this procedure
printing and the most effective.
I want to focus your attention on the
the next moment - as
byte mask, and byte sprite alternate with each other, then the 
length sprite can not be 3

familiarity, and 6 (where 6 can
bypassed if the program that creates the sprites, do not take 
into account this point), then you should

before entering the length of the register
C to reduce it to twice the team SRL A. Feature of this program 
is that sprite appears on the screen

smoothly, because when you print
sprite previous (particularly
first) programs, if the sprite
is quite large, you can see
screen flicker.

   Well, now we have to print a sprite from the program
JACK THE NIPPER-2. Here, too,
should draw your attention to
that in the header length can
indicated wrong: can
be given the total length of the mask and
sprite, and you have the same C
divided by 2, as in the previous procedure:
140.
PRINTSPR LD HL, (COORD)

          CALL ADR

          LD DE, (ADRSPR)

          LD A, (LENHGT +1)

          LD B, A
SETSPR1 PUSH HL

          LD A, (LENHGT)

          LD C, A
SETSPR2 LD A, (DE); Print the line masks.

          AND (HL)

          LD (HL), A

          INC DE

          INC HL

          DEC C

          JR NZ, SETSPR2

          POP HL; Restore address on your screen.

          PUSH HL; again save it.

          LD A, (LENHGT)

          LD C, A
SETSPR3 LD A, (DE); Print the line of the sprite.

          OR (HL)

          LD (HL), A

          INC DE

          INC HL

          DEC C

          JR NZ, SETSPR3

          POP HL

          CALL DOWN

          DJNZ SETSPR1

          RET
2

   I did not give detailed
Comments on this procedure,
it almost doubles the second and differs from it only
arrangement of structural elements.

   Previous sprites we printed without attributes to print the 
attributes of the sprite, we must add to these procedures, 
another small. For the second procedure, it should be made into 
a routines and cause a

CALL at the end of the head of the program.

   To print the attributes of the sprite
we need to address in the screen, which we got after calling
sub ADR, for this HL
must maintain two, not one
times, as in previous versions.
For the first procedure before calling the print attributes 
restore the address on the screen, and the first line labeled 
SETATTR Playing print attributes remove. Well, now the 
procedure itself: 

140.SETATTR POP HL; Restore address on your screen.
--------------------------------------- 3 (C) 1994 Vladimir 
Patrakhin ( ZX-Revue N6 1994) 
---------------------------------------           LD A, H; 
translate the address in the address on the screen 

                           ; Attributes.

          RRCA

          RRCA

          RRCA

          AND # 03

          OR # 58

          LD H, A
---------------------------------------
          LD A, (LENHGT +1)

          LD B, A; In case B the height in pixels.

          LD A, # 04

          SRL B; divide by 2.

          JR NC, R1; If strained, transition.

          LD (IZM), A; In A command code INC B, introducing it 
to 

                           ; Variable.
R1 SRL B; Divide at # 04.

          JR NC, R2

          LD (IZM), A
R2 SRL B; at # 08.

          JR NC, IZM

          LD (IZM), A
IZM NOP; Except where not divided evenly,

                           And here is a team INC B.
SETATTR1 PUSH HL; Save the address on the screen.

          LD A, (LENHGT)

          LD C, A; length of the sprite (for JACK THE NIPPER-2

                           , It is necessary after this command 
to add SRL 

                           ; C, too, and for ELEFANT-1).
SETATTR2 LD A, (DE); We transfer the attributes of the screen.

          LD (HL), A

          INC DE

          INC HL

          DEC C

          JR NZ, SETATTR2

          POP HL

          PUSH DE

          LD DE, # 0020

          ADD HL, DE

          POP DE

          DJNZ SETATTR1

          RET
2

   For sprites in the format ELEFANT-1 and JACK NIPPER-2 length
also is divided by 2 (unless, of course, you had to share it 
for printing sprites). 

   Many may notice a strange design in the place where
We divided the height of the sprite to 8. I
forced to clarify this situation.
If your sprite in height is a multiple of
familiarity (divisible by
8), then this construction can be replaced by three teams SRL 
B; but That is, if the sprite in

height not a multiple of familiarity, there may be disputes:

   Example: height was 9
pixels. When divided by two, we
we get 4, 4 - 2, 8 - 1
but then the sprite in the attributes of familiarity takes 2 (9 
line is as follows familiarity), and painted attributes will 
only the first 8 lines. But for this, and

need a similar design.

   Well, here we are with you and print all major formats of 
sprites in familiarity, and we should go to print on sprites

pixels.






Other articles:

Help - Description of the shell of an electronic book "ZX-FORUM 4.

Secrets of Successful Design - Head for the book "Design your Programs

screen effects - Running a string of R-Type.

screen effects - clearing the screen of Zynaps.

screen effects - "minimize" the screen from Comando Tracer.

screen effects - smooth "decay" of the screen Sommando Tracer.

screen effects - changed the character set for the original stylized font from the game Rockstar.

screen effects - "running out the string" out of the game Rockstar.

screen effects - "pouring" the screen of the game Rockstar.

screen effects - a complex multi-effects from the game Bubbler.

New top 40 procedures - scrolling display, a fusion of two images, inverting screen, rotate characters, replacement of attributes, fill a closed loop, the calculation of addresses in the screen, copy of the screen, etc.

Technology sprites - Part 1: Introduction.

Technology sprites - Part 2: The hunt for sprites (search and pulling).

Technology sprites - Part 3: Format of sprites.

Technology sprites - Part 4: Format of sprites with a mask.

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.)

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

Technology sprites - Part 8: Printing sprites (coordinates are given in familiarity).

Technology sprites - Part 9: Printing sprites (coordinates given in pixels).

Technology sprites - Part 10: a review of programs to work with sprites and graphics.

world of sound Spectrum - Chapter 1: The Physics of Sound.

world of sound Spectrum - Chapter 2: Operator BEEP, Creating effects on BEEPe, Making Music on BEEPe.

world of sound Spectrum - Chapter 3: How is the sound device (BEEP'ra and methods of sound production).

world of sound Spectrum - Chapter 4: Programming sound in assembler.

world of sound Spectrum - Chapter 4.1: Programming sound effects - Tone, Noise, Complexes effects.

world of sound Spectrum - Chapter 4.2: Programming Sound Effects - Volume Control.

world of sound Spectrum - chapter 4.3: Sound Effects - Management timbre.

world of sound Spectrum - Chapter 4.4: Programming sound effects - music programming.

world of sound Spectrum - Chapter 4.5: Programming sound effects - Polyphonic ringtones (polyphonic).

world of sound Spectrum - chapter 4.6: Treatment of external signals - digitization.

world of sound Spectrum - Chapter 4.7: Handling of external signals - Reverberation.

world of sound Spectrum - chapter 4.8: Synthesis of speech.

world of sound Spectrum - Chapter 4.9: audio playback interrupt.

world of sound Spectrum - Chapter 5: The operator PLAY for music coprocessor AY- 3-8910 (AY-3-8912).

world of sound Spectrum - Chapter 5.1: Creating effects operator PLAY.

world of sound Spectrum - Chapter 5.2: Making Music on PLAYe.

world of sound Spectrum - Chapter 6.1: Description of the coprocessor registers of the musical AY- 3-8910 (AY-3-8912).

world of sound Spectrum - Chapter 6.2: Programming effects and music under the musical coprocessor AY- 3-8910 (AY-3-8912).

world of sound Spectrum - Chapter 7: Software Review ZX-Spectrum to create sounds and music.

world of sound Spectrum - chapter 7.1: Editor, Sound Effects SUPER SOUND.

world of sound Spectrum - Chapter 7.2: Music Editor Wham the Music Box.

world of sound Spectrum - Annex 1, 2: Listings sound effects SUPER SOUND'a, tips assembler.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Locman - Adventure Cruise (end of short stories).
Tusovka - a letter reading rooms: ICE'DI GRIZ on how to mark the anniversary of Chelyabisnkaya group Omega HC, Vladimir Anshukov a decline of interest in the Spectrum in Russia.

В этот день...   7 May