;=====================================================================
;Miscellaneous support routines -
;
;Copyright 1992, Attention To Detail Ltd. Version 1.3
;
;---------------------------------------------------------------------
;Routines contained herein:
;
;	getsharedlist	: getdatalist and shared data
;
;	getdistance		: calculate distance between 2 (X,Z) coord sets
;	getdistance2	: as above but calculate distance squared
;	getangle		: calculate angle wrt North of a vector
;	polar2cart		: polar to cartesion calculation
;	polar1cart		: as above, but not scaled for world coords
;
;	setcollision	: set collision mask based on world coords
;
;	setcolr			: set faces on 3D object to specific colour
;	getcolrptrs		: obtain offset ptrs to face colours of given val
;
;	getshapevsize	: calculate the VSIZE of a shape (collision detection)
;
;	exactheight		: calculate the height above the world map
;	cruiseheight	: similar function to above
;	tilecolour		: get tile colour
;
;	checknotnear	: check 3D object not too close to another
;
;	animateobject	: animate a 3D object
;	setanimation	: set animation stuff up
;	setshape		: three entry points into one routine
;	makepuff		: puff explosion
;	warmexplosion	: make warm explosion
;	makeexplosion	: make an explosion
;i	simexplosion	: internal explode routine
;
;	addtoscore		: add to the player's score
;
;=====================================================================

OPTIMISED		equ 1					;optimised CRUISEHEIGHT + EXACTHEIGHT?



				include .\atd.inc

				modulename support

				include jag.inc

				include .\global.inc
				include .\system.inc
				include .\demo.inc
				include .\game.inc
				include .\maths.inc
				include .\obj3d.inc
				include .\support.inc
				include .\shapes.inc
				include .\scape.inc

				global sinetab,sinetable



				BEGVARS

				VAR scorebuf,DWORD		;temporary buffer

				ENDVARS




				BEGCONST

				align ALIGNWORD
collisiontab:
				include .\colltab.inc

				ENDCONST




				BEGCODE

;=====================================================================
;This routine is used to decompress a list of frames and then copy
;some of the pointers generated into other location - the frames are
;shared. This has to be the case as the animation code only supports
;simple structures.
;
;ON ENTRY:	A0 points to getdatalist structure.
;CURRUPTED:	?
;EXIT:


getsharedlist:	bsr getdatalist
				move.w (a0)+,d7			;count for shared ptrs
				subq.w #1,d7			;for DBRA below

0$:				move.l (a0)+,a1			;source of shared ptr
				move.l (a0)+,a2			;destination of shared ptr
				move.l (a1),d0
				move.l d0,(a2)			;copy ptr across
				dbra d7,0$
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This routine calculates the distance between 2 given object coords
;(approximates root of dX*dX+dZ*dZ). Uses macro above to generate the
;information and return it. Could generate in-line code with the
;macro each time we need to obtain the distance, apart from the code
;size constraints.
;
;ON ENTRY:	(D0.w,D1.w) = (x1,z1), (D2.w,D3.w) = (x2,z2)
;CURRUPTED:
;EXIT:		D0.w = approximated distance.


getdistance:	DISTANCE d0,d1,d2,d3,<rts>,<rts>

;
;---------------------------------------------------------------------

;=====================================================================
;Similar routine to the above, with the exception that we return the
;square of the distance between the coordinates. This is more accurate
;because it is not an approximation. Returned as a long due to size
;of the world.
;
;ON ENTRY:	(D0.w,D1.w) = (x1,z1), (D2.w,D3.w) = (x2,z2)
;CURRUPTED:
;EXIT:		D0.l = distance squared.


getdistance2:	DISTANCE2 d0,d1,d2,d3
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This routine obtains the angle of the vector connecting two points
;together relative to North (0 degrees). Used to calculate angles of
;travel to reach targets, firing times and such like. Calculation is
;broken down into 8 octants (Q1-Q8 below) for accuaracy to within 5
;degrees (assumes tangent is virtually linear 0-45 degrees).
;Vector is (x2-x1,z2-z1), and (x2,z2) are (D0.w,D1.w).
;
;                 Q8 | Q1
;                \   |	 /
;              Q7  \ | /   Q2
;             <------+------>
;              Q6  / | \   Q3
;                /   |   \
;				  Q5 | Q4
;
;
;ON ENTRY:	(D0.w,D1.w) = (x2,z2), (D2.w,D3.w) = (x1,z1)
;CURRUPTED:
;EXIT:		D0.w = angle.


