(C) Ivan Roshchin, Moscow, 1997
A few graphical effects
1. "Flame"
There are many variations of this effect (see, for example,
music demo FSRD, INSANE, S4B, NOUMENON, EYE ACHE
2, RAGE, etc.). I realized until now never meet: the screen is
Some pictures (say, a screen saver program), and in the back
background (and this sites pictures
painted black) as
times and is seen "flame". How does it
looks like, you can see by running "ZX FORUM 4 (effect used in
the main menu of the the electronic edition).
Thus, the text of the program (if it is
development, I used fragments of procedure, "Flame", taken
from an article in the St. Telitsin ZX REVIEW
05/06 1997):
140.
BUF1 EQU # 8000; Here are memorized
; Attributes of the image.
BUF2 EQU # 8300; array, resp.
; One printed image
; Proposition (L # 340).
BUF3 EQU # 8700; Picker (Associate
; Address byte = 0!)
LD HL, BUF3
EXX
XOR A
LD (23560), A
LD HL, BUF3; form a
LD DE, BUF3 +1; palette
LD (HL), 0
LD BC, 8
LDIR
LD A,% 1000
LD (BUF3 +4), A
LD (HL), A
LD BC, 8
LDIR
LD (HL),% 10000
LD BC, 8
LDIR
LD (HL),% 11000
LD BC, # E7
LDIR
LD HL, # 9000; transferred
LD DE, # 4000 picture
LD BC, # 1B00; screen
LDIR
LD HL, # 5800, saved
LD DE, BUF1; its attributes
LD BC, # 300
LDIR
LD HL, BUF2; resets
LD (HL), 0; working
LD DE, BUF2 +1; buffer
LD BC, # 2FF
LDIR
SSAVER LD HL, BUF2 + # 320; fill
LD (HL), -60; part
LD DE, BUF2 + # 321; buffer
LD BC, # 1F; number -60
, (From its value
LDIR; depends on type of effect)
LD HL, 0; original position
; In ROM
; Update cycle in the buffer BUF2:
LOOP_1 LD DE, BUF2 + # 300
LD B, # 20
LOOP_2 INC HL
LD A, H
AND # 1F
LD H, A
LD A, (HL); sl.bayt from ROM
AND% 00111111
ADD A,% 11000
JR NC, LL
LD A,% 11000
LL LD (DE), A
INC DE
DJNZ LOOP_2
PUSH HL
LD IX, BUF2
LD DE, # 5800
LD HL, BUF1
LD BC, # 2FF
LOOP_4 LD A, (IX +32)
ADD A, (IX +33)
ADD A, (IX +34)
ADD A, (IX +65)
SRL A
SRL A
JR Z, LOOP_5
DEC A
LOOP_5 INC IX
INC HL
INC DE
LD (IX), A
; Changed byte value in the buffer
And now are changing acc. attribute on the screen:
PUSH BC
EXX
LD L, A; address in the palette
LD A, (HL); A = desired color
EXX
LD B, A
; For the current attribute set
And instead of black or INK PAPER
, The color that was taken from the palette;
, Thus black is like
, "Transparent":
LD A, (HL); APR. Pictures
AND% 00111000; PAPER
JP NZ, TST_2; JP-for speed
LD A, B; now, instead of
OR (HL); black -
LD (DE), A; another color
TST_2 LD A, (HL)
AND% 00000111; INK
JR NZ, TST_Q
LD A, B
AND% 00111000
RRCA
RRCA
RRCA
OR (HL)
LD (DE), A
TST_Q POP BC
DEC BC
LD A, B
OR C
JP NZ, LOOP_4
POP HL
; Check the keyboard:
LD A, (23560)
AND A
JP Z, LOOP_1
RET
2
I should note that: firstly, it is easy, changing the
program to declare a "transparent" is not black, and any other
color (or even multiple colors).
Secondly, we can very precisely adjust color "flame" with
palette (array BUF3). Each byte palette contains one of eight
values that determines the color:% 000000% 001000 ... %
111000. During the program the value of the buffer BUF2
(Numbers from 0 to 255), which You can say, determine the
"brightness" of the flame, encoded in corresponding attribute
values in accordance with this palette.
Although this effect (as well as all
discussed in the article) is not synchronized by interrupts,
they should be allowed - this is
need to poll the keyboard.