home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 18
/
018.d81
/
t.sprites.128
< prev
next >
Wrap
Text File
|
2022-08-26
|
5KB
|
305 lines
128 SPRITES AND UTILITIES
*************************
Written by: Louis F. Sander
Microcomputers Magazine, December 1985
Page 46
In the 128, the memory locations
from 3584-4095 are reserved for eight
sprites, each using 64 bytes. These
locations hold only the shape of the
sprites; other attributes are
separately controlled by BASIC's
SPRITE statement. The eight sprites
are located as follows:
Sprite Decimal Hexidecimal
====== ========= ===========
1 3584-3647 $0E00-$0E3F
2 3648-3711 $0E40-$0E7F
3 3712-3775 $0E80-$0EBF
4 3776-3839 $0EC0-$0EFF
5 3840-3903 $0F00-$0F3F
6 3904-3967 $0F40-$0F7F
7 3968-4031 $0F80-$0FBF
8 4032-4095 $0FC0-$0FFF
Regardless of what is in the sprite
memory, the 128 treats it as a
sprite; therefore, it is up to you to
know which sprite has meaning. To see
what's in the sprite area at power
up, enter:
FORJ=1TO8:SPRITEJ,1,2
MOVSPRJ,35*J,200:NEXT [RETURN]
You have just made all eight sprites
white and printed them on the bottom
of the screen. Their shapes are
determined by whatever was in their
locations at the 128's power up. To
make them into squares, enter:
FORJ=3584TO4095
POKEJ,255:NEXT [RETURN]
SAVING AND LOADING SPRITES
======================================
To save and load sprites to and from
disk, use the BSAVE and BLOAD
commands. To save your squares to
disk, enter:
BSAVE"SQUARES.SPR",B0,P3584
TO P4096 [RETURN]
Be sure to type it as shown; one of
the examples in your system guide
contains an error. Use the .SPR to
identify sprite files in the
directory. This identification is
important, because sprite files must
be BLOADed and not DLOADed which
causes them to crash.
CONTROLLING THE SPRITES
======================================
To turn your sprites on, use:
SPRITEx,1,z where x specifies the
sprite you are controlling and z is a
number from 1 to 16, corresponding to
the color you want the sprite to be.
To turn off your sprite, enter:
SPRITEx,0 where x specifies the
sprite you wish to turn off.
To move your sprite around, use the
MOVSPR statement. Since this
statement is complex, we will not
discuss it here. Refer to section 17
of your manual.
CREATING SPRITES
======================================
To design your own sprites, you have
three options:
1. Use SPRDEF, the built-in sprite
editor program.
2. Use the 128's high-resolution
graphics commands to create a
design on the screen, then use
the SSHAPE and SPRSAV commands
to turn it into a sprite.
3. Use the tried and true methods
that work with the 64.
For a detailed description of SPRDEF
study pages 116-119 and page 293 in
your system guide. Keep in mind that
when SPRDEF says "saving" sprites, it
means storing them in memory.
Pages 109-116 give examples of using
SSHAPE and SPRSAV, both are also
explained in section 17. However, in
these lines there is a minor bug that
causes the sprites to keep moving
even after you hit STOP/RESTORE. To
improve this program add these
lines:
6 COLOR 1,8 : TRAP99
96 MOVSPR 1,0#0 : SPRITE 1,0
97 MOVSPR 2,0#0 : SPRITE 2,0
For the 64 method, it is best to
study the 64's Programmer's Reference
Guide, plus the many articles that
have been written on sprites.
UTILITIES
======================================
On Side 2 of this LOADSTRAR disk,
there are five useful tools for
managing your sprites. They are:
SPRITESEER.128; NUMBERS.BAS.128;
SPRITESAVER.128; HBARMULTI.128; and
VBARMULTI.128.
SPRITESEER.128 displays stationary
sprites on the bottom of the screen
and allows you to manipulate their
attributes. At the top of the screen,
the program prints line 110, followed
by a line containing "RUN". On line
110, set E=1 to expand the sprites in
the X and Y directions. To make them
multicolor, set M=1. If you want all
sprites to have the same color, then
change the third argument in the
SPRITE statement, on line 120, to
that color.
NUMBER.BAS.128 makes and BSAVEs
sprites that are labeled with their
numbers. Very useful for testing
purposes.
SPRITESAVER.128 lets you BSAVE all
the sprites, one sprite, or a
selected group of sprites. You answer
the prompts to specify which sprite
or group of sprites.
HBARMULTI.128 creates and saves
sprites which, in Multicolor mode,
appear as flags with horizontal bars
in three colors: sprite color;
Multicolor 1; and Multicolor 2. If
you are familiar with the literature
on sprites then you will understand
the use for such a tool. If not, I
urge you to delve into it.
VBARMULTI.128 does similiar to
HBARMULTI.128 except that the bars
are vertical instead of horizontal.
In both of these programs, if you are
in single-color mode these sprites
will have quite a different
appearance.
This program is copyrighted by
Commodore magazine. All rights to it
are reserved. LOADSTAR has relieved
you from the burden of keying in this
program. For more complete
information about this program, refer
to the December 1985 issue of
Microcomputers Magazine.
>Files used: SPRITESEER.128
NUMBER.BAS.128
SPRITESAVER.128
HBARMULTI.128
VBARMULTI.128
---------< end of article >-----------