Sketches
Alone Coder
In this section we will publish co-
simple and quick procedures that are recommended
we need to use instead of the ancient and thunder-
zdikh.Small ones will also be included
changes to old procedures that provide any
advantage over the latter.
A change in the seemingly classic
what procedure DOWN HL, which, as is known,
calculates the byte address on the screen, lying
one pixel below that specified in HL:
Was: Now:
INC H INC H
LD A,H LD A,H
AND 7 AND 7
JR NZ,EXIT JR NZ,EXIT;CY=0
LD A,L LD A,L
ADD A,32 ADD A,32
LD L,A LD L,A
JR C,EXIT JR C,EXIT;CY=1
LD A,H LD A,H
SUB 8 ADD A,-8
LD H,A LD H,A;CY=1
EXIT...EXIT...
In this version everything remains the same -
mu, except that the CY flag is now
indicates crossing the border of the current
acquaintances. In the UP HL procedure you can produce
make a similar change: instead of ADD A,8
put SUB -8.
: at the coordinates specified
in registers L=y, E=x, in an arbitrary place
screen (and even behind the screen) in 58(!) clock cycles
The dot appears. Register C is equal to the most significant byte
table addresses ('TABLE), register D=C+2.
LD H,C
LD A,(DE);x/8┐
INC D ├gives low byte
OR (HL);L(y) ┘INC H
LD H,(HL);H(y)
LD L,A
LD A,(DE);byte(x)
(X)OR (HL);point setting method
LD(HL),A
If instead of the last 2 commands you insert
AND (HL), then this will be the POINT function. To
the procedure worked many times, at the end of it
set DEC D. Tables are generated as follows
following program:
LD HL,TABLE+256
LD DE,#4000
GEN0 LD (HL),D ┐
DEC H │
LD (HL),E │
INC H │
DOWN DE │1st
LD A,D ├ and
SUB 88 │2nd
JR NZ,$+3 │
LD D,A │
INC L │
JR NZ,GEN0 ┘
INC H
LD A,128
GEN1 LD (HL),E ┐
INC H │
LD (HL),A │
DEC H │3rd
RRCA ├ and
JR NC,$+3 │4th
INC E │
INC L │
JR NZ,GEN1 ┘
A fragment of a program that allows you to
and the same 19 cycles to execute / not to execute
seven-cycle command (Z - execute, NZ -
do not execute):
JR NZ,$+4
JR EXIT
EXIT...
Quickly print 6x8 letters (screen in DE):
PUSH DE
LD L,A
LD B,C
LD A,2
RRCA
DJNZ$-1
LD (PRN+1),A
LD H,'FONT
LD B,8
PRGO PUSH HL
LD L,(HL)
PRN LD H,1
PR1 ADD HL,HL
ADD HL,HL
JR NC,PR1
LD A,(DE)
ORH
LD(DE),A
INC E
LD A,L
LD(DE),A
DEC E
INC D
POP HL
INC H
DJNZ PRGO
POP DE
If the font stops at 0, then remove LD
B,8,a DJNZ PRGOreplace with JR NZ,PRGO.
Register C must contain 7,5,3 or 1,
with 7 corresponding to the zero coordinate
letters inside the familiar place (x mod 8=0). Letters in
font 256, and they are all pressed to the left edge
(can be shifted one point to the right). How
you need to change C:
LD A,C
SUB 6
JR NC,$+5
INC E
AND 7
LD C,A
And finally, I’ll touch on what everyone is already tired of
ZX review calculation of the address of a letter in ROM:
Was: Now:
LD L,A LD L,A
LD H,0 ADD HL,HL
ADD HL,HL LD H,15
ADD HL,HL ADD HL,HL
ADD HL,HL ADD HL,HL
LD BC,15360
ADD HL,BC
We're convinced that you've been bullied all your life -
is it on your ears?
Share your thoughts about the article