+----------------------------+
| --- FOR PROGRAMMERS --- |#
+----------------------------+#
###############################
PART #2
-------------------
Magic on Scorpion'e ZS 256
----------------------------
You've probably come across the program
frames or games in which, when
pressing the Magic button does nothing
occurs or the authors of these pro-
The information is being joked about, i.e.
if you click on Magic, then on
funny message appears on the screen
an inscription or something like that.
So if you want to do
you have such a joke too
computer Scorpion ZS-256, then you
you can read this chapter, and those
who doesn't have this computer,
they might just miss a couple
pages.
For those who don't know how to
switch memory banks (country
I'll show you how it's done.
To switch pages from 0 to
7 you need to use port #7FFD.
In order to switch
Page 2 needs to be written to the port
#7FFD number #12 :
(the number is written to the port
command OUT (C),A, where C is the number
port, in the battery A-number)
LD A,#12
LD Sun,#7FFD
OUT(C),A
RET
Using this procedure you
you can switch pages in
regular ZX-Spectrum 128kb.
+------------------------------+
| Table |
| --------- |
| page number which you |
| will you write down|
| to port #7FFD. |
| 0 #10 |
| 1 #11 |
| 2 #12 |
| Z #1Z |
| 4 #14 |
| 5 #15 |
| 6 #16 |
| 7 #17 |
+------------------------------+
Page 5 is always located in
areas #4000-#7FFF.
Page 2 in area #8000-#BFFF
And in the area #C000-#FFFF it can
be any of the pages with
number 0...7.
To switch country
faces with numbers 8...15 are needed
use an additional port
#1FFD. For example, if you want
switch page 10, then you
first you need to switch 2
page and then write down the number
#10 to port #1FFD
LD A,#12 ;2 page
LD Sun,#7FFD
OUT (C),A
LD A,#10
LD Sun,#1FFDOUT (C),A
RET
As a result, switch 10
page - 8+2=10.
+------------------------------+
| Table #2 |
| ------------ |
| additional - necessary first |
| switch pages |
| page: |
| 8 (0+8=8) 0 |
| 9 (1+8=9) 1 |
| 10 (2+8=10) 2 |
| 11 (W+8=11) W |
| 12 (4+8=12) 4 |
| 1З (5+8=1З) 5 |
| 14 (6+8=14) 6 |
| 15 (7+8=15) 7 |
| and then write down|
| #10 to port #1FFD|
+------------------------------+
If page 10 is switched and
do you want to switch back 2
page, then you just need to write down
Put 0 (zero) into port #1FFD.
LD A,0
LD Sun,#1FFD
OUT (C),A
RET
Instead of LD A,0 you can use
XOR A (battery reset).
If you want to press
on Magic the computer just froze,
then you can use the pro-
procedure:
LD A,#10LD Sun,#7FFD
OUT (C),A
LD Sun,#1FFD
OUT (C),A
LD HL,#C000
LD DE,#С001
LD Sun,#ЗFFF
LD(HL),0
LDIR
LD A,0
LD Sun,#1FFD
OUT (C),A
RET
This protection is based on mashing
8 pages where it is located
main part of the shadow monitor
How it works:
Switches page 0, then 8
-th In HL we set the address to
chala (buffer) 8 pages. In DE -
address of the second byte of the buffer. A sun
- counter (page length - #ЗFFF)
Team LD (HL),0 cleared the lane
first byte of the buffer, and then transfer
blamed the entire contents of the buffer on
one byte and eventually cleared the second one
swarm byte.
While the LDIR command is running
the contents of HL,DE,BC do not remain
unchanged. After the transfer
each next byte HL and
DE increases by one, and
BC decreases by one.
Thanks to this, after the transfer
first byte into the second, DE already
will point to the third, and HL will “hook”
zero byte from the second cell and
so on. In general, the entire buffer
will be overwritten. Instead of zero you can
use anynumber from 0
up to 255 (#0-#FF).
Then switches again to 0
page.
If you want to press
your program was launched on Magic
frame then this procedure is just
for you:
LD HL,ADDR
LD A,#10
LD Sun,#7FFD
OUT (C),A
LD Sun,#1FFD
OUT (C),A
LD A,255
LD (#СОбЗ),А
LD (#С064),HL
XOR A
OUT (C),A
RET
ADDR DI
IM 1
LD A,#10 ;needed by you
; page
LD Sun,#7FFD
OUT (C),A
XOR A
LD Sun,#1FFD
OUT (C),A
EI
; Start of your program...
How it works:
Your address is loaded into HL
programs. Switches 8 countries
face. We write to battery A
255 and enter this value according to
address #SObZ. The address of your program
The frame is written in #C064.
Switches0 page.
INVERT CHARACTER
VERTICAL
------------------------
This procedure inverts the character
vertically For example if
the arrow is pointing upward, should
become a downward arrow
and vice versa.
LD HL,ADDR ;symbol address
;in RAM (ROM)
LD D,H
LD E,L
LD V,8
LOP1 LD А,(HL)
INC HL
PUSH AF
DJNZ LOP1
LD V,8
LOP2 POP AF
LD (DE),A
INC DE
DJNZ LOP2
RET
How it works:
HL loads into a pair of registers -
This is the symbol data address. This same one
the address is then copied to DE. B
register B is loaded with value 8
to use the register in ca-
as a counter.
For every byte in the accumulator
the existing one is loaded
moment value. HL increased
reads, pointing to the next
bytes, and the contents of the accumulator
is pushed onto the stack. Counterdecreases, and if it is not equal
0, the subroutine returns,
to repeat the process to follow
blowing byte. In register "B"
the value 8 is loaded again,
to use it again
as a counter. Image
character is saved on the stack.
The LOP2 procedure returns data
data from the stack to the same sign
place, but in reverse order.
Byte by byte is taken from the stack
and placed through the battery
at the address contained in DE.
DE is increased to indicate
to the next byte, and the counter
decreases. If it is not 0,
the procedure returns to LOP2.
Otherwise the procedure
completes its work.
INVERT CHARACTER
HORIZONTAL
------------------------
This procedure inverts the character
horizontally. If the arrow points
is directed to the left, becomes direction-
to the right.
LD HL,ADDR ;symbol address
LD A,8
LOP1 LD V.8
LOP2 RR (HL)
RL C
DJNZ LOP2
LD (HL), C
INC HL
DEC A
OR A
JR NZ,LOP1RET
How it works:
A couple of HL registers are loaded
address of the symbol data, and in the accumulator -
lator loading quantity
bytes that must be in-
verted.To register B loaded-
the number of bits in each byte
it is used as a counter.
The byte with the address in HL is shifted
to the right in such a way that the extreme
the right bit is copied to the flag
transfer. C - register shifts
to the left so that the carry flag
copied to the rightmost bit.
The counter decreases.
If the counter is not 0,
goes to LOP2 to work
with the next pixel.
The inverted byte, which
located in register C, placed
goes into the cell it came from
taken.
HL increases, indicating
next byte and accumulator
decreases. If it is not equal to 0,
transition to LOP1 occurs, otherwise
the procedure completes its work.
SHIFT ATTRIBUTES LEFT
------------------------
This procedure shifts the attributes
screen one space to the left.
LD HL,22528
LD A,* ;value 0-255
LD С,24
LOP1 LD В,З1
LOP2 INC HLLD E,(HL)
DEC HL
LD (HL),E
INC HL
DJNZ LOP2
LD (HL),A
INC HL
DEC C
JR NZ,LOP1
RET
How it works:
A couple of HL registers are loaded
attribute area address. Battery
lator is loaded with the at-value
ributa entered in the right column
The C register is loaded with
Number of lines to shift. In the region
page The number is entered 1 less -
neck than the number of characters in the line,
so that it can be used as an account
chick.HL is increased to indicate
put on the next attribute,
which is loaded into the E-register.
HL also decreases at address HL
the value from the E-region is placed
str. HL increases again,
to show at the next at-
ribut.Register B decreases and,
if it is not equal to 0, then
dit transition to LOP2. HL now
points to the right column and along
the HL address is given the value from
battery HL increases
to point to the next one
line. The line counter is decremented
and if it is not equal to 0, then
transition to LOP1, otherwise the process
the fool completes her work.
SHIFTATTRIBUTES TO RIGHT
------------------------
This procedure shifts the attributes
screen one space to the right
LD HL,2З295
LD A,* ;value 0-255
LD С,24
LOP1 LD В,З1
LOP2 DEC HL
LD E,(HL)
INC HL
LD (HL), E
DEC HL
DJNZ LOP2
LD (HL),A
DEC HL
DEC C
JR NZ,LOP1
RET
If you understand the procedure
"Shift attributes left" then you
you can easily figure this one out
procedure. These procedures are similar
at each other and I didn’t move
write the same thing twice.
Find out for yourself.
PRINTING A MESSAGE ON THE SCREEN
----------------------------
This procedure will help you to
Take your message to the screen.
LD A,2
CALL 5bZZ
LD HL,TECHT
CALL PRINT
RETPRINT LD А,(HL)
CP 255
RET Z
RST 16
INC HL
JR PRINT
TECHT DEFB 22,10,10
DEFM "SCORPION ZS 256"
DEFB 255
How it works:
We load battery A
stream number 2 (output to main
no screen). Setting up the stream
number 2 using a subroutine
located in the ROM at the address
5bЗЗ.In the register pair HL inserted
SIM address of your message. Call-
We create the PRINT procedure. This pro-
The procedure outputs symbolic
la into the current stream using
RST 16 (symbol output to stream).
Now let’s figure out why it should
yours begins and ends
message. In this example, the first
is the position control code
print AT. As in regular BASIC
after it the coordinates are indicated
you print. The message should
will end with code 255.
ENTERING A CHARACTER FROM THE KEYBOARD
---------------------------
To poll the keyboard most often
use the variable 2З560, it
contains the code of the last pressed
keys.
XOR A
LD (2З560),АKLOP LD А,(2З560)
OR A
JR Z,KLOP
RET
How it works:
Reset the battery, enter
its value in the variable 2З560.
We check this variable for 0,
if it is equal to 0, then it happens
transition to KLOP.
This will go on forever
until one is pressed
key.
SOUND SIGNAL
-----------------
The subroutine is located in ROM with
addresses 949 (#ОЗВ5).
Before calling the subroutine, you must
must be included in register pairs
HL and DE value from 0 to 655З5,
proportional, respectively,
frequency of the sound signal and its
duration. In this case, you need to learn
draw a linear relationship
between frequency and duration -
the higher the tone, the shorter the sound.
Required values calculated
are as follows:
HL=(4З7500/f)-З0.125 DE=f*t
where f is frequency in Hz, t is time in sec
For example, to play in
within 1 second of the note <>
first octave (frequency approx.
261 Hz) in HL we place the number 1646
and in DE the number is 261.
LD HL,1646
LDDE,261
CALL 949
RET
The text was written by Oleg Kogun.
from ChemneSoft+
__________________________________________
Share your thoughts about the article