Revival #03
02 августа 1997

System - Marquee on Border'e and foundations Multicolor'a for novice programmers.

<b>System</b> - Marquee on Border'e and foundations Multicolor'a for novice programmers.
                           SYSTEM



   That came in the first paper edition of the reader from the 
city Taganrog. How well it turned out - to judge you, dear

readers.


                                            SEM / CODERS 
'ACADEMY 



             HOW TO MAKE BORDER benefits.



   Many zhyrnalah I met povody articles on the use of
curb and myltikolora, but in none of these articles, I have not 
found no practical example, one only a theory, which I

could be understood only malyyu part. That's why I decided to 
concoct ety article in which a practical example pokazhy as 
possible use the curb and myltikolor, and besides you pomogy

make these effektiki work on all wheelbarrows same, ie
without blinking and zakosov in different directions.


   To begin to explain the principle of constructing the image 
on the curb: piece of iron, is responsible for the image, takes 
the color of the border port and begins to paint with this 
color, only I take it that color to draw each pixel, if ever 
poetomy change the value in port, you can polychit bands of 
different color. That band rather than pixels, because minimum 
time mezhdy color change equal to the time of the command OUT, 
t.e.12 cycles, or 11.5, but it does not play a big role, 
because for this yspevaet time to draw a line length of 3 
familiarity. Poetomy lowest point on the curb is 32 X 1 pixel, 
and This, unfortunately, nothing can be done.



   Ny and now it's time to move from theory to practice. First
step is to release 20 kilobytes for protsedyry Drawing
image. Dopystim, this block begins at address ADDR. For
fill them with kysok address ADDR +8 repetitions type:

   DEFS 19, # ED, # 69 = 19 X OUT (C), L

   DEFS 19, # ED, # 61 = 19 X OUT (C), H


   With the address ADDR is a small eyelets, which will
interrupt and start prorisovky border:


   LD BC, # 00FE

   LD HL, # XXYY; XX - paper lines, YY - ink lines

   EI

   HALT


    Number of DEFS must comply kolichestvy pixel
lines involved in the row. Takim, the entire string in
MASM'a format might look like:

BORDER: LD BC, # 00FE

        LD HL, # XXYY

        EI

        HALT

        BEGIN ZZ

        DEFS 19, # ED, # 61

        END

        DEFB # ED, # 71 (1)

        RET

(1) is equivalent to OUT (C), 0, but MASM does not understand 
takyyu mnemoniky, poetomy I used DEFB. This command is 
necessary in order to the rest of BORDER was black. ZZ-number 
of pixel lines occupied by the vertical lines. But this is not 
a line, and just part of risyyuschaya static image, but we have

must move it! We now construct protsedyry shift:

SCROLL: LD DE, ADDR +9 (1)

        LD HL, ADDR +11 (2)

        LD C, ZZ
LOOP1: LD B, 18
LOOP2: LD A, (HL)

        LD (DE), A

        INC HL (3)

        INC HL

        INC DE (4)

        INC DE

        DJNZ LOOP2

        INC HL (5)

        INC HL

        INC DE

        INC DE

        DEC C

        JR NZ, LOOP1

        RET


    Dannyyu protsedyry should comment on. As you probably
yspeli notice in pynktah 1 and 2 berytsya addresses are not 
themselves command OUT (C ),... And address on a byte more. 
This is done to so as not to throw those extra bytes # ED, 
because it will result in tselyyu tysyachy (if not more) 
cycles, and in pynktah 3 and 4 capacity for both addresses is 
equal to one-dvym same reason. 

   In pynkte 5 addresses built up again, so as not to capture
kysok with sledyyuschey line. Y now we have two very important
Block: drawing the line and its shift. It seemed, that would 
still nyzhno, but y do not yet have an image that we have 
gathered to shift, poetomy write yet another important building 
block - the block of image creation bykvy in byfere address 
BUFF. 

LETTER: LD A, 0

        INC A

        AND 7 blocks (1)

        LD (LETTER +1), A

        JR NZ, LET_BRD
TXT: LD HL, TEXT

        INC HL
LETTER1: LD A, (HL)

        OR A

        JR NZ, OK

        LD HL, TEXT

        JR LETTER1
OK: LD (TXT +1), HL

        LD L, A

        LD H, 0

        ADD HL, HL

        ADD HL, HL

        ADD HL, HL

        LD DE, FONT

        ADD HL, DE

        LD DE, BUFF

        LD BC, 8

        LDIR
LET_BRD: LD DE, BUFF

        LD HL, ADDR +44

        LD A, 8

        LD BC, 38
LETTR1: EX AF, AF '

        LD A, (DE)

        JR NC, PLT

        LD (HL), # 61

        JR NOPLT
PLT: LD (HL), # 69
NOPLT: ADD HL, BC

        EX AF, AF '

        DEC A

        JR NZ, LETTR1

        RET


   Block (1) will novyyu bykvy only after full draw
predydyschey.

TEXT - this is the address of the text.

