
******************************************************
*                   XInstall v1.1                    *
*          copyright © 1994 by Jens Tröger           *
*                 all rights reserved                *
******************************************************
*  Revision History:                                 *
*     o first there was this idea...                 *
*     o ...some simple tests and reading books...    *
*     o v1.0 was born (oh what a hard work !!!!)     *
*       but -#?§$/&- it doesn`t work without trouble *
*     o v1.1 is the actually version (bugs ?? hope   *
*       U will find nothing, but if so, don`t cry &  *
*       let me know !)                               *
*     o (is there any new version in work ????????)  *
*       U will see it                                *
******************************************************
*  Assembler:   DevPac v2.14d (tab 11)               *
*  Books:       AMIGA intern, AMIGA Profi Know How,  *
*               RKRM Libraries 3rd Ed.               *
*  Help:        Holger Gzella (Scroller BB)          *
*               Jan van den Baard (BackFill-Pattern) *
*               !!! THANX A LOT !!!                  *
*  Tester:      "PackMAN" Falk Zühlsdorff (27 n.D.)  *
*               he`s the best Pas-Coder I know !!!   *
*  Big Thanx:   Jan van den Bard for GadToolsBox     *
*               (I created the Layout...)            *
*  Thanx too:   all, I know                          *
*  ...and:      Merci to Helloween for music (Great) *
*               my girl Claudia for beeing there     *
******************************************************
*      Bug-Reports, Suggestion, Money, ... to        *
*                                                    *
*                   Jens Tröger                      *
*                   Jahnstr. 5                       *
*                   08209 Auerbach/V                 *
*                   GERMANY                          *
*                                                    *
******************************************************

	opt	o+

dummy_tag		equ	$80000000

rt_window		equ	(dummy_tag+01)
rt_reqpos		equ	(dummy_tag+03)
rt_lockwindow	equ	(dummy_tag+13)
rt_screentofront	equ	(dummy_tag+14)
rt_underscore	equ	(dummy_tag+11)
rtez_reqtitle	equ	(dummy_tag+20)
rtez_flags		equ	(dummy_tag+22)
rtfi_flags		equ	(dummy_tag+40)
rtgs_allowempty	equ	(dummy_tag+80)
rtgs_textfmt	equ	(dummy_tag+38)

gtst_string	equ	(dummy_tag+$8002d)
gtcy_active	equ	(dummy_tag+$8000f)

; -----  check the Kick-Version: I need 2.0 or higher to run !!

	move.l	4.w,a6		; need Kick 2.0 or higher
	cmp.w	#37,$14(a6)	; exec_SoftVer
	blt	no_kick20

; -----  find the adress of ThisTask

	move.l	#0,a1
	jsr	-294(a6)		; _LVOFindTask
	move.l	d0,thistask

; -----  open reqtools.library  *** brilliant, Nico François **
	
	lea	reqname,a1		; open reqtools.library
	moveq	#38,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	move.l	d0,reqbase
	beq	no_reqlib		; open failed -> end

; -----  reqtoolsbase holds some "Needful things" (!!!)

	move.l	d0,a0
	move.l	$2a(a0),intbase	; rt_IntuitionBase
	move.l	$2e(a0),gfxbase	; rt_GfxBase
	move.l	$32(a0),dosbase	; rt_DOSBase
	move.l	$36(a0),gadbase	; rt_GadToolsBase

; -----  alloc memory for BB

	move.l	#1024,d0		; 1024 Bytes
	move.l	#$10002,d1		; MEMF_CHIP|MEMF_CLEAR
	move.l	4.w,a6
	jsr	-198(a6)		; _LVOAllocMem
	move.l	d0,bb_mem
	beq	close_req		; oh f... - no mem ???

; -----  now open window (thanx to Jan van den Baard)
; -----  sorry, but I did a little work on your code to make
; -----  it better (you know the bug !) and to add the 
; -----  pattern (thanx again) to the window

screen	bsr	setupscreen
	cmp.l	#0,d0
	beq.s	window
	bra	scr_failed
window	bsr	openmainwindow
	cmp.l	#0,d0
	beq.s	check_drvs
	bra	wnd_failed

; -----  check for disk-drives
; -----  you can also FindTask() named "DF0", "DF1" etc, but I
; -----  try to open the trackdisk.device

check_drvs	move.l	mainglist,a3	; disable Drive-Gads if not
	moveq	#5,d0		; mounted
.loop	move.l	(a3),a3
	dbra	d0,.loop		; find Button DF0 (5th at GGList)
	moveq	#0,d3
.td_loop	bsr.s	.check_dev		; loop 2 find out, which
	move.l	(a3),a3		; drive is on
	addq.l	#1,d3
	cmp.l	#3,d3
	ble.s	.td_loop
	bra.s	refresh_wd

.check_dev	lea	trackname,a0	; if OpenDevice fails, the 
	lea	disk_io,a1		; drive is not on
	move.l	d3,d0
	moveq	#0,d1
	move.l	4.w,a6
	jsr	-444(a6)		; _LVOOpenDevice
	cmp.l	#0,d0
	beq.s	.device_on
	move.l	a3,a0
	move.l	mainwnd,a1
	move.l	#0,a2
	move.l	intbase,a6
	jmp	-174(a6)		; _LVOOffGadget
.device_on	lea	disk_io,a1
	jmp	-450(a6)		; _LVOCloseDevice

; ------  refresh Window

refresh_wd	move.l	mainglist,a0
	move.l	mainwnd,a1
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-222(a6)		; _LVORefreshGadgets

	move.l	mainglist,a0	; save ptr "_?"
	moveq	#2,d0
.loop1	move.l	(a0),a0
	dbra	d0,.loop1
	move.l	a0,getfile_1

	move.l	mainglist,a0	; save ptr String "<Path>"
	moveq	#3,d0
.loop2	move.l	(a0),a0
	dbra	d0,.loop2
	move.l	a0,getfile_2
	
	move.l	mainwnd,about_tags+4	; WindowPtr 4 rtRequesters
	move.l	mainwnd,freq_tags+4
	move.l	mainwnd,scrl_tags+4
	move.l	thistask,a0
	move.l	mainwnd,$b8(a0)	; pr_WindowPtr

; -----  wait for message

get_msg	move.l	4.w,a6
	move.l	mainwnd,a0		; wait 4 IDCMP-Message
	move.l	$56(a0),a0		; wd_UserPort --> a0
	move.l	a0,a2
	jsr	-384(a6)		; _LVOWaitPort
	move.l	a2,a0
	move.l	gadbase,a6
	jsr	-72(a6)		; _LVOGT_GetIMsg
	move.l	d0,a5
	move.l	d0,a1
	jsr	-78(a6)		; _LVOGT_ReplyIMsg
	move.l	$14(a5),d0		; im_Class d0
	move.w	$18(a5),d1		; im_Code d1
	move.l	$1c(a5),d2		; im_IAdress d2

	cmpi.l	#$40,d0		; IDCMP_GadgetDown
	beq.s	gad_up
	
	cmpi.l	#$200000,d0	; IDCMP_VanillaKey
	beq.s	keypressed

	cmpi.l	#$200,d0		; IDCMP_CloseWindow
	beq.s	quit

	bra.s	get_msg

; -----  jump to subroutines

gad_up	moveq	#0,d0		; compute the adress to jump to
	move.l	d2,a0
	move.w	$26(a0),d0
	lsl.l	#2,d0
	lea	jmp_tab1,a0	; see the table below
	adda.l	d0,a0
	move.l	(a0),a0
	jmp	(a0)

keypressed	lea	jmp_tab2,a0	; see table jmp_tab2
.key_loop	move.b	(a0),d4
	cmp.b	d1,d4
	beq.s	.key_jump
	cmp.b	#0,d4
	beq.s	get_msg
	adda.l	#6,a0
	bra.s	.key_loop
.key_jump	adda.l	#2,a0
	move.l	(a0),a0
	jmp	(a0)

; -----  close window (press q to quit too)

quit	bsr	closemainwindow
	bsr	closedownscreen

; -----  free allocated memory

free_mem	move.l	bb_mem,a1
	move.l	#1024,d0
	move.l	4.w,a6
	jsr	-210(a6)		; _LVOFreeMemory

; -----  close reqtools.library

close_req	move.l	reqbase,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary
	moveq	#0,d0
	rts

; -----  cry for help

scr_failed
wnd_failed	move.l	reqbase,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary
no_kick20
no_reqlib	moveq	#20,d0		; no Kick or reqtools.lib
	rts
	
; -----  CycleGad "Bootblock" selected...

bootblock1	move.b	d1,bb_id		; ...by MousePtr
	bra.s	bb_goon

bootblock2	cmp.b	#"B",d1		; ...by Keyboard
	beq.s	.down
.up	addq.b	#1,bb_id		; add (key "b") or sub 
	cmp.b	#5,bb_id		; (key "B") the CycleEntry
	ble.s	.refresh		; and refresh the Gadget
	move.b	#0,bb_id
	bra.s	.refresh
.down	subq.b	#1,bb_id
	cmp.b	#0,bb_id
	bge.s	.refresh
	move.b	#5,bb_id
.refresh	lea	gtcy_act,a3
	move.b	bb_id,7(a3)
	move.l	mainglist,a0
	move.l	(a0),a0
	move.l	mainwnd,a1
	move.l	#0,a2
	move.l	gadbase,a6
	jsr	-42(a6)		; _LVOGT_SetGadgetAttrsA
	
bb_goon	cmp.b	#5,bb_id		; enable Path if BB "(File)"
	beq.s	.en_path
	
.dis_path	move.l	getfile_1,a0
	btst	#8,$0c(a0)		; DISABLED-Bit already set ?
	bne.s	.copy_bb		; yoop -> don`t disable gadget
	move.l	mainwnd,a1		; else disable it
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-174(a6)		; _LVOOffGadget
	move.l	getfile_2,a0
	move.l	mainwnd,a1
	move.l	#0,a2
	jsr	-174(a6)		; _LVOOffGadget
	bra.s	.copy_bb
	
.en_path	move.l	getfile_1,a0	; if "(File)" is on, enable
	move.l	mainwnd,a1		; GetFile-Gadgets
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-186(a6)		; _LVOOnGadget
	move.l	getfile_2,a0
	move.l	mainwnd,a1
	move.l	#0,a2
	jsr	-186(a6)		; _LVOOnGadget
	bra	get_msg
	
.copy_bb	cmp.b	#3,bb_id		; after hard work above, copy
	beq	get_msg		; the cycle-selected Bootblock
	cmp.b	#5,bb_id		; into the buffer (don`t copy
	beq	get_msg		; if Scroller or (File) !!)
	moveq	#0,d0
	move.b	bb_id,d0		; calc adress and length of
	lsl.l	#3,d0		; Bootblock to copy (see table
	lea	bb_table,a0	; bb_table !)
	adda.l	d0,a0
	move.l	a0,a1
	adda.l	#4,a1
	move.l	(a0),a0
	move.l	(a1),a1
	suba.l	a0,a1
	move.l	a1,d0
	subq	#1,d0
	move.l	bb_mem,a1