getangle:		CALCANGLE d0,d1,d2,d3,<rts>,<rts>

;
;---------------------------------------------------------------------

;=====================================================================
;Convert (angle,length) to (x,z) vector. Very simple maths using sin
;and cos. The second entry point to this routine doesn't scale the
;input coordinate based upon the world size. Some calculations do not
;require it.
;
;ON ENTRY:	D0.w angle(0-255), D1.w length
;CURRUPTED:	A2
;EXIT:		D0.w=dx, D1.w=dz


polar2cart:
				IFNE DSHIFT
				lsl.w #DSHIFT,d1
				ENDC

polar1cart:		add.w d0,d0				;angle * 2 for table.w lookup
				lea sinetable,a2
				lea (a2,d0.w),a2
				move.w (a2),d0			;get sine
				muls d1,d0
				FIXEDPTSHIFT d0			;dX into D0
				muls ANGLE90*2(a2),d1	;cosine
				FIXEDPTSHIFT d1			;dZ into D1
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;Set the collision mask for a given object, based on current (X,Z)
;position in the world. The world is broken down into zones in X and Z
;(16 in each) so that a very quick proximity test can be performed.
;
;ON ENTRY:	A0 points to 3D object structure
;CORRUPTED:	D0,A2


setcollision:	lea collisiontab,a2
				move.b HIGHBYTE+obj.x(a1),d0
				and.w #$00fe,d0
				move.w (a2,d0.w),HIGHWORD+obj.collcell(a1)
				move.b HIGHBYTE+obj.z(a1),d0
				and.w #$00fe,d0
				move.w (a2,d0.w),LOWWORD+obj.collcell(a1)
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This routine sets all the faces in a given 3D shape to a given colour
;irrespective of what is already there.
;
;ON ENTRY:	D0.b is colour, A0 shape ptr
;CURRUPTED:	D1,D2,D3
;EXIT:


setcolr:		lsl.w #8,d0				;CR:0 into D0

				move.w (a0),d1			;total number of coords
				lsl.w #3,d1				;x8 (X,Y,Z,I) element size
				lea 8(a0,d1.w),a0		;A0 to number of faces

				move.w (a0)+,d1			;number of faces out
				subq.w #1,d1			;for DBRA below

0$:				move.l (a0)+,d2			;FLAGS:NVERTICES
				move.w (a0),d3			;colour (CR:I)
				move.b d3,d0
				move.w d0,(a0)			;store new CR and original intensity
				add.w d2,d2				;x2 for word fields
				lea 4+2(a0,d2.w),a0		;advance to next face

				dbra d1,0$
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This routine scans a 3D shape looking for a specific CRY colour. When
;it finds that colour it writes an offset from the beginning of the 3D
;shape to that location into a list and continues. This list can be
;used for speedy CRY colour setting at a later date.
;
;ON ENTRY:	D0.b is search CRY, A0 shape ptr, A1 is destn list ptr
;CURRUPTED:	D1,D2,D3,D4,A2
;EXIT:


getcolrptrs:	lea (a0),a2				;base, for offset calculations later

				move.w (a0),d2			;total number of coords
				lsl.w #3,d2				;x8 (X,Y,Z,I) element size
				lea 8(a0,d2.w),a0		;A0 to number of faces

				move.w (a0)+,d2			;number of faces out
				subq.w #1,d2			;for DBRA below

0$:				move.l (a0)+,d3			;FLAGS:NVERTICES
				cmp.w (a0),d0
				bne.s 1$

				move.l a0,d1			;FOUND required CRY colour. We can
				sub.l a2,d1				;now store the WORD offset from the
				move.w d1,(a1)+			;base to this field for later use

1$:				add.w d3,d3				;x2 for word fields
				lea 4+2(a0,d3.w),a0		;advance to next face

				dbra d2,0$
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This routine scans the vertices in a 3D shape to find the maxmimum,
;absolute Y coordinate (assuming that the object is centred around 0).
;This can be used for collision detection purposes later.
;
;ON ENTRY:	A1 ptr to 3D object
;CURRUPTED:	
;EXIT:		OBJ.VSIZE is set to vertical size


