ZX Club #07
28 февраля 1998

Coding - technology and algorithms demomeykinga: rapid withdrawal schedules through the stack.

<b>Coding</b> - technology and algorithms demomeykinga: rapid withdrawal schedules through the stack.
(C) Saruman / Dementia corp.

 Well, that was another demo-party,
Enlight-97, and again vylilo on the heads of the poor users a 
bunch of cool and clever demos. A poor user sits, looks at 
them, and nothing at all, then it is not clear: how all this 
can be possible? But possible, and the proof here it is - before

eyes.
 This is a small tip may serve as a
starting point for a series of articles in which I try to tell 
a little about demomeykinge, his techniques and algorithms. Of 
course, I do not such a cool coder as Rst7, Max Iwamoto,

Exploder, etc., but what I know - that little talk. I will be 
wildly happy if my work will help to write at least one 
distinct bend. And because it is best to start from the 
beginning, then today's topic will



     Rapid withdrawal schedules through the stack


                  - You know, I have on screen
                    wounds displayed 300

                    sprites in a single transformation
                    on closing, and I can not

                    get rid of the scintillation
                    of. Help!

                  - Now you someone

                    advise you to withdraw them

                    the stack. ;-)

                            From the correspondence

                            in the FIDO


 Perhaps the reader will carefully tracking
for all electronic media, indignantly
exclaim: "How much can you talk about it ?!?!?" How long does 
it! Once more there are demos with sprites and trembling 
glyuchaschimi effects (as they appear!), Then says not enough.

 Thus, the basic idea behind this
method is as follows:


    The command execution time


  LD A, (reg) 7

  LD (reg), A 7

  INC reg 6

  DEC reg 6

  LD HL, (ADDR) 16

  LD (ADDR), HL 16

  POP reg 10!

  PUSH reg 11!

  LD SP, nnnn 10

 So, what do we see? For the transfer of two
bytes in the right place, we have three ways:
 a) use the register A. That is, we have

    about this piece of code:

       LD A, (HL)

       LD (DE), A

       INC HL

       INC DE

    Total 26 * 2 = 52 cycles. Ouch ... Mnogova
    then!
 b) Use register pair HL:

       LD HL, (ADDR)

       LD (ADDR), HL

    Total 16 +16 = 32 clocks plus time of
    change in ADDR. That is too much ...
 c) use the operations PUSH and POP:

       LD SP, nnnn

       POP HL

        ....

       LD SP, nnnn

       PUSH HL

        ....
 You say: "What is the best
way, if it takes as much time with 41! "But
I have not knowingly put in the code dots.
Think of the action teams PUSH and POP: with
PUSH is entering the value of the register address contained in 
SP, and decrease the value of SP at 2, with POP - on the 
contrary, these accrue from memory, and SP increases. And since 
we have as many as 10 register pairs, then we can set the stack 
only once for 20 bytes. The final code looks like this:



       LD SP, addr; SP = sprite_adr

       POP AF; H

       POP BC; and

       POP DE; m

       POP HL; and

       POP IX; e

       POP IY; m

       EX AF, AF '; with

       EXX; n

       POP AF; p

       POP BC; and

       POP DE; th

       POP HL; m


       LD (SP_1 +1), SP; Save SP


       LD SP, addr; SP = screen_adr

       PUSH HL; In

       PUSH DE; s

       PUSH BC; in

       PUSH AF; of

       EX AF, AF '; g

       EXX; and

       PUSH IY; m

       PUSH IX; n

       PUSH HL; p

       PUSH DE; and

       PUSH BC; th

       PUSH AF; m


       LD (SP_2 +1), SP; save SP

SP_1 LD SP, 0000; SP = sprite_adr

       ............ ; Again reading

       ............ ; Data

SP_2 LD SP, 0000; SP = screen_adr

       ............ ; Again conclude

       etc.
 Subtotal get 302/10 = 2.30 cycles for two
Bytes!
 As can be seen, the difference is palpable, especially when
withdrawal of large amounts of graphics. For maximum speed 
dostizheiya better to do without any cycles, and show more

the whole sprite.
 Now we discuss some useful
techniques that can help you.
 Often, especially in the demos, the picture consists of 
several repetitions of one and the same part. In this case, by 
itself, enough once considered this part, and then throw it to 
the screen the desired number of times.  If you need to print a 
sprite with a mask, it is often convenient to proceed as 
follows as follows: sprite store in memory mixed with a mask, 
and read at the same time and then, and more. Example:


       LD SP, data_adr; address sprite

       LD DE, scr_adr; address screen

       POP BC; B = mask, C = sprite

       LD A, (DE)

       AND B; A AND mask

       OR C; A OR sprite

       LD (DE), A
 It is this way, slightly modified, used to display the cursor 
in the journal. The cursor is stored as two 2_bayta_dannyh 
_bayta_maski. Before displaying the mask and sprite is shifted 
to the desired number of bits and received _three_ byte sprite 
rush on the screen. As you can see, everything works without

flickering and glitches!
 Oh, and all things that can be anywhere on the screen and still
and move (different cursors jumping
Smileys, etc.) need to show the very first to play music, 
converting coordinates, etc. Otherwise, even if you have 
everything working perfectly, can be caught any inhibitory 
complex, where the sprite begins to shake and flicker. Do not 
forget about this!

 A Whereupon I say goodbye today, if there are any questions, 
suggestions or proposal, then you can contact

me by phone 54-01-70 (ask Oleg)
or at the addresses given in Section
"Editorial." Bye!!!
_______________________________________End





Other articles:

From the Editor - On the new shell magazine.

News - How are things going with the organization of Barnaul Spectrum network.

News - Olimpiada'97 informatics or reflection at the end.

Games - Description of the game "NIGEL MANSELL WORLD CHAMPIONSHIP".

User group - Review of music editors: WHAM + AY, ASM, SUPER SONIC, SOUND TRACKER v1.1, STD v2.01, STR v3.00, SOUND TRACKER PRO, PRO TRACKER and utilities: S.T. COMPILER, S. T. RECOMPILER, S.T. MUSIC STEALER, S. T. REC + +, FLASH DECOMPILER.

Coding - technology and algorithms demomeykinga: rapid withdrawal schedules through the stack.

Ex Libris - Loneliness - a brief synopsis.

Ex Libris - Existentialism - a brief synopsis.

Ex Libris - Press: What are books?

Hard group - Expansion of computer memory, "Synthesis of 2 'to 128 KB.

Enjoy - The Tale of Saltan.

Enjoy - Short Story "Learn to shoot."

Advertising - free advertising and announcements.


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

Similar articles:
Forum Games - Subtleties trading game Elite
News - News from Ulyanovsk.
Advertising - Advertisements and announcements ...
ZX-NET - the story of ehokonfarentsii ZX.TALKING.

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