; CheckPAL.asm V0.0

; by Neil Matthews
;	Henley Beach
;	South Australia

; Checks VBlankFrequency and does Hardware RESET if 60Hz


	INCLUDE "exec/funcdef.i"
	INCLUDE "exec/types.i"
	INCLUDE "exec/exec_lib.i"



CheckPAL:	movea.l	$0004,A6	; Get Exec's location in A6
		cmpi.b	#50,$0212(A6)	; Check if VBlankFrequency stored $212
		bne.s	_ColdReboot	;  offset from Exec pointer is 50Hz
		rts			; OK VBlankFrequency value is 50Hz



;	From Amiga Harware Manual- release 2, page 219
;	Commodore's "*only* supported reboot code"

; Forces a reboot of the system for all Amiga models


_ColdReboot:

	move.l	4,A6			;Get pointer to ExecBase
	lea.l	MagicResetCode(PC),A5	;Location of code to trap to
	jsr	_LVOSupervisor(A6)	;Start code (must use JSR)

	CNOP	0,4	;IMPORTANT: Must be longword aligned

MagicResetCode:

	lea.l	2,A0	;Point to JMP instruction at start of ROM
	RESET		;all RAM goes away now!
	jmp	(A0)	;Rely on prefetch to execute this instruction

	END