getshapevsize:	PUSHM <d1-d3/a0>
				move.l obj.shp(a1),a0	;ptr to shape definition

				lea WORD(a0),a0			;skip TOTAL VERTICES
				move.w (a0)+,d1
				add.w (a0)+,d1			;face normals + vertex normals
				move.w (a0),d2			;vertex count into D2
				lsl.w #3,d1				;x8 (X,Y,Z,I) for each vertex
				lea 2+2(a0,d1.w),a0		;A0 to Y coordinate of first

				move.w #0,d0			;D2 is largest +Ve
				move.w #0,d3			;D3 is largest -Ve

0$:				cmp.w (a0),d0
				bge.s 1$
				move.w (a0),d0			;D0 larger of the two
1$:				cmp.w (a0),d3
				ble.s 2$
				move.w (a0),d3			;D3 smaller of the two

2$:				lea 8(a0),a0			;skip (Y,Z,I,X)
				dbra d2,0$


;Got the largest in +ve and -ve direction. Combine to generate size!

				neg.w d3
				cmp.w d3,d0
				bge.s 3$
				move.w d3,d0			;choose largest of absolute values!

3$:				move.w d0,obj.vsize(a1)	;store it away

				POPM <d1-d3/a0>
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This subroutine returns the height of the map at a given position.
;All objects call this subroutine to make sure they appear at their
;required height.
;
;ON ENTRY:	(D0.w,D1.w) are (X,Z) world coords
;CORRUPTED:
;ON EXIT:	D0.l is the height


				IFNE OPTIMISED
exactheight:	PUSHM <a0/d2-d4>

				IFNE COORDSHIFT
				lsr.w #COORDSHIFT,d0
				lsr.w #COORDSHIFT,d1
				ENDC

				move.l d0,d2
				move.l d1,d3			;take copy of coords

				and.w #TILESIZE-1,d0
				and.w #TILESIZE-1,d1

				lsr.w #TILESHFT-2,d2
				and.l #(WORLDSIZE-1)*DWORD,d2
				lsr.w #TILESHFT-2,d3
				and.w #(WORLDSIZE-1)*DWORD,d3	;/TILESIZE then *DWORD

				mulu #WORLDSIZE+1,d3
				add.l d3,d2				;D2 is offset into wmap (long words)
				move.l localmap(a6),a0
				lea (a0,d2.l),a0

				move.w 2+DWORD(a0),d3	;height value B
				move.w 2+0(a0),d2		;height value A
				sub.w d2,d3				;B-A
				muls d0,d3				;dX * (B-A)
				lsl.l #16-TILESHFT,d3
				swap d3					;/512
				add.w d2,d3				;+A == E

				lea (WORLDSIZE+1)*DWORD(a0),a0

				move.w 2+DWORD(a0),d4	;height value D
				move.w 2+0(a0),d2		;height value C
				sub.w d2,d4				;D-C
				muls d4,d0				;dX * (D-C)
				lsl.l #16-TILESHFT,d0
				swap d0					;/512
				add.w d2,d0				;+C == F

				sub.w d3,d0				;F-E
				muls d1,d0				;dY * (F-E)
				lsl.l #16-TILESHFT,d0
				swap d0					;/512
				add.w d3,d0				;+E

				POPM <a0/d2-d4>
				rts
				ENDC




				IFEQ OPTIMISED
exactheight:	PUSHM <d2-d5/a0>
				and.l	#$ffff,d0
				and.l	#$ffff,d1

				IFNE COORDSHIFT
				lsr.w	#COORDSHIFT,d0
				lsr.w	#COORDSHIFT,d1
				ENDC

				move.l	d0,d2		;x
				move.l	d1,d3		;z

				moveq	#TILESHFT,d4		;shifts to get gmap co-ords
				lsr.w	d4,d2		;get gmap co-ords
				lsr.w	d4,d3
				and.w	#$FFFFFFFF>>(32-(TILESHFT)),d0	;get remainder
				and.w	#$FFFFFFFF>>(32-(TILESHFT)),d1

				; convert remainders to 2.14 fixed point format
				; (7FF -> 3FFF)
				lsl.w	#14-(TILESHFT),d0
				lsl.w	#14-(TILESHFT),d1

				; lookup at gmap position

				mulu	#WORLDSIZE+1,d3
				add.l	d3,d2		
				lsl.l	#2,d2		;d2 = offset into wmap (longwords)

				move.w	d0,d5		;dx
				move.w	d0,d3		;dx
				neg.w	d0
				add.w	#$4000,d0	;1-dx
				move.w	d0,d4

				mulu	d1,d5		;dz.(dx)
				mulu	d1,d4		;dz.(dx)
				neg.w	d1
				add.w	#$4000,d1	;1-dz
				mulu	d1,d3		;(1-dz).(dx)
				mulu	d1,d0		;(1-dz).(1-dx)

				; get back to 2.14 format
				FIXEDPTSHIFT d0
				FIXEDPTSHIFT d3
				FIXEDPTSHIFT d4
				FIXEDPTSHIFT d5

				move.l	localmap(a6),a0
				lea		(a0,d2.l),a0
				muls	2+0(a0),d0		;height value A

				muls	2+4(a0),d3		;height value B

				lea		(WORLDSIZE+1)*4(a0),a0
				muls	2+0(a0),d4		;height value C
				muls	2+4(a0),d5		;height value D

				add.l	d5,d4
				add.l	d4,d3
				add.l	d3,d0
	
				; adjust for fixed point 

				FIXEDPTSHIFT d0	;shift = 8 for tile, 3 for lstep, -4 for compression
	
				POPM <d2-d5/a0>
				rts
				ENDC