.loop1	move.b	(a0)+,(a1)+	; copy to buffer...
	dbra	d0,.loop1
	bra	get_msg

; -----  CycleGad "FileSystem" selected...
	
filesys1	move.b	d1,fs_id		; ... MousePtr
	bra	get_msg

filesys2	cmp.b	#"F",d1		; ... Keyboard
	beq.s	.down		; same like bootblock2
.up	addq.b	#1,fs_id		; (see above)
	cmp.b	#5,fs_id
	ble.s	.refresh
	move.b	#0,fs_id
	bra.s	.refresh
.down	subq.b	#1,fs_id
	cmp.b	#0,fs_id
	bge.s	.refresh
	move.b	#5,fs_id
.refresh	lea	gtcy_act,a3
	move.b	fs_id,7(a3)
	move.l	mainglist,a0
	move.l	(a0),a0
	move.l	(a0),a0
	move.l	mainwnd,a1
	move.l	#0,a2
	move.l	gadbase,a6
	jsr	-42(a6)		; _LVOGT_SetGadgetAttrsA
	bra	get_msg

; -----  About-Requester

about	lea	about_tags,a0	; only a simple About-Req
	lea	about_text,a1
	lea	about_gad,a2
	bsr	do_req
	bra	get_msg

; -----  any Drive-Button was pressed...

df0	moveq	#5,d0		; ignore key if button...
	bsr.s	get_ggptr		; ...is disabled
	btst	#8,$0c(a0)		; gg_Flags -> DISABLED
	bne	get_msg
	moveq	#0,d5
	bra.s	inst_goon

df1	moveq	#6,d0
	bsr.s	get_ggptr
	btst	#8,$0c(a0)		; gg_Flags -> DISABLED
	bne	get_msg
	moveq	#1,d5
	bra.s	inst_goon

df2	moveq	#7,d0
	bsr.s	get_ggptr
	btst	#8,$0c(a0)		; gg_Flags -> DISABLED
	bne	get_msg
	moveq	#2,d5
	bra.s	inst_goon

df3	moveq	#8,d0
	bsr.s	get_ggptr
	btst	#8,$0c(a0)		; gg_Flags -> DISABLED
	bne	get_msg
	moveq	#3,d5

inst_goon	cmp.b	#3,bb_id		; copy FileSys-ID to buffer
	beq	scroll_bb		; (or not if Scroller or (File) !!)
	cmp.b	#5,bb_id
	beq	load_file
	bra	do_install		; ...and install the BB

get_ggptr	move.l	mainglist,a0	; get ptr to Gadget (a0) with
.loop	move.l	(a0),a0		; ID -> d0
	move.w	$26(a0),d1		; gg_GadgetID
	cmp.w	d0,d1
	bne.s	.loop
	rts

; -----  get the Path of the BB-File to load

get_path	move.l	reqbase,a6		; get the Name & Path
	moveq	#0,d0
	move.l	d0,a0
	jsr	-30(a6)		; _LVOrtAllocRequestA
	cmp.l	#0,d0
	beq	get_msg
	lea	freq_tags,a0
	move.l	d0,a1
	move.l	d0,d7
	lea	freq_array,a2
	lea	freq_title,a3
	jsr	-54(a6)		; _LVOrtFileRequestA
	cmp.l	#0,d0
	bne.s	.copy_path
	move.l	d7,a1
	jsr	-36(a6)		; _LVOrtFreeRequestA
	bra	get_msg
	
.copy_path	lea	bb_path,a0		; make complete Path
	move.l	a0,a1
	move.l	#255,d0
.clr_loop	move.b	#0,(a1)+
	dbra	d0,.clr_loop
	move.l	d7,a1
	move.l	$10(a1),a1
.copy_loop	cmp.b	#0,(a1)
	beq.s	.copy_file
	move.b	(a1)+,(a0)+
	bra.s	.copy_loop
.copy_file	cmp.b	#":",-(a0)
	beq.s	.file2path
	adda.l	#1,a0
	move.b	#"/",(a0)
.file2path	adda.l	#1,a0
	lea	freq_array,a1
.copyloop2	cmp.b	#0,(a1)
	beq.s	.path_done
	move.b	(a1)+,(a0)+
	bra.s	.copyloop2
.path_done	move.l	getfile_1,a0	; show Path in StringGad
	move.l	mainwnd,a1
	move.l	#0,a2
	lea	stringtags,a3
	lea	bb_path,a4
	move.l	a4,4(a3)
	move.l	gadbase,a6
	jsr	-42(a6)		; _LVOSetGadgetAttrA
	move.l	reqbase,a6
	move.l	d7,a1
	jsr	-36(a6)		; _LVOrtFreeRequestA
	bra	get_msg

; -----  load BB to buffer

load_file	move.l	dosbase,a6
	move.l	#bb_path,d1
	moveq	#-2,d2
	jsr	-84(a6)		; _LVOLock
	move.l	d0,d5
	bne.s	.go_exam
	bra	.cant_lock		; no lock - no file

.go_exam	move.l	d0,d1
	move.l	#examine_bf,d2
	jsr	-102(a6)		; _LVOExamine
	move.l	d5,d1
	jsr	-90(a6)		; _LVOUnLock
	lea	examine_bf,a0
	move.l	124(a0),d6
	cmp.l	#1024,d6		; FileSize greater than 1024 Bytes ?
	bgt.s	.not_a_bb		; yes --> no (Disk)-BB

	move.l	#bb_path,d1	; open File 4 reading...
	move.l	#1005,d2
	jsr	-30(a6)		; _LVOOpen
	move.l	d0,d7
	cmp.l	#0,d0
	bne.s	.read_it
	bra.s	.cant_open

.read_it	move.l	d0,d1		
	move.l	bb_mem,d2
	move.l	d6,d3
	jsr	-42(a6)		; _LVORead
	cmp.l	d6,d0
	bne.s	.read_err
	
.read_goon	move.l	d7,d1		; ...and close File
	jsr	-36(a6)		; _LVOClose

	move.l	bb_mem,a0		; is loaded file a BB ?
	move.l	(a0),d0
	move.l	d0,d1
	and.l	#$ff,d0
	cmp.l	#$444f5300,d0	; 1st Long "DOS",0 ?
	beq.s	.lf_done
	cmp.l	#"KICK",d1		; 1st Long "KICK" ?
	bne.s	.not_a_bb

.lf_done	bra	do_install
	
.not_a_bb	lea	about_tags,a0	; ERROR: File no BB
	lea	err3_text,a1
	lea	err1_gad,a2
	bsr	do_req
	bra	get_msg

.cant_lock	lea	about_tags,a0	; ERROR: no lock
	lea	err1_text,a1
	lea	err1_gad,a2
	bsr	do_req
	bra	get_msg
	
.cant_open	lea	about_tags,a0	; ERROR: can`t open
	lea	err2_text,a1
	lea	err1_gad,a2
	bsr	do_req
	bra	get_msg

.read_err	lea	about_tags,a0	; ERROR: can`t read
	lea	err5_text,a1
	lea	err1_gad,a2
	bsr	do_req
	bra	get_msg

