PROGRAMMERS
(C) Alexander Nikiforov
In this issue, I decided to introduce a new column in our
newspaper for novice programmers. In this issue I decided to
write about a very simple effect called
multicolor. As soon as I was going to write this
article in Minsk came ZX-FORMAT # 5, and
there was a small little article about the effects of
on border'e. In this situation, I decided
slightly reduce the presentation of my thoughts,
on border'a, but still do not be surprised if you notice some
repetition.
First, a little information. As is well known in the
ZX-SPECTRUM 50 times a second signal comes INT. Simultaneously
with the arrival of this signal IC ULA begins
form an image on the screen, starting
the upper left corner. One line of the screen
ULA brings over 224 cycles Z80 (in some
machines, this is for 220 cycles
[ZX-FORMAT # 5]). All at the Spectrum 312
lines, and the Pentagon - 320. Therefore, the formation of
images on the screen of the Spectrum occupies 312 * 224 = 69888
cycles Z80, while the Pentagon 320 * 224 = 71680 cycles (here's
the answer the question: "Why the Pentagon" on intermeddle
interruption of "more effects than the Spectrum). Knowing this
information can easily figure out how to make a multicolor: you
just set a desired color border'a ULA before displaying on the
screen the desired line screen display and a 224 (220) stroke
change it to another color, etc. A small example:
DI
LD HL, # FE00
LD A, H
LD I, A
DEC A
LD (HL), A; Organizazhiya second
INC L; interrupt mode
JR NZ, $ -2
INC H
LD (HL), A
LD A, # C9; in the handling of interrupt
LD (# FDFD), A; set of only
IM 2; command RET
LOOP EI
HALT
CALL PAUSE
; Red
LD A, 2, 7 clocks
CALL BORDER; +17 = 24 cycles
; Yellow
LD A, 6
CALL BORDER
; Blue
LD A, 1
CALL BORDER
, Etc.
XOR A
OUT (254), A
LD A, # 7F; Hit testing
IN A, (# FE); space
RRA
JP C, LOOP
DI; Return to assembler
LD A, # 3F; (or BASIC).
LD I, A
IM 1
EI
RET
BORDER OUT (254), A; 11 clock cycles
LD B, 13, 7 = 18
DJNZ $; +12 * 13 +8 = 164 = 182
NOP; +4 = 186
NOP; +4 = 190
RET; +10 = 200 cycles
, 200 + 24 = 224 cycles!
And now, little comments. The result of the program will be
3 (or more if you put in instead of "etc."
several teams change colors)
colored stripes on border'e. Subroutine
PAUSE is used to delay before displaying
bands on the border, so as usual on TVs and monitors, some not
visible upper and lower rows, so you
have to write it yourself under your car and
monitor. You can write several different
PAUSE routines for different types of machines
or make one, but with the possibility of
podstoyki user via the keypad (as is done in EXTASY).
Well it seems and all I wanted to write about the effects on
border'e. If anything is unclear, read ZF # 5 can 'll be there.
And now a little bit about multicolor'e on the screen. The
principle is the same: before drawing ULA line on the screen,
set the attributes of a color screen, and by 224 (220) clocks
change it to another. However, to change the attributes of the
screen is much more complicated border'a than as attributes in
one line 32. The only way to change them
through the stack, because otherwise you do not
fail to meet at 224 bar. Example:
DI
LD HL, # 4000
LD DE, # 4001
LD BC, 2047
LD (HL), # FF
LDIR
LD HL, # FE00
LD A, H
LD I, A
DEC A
LD (HL), A; Organizazhiya second
INC L; interrupt mode
JR NZ, $ -2
INC H
LD (HL), A
LD A, # C9; in the handling of interrupt
LD (# FDFD), A; set of only
IM 2; command RET
LD (OLD_SP +1), SP; Save stack
LOOP EI
HALT
CALL PAUSE
LD HL, # 4242, 10
LD SP, # 5820; +10 = 20
DS 9, # E5; +9 * 11 = 99 = 119
LD HL, # 4444, 10 = 129
IN A, (254), 11 = 140
LD A, (HL); +7 = 147
DS 7, # E5; +7 * 11 = 77 = 224
LD HL, # 4444
LD SP, # 5820
DS 9, # E5
LD HL, # 4141
IN A, (254)
LD A, (HL)
DS 7, # E5
LD HL, # 4141
LD SP, # 5820
DS 9, # E5
LD HL, # 4646
IN A, (254)
LD A, (HL)
DS 7, # E5
LD HL, # 4646
LD SP, # 5820
DS 9, # E5
LD HL, # 4242
IN A, (254)
LD A, (HL)
DS 7, # E5
LD HL, # 4242
LD SP, # 5820
DS 9, # E5
LD HL, # 4444
IN A, (254)
LD A, (HL)
DS 7, # E5
LD HL, # 4444
LD SP, # 5820
DS 9, # E5
LD HL, # 4141
IN A, (254)
LD A, (HL)
DS 7, # E5
LD HL, # 4141
LD SP, # 5820
DS 9, # E5
LD HL, # 4646
IN A, (254)
LD A, (HL)
DS 7, # E5
LD HL, # 4646
LD SP, # 5820
DS 9, # E5
LD SP, # 580E
LD HL, # 4242
IN A, (254)
LD A, (HL)
DS 7, # E5
OLD_SP LD SP, 0
LD A, # 7F; Hit testing
IN A, (# FE); space
RRA
JP C, LOOP
DI; Return to assembler
LD A, # 3F; (or BASIC).
LD I, A
IM 1
EI
RET
The result of this program will
eight colors in the same familiarity. But for
this you will need to pick a pause
in sub PAUSE, so that-be program
COLOR started just in time for drawing the first line of
Spectrum ULA screen. Since ULA draws the image on the
screen from left to right, and atrubuty change
through the stack from right to left in the middle
program output attributes are two teams delay IN A, (254) and
LD A, (HL). They Need to ensure that-be attributes are not
vydavavalis on the screen at a familiarity which currently
draws a ULA. If this is not do something on the screen will
appear all "leftists" effects. Maybe on some machines, these
teams need to insert slightly earlier or later. If someone does
not know that for such a team DS 9, # E5, then explain: it is
nine (first digit) teams PUSH HL code kotoy # E5 (second
figure). This format is supported by MASM and TASM v.4 .*.
All programs are listed here
I have written for advertising demos of my server (which I had
still not finished :-(), and therefore guarantee their
one hundred percent efficiency.
Well, that's all I wanted to write. I hope that you still
understand something of what I here write out of one's own
head.
P.S. I read all this nonsense again and
realized that probably vain hope.
P.P.S. But hope springs eternal ...