Lesson assembler no.3
____________________
(C) Phantom Lord
Music by Shov
Today I will talk about things, which sometimes
greatly interfere with programmers in implementing their ideas
about television ray. The idea of writing about this poser
tossed to me by a friend of mine, because he had it
encountered. I think that the effect peregibaniya or
disappearance of familiar images everything, so if you do not
know how to use it fight, you better read this text -
useful.
To begin to tell how to construct an image on the screen.
Spectrum screen is divided into 320 (The Standard, on the old
models of Scorpio 312) lines in length at different computer
models are different, but try to adhere 216/224 CPU cycles.
Beam moves from left to right and reach the right limit to the
next lower line. The entire path of the beam across the screen
named "frame'om. One second is equal to 50 frames, ie beam for
a second doing your (hard) way 50 times. For beam steering (if
I may say so) there is only one team - HALT - This command
allows the line finish the picture and proceed to the
construction of "new" screen, ie, gives the line command to
start your move again.
Now, when problems arise?
Axiom: If you print on the screen in the
where the beam has already passed, then in this frame
You will not see the image!
Now you probably understand why, in
many programs, the cursor is at the top
invisible. For those who do not understand, explain. Consider
the scheme of the cursor:
1. Restore the image that
was under the cursor;
2. Save the image under the cursor
the new coordinates;
3. Print this cursor.
So as long as the first two
item, the beam is below the origin line.
Here and apply our axiom, ie Cursor
you will not see.
Once the problem is understandable, it is necessary to develop
methods to combat it. There three practical methods:
1. Synchronization of images by
clever algorithms.
2. Ispolzyvanie two screens for
a Multi.
3. Ispolzyvanie port attributes # FF
Go talk about the third method. I hope
no it will not take advantage
programs, since by my calculations
90% spektrumistov do not have the port # FF. The advantage of
the port # FF is that you do not need to know the peculiarities
of INT'a computer. You can always port # FF find out where the
beam in the zone BORDER or PAPER. And this is the knowledge
needed to torye programmer to synchronize their masterpieces.
Now for the first method. It is that you will visually
synchronize your program with the beam so that each printed
output object to the moment before it reaches the beam. To
determine where the beam should be change the color of the
border, we t.e.dopustim is how to print the sprite and we need
to determine where it will beam after sprite as printed.
A_1 EI
HALT
LD A, 7
OUT (# FE), A
CALL PRINTSPR
LD A, 1
OUT (# FE), A
JR A_1
* Do not forget to put HALT.
The border of white and blue bardyura exactly
will show the location of the beam
on the screen.
The third method is the easiest - no
need to synchronize, but it acts on the
machines with 128K. In this configuration, the computers
instead of one screen from the address 16384 (# 4000), there
exists a second screen - RAM 7 with 49,152 (# C000). What is
the essence of this method? We divide the frames into even and
odd. In the even will convert the image on a screen, and
display images at 2, and odd to be processed at 2, show 1. (It
should be say that a screen located in the RAM 5 with the
address 49152, but it's still the same screen that
and 16384.)
To understand how you can show a
screen and work with others, simply
know the operation of the port # 7FFD.
4-bit port is just responsible for what is displayed.
For example: BC = # 7FFD
LD A, # 10
....,# 11
....,# 12
....,# 13
....,# 14
....,# 15
....,# 16
....,# 17
OUT (C), A
Lead to the inclusion of 0,1, .., 7 pages
terminal 1 of the screen.
If, however, ignite 4 bits:
LD A, # 18
.....
LD A, # 1F
OUT (C), A
That will switch 0.1 ,..., 7 page with the conclusion of 2
screens.
Now you probably understand everything, but I
nevertheless give an example program to work
with two screens:
AGAIN EI;
HALT;
LD A, # 17; Vkl.7 Bank - 1 zkran
CALL STRAN;
CALL ACTION; performs an action
LD A, # 13;
CALL STRAN; vkl.3 Bank - 1 screen
CALL # C006; music
EI;
HALT;
LD A, # 1D; vkl.5 Bank - 2 screen
CALL STRAN;
CALL ACTION; ....
LD A, # 1B;
CALL STRAN; vkl.3 Bank - 2 screen
CALL # C006;
JR AGAIN;
That's - that's simple. If that does not
clear, then wait for letters.
__________________________________________