; -----  Scroller-BB needs a special Routine
	
scroll_bb	move.l	reqbase,a6		; get Scroll-Text
	moveq	#5,d0
	move.l	#0,a0
	jsr	-30(a6)		; _LVOrtAllocRequestA
	cmp.l	#0,d0
	beq	get_msg
	move.l	d0,d7
	moveq	#49,d0
	lea	scrl_tags,a0
	lea	scrl_bufr,a1
	lea	reqtitle,a2
	move.l	d7,a3
	jsr	-72(a6)		; _LVOrtGetStringA
.free_req	move.l	d0,d6
	move.l	d7,a1
	jsr	-36(a6)		; _LVOrtFreeRequestA
	cmp.l	#0,d6
	beq	get_msg

	move.l	bb_mem,a0		; copy BB to BBBuffer
	lea	scroller,a1
	move.l	#scroller_end-scroller-1,d0
.copy_loop	move.b	(a1)+,(a0)+
	dbra	d0,.copy_loop
	
; -----  Install-Routine

; in:    d5 - drive
; out:   -

do_install	movem.l	d0-d7/a0-a6,-(sp)
	move.l	bb_mem,a0
	move.b	fs_id,3(a0)	; don`t forget the FileSystem
	bsr	calc_csm		; and the CheckSum
	move.l	thistask,replyport+16
	lea	replyport,a1
	move.l	4.w,a6
	jsr	-354(a6)		; _LVOAddPort
	lea	disk_io(pc),a1
	move.l	#replyport,14(a1)
	move.l	d5,d0
	moveq	#0,d1
	lea	trackname(pc),a0
	jsr	-444(a6)		; _LVOOpenDevice
	cmp.l	#0,d0
	bne	.no_device
	lea	disk_io(pc),a1
	move.w	#3,28(a1)		; CMD_WRITE
	move.l	bb_mem,40(a1)	; write what ?
	move.l	#1024,36(a1)	; write 1024 Bytes
	move.l	#0,44(a1)		; start writing block 0
	jsr	-456(a6)		; _LVODoIO
	cmp.l	#0,d0
	bne.s	.io_failed		; ooops - an error
	move.w	#4,28(a1)		; CMD_UPDATE (don`t forget !!)
	jsr	-456(a6)		; _LVODoIO
	cmp.l	#0,d0
	bne.s	.io_failed		; ooops - another error
	move.w	#9,28(a1)		; CMD_MOTOR
	move.l	#0,36(a1)
	jsr	-456(a6)		; _LVODoIO
	cmp.l	#0,d0
	bne.s	.io_failed		; ooops - f... !!!
	lea	replyport(pc),a1
	jsr	-360(a6)		; _LVORemPort
	lea	disk_io(pc),a1
	jsr	-450(a6)		; _LVOCloseDevice
	move.l	bb_mem,a0
	move.l	#255,d0
.bfr_clr	move.l	#0,(a0)+		; after writing clear the
	dbra	d0,.bfr_clr	; buffer
	movem.l	(sp)+,d0-d7/a0-a6
	bra	get_msg

.no_bb	lea	err_txt4,a1	; react to the errors
	bra.s	.error_out
.no_device	lea	err_txt1,a1
	bra.s	.error_out
.io_failed	move.l	d0,d7
	move.w	#9,28(a1)		; first CMD_MOTOR
	move.l	#0,36(a1)
	jsr	-456(a6)		; _LVODoIO
	move.l	d7,d0
	sub.l	#19,d0
	lsl.l	#2,d0
	lea	td_errtab,a1	; see the tab below
	adda.l	d0,a1
	move.l	(a1),a1
.error_out	lea	about_tags,a0
	lea	about_gad,a2
	bsr	do_req
	movem.l	(sp)+,d0-d7/a0-a6
	bra	get_msg

; -----  compute Check-Sum of BB

calc_csm	movem.l	a1/d0/d1,-(sp)	; this way you calc BB`s CSum
	move.l	bb_mem,a1
	move.w	#$ff,d0
	moveq	#0,d1
	move.l	#0,4(a1)
.add_loop	add.l	(a1)+,d1
	bcc.s	.no_carry
	addq.l	#1,d1
.no_carry	dbra	d0,.add_loop
	not.l	d1
	bcc.s	.calc_done
	addq.l	#1,d1
.calc_done	move.l	bb_mem,a1
	move.l	d1,4(a1)
	movem.l	(sp)+,a1/d0/d1
	rts

; -----  draw a pattern into the Window (thanx Jan van den Baard)
	
; IN     A0  ^Window
; OUT    D0  success:  0 - ok
;                      1 - bad KickVersion (OS2.0 or better)
;                      2 - no ScreenDrawInfo

wd_pattern	movem.l	d1-d7/a0-a6,-(sp)

	move.l	4.w,a6		; Kick 2.0
	cmp.w	#37,$14(a6)	; exec_SoftVer
	blt	.failed1
	
	move.l	a0,d7		; d7: ^Window
	move.l	$2e(a0),a0		; wd_Screen
	move.l	intbase,a6
	jsr	-690(a6)		; _LVOGetScreenDrawInfo
	cmp.l	#0,d0
	beq	.failed2
	move.l	d0,d6		; d6: DrawInfo
	move.l	d0,a0
	move.l	$04(a0),a0		; dri_Pens
	move.w	$06(a0),d5		; d5: SHINEPEN
	move.w	$0e(a0),d4		; d4: BACKGROUNDPEN
	move.l	d7,a0
	move.l	$2e(a0),a0		; wd_Screen
	move.l	d6,a1
	jsr	-696(a6)		; _LVOFreeScreenDrawInfo
	
	move.l	d7,a0
	move.l	50(a0),a0
	move.l	a0,d6		; d6: RastPort
	move.l	#pattern,$08(a0)	; rp_AreaPtrn
	move.b	#1,$1d(a0)		; rp_AreaPtSize
	
	move.l	d6,a1
	move.l	d5,d0
	move.l	gfxbase,a6
	jsr	-342(a6)		; _LVOSetAPen
	
	move.l	d6,a1
	move.l	d4,d0
	jsr	-348(a6)		; _LVOSetBPen
	
	move.l	d6,a1
	moveq	#1,d0		; JAM2
	jsr	-354(a6)		; _LVOSetDrMd
	
	move.l	d7,a0
	moveq	#0,d0		; clear registers
	moveq	#0,d1
	moveq	#0,d2
	moveq	#0,d3
	moveq	#0,d4
	moveq	#0,d5
	move.b	$36(a0),d0		; wd_BorderLeft
	move.b	$37(a0),d1		; wd_BorderTop
	move.b	$38(a0),d4		; wd_BorderRight
	move.b	$39(a0),d5		; wd_BorderBottom
	move.w	$08(a0),d2		; wd_Width
	sub.w	d4,d2
	move.w	$0a(a0),d3		; wd_Height
	sub.w	d5,d3
	move.l	d6,a1
	jsr	-306(a6)		; _LVORectFill
	
	move.l	d6,a0
	move.l	#0,$08(a0)
	move.b	#0,$1d(a0)

	moveq	#0,d0
	movem.l	(sp)+,d1-d7/a0-a6
	rts	

.failed1	moveq	#1,d0
	movem.l	(sp)+,d1-d7/a0-a6
	rts
.failed2	moveq	#2,d0
	movem.l	(sp)+,d1-d7/a0-a6
	rts
	
pattern	dc.w	$aaaa,$5555

; -----  setup rt_Requester 

; IN    A0 ^TagList
;       A1 ^BodyText
;       A2 ^GadgetText
; OUT   D0 Nr. of Gadgets/-1($ff) if failed

do_req	movem.l	d1-d7/a0-a6,-(sp)
	movem.l	a0-a2,-(sp)
	move.l	reqbase,a6
	moveq	#5,d0
	move.l	#0,a0
	jsr	-30(a6)		; _LVOrtAllocRequestA
	cmp.l	#0,d0
	beq.s	.failed
	move.l	d0,d7
	movem.l	(sp)+,a0-a2
	move.l	d7,a3
	move.l	#0,a4
	jsr	-66(a6)		; _LVOrtEZRequestA
	move.l	d0,d6
	move.l	d7,a1
	jsr	-36(a6)		; _LVOrtFreeRequestA
	move.l	d6,d0
	movem.l	(sp)+,d1-d7/a0-a6
	rts
.failed	movem.l	(sp)+,a0-a2
	movem.l	(sp)+,d1-d7/a0-a6
	moveq	#-1,d0
	rts

; -----  Datas

reqname	dc.b	"reqtools.library",0
	even
trackname	dc.b	"trackdisk.device",0
	even

thistask	dc.l	0
reqbase	dc.l	0
intbase	dc.l	0
gfxbase	dc.l	0
dosbase	dc.l	0
gadbase	dc.l	0
bb_mem	dc.l	0

getfile_1	dc.l	0
getfile_2	dc.l	0

disk_io	ds.b	20	; Message-Structure
	ds.l	1	; Ptr Device-Structure
	ds.l	1	; Ptr Unit-Structure
	ds.w	1	; Device-Kommand
	ds.b	1	; Flags
	ds.b	1	; Error
ioext_requ	ds.l	1	; Bytes
	ds.l	1
	ds.l	1	; Ptr DataBuffer
	ds.l	1	; Offset (Startblock)
	even	

replyport	ds.b	14	; Node-Structure
	ds.b	1	; Flags
	ds.b	1	; Signal-Bits
	ds.l	1	; Ptr to Task
	ds.b	60	; Message-List
	even

; -----  Defs 4 About-Requester

about_tags	dc.l	rt_window,0
	dc.l	rt_lockwindow,1
	dc.l	rt_reqpos,0
	dc.l	rt_screentofront,1
	dc.l	rt_underscore,"_"
	dc.l	rtez_reqtitle,reqtitle
	dc.l	rtez_flags,4
	dc.l	0

about_text	dc.b	"xInstall v1.1",10
	dc.b	"© 1994 by Jens Tröger",10,10
	dc.b	"This is Freeware.",10,10
	dc.b	"Greets to:",10
	dc.b	"PackMAN",10
	dc.b	"Jan van den Baard,",10
	dc.b	"Holger Gzella",10,10
	dc.b	"xInstall`s Layout created",10
	dc.b	"with GadToolsBox.",0
	even

