RETRO
Music by MITCHELL
Dzh.Hardman, E. Hyuzon
40 best procedures
End. Beginning in the ZX REVIEW
1997 NN 1-2, 3-4.
6.10. Screen magnification
and copying
Length: 335
Number of variables: 8
Checksum: 33663
Purpose: This program copies a part of the display to another
area of the screen, increasing up to X or Y.
Variables:
Name Address Length Commentary
upper_Y_co-ord 1 23296 Y-coordinate of the top row
lower_Y_co-ord 1 23297 Y-coordinate of the bottom row
right_X_co-ord 1 23298 X-coordinate of the rightmost
column
left_X_co-ord 1 23299 X-coordinate of the leftmost
column
horizontal_scale a 23,300 increase in X
vertical_scale a 23,301 increase in Y
new_left_co-ord 1 23302 X-coordinate of the leftmost
column field in which
made up
new_lower_co-ord 1 23303 Y-coordinate of the bottom row
region, which is
copy
Calling the program:
RANDOMIZE USR address
Error checking: a program
back to BASIC, if one
of the following conditions is true:
(I) horizontal_scale = 0,
(II) vertical_scale = 0,
(III) upper_Y_co-ord more
than 175,
(IV) new_lower_co-ord more
than 175,
(V) lower_Y_co-ord more than
upper_Y_co-ord,
(VI) left_X_co-ord more than
right_X_co-ord.
However, for brevity, there is no control program, which
would have tested the possibility of placing new picture on the
screen. If this does not work, may fail. The program also
requires a large amount of free of RAM and, if available, may
fail.
Comment: this program because of conflicts between procedures
PLOT. It is located at
65033.
If you copy a screen area has the same size,
the original, the scale should
be set to 1 to double the size of the scale is loaded
2:1, to triple the size of load scale 3:1, etc.
LISTING machine code
Assembly label number to VVODA147.
LD IX, 23296 221 33 0 91
LD A, 175 62 175
CP (IX +0) 221 190 0
RET C 216
CP (IX +7) 221 190 7
RET C 216
SUB A 151
CP (IX +4) 221 190 4
RET Z 200
CP (IX +5) 221 190 5
RET Z 200
LD HL, (23296) 42 0 91
LD B, L 69
LD A, L 125
SUB H 148
RET C 216
LD (23298), A 50 0 91
LD E, A 95
LD HL, (23298) 42 February 1991
LD C, L 77
LD A, L 125
SUB H 148
RET C 216
LD (23298), A 50 February 1991
PUSH BC 197
LD L, A 111
LD H, 0 38 0
INC HL 35
PUSH HL 229
POP BC 193
INC E 28
ADD DEC E 29
JR Z, REMAIN 40 3
ADD HL, BC 9
JR ADD 24250
REMAIN LD A, L 125
AND 15 230 15
LD B, A 71
POP HL 225
LD C, L 77
JR NZ, SAVE 32 2
FULL LD B, 16 June 1916
SAVE PUSH HL 229
CALL SUBR 205 13 255
AND (HL) 166
JR Z, OFF 40 2
LD A, 1 January 1962
OFF POP HL 225
RRA 203 1931
RL E 203 19
RL D 203 18
LD A, L 125
CP (IX +3) 221 190 3
JR Z, NEXT_R 40 6
DEC L 45
N_BIT DJNZ SAVE 16,231
PUSH DE 213
JR FULL 24226
NEXT_R LD L, C 105
LD A, H 124
CP (IX +1) 221 190 1
JR Z, COPY 40 3
DEC H 37
JR N_BIT 24241
COPY PUSH DE 213
LD B, 0 6 0
LD H, B 96
LD L, B 104
RESET LD (23306), HL 34 October 1991
LD A, B 120
OR A 183
JR NZ, RETR 32 3
POP DE 209
LD B, 16 June 1916
RETR SUB A 151
DEC B 5
RR D 203 26
RR E 203 27
RL A 203 23
PUSH DE 213
PUSH BC 197
PUSH AF 245
LD H, 1 January 1938
LOOP LD L, 1 January 1946
PRESER LD (23304), HL 34 August 1991
LD A, (23307) 58 November 1991
LD HL, 0 33 0 0
LD DE, (23301) 237 91 May 1991
LD D, L 85
MULTIP OR A 183
JR Z, CALC 40 6
ADD HL, DE 25
DEC A 61
JR MULTIP 24249
L_JUMP JR RESET 24 208
CALC LD A, (23303) 58 July 1991
ADD A, L 133
LD HL, (23304) 42 August 1991
ADD A, L 133
DEC A 61
PUSH AF 245
LD A, (23306) 58 October 1991
LD HL, 0 33 0 0
LD DE, (23300) 237 91 April 1991
LD D, L 85
REPEAT OR A 183
JR Z, CONTIN 40 4
ADD HL, DE 25
DEC A 61
JR REPEAT 24249
CONTIN LD A, (23 302) 58 June 1991
ADD A, L 133
LD HL, (23305) 42 September 1991
ADD H, L 133
DEC A 61
LD L, A 111
POP AF 241
LD H, A 103
POP AF 241
PUSH AF 245
OR A 183
JR NZ, PLOT 32 7
CALL SUBR 205 13 255
CPL 1947
AND (HL) 166
JR POKE April 24
PLOT CALL SUBR 205 13 255
OR (HL) 182
POKE LD (HL), A 119
LD HL, (23304) 42 August 1991
INC L 44
LD A, (23301) 58 May 1991
INC A 60
CP L 189
JR NZ, PRESER 32165
36 INC H
LD A, (23 300) 58 April 1991
INC A 60
CP H 188
JR NZ, LOOP 32155
POP AF 241
POP BC 193
POP DE 209
LD HL, (23306) 42 October 1991
INC L 44
LD A, (23 298) 58 February 1991
INC A 60
CP L 189
JR NZ, L_JUMP 32164
LD L, 0 46 0
36 INC H
LD A, (23296) 58 0 91
INC A 60
CP H 188
JR NZ, L_JUMP 32154
RET 201
SUBR PUSH BC 197
PUSH DE 213
LD A, 175 62 175
SUB H 148
LD H, A 103
PUSH HL 229
AND 7230 7
ADD A, 64 198 1964
LD C, A 79
LD A, H 124
RRA 203 1931
RRA 203 1931
RRA 203 1931
AND 31 230 31
LD B, A 71
AND 24 230 24
LD D, A 87
LD A, H 124
AND 192230192
LD E, A 95
LD H, C 97
LD A, L 125
RRA 203 1931
RRA 203 1931
RRA 203 1931
AND 31 230 31
LD L, A 111
LD A, E 123
ADD A, B 128
SUB D 146
LD E, A 95
LD D, 0 22 0
PUSH HL 229
PUSH DE 213
POP HL 225
ADD HL, HL 41
ADD HL, HL 41
ADD HL, HL 41
ADD HL, HL 41
ADD HL, HL 41
POP DE 209
ADD HL, DE 25
POP DE 209
LD A, E 123
AND 7230 7
LD B, A 71
LD A, 8 August 1962
SUB B 144
LD B, A 71
LD A, 1 January 1962
ROTARE ADD A, A 135
DJNZ ROTARE 16253
RRA 203 1931
POP DE 209
POP BC 193
RET 201
2
How it works:
In IX load address buffer
printer for use in
as a pointer variable.
If the upper Y-coordinate or
new lower coordinate more than 175, the program returns to
BASIC. If the value increases
horizontally or vertically
is 0, there is a return to
BASIC.
In the H-register is loaded lower Y-coordinate, and L-register
Upper Y-coordinate. L-register
copied into the B-register and accumulator. H-register is
subtracted from the batteries and routine returns to BASIC, if
the result is negative.
The value of the battery and then
placed in a cell for 23298
use as a counter. BC register pair is then stored on the stack.
HL register value is loaded accumulator increases and copied
to the register BC. BC added to the HL E times, the resulting
value of HL is the number of pixels to be copied.
In the battery load value L-sensitive and 4, the leftmost bit
set to 0. The result is copied into the B-register to use it
as a counter.
HL register pair is recovered from the stack and the register
L is copied to the C-register. If the B-register contains 0, is
loaded into the register number 16 - the number of bits in the
register pair. It then calls the procedure SUBR
and a battery load values POINT (L, H). DE register pair is
shifted to the left and bit value of the battery is loaded into
the rightmost bit E-sensitive.
If the L-register is left
X-coordinate, the routine goes to NEXT_R (next row).
Otherwise, reduced L-register,
then - B-register. If the B-register does not contain 0, the
routine returns to the SAVE to feed the next bit in a couple of
registers, DE. If the B-register contains a 0, a pair of
registers DE pushed onto the stack and the transition to FULL.
Procedure NEXT_R in L-register
loaded right X-coordinate
and loaded into the accumulator value of H-sensitive. If the
value battery is equal to the lower Y-coordinate, transition to
COPY, because Last pixel for
Copy filed in DE. Otherwise Nregistr decreases, indicating
next row, and the subroutine
returns to N_BIT.
The procedure COPY contents
DE pair is placed in a stack, and B-,
H-and L-registers are set
to 0 to use them as counters. The contents of register pair HL
is placed in cell with address 23306 / 7. HL
can now be used as
counter for subsequent cycles
without using the stack. If
B-register contains 0, DE is restored from the stack and
register B re-established on
value 16, identifying the number of pixels stored in the DE.
B-register is reduced, indicating that bit of information
deleted of DE. Rightmost bit of E-register is loaded into the
battery, and a pair of registers DE shifted to the right. DE,
BC and AF on the stack as long as not performing certain
calculations.
In registers H and L 1 is loaded
for use as
counter, and placed in the HL
cell with address 23304 / 5. As the battery is loaded value
byte at 23,307 - is one
of the counters stored previously.
In a couple of registers loaded DE
vertical scale. This value is then multiplied by the battery,
and the result served in the HL. This value is added to the
bottom of the new Y-coordinate in the battery. Byte at 23,304
and then added to the battery, and the result is reduced.
Battery stores now
Y-coordinate for the construction of the next pixel. This value
stored on the stack as long as the calculated X-coordinate
the same way. After calculating
X-coordinate is loaded into the L-register. Y-coordinate is
recovered from the stack and loaded into H-sensitive. In the
battery installed last value stored in the stack. If it
is 1, should be constructed point (X, Y), otherwise, should
be performed procedure UNPLOTTED. Called SUBR and the
appropriate action.
HL register pair is loaded
loop counter that is stored on
addresses 23304 / 5. Register L is increased, and if it does
not contain a value (1 + vertical_scale), routine returns to
PRESER. Register of H increases, if it contains no value
(1 + horizontal_scale), is
go to LOOP.
A pair of registers AF, BC and DE
recovered from the stack, and
HL register pair is loaded
second value sets the loop counter, which is stored on
addresses 23306 / 7. Register L is increased and the transition
to RESET, if the result is not equal
(Right_X_co - ord - left_X_co -
ord + 1).
Register L is set to
0 - this is the initial value
loop counter. H-register and then
increases and the routine goes to RESET, if the result is
not equal (uppen_Y_co-ord-lower_Y
_co-ord +1). The program returns to BASIC.
SUBR procedure is identical to
that used in the program
"Painting the path."