Inferno #02
01 мая 2001

For Coderz - the translation algorithm of color image in gradations Spekrumovskogo gray.

<b>For Coderz</b> - the translation algorithm of color image in gradations Spekrumovskogo
gray.
          Gray sky

(C) Shaitan / Stars of Keladan

 This is precisely the color you would see the sky,
if people did not have a color analyzer eyes. In my opinion I 
drive.  Well, here suggest vyshemu attention

description of algorithm translation of color
_Spekrumovskogo_ Image gradation
gray. You might ask: "Why
is Spectrum? "And everything is very
simple - because Spekruma special
construction of the screen, and the algorithm is to
and this is based. But if you understand the case, then such 
feature can be implemented to any platform, but it's not a fact.

 So, let's begin.
 First we need to decide how many shades of gray would be 
consistent Our flowers and build a table of 8

(16), texture units in the following format. First
are 8 bytes of zero color, then 8 bytes
the second and so on until the 8 th or 16 th. In
example shows the files of that
uses 8 levels of gray, from black
to white, including, but not attaching
much effort it can be easily peredalat
at 16, that is, taking into account the brightness of the flag.
Such an algorithm, and the procedure is used in the module Grey 
Scale Convertor versions 1.0 and 2.0 for rulezneyshego graphics 
editor BGE.  And now we have to listen to me very

carefully, so as to be beyond
description of the algorithm.
 I hope that you are familiar with
structure of the Spectrum screen and
you is not news that we are so we have 8 colors + 2 graduation
brightness of each, a total of 16 colors of ink and 16 in the 
background, and generally get 256 color combinations on 
familiarity.  The algorithm I will show you

in the following graphic area, which the ink is green, and the 
background red.




 For convenience, the digestion of my ravings
except for the image in full size
bring the image in an eightfold
magnification.
 So true. Read the attribute
appropriate familiarity and it
determine the numbers and start addresses
textures for the background and ink. Then read the first byte 
of familiarity to remember on the stack and put on a mask byte 
first byte of ink. The resulting bytes be gdenibud remember it 
for later recovery. Now remove from the stack byte value 
familiarity, invert him and put on his mask as the first byte, 
but the background. Now, as the opofigey, we must add to both 
OR'u masked-byte, and then we received bytes to put in place

the original byte. After all of the these actions we can proceed
by the second byte of familiarity, only
it is not necessary to determine the address of textures and
as a mask byte must use the second byte of the same texture.
 After we walked around
familiarity, we need him to put the attribute you want with the 
code # 38, that is background to white, and black ink and

it all off with brilliance. As a result, you have something like
(See color example).



 We can then proceed to
next familiarity, and all actions necessary to produce again.
 To better understand the quote you the original procedure of 
translation in shades of gray, which was used in the module 
with version 1.0 of BGE. 

SCREEN EQU # 4000
ATTR EQU # 5800

        LD HL, SCREEN

        LD DE, ATTR

        LD B, 24; lines in screen
M3 PUSH BC

        PUSH HL
LINFIL LD B, 32; familiarity in a row
M2 PUSH BC

        LD A, (DE)

        PUSH HL

        PUSH DE

        PUSH AF

        RRA; determine the address of the background texture

        RRA

        RRA

        LD DE, ATR_TBL

        AND 7

        ADD A, A

        ADD A, A

        ADD A, A

        LD H, 0

        LD L, A

        ADD HL, DE

        LD (PAP), HL

        POP AF

        AND 7, determines the address of the inky texture

        ADD A, A

        ADD A, A

        ADD A, A

        LD H, 0

        LD L, A

        ADD HL, DE

        LD (INK), HL

        POP DE

        POP HL

        PUSH HL

        LD B, 8; the number of bytes in the familiarity
M1 LD A, (HL); read bytes from familiarity

        PUSH HL

        PUSH AF

        LD HL, (INK)

        AND (HL); put ink mask

        LD C, A; remember

        INC HL

        LD (INK), HL

        LD HL, (PAP)

        POP AF

        CPL; invert the original bytes

        AND (HL); put a background mask

        OR C; connects two bytes received

        INC HL

        LD (PAP), HL

        POP HL

        LD (HL), A; put in place

        CALL DOWN_HL; Come over to the underlying byte

        DJNZ M1

        LD A, # 38, put the attribute

        LD (DE), A

        POP HL

        INC HL

        INC DE

        POP BC; proceed to the next

                     ; Familiarity

        DJNZ M2

        POP HL

        CALL LOWERHL

        POP BC; disguised to the next line

        DJNZ M3

        RET
