Nicron #105
13 декабря 1998

Programming - support operations in deriving spraytav area of the display memory.

<b>Programming</b> - support operations in deriving spraytav area of  the display memory.
    Auxiliary operations
          the derivation of the sprite
    in the area of ​​the display memory

(C) Spencer Winset / Diamond group / Moscow



   Preface


   As you read the title of this article, I ask myself: My God, 
what else can come up with such and such sort of in an area 
where no lay a horse in 1982. Not even persuade me to tell

you about the device address space on the Spectrum - this
so we all know that space is not completely solid, ie
it is not continuous, but rather because we sometimes think ...


   We approached the subject of conversation - the calculation 
of the screen address the underlying line. There are about five 
conventional methods, that make appalled spektrumistov their 
time of execution of the problem. Next, give them as 
performance: 

1.Podborka at random. There's nothing funny - when you sit in 
STS'e, 

  nothing more quickly you can imagine.

2.Raschet on a calculator or in BASIC for uncomplicated formula 
16384 +2048 * i +32 * j +256 * k + x  where i = [0-2] 
number-thirds of the screen; j = [0-7] line number of 
characters;  k = [0-7] line number in the symbol; x = [0-31] 
number of characters per line.  This is for those who like a 
little longer, but one time and accurately. ;) 

3.Krutaya protsedurka for those who only studies of the logs
  optical commands over the battery and their impact on the 
flags. 

  Total cycles: for every "normal" line = 27 cycles

  and on every eighth = 60 cycles.

LOGDW_HL INC H

          LD A, L

          AND # 07

          JR NZ, $ +12

          LD A, L

          ADD A, # 20

          LD L, A

          CCF

          SBC A, A

          AND # F8

          ADD A, H

          LD H, A

4.Etot algorithm "DOWN HL" Many people know, and some have 
already forgotten 

  how it works, yes it does not matter. I think this is the 
second of Ca   Mykh commonly used algorithms, after cleaning 
the screen 

  LDIR'u. On cycles: for each "normal" line = 27 cycles

  for every eight = 59 cycles and each 64-th line (from the 
requirement   TI third) = 49 cycles. Going Fullscreen - an 
average of 30.84 

  bars on each line.

DOWN_HL INC H

         LD A, H

         AND # 07

         JR NZ, $ +12

         LD A, L

         ADD A, # 20

         LD L, A

         JR C, $ +6

         LD A, H

         SUB # 08

         LD H, A

5.Po plate (192 * 2 = 384 bytes), which contains two bytes, 
meaning the   ing the beginning of each subsequent line. In 
deep childhood I ka   It turned out that it is very wasteful 
for the memory. : / 


         POP DE

         LD A, E

         ADD A, C

         LD E, A

Total cycles: for each following line = 22 cycles. Gentlemen,
it is not bad. It is possible and even faster (10 cycles), but 
then plate will have to sign the screen all the addresses, but 
it is 12 KB - Now that's really wasteful, but twice

faster. Say what you like, but the amount of memory in the 
computer (almost linearly) related to the quality of programs, 
and not far off a new Standard - Pentagon 512K.


6.How always, at this point there is a pessimistic optimistic
  Political Affairs: a possible faster?? "Yes!" - I say, from 
the mountains   The hardness of GOMOSAPIENSA. Algorithm Down 
Micro Dab (DMD), enables   that returns to come close to the 
maximum possible speed 

  4 clocks per line. Essentially, the method is well described 
by the following 

  scheme:

        L0
                 1, the output first line of the sprite

              INC H
        L1
                 2, the output of second-line sprite

              INC H
              .......
        L7
                 8, the eighth line of the output sprite

              LD A, L
              ADD A, # 20
              LD L, A
              JR C, NPOS
              LD A, H
              SUB # 07
              LD H, A
              DJNZ L0
        NPOS INC H
              DJNZ L0


   Now explain to the fingers. Conclusion sprite signs under
symbolic position, ie, eight lines (and each line is painted
the width of a sprite). For the algorithm is sufficient even
286-th processor). Rather, we must take the Y-coordinate, to 
make AND # 7 and jump to get the number of lines (L0-L7), as in

registre "B" number of character positions in the sprite 
(height). It's almost all; remained excluding emissions 
unnecessary lines when printing the last position (here the 
same action at the beginning of the Y-coordinate). It's as 
simple as take pocket money from pervoklasnika; +). 

   Total cycles: for every "normal" line = 4 clocks,
for every eight = 37 cycles and each 64-th line (from the third
third) = 31 cycles. Going Fullscreen - an average of 8.03 cycles
on each line.

   If you download an application: dmd.H and activisn.C, you do 
not should be asking questions, just crank ALASM, and forward 
to new victories! 

   It's not all: if you want, based on the principle of the 
algorithm Down Micro Dab (DMD), the average cost per line can 
be reduced almost by half. 


   Now to complete literacy classes want to give useful advice, 
especially on the game-makers: Do not choose the size of 
sprites, the height of eight times (eg 3 * 3 simv.poz), as 
generally accepted as it steals from you and nick 59/10/37 
ticks depending on the method of calculation. Best format for 
the sprite height - it is eight times the number of lines minus 
one! Can now multiply the number of sprites on 59/10/37 and 
will learn much to save on trifles. 


                Date: 22 November 1998

        Goljakov Evgeny aka Spencer Winset / Diamond group
        ZXNet: 500:95 / 550.8


m Editorial


   Dear readers! Your feedback on this article, you can send to 
ZXNet-author's address and the address of the newspaper Nicron. 

            *







Other articles:

Entry - the contents of rooms.

BBS - list of stations BBS ZXNet.

Programming - support operations in deriving spraytav area of the display memory.

Iron - revision CDOS-modem.

Soft - bug mail editor "Lara Croft".

Story - On the bridge.

Advertising - advertising and announcements.

Feedback - contact the publisher.


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

Similar articles:
Iron - Yugoslavia - landfill?
Interface - the story of creating a virtual party of Antique Toy.

В этот день...   21 November