
* FixRamlib patch module for RemAPollo
* fixes problems with ramlib module on KS 2x
* (data registers trashing on init time)

* must be applied if you want to use external RT_AFTERDOS resident modules
* on KS2x

* based on BlizKick [(c) Harry Sintonen] interface
* Public Domain
* coded by MM in 2000


	moveq	#'z',d0			;BKMODULE_ID
	rts

	dc.l	$4e71			;BKEP_ID

	moveq	#0,d7
	move.l	a1,-(sp)
	lea	(_name,pc),a1		; _FindResident
	jsr	(a2)
	move.l	(sp)+,a1
	tst.l	d0
	beq	.exit
	move.l	d0,a2

	move.b	(11,a2),d0
	cmpi.b	#36,d0
	bcs	.exit
	cmpi.b	#39,d0
	bcc	.exit

	move.l	($16,a2),d0		;init
	sub.l	a1,d0
	adda.l	d0,a0

	cmpi.l	#$48e70034,(a0)+
	bne	.out
	move.b	#$38,(-2,a0)		;fix starting movem
.find	cmpi.w	#$4e75,(a0)+
	bne	.find
	cmpi.l	#$4cdf2c00,(-6,a0)
	bne	.out
	move.b	#$1c,(-3,a0)		;fix ending movem
	
	moveq	#1,d7
.out	move.l	d7,d0
	rts

.exit	lea	(_error1,pc),a0		; a0=fmt
	suba.l	a1,a1
	jsr	(a4)			; Call _Printf
	bra	.out

_name	dc.b	'ramlib',0

_error1	dc.b	'FixRamlib: This patch requires Kickstart 2x!',10,0
	dc.b	'$VER: FixRamlib_PATCH 1.0 (14.5.2000)',13,10,0
