EasyManua.ls Logo

Commodore Amiga - Page 122

Commodore Amiga
321 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
You must take care
that
you are not moving the sprite
(that
is, changing control word
data)
at
the same time
that
the system
is
using tha.t
data
to
find
out
where
to
display
the object.
If
you do so, the system might
find
the
start
position for one
field
and the
stop position for the following
field
as
it
retrieves
data
for display. This would cause a
"glitch" and would mess up the screen. Therefore, you should change the content of the
control words only during a time when the system is not trying
to
read them. Usually,
the vertical blanking period is a safe time, so moving the sprites becomes
part
of the
vertical blanking tasks and is handled by the Copper as shown
in
the example below .
.As
sprites move about
on
the screen, they can collide with each other or with either of
the two playfields.
You
can
use
the hardware to detect these collisions and exploit this
capability for special effects. In addition, you can
use
collision detection to keep a
mov-
ing object within specified on-screen boundaries. Collision is described
in
chapter
7,
"System Control Hardware."
In this example of moving a sprite, the spaceship is bounced around on the screen,
changing direction whenever it reaches an edge.
The
sprite position data, containing VSTART and HSTART, lives
in
memory
at
$25000.
VSTOP
is
located
at
$25002.
You
write to these locations
to
move the sprite. Once
during each frame, VSTART
is
incremented (or decremented)
by
1 and HSTART by
2.
Then a
new
VSTOP
is
calculated, which will
be
the new VSTART +
6.
,
MOVE.B #151,DO
MOVE.B #194,Dl
MOVE.B #64,D2
MOVE.B #44,D3
MOVE.B #1,D4
MOVE.B #1,D5
jlnitialize horizontal count
jlnitialize vertical count
jlnitialize horizontal position
jlnitialize vertical position
jlnitialize horizontal increment value
jlnitialize vertical increment value
jHere
we
wait for the vertical blanking bit in
INTREQR
to turn on.
j This ensures a glitch-free display.
VLOOP:
MOVE.W CUSTOM+INTREQR,D6
AND.W #$0020,D6
jRead interrupt request word
jMask
off
all but vertical blank bit
jLoop until bit is a 1
BEQ VLOOP
MOVE.W #$OO20,CUSTOM+INTREQ
; Vertical bit is on, so reset
it
ADD.B
SUBQ.B
BNE
MOVE.B
EOR.B
D4,D2
#,DO
Ll
#151,DO
#$FE,D4
jlncrement horizontal value
;Decrement horizontal counter
;Count exhausted, reset to
151
;Negate the increment value
Sprite Hardware
109

Table of Contents

Other manuals for Commodore Amiga

Related product manuals