RETRO
Dzh.Hardman, E. Hyuzon
40 best procedures
Continued. Beginning in the ZX REVIEW
1997 NN 1-2, 3-4.
6. DISPLAY PROGRAMS
6.1. Merging Images
Length: 21
Number of variables: 1
Checksum: 1709
Purpose: This program
combines the image stored
in RAM, the current screen display.
Attributes are not changed.
Variables:
Name: screen_store
Length: 2
Cell: 23296
Comment: contains the address
images in RAM.
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: To join
Images must be used on the reduced program listing. However,
interesting results can also be obtained by replacing OR (HL)
at XOR (HL) or AND (HL).
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, 16 384 33 0 64
LD DE, (23296) 237 91 0 91
LD BC, 6144 1 0 24
NEXT_B LD A, (DE) 26
OR (HL) 182
LD (HL), A 119
INC HL 35
INC DE 1919
DEC BC 11
LD A, B 120
OR C 177
JR NZ, NEXT_B 32246
RET 201
2
How it works:
In a couple of registers HL loaded starting address display
file, and a pair of registers, DE -
its length. Register pair BC
used as a counter.
As the battery is loaded bytes
with an address in DE and holds the logical OR (OR) of this
value with byte display file. The result is then placed in the
display area.
HL and DE are moved to the next position, the counter
decreases. If the counter is not 0, then subroutine returns
to repeat the process with the next byte.
The program returns to BASIC.
6.2. Invert screen
Length: 18
Number of variables: 0
Checksum: 1613
Purpose: invert all
system on display file: If the pixel
included, it is reset (OFF),
If the pixel is off, it is installed.
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: This program can be used to obtain the effect of the
outbreak. This effect is enhanced if done call several times
and added sound.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, 16 384 33 0 64
LD BC, 6144 1 0 24
LD D, 255 22 255
NEXT_B LD A, D 122
SUB (HL) 150
LD (HL), A 119
INC HL 35
DEC BC 11
LD A, B 120
OR C 177
JR NZ, NEXT_B 32247
RET 201
2
How it works:
In a couple of registers loaded HL address display file, and
BC is loaded its length. In
D-register value is placed
255. Whenever the routine returns to NEXT_B, in
battery load value
of the D-register. This method is preferred over instruction LD
A, 255, as LD A, D holds
approximately 2 times faster
than the instruction LD A, 255. Byte value stored in cell
the address listed in the HL, is subtracted from the
accumulator and the result is loaded into the same byte. Thus,
is inverted.
HL increased, indicating
next byte, and the counter BC
decreases. If the counter is not 0, the program returns to
NEXT_B. If the counter is 0
the program returns to BASIC.
6.3. Inverting character
vertically
Length: 20
Number of variables: 1
Checksum: 1757
Purpose: This program inverts the symbol vertically.
For example, the arrow pointing
up should be an arrow
downward, and vice versa.
Variables:
Name: chr_start
Length: 2
Cell: 23296
Comment: The address of the symbol in
Memory (ROM).
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: This program is useful in games, because You can
change individual characters without affecting the adjacent
areas of the image.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, (23296) 42 0 91
LD D, H 84
LD E, L 93
LD B, 8 6 8
NEXT_B LD A, (HL) 126
INC HL 35
PUSH AF 245
DJNZ NEXT_B 16251
LD B, 8 6 8
REPL POP AF 241
LD (DE), A 18
INC DE 1919
DJNZ REPL 16251
RET 201
2
How it works:
In a couple of registers HL loaded address of the data
symbol. The same address is then copied to the DE. In
Register B is loaded to 8
to use the register as a counter.
For each byte in the accumulator is loaded currently
available value. HL increased, pointing to next byte and the
contents of the battery is placed on the stack. Counter is
decremented and if it does not is equal to 0, the routine
returns to repeat the process for the next byte. In the case
B re-load value
8, to re-use it
as a counter. Symbol image stored on the stack.
REPL procedure returns data from the stack on the same
familiarity, but in reverse order.
Byte by byte is taken from the stack and through the battery
placed on the address contained in DE. DE increases, to
indicate the next byte, and the counter decreases. If it is not
0, the program returns to REPL. Otherwise, it
returns to BASIC.
6.4.
Length: 19
Number of variables: 1
Checksum: 1621
Purpose: This program inverts the symbol horizontally.
For example, the arrow pointing
the left becomes the right arrow.
Variables:
Name: chr_start
Length: 2
Cell: 23296
Comment: The address of the data
symbol.
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: None.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, (23296) 42 0 91
LD A, 8 August 1962
NEXT_B LD B, 8 6 8
NEXT_P RR (HL) 203 30
RL C 203 17
DJNZ NEXT_P 16250
LD (HL), C 113
INC HL 35
DEC A 61
JR NZ, NEXT_B 32243
RET 201
2
How it works:
In a couple of registers HL loaded address of the data
symbol, and a battery load number of bytes that need to be
inverted. The register B is loaded the number of bits in each
byte - it is used as counter.
Bytes with an address in HL shifted to the right so that
rightmost bit is copied into
carry flag. C-register is shifted to the left so that the carry
flag is copied into the rightmost bit. Meter (B-sensitive)
decreases.
If the counter is not 0,
transition to NEXT_P for
work with the next pixel.
Inverted byte, which
in register C, is placed in a cell, from which he
was taken.
HL increased, indicating
next byte, and the battery
decreases. If the battery is not
is 0, the transition to
NEXT_BYTE, otherwise -
return to BASIC.
6.5. The rotation of the symbol
clockwise
Length: 42
Number of variables: 1
Checksum: 3876
Purpose: This program rotates the symbol by 90 degrees
clockwise. For example, the arrow pointing up, becomes directed
right.
Variables:
Name: chr_start
Length: 2
Cell: 23296
Comment: The address of the data
symbol.
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: This program is useful in games and for serious
purposes, such as in the schedule.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, (23296) 42 0 91
LD E, 128 30 128
N_BIT PUSH HL 229
LD C, 0 14 0
LD B, 1 6 1
NEXT_B LD A, E 123
AND (HL) 166
CP 0254 0
JR Z, NOT_S 40 3
LD A, C 121
ADD A, B 128
LD C, A 79
NOT_S SLA B 203 32
INC HL 35
JR NZ, NEXT_B 48242
POP HL 225
PUSH BC 197
SRL E 203 59
JR NC, N_BIT 48231
LD DE, 17 July 7 0
ADD HL, DE 25
LD B, 8 6 8
REPL POP DE 209
LD (HL), E 115
DEC HL 1943
DJNZ REPL 16251
RET 201
2
How it works:
Symbol consists of a group of 8x8 pixels, each of
which may be able to
ON (1) or OFF (0). Consider
any bit byte B1 B2 in Figure 1.
Data is stored in the cell (B2, B1)
in the form:
N1 N3
N2 N4
where:
N1 = B, in which pixel
(B2, B1) will be inserted after
rotation.
N2 = bit in N1, in which he
will be inserted.
N3 = value that represents the current value of the bit.
N4 = bit value of N2. Each
byte characters will be rotated
formed by adding the values of all bits of N2, which will be
a new byte.
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 2
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 3
2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 4
3 8 3 8 3 8 3 8 3 8 3 8 3 8 3 8
Byte (B1)
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 5
4 16 4 16 4 16 4 16 4 16 4 16 4 16 4 16
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 6
5 32 5 32 5 32 5 32 5 32 5 32 5 32 5 32
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 7
6 64 6 64 6 64 6 64 6 64 6 64 6 64 6 64
1 128 2 64 3 32 4 16 5 8 6 4 7 2 8 1 8
7 128 7 128 7 128 7 128 7 128 7 128 7 128 7 128
7 6 5 4 3 2 1 0 Bit (B2)
Figure 1. The key to the routine rotation of the symbol
In HL load address of the first byte of the character. In the
case E load byte value, which has a 7-bits in the state
ON and 0 to 6-th bits - in the OFF,
ie 128. HL is stored in the stack. The register C are sending 0.
Further, it will be added
data, giving new meaning to
formed by byte. In case B
load byte value, zero bit is turned on and
Bits 1-7 - off, ie, it
unit.
As the battery is loaded content, E-register (N3). This
value multiplied logically (AND) with a byte whose address is
stored in the HL. If the result is 0, the transition to NOT_S,
because pixel addressed register E and HL register pair is
cleared (OFF). If it is set (ON), in
battery is loaded with the value byte (N1). Register
B (N4) is added to the battery and this value is loaded into
register C. Register is then set to indicate
the next bit of N1. HL increased, pointing to the next
B (B1). If the N1 byte is not completed, the routine returns to
NEXT_B.
HL recovered from the stack,
again to indicate for the first
byte characters. BC is preserved in
stack to remember the importance of
last byte to complete the
in the C-register. E-register is set to address the next bit
each byte. If the rotation is not
completed the transition to
N_BIT.
In DE loads the value 7, and
This value is added to the HL.
HL now points to the last byte of data. In case B
load number of bytes that must be taken from the stack.
For each byte of the new value
copied to the E, and this value
placed in a cell with an address in
HL. HL decreases to point to the next byte, and counter
(B-register) is reduced.
If the counter is not 0, the transition to the REPL.
The program returns to BASIC.
6.6. Change Attribute
Length: 21
Number of variables: 2
Checksum: 1952
Purpose: This program changes the value of the attribute of
all characters on the screen given by,
for example, can be changed
colors of all the characters or the whole screen may blink, etc.
Variables:
Name: data_saved
Length: 1
Cell: 23296
Comment: immutable bit
attribute.
Name: new_data
Length: 1
Cell: 23297
Comment: The new bits input to the attribute byte.
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: The individual bits
attribute of each character can
be changed by using the AND and OR.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, 22 528 33 0 88
LD BC, 768 1 0 3
LD DE, (23296) 237 91 0 91
NEXT_B LD A, (HL) 126
AND E 163
OR D 178
LD (HL), A 119
35 INC H
DEC BC 11
LD A, B 120
OR C 177
JR NZ, NEXT_B 32246
RET 201
2
How it works:
In a couple of registers loaded HL address field attributes,
and pair of registers BC - the number of
characters on the screen. In case D
loaded value new_data, and
E is loaded into the register value data_saved.
As the battery is loaded bytes
to address in HL, and
bits are set, respectively, the values of registers D and
E. The result is placed back
in a cell in the address stored in
HL. HL increased, indicating
the next byte, and the counter BC
decreases. If the contents of BC
to equal 0, the program returns to NEXT_B.
The program returns to BASIC.
6.7. Change Attribute
Length: 22
Number of variables: 2
Checksum: 1825
Purpose: This program seeks
attributes with a particular value, and replaces every
occurrence found another value.
Variables:
Name: old_value
Length: 1
Cell: 23296
Comment: The value of the byte
to be replaced.
Name: new_value
Length: 1
Cell: 23297
Comment: The value of the replacement byte.
Calling the program:
RANDOMIZE USR address
Error Checking: None.
Comment: This program is useful for highlighting areas
text and graphics.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, 22 528 33 0 88
LD BC, 768 1 0 3
LD DE, (23296) 237 91 0 91
NEXT_B LD A, (HL) 126
CP E 187
JR NZ, NO_CH 32 1
LD (HL), D 114
N) _CH INC HL 35
DEC BC 11
LD A, B 120
OR C 177
JR NZ, NEXT_B 32245
RET 201
2
How it works:
In a couple of registers loaded HL address field attributes,
and BC boot on the number of characters
screen. In the E-register is loaded
old_value, but in the D-register nev_value. As the battery is
loaded bytes whose address is stored in
pair HL. If the battery keeps
value, which is equivalent to
Content E-Register, in
byte of the address available in the HL,
put the contents of D-register. In this case HL increases
pointing to the next byte, and
BC count decreases. If BC
is not equal to 0, the transition to
NEXT_B, otherwise the program returns to BASIC.
6.8. Fill path
Length: 263
Number of variables: 2
Checksum: 26647
Purpose: This program fills the screen area bounded by a line
of pixels.
Variables:
Name: X_coord
Length: 1
Cell: 23296
Comment: The X coordinate
starting position.
Name: Y_coord
Length: 1
Cell: 23297
Comment: Y coordinate
starting position.
Calling the program:
RANDOMIZE USR address
Error control: if the coordinate Y> 175 or POINT (X, Y) = 1,
then the program immediately returns
in BASIC.
Comment: This program is not
Flexible, its start address - 31955. When painted over a large
area of complex shapes, you need a large number of free
space. If this is impossible can happen
failure.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, (23296) 42 0 91
LD A, H 124
CP 176 254 176
RET NC 208
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
RET NZ 192
LD BC, 65535 1 255 255
PUSH BC 197
RIGHT LD HL, (23296) 42 0 91
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
JR NZ, LEFT 32 9
LD HL, (23296) 42 0 91
INC L 44
LD (23296), HL 34 0 91
JR NZ, RIGHT 32236
LEFT LD DE, 0 17 0 0
LD HL, (23296) 42 0 91
DEC L 45
LD (23296), HL 34 0 91
PLOT LD HL, (23296) 42 0 91
PUSH HL 229
CALL SUBR 205 143 * 125
OR (HL) 182
LD (HL), A 119
POP HL 225
LD A, H 124
CP 175 254 175
JR Z, DOWN 40 44
LD A, E 123
CP 0254 0
JR NZ, RESET 32 16
36 INC H
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
JR NZ, RESET 32 7
LD HL, (23296) 42 0 91
36 INC H
PUSH HL 229
LD E, 1 Jan. 30
RESET LD HL, (23296) 42 0 91
LD A, E 123
CP 1 254 1
JR NX, DOWN 32 15
36 INC H
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
JR Z, DOWN 40 6
LD E, 0 30 0
JR DOWN February 24
L_JUMP JR RIGHT 24167
DOWN LD HL, (23296) 42 0 91
LD A, H 124
CP 0254 0
JR Z, NEXT_P 40 40
LD A, D 122
CP 0254 0
JR NZ, REST 32 16
DEC H 37
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
JR NZ, REST 32 7
LD HL, (23296) 42 0 91
DEC H 37
PUSH HL 229
LD D, 1 22 1
REST LD A, D 122 1
CP 1 254 1
JR NZ, NEXT_P 32 14
LD HL, (23296) 42 0 91
DEC H 37
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
JR Z, NEXT_P 40 2
LD D, 0 22 0
NEXT_P LD HL, (23296) 42 0 91
LD A, L 125
CP 0254 0
JR Z, RETR 40 12
DEC L 45
LD (23296), HL 34 0 91
CALL SUBR 205 143 * 125
AND (HL) 166
CP 0254 0
JR Z, PLOT 40129
RETR POP HL 225
LD (23296), HL 34 0 91
LD A, 255 62 255
CP H 188
JR NZ, L_JUMP 32177
CP 1189
JR NZ, L_JUMP 32174
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 203 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
147.
RRA 203 1931
AND 31 203 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:
This program draws the horizontal lines of the adjacent
pixels. We call them lines.
Limit the filling of the lines is limited to enable (ON)
pixels. Each line is stored by entry into
stack coordinates of the rightmost
pixel of this line.
Starting with a certain
coordinates, the program makes the filling in each line, noting
the position of each of the outstanding lines above or below.
By end of a line of recent value is restored and marked the
coordinates for respective lines are filled. This process
repeated until, until
remain unfilled lines.
Figure 2 illustrates the technique
process. Squares represent
pixels, X denotes the start
position within the field of the hatch, and * denotes extreme
right pixel lines.
/ / / / / / / / / / / / / / / / / / / / / / / / / /
/ / / / / /
/ / / / 0 / / / / * / / / / / / / / / / / /
/ / / / 0 / / / / X / / / /
/ / / / / / / / / / / / * / / / /
/ / / / * / / / / * / / / /
/ / / / * / / / / / / / / / / / / * / / / /
/ / / / * / / / / / / / / / / / / * / / / /
/ / / / / / / / / / / / / / / / / / / / / / / / / /
/ / / / / /
Figure 2. Illustration art fill the area
X - Starting position * - the beginning of lines,
0 - remaining unshaded area
Program-stroke horizontal line containing the start position,
and stores stack position at the start line
lines directly above and
below. She further stroke line
above, then below, noting in
the latter case that two
lines start at the next lower line, etc. Any
position within the region for
shading can be chosen as
starting position. But note
that two pixels, labeled with zeros, untouched, because they
separated from the shade area.
In case H is loaded Y-coordinate, and L-Register -
X-coordinate. If the value is greater than Y than 175, the
program returns in BASIC. SUBR procedure is called, returning
the address bits (X, Y) in memory. If this bit is in a position
to ON (enabled), program returns to BASIC.
The number 65535 is placed in a stack,
to mark the first stored value. Later, when
number recovered from the stack, it is interpreted as
pair of coordinates. However, if
number is 65535, is
return to BASIC, because program
completed.
In case H is loaded Y-coordinate, and in case L -
X-coordinate. SUBR procedure is called, returning to the HL-bit
address (X, Y). If this bit is set
(ON), the transition to the LEFT.
Otherwise the X-coordinate increases
and a transition is made to the RIGHT, if
X does not equal 256.
The procedure LEFT DE set to 0. Registers D and E are used as
flags: D - down (DOWN), E - up (UP). X-coordinate decreases.
SUBR is called and the plotted point (X, Y). If the
Y-coordinate is 175, subroutine goes to
DOWN. If this flag is set to UP, the transition to the RESET.
If the bit (X, Y +1) is reset, the value of X and Y +1 is
stored in the stack and flag up is included.
In the process of RESET, if the flag
UP is enabled, a transition to DOWN. If the bit (X, Y +1)
enabled (ON), flag up off. The procedure DOWN, if
Y-coordinate is 0, the transition to NEXT_PIXEL. If
flag down on, is
transition to REST. If the bit (X, Y-1)
reset (OFF), then the values of X and
Y-1 stored on the stack and flag
DOWN included.
The procedure for REST, if the flag
DOWN off, the transition to NEXT_P. If the bit (X, Y-1)
set (ON), then flag down
off. The procedure NEXT_P,
if the X-coordinate equal to 0, the routine goes to RETR.
X-coordinate decreases, and if
a new bit (X, Y) is reset (OFF),
transition to PLOT. In
procedure RETR X-and Y-coordinates are retrieved from the
stack. If X and Y equal to 255, - return
BASIC, because filling area
completed. Otherwise routine
returns to the RIGHT.
Procedure SUBR should calculate the address bits (X, Y) in
memory. In BASIC this address will be:
16,384 + INT (Z / 8) + 256 * (Z - 8
* INT (Z / 8)) + 32 * (64 * INT (Z /
64) + INT (Z / 8) - 8 * INT (Z/64))
where Z = 175-Y.
Pair of registers BC and DE are stored on the stack. In
battery send the number 175, and from this
subtracted Y-koodinata. The result is copied into H-register.
Then HL is stored on stack. Five left-wing bits accumulator set
to 0, and then it is added to the 64. The result is copied to
the C-register. When multiplying by 256 we get:
16384 +256 * (Z-8 * INT (Z / 8))
In the battery load Z,
This value is divided by 8, the result is copied into register
B. This result - INT (Z / 8). Installation of the three
rightmost bits to 0 when the rotation gives the value
8 * INT (Z/64), which is loaded in the D-register.
As the battery is loaded and Z
6 rightmost bits off, which gives 64 * INT (Z/64).
This value is loaded into the E-register. Value of C-register
copies of H. In battery
loaded X-coordinate is
value is divided by 8, and the result is copied to the L.
In the battery and then load the value of E-register and for
him added to the contents of B. The value of D-register is
subtracted and the result is loaded into the DE. This
value is multiplied by 32, DE
recovered from the stack and
added to HL. Thus HL now stores the address bits (X, Y).
In the battery load the initial value X. Installation of five
left-wing bits to zero yields value of X-8 * INT (X / 8). The
B-register and then loaded minus 8 value of the battery to use
it as a counter. The battery is set to 1 and is multiplied by 2
(B-1) times.
At this point in the accumulator
you must install the bits, which corresponds to a bit (X, Y)
with address in HL. DE and BC are then recovered from the
stack, and SUBR and return to the main
program.
6.9. Building Templates
Length: 196
Number of variables: 2
Checksum: 20278
Purpose: This program traces the pattern of any size on the
screen. The pattern is understood Any previously defined figure.
Variables:
Name: X_start
Length: 1
Cell: 23296
Comment: X-coordinate of the first pixel.
Name: Y_start
Length: 1
Cell: 23297
Comment: Y-coordinate of the first pixel.
Calling the program:
RANDOMIZE USR address
Error checking: If the string variable that stores
information on the pattern A $, there is a zero-length or does
not contain any information the program returns directly to the
BASIC. This occurs as if the Y-start
more than 175.
Comment: this is a useful
program for keeping figures in
memory and quick tracing
them on the screen.
Using this program:
(I) LET A $ = "information
pattern "
(II) POKE 23296, X-coordinate
first pixel
(III) POKE 23297, Y-coordinate
first pixel
(IV) RANDOMIZE USR address
Information Template - a symbol that has the following
Format:
"0" - to put the point
"5" - to reduce the X-coordinate
"6" - to reduce the Y-coordinate
"7" - to increase the X-coordinate
"8" - to increase the Y-coordinate
Any other characters are ignored. The program includes the
ability to "wrap-round", ie, if the X-coordinate goes
the left side of the screen pattern
appears to the right, etc.
To change the program to
use a string variable instead of A $, need to change the 65 *
(code letter A) to the code other characters.
LISTING machine code
Assembly label NUMBER FOR INPUT
147.
LD HL, (23627) 42 75 92
NEXT_V LD A, (HL) 126
CP 128 254 128
RET Z 200
BIT 7, A 203 127
JR NZ, FORNXT 32 23
CP 96254 1996
JR NC, NUMBER 48 11
CP 65 254 65 *
JR Z, FOUND 40 35
STRING INC HL 35
LD E, (HL) 94
INC HL 35
LD D, (HL) 86
ADD ADD HL, DE 25
JR INCR May 24
NUMBER INC HL 35
INC HL 35
INC HL 35
INC HL 35
INC HL 35
INCR INC HL 35
JR NEXT_V 24225
FORNXT CP 224 254 224
JR C, N_BIT 56 5
LD DE, 18 17 18 0
JR ADD 24236
N_BIT BIT 5, A 203 111
JR Z, STRING 40228
NEXT_B INC HL 35
BIT 7, (HL) 203 126
JR Z, NEXT_B 40251
JR NUMBER 24228
FOUND INC HL 35
LD C, (HL) 78
INC HL 35
LD B, (HL) 70
INC HL 35
EX DE, HL 235
LD A, (23 297) 58 January 1991
CP 176 254 176
RET NC 208
AGAIN LD HL, (23296) 42 0 91
LD A, B 120
OR C 177
RET Z 200
DEC BC 11
LD A, (DE) 26
INC DE 1919
CP 48254 1948
JR NZ, NOT_PL 32 78
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
147.
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, L 62 1
ROTARE ADD A, A 135
DJNZ ROTARE 16253
RRA 203 1931
POP DE 209
POP BC 193
OR (HL) 182
LD (HL), A 119
HERE JR AGAIN 24165
NOT_PL CP 53254 1953
JR NZ, DOWN 32 1
DEC January 1945
DOWN CP 54254 1954
JR NZ, UP 32 8
DEC H 37
LD H, A 124
CP 255 254 255
JR NZ, SAVE 32 19
LD H, 175 38,175
CP 55254 1955
JR NZ, RIGHT 32 8
36 INC H
LD A, H 124
CP 176 254 176
JR NZ, SAVE 32 7
LD H, 0 38 0
RIGHT CP 56254 1956
JR NZ, SAVE 32 1
INC January 1944
SAVE LD (23296), HL 34 0 91
JR HERE 24215
2
How it works:
To find the address of a string variable, use a slightly
modified the first part of program "Find the string".
The length of the string variable
loaded into the BC, and the address of the first character is
loaded into the A $ DE. In the battery is installed
the initial value of Y, and if it
more than 175, the routine returns to BASIC. In the H-register
is loaded Y-coordinate, and L - X-coordinate. If the value of a
pair of registers BC is 0, the routine returns to BASIC, as
reached the end of the string variable. BC is reduced to show
that the processed the next character. The next character is
loaded into the accumulator and DE increases, indicating
next byte. If the battery does not contain a code 48, a
transition to NOT_PL. Point (X, Y) is drawn using
procedure SUBR from the program
"Painting the path." Then
the program returns back to
AGAIN.
The procedure NOT_PL, if the battery contains a number of 53,
X-coordinate decreases. The procedure DOWN, if the battery is
not contains the number 54, made the transition to the UP.
Y-coordinate decreases, and if its value becomes equal to -1,
Y-coordinate set to the 175.
In the process of UP, if the battery does not contain 55, is
transition to the RIGHT. Y-coordinate
increases, and if it is
176, then the Y-coordinate is set to 0. The procedure RIGHT,
if the battery contains a value of 56, X-coordinate increases.
The procedure SAVE X and Y coordinates are placed in memory,
and the program makes the transition to HERE.
*