add.l	d3,d3
		move.l	(a1,d3.l),a2
		move.l	orig-d(a5),d0
		lea	(a4,d0.l),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)
		lea	_scrwidth(a4),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)
		lea	_scrwidth(a4),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)


		movem.l	(a7)+,d2/a0
		add.l	xsetlpos2-d(a5),a0
		add.l	xsetpos2-d(a5),d2
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,d2
		bmi.s	.lc5
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,d2
.lc5		lea	(a3,d2.l),a4
		moveq	#0,d3
		move.w	(a0),d3
		move.w	d3,d5
		and.w	d6,d5
		cmp.w	#$f000,d5
		bhi.s	.lc13
		move.w	-4(a0),d5
		and.w	d6,d5
		beq.s	.lc11
		cmp.w	#$c400,d5
		bhi.s	.lc11

		movem.l	d0-a6,-(a7)
		lea	-4(a0),a0
		move.l	xpos-d(a5),d0
		subq.l	#4,d0
		lsl.l	#3,d0
		move.l	actysoftabs-d(a5),d1
		and.l	#$fffffff0,d1
		add.l	xsetsoft2-d(a5),d1
		bsr	setbobl
		movem.l	(a7)+,d0-a6
		bra.s	.lc11

.lc13		movem.l	d0/d3/d2/d4/a0/a4/a5/a6,-(a7)
		move.l	xsetsoft2-d(a5),d4
		bsr	setblkl
		movem.l	(a7)+,d0/d3/d2/d4/a0/a4/a5/a6
;		moveq	#0,d3

.lc11		and.w	d1,d3
		add.l	d3,d3
		add.l	d3,d3
		move.l	(a1,d3.l),a2
		move.l	orig-d(a5),d0
		lea	(a4,d0.l),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)
		lea	_scrwidth(a4),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)
		lea	_scrwidth(a4),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)

		sub.l	#_scrwidth*_scrdepth*3*16,d2
		bpl.s	.lc00004
		add.l	#_scrwidth*_scrdepth*3*_scrheight,d2
.lc00004	lea	-_levwidth(a0),a0
		
		lea	(a3,d2.l),a4
		moveq	#0,d3
		move.w	(a0),d3
		move.w	d3,d5
		and.w	d6,d5
		cmp.w	#$f000,d5
		bhi.s	.lc213
		move.w	-4(a0),d5
		and.w	d6,d5
		beq.s	.lc211
		cmp.w	#$c400,d5
		bhi.s	.lc211

		movem.l	d0-a6,-(a7)
		lea	-4(a0),a0
		move.l	xpos-d(a5),d0
		subq.l	#4,d0
		lsl.l	#3,d0
		move.l	actysoftabs-d(a5),d1
		and.l	#$fffffff0,d1
		add.l	xsetsoft2-d(a5),d1
		subq.l	#8,d1
		subq.l	#8,d1
		bsr	setbobl
		movem.l	(a7)+,d0-a6
		bra.s	.lc211

.lc213		movem.l	d0/d3/d2/d4/a0/a4/a5/a6,-(a7)
		move.l	xsetsoft2-d(a5),d4
		subq.l	#8,d4
		subq.l	#8,d4
		bsr	setblkl
		movem.l	(a7)+,d0/d3/d2/d4/a0/a4/a5/a6
;		moveq	#0,d3

.lc211		and.w	d1,d3
		add.l	d3,d3
		add.l	d3,d3
		move.l	(a1,d3.l),a2
		move.l	orig-d(a5),d0
		lea	(a4,d0.l),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)
		lea	_scrwidth(a4),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)
		lea	_scrwidth(a4),a4
		waitblt
		move.l	a2,$50(a6)
		move.l	a4,$54(a6)
		move.w	d4,$58(a6)


		moveq	#32,d0
		add.l	d0,xsetsoft1-d(a5)
		add.l	#_levwidth*2,xsetlpos1-d(a5)
		add.l	#_scrwidth*_scrdepth*3*32,xsetpos1-d(a5)
		sub.l	d0,xsetsoft2-d(a5)
		sub.l	#_levwidth*2,xsetlpos2-d(a5)
		sub.l	#_scrwidth*_scrdepth*3*32,xsetpos2-d(a5)

