Академический Документы
Профессиональный Документы
Культура Документы
CODE
PROGRAMMING
Bring your MSX
for only 4.95
Learn
Uses
less
howto write
Machine Code
programs
ito life
memory
and runs up to
100 times faster
than ordinary BASIC
By Steve Webb
brar-ti
PRACTICAL MSX
MACHINECODE
PROGRAMMING
PRACTICAL MSX
MACHINE CODE
PROGRAMMING
BY
STEVE WEBB
1SBN0863690742
All rights reserved. Nopartofthis book
Contents
Introduction
9
11
17
31
41
Sprites
49
55
73
85
Appendices
95
Introduction
The intention of this book is to introduce you to Machine Code
programming on MSX computers. The chapters have been
written in a logical order and it is important that you read and
understand each one before moving on to the next.
Machine Code programming is not as complex as you may
have been led to believe. If you have a working knowledge of
BASIC then you will be able to grasp the concepts of Machine
Code programming very quickly.
The first few chapters deal with the theory of Machine Code,
showing you how numbers are stored, answering the question
What
simple routines.
In the last few chapters you will be shown some useful
routines and how to take advantage of the advanced facilities of
the MSX. Throughout the book you will come across various
questions, which you should attempt to answer (you will find
the answers in the back of the book); if you get them wrong,
re-read the appropriate section until you are able to answer
them correctly.
work
10
WHAT IS
MACHINE CODE?
11
Machine Code. This is what is left after 4000 of 32000 has been
taken up by system variables. In a 64k computer, a further 32k
is available in addition to the 28k described above. However,
advanced Machine Code programming techniques are needed
ifyou want to use this extra 32k- and this goes beyond the scope
of this book. All the programs in this book will work on a 32k (or
greater)
MSX computer.
done.
Lets say that the number you wish to store is 29248. First we
divide this
13
is
an
is
done.
Lets say that the number you wish to store is 29248. First we
divide this
number by
down to the
be stored (29248).
114x256 = 29184
29248-29184 = 64
64 is called the low part of the number to be stored.
To store the number 29248 in memory, we put the low part,
64, in one memory location and the high part, 114, in the
following location. So to store a number greater than 255
requires the use of two memory locations. Thus if you read in
this book or anywhere else that a number greater than 255 is
stored at location 50000, you will now know that it is in fact
stored at locations 50000 and 5000 1
What are the high and low parts of the number 45621?
If the low part of a number is 31 and the high part is 64,
then what is the number?
14
16
MACHINE CODE
EQUIVALENTS OF
BASIC STATEMENTS
17
close equivalent in
A,B,C,D,E,H,L
There
ourselves with
HL
BC
DE
This pairing does not prevent the registers being used
individually.
19
r
The equivalent opcode is:
LDA,5
number
BASIC:
Meaning:
Opcode:
Meaning:
LET A = B
Let variable A have the same value as variable B.
LD A,B
Load
register
register B.
with the
same
value as contained by
LDA,H
LDE,A
LDH.C
BASIC:
LET A = A + 5
Meaning: Increase the present value of A by 5.
Opcode: ADD A,
Meaning: Increase the value contained by register A by
20
5.
Register A is the only register you can directly add a number to.
Y ou cannot have opcodes such as:
ADDB,9
ADD E.3
This
is
it
is easily
BASIC:
LET A = A + B
Meaning: Increase the value of A by the value of B.
Opcode: ADDA.B
Meaning: Increase the value contained by register A by the value
contained by register B.
A with the
ADDA.B
ADDA,C
ADD A.H
ADD A.L
ADD A.D
ADD A.E
ADD A,
last opcode above is ADD A, A. This has the effect of
doubling the present value of A. It is not possible to add any
other combinations of registers other than those shown above.
Thus you cannot have:
The
ADDB.H
ADDD.C
Register pairs can also be added together, but only in the
following combinations:
ADDHL.BC
ADDHL.DE
ADDHL.HL
The answer will always appear in HL. The last opcode, ADD
HL.HL, obviously has the effect of doubling the value of HL. It is
not possible to add a single register directly to a register pair.
21
will
1)
LDA.B
Register A now has the same value as B.
Step 2)
ADD A,
The required addition
is
register A.
Step 3)
LD B,A
The answer is transferred from register A to B.
ADD B,H
We get round this limitation in the following way. Lets say that
B has a value of 5 and H has a value of7 and that we want to add
the registers together with the answer appearing in register B
1)
LD A,B
Register A now has the same value as B.
Step 2)
ADD A,H
The addition is complete with the answer in register A.
Step 3)
LDB.A
The answer is transferred to register B
itself.
Using similar steps we can now add any register pair to any
other register pair. To add the values of BC and DE, with the
answer appearing in BC, we do the following:
22
55
Step
LDH,B
1)
LDL.C
Register pair
ADDHL.DE
Step 2)
LDB.H
LDC.L
Step 3)
BASIC:
LET A = A - 5
Meaning: Decrease the value of A by 5.
Opcode: SUB A,
Meaning: Decrease the value of register A by 5.
LDA.D
Stepl)
Register A
Step
2)
Step
3)
SUB A,
The subtraction is done with the answer in register A.
LDD.A
The answer is transferred from A to D.
BASIC:
LET A = A - B
Meaning: Decrease the value of A by the value of B.
Opcode:
SUBB
shown you.
Register pairs can also be subtracted from each other but
only in the following combinations:
23
SBC HL,BC
SBCHL.DE
SBCHL.HL
INCA
INC B
INCC
INC D
INCE
INCH
INC L
INCHL
INC
BC
INCDE
you wish
if
to subtract
BASIC:
GOTO (line number)
Meaning: Go to specified line number.
Opcode: JP (memory location)
Meaning: Jump to the specified memory location.
same as
BASIC:
Meaning:
instruction.
Opcode:
Meaning:
24
BASIC subroutine,
BASIC:
Meaning:
In
A = 5 THEN (GOTO/GOSUB/LET/etc.)
A = 5 then do whatever is specified.
IF
If
This means that if the result of the last calculation was zero
then call the subroutine at the specified memory location.
The following is a list of the most commonly used IF
opcodes:
CALLNZ.nn
the last result calculated was not zero then call the
subroutine at the specified memory location nn.
If
CALLM.nn
If the last
at
CALLP.nn
If the last result calculated was positive then call the
subroutine at memory location nn.
JPZ.nn
If the last result
JPNZ.nn
If the last
result calculated
location nn.
JPM.nn
If
to
memory
location nn.
25
JPP,nn
If the last result calculated
location nn.
BASIC:
FOR A = 1 T0 100
Routine which needs to be done 1 00 times.
NEXT A
Meaning:
Do the routine within the loop 1 00 times.
Machine Code: LDA.100
Routine which needs to be done 1 00 times.
SUBA.1
JP NZ, start of routine.
To simulate a FOR/NEXT loop, we first load register A with
however many times we need to perform the routine
within the loop. At the end of the routine we subtract 1 from
register A. If the result of subtracting 1 from register A was
NZ (not zero) then we jump to the start of the routine. This
100, or
LD A, (40000)
Meaning: Load register A with the value contained by memory
location 40000.
Opcode:
LDD, (40000)
26
is
to load register
location 40001.
to
locations.
POKE (40000), A
BASIC:
Meaning: Put the value of variable A into
Opcode:
LD (40000),
locations.
Opcode:
LD (40000), HL
(40000), HL?
BASIC:
LET A = 5
LET B = 40000
POKE (B), A
Meaning:
Opcodes: LDA,5
LDHL, 40000
LD(HL),A
Meaning:
memory
27
BASIC:
LET B = 40000
LET A = PEEK(B)
Meaning:
in
the
memory
LDA,(HL)
LD A,(BC)
LD A,(DE)
The other six single registers can only be loaded from register
pair HL as shown below:
LDB,
LDC,
LD D,
LD E,
LDH,
LD L,
HL)
HL
HL)
HL
HL)
HL)
Opcodes: PUSH
POP
These two opcodes do not really have BASIC equivalents.
However, they are very important in Machine Code
programming and the following example will help to explain
all
of the seven
HL
BC
DE
A
In BASIC if we wanted to execute this routine several times
we would use a FOR7NEXT loop. I have already explained how
to simulate a FOR/NEXT loop in Machine Code, so now lets
try
28
it.
(start of routine)
BC
DE
A
SUB A,1
JPNZ, (start of routine)
END
am
sure that you can see that the above program will not
It is like setting up a FOR/NEXT loop such as FOR A = 1
TO 8, and then using the variable A in the routine inside the
loop. Very strange things would happen; the value of A
controlling the loop would be destroyed by the use of A inside
the routine. In BASIC this problem is easy to avoid because
I
work.
LDA,8
(start of routine)
PUSH A
HL
BC
DE
A
POP A
SUBA.1
JP NZ, (start of routine)
original value of A.
before
30
STORING OPCODES
IN MEMORY
31
mentioned are only one byte long- that is, they are stored in one
memory location. However, some opcodes such as ADD A, 5
require two memory locations. One location holds the actual
opcode which is ADD A. The next consecutive location must
hold the number which you wish to add to A. If ADD A, 5 was the
first opcode of a program starting at location 40000 then we
would need to put 198 (which is the number for ADD A) into
location 40000. In location 40001 we would have to put 5.
When the program is started (I will show you how to do this in
a while), the processor would look at the contents of the first
location and see that the opcode is ADD A. It would then look at
location 40001 to see how much it should add to A. Once it had
completed the addition it would move on to the next opcode
which starts at location 40002.
Some opcodes are two bytes long and may need to be followed
by one or two bytes, making the total instruction three or four
bytes long. Again, these bytes must be stored consecutively in
the
memory.
33
By now you
instructions,
it is currently
the instruction is completed, the processor
moves on to the next one. Despite the lack of line numbers it is
still possible to have instructions such as GOTO and GOSUB.
Instead of having to GOTO line numbers we can GOTO specific
executing.
When
memory locations.
When we input a Machine Code program we do
not type in
DECIMAL
HEX
00
09
10
15
16
OA
255
FF
OF
10
2
6
10CLEAR200, 39999
15CLS
20 LOCATE 0,0
25 PRINT "PUT CAPS LOCK ON"
30 LOCATE 0,4
35 PRINT PRESS KEY E TO ENTER HEX CODE"
40 LOCATE 0,8
45 PRINT PRESS KEY C TO CHECK HEX CODE
50 LOCATE 0,1
55 PRINT "PRESS KEY X TO CHECK HEX TOTAL
60 LOCATE 0,1
65 PRINT "PRESS KEY Q TO STOP"
70 A$ = INKEYS
=
75 IF AS ETHEN GOT0 1 85
=
80 IF AS CTHEN GOTO 380
=
85 IF AS "X'THEN GOTO 1 00
90 IF AS = QTHEN STOP
95 GOTO70
100 CLS
105 LOCATE 0,0
1 1 0 PRINT INPUT STARTING ADDRESS
115 INPUT SA
120 LOCATE 0,5
1 25 PRINT "INPUT END ADDRESS"
130 INPUT EA
135LETD=0
140 FORC=SATOEA
145 LETD=D t PEEK(C)
150 NEXT
155 CLS
160 PRINT "TOTAL COUNT - ;D
165 LOCATE 0,20
1 70 PRINT "PRESS M TO RETURN TO MENU"
1 75 IF INKEY$<>M"THEN GOTO 1 75
180 G0T015
185 CLS
190 LOCATE 0,0
35
415INPUTEA
420 CLS
425 IF SA+20>EA THEN GOTO490
430 FOR C=SA TO SA + 20
1 6 THEN GOTO480
435 IF PEEK(C)<
<
440 PRINT C; ;HEXS(PEEK(C))
36
445 NEXT
450 IF ND= 1 THEN GOTO 505
455 IF C>EA THEN GOTO 505
460 PRINT PRESS M FOR MORE"
465 LETSA=C
470 IF INKEYS <> M THEN GOTO 470
475 G0T0425
480 PRINT C; 0;HEX$(PEEK(C))
485 GOTO 445
490 FOR C= SA TO EA
495LETND=1
500 GOTO 435
505 PRINT PRESS M TO RETURN TO THE MENU"
510 IF INKEYS <>M" THEN GOTO 510
51 5 GOT0 15
When it has loaded it will automatically RUN and you will see
the following menu:
To enter Machine Code you must press key E. You will then
be asked to put the
it is
40000.
You can then start to enter the HEX codes. The first line
is
and 40001.
Enter the other three
lines in
40000
40007
852
Start address
End address
Hex total
3E05
C610
ADDA, 16
32A49C
LD|40100),A
LD A,5
The next thing to do is to check that you have entered the code
done by pressing C. You will then be asked to
enter the start address of the code you wish to check, which in
this case is 40000. Then you will be asked to enter the end
address of the code, which in this case is 40007. The screen will
then display the memory locations and their contents. You
should check this very carefully; if there is an error you should
go back to the menu and re-enter the code.
There is another checking facility which is obtained by
pressing key X. You will then be asked for the start and end
address again. The HEXENT program will then add up the
contents of all these locations and printout the total in this case
it should be 852. If it is not, then you have either entered the
code incorrectly or, less likely, you have mistyped the
HEXENT program. Make sure that you cure the problem
correctly. This is
before proceeding.
All this checking is vitally important because, unlike BASIC
These two
38
meaning
GOSUB
the
it is
RET, meaning
return.
When
this opcode it will return to where it came from, in this case back
to
and 5.
39
UNDERSTANDING
THE
SCREEN DISPLAY
41
Understanding the
Screen Display
One very useful feature of the MSX
modes. These four modes are:
is its
So where
is
memory?
have already
your
43
rhappen. The
SCREEN 1
PRINT BASE (5)
The first line ensures that you are in mode 1 The second line
number which is the start address of your screen
map. Y ou should make a note of this number; we will refer to it
.
will print a
following line:
VPOKE (SCREENSTART), 65
televisions
+ CHARSTART
((
(65 * 8)
(65
is
+ CHARSTART = 520
32
16
32
80
136
136
248
136
136
stored:
45
VPOKE
VPOKE
VPOKE
VPOKE
VPOKE
In
as
SCREEN 1
VPOKE (SCREENSTART +5), 65
This will put the letter on the screen.
COLSTART
(CHARACTER NUMBER/ 8)
8192 +
In the following example
(65/8)
= 8200
will be
you, of course,
calculation.
to be printed in
white on a black
background.
There are 1 6 colours and each one is given a code between 0 and
15,
as shown below:
0 transparent
1 black
2 medium green
3 light green
4 dark blue
5 light blue
6 dark red
7 cyan
8 medium red
9 light red
10 dark yellow
11
12
13
14
15
yellow
dark green
light
magenta
grey
white
into
Get the code for the ink colour. Multiply it by 16 then add the
code for the paper colour. Thus the code for magenta ink is 13
multiplied by 16 = 208, and the code for white paper is 15.
Therefore the code for white paper and magenta ink is 208 +
15
223.
47
SPRITES
Sprites
One of the very useful features of the MSX is its sprites. What
are sprites? Lets suppose you are writing a game and you need
to move something smoothly across the screen. If you didnt
have sprites, you would first have to print a character in one
position,
can define
location.
possible to have
VDP(1) = 224
1
will deal
my MSX
SPRITE
is
SHAPE START. As
Space Invader.
51
4) Vertical position
2T\ Horizontal position
3 Sprite number
4 Colour
(SPRITE NUMBER *
4) +
6912 = 6972
will
is:
VPOKE
VPOKE
VPOKE
VPOKE
255
191
then the sprite will disappear off the screen. Associated with
the sprites is a register; this can be read to see if any sprites have
I will show you how this can be used in the next chapter
in the Space Invader program.
collided.
sprites
particularly
fifth sprite
cannot be seen:
53
THE
SPACE INVADER
PROGRAM
55
"\
Before
ROM
difficulty in
THE FLOWCHART
When developing a program, one of the first things to do
is
to
and what
Game
CALL SETUP
DELAY
ROUTINE
GAMELOOP
CALL MOVE INVADER
CALL DELAY
HAS INVADER BEEN HIT?
IF SO, THEN JUMP TO
EXPLOSION ROUTINE
6 Bytes
1 1
Bytes
1 1
Bytes
ROUTINE
FIRE
37 Bytes
ROUTINE
CALL DELAY
ROUTINE
62 Bytes
EXPLOSION
ROUTINE
33 Bytes
BULLET ACTIVE
ROUTINE
20 Bytes
IS
MOVE INVADER
IS
IS
IF
CALL DELAY
IS
IF
KEY X PRESSED?
RETURN TO BASIC
SO,
MOVE BULLET
ROUTINE
27 Bytes
SETUP
ROUTINE
125 Bytes
JUMP TO START OF
GAMELOOP
70 Bytes
to
58
you will have to move all the instructions which follow on from
it. This then causes huge problems with absolute jumps and
calls. Let us suppose that you have a delay routine at location
40000 in the program. To access the delay you would probably
have an instruction somewhere else such as CALL 40000. If, for
some reason, you needed to add a simple three-byte instruction
at the end of the routine which normally ends at location 39999,
then you will obviously need to use locations 40000/40001/
40002. It will then be necessary to move the delay routine so
that it starts at location 40003. Having done that, you will then
have to work through your program and change all the CALL
40000 to CALL 40003. Writing a program in this way is tedious
and will take a very long time.
These problems can be overcome by using your main
flowchart to create a memory map. To form a memory map you
need to know approximately how many bytes there are in each
routine. You then allocate specific memory locations to each
routine, while also leaving a few bytes free between the end of
one routine and the start of the next. The free memory spaces
will enable you to extend any routine without affecting the
following routines. The following flowchart for a very simple
program - demonstrates how to create a memory map:
CLEAR
SCREEN
40 Bytes
DELAY
20 Bytes
ROUTINE
50 Bytes
marked with
number
GAMELOOP
40000
40082
40133
40157
40205
40243
40316
40338
40363
40474
BULACT
EXPLO
FIRE
MOVBUL
MOVINV
MOVLEF
MOVRIG
SETUP
DELAY
variables.
shortly.)
EXPLANATION OF TERMS
I
would now
like to explain a
make the
2)
Gameloop: This
have been carried out, the program jumps to the start and
does them all over again, hence the name Gameloop.
Deadflag: This is a single memory location which normally
contains the
the
number one.
memory
location
is set
to zero.
The
Deadflag is 41000.
Rag: This is a single memory location which
normally contains the number one. When the bullet has
been fired this location is set to zero. It is used to prevent a
bullet being fired when there is already one on the screen.
The location of the Bullet Active Flag is 41001
3) Bullet Active
60
4)
INITIALISATION ROUTINE
40363
40463
6910
Start address
End address
Hex total
3E01
32AFFC
CD5F00
21EC9D
110038
2050 SETUP:
2060
2070
2080
2090
LD
A,1
LD
64687) ,A
CALL
HL.DATA
LD
LD
DE, 14336
61
011800
00000 IOC
C8000201
2100
2110
2120
2130
2140
2150
2160
2170
2180
2190
2200
2210
2220
2230
2240
2250
2260
2270
2280
2290
2300 DATA:
2310
2320
2330
2340
2350
2360 DATA 1:
2370
2380
The above
initialisation
CD5C00
0E05
0636
CD4700
21049E
11001B
010C00
CD5C00
3E01
32269E
32279E
32289E
0E01
06E1
CD4700
0E02
0606
CD4700
C9
1818187E
FFFFFFOO
3C7E99FF
663C4224
18181818
18181818
AA64000F
LD
BC.24
CALL 92
LD
LD
CALL
LD
LD
LD
C,5
B,54
71
HL.DATA1
DE.6912
BC.12
CALL 92
LD
LD
LD
LD
LD
LD
A,1
CALL
71
DEADF) ,A
ACTF) ,A
DIREC) ,A
C,1
B.225
LD
C,2
LD
B,6
CALL 71
RET
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
24,24,24,126
255,255,255,0
60,126.153,255
102,60,66,36
24,24,24,24
24,24,24,24
170,100,0,15
0,0,1,12
200,0,2,1
1000DEFUSR = 40363
1005 A = USR(1)
lOIOGOTO 1010
You should now see the Invader printed in the top left-hand
corner of the screen and the gun at the bottom of the screen in
the middle.
The move gun right routine can be tested by changing line 1010
in the previous BASIC
program to:
1010DEFUSR
40338
is
1)
If the
2)
so the Invader is
3) If
4)
gameloop.
The Invader
is
it is
moved
moved
a very
current
get
its
we
first
that
is,
gun;
the
similar way
horizontal position and, in the case of moving right, we add
one to it. This new value is then put into the correct place in
VRAM which represents the horizontal position of the
one position
to the right.
The Invader
is
in
to
5)
6)
7)
8)
9)
Invader sprite.
Return to the gameloop.
The Invader Direction Flag is set to one so the Invader is
currently moving from right to left.
then the
If the Invader is at the extreme left of the screen,
to the
returns
program
and
the
zero
Direction Flag is set to
gameloop.
The Invader is not at the extreme left edge of the screen, so it
done by subtracting
is moved one position to the left. This is
one from the horizontal position of the Invader sprite.
Start address
End address
Hex total
64
40243
5797
3A289E
3D
CA569D
21051B
CD4A00
D6F0
C24B9D
3E01
32289E
C9
21051B
CD4A00
3C
CD4D00
C9
21051B
CD4A00
D601
C2679D
3E00
32289E
C9
21051B
CD4A00
3D
CD4D00
C9
1350MOVINV
LD
A,(DIREC)
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450 IRIG1:
1460
1470
1480
1490
1500 ILEFT:
1510
1520
1530
1540
1550
1560
1570ILEF1:
1580
1590
1600
1610
DEC
JP
Z, ILEFT
LD
HL.6917
CALL 74
SUB 240
JP
NZ.IRIG1
LD
A,1
LD
(DIREC) ,A
RET
LD
HL.6917
CALL 74
A
CALL 77
RET
LD
HL.6917
CALL 74
SUB 1
INC
JP
LD
LD
NZ.ILEF1
A.O
(DIREC), A
RET
LD
HL,6917
CALL 74
DEC A
CALL 77
RET
lines:
1000DEFUSR = 40363
1005 A = USR (0)
1010DEFUSR = 40243
1015A = USR (0)
1020 GOTO 1015
65
40157
Start address
269$
Hex total
3A279E
3C
3D
C8
cM CE4A00
2101 IB
ZT091B
CD4D00
21001B
CD4A00
D61
21081B
CD4D00
3E00
32279E
C9
The
lines.
fire
870 FIRE:
880
890
900
910
920
930
940
950
960
970
980
990
1000
1010
1020
LD
A.(ACTF)
INC
A
A
DEC
RET
LD
CALL
LD
CALL
LD
CALL
SUB
17
HL.6913
74
HL.6921
77
HL,6912
74
LD
HL.6920
CALL 77
LD
A.O
(ACTF).A
LD
RET
the gun:
If it has,
is set
to one,
and the
cannot be seen.
40205
40232
2400
Start address
End address
Hex total
2 108 IB
CD4A00
3D
CA1B9D
CD4D00
C9
3EC8
21081B
CD4D00
3E01
32279E
C9
1130 MOVBUL
1140
1150
1160
1170
1180
11 90 TOP:
1200
1210
1220
1230
1240
LD
HL.6920
CALL 74
DEC A
JP
Z.TOP
CALL 77
RET
LD
LD
A, 200
HL.6920
CALL 77
LD
LD
A,1
(ACTF).A
RET
lines.
1020DEFUSR = 40157
1025 A = USR (0)
1 030 DEF USR = 40205
1035 A = USR(O)
1040 GOTO 1035
MOVE
VRAM
67
3A
to
Start address
40082
40102
2416
End address
Hex total
CB6F
C8
3E00
32269E
C9
450
460
470
480
490
500
MOVBUL
MOVBUL
MOVBUL
CALL
CALL
CALL
CALL
318
BIT
5,
RET
LD
LD
RET
Z
A.O
(DEADF)
.A
EXPLOSION ROUTINE
The gameloop constantly checks the DE ADFLAG; if it is set to
zero then the program jumps to the explosion routine. The way
in which the explosion is caused is simple but dramatic. Firstly,
the screen is set to mode 3 the multicolour mode. The memory
map
is
then
filled
End address
Hex total
3E03
32AFFC
CD5F00
3E64
210000
E5
F5
110008
01E803
CD5C00
FI
68
610EXPLO:
620
630
640
650
660 EXPL01
670
680
690
700
710
LD
LD
A,
(64687),
CALL 95
LD
LD
100
HL,0
A.
PUSH HL
PUSH AF
LD
DE.2048
LD
BC.1000
CALL 92
POP AF
40113
40146
3587
El
POP
24
INC
720
730
3D
740
C2BE9C 750
C3409C 760
DEC
JP
JP
HL
H
A
NZ.EXPL01
START
DELAY ROUTINE
As can be seen from the flowchart, a delay routine is included.
This is required to slow down the whole program so that you can
actually see what is happening. The delay loop works by
loading register A with a value of 255 and repeatedly
decrementing it until zero is reached. When register A finally
reaches zero, the program returns to the gameloop. It is not
practical to test this routine, since even with a maximum
possible delay value of 255 it is still too fast for the average
human to detect. At the end of this chapter I will demonstrate
how you can prove that the delay is actually working.
40474
40480
959
Start address
End address
Hex total
3EFF
3D
C21C9E
C9
2490 DELAY:
2500 DEL:
2510
2520
LD
A, 255
DEC
JP
NZ.DEL
RET
THE GAMELOOP
I will now describe the gameloop in great detail. Firstly, here
a list of the things which the gameloop does:
1)
2)
Call
the DEADFLAG
explosion routine.
See
is
if
is
set to zero, if so
jump
to the
69
rr
3)
if so call
the
key
is
call
the
call
the
is
space bar
is
FIRE
BUTTON
ROUTINE.
7) If key
several
The gameloop also calls the DELAY ROUTINE
Without this
times This is to slow down the whole program.
hardly be able to
delay things would move so fast that you would
see them.
The calls to the various routines do not need any explanation.
being
is possible to detect which key is
I will now explain how it
program does not do the equivalent of asking
The
Which key is being pressed? - but it does ask Is a specific key
pressed.
it.
n
g
ID'
2
a
a
an
a
D
a
a
a
a
a
aa
a a
E
m
gg
6
F3
F2
RETURN
SEL
FI
CODE
BACK
STOP
CAP
CTRL
SHIFT
TAB
F5
F4
SPACE
T
70
OEL
INS
A8
Lets suppose
we wish
then
The routine
will
into register
A relating to
which of the 8 keys in the specified row you pressed. If you look
at the above diagram you will see that each of the 8 columns is
numbered from 0 to 7. The left-hand cursor key is in the column
marked 4. To test if this key has been pressed we use the
following instruction:
BIT 4, A
40000
40071
8681
End address
Hex total
CDAB9D
20 START:
30 LOOP:
40
50
3C
60
3D
70
CAB19C 80
3A279E
90
3C
100
3D
110
CD339D
CD1A9E
3A269E
CC929C
3E08
CD4101
CB67
CC7C9D
CD1A9E
120
130
140
150
160
170
CALL SETUP
CALL MOVINV
CALL DELAY
LD
A, (DEADF)
INC
A
DEC A
JP
Z.EXPLO
LD
A,(ACTF)
INC
A
DEC A
CALL Z.BULACT
LD
A,
CALL 321
BIT
4,
CALL Z.MOVLEF
CALL DELAY
71
A
8
A
5
r
A,
LD
CALL 321
3E08
CD4101
180
190
200
210
220
230
CB47
240
BIT
3E08
CD4101
CB7F
CC929D
CCDD9C 250
CD1A9E 260
3E05
CD4101
CB6F
C8
C3439C
270
280
290
300
310
BIT
7,
CALL Z.MOVRIG
A,
LD
CALL 321
O.A
CALL Z.FIRE
CALL DELAY
LD
A,
CALL
321
BIT
5,
RET
JP
LOOP
lines:
1000DEFUSR 40000
1 005 A = USR (0)
wish to see what the game would be like without a delay
then type in the following line, then run the above program:
If you
POKE 40475,1
Location 40475 should normally be 255;
length of the delay.
it
represents the
ADVANCED
MSX FACILITIES
73
In such a broadly-based
MODEO.
The
VRAM contains
random numbers
configured. Setting the values of the VDPs to
you will then have to
could result in the machine locking up and
values which
switch off the machine. So, do not set the VDPs to
have not been carefully calculated and checked.
VDP is not of any interest to us and you are
0,
When VDP 1
VDP 2
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
78
0
1024
2048
3072
4096
5120
6144
7168
8192
9216
10240
11264
12288
13312
14336
15360
screen
map
1344.
The value
of
VDP
character shapes.
It
possibilities:
VDP 4
Start
0
2048
4096
6144
8192
10240
12288
14336
3
4
5
6
7
VDP
The value of
5 determines the start address of the sprite
variables. Its value can be set to anything between 0 and 127
inclusive. The start address of the sprite variables is then
calculated by multiplying the value of VDP 5 by 1 28. So if VDP
5 has a value of 45, the sprite variables will start at 45 x 128 =
5760.
shapes.
following chart:
VDP 6
0
1
2
3
4
5
6
7
Start
0
2048
4096
6144
8192
10240
12288
14336
79
Machine Code
not of much interest to the
colour the ink and
what
determine
will
value
programmer. Its
0 when a CLS command
paper will be set to in SCREEN
VDP
is
MODE
is
JOYSTICKS
,
one or two
machines have the facility to plug in
can be used
which
ROM
joysticks. There are two routines in the
first routine
The
joystick.
each
of
condition
to determine the
position of the specified joystick. To
All
MSX
demonstrate the
a small Machine Code routine to
with 1 (the
loaded
is
A
register
reading of the joystick. First
reading). Then.the
will
be
we
that
joystick
the
number of
value of register A is then
routine at location 213 is called. The
Here
is
40000
40008
1007
Start address
End address
Hex total
3E01
CDD500
3250C3
C9
80
routine:
000 SCREEN 1
005 DEFUSR = 40000
1010A = USR(O)
1015 B = PEEK (50000)
1020 PRINT B
1025 GOTO 1010
1
1
The routine
want to read.
40000
40008
1025
Start address
End address
Hex total
3E01
CDD800
3C
20F8
C9
Enter and run the following BASIC program
to test the
above
routine:
000 DEFUSR
40000
i
BASIC INPUT OPERATING SYSTEM (BIOS)
The BIOS was briefly described in the chapter dealing with the
Space Invader program. The BIOS contains many Machine
81
Code routines which we can use, thus making the writing of our
own Machine Code routines a great deal easier. The routines I
have listed here are the ones that I consider to be important to
know about while learning Machine Code programming.
VRAM
Name:
Fill
Function:
VRAM
MODE
Requirements:
register A.
CALL:
CD 56 00
Name:
Function:
into
Requirements:
RAM.
VRAM
RAM
CALL:
CD 59 00
Name:
Function:
This routine
of
Requirements:
memory
is
used
into
to
VRAM.
in
of the block.
CALL:
CD5C00
Name:
Get character.
Function:
typical
CALL:
CD9F00
Name:
Position cursor.
Function:
Requirements:
CALL:
CDC600
Name:
Function:
CALL:
CDCCOO
Name:
Function:
is
called
it
CALL:
CDCFOO
Name:
Write to VRAM.
This routine is the Machine Code equivalent
of the BASIC instruction VPOKE (VRAM
address), n - where VRAM address is a
Function:
83
memory
in
Register HL must hold the address
that you want to write to. Register A
must contain a number between 0 and 255.
VRAM
CALL:
CD4D00
Name:
Read VRAM.
Function:
Requirements:
84
CD4A00
A FEW
USEFUL ROUTINES
85
one routine
feel like
writingyourown.
Name:
Function:
Requirements:
Start address
End address
Hex total
3A50C3
012000
211F18
3C
3D
CA529C
09
C34A9C
CD4A00
F5
011F00
2B
20
30
40
50
60 LOOP:
70
80
90
100 LOOP1:
110
120
LD
LD
LD
A, (50000)
INC
A
A
DEC
JP
ADD
BC,32
HL,6175
Z.LOOP1
HL.BC
LOOP
CALL 74
PUSH AF
JP
LD
BC.31
CD4A00 140 ^
DEC HL
CALL 74
23
INC
130LOOP2:
150
CD4D00 160
2B
0B
79
B0
C2599C
FI
CD4D00
C9
170
180
190
200
210
220
230
240
CALL
DEC
DEC
LD
HL
77
HL
BC
A,C
OR
B
NZ.LOOP2
POP AF
CALL 77
JP
RET
87
Name:
Function:
Requirements:
4 ?]9
Start aHdress
4420
Hex total
3A51C3
012000
210018
3C
3D
CAB69C
09
C3AE9C
CD4A00
F5
011F00
23
20
30
40
50
60 LOOP:
70
80
90
1 00 LOOP 1:
110
120
LD
LD
LD
A. (50001)
INC
DEC
JP
Z.LOOP1
HL,BC
LD
BC,31
130LOOP2:
INC
HL
2B
150
160
170
23
180
0B
190
79
200
B0
C2BD9C 210
220
FI
CD4D00 230
240
C9
CD4D00
Function:
LOOP
CALL 74
PUSH AF
JP
CALL 74
DEC HL
CALL 77
CD4A00 140
Name:
ADD
BC.32
HL.6144
INC
HL
DEC
BC
LD
A,C
OR
B
NZ.LOOP2
POP AF
CALL 77
JP
RET
a column of text in SCREEN MODE 1
upwards.
This routine will enable you to scroll any of
the 32 columns of text in SCREEN MODE 1
Scroll
up.
Requirements:
Memory
upwards.
88
Start
40300
40345
4540
address
End address
Hex total
3A52C3
3C
011700
112000
20
30
40
50 LOOP:
60
70
80
90 LOOP1:
100
110
120
19
130LOOP2:
210018
3D
CA7B9D
23
C3739D
CD4A00
F5
CD4A00 140
ED52
150
CD4D00 160
19
0B
79
BO
C2859D
170
180
190
200
210
220
LD
A,(50002)
INC
LD
HL.6144
DEC
A
Z.LOOP1
HL
JP
INC
LOOP
CALL 74
PUSH AF
JP
LD
LD
BC.23
DE.32
ADD HL.DE
CALL 74
SBC HL.DE
CALL 77
ADD HL.DE
DEC
BC
LD
A.C
OR
JP
NZ.LOOP2
CD4D00 225
POP AF
CALL 77
C9
RET
FI
230
Name:
Function:
Requirements:
40200
40246
Start address
End address
Hex total
3A53C3
3C
21E01A
3D
CA179D
20
30
40
50 LOOP:
60
4761
LD
A, (50003)
INC
LD
HL.6880
DEC
A
Z.LOOP1
JP
89
1000 SCREEN 1
1005 VDP(2)=6
1015
1020
1025
1030
1035
1040
1045
1050
1055
1060
1065
1070
Y=X
FOR B=0TO31
VPOKE(A+B),Y
Y=Y+1
NEXTB
X=X+1
NEXT
POKE (50000), 10
DEFUSR =40000
A=USR(1)
GOTO 1065
End address
Hex total
90
40600
40667
7249
6
7
8
3E08
1E0F
CD9300
3E07
1EFE
CD9300
3E00
1E6E
CD9300
3E01
1E00
CD9300
1E6E
3E00
CD9300
3EC8
F5
20
30
40
50
60
70
80
90
100
110
120
130
140
150 LOOP:
160
170
180 DELAY:
190
200 DEL:
3E0A
3D
C2C09E 210
220
3D
230
C2BD9E 240
7B
250
C606
260
CAD49E 270
3D
280
5F
290
C3B69E 300
3E07
310 END:
1EFF
320
CD9300 330
C9
340
FI
LD
LD
A,
E,15
CALL 147
LD
LD
CALL
LD
LD
CALL
LD
LD
CALL
LD
LD
CALL
LD
A,
E,254
147
A,0
E,1 10
147
A,1
E,0
147
E,1 10
A,0
147
A, 200
PUSH AF
LD
A, 10
DEC
JP
NZ.DEL
POP
DEC
AF
A
JP
LD
NZ, DELAY
A,E
ADD
A,
JP
Z,END
DEC
LD
JP
LD
LD
E,A
LOOP
A,
E,255
CALL 147
RET
7
87
Name:
Function:
40514
End address
Hex total
3E07
1EFE
CD9300
3E0fi
1E0F
CD9300
1E28
3E00
CD9300
3E0A
F5
3EFF
3D
C2EA9D
FI
3D
C2E79D
7B
D696
CAFF9D
C697
5F
C3E09D
3E00
1E00
CD9300
3E07
1EF7
CD9300
3E00
F5
5F
CD9300
3E32
F5
3EFF
3D
92
20
30
40
50
60
70
80
90 LOOP:
100
110
120 DELAY:
130
140 DEL:
150
160
170
180
190
200
210
220
230
240
250 NEXT:
260
270
280
290
300
310
320 NEXT 1:
330
340
350
360 STEVE:
370
380 TRACEY:
13909
LD
LD
A,
E,254
CALL 147
LD
LD
A,
E,15
CALL 147
LD
LD
E,40
A,0
CALL 147
LD
A, 10
PUSH AF
LD
A, 255
DEC
JP
NZ.DEL
POP
DEC
AF
A
JP
LD
NZ, DELAY
SUB
A.E
150
JP
Z.NEXT
ADD
A, 151
LD
E,A
JP
LD
LOOP
LD
CALL
LD
LD
CALL
LD
PUSH
LD
CALL
LD
PUSH
LD
DEC
E,0
A,0
147
A,
E,247
147
A.O
AF
E,A
147
A, 50
AF
A, 255
C2199E
JP
NZ, TRACEY
FI
POP
DEC
AF
A
JP
NZ, STEVE
POP
SUB
AF
JP
Z.LDEL
A, 32
NEXT1
390
400
3D
410
C2169E 420
FI
430
D61F
440
CA2D9E 450
460
C620
C30F9E 470
480LDEL:
3E64
490LDEL1:
F5
3EFF
500
510LDEL2:
3D
C2329E 520
530
FI
3D
540
C22F9E 550
3E07
560
1EFF
570
CD9300 580
C9
590
ADD
JP
31
LD
A. 100
PUSH AF
LD
A, 255
DEC A
JP
NZ.LDEL2
POP
DEC
AF
A
JP
LD
LD
NZ.LDEL1
A,
E.255
CALL 147
RET
APPENDICES
Appendices
1)
2)
3)
4)
Z80 OPCODES
97
Opcodes
ADC A, (HL)
ADC A, (IX +
ADC A, (IY +
ADC A, A
ADC A, B
ADC A, C
ADC A, D
ADC A, E
ADC A. H
ADC A, l
ADC A. n
ADC HL. BC
ADC HL, DE
ADC HL, HL
ADC HL, SP
ADD A, (HL)
ADD A, (IX +
ADD A, (IY +
ADD A, A
ADD A. B
ADD A. C
ADD A. D
ADD A, E
ADD A, H
ADD A, L
ADD A, n
ADD HL, BC
ADD HL, DE
ADD HL, HL
ADD HL, SP
ADD IX, BC
ADD IX, DE
ADD IX, IX
ADD IX, SP
ADD IY, BC
ADD IY, DE
ADD IY, IY
ADD IY, SP
8E
d)
d)
8F
88
89
8A
8B
8C
8D
CEn
ED4A
ED5A
ED6A
ED7A
86
d)
d)
AND(HL)
AND
AND
AND
AND
AND
AND
AND
AND
(IX
(IY
+
+
d)
d)
DD86d
FD86d
87
80
81
82
83
84
85
C6n
09
19
29
39
DD09
DD19
DD29
DD39
FD09
FD19
FD29
FD39
A6
DDA6d
FDA6d
A
B
A7
AO
C
D
A1
E
H
ANDL
AND
DD8Ed
FD8Ed
BIT 0. (HL)
BIT 0, (IX + D)
BIT 0, (IY + d)
A2
A3
A4
A5
E6n
CB46
DDCBd46
FDCBd46
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
0,
0,
CB47
CB40
0.
CB41
0,
0.
0,
CB42
CB43
CB44
CB45
CB4E
0,
1.
L
(HL)
1, (IX
1, (IY
1.
1.
1.
1,
1,
1,
2,
2, (IY
2,
2,
2,
2,
2,
2,
2,
3,
3,
3,
C
D
3,
3,
4,
CB52
CB53
CBM
CB55
CB5E
L
(HL)
3,
+
+
d)
d)
CB5A
CB5B
CB5C
CB5D
4, (IX
d)
4, (IY
d)
4,
4,
4,
4,
C
D
4,
4,
4,
5,
(HL)
5. (IY
5,
5,
A
B
5.
C
D
5,
5,
5.
DDCBd5E
FDCBd5E
CB5F
CB58
CB59
L
(HL)
5. (IX
CB56
DDCBd56
FDCBd56
CB57
CB50
CB51
E
H
3. (IY
3,
+ d)
+ d)
C
D
3, (IX
3.
CB4A
CB4B
CB4C
CB4D
L
(HL)
2, (IX
DDCBd4E
FDCBd4E
CB4F
CB48
CB49
C
D
1,
+ d)
+ d)
CB66
DDCBd66
FDCBd66
CB67
CB60
CB61
CB62
CB63
CB64
CB65
+ d)
+ D)
CB6E
DDCBd6E
FDCBd6E
CB6F
CB68
CB69
CB6A
CB6B
CB6C
BIT 5, L
BIT 6. (HL)
BIT 6, (IX 1- d)
BIT 6, (IY + d)
BIT 6. A
BIT 6. B
BIT 6. C
BIT 6, D
BIT 6, E
BIT 6. H
BIT 6, L
BIT 7, (HL)
BIT 7, (IX + d)
BIT 7, (IY + d)
BIT 7, A
BIT 7, B
BIT 7. C
BIT 7. D
BIT 7, E
BIT 7, H
BIT 7. L
CALL C, nn
CALL M, nn
CALL NC, nn
CALL nn
CALL NZ, nn
CALL P. nn
CALL PE, nn
CALL PO, nn
CALL Z, nn
CB6D
CB76
DDCBd76
FDCBd76
C877
C870
CB71
CB72
CB73
CB74
CB75
CB7E
DDCBd7E
FDCBd7E
CB7F
CB78
CB79
CB7A
CB7B
CB7C
CB7D
DCnn
FCnn
D4nn
CDnn
C4nn
d)
FD2B
2D
3B
lOd
DJNZ, d
FB
El
EX
EX
EX
HL
(SP),
(SP), IX
(SP), IY
BB
BC
BD
FEn
EDA9
EDB9
EDA1
EDB1
E3
DDE3
FDE3
EX AF, AF
EX DE. HL
EXX
HALT
08
IM 0
IM 1
ED46
ED56
ED5E
ED78
DBn
ED40
ED48
ED50
ED58
ED60
ED68
EB
D9
76
IM 2
IN A. (C)
IN A, (n)
IN B. (C)
IN C, (C)
IN D, (C)
INC (HL)
INC (IX +
INC (IY +
INC A
INC B
INC BC
INC C
INC D
INC DE
INC E
INC H
INC HL
INC IX
INC IY
INC L
INC SP
IND
BA
CPIR
F3
DD2B
IN L, (C)
B8
B9
CPI
Dl
2B
CCnn
BE
DDBEd
FDBEd
BF
+ d)
25
E4nn
CP
CP
(IX
ID
DEC H
DEC HL
DEC IX
DEC IY
DEC L
DEC SP
IN E, (C)
IN H, (C)
3F
CP (IY +
CP A
CP B
CP C
CP D
CP E
CP H
CP L
CP n
CPD
CPDR
IB
DECE
ECnn
F4nn
CCF
(HL)
DEC DE
34
d)
d)
DD34d
FD34d
3C
04
03
OC
14
13
1C
24
23
DD23
FD23
2C
33
EDAA
EDBA
EDA2
CPL
DAA
2F
INDR
27
INI
DEC (HL)
DEC (IX +
DEC (IY +
DEC A
DEC B
DEC BC
DEC C
DEC D
35
INIR
JP (HL)
EDB2
JP
JP
(IX)
DDE9
(IY)
100
d)
d)
DD35d
FD35d
3D
E9
05
JP C, nn
FDE9
DAnn
OB
JP M, nn
JP NC, nn
JP nn
C3nn
OD
15
FAnn
D2nn
JP NZ, nn
JP P, nn
JP PE, nn
JP PO, nn
JP Z, nn
C2nn
LD
F2nn
JR
38d
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
EAnn
E2nn
CAnn
C, d
JR, d
18d
30d
20d
28d
02
JR NC, d
JR NZ, d
JR Z. d
LD (BC). A
LD (DE), A
LD (HL), A
LD (HL), B
LD (HL), C
LD (HL). D
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
(HL).
(HL),
12
77
70
71
72
73
74
(HL), L
(HL), n
(IX
(IX
+
+
(IX
d),
d).
(IX
+
+
+
(IX
(IX
(IX
+
+
(IY
d).
C
D
d),
d),
d).
d),
L
n
d),
d),
+
+
(IX
A
B
d),
(IY
d),
(IY
+
+
+
+
+
d),
d),
d),
d),
d),
(IY
(IY
(IY
(IY
(IY
(nn),
(nn),
BC
(nn),
DE
(nn),
HL
(nn). IX
(nn), IY
(nn),
SP
(BC)
A, (DE)
A,
DD7Ed
FD7Ed
A,
A,
A,
A,
B, (IY
B,
B.
3Ann
7F
78
79
7A
7B
7C
ED57
d)
d)
A
B
B,
C
D
B,
B,
B,
40
41
42
43
44
45
06n
B. L
B, n
B,
B,
C
C
DD46d
FD46d
47
(nn)
ED4Bnn
nn
01 nn
C, (HL)
C, (IX + d)
C, (IY + d)
C, A
C. B
C. C
C. D
LD
LD
FD74d
FD75d
FD36dn
32nn
ED43nn
ED53nn
22nn
DD22nn
FD22nn
ED73nn
OA
46
+
+
LD
LD
LD C. E
LD C, H
LD C. L
LD C, n
LD D, (HL)
LD D. (IX +
LD D. (IY +
LD D. A
LD D. B
LD D, C
LD D, D
LDD. E
LD D. H
LD D, L
LD D, n
LD DE, (nn)
LD DE. nn
LD E, (HL)
LD E, (IX +
LD E, (IY +
LD E, A
LD E, B
LD E, C
LD E. D
LD E, E
LD E, H
LD E. L
LD E, n
LD H. (HL)
LD H, (IX +
LD H, (IY +
LD H, A
LD H, B
LD H. C
7E
A.
B, (IX
DD77d
DD70d
DD71d
DD72d
DD73d
DD74d
DD75d
DD36dn
FD77d
FD70d
FD71d
FD72d
FD73d
A, (IX + d)
A, (IY + d)
A, (nn)
A, A
3En
B. (HL)
75
36n
A, (HL)
A,
7D
A, L
A, n
4E
DD4Ed
FD4Ed
4F
48
49
4A
4B
4C
4D
OEn
56
d)
d)
DD56d
FD56d
57
50
51
52
53
54
55
16n
ED58nn
linn
5E
d)
DD5Ed
d)
FD5Ed
5F
58
59
5A
5B
5C
5D
1En
66
d)
d)
DD66d
FF66d
67
60
61
101
LD
LD
LD
LD
LD
LD
H.
H,
H. H
H, L
H, n
HL, (nn)
ED47
DD2Ann
1,
LD
LD
LD
LD
LD
LD
LD
LD
LD
LD
IX, (nn)
LD
DD21nn
FD2Ann
FD21nn
6E
nn
IX,
IY, (nn)
nn
IY,
65
26n
2Ann
21 nn
LD HL, nn
LD A
L,
(HL)
L,
(IX
L,
(IY
L,
6F
L,
L,
68
69
L.
L.
L,
LD
LD
LD
LD
LD
LD
+ d)
+ d)
DD6Ed
FD6Ed
6A
6B
L,
6C
6D
L.
2En
L
n
SP, (nn)
SP, HL
SP. IX
LD
LD SP,
ED7Bnn
F9
DDF9
FDF9
IY
LD SP, nn
LDD
31 nn
LDDR
EDA8
EDB8
LDI
EDAO
LDIR
EDBO
NEG
NOP
ED44
OR (HL)
OR (IX +
OR (IY +
OR A
OR B
00
B6
d)
d)
DDB6d
FDB6d
B7
BO
ORC
B1
OR D
OR E
OR H
OR L
OR n
OTDR
B2
OTIR
OUT (C), A
OUT (C), B
OUT (C), C
OUT (C), D
OUT (C), E
OUT (C). H
OUT (C), L
OUT (n). A
OUTD
102
B3
B4
B5
F6n
EDBB
EDB3
ED79
ED41
ED49
ED51
ED59
ED61
ED69
D3n
EDAB
EDA3
OUTI
62
63
64
K.
FI
POPAF
Cl
POP BC
D1
POP DE
El
POP HL
POP IX
DDE1
FDE1
POP IY
F5
AF
PUSH
PUSH BC
C5
D5
PUSH OE
E5
PUSH HL
DDE5
PUSH IX
FDE5
PUSH IY
CB86
RES 0, (HL)
RES 0, (IX + d) DDCBd86
RES 0, (IY + d) FDCBd86
CB87
RES 0. A
CB80
RES 0, B
CB81
RES 0, C
CB82
RES 0, D
CB83
RES 0, E
CB84
RES 0, H
CB85
RES 0, L
CB8E
RES 1. (HL)
RES 1. (IX d) DDCBd8E
RES 1. (IY + d) FDCBd8E
CB8F
RES 1, A
CB88
RES 1, B
CB89
RES 1, C
CB8A
RES 1, D
CB8B
RES 1, E
CB8C
RES 1. H
CB8D
RES 1, L
CB96
RES 2, (HL)
RES 2, (IX + d) DDCBd96
RES 2, (IY + d) FDCBd96
CB97
RES 2. A
CB90
RES 2, B
CB91
RES 2. C
CB92
RES 2, D
CB93
RES 2. E
CB94
RES 2, H
CB95
RES 2, L
CB9E
RES 3. (HL)
+
RES 3, (IX d) DDCBd9E
(IY
+
d)
FDCBd9E
RES 3,
CB9F
RES 3. A
CB98
RES 3, B
CB99
RES 3, C
CB9A
RES 3, D
CB9B
RES 3. E
CB9C
RES 3, H
CB9D
RES 3, L
CBA6
RES 4, (HL)
RES 4, (IX + d) DDCBdA6
RES 4, (IY + d) FDCBdA6
-t-
RES 4, A
RES 4, B
RES 4, C
RES 4, D
RES 4, E
RES 4, H
RES 4. L
RES 5, (HL)
RES 5, (IX +
RES 5. (IY +
RES 5, A
RES 5, B
RES 5. C
RES 5. D
RES 5, E
RES 5, H
RES 5. L
RES 6. (HL)
RES 6, (IX +
RES 6, (IY +
RES 6, A
RES 6, B
RES 6. C
RES 6. D
RES 6, E
RES 6, H
RES 6, L
RES 7, (HL)
RES 7, (IX +
RES 7, (IY +
RES 7, A
RES 7, B
RES 7, C
RES 7, D
RES 7, E
RES 7, H
RES 7, L
RET
RET C
RET M
RET NC
RET NZ
RET P
RET PE
RET PO
RETZ
d)
RL H
CBA1
RLA
RLC (HL)
RLC (IX +
RLC (IY +
RLC A
RLC B
RLC C
RLC D
RLC E
RLC H
RLC L
RLCA
RLD
CBA2
CBA3
CBA4
CBA5
CBAE
DDCBdAE
FDCBdAE
C8AF
CBA8
CBA9
CBAA
CBAB
CBAC
CBAD
d)
d)
CBB6
DDCBdB6
FDCBdB6
CBB7
CBBO
CBB1
d)
d)
CBB2
CBB3
CBB4
CBB5
CBBE
DDCBdBE
FDCBdBE
CBBF
CBB8
CBB9
CBBA
CBBB
CBBC
CBBD
C9
D8
07
ED6F
CB1E
DDC8d1E
FDCBdIE
CB1F
CB18
CB19
CB1A
CB1B
CB1C
CB1D
RR (HL)
RR (IX + d)
RR (IY + d)
RR A
RR B
RR C
RR D
RR E
RR H
RR L
RRA
RRC (HL)
RRC (IX +
RRC (IY +
RRC A
RRC B
RRC C
RRC D
RRC E
RRC H
RRC L
RRC A
RRD
RST 0
IF
CBOE
DDCBdOE
FDCBdOE
CBOF
d)
d)
CB08
CB09
CBOA
CBOB
CBOC
CBOD
OF
ED67
C7
FF
RST
SBC
SBC
SBC
SBC
SBC
CF
CB12
CB13
CB02
CB03
CB04
CB05
RST38H
d)
CBOI
EO
FO
CB11
d)
d)
d)
E8
CO
RL (HL)
RL (IX +
RL (IY +
RL A
17
CB06
DDCBd06
FDCBd06
CB07
CBOO
D7
DO
RETN
CB14
CB15
RL L
RSTIOH
RST 18H
RST 20H
RST 28H
RST 30H
F8
C8
ED4D
ED45
CB16
DDCBd16
FDCBd16
CB17
CB10
RETI
RL
RL
RL
RL
d)
CBA7
CBAO
OF
E7
EF
F7
9E
A. (HL)
A, (IX + d)
A, (IY
A. A
A.
SBC A, C
SBC A, D
SBC A. E
SBC A, H
SBC A. L
d)
DD9Ed
FD9Ed
9F
98
99
9A
9B
9C
9D
A
C
D
H
SBC A, n
SBC HL. BC
SBC HL, DE
SBC HL, HL
SBC HL, SP
SCF
DEn
ED42
ED52
ED62
ED72
37
CBC6
SET 0, (HL)
SET 0, (IX + d) DDCBdC6
SET 0, (IY + d) FDCBdC6
CBC7
SET 0, A
CBCO
SET 0, B
CBC1
SET 0, C
CBC2
SET 0, D
CBC3
SET 0, E
CBC4
SET 0, H
CBC5
SET 0, L
CBCE
SET 1, (HL)
SET 1, (IX + d) DDCBdCE
SET 1, (IY + d) FDCBdCE
CBCF
SET 1
CBC8
SET 1. B
CBC9
SET 1
CBCA
SET 1
CBCB
1.
E
SET
CBCC
SET 1
CBCD
SET 1, L
CBD6
SET 2, (HL)
SET 2. (IX + d) DDCBdD6
SET 2. (IY + d) FDCBdD6
CBD7
SET 2, A
CBDO
SET 2, B
CBD1
SET 2, C
CBD2
SET 2, D
CBD3
SET 2. E
CBD4
SET 2, H
CBD5
SET 2. L
CBDE
SET 3, (HL)
SET 3, (IX + d) DDCBdDE
SET 3, (IY + d) FDCBdDE
CBDF
SET 3, A
CBD8
SET 3, B
CBD9
SET 3, C
CBDA
SET 3, 0
CBDB
SET 3, E
CBDC
SET 3, H
CBDD
SET 3, L
CBE6
SET 4, (HL)
+
SET 4, (IX d) DDCbE6
SET 4, (IY + d) FDCBdE6
CBE7
SET 4, A
CBEO
SET 4, B
CBE1
SET 4, C
CBE2
SET 4. D
CBE2
SET 4, E
CBE4
SET 4, H
CBE5
SET 4, L
,
104
SET 5. (HL)
SET 5. (IX + d)
SET 5, (IY + d)
SET 5, A
SET 5, B
SET 5, C
SET 5, D
SET 5, E
SET 5. H
SET 5, L
SET 6, (HL)
SET 6. (IX + d)
SET 6, (IY + d)
SET 6, A
SET 6, B
SET 6, C
SET 6. D
SET 6. E
SET 6, H
SET 6. L
SET 7, (HL)
SET 7. (IX + d)
SET 7, (IY + d)
SET 7. A
SET 7, B
SET 7, C
SET 7, D
SET 7. E
SET 7, H
SET 7. L
SLA (HL)
SLA (IX + d)
SLA (IY + d)
SLA A
SLAB
SLA C
SLAD
SRL (HL)
SRL (IX +
SRL (IY +
SRL A
SRL B
SRL C
CBEC
CBED
CBF6
DDCBdF6
FDCBdF6
CBF7
CBFO
CBF1
CBF2
CBF3
CBF4
CBF5
CBFE
DDCBdFE
FDCBdFE
CBFF
CBF8
CBF9
CBFA
CBFB
CBFC
CBFD
CB26
DDCBd26
FDCBd26
CB27
CB20
CB21
SLA E
SLA H
SLAL
SRA (HL)
SRA (IX +
SRA (IY +
SRA A
SRA B
SRA C
SRA 0
SRA E
SRA H
SRA L
CBEE
DDCBdEE
FDCBdEE
CBEF
CBE8
CBE9
CBEA
CBEB
d)
d)
d)
d)
CB22
CB23
CB24
CB25
CB2E
DDCBd2E
FDCBd2E
CB2F
CB28
CB29
CB2A
CB2B
CB2C
CB2D
CB3E
DDCBd3E
FDCBd3E
CB3F
CB38
CB39
CB3A
CB3B
CB3C
CB3D
SRL D
SRLE
SRL H
SRL L
SUB (HL)
SUB (IX +
SUB (IY +
SUB A
SUB B
SUB C
SUB D
SUB E
SUB H
96
d)
d)
DD96d
FD96d
97
90
91
92
93
94
SUB L
SUB n
XOR (HL)
XOR (IX +
XOR (IY +
XOR A
XOR B
XOR C
XOR D
XOR E
XOR H
XOR L
XOR n
95
D6n
d)
d)
AE
DDAEd
FDAEd
AF
A8
A9
AA
AB
AC
AD
EEn
10
11
12
13
14
15
16
17
16
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
36
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
56
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
60
81
82
83
84
85
86
87
88
69
90
91
92
93
94
95
111
96
97
98
99
100
101
102
103
104
10S
106
107
108
109
110
112
113
114
115
116
117
118
119
120
121
122
123
124
12S
126
127
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
145
146
147
148
149
150
151
152
153
154
155
156
157
58
159
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
177
178
179
180
181
182
163
84
IBS
186
187
188
189
190
191
207
176
193
194
195
196
197
198
199
200
201
202
203
204
205
206
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
107
Binary
time that you have encountered Binary you
it slightly confusing. It may even put you off
wanting to learn Machine Code, and I certainly wouldnt want
that to happen. Let me stress thatyou do not need to understand
Binary in order to write Machine Code programs. In the section
on storing numbers, you will have learnt that each memory
location can hold a number between 0 and 255. We refer to these
numbers as bytes. Each byte is divided into eight parts, known
as bits; these are numbered in the following way:
If this is
the
first
Eight bits
|7~T6l5l4 13 2
1
Bit
values
Bit
numbers
128 64 32 16 18
5 4
3
JUA
4 r2
109
1,
the byte?
it out.)
how
to calculate this,
but see
if
Character/Sprite Designer
The following program
Remember,
MODE
Start address
40000
40702
85482
End address
Hex total
011800
11F803
215F9D
CD5C00
3E01
32E3D6
32E8D6
32E9D6
210218
22E6D6
21A08C
22E4D6
3E80
32E2D6
21D8D6
22E0D6
CD849D
CD909D
3E7F
210218
CD4D00
3E31
210C18
CD4D00
3E30
210B18
CD4D00
3E30
210A18
CD4D00
CD779D
3E82
110 START:
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
LD
BC.24
LD
DE. 01
LD
HL.IXSTR
CALL
LD
LD
(CURCHR),A
LD
(VER).A
LD
(HOR),A
LD
HL,6146
LD
(CURSOR), HL
LD
HL,SETSTR
LD
(CHRADD).HL
LD
LD
(CHBIT),A
LD
HL.GRID
LD
(BYTELHL
CALL CHRGRD
CALL DISCH
LD
A, 127
LD
HL.6146
CALL 77
/
LD
A, 49
LD
HL.6156
CALL 77
LD
A, 48
LD
HL.6155
CALL 77
LD
A, 48
LD
HL.6154
CALL 77
CALL RAM2V
LD
A, 130
1
'
i/fc
rr
111
A
9
A
48
7
218B18
CD4D00
00
3E07
CD4101
CB57
C8
3E08
CD4101
CB47
CAEC9D
CB7F
CA3D9D
CB77
CAFB9C
CB6F
CAD89C
CB67
CA1F9D
3E04
CD4101
CB6F
CA8B9E
CB5F
CA329E
C39F9C
3AE8D6
3D
CA9F9C
32E8D6
2AE0D6
2B
22E0D6
2AE6D6
012000
A7
ED42
22E6D6
CD909D
C39F9C
3AE8D6
,D608
CA9F9C
C609
32E8D6
2AE0D6
'
23
22E0D6
2AE6D6
012000
430
440
450 LOOP:
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690 CUP:
700
710
720
730
740
750
760
770
780
790
800
810
820
LD
HL.6283
CALL 77
Bi\iR
s-/
NOP
LD
A,
CALL 321
BIT
2,
RET Z
LD
A,
CALL 321
BIT
O.A
JP
Z, SWITCH
BIT
7.
JP
Z, RIGHT
BIT
6,
JP
Z.CDOWN
BIT
5,
JP
Z.CUP
BIT
4,
JP
LD
Z,LEFT
A,
CALL 321
BIT
5,
JP
Z.PREV
BIT
3,
JP
JP
LD
Z.NEXT
DEC
A
Z.LOOP
JP
LD
LD
5 Hi
*-t
/>
LOOP
A.(VER)
(VER),A
HL,(BYTE)
DEC
HL
LD
LD
LD
(BYTE),HL
AND
SBC
A
HL.BC
LD
(CURSOR), HL
HL, (CURSOR)
BC.32
CALL DISCH
JP
LOOP
830CDOWN:
LD
A.(VER)
840
850
860
870
880
890
900
910
920
SUB
JP
Z.LOOP
ADD
A,
LD
LD
(VERj.A
HL.(BYTE)
INC
HL
LD
LD
LD
(BYTE),HL
HL, (CURSOR)
BC,32
112
A98
09
22E6D6
CD909D
C39F9C
3AE9D6
3D
CA9F9C
32E9D6
3AE2D6
87
32E2D6
2AE6D6
2B
22E6D6
CD909D
C39F9C
3AE9D6
D608
CA9F9C
C609
32E9D6
3AE2D6
CBOF
32E2D6
2AE6D6
23
22E6D6
CD909D
C39F9C
FFC3A599
99A5C3FF
FF81BDBD
BDBD81FF
FF818181
818181FF
010800
111004
2AE4D6
CD5C00
C9
010800
11D8D6
2AE4D6
EDBO
C9
210218
11D8D6
3E08
F5
1A
930
940
950
960
970 LEFT:
980
990
1000
1010
1020
1030
1040
1050
1060
1070
1080
1090 RIGHT:
1100
1110
1120
1130
1140
1150
1160
1170
1180
1190
1200
1210
1220 IXSTR:
1330
1240
1250
1260
1270
1280RAM2V:
1290
1300
1310
1320
ADD HL.BC
(CURSOR), HL
LD
CALL DISCH
JP
LOOP
LD
DEC
A,(HOR)
JP
LD
(HOR),A
LD
A,(CHBIT)
ADD
A,
LD
LD
(CHBIT),A
HL, (CURSOR)
DEC
HL
LD
CALL
JP
LD
(CURSOR), HL
DISCH
SUB
JP
Z.LOOP
ADD
A.
LD
LD
(HOR
LOOP
A,(HOR)
,A
A,(CHBIT)
RRC
A
(CHBITLA
HL, (CURSOR)
HL
INC
(CURSOR), HL
LD
CALL DISCH
LD
LD
JP
LOOP
DEFB
DEFB
DEFB
DEFB
DEFB
DEFB
255,195,165,153
153,165.195,255
255,129,189,189
189,189,129,255
255,129,129,129
129,129,129,255
BC,8
DE.1040
HL.(CHRADD)
LD
CALL 92
RET
1330CHRGRD LD
1340
1350
1360
1370
1380 DISCH:
1390
1400
1410 DISCH1
1420
A
Z.LOOP
LD
LD
BC,8
DE.GRID
HL.(CHRADD)
LDIR
RET
LD
LD
LD
HL.6146
DE.GRID
A,
PUSH AF
LD
A,(DE)
113
CB7F
CDDB9D
CB77
CDDB9D
CB6F
CDDB9D
CB67
CDDB9D
CB5F
CDDB9D
CB57
CDDB9D
CB4F
CDDB9D
CB47
CDDB9D
13
011800
09
FI
3D
C2989D
CD779D
3E7F
2AE6D6
CD4D00
CDE39E
C9
F5
CAE49D
3E80
C3E69D
3E81
CD4D00
FI
23
C9
)
00
2AE0D6
7E
47
3AE2D6
4F
3E01
CB79
C2059E
CBOO
CB01
3C
C3F89D
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710 BIT:
1720
1730
1740
1750BIT1:
1760BIT2:
1770
1780
1790
1800 SWITCH
1810
1820
1830
1840
1850
1860
1870SWIT1:
1880
1890
1900
1910
1920
BIT
7, A
CALL
BIT
BIT
6,
CALL
BIT
BIT
5,
CALL
BIT
A
A
4, A
CALL BIT
BIT
3, A
CALL BIT
BIT
2, A
CALL BIT
BIT
CALL
1,A
BIT
0,A
BIT
INC
DE
LD
BC,24
HL.BC
BIT
CALL
BIT
ADD
POP
DEC
AF
A
JP
NZ,DISCH1
CALL
LD
LD
CALL
CALL
RET
PUSH
RAM2V
JP
LD
JP
Z,BIT1
A, 128
A, 127
HL, (CURSOR)
77
DELAY
AF
BIT2
A, 129
LD
CALL 77
POP AF
INC
HL
RET
NOP
LD
LD
LD
LD
LD
LD
HL.IBYTE)
BIT
7,C
JP
NZ.SWIT2
B
RLC
RLC
A,(HL)
B,A
A,(CHBIT)
C,A
A,1
INC
C
A
JP
SWIT1
A8
CB78
CA0F9E
CBB8
C3119E
CBFF
3D
CA1A9E
CB08
C3119E
78
77
CDF29E
CD909D
CDE39E
3E08
CD4101
CB47
CA229E
C39F9C
00
3AE3D6
D67E
CA9F9C
C67F
32E3D6
2AE4D6
010800
09
22E4D6
CD849D
CD909D
210C18
CD4A00
D639
CA639E
C63A
CD4D00
C39F9C
3E30
CD4D00
210B18
CD4A00
D639
CA7B9E
C63A
CD4D00
C39F9C
3E30
CD4D00
210A18
1930 SWIT2:
1940
1950
1960
1970 SWIT3:
1980SWIT4:
1990
2000
2010
2020 SWIT5:
2030
2040
2050
2060 WAIT:
2070
2080
2090
2100
2110
21 20 NEXT:
2130
2140
2150
2160
2170
2180
2190
2200
2210
2220
2230
2240
k
f
2250
2260
2270
2280
2290
2300
2310NEXT1:
2320
2330
2340
2350
2360
2370
2380
2390
2400NEXT2:
2410
2420
BIT
7,B
JP
Z.SWIT3
RES
7,B
JP
SET
SWIT4
DEC
JP
Z.SWIT5
RRC
JP
SWIT4
LD
LD
CALL
CALL
CALL
LD
CALL
A,B
BIT
JP
JP
7,
(HL),A
GRDCHR
DISCH
DELAY
A,
321
O.A
Z.WAIT
LOOP
NOP
LD
A.(CURCHR)
SUB
126
JP
Z,LOOP
ADD
A, 127
LD
LD
LD
(CURCHR),A
HL.(CHRADD)
BC,8
ADD HL.BC
LD
CALL
CALL
LD
CALL
(CHRADD),HL
CHRGRD
DISCH
HL.6156
Kpi
74
57
JP
Z.NEXT1
ADD A, 58
WtH
CALL 77
LOOP
JP
LD
A,48
viLTxjiirr
CALL 77
LD
HL.6155
ppvnv
CALL 74
SUB 57
Z.NEXT2
JP
ADD A, 58
*jrz-ri/K<7
CALL 77
JP
LOOP
LD
A, 48
vrttTV/W
CALL 77
LD
HL.6154
SUB
115
3E31
CD4D00
C39F9C
00
3AE3D6
3D
CA9F9C
32E3D6
2AE4D6
010800
A7
ED42
22E4D6
CD849D
CD909D
210C18
CD4A00
D630
CABB9E
C62F
CD4D00
C39F9C
3E39
CD4D00
21 OBI 8
CD4A00
D630
CAD39E
C62F
CD4D00
C39F9C
3E39
CD4D00
210A18
3E30
CD4D00
C39F9C
3E32
F5
3EFF
3D
C2E89E
FI
3D
C2E59E
C9
010800
2430
2440
2450
2460 PREV:
2470
2480
2490
2500
2510
2520
2530
2540
2550
2560
2570
2580
2590
2600
2610
2620
2630
2640
2650 PREV1:
2660
2670
2680
2690
2700
2710
2720
2730
2740 PREV2:
2750
2760
2770
2780
2790
2800 DELAY:
2810 DEL:
2820
2830 DELI:
2840
2850
2860
2870
2880
A, 49
LD
CALL 77
JP
LOOP
NOP
A,(CURCHR)
A
Z.LOOP
(CURCHR).A
HL.(CHRADD)
BC,8
CALL
HL.BC
(CHRADD).HL
.
CHRGRD
CALL DISCH
HL.6156
LD
CALL 74
CDViiiqi
SUB
48
Z,PREV1
JP
ADD A, 47
CALL 77
LOOP
JP
A, 57
LD
CALL 77
HL,6155
LD
CALL 74
SUB 48
Z,PREV2
JP
ADD A, 47
CALL 77
LOOP
JP
LD
A, 57
CALL 77
HL.6154
LD
A, 48
LD
CALL 77
LOOP
JP
A, 50
LD
PUSH AF
LD
A,255
DEC
JP
NZ.DEL1
AF
POP
DEC
NZ.DEL
RET
BC,8
2890GRDCHR LD
DE,(CHR
LD
ED5BE4D6 2900
HL.GRID
LD
2910
21D8D6
LDIR
2920
EDBO
RET
2930
C9
JP
verm
Having entered the program and checked it, you can SAVE it
on tape using:
tested by entering
following lines:
1000DEFUSR = 40000
1005 A = USR(1)
1.
3)
the cassettes
I
will
now
is
damaged.
own
characters:
Type in:
Type in:
1)
2)
CLEAR 200,35999
BLOADCAS:
BLOADCAS:"
4)
6)
Press ESC.
Save your character set on tape using:
7)
in
this is as follows:
1)
2)
3)
CLEAR 200,35999
Type in:
SCREEN 1
Type in:
Load your character set using:
BLOADCAS:'
The 126 characters are now in RAM; however, to be of any use
they need to be moved into VRAM. The following BASIC
program will transfer the characters into VRAM:
10FOR A
0TO2007
20 VPOKE(CHARST ART +
30 NEXT
40 STOP
A),
PEEK (36000 +
A)
position
character set.
will
show that
all
your
VRAM:
10FORA= 126T0251
20 VPOKE (SCREENSTART +
30 NEXT
40 STOP
A),
CLEAR 200,35999
Load the character designer using:
BLOADCAS:
119
A
3)
1000DEF USR
40000
1005 A = USR(1)
4)
5) Press
6)
Type RUN.
8)
9)
Press ESC.
Save the characters on tape using the following:
10)
3)
When you wish to use the 252 characters in your program you
must do the following:
CLEAR 200,35999
BLOAD CAS:SET 1
1)
2)
10FORA = 0TO2007
20 VPOKE(CH ARST ART + A +
30 NEXT
40 STOP
1ft08), PEEK
(36000 + A)
into
positions in
4)
5)
BLOADCAS:SET2
Change line 20 of the above BASIC program to:
20 VPOKE(CHARST ART + A), PEEK (A + 36000)
Now
6)
type
RUN. This
positions in
VRAM
where
Having done this you may find that what is on the screen is
very difficult to read, unless you actually designed some
letters and numbers in the correct positions in character
set 2.
Obviously,
120
if you
program.
SPRITE DESIGNER
The character designer can also be used to design the shapes of
sprites. The following procedure will show you how to design
the shapes of 32 sprites:
CLEAR 200,35999
1)
2)
BLOADCAS:
3)
5) Press ESC.
3)
6) Save the 32 sprite shapes on tape
When you wish to use the sprite shapes follow this procedure:
CLEAR 200,35999
1)
2)
BLOAD CAS:SP32
The
position in
now
A),
PEEK (A + 36000)
30 NEXT
40 STOP
Now you can VPOKE some of the sprite variables and try to
make the sprites appear on screen.
121
Authors Note
I hope that I have now achieved what I set out to do, which was to
give you a gentle introduction into the world of Machine Code
programming. You should havediscovered by now whetheryou
and Machine Code make suitable partners. There are many
Z80 opcodes which I have not covered in this book; should you
wish to learn about them there are a few books available which
cover the subject of Z80 opcodes in great detail. When you begin
writingyour own Machine Code programsyou may come across
a few problems which you are unable to sol ve. Ifyou write to me
via the publishers of this book then I will be pleased to try and
help you (but I wont reply if you dont enclose a stamped
addressed envelope!) Please do not write to me with such letters
as I have found a faster way of creating the explosion in the
Any such
letters will
be passed
Steve Webb
61-63 Portobello Road
London Wll
January 1985
123
Answers
1)
is 1 78,
125
PRACTICAL
MACHINE
ID
EJ
LCILO
M M N G
P R O G R
-c
sprites