;
;---------------------------------------------------------------------

;=====================================================================
;Get a height from a cruise map. The cruise map is a smoothed version
;of the world map. It is generated from the world map and is used by
;flying/moving objects. Static objects use exactheight.
;
;ON ENTRY:	(D0.w,D1.w) are (X,Z) world coords
;CORRUPTED:
;ON EXIT:	D0.l is the height


				IFNE OPTIMISED
cruiseheight:	PUSHM <a0/d2-d4>

				IFNE COORDSHIFT
				lsr.w #COORDSHIFT,d0
				lsr.w #COORDSHIFT,d1
				ENDC

				move.l d0,d2
				move.l d1,d3			;take copy of coords

				and.w #TILESIZE-1,d0
				and.w #TILESIZE-1,d1

				lsr.w #TILESHFT-1,d2
				and.l #(WORLDSIZE-1)*WORD,d2
				lsr.w #TILESHFT-1,d3
				and.w #(WORLDSIZE-1)*WORD,d3	;/TILESIZE then *DWORD

				mulu #WORLDSIZE+1,d3
				add.l d3,d2				;D2 = offset into map (words)

				move.l cruisemap(a6),a0
				lea (a0,d2.l),a0

				move.w (a0)+,d2			;height value A
				move.w (a0),d3			;height value B
				sub.w d2,d3				;B-A
				muls d0,d3				;dX * (B-A)
				lsl.l #16-TILESHFT,d3
				swap d3					;/512
				add.w d2,d3				;+A == E

				lea (WORLDSIZE+1)*WORD-WORD(a0),a0

				move.w (a0)+,d2			;height value C
				move.w (a0),d4			;height value D
				sub.w d2,d4				;D-C
				muls d4,d0				;dX * (D-C)
				lsl.l #16-TILESHFT,d0
				swap d0					;/512
				add.w d2,d0				;+C == F

				sub.w d3,d0				;F-E
				muls d1,d0				;dY * (F-E)
				lsl.l #16-TILESHFT,d0
				swap d0					;/512
				add.w d3,d0				;+E

				POPM <a0/d2-d4>
				rts
				ENDC




				IFEQ OPTIMISED
cruiseheight:	PUSHM <d2-d5/a0>

				and.l	#$ffff,d0
				and.l	#$ffff,d1

				IFNE COORDSHIFT
				lsr.w	#COORDSHIFT,d0
				lsr.w	#COORDSHIFT,d1
				ENDC

				move.l	d0,d2		;x
				move.l	d1,d3		;z


				moveq	#TILESHFT,d4		;shifts to get gmap co-ords
				lsr.w	d4,d2		;get gmap co-ords
				lsr.w	d4,d3
				and.w	#$FFFFFFFF>>(32-(TILESHFT)),d0	;get remainder
				and.w	#$FFFFFFFF>>(32-(TILESHFT)),d1

				; convert remainders to 2.14 fixed point format
				; (7FF -> 3FFF)
				lsl.w	#14-(TILESHFT),d0
				lsl.w	#14-(TILESHFT),d1

				; lookup at gmap position

				mulu	#WORLDSIZE+1,d3
				add.l	d3,d2		
				add.l	d2,d2		;d2 = offset into wmap (WORDS!)

				; compute (LINEAR) multipliers

				move.w	d0,d5		;dx
				move.w	d0,d3		;dx
				neg.w	d0
				add.w	#$4000,d0	;1-dx
				move.w	d0,d4

				mulu	d1,d5		;dz.(dx)
				mulu	d1,d4		;dz.(dx)
				neg.w	d1
				add.w	#$4000,d1	;1-dz
				mulu	d1,d3		;(1-dz).(dx)
				mulu	d1,d0		;(1-dz).(1-dx)

				; get back to 2.14 format
				FIXEDPTSHIFT d0
				FIXEDPTSHIFT d3
				FIXEDPTSHIFT d4
				FIXEDPTSHIFT d5

				move.l	cruisemap(a6),a0
				lea		(a0,d2.l),a0
				muls	(a0)+,d0		;get height value (A)
				muls	(a0),d3			;get height value (B)

				lea		(WORLDSIZE+1)*2-2(a0),a0

				muls	(a0)+,d4		;get height value (C)
				muls	(a0),d5			;get height value (D)

				add.l	d5,d4
				add.l	d4,d3
				add.l	d3,d0
	
				; adjust for fixed point 

				FIXEDPTSHIFT d0	;shift = 8 for tile, 3 for lstep, -4 for compression

				POPM <d2-d5/a0>
				rts
				ENDC