FONT - this is the address of the font minys 256 bytes.

BUFF - this is the address where stored byfera tekyschaya bykva.

ADDR +44 - this is the address of the last OUT on the top line.


   Ny here, like, everything that had to write. Now we must
ety stroky work force. To this end, we write more odny
korotenkyyu protsedyrky, vyzyvayuschyyu all the others:

MAINBRD: CALL BORDER

        CALL SCROLL

        CALL LETTER

        IN A, (# FE)

        AND% 00011111

        XOR% 00011111

        JR Z, MAINBRD

        EI

        RET


    This program will provide a hasty crawling to the curb
com, y at which one gets to interrupt 72,960 cycles, ie
228 cycles per prorisovky one full-line screen. At drygih
com it bydet mow the right or left, depending on the
the speed of PC.

   How do strochky workable for all complex
bydet described later, and now how ylychshit quality
line. If someone typed the above prog, and they have earned, he 
probably noticed two distinctive features of this SCROLL'a:


1. Bykvy very broad.
2. Line runs too fast.


    The first was pynkt will explain the beginning of this 
article. Second pynkt The explanation is even simpler than the 
first: when we move stroky by one pixel on the screen it moves 
into three familiarity! Ystraneniya for this error can be 
dorabotky Block BORDER. Then he bydet be:


BORDER: LD BC, # 00FE

        LD HL, # XXYY

        EI

        HALT

        JP NOPS
NOPS: NOP

        NOP

        NOP

        BEGIN ZZ

        DEFS 19, # ED, # 61

        END

        DEFB # ED, # 71

        RET


   So as to refine the unit MAINBRD: now it looks
sledyyuschim as follows:

MAINBRD: CALL BORDER

        LD HL, (NOPS-2)

        INC HL
NIPS: LD A, 3

        DEC A

        OR A

        JR NZ, OKNIP

        LD A, 3

        LD HL, NOPS
OKNIP: LD (NIPS +1), A

        LD (NOPS-2), HL

        CALL Z, SCROLL

        CALL LETTER

        IN A, (# FE)

        AND% 00011111

        XOR% 00011111

        JR Z, MAINBRD

        EI

        RET


   If the you have understood, then as mentioned above, the 
work of the block for you to understand, but I just slychay 
everlasting: when would be called a block BORDER, it will work 
as before, but with one difference is almost imperceptible 
difference - it will go on 3 NOP'a. The question is, why? They 
did not change anything! Yeah, nothing change, but sozhryt 12 
cycles. When the address transition to NOP'y yvelichitsya at 1 
and sledyyuschem call them zahavayut not 12, and 8 cycles, and 
later - only 4 cycles. But it is!? Jump address again 
ystanovlen 3 NOP'a, but after that there is a call protsedyry 
SCROLL, which, in turn, will shift the image itself. Thus, the 
line does not move bydet three familiarity, but by odnomy that 
creates the appearance of a smooth shift. 


   Now I want to say that the line is written, and more with her
no problem, but I promised to explain how to make it run on a
any wheelbarrow, regardless of speed. To do this, we can write
protsedyry, which calculates the number of cycles in a 
wheelbarrow and sootvetstvyyuschie make conclusions. I do not 
include ety protsedyry due its size, but explained that she 
should do. The first thing score NOPs kysok memory length 20000 
bytes and then create protsedyry interrupt handling, which 
would be the second call removed from the stack the return 
address and puts it in yacheyky memory and then passed 
ypravlenie protsedyre counting speed. In the cell kyda you put 
the return address bydet kept the number of cycles divided by 
4, and folded with address equal to adresy start NOP'ov.


   Before you pass on ypravlenie pystoy block needs to be done 
HALT and JP ADDR1, where ADDR1 is pystogo address block. When 
first HALT protsedyra interrupt just come back and second 
interrupt will remove from the stack the return address and 
place it yacheyky in memory.



   Protsedyra calculation speed should do sledyyuschee:

A. Take the number of memory cells, kyda put the return address.
B. Subtract from it the value ADDR1.
B. Divide polychennoe number 80 (polychim dliny string

   bars).
G. From polychennogo subtract 216.
D. Multiply a reward of 2.
Ye added to ADDR2.
J. From polychennogo addresses take 2 bytes.
Z. Substituting these bytes to the end of each line in the 
procedure BORDER. I. Pass the ypravlenie MAINBRD.



   ADDR2 - address table, which stores the command speed
performance of which varies on a cycle, the first two bytes 0,0.
The team should meet dvym requirements, namely to be 
dvyhbaytnoy (or replaced by two single-byte) and not to spoil 
the contents of the registers BC, HL. 

   This algorithm was tested on yspeshno kyche computers and no
razy not looked scroll, but obnaryzhilsya new glitch: Some
COMP LINE begins to run not from the beginning screen, and 
LITTLE Move right or left.


   This software glitch ystranit pytem y me polychilos,
poetomy I postypil very simple: put zaderzhky after HALT and
Poll dvyh buttons that change the value of delay that
stroky shifted the left or right. As you probably noticed has 
finally arrived DEFS application saves the space occupied by 
the source, but after They take kysok compilation of 20 
kilobytes, which spoils case poetomy can be inserted into 
programmy tuner, which determine the speed and build protsedyry 
BORDER. It will save and compilation time and disk space. 
Recently, some zhyrnale I yvidel protsedyry, vypolnyayuschyyu 
dealer service tools count the number of cycles in the same 
row, but instead it ispolzovanie proposed in this the article 
gave is not very good reward for. That is, it worked, but not 
everywhere, some companies she lied, and the reward for a 
string kosela, poetomy rekomendyyu I use my algorithm to

normal work on ANY wheelbarrow.


   Here, pozhalyy, and all I wanted to tell you about the curb 
and Now I suggest you read up on no less amusing effect -

MULTICOLOR'e.



                      MULTICOLOR FOR ALL.



   Now I try to explain to you how to sbatsat MULTICOLOR
your wheelbarrow. No theory here is not bydet because it does
useless thing, poetomy srazy perehozhy to practice: before
how to create risynok, you need to HALT and nebolshyyu
payzy approximately 17920-18240 cycles. This nyzhno to
lych yspel get to the start screen area, and then pass
ypravlenie protsedyre constructing images from atribytov. This 
block should look like this:



        LD HL, DATA

        LD DE, # 5800

        BEGIN YY

        LD B, E

        BEGIN 8

        BEGIN XX

        LD A, (HL)

        LD (DE), A

        INC E

        INC L

        END

        LD E, B

; 


        END

        LD A, # 20

        ADD A, E · (*)

        LD E, A ·

        END

where XX - width myltikolora,

     YY - height myltikolora in familiarity

     DATA - the beginning of the address block that appears on 
the screen, 

            low byte must be 0.


   The above protsedyra allows you to display unit, consisting
of 32 (YY) pixel line width of 8 (XX) familiarity. order
to be able to display more lines, it is necessary
or use several such units, or replace all
INC L at INC HL. Also will have to put proverky the transition 
in sledyyuschy segment. To do this, after the block (*) must 
finish sledyyuschy snippet:


JR NZ, $ +1
INC D


   We should also add that the value of XX can not exceed 16,
as This slychae some wheelbarrows your MULTICOLOR just
stop syschestvovat, but instead bydet kycha stirred
colored pixel lines.


    should contain left the team for
lych yspel to go to sledyyuschey pixel line, and then
on the line y sledyyuschey you bydet not the color, as on 
predydyschey. But it should be noted that, as for BORDER'nyh 
effects, this unit should be adjustable to any computer. This 
can be done with the help of the protsedyry, which was cited in 
an article on BORDER'e. Another thing I would advise you to 
delay block not wait until until lych move to sledyyuschey line 
and start to 6-8 cycles earlier. it ystranit 'zakos' 
MULTICOLOR'a. With this protsedyry can also be made SCROLLER, 
bouncing on pixels, so even with a different color bykv. For 
some prefer, you can SCROLL to combine BORDER'y and 
MULTISOLOR'ny SCROLL. I tried polychilos pretty cool, that's 
only been one problem: on some wheelbarrows both SCROLL'a fled, 
but BORDER'ny SCROLL fled or left or right MULTICOLOR'a, and 
this had to adjust vrychnyyu.



   By the way I tried to combine the curb and scroll 
MULTILOADER, polychilos funny if you do not take into account 
that the scroll constantly shaking and it's neither as not 
correct, even vrychnyyu. Most likely, it is connected to the 
controller TR-DOS. 


   If the y you have any objections or additions, please call me
or write to Fido (see address in the Mail - SN).

PS: If you are using the data above protsedyr and algorithms 
for link to the author!



                                          SEM OF CODERS 'ACADEMY





Other articles:

From the Author - the correct pronunciation of the name of the newspaper.

News - stopped going ON-Line. The contents of the log Spectrofon N22, 23.

News - miniintervyu Lav aka Dr, Sampler.

News - a new assembler Masm 2.0.

Thoughts aloud - Doom of Inlayte'97: news from the Flash and Softland.

new software - On how to make inappropriately releases of games. List of leaders in one way or another Spectrum of activity. The work of the Novgorod Digital Reality.

System - Marquee on Border'e and foundations Multicolor'a for novice programmers.

Mail - on the Spectrum and Spektrumistah in Taganrog.

Mail - The four groups - Magic Soft, MegaCode, Beermans H.G. and Speed Co. - Merged into the new larger organization - Extreme.

Likbez - As translated Russian names into English.

Cache - Something from POKES for games (small group pokov).

Application - On the games included in the application: Road Runner, G-Man, Master of the Uuniverse, Infection, R.B.I. - 2.


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

Similar articles:
Nemo open letters № 2.9
Softinka - Music Editor Pro Tracker v3.71. Revision history.
VIP - an interview with Arny and Mythos, the creators of Elite clone game Awaken.

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