dth*3*3(a0),d1
		and.l	d3,d1
		bne	.add6
	
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c20
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c20		move.l	_scrwidth*3*3(a0),d1
		and.l	d3,d1
		bne	.add7
		bra	.fall
	
.testnofall2	cmp.b	#18,(a4,d2.w)
		bne	.nofall4
		bra	.fall

	
	
.rough2		cmp.w	#$94,manypos-d(a5)
		bpl.s	.testnofall2
		lea	falltab-d(a5),a0
		move.w	fallpos-d(a5),d0
		move.w	(a0,d0.w),d4
		
		moveq	#0,d0
		move.b	(a4,d2.w),d0
		sub.w	#14,d0
		move.w	d0,blktype-d(a5)
		moveq	#0,d0
		move.w	manxpos-d(a5),d0
		add.l	xsoftabs-d(a5),d0
		add.l	#47,d0
		move.w	d0,d2
		lsr.l	#4,d0
		add.l	d0,d0

		move.l	multab-d(a5),a0		
		move.w	manypos-d(a5),d1
		add.w	ysoft-d(a5),d1
		add.w	ysoftpos-d(a5),d1
		add.w	#67,d1
		cmp.w	#_scrheight,d1
		bmi.s	.c1
		sub.w	#_scrheight,d1
.c1		move.w	d1,d7
		add.w	d1,d1
		add.w	d1,d1
		add.l	(a0,d1.w),d0
		add.l	orig-d(a5),d0
		move.l	d0,a0
		
		move.l	#$fe000000,d3
		and.w	#$f,d2
		lsr.l	d2,d3

		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.sub4
		
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c22
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c22		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.sub3
		
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c21
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c21		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.sub2
		
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c6
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c6		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.sub1
		
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c5
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c5		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add0
		
		subq.w	#1,d4
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c2
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c2		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add1
		
		subq.w	#1,d4
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c3
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c3		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add2

		subq.w	#1,d4
		bmi	.fall
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c4
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c4		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add3

		subq.w	#1,d4
		bmi	.fall
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c7
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c7		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add4
		
		subq.w	#1,d4
		bmi	.fall
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c8
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c8		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add5

		subq.w	#1,d4
		bmi	.fall
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c9
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c9		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add6
		
		subq.w	#1,d4
		bmi	.fall
		lea	_scrwidth*_scrdepth*3(a0),a0
		addq.w	#1,d7
		cmp.w	#_scrheight,d7
		bmi.s	.c10
		sub.w	#_scrheight,d7
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,a0
.c10		move.l	(a0),d1
		or.l	_scrwidth*3*2(a0),d1
		or.l	_scrwidth*3*3(a0),d1
		not.l	d1
		and.l	_scrwidth*3(a0),d1
		and.l	d3,d1
		bne	.add7
		bra	.fall

.add7		addq.l	#7,absmanypos-d(a5)
		addq.w	#7,manypos-d(a5)
		bra.s	.add0

.add6		addq.l	#6,absmanypos-d(a5)
		addq.w	#6,manypos-d(a5)
		bra.s	.add0

.add5		addq.l	#5,absmanypos-d(a5)
		addq.w	#5,manypos-d(a5)
		bra.s	.add0

.add4		addq.l	#4,absmanypos-d(a5)
		addq.w	#4,manypos-d(a5)
		bra.s	.add0

.add3		addq.l	#3,absmanypos-d(a5)
		addq.w	#3,manypos-d(a5)
		bra.s	.add0

.add2		addq.l	#2,absmanypos-d(a5)
		addq.w	#2,manypos-d(a5)
		bra.s	.add0

.add1		addq.l	#1,absmanypos-d(a5)
		addq.w	#1,manypos-d(a5)
		bra.s	.add0
		
.sub4		subq.l	#4,absmanypos-d(a5)
		subq.w	#4,manypos-d(a5)
		bra.s	.add0
		
.sub3		subq.l	#3,absmanypos-d(a5)
		subq.w	#3,manypos-d(a5)
		bra.s	.add0
		
.sub2		subq.l	#2,absmanypos-d(a5)
		subq.w	#2,manypos-d(a5)
		bra.s	.add0
		