about_gad	dc.b	"_OK",0
	even

reqtitle	dc.b	"xInstall v1.1",0
	even

; -----  Examine-Buffer

	cnop	0,4
examine_bf	ds.b	260
	even

; -----  Defs 4 FileRequester

freq_tags	dc.l	rt_window,0
	dc.l	rt_lockwindow,1
	dc.l	rt_reqpos,0
	dc.l	rt_screentofront,1
	dc.l	rt_underscore,"_"
	dc.l	rtfi_flags,$10
	dc.l	0

freq_array	ds.b	108
	even

freq_title	dc.b	"Load BootBlock-File",0
	even

bb_path	ds.b	256
	even

; -----  Defs ErrReq

err1_gad	dc.b	"_Yoop",0
	even

err1_text	dc.b	"Can`t lock selected file.",0
	even

err2_text	dc.b	"Can`t open selected file.",0
	even

err3_text	dc.b	"File is not a BootBlock.",0
	even

err4_text	dc.b	"No BB-File loaded.",0
	even

err5_text	dc.b	"Error while reading Bootblock-File.",0
	even

; -----  Defs 4 Enter-Scroll-Text-Requester

scrl_tags	dc.l	rt_window,0
	dc.l	rt_lockwindow,1
	dc.l	rt_reqpos,0
	dc.l	rt_screentofront,1
	dc.l	rt_underscore,"_"
	dc.l	rtez_flags,4
	dc.l	rtgs_allowempty,0
	dc.l	rtgs_textfmt,fmt_text
	dc.l	0

fmt_text	dc.b	"Enter the Scroll-Text !!",10
	dc.b	"[max 50 chars]",0
	even

; -----  other definitions

bb_table	dc.l	cleared,cleared_end
	dc.l	standart,standart_end
	dc.l	message,message_end
	dc.l	scroller,scroller_end
	dc.l	memtest,memtest_end

gtcy_act	dc.l	gtcy_active,1
	dc.l	0
	
bb_id	dc.b	0
	even

fs_id	dc.b	0
	even

stringtags	dc.l	gtst_string,0
	dc.l	0
	
jmp_tab1	dc.l	bootblock1		; Cycle "Bootblock"
	dc.l	filesys1		; Cycle "FileSys"
	dc.l	get_msg		; String "<Path>"
	dc.l	get_path		; Button "?"
	dc.l	about		; Button "About"
	dc.l	df0,df1,df2,df3	; Buttons df0-df3

jmp_tab2	dc.b	"Q",0		; this tab I need to get
	dc.l	quit		; the adress of the routine
	dc.b	"B",0		; to jump to if the under-
	dc.l	bootblock2		; scored character was
	dc.b	"F",0		; pressed
	dc.l	filesys2
	dc.b	"A",0		; the ,0 I need to get
	dc.l	about		; a even adress
	dc.b	"q",0
	dc.l	quit
	dc.b	"b",0
	dc.l	bootblock2
	dc.b	"f",0
	dc.l	filesys2
	dc.b	"a",0
	dc.l	about
	dc.b	"0",0
	dc.l	df0
	dc.b	"1",0
	dc.l	df1
	dc.b	"2",0
	dc.l	df2
	dc.b	"3",0
	dc.l	df3
	dc.b	"?",0
	dc.l	get_path
	dc.b	0		; this is the end of tab
	even

; -----  Errors trackdisk.device

td_errtab	dc.l	err_txt1,err_txt2,err_txt3,err_txt4
	dc.l	err_txt5,err_txt6,err_txt7,err_txt8
	dc.l	err_txt9,err_txt10,err_txt11,err_txt12
	dc.l	err_txt13,err_txt14,err_txt15,err_txt16
	dc.l	err_txt17

err_txt1	dc.b	"Cannot open trackdisk.device",0
	even
err_txt2	dc.b	"TDErr #20: Error not specified",0
	even
err_txt3	dc.b	"TDErr #21: No Sector-Header",0
	even
err_txt4	dc.b	"TDErr #22: Bad Sector Preamble",0
	even
err_txt5	dc.b	"TDErr #23: Bad Sector ID",0
	even
err_txt6	dc.b	"TDErr #24: Bad Header CheckSumm",0
	even
err_txt7	dc.b	"TDErr #25: Bad Sector CheckSumm",0
	even
err_txt8	dc.b	"TDErr #26: Too few Sectors",0
	even
err_txt9	dc.b	"TDErr #27: Bad Sector Header",0
	even
err_txt10	dc.b	"TDErr #28: Disk write protected",0
	even
err_txt11	dc.b	"TDErr #29: No Disk in drive",0
	even
err_txt12	dc.b	"TDErr #30: Seek error",0
	even
err_txt13	dc.b	"TDErr #31: Not enough memory",0
	even
err_txt14	dc.b	"TDErr #32: Bad unit number",0
	even
err_txt15	dc.b	"TDErr #33: Bad drive type",0
	even
err_txt16	dc.b	"TDErr #34: Drive is in use",0
	even
err_txt17	dc.b	"TDErr #35: Post Reset done",0
	even

; Are there more trackdisk-errors I do not know ?? These are Kick 1.3
; errors, the new I did not found anywhere !!! Can somebody help me ?

	opt	o+,p+
	
; -----  BootBlock: DOS CLEARED (what a nice BB)

cleared	dc.l	$444f5300		; DOS,0
	dc.l	$00000000		; later CheckSum
	dc.l	$00000370		; ptr to disk`s RootBlock

cleared_end

; -----  BootBlock: STANDART (BORING, isn`t it ??)

standart	dc.l	$444f5300		; Standart-Bootcode
	dc.l	$00000000
	dc.l	$00000370

	lea	exp_libra(pc),a1
	moveq	#37,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq.s	.no_explib
	move.l	d0,a1
	bset	#6,34(a1)
	jsr	-414(a6)		; _LVOCloseLibrary
.no_explib	lea	dos_libra(pc),a1
	jsr	-96(a6)		; _LVOFindResident
	cmp.l	#0,d0
	beq.s	.not_found
	move.l	d0,a0
	move.l	22(a0),a0
	moveq	#0,d0
	rts
.not_found	moveq	#-1,d0
	rts
	
exp_libra	dc.b	"expansion.library",0
dos_libra	dc.b	"dos.library",0

standart_end

; -----  BootBlock: MESSAGE (this is not so boring, or ??)

message	dc.l	$444f5300
	dc.l	$00000000
	dc.l	$00000370

	move.l	4.w,a6
	jsr	-132(a6)		; _LVOForbid

.alloc_mem	move.l	#320+12+100+108,d0	; BitPlane+BitMap+RastPort+CopperList
	move.l	#$10002,d1		; MEMF_CHIP|MEMF_CLEAR
	jsr	-198(a6)		; _LVOAllocMem
	cmp.l	#0,d0
	beq	.dos_boot
	move.l	d0,d7

.open_gfx	lea	gfx_libr(pc),a1
	moveq	#33,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq	.free_mem
	move.l	d0,a6

	move.l	d7,a1		; init what U need, my son
	adda.l	#320+12,a1
	jsr	-198(a6)		; _LVOInitRastPort

	move.l	d7,a0
	adda.l	#320,a0
	moveq	#1,d0
	move.l	#320,d1
	moveq	#8,d2
	jsr	-390(a6)		; _LVOInitBitMap

	move.l	d7,a0
	adda.l	#320+12,a0
	move.l	d7,a1
	adda.l	#320,a1
	move.l	d7,a2
	move.l	a1,$04(a0)
	move.l	a2,$08(a1)

	move.l	d7,a1
	adda.l	#320+12,a1
	moveq	#52,d0
	moveq	#6,d1
	jsr	-240(a6)		; _LVOMove
	move.l	d7,a1
	adda.l	#320+12,a1
	lea	boot_text(pc),a0
	moveq	#24,d0
	jsr	-60(a6)		; _LVOText

	moveq	#107,d0
	move.l	d7,a0
	adda.l	#320+12+100,a0
	move.l	a0,a2
	lea	coplist(pc),a1
