Soft Group - chunky to planar conversion converter.

ZX Club #08

     (C) Saruman/Dementia corp.

  C2P converter

  Hello people! I am with you again, Saruman.
As I remember, last time I told
talked about methods for quickly rendering graphics
via stack; and today we have another powerful
nal method: chunky to planar conversion.
  Let me explain in more detail what the meaning is.
of this algorithm.  If you pay more attention
take a closer look at the latest demos, you'll probably
You will notice that in many effects for
16-color mode simulations are used
textures.   That is, an elementary unit
the image becomes not a pixel, but a square
rath with a side of, for example, 4 pixels. Ta-
Thus, in one familiar place we get
we eat 4 elements, each of which, with the help of
cabbage soup textures are “colored” in one of 16
flowers.  With this in mind, naturally,
stored as bytes per element (chunky
data), and when displayed on the screen it is necessary
convert data to standard
(planar) view.  To achieve maximum
fast output is what this algorithm serves.
  Note: I want to warn you that this
the method was not developed by me. I found out myself
about it from the files Explodera.

  Each byte of chunky data looks like:
 1000 0101

  Here the least significant 4 bits are the color (offset
from the beginning of the palette), and the most significant 4 bits -
- base address of the palette. But!!! after all, the team
Stack manipulation tools can read from memory
2 bytes at once!!! Therefore the palette will be
look like this:

#8080 00 01 02 03 04 .. .. 0D 0E 0F
#8180 10 11 12 13 14 .. .. 1D 1E 1F
. .    .    .    .    .    .
#8F80 F0 F1 F2 F3 F4 .. .. FD FE FF
 On the left is the address read from
chunky data, i.e. low byte - color of the
first of the output elements, the most significant byte is
- the color of the second.  Numbers are indicated on the right
textures output with this combination
colors, and in texture, naturally,
2 elements are shown at once. Those. first
row - all textures with second color 0,
second row - with second color 1, etc.
In total we get 16*16=256 textures.
  Well, now, having understood the format
data storage, you can proceed to
writing the withdrawal procedure.

  Required for work:

  SP = chunky data address;
  DE = address on the screen whereвыводить;
  B  = старший байт адреса,с которого хра-
     нятся текстуры.

     POP  HL       ;читаем chunky daty
     LD   C,(HL)   ;читаем адрес текстуры
     LD   A,(BC)   ;выводим
     LD   (DE),A
     INC  B
     INC  D
     LD   A,(BC)   ;  спрайт
     LD   (DE),A
     INC  B
     INC  D
     LD   A,(BC)   ;      на
     LD   (DE),A
     INC  B
     INC  D
     LD   A,(BC)   ;     экран
 LD   (DE),A
     INC  E
     POP  HL       ;читаем chunky daty
     LD   C,(HL)   ;читаем адрес текстуры
     LD   A,(BC)   ;выводим
     LD   (DE),A
     DEC  B
     DEC  D
     LD   A,(BC)   ;  спрайт
     LD   (DE),A
     DEC  B
     DEC  D
     LD   A,(BC)   ;      на
     LD   (DE),A
     DEC  B
     DEC  D
     LD   A,(BC)   ;      экран
     LD   (DE),A
     INC  E

  Ну  вот и все.Understand my writing
Nina and - let`s start da demomakin`! (Raz-
I ask you not to propagandize the gate ;-)
ed.) Do you have any questions, suggestions or
offers - call 54-01-70
in Barnaul, of course ;-)) and ask
Oleg - if he is at home, he will answer
everyone!
  Bye, people! C Ya l8r!!!
________________________________________End

Share your thoughts about the article