; routines to allow viewing of single objects from the object list, without having to use a separate program
; requires entirely self-contained key controls etc

.include	'joypad.inc'
.include	'memdefs.inc'
;.include	'vardefs.inc'

.text

Single::

movem.l	d0-d7/a0-a6,-(a7)	; stack the lot

; start off by hoving the current "Start Data" onto the stack because we're going to replace it

movea.l	#Genstr,a0

movem.l	(a0),d0-d7	; get eight longs
movem.l	d0-d7,-(a7)	; and write out 

moveq.l	#0,d0
moveq.l	#100,d1
move.l	#-205<<16|115,d2
moveq.l	#0,d3
moveq.l	#0,d4
move.l	#-3000,d5
moveq.l	#1,d6
movea.l	spinad.w,a1

movem.l	d0-d6/a1,(a0)

move.l	d6,(a1)+	; to mean one object in list

moveq.l	#-1,d0		; to signify end of spin list
move.l	d0,a2

move.l	#$00010000,d0	; spin around x axis slowly, no effect on others
moveq.l	#0,d1
moveq.l	#0,d2
moveq.l	#0,d3
moveq.l	#0,d4
moveq.l	#0,d5
moveq.l	#0,d6
move.l	#StrtW,d7

movem.l	d0-d7/a2,(a1)

.mainloop:

	bsr	readpad
	bsr	Display_routine
	
	move.l	joy_edge.w,d0
	btst.l	#KEY_1,d0
	beq.b	.noxf
	move.w	(a1),d1
	eori.b	#1,d1
	move.w	d1,(a1)
.noxf:	btst.l	#KEY_2,d0
	beq.b	.noyf
	move.w	4(a1),d1
	eori.b	#1,d1
	move.w	d1,4(a1)
.noyf:	btst.l	#KEY_3,d0
	beq.b	.nozf
	move.w	8(a1),d1
	eori.b	#1,d1
	move.w	d1,8(a1)
.nozf:	btst.l	#KEY_STAR,d0
	beq.b	.nosp
	asl.w	(a1)
	asl.w	4(a1)
	asl.w	8(a1)
.nosp:	btst.l	#KEY_HASH,d0
	beq.b	.nosl
	moveq.l	#1,d1
	move.w	d1,(a1)
	moveq.l	#0,d1
	move.w	d1,4(a1)
	move.w	d1,8(a1)
.nosl:	btst.l	#JOY_LEFT,d0
	beq.b	.nopo
	move.l	28(a1),a2	; get address of current structure
	suba.w	#16,a2
	move.l	(a2),d1
	bpl.b	.nowf
	movea.l	4(a2),a2
.nowf:	move.l	a2,28(a1)
.nopo:	btst.l	#JOY_RIGHT,d0
	beq.b	.nono
	move.l	28(a1),a2	; get address of current structure
	lea	16(a2),a2
	move.l	(a2),d1
	bpl.b	.nowb
	movea.l	4(a2),a2
.nowb:	move.l	a2,28(a1)
.nono:	move.l	joy_cur.w,d0
	btst.l	#JOY_UP,d0
	beq.b	.nopb
	sub.l	#1000,20(a0)
.nopb:	btst.l	#JOY_DOWN,d0
	beq.b	.nomi
	add.l	#1000,20(a0)
.nomi:	move.l	joy_edge.w,d0
	btst.l	#FIRE_C,d0
	beq	.mainloop

movea.l	#Genstr,a0

movem.l	(a7)+,d0-d7	; get eight longs
movem.l	d0-d7,(a0)	; and write out 

movem.l	(a7)+,d0-d7/a0-a6	; unstack the lot

end:
rts