.sub1		subq.l	#1,absmanypos-d(a5)
		subq.w	#1,manypos-d(a5)

.add0		bsr	teststauch
		moveq	#0,d0
		move.w	d0,fallpos-d(a5)
		move.w	d0,fallspeed-d(a5)
		move.w	d0,fallflag-d(a5)
		rts

teststauch	cmp.w	#80,fallpos-d(a5)
		bmi.s	.ok
		sub.w	#32,energy-d(a5)
		cmp.w	#4,energy-d(a5)
		bpl.s	.ok2
		move.w	#1,deathflag-d(a5)
		move.w	#$10,priority-d(a5)
		bra.s	.ok

.ok2		move.w	#1,stauchflag-d(a5)
		move.w	#32,ouchflag-d(a5)

.ok		rts	
;------------------------------------------------
calcblockno	calcblockno_m
;------------------------------------------------
jump		lea	d(pc),a5
		move.w	jumpflag-d(a5),jumpflag2-d(a5)
		tst.w	jumpflag-d(a5)
		beq	.end

		moveq	#18,d0
		moveq	#16,d1
		bsr	calcblockno
		move.w	(a0),d0
		and.w	#$fc00,d0
		cmp.w	#$e800,d0
		beq.s	.off

		lea	jumptab-d(a5),a0
		move.w	jumppos-d(a5),d0
		moveq	#0,d1
		move.w	(a0,d0.w),d1
		sub.w	d1,manypos-d(a5)
		sub.l	d1,absmanypos-d(a5)
		move.w	d1,jumpspeed-d(a5)

		tst.w	jumphold-d(a5)
		beq.s	.c1
		subq.w	#1,jumphold-d(a5)
		bra.s	.end

.c1		addq.w	#2,jumppos-d(a5)
		cmp.w	#12,d0
		bne.s	.end
.off		clr.w	jumpflag-d(a5)
		clr.w	jumphold-d(a5)
		clr.w	outoflorry-d(a5)
.end		rts

setjump		tst.w	jumpflag-d(a5)
		bne.s	.end
		move.w	#1,jumpflag-d(a5)
		clr.w	jumppos-d(a5)
		move.w	#4,janimcount-d(a5)
		tst.w	jumphold-d(a5)
		bne.s	.end
		move.w	#14,jumphold-d(a5)
.end		rts

*****
;------------------------------------------------
duck		lea	d(pc),a5
		clr.w	duckdir-d(a5)
		cmp.w	#8,duckpos-d(a5)
		beq.s	.end
		addq.w	#1,duckcount-d(a5)
		cmp.w	#3,duckcount-d(a5)
		bne.s	.end
		move.w	#0,duckcount-d(a5)
		addq.w	#4,duckpos-d(a5)
.end		rts	

standup		lea	d(pc),a5
		move.w	#1,duckdir-d(a5)
		tst.w	duckpos-d(a5)
		beq.s	.end
		addq.w	#1,duckcount-d(a5)
		cmp.w	#3,duckcount-d(a5)
		bne.s	.end
		move.w	#0,duckcount-d(a5)
		subq.w	#4,duckpos-d(a5)
.end		rts

;------------------------------------------------
getobj		move.l	nm-d(a5),a0
		moveq	#_nmeno-1,d7
.l1		cmp.w	nmobj(a0),d0
		beq.s	.c1
		addq.l	#4,a0
		dbra	d7,.l1
.c1		rts
;------------------------------------------------
boatride	tst.w	boatrideflag-d(a5)
		bne.s	.end
		move.w	boatflag-d(a5),d0
		cmp.w	#2,d0
		bpl.s	.doride
		moveq	#22,d0
		bsr	getobj
		tst.w	d7
		bpl.s	.c1
		clr.w	boatflag-d(a5)
.end		rts
.c1		move.l	absmanxpos-d(a5),d1
		move.w	nmxpos(a0),d0
		sub.w	#56,d0
		cmp.w	d1,d0
		bpl.s	.c2
		addq.w	#8,d0
		cmp.w	d1,d0
		bmi.s	.c3
		addq.w	#1,boatflag-d(a5)
		rts
