;
; $VER: Reboot.a V1.0 recoded in 100% assembly
;
; Reboot v1.0  100% assembly!
; Written by Mauro Panigada
;
; Version with confirmation (see also ColdReboot.a)
;
; (FREEWARE) It needs OS2.0+
;
; STARTED: 02/04/1996
;
; Original by Max Francis, coded in C (7368 bytes!)
; USAGE: Reboot
;
; Perform an immediate cold reboot.
;
; NOTE: This is simply a remake from "MF WBTools Reboot.c" by Max Francis,
; written in C. It is my second remake from Max Francis' program. You can
; also find DFree and DFree2, the first rough, the second better (and
; better and better than Max's C version!). The Max version often are
; copyrighted (or no?), but I note that NO PART OF CODE ARE USED OR STOLEN
; IN MY OWN VERSION (FREEWARE); I only got C-idea and converted it
; in an assembly-program.
;
; GOOD QUALITIES: My own version's shorter. Very shorter. A question for
; Max Francis: do you know that a program which only call amiga-system
; routine for a cold reset (or for getting information, as in DFree)
; longer than 1000 bytes is obsolete? Kill your C and make assembly alive
; for these simple programs... Just a suGGestion!
;
; ADDED NOTE: The same of ColdReboot, but with confirmation... So HE did!
; ADDED QUALITIES: ColdReboot + Reboot < 1000 bytes! (MY version)
; ColdReboot + Reboot > 11000 bytes!!! (HIS version)
;

		incdir	"dh0:progr/assem/include/"
		include	"exec/types.i"
		include	"exec/libraries.i"
		include	"exec/exec_lib.i"
		include	"dos/dos_lib.i"


		bra.s	start

		dc.b	"$VER: ColdReboot v1.0 written by Mauro Panigada"
		dc.b	0
		even

start		move.b	d0,d6
		lea	dosname(pc),a1
		moveq	#36,d0
		movea.l	4.w,a6
		jsr	_LVOOpenLibrary(a6)
		tst.l	d0
		beq.s	exit0
		cmp.b	#1,d6
		bne.s	help_scr
		move.l	d0,a6
		lea	confirm(pc),a0
		move.l	a0,d2
		moveq	#clen,d3
		jsr	_LVOOutput(a6)
		move.l	d0,d1
		jsr	_LVOWrite(a6)
		jsr	_LVOInput(a6)
		move.l	d0,d1
		lea	buffer(pc),a0
		move.l	a0,d2
		move.l	a0,a3
		moveq	#2,d3
		jsr	_LVORead(a6)
		cmp.b	#"Y",(a3)
		bne.s	abort
cr		move.l	4.w,a6
		jmp	_LVOColdReboot(a6)
abort		lea	ab(pc),a0
		move.l	a0,d1
		jsr	_LVOPutStr(a6)
		bra.s	close
help_scr	move.l	d0,a6
		lea	help(pc),a0
		move.l	a0,d1
		jsr	_LVOPutStr(a6)
close		move.l	a6,a1
		move.l	4.w,a6
		jsr	_LVOCloseLibrary(a6)
exit0		rts


dosname		dc.b	"dos.library",0
		even
help		dc.b	"Reboot v1.0 by Mauro Panigada",10
		dc.b	"Original C version written by Max Francis",10
		dc.b	"Perform a cold reboot of the system",10
		dc.b	"USAGE: Reboot",10
		dc.b	"(equivalent of <CTRL><A><A>",10,10,0
		even
confirm		dc.b	"Cold reboot? Confirm (Y/n): "
clen		EQU	*-confirm
		even
ab		dc.b	">> ABORTED <<",10,0
		even
buffer		dc.w	0

		END