Soft Group - Running lines outside the screen.

ZX Club #09
                                          
     (c) Alex Rostov / Dementia Corp.     
__________________________________________
                                          
 Tickers outside the screen.        
                                          
    The topic of border effects has been around for a long time
well covered in the literature, but to some extent
some subtleties of their implementation I would like
stop in more detail. The basis for
such a step is served by the plight
demomaking in Barnaul. I would like to see
Barnaul not only has its own demos, and not demos
ki of my good friends and acquaintances, and new ones
(maybe not particularly professional, but
NEW!!! ). In this regard, I again spent
I'm living this topic. This short article
I hope it helps you deal with this
interesting effect, like graphics outside
screen...                                 
                                          
1. Introduction                             
                                          
    ...that day I took my jaw to
corman, as it fell off completely.
It was a sunny autumn day. It's my first time
saw the hidden part of Insult Megademo...2. Theory                                 
                                          
    To begin with, it would not hurt to figure out
what is BORDER and how is it formed
image. As you know, BORDER is about
power that is outside the standard spectrum
room screen and occupying all the remaining
a place running away from him. Unfortunately, the only
great thing we can do with BORDERom,
is to change its color.  No points on
We won’t be able to deliver it. What then
run creeping lines along BORDERy? - asked
sit you. Here's how. Comes to our aid
our native cathode ray tube. All
the fact is that the image on the screen can
nitor does not appear immediately (whether SCREEN
or BORDER), and is drawn from top to bottom
from left to right with a certain frequency - 50
frames per second. The color of BORDERa depends on
contents of port No. 254 (#FE). It contains
a byte will be created, the least significant three bits of which are
cherished for the color BORDERa (the remaining bits
do not affect the color, we reset them to 0).
Now we only need to “slip”
the ray that draws the picture on the screen,
the values we need. As soon as the beam
reaches the place where we need to
put a dot, send color to port #FE
points. As soon as the beam has passed the point, it sends
bark into the port the number of the background color or another
points. This is, in principle,the whole algorithm.
                                          
3. Problems                               
                                          
    Despite such a simple algorithm,
in practice we are faced with quite
serious problems. One of them is
synchronization problem. The whole trouble is that
you can almost never guess where
the beam is located at a given moment in time.    
    The solution to this problem is very simple and
Port #FF helps in an effective way, but
since not everyone has it (more precisely, it
almost no one has it), then from this method
we immediately abstract ourselves and talk about
I won't be here. If anyone is interested,
you can call me and I'll tell you how he is
works.                                 
    Another solution to this
problem is synchronization under pre-
tearing. It just so happens that the frequency, s
which interruptions come a penny in a co-
pieku coincides with the drawing frequency - 50
hertz (= 50 frames per second). From this de-
We conclude that after 1/50 of a second the beam will
child will be in the same place where he is now
time and where it was for 1/50th of a second (i.e.
exactly one interrupt) ago.             
    Unfortunately, this only solves the problem
half. We still don't know where
this is where the beam is located. Thisdepends on type
computer (more precisely from its INTa), and since
Everyone's computers are different, no syn-
At first glance there cannot be chronicity
and speeches (here I will make a small reservation:
Lately all demos (99.9%) are being written
for INT computer Pentagon 128). But also from
There is a way out of this situation. Such a way out
I was first found by the authors of KAZAN Demo
(Enlight 97). They offered the user
configure the program yourself
your computer by adjusting the delay,
preceding the output of the border image
nia:                                      
 1. interrupt                        
 2. adjustable delay             
 3. image output                 
                                          
There is another method that gives the best results.
results - disable interruptions and achieve
by adjusting the delay so that
exactly 1/50 of a second, when the beam
is located in the right place, the program is just right
I got to the image output procedure.  On
in fact it is not difficult at all if you
You have a table at your fingertips over time
of each command (in measures) and if you
do you know how many processor cycles it takes?
for 1/50seconds.                          
    There is another problem that needs to be solved
This time it won't work. It consists of
that the command to output a byte to the port is required
there are at least 12 measures, and in one measure
the beam is shifted by two pixels.  We get
2*12=24 pixels (= 3 familiar spaces). This is known
cheat, that's a point, already than 3 familiar places to us
it will not be possible to place (the height of the “point” is 1
pixel). There's nothing you can do about it,
this will have to be accepted. It is for this reason
reason border graphics rarely go beyond
frames of horizontal stripes (for some reason I
suddenly I remembered the procedure for downloading a program
ramm from tape...). As already said
above, in one clock cycle the beam passes two pixels
la, the one that moves the image to the board
Duré left/right is only possible by 2*n peaks
selov ( n = 1,2,3...), adjusting the delay.
You can move the image vertically
for any integer number of pixels.       
                                          
4. Implementation                             
                                          
    So my little curb lovers
effects, it's time to talk about
the main thing - about the application of the above theory -
ria to the running line on the border.         
    Let's say we want to start scrolling at
top of the screen, above the screen area
tew (let's assume that you understand where it islocated :-). To prevent interruptions
interfered with our work, we'll put it on interruptions
IM2 just one command:                   
RETI                             
i.e. the interrupt does not perform any functions
tions, therefore will not affect the beam,
carrying out additional, it is unknown how-
what a delay. Next we perform it cyclically
the following algorithm:                       
                                          
- we wait for the interruption to come. This is de-
   assembler command barks               
HALT                             
                                          
- we make the necessary delay, for example
   performing some neutral-
   new command like                      
NOP,or                         
LD A,A                           
 Cycle parameters depend on the type of computer
   tera, from the location of the scroll and sub-
   are fought manually.                        
                                          
- display the image. At this point I
   I will go into more detail. For withdrawal
   we will use the commands: OUT (C),A #ED79        
         OUT (С),В #EDЧ1        
 OUT (C),D #EDS1        
         OUT (C),E #EDS9        
         OUT (C),H #EDb1        
         OUT (C),L #EDb9        
                                          
To work, we need a buffer of size
(l*2+1)*h+1 bytes, where l is the scroll length in
"points" with three familiar places (18), h-height
scroll (8) in “dots” of x pixels ( per
example x=4). That is, the buffer will consist
of x*h lines of l*2+1 bytes. Now I'll explain
where do +1 come from. Firstly, at the end of this
of the buffer we will place byte 201 (command
RET), and secondly at the end of each line
position byte 0 (NOP command). Since
this buffer will consist of command codes
assembler (how cunning!..), RET for us
will be necessary in order to ensure the possibility
gate to the program when we turn-
access this buffer as a subroutine (with
using the CALL command). Each line of the buffer
ra will consist of l (18) pieces of commands
OUT (C),N (N - some register) then
is from the byte sequence ED NN ED
NN ED NN...NOP. Why NOP? But why.
The whole point is that the ray passes through one
screen line for 224 (remember this number)
processor cycle (if you don’t have quite"left" Speckie). As already mentioned,
the OUT (C),N command is executed in 12 clock cycles
processor. Obviously, in one line we
we can fit no more than 224/12 =
18 "dots" of 24 pixels. But since 12*18=216
we have 8 “extra” clock cycles left. Here they are
then fills in NOP.                       
    Now to display an image (eg
measures of the running siroka) will be placed after each
The next byte #ED is one of the following bytes:
#79 (register A), #41 (B), #51 (D), #59 (E)
#61 (H) or #69 (L). Let's start the yellow scroll
on a blue background (for example). Then if Nth
the point must be colored yellow, write down
we write after the Nth byte, equal to #ED byte
#69, if in blue - #61. Now in front of you-
by the call of this subroutine, the
Ti 6 (yellow), and in N - 1 (blue) and everything is OK!
Now, in order to change the color of the scroll-
All you need to do is change the L register, the background color
on - N.                                   
    They took me out. How can I make her
run? This is implemented by changing
delay before calling the output routine
images Please note that when changing
hold for one beat the image shifts
np two pixels! I wish you good luck in programming
Vania. For any questions call me:      
                                          
 42 - 48 - 07 (Sasha)              
          
              The END                     

Share your thoughts about the article