.lc3		addq.l	#1,absxpos-d(a5)
		cmp.l	#640,absxpos-d(a5)
		bmi.s	.lc2
		sub.l	#640,absxpos-d(a5)
.lc2		addq.w	#2,xscrflag-d(a5)

.left2		move.w	#103*4,d1
		sub.w	agamanxpos-d(a5),d1
		cmp.w	#4,d1
		bpl.s	.lc03
		moveq	#4,d1
.lc03		cmp.w	#16,d1
		bmi.s	.lc04
		moveq	#16,d1
.lc04		ext.l	d1
		sub.l	d1,agaxsoftabs-d(a5)
		add.w	d1,xsoft-d(a5)
		cmp.w	#64,xsoft-d(a5)
		bmi.s	.lc7
		sub.w	#64,xsoft-d(a5)
		subq.l	#2,xpos-d(a5)
.lc7		add.w	d1,agamanxpos-d(a5)
		move.w	agamanxpos-d(a5),d0
		lsr.w	#2,d0
		move.w	d0,manxpos-d(a5)
		move.l	agaabsmanxpos-d(a5),d0
		lsr.l	#2,d0
		move.l	d0,absmanxpos-d(a5)
		move.l	agaxsoftabs-d(a5),d0
		lsr.l	#2,d0
		move.l	d0,xsoftabs-d(a5)
		
		rts
		

.end		rts
*****
;------------------------------------------------
scrolly		lea	d(pc),a5
		tst.w	yscrflag-d(a5)
		beq	.end
		bpl	.down
.up		move.l	scycount-d(a5),d0
		sub.l	d0,ysoftabs-d(a5)
		sub.l	d0,yscrollofs-d(a5)
		sub.w	d0,ysoft-d(a5)
;		add.w	d0,manypos
		move.l	scyhard-d(a5),d0
		sub.l	d0,ypos-d(a5)
		bpl.s	.uc2
		add.l	#_scrwidth*_scrdepth*3*_scrheight,ypos-d(a5)
		add.w	#_scrheight,ysoft-d(a5)

.uc2		
		move.l	scycount-d(a5),d0
		sub.w	d0,ysetsoft-d(a5)
		tst.w	ysetsoft-d(a5)
		bpl.s	.uc1
		addq.w	#4,ysetsoft-d(a5)
		sub.l	#_scrwidth*_scrdepth*3*4,ysetbd-d(a5)
		tst.l	ysetbd-d(a5)
		bpl.s	.uc5
		add.l	#_scrwidth*_scrdepth*3*_scrheight,ysetbd-d(a5)
.uc5		sub.l	#40*_scrdepth*4,ysetlpos-d(a5)
		tst.l	ysetlpos-d(a5)
		bpl.s	.uc1
		add.l	#40*_scrdepth*16,ysetlpos-d(a5)
		sub.l	#_levwidth,yhard-d(a5)
		sub.l	#_scrwidth*_scrdepth*3*16,yshard-d(a5)
		bpl.s	.uc1
		add.l	#_scrwidth*_scrdepth*3*_scrheight,yshard-d(a5)
.uc1		
		waitblt
		move.l	#-1,$44(a6)
		move.l	#$09f00000,$40(a6)
		move.w	#$0026,$64(a6)
		move.w	#(_scrwidth*3)-2,$66(a6)
		move.l	_xmem,a0
		add.l	ldatofs-d(a5),a0
		subq.l	#4,a0
		add.l	xpos-d(a5),a0
		add.l	yhard-d(a5),a0
		add.l	#_levwidth,a0
		move.l	yshard-d(a5),d0
		move.l	ysetbd-d(a5),a3
		add.l	#_scrwidth*_scrdepth*3*16,a3
		add.l	#_scrwidth*_scrdepth*3*16,d0
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,a3
		bmi.s	.uc3
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a3
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,d0
.uc3		add.l	orig-d(a5),a3
		add.l	xpos-d(a5),a3
		add.l	xpos-d(a5),d0
		move.l	a3,a4
		moveq	#0,d3
		move.w	#64*_scrdepth*4+1,d4
		move.l	index-d(a5),a1
		move.w	#$03ff,d1
		move.w	#$fc00,d6
		moveq	#0,d2
		moveq	#(_scrwidth/2)-1,d7
