Demo or Die #02
31 июля 1999

Demo-Building - The implementation of plasma sizes of 2x2.

<b>Demo-Building</b> - The implementation of plasma sizes of 2x2.
__________________________________________

 Wolf of eTc / Scene


      Implementation of the plasma size 2x2

           (As in BooM trackmo)


   Write this article, I made
interest of some people to the plasma size
2x2, in our FunTop'ovskoy demo - BooM
trackmo.



   I hasten to add that this effect
very easy to implement. Its size
is about 150 bytes (excluding tables and
data). In the demo itself, the data for
implementation of the 2x2 plasma were established in advance
and take in the form of neupakovanom about 26kb
(!). In my opinion a lot, but I do not
meant to make fans
demomeykerstva long wait.

   So how does this all done?

   First we need to create
normal plasma size 128x96
(256/2x192/2) - this is due to the fact that
point we will have the size 2x2. At what
plasma must be constructed in 256
color (ie bytes per point).

   For those who do not know how one
normal plasma, read the rest
can skip the next paragraph.


  The algorithm is very simple. First, create
a grid of points in the buffer with some tasks
step, where the color of a point will be
random variable (0 to maximum
color values, such as "chunks" -
16). Then in the middle of each
square write the arithmetic mean
one of the two numbers (color values)
which are recorded at the vertices of
square. In the center of the square write
arithmetic mean of the four
flowers in the four vertices of a square. And so
continue recursively, until no
fill the entire buffer, ie until
reduced to the minimum squares
size. As a result, we have
plasma.


   There is another way to build a plasma
but this plasma I call - a sine wave.
In my opinion, this is a plazmochka
BestView (by Ivan Roshchin) in screensaver'e
(As custodian of the screen).

   I'm doing it this way:


   round (n) - rounded to the nearest whole number
values.

z1: = 0.25; z2: = 0.125; {all sorts of factors}

    for y: = 0 to 95 do {} elevation of plasma

    for x: = 0 to 127 do {width} of the plasma

    c: = round (32 * sin (x * z1/pi) * sin ((x) *
z2/pi) +32 * cos (y * z1/pi)); {proper
formula for the plasma}


   As you can see here, depending on the
coordinates X and Y, the function will have
a result that matches the color
point with the same coordinates.



   Having such a plasma size 128x96
(Total length 12,288), create a data
Our unpretentious effect.

   For clarity, we will do this by
Pascal, but who knows, I think
after such source quickly to it
get used to it, especially with my
comments.


  plasma [1 .. 128.1 .. 96] - an array of
128x96, which houses our plasma;

  data [1 .. 12 288 * 2] - an array which will
stored the coordinates of the plasma;

  data_len [1 .. 256] - an array, where it will
contains information about the number of
dorisovuyuschihsya points per frame.


  A little bit about the syntax of Pascal:

   inc (n) - to increase the variable n to 1;

   dec (n) - to reduce the variable n to 1;

   plasma [x, y]: = C - Record the variable C,
in a cell array with coordinates x, y;


   i: = 1;

   j: = 1;

   for phase: = 1 to 256 do

   begin

    len: = 0;

    for y: = 1 to 96 do

     for x: = 1 to 128 do

      begin

       if plasma [x, y] = 0 then

            begin

                data [i]: = x;

                inc (i);

                data [i]: = y;

                inc (i);

                inc (len);

            end;

       inc (plasma [x, y]);

      end;

    data_len [j]: = len;

    inc (j);

   end;


   This procedure examines each
pixel plasma to zero color. Namely,
writes the buffer coordinates (X and Y)
each of the zero point and the second buffer
number of points found in one
passage. So do 256 times. This is due to
the fact that the plasma is used for byte
pixel.

; (C) CopyRight by Wolf / eTc / Scene 1998
; From BooM trackmo


        ORG 25000

; Throw the picture (black)

        LD HL, SCR

        LD DE, # 4000

        LD BC, 6144

        LDIR
, Paint it some color

        LD HL, # 5800

        INC DE

        LD BC, 767

        LD (HL), 28

        LDIR
; Create a table of addresses screen

        LD HL, TAB

        LD DE, # 4000

        LD B, 96; (192 / 2) as 2x2 points
