	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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*3(a0),d1
		and.l	d3,d1
		bne.s	.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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*3(a0),d1
		and.l	d3,d1
		bne.s	.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	_scrwidth*3(a0),d1
		not.l	d1
		and.l	(a0),d1
		and.l	_scrwidth*3*2(a0),d1
		and.l	_scrwidth*3*3(a0),d1
		and.l	d3,d1
		bne.s	.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

		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
		clr.w	jumpflag-d(a5)
		clr.w	jumphold-d(a5)
		clr.w	swsinkflag2-d(a5)
		tst.w	swsinkflag-d(a5)
		beq.s	.end2
		move.w	#1,swsinkflag2-d(a5)
.end2		clr.w	swsinkflag-d(a5)		
.end		rts

setjump		tst.w	jumpflag-d(a5)
		bne.s	.end
		move.w	#1,jumpflag-d(a5)
		move.w	#0,jumppos-d(a5)
		move.w	#4,janimcount-d(a5)
		move.w	#14,jumphold-d(a5)
		tst.w	swsinkflag-d(a5)
		beq.s	.end
		move.w	#4,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	#5,d0
		bmi.s	.c001
		cmp.w	#6,d0
		bpl.s	.doride
		moveq	#22,d0
		bsr	getobj
		tst.w	d7
		bpl.s	.c1
		clr.w	boatflag-d(a5)
.end		rts

.c001		addq.w	#1,boatflag-d(a5)
		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	#9,d0
		bmi.s	.c6
		tst.w	animdir-d(a5)
		beq.s	.c4
		cmp.w	#29,d0
		bpl.s	.c5
		cmp.w	#19,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	.ropeup
		cmp.w	#3,ropedownflag-d(a5)
		beq	.ropeup2
		tst.w	ropedowncount-d(a5)
		bne	.c1
		moveq	#20,d0
		bsr	getobj
		tst.w	d7
		bpl.s	.c2
		clr.w	ropedownflag-d(a5)
		rts

.c2		clr.w	priority-d(a5)
		lea	sprpri+2,a1
		add.l	(_nmem).w,a1
		move.w	priority-d(a5),(a1)

		move.w	nmypos(a0),d0
		add.w	#16,d0
		and.w	#$fff0,d0
		move.w	d0,ropeypos-d(a5)
		move.w	d0,ropeystartpos-d(a5)
		move.w	nmxpos(a0),d0
		and.w	#$fff0,d0
		move.w	d0,ropexpos-d(a5)
		move.l	nmstartblk(a0),d0
		add.l	#_levwidth,d0
		move.l	d0,ropeblk-d(a5)
		move.l	d0,ropestartblk-d(a5)
		move.l	ysoftabs-d(a5),d1
		move.w	ropeypos-d(a5),d0
		sub.w	d1,d0
		add.w	ysoft-d(a5),d0
		cmp.w	#_scrheight,d0
		bmi.s	.c5
		sub.w	#_scrheight,d0
.c5		mulu	#_scrwidth*_scrdepth*3,d0
		move.l	d0,ropeadr-d(a5)
		moveq	#-2,d0
		move.l	d0,ropeoldadr-d(a5)
		addq.w	#1,ropedowncount-d(a5)
		rts
		
.c1		cmp.w	#6,ropedowncount-d(a5)
		bmi	.anim2
		cmp.w	#7,ropedowncount-d(a5)
		bpl	.anim
		move.l	agaabsmanxpos-d(a5),d0
		asr.l	#2,d0
		moveq	#72,d1
		tst.w	animdir-d(a5)
		beq.s	.c11
		moveq	#74,d1
.c11		add.w	d1,d0
		cmp.w	ropexpos-d(a5),d0
		beq.s	.c6
		bmi.s	.c7
		move.w	#$0300,actstick-d(a5)
		bra	stickx2
.c7		move.w	#$0003,actstick-d(a5)
		bra	stickx2
