
MOVING A SPRITE
A sprite generated in automatic mode can be moved by specifying a different position in
the data structure. For each display field, the data is reread and the sprite redrawn.
Therefore, if you change the position data before the sprite is redrawn, it will appear in a
new position and will seem to be moving.
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 that 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 moving
object within specified on-screen boundaries. Collision Detection 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 6.
MOVE.B #151,d0 ; Initialize horizontal count
MOVE.B #194,d1 ; Initialize vertical count
MOVE.B #64,d2 ; Initialize horizontal position
MOVE.B #44,d3 ; Initialize vertical position
MOVE.B #1,d4 ; Initialize horizontal increment value
MOVE.B #1,d5 ; Initialize vertical increment value
;
; Here we wait for the start of the screen updating.
; This ensures a glitch-free display.
;
LEA CUSTOM,a0 ; Set custom chip base pointer
VLOOP:
MOVE.B VHPOSR(a0),d6 ; Read Vertical beam position.
; Only insert the following line if you are using a PAL machine.
; CMP.B #$20,d6 ; Compare with end of PAL screen.
BNE.S VLOOP ; Loop if not end of screen.
; Alternatively you can use the following code:
; VLOOP:
- 110 Sprite Hardware -
Summary of Contents for Amiga A1000
Page 1: ...AMIGA HARDWARE REFERENCE MANUAL 1992 Commodore Business Machines Amiga 1200 PAL...
Page 20: ...Figure 1 1 Block Diagram for the Amiga Computer Family Introduction 11...
Page 21: ...12 Introduction...
Page 72: ...Figure 3 12 A dual Playfield display Playfield Hardware 63...
Page 87: ...Figure 3 24 Horizontal Scrolling 78 playfield hardware...
Page 101: ...92 Playfield Hardware...
Page 199: ...Figure 6 9 DMA time slot allocation 190 Blitter hardware...
Page 203: ...Figure 6 13 Blitter Block Diagram 194 Blitter Hardware...
Page 229: ...220 System Control Hardware...
Page 246: ...Figure 8 8 Chinon Timing diagram cont Interface Hardware 237...
Page 265: ...256 Interface Hardware...
Page 289: ...280 Appendix A...
Page 297: ...288 Appendix B...
Page 298: ...APPENDIX C CUSTOM CHIP PIN ALLOCATION LIST NOTE Means an active low signal Appendix C 289...
Page 302: ...APPENDIX D SYSTEM MEMORY MAP Appendix D 293...
Page 343: ...334 Appendix F...
Page 351: ...342 Appendix G...
Page 361: ...352 Appendix H...
Page 367: ...358 Appendix I...