CRUNCH1 LD (HL), E

        INC HL

        LD (HL), D

        INC HL
; Procedure for calculating the addresses of the screen through
; Two lines

        INC D

        INC D

        LD A, D

        AND 7

        JR NZ, DONE

        LD A, E

        ADD A, 32

        LD E, A

        JR C, DONE

        LD A, D

        SUB 8

        LD D, A
DONE

        DJNZ CRUNCH1

; Actually very beginning


        EI
START LD A, 4; show all

        OUT (# FE), A; how much it

        HALT; "eating" time

        XOR A

        OUT (# FE), A

TIME LD A, 0; loop counter

        DEC A; initialization

        JR NZ, COOL


        LD HL, TABLEN; set options

        LD (F1 +1), HL; if the counter has gone

        LD HL, DATA; on the second circle

        LD (F2 +1), HL

        XOR A
COOL LD (TIME +1), A


F1 LD DE, TABLEN
F2 LD HL, DATA

        LD A, (DE); how many points to draw

        LD B, A

        INC DE

        LD (F1 +1), DE

        OR A

        JR Z, NO_P
PRN PUSH BC

        LD A, (HL); \ = x

        INC HL; |-coordinates

        LD E, (HL); / = y

        INC HL

        PUSH HL

        LD L, E

        CALL PLOT; Draw point

        POP HL

        POP BC

        DJNZ PRN; draw on
NO_P

        LD (F2 +1), HL


        LD A, # 7F; poll gap

        IN A, (# FE)

        RRA

        JP C, START

        RET; Output:)



; Procedure for drawing points, size 2x2
; When drawing, the point xor'itsya.
; A = x, L = y
; (C) By Wolf / eTc / Scene 1998
PLOT

        LD H, TAB [

        PUSH AF

        LD A, L

        ADD A, A

        LD L, A

        POP AF

        LD E, (HL)

        INC HL

        LD D, (HL)

        LD L, A

        RRCA

        RRCA

        AND # 3F

        ADD A, E

        LD E, A

        LD H, D

        LD A, L

        LD L, E

        AND 3

        LD D, (TAB +256) [

        LD E, A

        LD A, (DE)

        LD E, A

        XOR (HL)

        LD (HL), A

        INC H

        LD A, E

        XOR (HL)

        LD (HL), A

        RET
; Table lengths
TABLEN INCB "tablen"
; Address table screen

        ORG ($ -1) / 256 * 256 +256
TAB
4-points and options

        ORG TAB +256

        DB 128 +64.32 +16.8 +4.1 +2
, "Slonyachie" data
DATA INCB "data"
; Layback etc group
SCR INCB "etcgroup"


 Alexandr Kulik (Wolf) 2:4635 / 8.18 @ FidoNet
__________________________________________







Other articles:

Deathmatch Quake v. 2.00 - BRIEF manual on methods of deprivation life of their own kind.

Demo party - OFFICIAL results Chaos Construction 999 for the PC.

Demo party - OFFICIAL results Chaos Construction 999 for the ZX Spectrum.

Demo party - OFFICIAL Paradox'99 results for the PC.

Demo party - OFFICIAL Paradox'99 results for the ZX Spectrum.

Demo-Building - Phong Shading.

Demo-Building - Radial blur, blur effect around the bitmap.

Demo-Building - Generator table of squares.

Demo-Building - an ancient effect a tricky name Moving Shit.

Demo-Building - some of sorting method.

Demo-Building - The printing of chunks.

Demo-Building - The implementation of plasma sizes of 2x2.

NeOS FAQ - Frequently Asked vopposy operating system for ZX Spectrum - NeOS.

Interview - Interview with Dennis Ritchie (Dennis M. Ritchie) creator of the programming language "C".

Interview - an interview with a famous coder'om, one of the founders M & U Sinclair Club, and later eTc group - Lazy.

Interview - Interview with the encoder and zhelezyachnikom LD / X-Trade.

Criticism - Kartika at first nome.p zhypnala Demo or Die.

From the Editor - interface.

From the Editor - Epilogue.

Application - wrapper display files LazyPack 2.0.

Advertising - Advertising and announcements.


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

Similar articles:
attempt at writing - An excerpt from the novel: Labyrinth of Reflections.
Presentation - the announcement of the new paper "Stonehenge".

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