(C) Ivan Roshchin, Moscow, 1996.
Bring to your attention
two procedures, native,
realizing the beautiful and unusual
effects (at least to me
these do not have to see).
Before the first procedure on the screen should be any
picture. You will see how this picture changes gradually. To
leave enough press any key.
This effect, you can use in your program, for example: if a
user does not press for a long time on the keys, store the
contents of display area and start the procedure. As soon as
any key is pressed, restore the image on the screen (by the
way, this can help the second procedure).
This procedure is easy to change. Try these
places to put the CALL
SET_0 or CALL SET_1 and see what happens.
Here is the text of the procedure for
Assembler:
148.
EFFECT LD HL, 0; ADDRESS ROM
LD (ADR_ROM), HL
, GET IN DE random coordinates
; The next point and retained in memory:
NEXT_X LD HL, (ADR_ROM)
LD B, (HL); X coordinate
INC HL
LD A, R
XOR B
LD R, A
LD D, A
NEXT_Y LD B, (HL); Y coordinate
INC HL
LD A, R
XOR B
CP 191
JR NC, NEXT_Y
LD E, A
LD (KRDS), DE
LD (ADR_ROM), HL
LD A, (HL)
PUSH AF
CALL GET_P; find the color of this point (0 .. 1)
LD (COL), A
; CHOOSE direction in which
, Is the second point, and knew her
; CONTACT:
POP AF
AND 3 NUMBER OF 0 .. 3 ROOM AREAS
LD HL, TABLE
LD B, 0
LD C, A
ADD HL, BC
LD A, (HL); ON HOW TO CHANGE Y
PUSH AF
LD BC, 4
ADD HL, BC
LD A, (HL); ON HOW MUCH X
ADD A, D
LD D, A
POP AF; ON HOW Y
ADD A, E
LD E, A
CP 192
JR NZ, NE_192
LD E, 190
NE_192 CP # FF
JR NZ, X_OK
LD E, 1
X_OK CALL GET_P; find the color of second point
LD IX, COL; compares it with the color of the first
POINT
CP (IX); if they are identical,
JR Z, H_OK; CHANGE THE POINT OF SITES ARE NOT NECESSARY.
PUSH DE; SAVE. Coord. The second point
LD DE, (KRDS); DRAW this color first point
CP 0; THESE 5 teams can be replaced by
PUSH AF; TEAM OR CALL SET_0
CALL Z, SET_0; CALL SET_1, The observed
POP AF; EFFECT CHANGE.
CALL NZ, SET_1
POP DE; RESET. COORDINATES OF THE SECOND POINT
LD A, (COL); THESE 6 commands can be replaced by
CP 0; TEAM OR CALL SET_0
PUSH AF; CALL SET_1, The observed
CALL Z, SET_0; EFFECT CHANGE.
POP AF
CALL NZ, SET_1
LD A, (ADR_ROM +1); CHECK not been reached
AND # 1F; LIMITING ADDRESS
LD (ADR_ROM +1), A; in the Spectrum ROM.
H_OK LD A, 0; Checks you have pressed
IN A, (# FE); ANYTHING on the keyboard.
AND% 00011111
CP% 00011111
JP Z, NEXT_X
RET; IF YES, output.
SET_1 CALL BYTE
LD B, (HL)
OR B
LD (HL), A
RET
SET_0 CALL BYTE
LD B, # FF
XOR B
LD B, (HL)
AND B
LD (HL), A
RET
GET_P CALL BYTE
LD B, (HL)
AND B
CP 0
RET Z
LD A, 1
RET
BYTE PUSH DE
LD A, E
AND A
RRA
SCF
RRA
AND A
RRA
XOR E
AND # F8
XOR E
LD H, A
LD A, D
RLCA
RLCA
RLCA
XOR E
AND # C7
XOR E
RLCA
RLCA
LD L, A
LD A, D
AND 7
LD B, A
INC B
LD A, 1
LOOP RRCA
DJNZ LOOP
POP DE
RET
KRDS DW 0; CONTACT POINT
COL DB 0; COLOR POINT
TABLE DB 0, # FF, 0,1
DB 1,0, # FF, 0
ADR_ROM DW 0
2
The second procedure is designed to display images on the
screen. Before its launch in the register
HL pair to specify the address of the picture.
Here is the text of the procedure for
Assembler:
148.
DEMO LD HL, # C000; ADDRESS The output PICTURES
CALL EFFECT
RET
; TREATMENT EFFECT implement the findings
; PICTURES ON SCREEN.
; ENTRY: HL-ADDRESS The output PICTURES.
; When you call the interrupt is to be
; Allowed!
Q EQU 7; Q can be changed
Q_2 EQU Q * Q; range [1 .. 8], from its
; Value depends EFFECT.
EFFECT LD DE, # C000; SET ADDRESSES
ADD HL, DE; IN PROCEDURE
LD (ADR1 +1), HL
LD D, # 58; File Transfer
ADD HL, DE; Attributes.
LD BC, # 300
LDIR; THEN E = 0.
LD D,-Q_2; D-current line number.
, The Register E-How many rows processed (YET 0).
LOOP1 HALT; DELAY
LD BC, Q +1 * 256 + Q_2; B-COUNTER, C-SHIFT
LOOP2 LD A, D; current line number
ADD A, C; add an offset
CP 192; If the number is more rows 192,
JR NC, NEXT; miss it.
EXX
CALL ADR_STR; otherwise you'll ADDRESS LINES
ADR1 LD BC, 0
ADD HL, BC; in HL-ADDRESS BUFFER
LD BC, # 20, THE LENGTH OF A LINE
LDIR; brought to SCREEN.
EXX; Increases the number of
INC E; rows processed
NEXT LD A, C; REDUCE THE OFFSET
SUB Q
LD C, A
DJNZ LOOP2; repeat the cycle.
INC D; INCREASED NUMBER TEK.STROKI
And if it is divisible by (Q +1), increment it by Q
LD B, 0; COUNTER (256 Reprise)
LD A, D; checking of
LOOP3 SUB Q +1; Subtracts DIVIDED
JR Z, DEL; If you receive a 0, ie Divisible
DJNZ LOOP3; continue ...
JR M12; If number is not divisible
DEL LD A, D; increment
ADD A, Q; Current Line
LD D, A; on Q.
M12 LD A, E; how many lines deduced?
CP 192; 192 LINES ALREADY?
JR NZ, LOOP1; If Not, Conclusion.
RET
;
; PROCEDURE ADR_STR
; LOG: A-line number (0 .. 191)
; EXIT: HL, DE-ADDRESS DISPLAY FILE.
ADR_STR LD E, A
AND A
RRA
SCF
RRA
AND A
RRA
XOR E
AND # F8
XOR E
LD H, A
XOR A
XOR E
AND # C7
XOR E
RLCA
RLCA
LD L, A
LD E, A
LD D, H
RET
2
********************************