.loop	move.b	(a1)+,(a0)+
	dbf	d0,.loop

	move.l	d7,d0
	move.w	d0,46(a2)
	swap	d0		; BPL1PTH / BPL1PTL
	move.w	d0,42(a2)

	lea	$dff000,a0
	move.l	a2,$080(a0)	; COP1LCH
	move.w	#0,$088(a0)	; COPJMP1
	move.w	#$8300,$096(a0)	; DMACON

	move.w	#$000c,d1		; wait a little bit
	move.w	#$ffff,d0		; (sorry for polling !)
.wait	nop
	nop
	dbf.w	d0,.wait
	dbf.w	d1,.wait

	move.l	$26(a6),$080(a0)	; COP1LCH
	move.w	#0,$088(a0)

.close_gfx	move.l	a6,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary

.free_mem	move.l	d7,a1
	move.l	#320+12+100+108,d0
	jsr	-210(a6)		; _LVOFreeMem

	jsr	-138(a6)		; _LVOPermit

.dos_boot	lea	exp_libr(pc),a1	; now the standard-code
	moveq	#37,d0		; (don`t forget it - never !)
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq.s	no_explib
	move.l	d0,a1
	bset	#6,34(a1)
	jsr	-414(a6)		; _LVOCloseLibrary
no_explib	lea	dos_libr(pc),a1
	jsr	-96(a6)		; _LVOFindResident
	cmp.l	#0,d0
	beq.s	not_found
	move.l	d0,a0
	move.l	22(a0),a0
	moveq	#0,d0
	rts
not_found	moveq	#-1,d0
	rts

gfx_libr	dc.b	"graphics.library",0
	even
dos_libr	dc.b	"dos.library",0
	even
exp_libr	dc.b	"expansion.library",0
	even
boot_text	dc.b	"No Virus on Bootblock !!",0
	even

; -----  this is the Copperlist you need !!

coplist	dc.w	$2001,$fffe
	dc.w	$0100		; BPLCON0
	dc.w	$0200
	dc.w	$008e		; DIWSTRT
	dc.w	$0581
	dc.w	$0090		; DIWSTOP
	dc.w	$40c1
	dc.w	$0092		; DDFSTRT
	dc.w	$0038
	dc.w	$0094		; DDFSTOP
	dc.w	$00d0
	dc.w	$0102		; BPLCON1
	dc.w	$0000
	dc.w	$0104		; BPLCON2
	dc.w	$0024
	dc.w	$0108		; BPL1MOD
	dc.w	$0000
	dc.w	$010a		; BPL2MOD
	dc.w	$0000
	dc.w	$00e0		; BPL1PTH
	dc.w	0
	dc.w	$00e2		; BPL1PTL
	dc.w	0
	dc.w	$182		; COLOR01
	dc.w	$00f0
	dc.w	$180		; COLOR00
	dc.w	$0040
	dc.w	$9b0f		; line
	dc.w	$fffe
	dc.w	$180		; COLOR00
	dc.w	$00f0
	dc.w	$9d0f		; line
	dc.w	$fffe
	dc.w	$180		; COLOR00
	dc.w	$0000
	dc.w	$a20f,$fffe
	dc.w	$0100		; BPLCON0
	dc.w	$1200
	dc.w	$a90f,$fffe
	dc.w	$0100		; BPLCON0
	dc.w	$0200
	dc.w	$af0f		; line
	dc.w	$fffe
	dc.w	$180		; COLOR00
	dc.w	$00f0
	dc.w	$b10f		; line
	dc.w	$fffe
	dc.w	$180		; COLOR00
	dc.w	$0040
	dc.l	$fffffffe		; End of CopperList
	
coplist_end

message_end

; -----  BootBlock: MEMTEST (exactly 1024 Bytes !!!)

; -----  there is a little bug (do you find it, guy ??), but if you
; -----  have a "normal" AMIGA the bug will never appear !

memtest	dc.l	$444f5300		; DOS-Disk OFS
	dc.l	$00000000		; CheckSum
	dc.l	$00000370		; RootBlock pointer

; -----  Standart-DOS-Bootcode
	
.dos_boot	lea	exp_lib(pc),a1	; Standard OS2.0 code
	moveq	#37,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq.s	.no_explib
	move.l	d0,a1
	bset	#6,34(a1)
	jsr	-414(a6)		; _LVOCloseLibrary
.no_explib	lea	dos_lib(pc),a1
	jsr	-96(a6)		; _LVOFindResident
	cmp.l	#0,d0
	beq.s	.not_found
	move.l	d0,a0
	move.l	22(a0),a0
	moveq	#0,d0
	bra.s	.own_boot
.not_found	moveq	#-1,d0	

; -----  MemTest-Routine
	
.own_boot	movem.l	d0-d7/a0-a6,-(sp)
	cmp.b	#50,530(a6)	; NTSC-Display ?? (PAL -> 50Hz)
	bne	.softreset
	cmp.l	#0,42(a6)		; ColdCapture
	bne	.vecs_bad
	cmp.l	#0,46(a6)		; CoolCapture
	bne	.vecs_bad
	cmp.l	#0,546(a6)		; KickMemPtr
	bne	.vecs_bad
	cmp.l	#0,550(a6)		; KickTagPtr
	bne	.vecs_bad
	cmp.l	#0,554(a6)		; KickCheckSumPtr
	bne	.vecs_bad

; -----  setup green CopperList, wait and terminate

.vecs_ok	move.l	#cop_end-cop_start,d0
	moveq	#2,d1
	jsr	-198(a6)		; _LVOAllocMem
	lea	cop_adress(pc),a0
	move.l	d0,(a0)
	beq.s	.back_1
	lea	cop_start(pc),a0
	move.l	cop_adress(pc),a1
	move.l	#cop_end-cop_start-1,d0
.cl_copy	move.b	(a0)+,(a1)+
	dbf	d0,.cl_copy
	jsr	-132(a6)		; _LVOForbid
	lea	$dff000,a5
	move.w	#$03a0,$96(a5)	; DMACON
	move.l	cop_adress(pc),$80(a5) ; COP1LCH
	move.w	#0,$88(a5)		; COPJMP1
	move.w	#$8280,$96(a5)	; DMACON
	moveq	#$c,d1
	move.l	#$ffff,d0
.wait_loop	nop			; wait (Polling)
	dbra	d0,.wait_loop
	dbra	d1,.wait_loop
	lea	gfx_lib(pc),a1
	moveq	#33,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	move.l	d0,a4
	move.l	38(a4),$80(a5)	; COP1LCH
	move.w	#0,$88(a5)		; COPJMP1
	move.w	#$83e0,$96(a5)	; DMACON
	jsr	-138(a6)		; _LVOPermit
	move.l	cop_adress(pc),a1
	move.l	#cop_end-cop_start,d0
	jsr	-210(a6)		; _LVOFreeMem
.back_1	movem.l	(sp)+,d0-d7/a0-a6
	rts

; -----  setup Error-Alert

.vecs_bad	lea	bad_text(pc),a1
	adda.l	#71,a1
	move.l	42(a6),d0		; ColdCapture
	bsr	.bbbin2hex
	adda.l	#36,a1
	move.l	46(a6),d0		; CoolCapture
	bsr	.bbbin2hex
	adda.l	#27,a1
	move.l	546(a6),d0		; KickMemPtr
	bsr	.bbbin2hex
	adda.l	#36,a1
	move.l	550(a6),d0		; KickTagPtr
	bsr	.bbbin2hex
	adda.l	#33,a1
	move.l	554(a6),d0		; KickCheckSumPtr
	bsr	.bbbin2hex
	adda.l	#35,a1
	move.l	300(a6),d0		; ResModules
	bsr	.bbbin2hex

	lea	int_lib(pc),a1
	moveq	#33,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	move.l	d0,a6
	beq.s	.back_2
	lea	bad_text(pc),a0
	moveq	#1,d0
	moveq	#95,d1
	jsr	-90(a6)		; _LVODisplayAlert
	cmp.l	#0,d0
	beq.s	.coldreset
	move.l	a6,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary
.back_2	movem.l	(sp)+,d0-d7/a0-a6
	rts

; -----  make ColdReset (sorry, this is NOT the StyleGuide-Reset,
; -----  but this works too)

.coldreset	move.l	4.w,a6
	jsr	-132(a6)		; _LVOForbid

	move.l	#0,38(a6)		; Exec_ChkBase
	move.l	#0,42(a6)		; ColdCapture
	move.l	#0,46(a6)		; CoolCapture
	move.l	#0,82(a6)		; Exec_ChkSum
	move.l	#0,300(a6)		; ResModules
	move.l	#0,546(a6)		; KickMemPtr
	move.l	#0,550(a6)		; KickTagPtr
	move.l	#0,554(a6)		; KickCheckSumPtr
	
; -----  make Soft-Reset
	