;
;---------------------------------------------------------------------

;=====================================================================
;This routine obtains the CRY information for a given world tile. It
;is called by various camouflaged enemy sprites.
;
;ON ENTRY:	(D0.w,D1.w) are (X,Z) world coords
;CORRUPTED:
;ON EXIT:	D0.w is the CRY information, A0 points to tile


tilecolour:		moveq #TILESHFT+COORDSHIFT,d2
				lsr.w d2,d0
				lsr.w d2,d1				;get tile indices
				mulu #WORLDSIZE+1,d1
				add.w d0,d1
				lsl.l #2,d1				;scale for DWORDs
				move.l localmap(a6),a0
				lea (a0,d1.l),a0		;A0 to required cell
				move.w 0(a0),d0			;get CRY information
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This routine is used to ensure that nothing is near to a 3D object
;when we attempt to create it. Does a brute force linear search. Not
;used very often, so we should be OK. It is alright to be near player
;missiles, enemy missiles and collectables but not anything else!
;
;ON ENTRY:	A1 is ptr to source object, D6.w is min distance
;CORRUPTED:	D0,D1,D7,A2
;ON EXIT:	-VE flag set if the object is too close


checknotnear:	PUSH a0
				move.l objlist(a6),a0
				move.w numobj(a6),d7
				subq.w #1,d7
				bmi.s exitnotnr			;nothing else around!

nrloop:			move.l (a0)+,a2
				move.b LOWBYTE+obj.type(a2),d0
				cmp.b #OBJ3D_PLAYRMISS,d0
				beq.s notnr
				cmp.b #OBJ3D_NMEMISS,d0
				beq.s notnr
				cmp.b #OBJ3D_COLLECT,d0
				beq.s notnr

				cmp.l a1,a2
				beq.s notnr				;do not check ourself!

				move.w obj.x(a1),d0
				move.w obj.z(a1),d1
				QUICKDIST d0,d1,obj.x(a2),obj.z(a2),<bra.s neardist>
neardist:		cmp.w d6,d0
				bcs.s tooclose

notnr:			dbra d7,nrloop

exitnotnr:		POP a0
				moveq #0,d7				;+ve flag
				rts

tooclose:		POP a0
				moveq #-1,d7			;-ve flag
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;Animating object animation code. Uses several fields in the object
;structure to make animation happen. Moves through a list of frames
;every anm.animspd cycles. The current frame is advanced until it
;reaches the maximum and then is reset to anm.baseframe. The current
;frame can be -ve initially (allows fixed sequence lead to repeat).
;This subroutine contains 3 entry points depending on what we are
;trying to achieve:
;
;animateobject ON ENTRY:	A1=object ptr
;setanimation ON ENTRY:		A1=object ptr
;setshape ON ENTRY:			A1=object ptr, D0 is shape number
;
;CORRUPTED:		D0,A2
;EXIT:

animateobject:	subq.w	#1,anm.animcnt(a1)	;check animation-speed counter
				bpl.s  	donowt				;branch if not time to animate
				move.w	anm.animspd(a1),d0	;restart counter
				move.w	d0,anm.animcnt(a1)
				move.w	anm.currframe(a1),d0
				addq.w	#4,d0			;advance current frame
				cmp.w	anm.numframe(a1),d0
				bmi.s	2$				;branch if num-frame NOT reached
				sub.w	d0,d0			;ELSE reset animation to zero
