*****************************************************************************
**                                                                         **
** Eagleripper: Sean Connolly                                              **
**                                                                         **
** Project: Eagleplayer 2.04                                               **
** Authors: Jan Blumenthal & Henryk Richter                                **
** Start  : 1993/01/09                                                     **
** $Header$                                                                **
**                                                                         **
*****************************************************************************
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program (See the included file COPYING);
** if not, write to the Free Software Foundation, Inc.,
** 675 Mass Ave, Cambridge, MA 02139, USA.
**
***************************************************************************** 


*-----------------------------------------------------------------------------*
*			      Eagleripper V1.0				      *
*				Sean Connolly				      *
*-----------------------------------------------------------------------------*
Test	= 0
		incdir	include:
		include	misc/eagleplayerripper.i
		include	exec/exec_lib.i
			
	if	Test
	lea	data,a0
	*lea	SC_Tags,a0
	move.l	#datasize,d0
	move.l	a0,a5
	move.l	a0,a4
	move.l	d0,d4
	move.l	d0,d6
wait:	move.l	a5,a1
	move.l	a4,a0
	move.l	d4,d0
	move.l	(a1),d1
	bsr	SC_Ripp1
	tst.l	d0
	beq.s	.Ja
	addq.l	#2,a5
	subq.l	#2,d6
	blt.s	.Err
	btst	#6,$bfe001
	bne.s	wait
.err:	moveq	#-1,d0
.ret:	illegal

.ja:	move.l	d1,d0
	*bsr	GetModuleName
	bra.s	.Ret
	endc
		RIPPERHEADER	SC_Tags

	dc.b	"Sean Connolly EagleRipper V1.0",10
	dc.b	"done by Eagleeye/DFT 28.08.97",0
	even

SC_Tags:	dc.l	RPT_Formatname,.Formatname
		dc.l	RPT_Ripp1,SC_Ripp1
		dc.l	RPT_RequestRipper,1
		dc.l	RPT_Version,1<<16!0
		dc.l	RPT_Creator,.Creator
		dc.l	RPT_Prefix,.Prefix
		dc.l	RPT_Playername,.Playername
		dc.l	0

.Creator:	dc.b	"Sean Connolly, adapted by DEFECT",0
.Playername:
.Formatname:	dc.b	"Sean Connolly",0
.Prefix:	dc.b	"SCN.",0
		even

*-----------------------------------------------------------------------------*
* Input: a0=Adr (start of memory)
*	 d0=Size (size of memory)
*	 a1=current adr
*	 d1=(a1.l)
* Output:d0=Error oder NULL
*	 d1=Size
*	 a0=Startadr (data)
*-----------------------------------------------------------------------------*
SC_Ripp1:	lsr.l	#8,d1
		lsr.l	#8,d1
		cmp.w	#$6000,d1
		beq.s	.Ja
		rts

		*--- Jetzt testen, ob es ein korrektes Module sein kann ---*
.Ja:		cmp.w	#$6000,(a1)
		bne.w	.Return
		cmp.w	#$6000,4(a1)
		bne.w	.Return
		cmp.w	#$6000,8(a1)
		bne.w	.Return
		cmp.w	#$6000,12(a1)
		bne.w	.Return

		*--- ersten Jump testen ---*
		moveq	#0,d2
		move.w	2(a1),d2			;Offset negativ ?
		blt.w	.Return
		cmp.l	d0,d2
		bhi.w	.Return
		lea	2(a1,d2.w),a0
		cmp.l	#$48e740f0,(a0)
		bne.s	.Type2
		cmp.w	#$4a00,4(a0)
		beq.s	.Jump2
.Type2:		cmp.l	#$48e77ffe,(a0)
		bne.w	.Return
		cmp.l	#$e98841fa,4(a0)
		bne.w	.Return
		

		*--- zweiten Jump testen ---*
.Jump2:		moveq	#0,d2
		move.w	6(a1),d2			;Offset negativ ?
		blt.w	.Return
		cmp.l	d0,d2
		bhi.w	.Return
		lea	6(a1,d2.w),a0
		cmp.l	#$48e7fffe,(a0)
		beq.s	.Jump2_2
		cmp.l	#$48e77ffe,(a0)
		bne.w	.Return
.Jump2_2:	cmp.l	#$e98841fa,4(a0)
		beq.s	.Jump3
		cmp.l	#$70001039,4(a0)
		bne.s	.Return
		cmp.l	#$00dff006,8(a0)
		bne.s	.Return

		*--- dritten Jump testen ---*
.Jump3:		moveq	#0,d2
		move.w	10(a1),d2			;Offset negativ ?
		blt.s	.Return
		cmp.l	d0,d2
		bhi.s	.Return
		lea	10(a1,d2.w),a0
		cmp.l	#$48e7fffe,(a0)
		bne.s	.Type1
		cmp.w	#$41fa,4(a0)
		beq.s	.Jump4
.Type1:		cmp.l	#$48e720e0,(a0)
		bne.s	.Return
		cmp.l	#$02800000,4(a0)
		bne.s	.Return
		cmp.l	#$00030281,8(a0)
		bne.s	.Return

		*--- vierten Jump testen ---*
.Jump4		moveq	#0,d2
		move.w	14(a1),d2			;Offset negativ ?
		blt.s	.Return
		cmp.l	d0,d2
		bhi.s	.Return
		lea	14(a1,d2.w),a0
		cmp.l	#$2f080240,(a0)
		beq.s	.Ja2
		cmp.l	#$4df900df,(a0)
		bne.s	.Return
		cmp.l	#$f0007000,4(a0)
		bne.s	.Return

.Ja2:		move.l	a1,a0
		moveq	#0,d0
		moveq	#-1,d1
.Return:	rts




	if	test
data:		incdir	"Modules:Verschiedenes/"
	*	ds.b	200

		*incbin	"SCN.SoccerSuperstarsAGA"
		*incbin	"SCN.SurfNinjas Ingame"
		incbin	"SCN.SurfNinjasCD32_Intro"






datasize	= *-data
	endc