.softreset	jsr	-150(a6)		; _LVOSuperState
	move.l	#$fc0002,$20.w
	movea.l	#$f80002,a0
	reset			; reserved Cmd (SuperVisor)
	jmp	(a0)

; -----  Bin -> ASCII-Hex

.bbbin2hex	adda.l	#8,a1
	lea	hextab(pc),a0
	moveq	#7,d1
.loop	move.l	d0,d2
	and.l	#15,d2
	move.b	(a0,d2),-(a1)
	lsr.l	#4,d0
	dbra	d1,.loop
	rts

; -----  CopperList (oh what a sweet list !)

cop_start	dc.w	$180,$00d0
	dc.w	$7007,$fffe
	dc.w	$180,$0080
	dc.w	$d00d,$fffe
	dc.w	$180,$0040
	dc.w	$ffff,$fffe
cop_end

; -----  Variablen/Konstanen

cop_adress	dc.l	0

hextab	dc.b	"0123456789ABCDEF"

exp_lib	dc.b	"expansion.library",0
dos_lib	dc.b	"dos.library",0
gfx_lib	dc.b	"graphics.library",0
int_lib	dc.b	"intuition.library",0

bad_text	dc.b	0,128,15
	dc.b	"Some of your Vectors are not pointing to zero !!"
	dc.b	0,$ff,0,80,40
	dc.b	"ColdCapture:                        CoolCapture:           "
	dc.b	0,$ff,0,80,50
	dc.b	"KickMemPtr:                         KickTagPtr:            "
	dc.b	0,$ff,0,80,60
	dc.b	"KickCheckSumPtr:                    ResModulesBase:           "
	dc.b	0,$ff,0,24,85
	dc.b	"* [LMB] to continue *                               * [RMB] to ColdReset *"
	dc.b	0,0

	dc.b	0,"** MemTest V1.2 - 1993 by Jens Troeger **"

memtest_end

; -----  BootBlock: SCROLLER
; -----  thanx to Holger Gzella for his help !

scroller	dc.l	$444f5300		; Standart-Bootcode
	dc.l	$00000000
	dc.l	$00000370

.scroller	lea	fontname(pc),a0	; alloc and init all you need
	lea	textattr(pc),a1
	move.l	a0,(a1)

	lea	gfxname(pc),a1
	moveq	#33,d0
	move.l	4.w,a6
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq	.error_1
	lea	gfx_base(pc),a0
	move.l	d0,(a0)

 	move.l	d0,a6
	lea	textattr(pc),a0
	jsr	-72(a6)		; _LVOOpenFont
	cmp.l	#0,d0
	beq	.error_2
	lea	fontbase(pc),a0
	move.l	d0,(a0)

	move.l	#2000,d0
	move.l	#$10002,d1
	move.l	4.w,a6
	jsr	-198(a6)		; _LVOAllocMem
	cmp.l	#0,d0
	beq	.error_3
	lea	copperlist(pc),a0
	move.l	d0,(a0)
	
	move.l	#52*345,d0
	move.l	#$10002,d1
	move.l	4.w,a6
	jsr	-198(a6)		; _LVOAllocMem
	cmp.l	#0,d0
	beq	.error_4
	lea	bitplane(pc),a0
	move.l	d0,(a0)

	jsr	-132(a6)		; _LVOForbid

	move.w	#$3e0,$DFF096	; DMACON

	move.l	copperlist(pc),a0	; create the CopperList
	move.l	bitplane(pc),d2
	swap	d2
	move.w	#$0E0,(a0)+	; BPL1PTH
	move.w	d2,(a0)+
	move.w	#$0E2,(a0)+	; BPL1PTL
	swap	d2
	move.w	d2,(a0)+
	move.w	#$180,(a0)+	; COLOR00
	move.w	#$000,(a0)+
	move.w	#$182,(a0)+	; COLOR01
	move.w	#$000,(a0)+

	move.w	#$9001,d0		; create CopperList
	move.w	#$0000,d1		; the colors now...
	moveq	#$e,d2
.set_list1	move.w	d0,(a0)+
	move.w	#$fffe,(a0)+
	move.w	#$180,(a0)+
	move.w	d1,(a0)+
	add.w	#$100,d0
	add.w	#$101,d1
	dbra	d2,.set_list1
	moveq	#$f,d2
	add.w	#$a00,d0
.set_list2	move.w	d0,(a0)+
	move.w	#$fffe,(a0)+
	move.w	#$180,(a0)+
	move.w	d1,(a0)+
	add.w	#$100,d0
	sub.w	#$101,d1
	dbra	d2,.set_list2

	move.l	#$fffffffe,(a0)	; end of list

	move.l	copperlist(pc),$DFF080 ; COP1LCH
	move.w	#0,$DFF088		; COPJMP1

	move.w	#$1AC4,$DFF08E	; DIWSTRT
	move.w	#$39D8,$DFF090	; DIWSTOP
	move.w	#$0020,$DFF092	; DDFSTRT
	move.w	#$00D8,$DFF094	; DDFSTOP
	move.w	#$1000,$DFF100	; BPLCON0
	move.w	#0,$DFF102		; BPLCON1
	move.w	#0,$DFF104		; BPLCON2
	move.w	#4,$DFF108		; BPL1MOD
	move.w	#4,$DFF10A		; BPL2MOD

	move.w	#$83C0,$DFF096	; DMACON

	moveq.l	#0,d6
	lea	scrl_bufr(pc),a6

.scrollit	and.l   #$7,d6		; now we scroll the text
	bne.s   .scrollon

	move.l	fontbase(pc),a0
	move.l	34(a0),a3
	move.w	38(a0),d4
	move.w	d4,d5
	mulu	#7,d4
	add.l	d4,a3

	moveq.l	#0,d1

	move.b	(a6)+,d1
	bne.s	.not_last

	lea	scrl_bufr(pc),a6
	move.b	(a6)+,d1

.not_last	cmp.b	#127,d1
	bls.s	.no_spec

	sub.b	#32,d1

.no_spec	sub.b	#32,d1
	add.l	d1,a3

.scrollon	move.l	bitplane(pc),a0
	add.l	#143*52,a0
	moveq	#7,d1

	move.l	a3,a5

.sync_beam	move.l	$DFF004,d3		; VPOSR
	and.l	#$1ff00,d3
	cmp.l	#$08000,d3
	bne.s	.sync_beam

	addq.b	#$8,d6

.scroll_pl	moveq.l	#25,d3
	moveq	#0,d2
	move.b	(a5),d2
	sub.l	d5,a5

	roxl.w	#1,d2
	roxl.w	d6,d2

.scrl_wrd	roxl.w	-(a0)
	dbra	d3,.scrl_wrd
	dbra	d1,.scroll_pl
	addq	#1,d6

	btst.b	#6,$bfe001		; PRA (CIA-A)
	bne.s	.scrollit

	move.l	#0,$DFF088		; COPJMP1
	move.w	#$83E0,$DFF096	; DMACON

	move.l	4.w,a6
	jsr	-138(a6)		; _LVOPermit

	move.l	Bitplane(pc),a1
	move.l	#52*345,d0
           jsr	-210(a6)		; _LVOFreeMem

.error_4	move.l	copperlist(pc),a1
	move.l	#2000,d0
	move.l	4.w,a6
	jsr	-210(a6)		; _LVOFreeMem
	
.error_3	move.l	fontbase(pc),a1
	move.l	gfx_base(pc),a6
	jsr	-78(a6)		; _LVOCloseFont

.error_2	move.l	gfx_base(pc),a1
	; move.l	38(a1),$DFF080	; COP1LCH
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary

.error_1	lea	expname(pc),a1
	moveq	#37,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq.s	.no_explib
	movea.l	d0,a1
	bset	#6,34(a1)
	jsr	-414(a6)		; _LVOCloseLibrary
.no_explib	lea	dosname(pc),a1
	jsr	-96(a6)		; _LVOFindResident
	cmp.l	#0,d0
	beq.s	.not_found
	movea.l	d0,a0
	movea.l	22(a0),a0
	moveq	#0,d0
	rts
.not_found	moveq	#-1,d0
	rts

gfx_base	dc.l	0
fontbase	dc.l	0

copperlist	dc.l	0
bitplane	dc.l	0

textattr	dc.l	0
	dc.w	8
	dc.b	0,1

gfxname	dc.b	"graphics.library",0
	even
dosname	dc.b	"dos.library",0
	even
expname	dc.b	"expansion.library",0
	even
fontname	dc.b	"topaz.font",0
	even

scrl_bufr	ds.b	50
	even

scroller_end

	opt	o-,p-

; now the code of GadToolsBox - great Jan !

******************************************************
*
*  Source machine generated by GadToolsBox 37.313
*  which is (c) Copyright 1991-1993 Jaba Development
*
*  GUI Designed by : Jens Tröger
*

