*******************************************************************************
****                  Boot It V1.01 ½ 1992-1993 Joe Tapply                 ****
*******************************************************************************
****	With any luck this program should boot most ST boot sectors from   **** 	
****       the desktop,on TTs with and perhaps even without TT-RAM.        ****
*******************************************************************************
****	     USE THIS PROGRAM AT YOUR OWN RISK!I WILL NOT ACCEPT ANY       **** 
****    RESPONSIBILITY FOR ANY DAMAGE OR INJURY(!) RESULTING FROM THE      ****
****                USE OR MISUSE OF THIS CODE.                            ****
*******************************************************************************

*O.K. Here is the source,it was written and assembled using Decpac TT/Devpac 3.
*This code is pretty dirty,but it works!

*It is really easy to use - just set your TT to the appropriate resolution 
* (probably ST low),stick the boot disk in drive A and run this!

*Good luck,have fun,Joe Tapply. (jdmt@dcs.ed.ac.uk)
 	
 	
	comment	HEAD=$7		Set header to load into TT ram etc..
	bra	start

*Before we run the boot sector,we should set up the '030's cache:
*The various options for cache_flags are:
* $3111 - Turn both caches on, 
* $3110 - No instruction cache,but data cache enabled,
* $0000 - Turn both caches off

cache_flags	equ	$3110	


boot_drive	equ	$446
super		equ	$20
phystop		equ	$42e


start

	clr.l	-(sp)
	move.w	#super,-(sp)	Into super mode
	trap	#1
	addq.l	#6,sp
	lea	old_ssp,a0
	move.l	d0,(a0)	

	lea	buffer(pc),a6
	
	lea	start(pc),a0		where are we running?
	cmp.l	#$0100000,a0	
	bge.s	we_are_in_TT_RAM	

*If this code is running in ST RAM,we should put the boot-sector 
*somewhere safe - just above the screen seems like a good place:
  
	move.l	phystop,a6	Find the top of ST RAM
	lea	-512(a6),a6	and use the top 512 bytes.

we_are_in_TT_RAM

*Now we load the bootsector 

	move.w	#1,-(sp)	read 1 sector
	move.w	#0,-(sp)	from side 0,
	move.w	#0,-(sp)	track 0,
	move.w	#1,-(sp)	sector 1 is the boot sector,
	move.w	#0,-(sp)	from drive A,
	move.l	#0,-(sp)	
	move.l	a6,-(sp)	load it to here
	move.w	#8,-(sp)	XBIOS read sectors
	trap	#14
	lea	20(sp),sp
	
	tst.l	d0		Did we get an error
	bmi.s	going_home	Yes,so exit.	
*This bit sets up the '030's cache

	move.l	#cache_flags,d0
	movec.l	d0,cacr
	
	move.w	#0,boot_drive	we booted from drive A

	jsr	(a6)		run the bootsector

*We should NOT get back here,but just incase...	

going_home
	move.l	old_ssp(pc),-(sp)
	move.w	#super,-(sp)
	trap	#1			back to user mode
	addq.l	#6,sp
	
	clr.w	-(sp)			bye!
	trap	#1

old_ssp
	dc.l	0

	section BSS	
buffer
	ds.w	512
	
	