mumble
One guy's collection of rants, babble, and 6502.

2012-05-03

BOOTD2.S
logo

NOTE: It took years for me to get (or emulate) hardware other than a disk][ Apple ][e, so it took years for me to realize that the following code works ONLY on ][ series that have a real disk][ controller (or equivalent). The //c and IIgs seem to have code that's much different in the $C600 slotspace.

Oh well, this ups the ante for me to make a version that works with ANY Apple or compatible!

Not that anyone else would care, but I've rewritten the evil "getting my Merlin-fu back" code so it makes more sense. I've also corrected some symbols, as I've disassembled and documented the ProDOS boot block since this stupid trick.

Furthermore, I apologize for the use of <pre>, but using nonbreaking spaces would suck more.

eslingc 20040803

********************************
*DISK][ STUPID TRICKS          *
*ESLINGC 20040803              *
*Merlin8 v2.57                 *
********************************
	 EXP	OFF
	 TR
	 TYP	$FF	;TSYS
*-------------------------------
BOOT	 = $801		;location of boot sector
PPATCH	 = $87A		;ProDOS patch addr
DPATCH	 = $84A		;DOS patch addr
BLKRDFE	 = $912		;ProDOS block reader frontend
UNIT	 = $43		;Unit (%DSSS0000) for ProDOS
RWTSLOAD = $8FE		;page byte of RWTS loader
DRV2PROM = $8636	;modify fake PROM drive byte (depends on controller!)
PROMBASE = $8600	;base for the PROM
C6PROM	 = $C600	;most everyone has slot 6
REALSLT  = $C006	;enable real slots
A1L	 = $3C		;from address for move
A2L	 = $3E		;length for MOVE
A4L	 = $42		;to address for MOVE
MOVE	 = $FE2C	;Monitor MOVE subr
*-------------------------------
* LDAD macro to reduce tedium for fixing adrs bytes
*-------------------------------
LDAD	 MAC		;load 16bit number in 2 locns
	 LDA	#<]1	;lob
	 STA	]2	;little-endian
	 LDA	#>]1	;hob
	 STA	]2+1
	 <<<		;not >>>
*-------------------------------
	 ORG	$2000	;TSYS requirement
*===============================
* relo program and setup
*===============================
	 STA	REALSLT		;ensure we're on real slots
	 LDAD	C6PROM;A1L	;from slot ROM
	 LDAD	PROMBASE;A4L	;to RAM "PROM"
	 LDAD	C6PROM+255;A2L	;len=$100
	 LDY	#0
	 JSR	MOVE		;go move it
	 LDAD	STUB;A1L	;move the stub
	 LDAD	PROMBASE+$F8;A4L ;to PROM base
	 LDAD	SEND-1;A2L	;amount of code to move
	 LDY	#0
	 JSR	MOVE	;getem
	 INC	DRV2PROM	;make PROM boot from drive 2
	 JMP	PROMBASE	;boot from drive2
*===============================
* end of relo program
* the new end of the disk][ PROM follows
*===============================
STUB				;let edasm do the relo work
	 ORG	PROMBASE+$F8	;the stub assembles at $86f8, this is also controller-dependent
	 PHA			;save A register in case of ProDOS
	 LDA	BOOT
	 CMP	#$38		;ProDOS/SOS?
	 BEQ	:PRODOS		;yes
	 LDA	#$4C		;else, assume DOS and pray
	 STA	DPATCH
	 LDAD	DOS33ENT;DPATCH+1	;jump to DOS 3.3 stub
	 PLA			;restore A register
	 JMP	BOOT		;proceed to "boot"
:PRODOS	 LDAD	PENT;PPATCH	;program loader to JSR to our stub
	 PLA			;restore A reg
	 JMP	BOOT		;(re)enter into $0801 loader
PENT	 PHP			;save proc status jic
	 LDA	UNIT		;get slot/drive
	 ORA	#%10000000	;turn on drive 2
	 STA	UNIT		;make it so
	 PLP			;get original proc status
	 JMP	BLKRDFE		;carry on to block reader
DOS33ENT LDA	RWTSLOAD	;get RWTS loader page
	 STA	:DOSP+2		;self-modify to get relocating DOSes
	 LDA	#2		;drive 2
:DOSP	 STA	$C607		;into $x707 (make sure this is a 3byte)
	 JMP	(RWTSLOAD-1)	;jump to RWTS loader
	 ORG			;apparently will return to $20xx this way
SEND				;EOF(relo code)

( link )

I got yer can Home