2$:				move.w	d0,anm.currframe(a1) ;store animation frame number 

				; get the correct frame data

setanimation:
				move.w	anm.currframe(a1),d0
				add.w	anm.baseframe(a1),d0
setshape:
				lea		shapetable,a2
				move.l	(a2,d0.w),a2	; get pointer to shapedef
				move.l	a2,obj.shp(a1)

donowt:			rts

;
;---------------------------------------------------------------------

;=====================================================================
;=====================================================================
;This routine generates a puff of blue smoke where an object used to
;be. Player missiles will explode using this routine. Branches into
;MAKEEXPLOSION for most of the work to be carried out.
;
;ON ENTRY:
;CORRUPTED:	as setanimation
;ON EXIT:


makepuff:		move.w #8*4,anm.numframe(a1)
				move.w #8-1,die.counter(a1)
				move.w #puff_anims,d0
				bra.s doexplode

;
;---------------------------------------------------------------------

;=====================================================================
;This routine turns a 3D object (sprite or 3D shape) into an explosion
;sprite. An alternative entry point is DOEXPLODE which is used by the
;above routine to generate a puff of smoke.
;
;ON ENTRY:
;CORRUPTED:	as setanimation
;ON EXIT:


warmexplosion:	move.w #8*4,anm.numframe(a1)
				move.w #8-1,die.counter(a1)
				move.w #explosion2_anims,d0
				bra.s doexplode


makeexplosion:	move.w #12*4,anm.numframe(a1)
				move.w #12-1,die.counter(a1)
				move.w #explosion1_anims,d0

doexplode:		clr.w anm.animspd(a1)
				clr.w anm.animcnt(a1)
				clr.w anm.currframe(a1)
				move.w #TYPE_EXPLOSION+TYPE_NOTCOLLIDE,obj.type(a1)

				move.w d0,anm.baseframe(a1)
				lea shapetable,a2
				move.l (a2,d0.w),a2		;pointer to shape def
				move.l a2,obj.shp(a1)

				move.l #simexplosion,obj.mover(a1)


;Adjust the explosion position based upon where the collision occured

				move.w obj.collpercent(a1),d2
				beq.s 9$

				move.w obj.x(a1),d0
				move.w obj.udx(a1),d1
				muls d2,d1
				FIXEDPTSHIFT d1
				sub.w d1,d0
				move.w d0,obj.x(a1)

				move.w obj.y(a1),d0
				move.w obj.udy(a1),d1
				muls d2,d1
				FIXEDPTSHIFT d1
				sub.w d1,d0
				move.w d0,obj.y(a1)

				move.w obj.z(a1),d0
				move.w obj.udz(a1),d1
				muls d2,d1
				FIXEDPTSHIFT d1
				sub.w d1,d0
				move.w d0,obj.z(a1)

9$:				rts

;
;---------------------------------------------------------------------

;=====================================================================
;This subroutine simply animates the explosion sprite on the spot and
;kills the object when the end of the animation has been reached.
;
;ON ENTRY:
;CORRUPTED:	as animateobject
;ON EXIT:

simexplosion:	bsr		animateobject
				subq.w	#1,die.counter(a1)
				bmi		KillObj
				rts

;
;---------------------------------------------------------------------

;=====================================================================
;Add a value to the player's score. There are two entry points;
;ADDNUMTOSCORE to add D0.l to the player's score and ADDSTRTOSCORE to
;add a string to the player's score.
;
;ADDNUMTOSCORE:	D0.l = what to add on, A2 points to player structure
;ADDSTRTOSCORE:	A3=ptr past end of addon str
;CORRUPTED:		A3


addstrtonum:	lea scorebuf(a6),a3
				move.l d0,(a3)+			;store score + A3 past end!
				bra.s dobcdadd			;A2 provided for this one

addnumtoscore:	lea scorebuf(a6),a3
				move.l d0,(a3)+			;store score + A3 past end!

addstrtoscore:	lea 4+plr.score(a2),a2

dobcdadd:		and #$ef,CCR			;clear extend flag
				abcd -(a3),-(a2)
				abcd -(a3),-(a2)
				abcd -(a3),-(a2)
				abcd -(a3),-(a2)
				rts

;
;---------------------------------------------------------------------

				ENDCODE

				END

ÿ