DOWN_HL INC H

        LD A, H

        AND 7

        RET NZ

        LD L, A

        ADD A, # 20

        LD L, A

        RET C

        LD A, H

        SUB 8

        LD H, A

        RET
LOWERHL LD A, L

        ADD A, # 20

        LD L, A

        RET NC

        LD A, H

        ADD A, 8

        LD H, A

        RET
ATR_TBL; but it ourselves texture

         DEFB # FF, # FF, # FF, # FF;-BLACK

         DEFB # FF, # FF, # FF, # FF

         DEFB # 77, # FF, # DD, # FF;-BLUE

         DEFB # 77, # FF, # DD, # FF

         DEFB # AA, # FF, # AA, # FF;-RED

         DEFB # AA, # FF, # AA, # FF

         DEFB # 55, # BB, # 55, # EE;-MAGENTA

         DEFB # 55, # BB, # 55, # EE

         DEFB # 55, # AA, # 55, # AA;-GREEN

         DEFB # 55, # AA, # 55, # AA

         DEFB # 55, # 22, # 55, # 88;-CYAN

         DEFB # 55, # 22, # 55, # 88

         DEFB # 55, # 00, # 55, # 00;-YELLOW

         DEFB # 55, # 00, # 55, # 00

         DEFB # 00, # 00, # 00, # 00;-WHITE

         DEFB # 00, # 00, # 00, # 00
INK DEFW # 0000
PAP DEFW # 0000

6 In the appendix can we meet this source in the format Alasm, 
but without comment.  But what can be achieved by

This protsedurki.







Other articles:

For Coderz - the translation algorithm of color image in gradations Spekrumovskogo gray.

Inferno - Managing obolchka magazine.

For Coderz - Aparatnye computer errors ATM-TURBO.

For Coderz - Description of a personal computer ATM-TURBO 1.

For Coderz - Description of a personal computer ATM-TURBO 2 +.

For Coderz - how to programmatically determine the number of strokes in the line of cars equipped with Port # FF.

Shelezyaka - the prefix to the phone to remove noise and clicks.

Shelezyaka - Pagemaker: refinement of weaving displays the page number memory.

Shelezyaka - NEW BRIGHT: Sixteen full-color mode.

Interview - an interview with the leader of the Samara spektrumistov Unbel! Ver / XTM.

Others - the outcome of the failed survey.

Others - ROMkadrom (humor).

Others - Safemode: computer crime and information warfare.

Others - Thoughts aloud: "All your thoughts about that Sreccy already bent, are complete nonsense ... "

Softinka - description of a new text editor ZX-WinWord V3.0.

Softinka - description of a new text editor ZX-WinWord V3.0 (Oberon Creative Pack).

Softinka - File Extractor: File Extractor.

Gameland - How to write a play. Volume 3. Part One.

Gameland - How to write a play. Volume 3. Part One.

Gameland - the latest demo spekrumovskoy Amiga version znaminitoy Toys WALKER.

Gameland - the third demo of the game Wolf 3D.

Samizdat - Dragonland: Presentation.

Samizdat - Dragonland: Wild Honey.

Samizdat - Dragonland: When the rain ...

Samizdat - "Bastard AlHimik Doctor Faustus Plumed Serpent "№ 1.

Samizdat - "Bastard AlHimik Doctor Faustus Plumed Serpent "№ 2.

Samizdat - Something like Kashpirovsky ....

Soap - Letter from nowhere.

Inferno - The authors.

Inferno - Intro.


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

Similar articles:
Ottyag - Terminology of the user or the modern spoken language. Marazminki: 10 reasons why the dinosaurs became extinct. 10 contenders for the Ninja Turtles. 10 things you could do V. Van Gogh. 10 things you can cry, stealing back to my Granddaddy. 10 things that would gluppo say what who came to buy your house. 10 things you can give a deaf-rodst ots. That you should not say or do, if you nazh- ralsya. Chinese poslivitsy. The Gospel of Mitkov. Tests: "Are you cool demomayker?" "Do you have friends?" "Russian Folk Chernushka" (scanned images of SERGA)
Forum Games - Passage Renegade.
From the Editor - On the future of newspapers

В этот день...   27 April