OpenScreenTagList    EQU    -612
OpenWindowTagList    EQU    -606
CloseScreen          EQU    -66
CloseWindow          EQU    -72
PrintIText           EQU    -216
LockPubScreen        EQU    -510
UnlockPubScreen      EQU    -516
SetMenuStrip         EQU    -264
ClearMenuStrip       EQU    -54
GetVisualInfoA       EQU    -126
FreeVisualInfo       EQU    -132
CreateContext        EQU    -114
CreateGadgetA        EQU    -30
GT_RefreshWindow     EQU    -84
FreeGadgets          EQU    -36
CreateMenusA         EQU    -48
LayoutMenusA         EQU    -66
FreeMenus            EQU    -54
OpenDiskFont         EQU    -30
CloseFont            EQU    -78
DrawBevelBoxA        EQU    -120
FreeClass            EQU    -714
NewObjectA           EQU    -636
DisposeObject        EQU    -642
TextLength           EQU    -54
CopyMem              EQU    -624
FindTagItem          EQU    -30
IntuiTextLength      EQU    -330
Forbid               EQU    -132
Permit               EQU    -138
RectFill             EQU    -306
SetAPen              EQU    -342
GetScreenDrawInfo    EQU    -690
FreeScreenDrawInfo   EQU    -696

GD_Gadget00                            EQU    0
GD_Gadget10                            EQU    1
GD_Gadget20                            EQU    2
GD_Gadget30                            EQU    3
GD_Gadget40                            EQU    4
GD_Gadget50                            EQU    5
GD_Gadget60                            EQU    6
GD_Gadget70                            EQU    7
GD_Gadget80                            EQU    8

Main_CNT    EQU    9

Scr:
    DC.L    0
VisualInfo:
    DC.L    0
PubScreenName:
    DC.L    0
MainWnd:
    DC.L    0
MainGList:
    DC.L    0
MainGadgets:
    DCB.L    9,0
BufNewGad:
    DC.W    0,0,0,0
    DC.L    0,0
    DC.W    0
    DC.L    0,0,0
TD:
    DC.L    $00000000
NR:
    DC.L    $80080034,$00000000,$00000000
IR:
    DC.L    $80080034,$00000000,$80080033,1,$00000000
MainLeft:
    DC.W    0
MainTop:
    DC.W    11
MainWidth:
    DC.W    432
MainHeight:
    DC.W    65
Font:
    DC.L    0
FontX:
    DC.W    0
FontY:
    DC.W    0
OffX:
    DC.W    0
OffY:
    DC.W    0
Attr:
    DC.L    0
    DC.W    0
    DC.B    0,0
TopazName:
    DC.B    'topaz.font',0
    CNOP    0,2

MainGTypes:
    DC.W    7
    DC.W    7
    DC.W    12
    DC.W    1
    DC.W    1
    DC.W    1
    DC.W    1
    DC.W    1
    DC.W    1

MainNGads:
    DC.W    107,7,133,14
    DC.L    Gadget00Text,0
    DC.W    GD_Gadget00
    DC.L    $0001,0,0
    DC.W    106,24,133,14
    DC.L    Gadget10Text,0
    DC.W    GD_Gadget10
    DC.L    $0001,0,0
    DC.W    271,7,142,14
    DC.L    Gadget20Text,0
    DC.W    GD_Gadget20
    DC.L    $0000,0,0
    DC.W    247,7,20,14
    DC.L    Gadget30Text,0
    DC.W    GD_Gadget30
    DC.L    $0010,0,0
    DC.W    248,24,166,14
    DC.L    Gadget40Text,0
    DC.W    GD_Gadget40
    DC.L    $0010,0,0
    DC.W    7,48,91,14
    DC.L    Gadget50Text,0
    DC.W    GD_Gadget50
    DC.L    $0010,0,0
    DC.W    116,48,91,14
    DC.L    Gadget60Text,0
    DC.W    GD_Gadget60
    DC.L    $0010,0,0
    DC.W    225,48,91,14
    DC.L    Gadget70Text,0
    DC.W    GD_Gadget70
    DC.L    $0010,0,0
    DC.W    334,48,91,14
    DC.L    Gadget80Text,0
    DC.W    GD_Gadget80
    DC.L    $0010,0,0

MainGTags:
    DC.L    $8008000E,Gadget00Labels
    DC.L    $80080040,'_'
    DC.L    $00000000
    DC.L    $8008000E,Gadget10Labels
    DC.L    $80080040,'_'
    DC.L    $00000000
    DC.L    $8008002D,Gadget20String
    DC.L    $8008002E,256
    DC.L    $8003000E,1
    DC.L    $00000000
    DC.L    $80080040,'_'
    DC.L    $8003000E,1
    DC.L    $00000000
    DC.L    $80080040,'_'
    DC.L    $00000000
    DC.L    $80080040,'_'
    DC.L    $8003000E,0
    DC.L    $00000000
    DC.L    $80080040,'_'
    DC.L    $8003000E,0
    DC.L    $00000000
    DC.L    $80080040,'_'
    DC.L    $8003000E,0
    DC.L    $00000000
    DC.L    $80080040,'_'
    DC.L    $8003000E,0
    DC.L    $00000000


Gadget20String:
    DC.B    'Bootblocks:',0
    CNOP    0,2

Gadget00Text:
    DC.B    '_Bootblock',0

Gadget10Text:
    DC.B    '_FileSystem',0

Gadget20Text:
    DC.B    '',0

Gadget30Text:
    DC.B    '_?',0

Gadget40Text:
    DC.B    '_About',0

Gadget50Text:
    DC.B    'DF_0',0

Gadget60Text:
    DC.B    'DF_1',0

Gadget70Text:
    DC.B    'DF_2',0

Gadget80Text:
    DC.B    'DF_3',0

    CNOP    0,2

Gadget00Labels:
    DC.L    Gadget00Lab0
    DC.L    Gadget00Lab1
    DC.L    Gadget00Lab2
    DC.L    Gadget00Lab3
    DC.L    Gadget00Lab4
    DC.L    Gadget00Lab5
    DC.L    0

Gadget10Labels:
    DC.L    Gadget10Lab0
    DC.L    Gadget10Lab1
    DC.L    Gadget10Lab2
    DC.L    Gadget10Lab3
    DC.L    Gadget10Lab4
    DC.L    Gadget10Lab5
    DC.L    0

Gadget00Lab0:    DC.B    'DOS cleared',0
Gadget00Lab1:    DC.B    'Standard',0
Gadget00Lab2:    DC.B    'Message',0
Gadget00Lab3:    DC.B    'Scroller',0
Gadget00Lab4:    DC.B    'MemCheck',0
Gadget00Lab5:    DC.B    '(File)',0

    CNOP    0,2

Gadget10Lab0:    DC.B    'OFS',0
Gadget10Lab1:    DC.B    'FFS',0
Gadget10Lab2:    DC.B    'OFS int',0
Gadget10Lab3:    DC.B    'FFS int',0
Gadget10Lab4:    DC.B    'DC-OFS',0
Gadget10Lab5:    DC.B    'DC-FFS',0

    CNOP    0,2

MainWindowTags:
MainL:
    DC.L    $80000064,0
MainT:
    DC.L    $80000065,0
MainW:
    DC.L    $80000066,0
MainH:
    DC.L    $80000067,0
    DC.L    $8000006A,$00200244
    DC.L    $8000006B,$0001100E
MainWG:
    DC.L    $8000006C,0
    DC.L    $8000006E,MainWTitle
    DC.L    $8000006F,MainSTitle
MainSC:
    DC.L    $80000079,0
    DC.L    $00000000

MainWTitle:
    DC.B    'xInstall v1.1   © 1994 by Jens Tröger',0
    CNOP    0,2

MainSTitle:
    DC.B    'xInstall v1.1',0
    CNOP    0,2

ComputeX:
    move.l  d1,-(sp)
    move.w  FontX,d1
    bra.s   ComputeItX
ComputeY:
    move.l  d1,-(sp)
    move.w  FontY,d1
    mulu    d1,d0
    addq.w  #4,d0
    divu    #8,d0
    ext.l   d0
    move.l  (sp)+,d1
    rts

ComputeItX:
    mulu    d1,d0
    addq.w  #4,d0
    divu    #8,d0
    ext.l   d0
    move.l  (sp)+,d1
    rts

ComputeFont:
    lea.l   Attr,a0
    move.l  a0,Font
    move.l  Scr,a1
    lea.l   84(a1),a1
    move.l  52(a1),a1
    move.l  10(a1),(a0)
    move.w  20(a1),4(a0)
    move.w  24(a1),FontX
    move.w  20(a1),FontY
    move.l  Scr,a0
    move.b  36(a0),d0
    ext.w   d0
    move.w  d0,OffX
    move.l  40(a0),a1
    move.w  4(a1),d0
    addq.w  #1,d0
    move.b  35(a0),d1
    ext.w   d1
    add.w   d1,d0
    move.w  d0,OffY
    tst.w   d2
    beq.s   CompDone
    tst.w   d3
    beq.s   CompDone
    move.w  d2,d0
    jsr     ComputeX
    add.w   OffX,d0
    move.b  37(a0),d1
    ext.w   d1
    add.w   d1,d0
    cmp.w   12(a0),d0
    bhi.s   UseTopaz
    move.w  d3,d0
    jsr     ComputeY
    add.w   OffY,d0
    move.b  38(a0),d1
    ext.w   d1
    add.w   d1,d0
    cmp.w   14(a0),d0
    bhi.s   UseTopaz