.c6		and.w	#$fffc,xsoft-d(a5)
		and.w	#$fffc,agamanxpos-d(a5)
		and.l	#$fffffffc,agaabsmanxpos-d(a5) 
		and.l	#$fffffffc,agaxsoftabs-d(a5) 

		move.l	ropeblk-d(a5),a0
		move.w	#20,(a0)
		add.l	#_levwidth,ropeblk-d(a5)
		move.l	ropeadr-d(a5),d0
		move.w	ropeypos-d(a5),d4
		add.w	#16,ropeypos-d(a5)
		add.l	#_scrwidth*_scrdepth*3*16,ropeadr-d(a5)
		cmp.l	#_scrwidth*_scrdepth*3*_scrheight,ropeadr-d(a5)
		bmi.s	.c9
		sub.l	#_scrwidth*_scrdepth*3*_scrheight,ropeadr-d(a5)
.c9		move.l	ysoftabs-d(a5),d1
		and.w	#$fff0,d1
		add.w	#_scrheight-16,d1
		cmp.w	d4,d1
		bmi	.c3
		moveq	#0,d1
		move.w	ropexpos-d(a5),d1
		lsr.w	#4,d1
		add.w	d1,d1
		add.l	d1,d0
		subq.l	#4,d0
		move.l	d0,d1
		move.l	ropeoldadr-d(a5),d2
		move.l	d0,ropeoldadr-d(a5)
		add.l	orig-d(a5),d0
		add.l	draw-d(a5),d1
		waitblt
		move.l	#$09f00000,$40(a6)
		move.l	#$ffffffff,$44(a6)
		move.w	#38,$64(a6)
		move.w	#(_scrwidth*3)-2,$66(a6)
		move.l	#lgraph+32+160*16,d3
		add.l	(_nmem).w,d3
		move.l	d3,$50(a6)
		move.l	d0,$54(a6)
		move.w	#64*4*16+1,$58(a6)
		waitblt
		waitblt
		move.l	#lgraph+32+160*16,a0
		add.l	(_nmem).w,a0
		move.l	a0,$50(a6)
		move.l	d1,$54(a6)
		move.w	#64*4*16+1,$58(a6)
		tst.l	d2
		bmi.s	.c3
		add.l	draw-d(a5),d2
		waitblt
		move.l	#lgraph+32+160*16,a0
		add.l	(_nmem).w,a0
		move.l	a0,$50(a6)
		move.l	d2,$54(a6)
		move.w	#64*4*16+1,$58(a6)
.c3		move.l	ropeblk-d(a5),a0
		tst.w	(a0)
		bne	.c10
		rts
		
.c10		or.w	#(29<<10),-_levwidth(a0)
		addq.w	#1,ropedowncount-d(a5)
		move.w	#1,ropeflag-d(a5)
.end		rts
		
.anim		lea	.ltab2(pc),a2
		tst.w	animdir-d(a5)
		beq.s	.ac2
		lea	.rtab2(pc),a2
.ac2		move.w	ropedowncount-d(a5),d0
		subq.w	#7,d0
;		cmp.w	#2,d0
		beq.s	.res3
		bpl.s	.res2
.da01		add.w	d0,d0
		add.w	d0,d0
.doanim		move.l	_xmem,a0		;mananim
		add.l	#_manofs,a0
		add.l	(a2,d0.w),a0
		lea	_sprite,a1
		add.l	(_nmem).w,a1
		bsr	copyanim
		lea	d(pc),a5
		addq.w	#1,ropedowncount-d(a5)
		rts
		
.anim2		lea	.ltab(pc),a2
		tst.w	animdir-d(a5)
		beq.s	.ac1
		lea	.rtab(pc),a2
.ac1		move.w	ropedowncount-d(a5),d0
		subq.w	#1,d0
		add.w	d0,d0
		add.w	d0,d0
		bra.s	.doanim
		
.res3		moveq	#24,d3
		add.l	d3,absmanypos-d(