.c2		move.w	#$0003,actstick-d(a5)
		bra	stickx
.c3		move.w	#$0300,actstick-d(a5)
		bra	stickx
		
.doride		cmp.w	#5,d0
		bmi.s	.c6
		tst.w	animdir-d(a5)
		beq.s	.c4
		cmp.w	#25,d0
		bpl.s	.c5
		cmp.w	#15,d0
		bmi.s	.c6
		move.w	#$0001,actstick-d(a5)
.c6		addq.w	#1,boatflag-d(a5)
		bsr	stickx
		bra	sticky
		
.c5		move.w	#1,boatrideflag-d(a5)
		rts
		
.c4		move.w	#$3,actstick-d(a5)
		bra	stickx

;------------------------------------------------
ropedown	cmp.w	#2,ropedownflag-d(a5)
		beq	sticky2
		cmp.w	#4,ropedownflag-d(a5)
		beq	.next
		tst.w	turnflag-d(a5)
		bne	.ret
		cmp.w	#5,ropedownflag-d(a5)
		beq	.next3
		cmp.w	#6,ropedownflag-d(a5)
		beq	.next2

		move.w	#10,turnflag-d(a5)
		move.w	#2,turncount-d(a5)
		move.w	#1,turned-d(a5)
		addq.w	#1,ropedownflag-d(a5)
		rts
		
.next		cmp.w	#27,ropedowncount-d(a5)
		beq.s	.c1
		addq.w	#1,ropedowncount-d(a5)
		rts

.next3		add.w	#19,manypos-d(a5)
		add.l	#19,absmanypos-d(a5)
		addq.w	#1,ropedownflag-d(a5)
		
.next2		tst.w	ropedowncount-d(a5)
		beq.s	.c2
		subq.w	#1,ropedowncount-d(a5)
		rts
		
.c1		move.w	#11,turnflag-d(a5)
		move.w	#27,turncount-d(a5)
		clr.w	turned-d(a5)

		clr.w	ropeflag-d(a5)
		clr.w	ropedownflag-d(a5)
		clr.w	ropedowncount-d(a5)
		clr.w	runyofs-d(a5)
		sub.w	#16,manypos-d(a5)
		sub.l	#16,absmanypos-d(a5)
.ret		rts
		

.c2		addq.w	#1,manypos-d(a5)
		addq.l	#1,absmanypos-d(a5)
		move.w	#2,ropedownflag-d(a5)
		clr.w	ropedowncount-d(a5)
		move.w	#8,ropeanimpos-d(a5)
		clr.w	ropeanimcount-d(a5)
		rts

;------------------------------------------------
stick		tst.w	testflag-d(a5)
		bne.s	.test
		tst.w	enterflag2-d(a5)
		bne	.enter
		tst.w	leaveflag2-d(a5)
		bne	.leave
		tst.w	ropedownflag-d(a5)
		bne.s	.c4	
		tst.w	ropeflag-d(a5)
		bne.s	.c5
		tst.w	boatflag-d(a5)
		beq.s	.c1
		bsr	boatride
		bra.s	.c2
.c4		bsr	ropedown
		bra.s	.c2
.c5		bsr	sticky2
		bra.s	.c2

.c1		tst.w	ouchflag-d(a5)
		bmi.s	.c8
		bne.s	.c7
.c8		bsr	testfall
		bsr	stickx
		bsr	sticky
.c2		rts

.c7		tst.w	stauchflag-d(a5)
		bne.s	.c01
		bsr	testfall
.c01		rts

.test		bsr	teststick
		rts

.enter		cmp.w	#40,enterflag2-d(a5)
		beq.s	.enter2
		addq.w	#1,enterflag2-d(a5)
		rts
.enter2		move.w	#1,enterflag-d(a5)
		rts		

.leave		cmp.w	#50,leaveflag2-d(a5)
		beq.s	.leave2
		addq.w	#1,leaveflag2-d(a5)
		rts
.leave2		move.w	#1,leaveflag-d(a5)
		rts		
;------------------------------------------------
teststick	teststick_m
;------------------------------------------------
stickx		lea	d(pc),a5
		tst.w	punchcount2-d(a5)
		bne	.mid
		cm