; *** Super WonderBoy Hard Disk Loader V1.0
; *** Written by Jean-François Fabre

; *** Needs 1.5MB of memory to run
; *** 1.5MB of fast memory to be able to quit.


	include	"/lib/libs.i"
	include	"/lib/macros.i"
	include	"/lib/refs.i"

_loader:
	Mac_printf	"Super Wonderboy HD Loader V1.0"
	Mac_printf	"Programmed by Jean-François Fabre © 1997"

	JSRABS	LoadDisks
	JSRABS	TransfRoutines

	moveq.l	#0,D0
	move.l	#CACRF_CopyBack,D1
	JSRABS	Degrade

	GO_SUPERVISOR
	SAVE_OSDATA	$80000
	move	#$2700,SR

	GETUSRADDR	BootGame
	move.l	D0,A0
	jmp	(A0)
	
_UserPatchRoutines:
	cnop	0,4

BootGame:
	JSRGEN	InitTrackDisk
	
	move.w	#2,$1C(A1)
	move.l	#$80C00,$2C(A1)
	move.l	#$33400,$24(A1)
	move.l	#$400,$28(A1)
	JSRGEN	TrackLoadFast

	PATCHUSRJMP	$D03C,PatchLoad
	PATCHUSRJSR	$CC22,KbInt

	; **** boot stuff and patch

	JSRGEN	FlushCachesHard

	nop	
	nop
	JMP	$400.W
	nop
	nop

KbInt:
	lea	$CCE5,A0
	cmp.b	#$59,D1
	bne	noquit$
	JSRGEN	InGameExit
noquit$
	rts

PatchLoad:
	STORE_REGS

	mulu	#$200,D0
	move.l	D0,A0
	moveq.l	#0,D0
	JSRGEN	GetDiskPointer
	add.l	D0,A0

copy$
	move.b	(A0)+,(A1)+
	subq.l	#1,D1
	bne	copy$

	RESTORE_REGS
	move.l	(A7)+,A0	; original game
	rts


_user_pbuffer:
	dc.l	0
_general_pbuffer:
	dc.l	0
_EndUserPatchRoutines:

	HD_PARAMS	"swboy.d","CON:20/20/350/200/Super WonderBoy HD Loader",STD_DISK_SIZE,1