.ul1		moveq	#0,d3
		move.w	(a0),d3
		move.w	d3,d5
		and.w	d6,d5
		beq.s	.uc4

		cmp.w	#$f000,d5
		bhi.s	.uc6
		cmp.w	#$c400,d5
		bhi.s	.uc4
		
		movem.l	d0-a6,-(a7)
		move.l	xpos-d(a5),d0
		addq.l	#4,d0
 		lsl.l	#3,d0
		add.l	d2,d0
		move.l	ysoftabs-d(a5),d1
		and.l	#$fffffff0,d1
		bsr	setbobu
		movem.l	(a7)+,d0-a6
		bra.s	.uc4
		
.uc6		movem.l	d0/d4/d5/d6/d3/a0/a5/a6,-(a7)
		bsr	setblku
		movem.l	(a7)+,d0/d4/d5/d6/d3/a0/a5/a6
;		moveq	#0,d3

.uc4		and.w	d1,d3
		add.l	d3,d3
		add.l	d3,d3
		move.l	(a1,d3.l),a2
		add.l	ysetlpos-d(a5),a2
		waitblt
		move.l	a2,$50(a6)
		move.l	a3,$54(a6)
		move.w	d4,$58(a6)
		addq.l	#2,a3
		addq.l	#8,d2
		addq.l	#8,d2
		addq.l	#2,a0
		addq.l	#2,d0
		dbra	d7,.ul1
		
		lea	_scrwidth(a4),a3
		waitblt
		move.w	#_scrwidth*2,$64(a6)
		move.w	#_scrwidth*2,$66(a6)
		move.l	a4,$50(a6)
		move.l	a3,$54(a6)
		
		move.w	#64*_scrdepth*4+(_scrwidth/2),$58(a6)
		lea	_scrwidth(a3),a3
		waitblt
		move.l	a4,$50(a6)
		move.l	a3,$54(a6)
		move.w	#64*_scrdepth*4+(_scrwidth/2),$58(a6)

		addq.w	#1,yscrflag-d(a5)
		move.l	scycount-d(a5),d0
		rts


.down		waitblt
		move.l	#-1,$44(a6)
		move.l	#$09f00000,$40(a6)
		move.w	#$0026,$64(a6)
		move.w	#(_scrwidth*3)-2,$66(a6)
		move.l	_xmem,a0
		add.l	ldatofs-d(a5),a0
		add.l	#_levwidth*((_viewheight+16)/16)-4,a0
		add.l	xpos-d(a5),a0
		add.l	yhard-d(a5),a0
		move.l	ysetbd-d(a5),a3
		move.l	yshard-d(a5),d0
		add.l	#_scrwidth*_scrdepth*3*(_viewheight+16),a3
		add.l	#_scrwidth*_scrdepth*3*(_viewheight+16),d0
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,a3
		bmi.s	.dc3
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a3
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,d0
.dc3		add.l	orig-d(a5),a3
		add.l	xpos-d(a5),a3
		add.l	xpos-d(a5),d0
		move.l	a3,a4
		moveq	#0,d3
		move.w	#64*_scrdepth*4+1,d4
		move.l	index-d(a5),a1
		move.w	#$03ff,d1
		moveq	#0,d2
		move.w	#$fc00,d6
		moveq	#(_scrwidth/2)-1,d7
.dl1		moveq	#0,d3
		move.w	(a0),d3
		move.w	d3,d5
		and.w	d6,d5
		beq.s	.dc4

		cmp.w	#$f000,d5
		bhi.s	.dc6
		cmp.w	#$c400,d5
		bhi.s	.dc4
		
		movem.l	d0-a6,-(a7)
		move.l	xpos-d(a5),d0
		addq.l	#4,d0
		lsl.w	#3,d0
		add.l	d2,d0
		move.l	ysoftabs-d(a5),d1
		and.l	#$fffffff0,d1
		add.l	#224,d1
		bsr	setbobd
		movem.l	(a7)+,d0-a6
		bra.s	.dc4
		
.dc6		movem.l	d0/d4/d5/d6/d3/a0/a5/a6,-(a7)
		bsr	setblkd
		movem.l	(a7)+,d0/d4/d5/d6/d3/a0/a5/a6
