This wall of code replaces the code in OP. It's tested in WinUAE on A1200-060 3.1, stock A1200 3.1, A500 3.1 and A500 1.3, and on real A500-ACAPlus-3.1 and A500 1.3.
The code can be run from assembler/CLI/WB as is, but ADF is also attached. If something is resident (such as invoked Early Boot menu, accelerator stuff, or virus), it will report a red color else green, and then wait for LMB=Soft Reset or RMB=Hard Reset. If RMB, it must report green on next bootblock run, or report green on next run from assembler/CLI/WB as long as nothing installs itself resident in s-seq before.
I'm looking for feedback on reliability before I commit. (Edit: Please see the
;** and
must be comments.) Cheers.
Code:
LowMemChkSum=$24
ChkBase=$26
ColdCapture=$2a
CoolCapture=$2e
WarmCapture=$32
EAllocMem=-198
INTENA =$dff09a
DMACON =$dff096
COLOR00 =$dff180
ABSEXECBASE =4 ;Pointer to the Exec library base
MAGIC_ROMEND =$01000000 ;End of Kickstart ROM
MAGIC_SIZEOFFS =-$14 ;Offs from endROM to KS size
V36_EXEC =36 ;Exec with the ColdReboot() function
TEMP_ColdReboot =-726
LIB_VERSION =20 ;offset in Exec
_LVOSupervisor =-$1e
JUMPPTR BootCode ;for assemblers with this function
BOOT: dc.b "DOS",0
dc.l 0,880
BootCode:
move.l 4.w,a6
move.l #BootCodeE-BootStart,d7
*--- alloc ---*
move.l d7,d0 ;size
moveq #2,d1 ;chip
jsr -198(a6) ;AllocMem()
move.l d0,a1
*--- copy ---*
move.l a1,a2
lea BootStart(PC),a0
.copyl: move.b (a0)+,(a1)+
subq.l #1,d7
bne.s .copyl
jmp (a2) ;jump into chipmem
******************** BOOT START ********************
BootStart: ;a6=Execbase
move.w #$272,d1
move.l $2a(a6),d0 ;CHECK COLD- & COOLCAPTURE & KICKTAGPTR
or.l $2e(a6),d0
or.l $22a(a6),d0
beq.s .novirus
move.w #$822,d1
.novirus:
move.w d1,COLOR00 ;signify presence
btst #6,$bfe001 ;no symbols for these, geddoudaheere...
beq.s SoftReset ;LMB:Soft Reset
btst #2,$dff016 ;RMB:Hard Reset
bne.s BootStart ;*magic hand gesture* there is no boot
HardReset:
*--- disable ints and dma ---*
move.w #$4000,INTENA ;disable ints to avoid interference
move.w #$0580,DMACON ;and some DMA to avoid delayed prefetch
clr.w COLOR00 ;cosmetic (avoid random bg color)
*--- clr coldcapture, set other two+nuke chkbase(+lowmemchksum?) ---*
clr.l ColdCapture(a6) ;must be 0
st CoolCapture+3(a6) ;must not be 0
st WarmCapture+3(a6) ;must not be 0
not.l ChkBase(a6) ;must be not correct (clr is unsafe)
*--- normal reset but rebuild Exec ---*
lea.l GoHard(pc),a5 ;<KS20 supervisor address
bra.s _ElbowTemperatureReboot ;** really allow Exec to do it?
SoftReset:
lea.l GoAway(pc),a5 ;<KS20 supervisor address
_ElbowTemperatureReboot: ;a5=GoAway or GoHard
; move.l ABSEXECBASE,a6 ;HRM code minus load of a5,a6
cmp.w #V36_EXEC,LIB_VERSION(a6)
blt.s .pre20
jmp TEMP_ColdReboot(a6) ;Let Exec do it...
;NOTE: Control flow never returns to here
;---- manually reset the Amiga ---------------------------------------------
.pre20: jsr _LVOSupervisor(a6) ;supervise-jump to code at (a5)
;NOTE: Control flow never returns to here
;-------------- MagicResetCode ---------DO NOT CHANGE-----------------------
CNOP 0,4 ;IMPORTANT! Longword align!
GoAway: lea.l MAGIC_ROMEND,a0 ;(end of ROM)
sub.l MAGIC_SIZEOFFS(a0),a0 ;(end of ROM)-(ROM size)=PC
move.l 4(a0),a0 ;Get Initial Program Counter
subq.l #2,a0 ;now points to second RESET
reset ;first RESET instruction
jmp (a0) ;CPU Prefetch executes this
;NOTE: the RESET and JMP instructions must share a longword!
;---------------------------------------DO NOT CHANGE-----------------------
;-------------- MagicResetCode ---------DO NOT CHANGE-----------------------
;sorry, this is a changed copy. 4 bytes inserted, OK. see *
CNOP 0,4 ;IMPORTANT! Longword align!
GoHard: lea.l MAGIC_ROMEND,a0 ;(end of ROM)
sub.l MAGIC_SIZEOFFS(a0),a0 ;(end of ROM)-(ROM size)=PC
move.l 4(a0),a0 ;Get Initial Program Counter
subq.l #2,a0 ;now points to second RESET
st 7.w *Exec made odd to force rebuild
reset ;first RESET instruction
jmp (a0) ;CPU Prefetch executes this
;NOTE: the RESET and JMP instructions must share a longword!
;---------------------------------------DO NOT CHANGE-----------------------
BootCodeE:
******************** BOOT END ********************
ds.b 1024,0 ;filler