CompDone:
    rts
UseTopaz:
    move.l  Font,a0
    move.l  #TopazName,(a0)
    move.w  #8,FontY
    move.w  #8,FontX
    move.w  #8,4(a0)
    rts

SetupScreen
    movem.l d1-d3/a0-a2/a6,-(sp)
    move.l  intbase,a6
    move.l  PubScreenName,a0
    jsr     LockPubScreen(a6)
    move.l  d0,Scr
    tst.l   d0
    beq     SError
    moveq   #0,d2
    moveq   #0,d3
    jsr     ComputeFont
    move.l  Scr,a0
    move.l  gadbase,a6
    lea.l   TD,a1
    jsr     GetVisualInfoA(a6)
    move.l  d0,VisualInfo
    tst.l   d0
    beq     VError
    moveq   #0,d0
SDone:
    movem.l (sp)+,d1-d3/a0-a2/a6
    rts
SError:
    moveq   #1,d0
    bra.s   SDone
VError:
    moveq   #2,d0
    bra.s   SDone

CloseDownScreen:
    movem.l d0-d1/a0-a1/a6,-(sp)
    move.l  gadbase,a6
    move.l  VisualInfo,a0
    cmpa.l  #0,a0
    beq.s   NoVis
    jsr     FreeVisualInfo(a6)
    move.l  #0,VisualInfo
NoVis:
    move.l  intbase,a6
    suba.l  a0,a0
    move.l  Scr,a1
    cmpa.l  #0,a1
    beq.s   NoScr
    jsr     UnlockPubScreen(a6)
    move.l  #0,Scr
NoScr:
    movem.l (sp)+,d0-d1/a0-a1/a6
    rts

MainRender:
    movem.l d0-d5/a0-a2/a6,-(sp)

; -----  now some code of mine

    move.l  mainwnd,a0
    bsr     wd_pattern

; -----  yep, the end (very short, isn`t it ??)
    
    move.l  MainWnd,a0
    move.w  MainWidth,d2
    move.w  MainHeight,d3
    jsr     ComputeFont
    move.l  VisualInfo,NR+4
    move.l  VisualInfo,IR+4
    move.l  gadbase,a6
    move.l  MainWnd,a0
    move.l  50(a0),a2
    move.l  a2,a0
    lea.l   NR,a1
    move.l  #3,d0
    jsr     ComputeY
    add.w   OffY,d0
    move.l  d0,d1
    move.l  #418,d0
    jsr     ComputeX
    move.l  d0,d2
    move.l  #42,d0
    jsr     ComputeY
    move.l  d0,d3
    move.l  #7,d0
    jsr     ComputeX
    add.w   OffX,d0

; -----  oh ha, again a little more code (setup a BevelBox and
; -----  fill the room IN it !!!!)
    
    movem.l d0-d3/a0/a1/a6,-(sp)
    movem.l d0-d3,-(sp)
    move.l  Scr,a0
    move.l  intbase,a6
    jsr     GetScreenDrawInfo(a6)
    move.l  d0,d6
    move.l  d0,a0
    move.l  $04(a0),a0
    move.w  $0e(a0),d2
    move.l  Scr,a0
    move.l  d6,a1
    jsr     FreeScreenDrawInfo(a6)
    move.l  a2,a1
    moveq   #0,d0
    move.w  d2,d0
    move.l  gfxbase,a6
    jsr     SetAPen(a6)
    move.l  a2,a1
    movem.l (sp)+,d0-d3
    add.l   d0,d2
    add.l   d1,d3
    subq.l  #1,d2
    subq.l  #1,d3
    jsr     RectFill(a6)
    movem.l (sp)+,d0-d3/a0/a1/a6

; -----  the end again
    
    jsr     DrawBevelBoxA(a6)
    movem.l (sp)+,d0-d5/a0-a2/a6
    rts

OpenMainWindow:
    movem.l d1-d4/a0-a4/a6,-(sp)
    move.l  Scr,a0
    moveq   #0,d3
    moveq   #0,d2
    move.w  MainWidth,d2
    move.w  MainHeight,d3
    jsr     ComputeFont
    move.l  Scr,a0
    move.l  d2,d0
    jsr     ComputeX
    move.l  d0,d4
    move.w  MainLeft,d2
    add.w   d2,d0
    add.w   OffX,d0
    move.b  37(a0),d1
    ext.w   d1
    add.w   d1,d0    cmp.w   12(a0),d0
    bls.s   MainWOk
    move.w  12(a0),d0
    sub.w   d4,d0
    move.w  d0,d2
MainWOk:
    move.l  d3,d0
    jsr     ComputeY
    move.l  d0,d4
    move.w  MainTop,d3
    add.w   d3,d0
    add.w   OffY,d0
    move.b  38(a0),d1
    ext.w   d1
    add.w   d1,d0
    cmp.w   14(a0),d0
    bls.s   MainHOk
    move.w  14(a0),d0
    sub.w   d4,d0
    move.w  d0,d3
MainHOk:
    move.l  gadbase,a6
    lea.l   MainGList,a0
    jsr     CreateContext(a6)
    move.l  d0,a3
    tst.l   d0
    beq     MainCError
    movem.w d2-d3,-(sp)
    moveq   #0,d3
    lea.l   MainGTags,a4
MainGL:
    move.l  4.w,a6
    lea.l   MainNGads,a0
    move.l  d3,d0
    mulu    #30,d0
    add.l   d0,a0
    lea.l   BufNewGad,a1
    moveq   #30,d0
    jsr     CopyMem(a6)
    lea.l   BufNewGad,a0
    move.l  VisualInfo,22(a0)
    move.l  Font,12(a0)
    move.w  (a0),d0
    jsr     ComputeX
    add.w   OffX,d0
    move.w  d0,(a0)
    move.w  2(a0),d0
    jsr     ComputeY
    add.w   OffY,d0
    move.w  d0,2(a0)
    move.w  4(a0),d0
    jsr     ComputeX
    move.w  d0,4(a0)
    move.w  6(a0),d0
    jsr     ComputeY
    move.w  d0,6(a0)
    move.l  gadbase,a6
    lea.l   MainGTypes,a0
    moveq   #0,d0
    move.l  d3,d1
    asl.l   #1,d1
    add.l   d1,a0
    move.w  (a0),d0
    move.l  a3,a0
    lea.l   BufNewGad,a1
    move.l  a4,a2
    jsr     CreateGadgetA(a6)
    tst.l   d0
    bne.s    MainCOK
    movem.w (sp)+,d2-d3
    bra     MainGError
MainCOK:
    move.l  d0,a3
    move.l  d3,d0
    asl.l   #2,d0
    lea.l   MainGadgets,a0
    add.l   d0,a0
    move.l  a3,(a0)
MainTL:
    tst.l   (a4)
    beq.s   MainDN
    addq.w  #8,a4
    bra.s   MainTL
MainDN:
    addq.w  #4,a4
    addq.w  #1,d3
    cmp.w   #Main_CNT,d3
    bmi     MainGL
    movem.w (sp)+,d2-d3
    move.l  MainGList,MainWG+4
    move.l  Scr,MainSC+4
    ext.l   d2
    ext.l   d3
    move.l  d2,MainL+4
    move.l  d3,MainT+4
    move.l  Scr,a0
    move.w  MainWidth,d0
    jsr     ComputeX
    add.w   OffX,d0
    move.b  37(a0),d1
    ext.w   d1
    add.w   d1,d0
    move.l  d0,MainW+4
    move.w  MainHeight,d0
    jsr     ComputeY
    add.w   OffY,d0
    move.b  38(a0),d1
    ext.w   d1
    add.w   d1,d0
    move.l  d0,MainH+4
    move.l  intbase,a6
    suba.l  a0,a0
    lea.l   MainWindowTags,a1
    jsr     OpenWindowTagList(a6)
    move.l  d0,MainWnd
    tst.l   d0
    beq     MainWError
    move.l  gadbase,a6
    move.l  MainWnd,a0
    suba.l  a1,a1
    jsr     GT_RefreshWindow(a6)
    jsr     MainRender
    moveq   #0,d0
MainDone:
    movem.l (sp)+,d1-d4/a0-a4/a6
    rts
MainCError:
    moveq   #1,d0
    bra.s   MainDone
MainGError:
    moveq   #2,d0
    bra.s   MainDone
MainWError:
    moveq   #4,d0
    bra.s   MainDone

CloseMainWindow:
    movem.l d0-d1/a0-a2/a6,-(sp)
    move.l  intbase,a6
    move.l  MainWnd,a0
    cmpa.l  #0,a0
    beq     MainNWnd
    jsr     CloseWindow(a6)
    move.l  #0,MainWnd
MainNWnd:
    move.l  gadbase,a6
    move.l  MainGList,a0
    cmpa.l  #0,a0
    beq     MainNGad
    jsr     FreeGadgets(a6)
    move.l  #0,MainGList
MainNGad:
    movem.l (sp)+,d0-d1/a0-a2/a6
    rts

    end