;		moveq	#0,d3

.dc4		and.w	d1,d3
		add.l	d3,d3
		add.l	d3,d3
		move.l	(a1,d3.l),a2
		add.l	ysetlpos-d(a5),a2
		waitblt
		move.l	a2,$50(a6)
		move.l	a3,$54(a6)
		move.w	d4,$58(a6)
		addq.l	#2,a3
		addq.l	#8,d2
		addq.l	#8,d2
		addq.l	#2,a0
		addq.l	#2,d0
		dbra	d7,.dl1

		lea	_scrwidth(a4),a3
		waitblt
		move.w	#_scrwidth*2,$64(a6)
		move.w	#_scrwidth*2,$66(a6)
		move.l	a4,$50(a6)
		move.l	a3,$54(a6)
		move.w	#64*_scrdepth*4+(_scrwidth/2),$58(a6)
		lea	_scrwidth(a3),a3
		waitblt
		move.l	a4,$50(a6)
		move.l	a3,$54(a6)
		move.w	#64*_scrdepth*4+(_scrwidth/2),$58(a6)
		
		move.l	scycount-d(a5),d0
		add.l	d0,yscrollofs-d(a5)
		add.l	d0,ysoftabs-d(a5)
		add.w	d0,ysoft-d(a5)
;		sub.w	d0,manypos
		move.l	scyhard-d(a5),d0
		add.l	d0,ypos-d(a5)
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,ypos-d(a5)
		bmi.s	.dc1
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,ypos-d(a5)
		sub.w	#_scrheight,ysoft-d(a5)
.dc1		subq.w	#1,yscrflag-d(a5)


		move.l	scycount-d(a5),d0
		add.w	d0,ysetsoft-d(a5)
		cmp.w	#4,ysetsoft-d(a5)
		bmi.s	.dc2
		subq.w	#4,ysetsoft-d(a5)
		add.l	#_scrwidth*_scrdepth*3*4,ysetbd-d(a5)
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,ysetbd-d(a5)
		bmi.s	.dc5
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,ysetbd-d(a5)
.dc5		add.l	#40*_scrdepth*4,ysetlpos-d(a5)
		cmp.l	#40*_scrdepth*16,ysetlpos-d(a5)
		bmi.s	.dc2
		sub.l	#40*_scrdepth*16,ysetlpos-d(a5)
		add.l	#_levwidth,yhard-d(a5)
		add.l	#_scrwidth*_scrdepth*3*16,yshard-d(a5)
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,yshard-d(a5)
		bmi.s	.dc2
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,yshard-d(a5)
.dc2		rts

.end		rts
*****
;------------------------------------------------
incnumber	incnumber_m
;------------------------------------------------
decnumber	decnumber_m
;------------------------------------------------
reset		reset_m
;------------------------------------------------
setblkr		setblkr_m

setblkl		setblkl_m

setblkd		setblkd_m

setblku		setblku_m
;------------------------------------------------
setbobr		setbobr_m

setbobl		setbobl_m

setbobu		setbobu_m

setbobd		setbobd_m

doset2		doset2_m
;------------------------------------------------
showenergy	showenergy_m
;------------------------------------------------
testmancoll	lea	d(pc),a5
		bsr	showenergy

		tst.w	ouchsetflag-d(a5)
		bne.s	.set1	
		tst.w	deathflag-d(a5)
		bne	.death		
		tst.w	ouchflag-d(a5)
		bmi	.c2
		bne	.c1
		tst.w	defmancoll-d(a5)
		beq	.show

.set1		clr.w	ouchsetflag-d(a5)
		sub.w	#32,energy-d(a5)
		move.w	#20,ouchflag-d(a5)
		cmp.w	#4,energy-d(a5)
		bpl.s	.show
		move.w	#1,deathflag-d(a5)
		move.w	#$10,priority-d(a5)

.show		moveq	#17,d1
		move.w	actenergy-d(a5),d0
		asr.w	#4,d0
		sub.w	d0,d1
		cmp.w	#13,d1
		bpl.s	.c01
		subq.w	#1,d1
		cmp.w	#6,d1
		bpl.s	.c01	
		subq.w	#1,d1
.c01		move.w	d1,d0
		add.w