
******************************************************
*                   XInstall v1.4                    *
*          copyright © 1994 by Jens Tröger           *
*                 all rights reserved                *
******************************************************
*     take NO care for my english - it`s terrible    *
******************************************************
*  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 v1.2 goes WB                                 *
*     o v1.2a: i modified the GTB-source (now faster *
*       and no bugs -I hope-) [sorry, Jan], removed  *
*       the terrible flicker at startup              *
*     o v1.3 all error-messages are localized        *
*     o v1.3a the localization failed (don`t know    *
*       why !), but one bug killed, the string-gad   *
*       goes colored when activated                  *
*     o v1.3b still working on localization, some    *
*       code optimized                               *
*     o v1.3c now localized (thanks Oliver !!) and   *
*       no trouble anymore (ON MY MACHINE)           *
*     o v1.3d new workbench-startup, code more       *
*       optimized                                    *
*     o v1.4 GUI a little bit changed. Show and Read *
*       added. Does not calc CheckSum when BB Empty  *
*       is on.                                       *
*     o v1.4a trouble with big proportional-fonts on *
*       high resolution removed                      *
******************************************************
*  Assembler:   DevPac v2.14d (tab 11)               *
*               DevPac v3.04
*  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)

loclea	MACRO			; important for localized xInstall
	pea.l	\1		; thanx to ALEXANDER KOCHMANN
	opt	w-		; and OLIVER REIFF
	bsr	get_string
	opt	w+
	move.l	(sp)+,\2
	ENDM

 SECTION "xInstall_CODE",CODE

; -----  first save command-line (if cli-start)
; -----  later it will be ignored...

	movem.l	d0/a0,-(sp)	; length (d0) and adress (a0)
				; of command-line

; -----  Where did we start from ? CLI or WB...

	moveq	#0,d7
	move.l	4.w,a6
	sub.l	a1,a1		; own task
	jsr	-294(a6)		; _LVOFindTask
	move.l	d0,a0
	move.l	d0,thistask
	tst.l	172(a0)		; pr_CLI (APTR to CLI-Struc)
	bne.s	from_cli
from_wb	lea.l	92(a0),a0		; pr_MsgPort
	jsr	-384(a6)		; _LVOWaitPort
	jsr	-372(a6)		; _LVOGetMsg
	move.l	d0,wbenchmsg
from_cli	movem.l	(sp)+,d0/a0

	bsr.s	go_do_it

	tst.l	wbenchmsg
	beq.s	exit
	move.l	4.w,a6
	jsr	-132(a6)		; _LVOForbid
	move.l	d7,a1
	jsr	-378(a6)		; _LVOReplyMsg
exit	moveq	#0,d0
	rts

******************************************************
*                   XInstall v1.4                    *
*       this goes, when started from Workbench       *
******************************************************

go_do_it	

; -----  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

	move.l	#0,locbase		; clear these pointers
	move.l	#0,catalog

; -----  open locale.library and xinstall.catalog to use localized strings

open_loc	move.l	4.w,a6
	lea.l	loc_name,a1
	moveq	#37,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	move.l	d0,locbase
	beq.s	init_tderr
	move.l	d0,a6
	move.l	#0,a0
	lea.l	cat_name,a1
	move.l	#0,a2
	jsr	-150(a6)		; _LVOOpenCatalogA
	move.l	d0,catalog

; -----  now fill the td_errtab with pointers to the error-strings

init_tderr	lea.l	td_errtab,a5
	loclea	err_txt1,(a5)+
	loclea	err_txt2,(a5)+
	loclea	err_txt3,(a5)+
	loclea	err_txt4,(a5)+
	loclea	err_txt5,(a5)+
	loclea	err_txt6,(a5)+
	loclea	err_txt7,(a5)+
	loclea	err_txt8,(a5)+
	loclea	err_txt9,(a5)+
	loclea	err_txt10,(a5)+
	loclea	err_txt11,(a5)+
	loclea	err_txt12,(a5)+
	loclea	err_txt13,(a5)+
	loclea	err_txt14,(a5)+
	loclea	err_txt15,(a5)+
	loclea	err_txt16,(a5)+
	loclea	err_txt17,(a5)+

; -----  this will setup the localized gadgets (no more full 
; -----  key-selection available... sorry)

	loclea	gadget6txt,gad6_text
	loclea	gadget7txt,gad7_text
	loclea	gadget8txt,gad8_text
	loclea	gadget9txt,gad9_text
	loclea	bb1_text,gad0_lab
	loclea	bb2_text,gad0_lab+4
	loclea	bb3_text,gad0_lab+8
	loclea	bb4_text,gad0_lab+12
	loclea	bb5_text,gad0_lab+16
	loclea	bb6_text,gad0_lab+20
	loclea	fmt_text,scrl_tags+60

; -----  now find the underscored letter of gadget`s text and use it

find_under	loclea	gadget6txt,a0
.loop_1	cmp.b	#"_",(a0)+
	beq.s	.found_1
	cmp.b	#0,(a0)
	beq.s	.search_2
	bra.s	.loop_1
.found_1	move.b	(a0),d0
	move.b	d0,read_key1
	cmp.b	#"a",d0
	blt.s	.big_1
	sub.b	#$20,d0
	move.b	d0,read_key2
	bra.s	.search_2
.big_1	add.b	#$20,d0
	move.b	d0,read_key2

.search_2	loclea	gadget7txt,a0
.loop_2	cmp.b	#"_",(a0)+
	beq.s	.found_2
	cmp.b	#0,(a0)
	beq.s	.search_3
	bra.s	.loop_2
.found_2	move.b	(a0),d0
	move.b	d0,load_key1
	cmp.b	#"a",d0
	blt.s	.big_2
	sub.b	#$20,d0
	move.b	d0,load_key2
	bra.s	.search_3
.big_2	add.b	#$20,d0
	move.b	d0,load_key2
	
.search_3	loclea	gadget8txt,a0
.loop_3	cmp.b	#"_",(a0)+
	beq.s	.found_3
	cmp.b	#0,(a0)
	beq.s	.search_4
	bra.s	.loop_3
.found_3	move.b	(a0),d0
	move.b	d0,show_key1
	cmp.b	#"a",d0
	blt.s	.big_3
	sub.b	#$20,d0
	move.b	d0,show_key2
	bra.s	.search_4
.big_3	add.b	#$20,d0
	move.b	d0,show_key2

.search_4	loclea	gadget9txt,a0
.loop_4	cmp.b	#"_",(a0)+
	beq.s	.found_4
	cmp.b	#0,(a0)
	beq.s	.done
	bra.s	.loop_4
.found_4	move.b	(a0),d0
	move.b	d0,about_key1
	cmp.b	#"a",d0
	blt.s	.big_4
	sub.b	#$20,d0
	move.b	d0,about_key2
	bra.s	.done
.big_4	add.b	#$20,d0
	move.b	d0,about_key2
.done

; -----  if started from CLI printout funny message (ha ha ha !!)

	tst.l	wbenchmsg
	bne.s	open_rt

funny_out1	lea.l	dos_name,a1
	moveq	#37,d0
	move.l	4.w,a6
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq.s	open_rt
	move.l	d0,a6
	jsr	-60(a6)		; _LVOOutput
	move.l	d0,d1
	loclea	funny_msg1,a0
	move.l	a0,d2
	moveq	#0,d3
.count_chr	cmp.b	#0,(a0)+
	beq.s	.out
	addq	#1,d3
	bra.s	.count_chr
.out	jsr	-48(a6)		; _LVOWrite
	move.l	a6,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary

; -----  open reqtools.library  *** brilliant, Nico François **
	
open_rt	move.l	4.w,a6
	lea.l	req_name,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 big work on your code to make
; -----  it better (you know the bug !) and to add the 
; -----  pattern (thanx again) to the window

open_scr	bsr	setup_scr
	cmp.l	#0,d0
	beq.s	open_wnd
	bra	scr_failed
open_wnd	bsr	setup_wnd
	cmp.l	#0,d0
	beq.s	add_port
	bra	wnd_failed

; -----  add a port for device-operation

add_port	move.l	thistask,replyport+16
	lea.l	replyport,a1
	move.l	4.w,a6
	jsr	-354(a6)		; _LVOAddPort

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

check_drvs	move.l	gad_list,a3	; disable Drive-Gads if not
	moveq	#2,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	disable_gg

.check_dev	lea.l	track_name,a0	; if OpenDevice fails, the 
	lea.l	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	window,a1
	move.l	#0,a2
	move.l	intbase,a6
	jmp	-174(a6)		; _LVOOffGadget
.device_on	lea.l	disk_io,a1
	jmp	-450(a6)		; _LVOCloseDevice

; ------  disable the FileSelect- and Read-Gadgets

disable_gg	lea	dis_tab,a1
	moveq	#1,d2
.loop2	move.l	(a1)+,d0
	move.l	gad_list,a0
.loop1	move.l	(a0),a0
	dbra	d0,.loop1
	move.l	a0,getfile_1
	movem.l	a1,-(sp)
	move.l	window,a1
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-174(a6)		; _LVOOffGadget
	movem.l	(sp)+,a1
	dbra	d2,.loop2

; -----  write window-ptr to requester-tags and process-structure

	move.l	window,about_tags+4	; WindowPtr 4 rtRequesters
	move.l	window,freq_tags+4
	move.l	window,scrl_tags+4
	move.l	thistask,a0
	move.l	window,$b8(a0)	; pr_WindowPtr

; -----  wait for message

get_msg	move.l	4.w,a6
	move.l	window,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,a1
	move.l	$14(a1),d0		; im_Class d0
	move.w	$18(a1),d1		; im_Code d1
	move.l	$1c(a1),d2		; im_IAdress d2
	movem.l	d0-d2,-(sp)
	jsr	-78(a6)		; _LVOGT_ReplyIMsg
	movem.l	(sp)+,d0-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.l	jmp_tab1,a0	; see the table below
	adda.l	d0,a0
	move.l	(a0),a0
	jmp	(a0)

keypressed	lea.l	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
	lea.l	6(a0),a0
	bra.s	.key_loop
.key_jump	lea.l	2(a0),a0
	move.l	(a0),a0
	jmp	(a0)

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

quit	bsr	close_wnd
	bsr	close_scr

; -----  remove the port
	
rem_port	lea.l	replyport,a1
	move.l	4.w,a6
	jsr	-360(a6)		; _LVORemPort

; -----  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

; -----  close locale.library 

no_reqlib	cmp.l	#0,catalog
	beq.s	.close_loc
	move.l	catalog,a0
	move.l	locbase,a6
	jsr	-36(a6)		; _LVOCloseCatalog
.close_loc	cmp.l	#0,locbase
	beq.s	funny_out2
	move.l	locbase,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary

; -----  complete the very funny message

funny_out2	tst.l	wbenchmsg
	bne.s	go_away

funny_out	lea.l	dos_name,a1
	moveq	#37,d0
	move.l	4.w,a6
	jsr	-552(a6)		; _LVOOpenLibrary
	cmp.l	#0,d0
	beq.s	go_away
	move.l	d0,a6
	jsr	-60(a6)		; _LVOOutput
	move.l	d0,d1
	loclea	funny_msg2,a0
	move.l	a0,d2
	moveq	#0,d3
.count_chr	cmp.b	#0,(a0)+
	beq.s	.out
	addq	#1,d3
	bra.s	.count_chr
.out	jsr	-48(a6)		; _LVOWrite
	move.l	a6,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary

; -----  NOW quit away...

go_away	moveq	#0,d0
	rts

; -----  cry for help

scr_failed
wnd_failed	move.l	reqbase,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary
	move.l	locbase,a1
	move.l	4.w,a6
	jsr	-414(a6)		; _LVOCloseLibrary

no_kick20	moveq	#20,d0		; no Kick
	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.l	gtcy_act,a3
	move.b	bb_id,7(a3)
	move.l	gad_list,a0
	move.l	(a0),a0
	move.l	window,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
	move.w	$0c(a0),d0
	btst	#8,d0		; DISABLED-Bit already set ?
	bne	get_msg		; yoop -> don`t disable gadget
	lea	dis_tab,a1
	moveq	#1,d2
.loop2	move.l	(a1)+,d0
	move.l	gad_list,a0
.loop1	move.l	(a0),a0
	dbra	d0,.loop1
	move.l	a0,getfile_1
	movem.l	a1,-(sp)
	move.l	window,a1
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-174(a6)		; _LVOOffGadget
	movem.l	(sp)+,a1
	dbra	d2,.loop2
	bra	get_msg
	
.en_path	lea	dis_tab,a1
	moveq	#1,d2
.loop4	move.l	(a1)+,d0
	move.l	gad_list,a0
.loop3	move.l	(a0),a0
	dbra	d0,.loop3
	move.l	a0,getfile_1
	movem.l	a1,-(sp)
	move.l	window,a1
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-186(a6)		; _LVOOnGadget
	movem.l	(sp)+,a1
	dbra	d2,.loop4
	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.l	gtcy_act,a3
	move.b	fs_id,7(a3)
	move.l	gad_list,a0
	move.l	(a0),a0
	move.l	(a0),a0
	move.l	window,a1
	move.l	#0,a2
	move.l	gadbase,a6
	jsr	-42(a6)		; _LVOGT_SetGadgetAttrsA
	bra	get_msg

; -----  About-Requester

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

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

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

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

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

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

inst_goon	cmp.b	#3,bb_id
	beq	scroll_bb
	bra	do_install

get_ggptr	move.l	gad_list,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

load	move.l	getfile_1,a0	; if Gadget disabled -> ignore
	move.w	$0c(a0),d0
	btst	#8,d0		; gg_Flags -> DISABLED
	bne	get_msg
	
	move.l	bb_mem,a0
	move.l	#1023,d0
.loop1	move.b	#0,(a0)+
	dbra	d0,.loop1

	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.l	freq_tags,a0
	move.l	d0,a1
	move.l	d0,d7
	lea.l	freq_array,a2
	loclea	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.l	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
	lea.l	1(a0),a0
	move.b	#"/",(a0)
.file2path	lea.l	1(a0),a0
	lea.l	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	window,a1
	move.l	#0,a2
	lea.l	stringtags,a3
	lea.l	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

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

.go_exam	move.l	d0,d5
	move.l	d0,d1
	move.l	#examine_bf,d2
	jsr	-102(a6)		; _LVOExamine
	move.l	d5,d1
	jsr	-90(a6)		; _LVOUnLock
	lea.l	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	.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	.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	#$ffffff00,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.l	about_tags,a0	; ERROR: File no BB
	loclea	err3_text,a1
	loclea	err1_gad,a2
	bsr	do_req
	bra.s	.clr_bfr

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

.read_err	lea.l	about_tags,a0	; ERROR: can`t read
	loclea	err4_text,a1
	loclea	err1_gad,a2
	bsr	do_req

.clr_bfr	move.l	bb_mem,a0
	move.l	#1023,d0
.loop	move.b	#0,(a0)+
	dbra	d0,.loop
	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.l	scrl_tags,a0
	lea.l	scrl_bufr,a1
	lea.l	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.l	scroller,a1
	move.l	#scroller_end-scroller-1,d0
.copy_loop	move.b	(a1)+,(a0)+
	dbra	d0,.copy_loop
	
; -----  Install-Routine (will react to errors !)

; in:    d5 - drive
; out:   -

do_install	movem.l	d0-d7/a0-a6,-(sp)
	move.w	#3,dev_cmd
	cmp.b	#3,bb_id
	beq.s	.goon1
	cmp.b	#5,bb_id
	beq.s	.goon1
	bsr	copy2bfr
.goon1	move.l	bb_mem,a0
	move.b	fs_id,3(a0)	; don`t forget the FileSystem
	bsr	calc_csm		; and the CheckSum
	move.l	show_gg,a0
	move.w	$0c(a0),d0
	btst	#7,d0
	beq.s	do_device
	bsr	show_bb
	tst.l	d0
	bne.s	do_device
	move.l	bb_mem,a0
	move.l	#255,d0
.bfr_clr	move.l	#0,(a0)+		; after writing clear the
	dbra	d0,.bfr_clr	; buffer
.return	movem.l	(sp)+,d0-d7/a0-a6
	bra	get_msg

; -----  read/write bb from/to disk (read always unit 0)

do_device	lea.l	disk_io,a1
	move.l	#replyport,14(a1)
	move.l	d5,d0
	moveq	#0,d1
	lea.l	track_name,a0
	move.l	4.w,a6
	jsr	-444(a6)		; _LVOOpenDevice
	cmp.l	#0,d0
	bne	.no_device
	lea.l	disk_io,a1
	move.w	dev_cmd,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.l	disk_io,a1
	jsr	-450(a6)		; _LVOCloseDevice
	cmp.w	#2,dev_cmd
	beq.s	.return
.done	move.l	bb_mem,a0
	move.l	#255,d0
.bfr_clr	move.l	#0,(a0)+		; after writing clear the
	dbra	d0,.bfr_clr	; buffer
.return	movem.l	(sp)+,d0-d7/a0-a6
	bra	get_msg

.no_bb	loclea	err_txt4,a1	; react to the errors
	bra.s	.error_out
.no_device	lea.l	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.l	td_errtab,a1	; see the tab below
	adda.l	d0,a1
	move.l	(a1),a1
.error_out	lea.l	about_tags,a0
	lea.l	about_gad,a2
	bsr	do_req
	movem.l	(sp)+,d0-d7/a0-a6
	bra	get_msg

; -----  this will copy the boot-code to the install-buffer, if not
; -----  selected "Scroller" or "(File)"

copy2bfr	movem.l	a0/a1/d0,-(sp)
	move.l	bb_mem,a0		; first clear the buffer
	move.l	#1023,d0
.clr_loop	move.b	#0,(a0)+
	dbra	d0,.clr_loop
	moveq	#0,d0
	move.b	bb_id,d0		; calc adress and length of
	lsl.l	#3,d0		; Bootblock to copy (see table
	lea.l	bb_table,a0	; bb_table !)
	adda.l	d0,a0
	move.l	a0,a1
	lea.l	4(a1),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
	movem.l	(sp)+,a0/a1/d0
	rts

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

calc_csm	movem.l	a1/d0/d1,-(sp)	; this way you calc BB`s CSum
	cmp.b	#0,bb_id
	beq.s	.all_done
	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)
.all_done	movem.l	(sp)+,a1/d0/d1
	rts

; -----  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)
	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	28(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)+,d1-d7/a0-a6
	moveq	#-1,d0
	rts

; -----  this will toggle the show-gadget

show	move.l	window,a0
	move.l	show_gg,a1
	move.l	intbase,a6
	jsr	-228(a6)		; _LVORemoveGadget
	move.l	window,a0
	move.l	show_gg,a1
	eor.w	#$80,$0c(a1)	; gg_Activation
	jsr	-42(a6)		_LVOAddGadget
	move.l	show_gg,a0
	move.l	window,a1
	move.l	#0,a2
	moveq	#1,d0
	jsr	-432(a6)		; _LVORefreshGList
	bra	get_msg	

; -----  the following code shows an ASCII-Dump of the actual bb
; -----  using a reqtools-requester

show_bb	movem.l	d1/d2/d7/a0/a1/a2/a6,-(sp)
	move.l	4.w,a6		; mem to show bootblock
	move.l	#1024+18+78,d0	; bb: 1024 CR: 18 info: 78
	move.l	#$10001,d1
	jsr	-198(a6)		; _LVOAllocMem
	tst.l	d0
	beq	.done
	move.l	d0,d7
	move.l	d0,a1
	loclea	show_text,a0	; make head-information
	moveq	#77,d0
.loop0	move.b	(a0)+,(a1)+
	dbra	d0,.loop0
	move.l	d7,a1
	lea	25(a1),a1		; 1st bb`s name
	moveq	#0,d0
	move.b	bb_id,d0
	lsl.l	#2,d0
	lea.l	gad0_lab,a0
	lea.l	(a0,d0.l),a0
	move.l	(a0),a0
	moveq	#-1,d0
.loop3	cmp.b	#0,(a0)+
	beq.s	.goon1
	addq.l	#1,d0
	bra.s	.loop3
.goon1	lea.l	-1(a0),a0
.loop4	move.b	-(a0),-(a1)
	dbra	d0,.loop4
	move.l	d7,a1		; 2nd bb`s FileSystem
	lea	51(a1),a1
	moveq	#0,d0
	move.b	fs_id,d0
	lsl.l	#2,d0
	lea	gad1_lab,a0
	lea.l	(a0,d0.l),a0
	move.l	(a0),a0
	moveq	#-1,d0
.loop5	cmp.b	#0,(a0)+
	beq.s	.goon2
	addq.l	#1,d0
	bra.s	.loop5
.goon2	lea.l	-1(a0),a0
.loop6	move.b	-(a0),-(a1)
	dbra	d0,.loop6
	move.l	d7,a1		; 3rd bb`s checksum
	lea	77(a1),a1
	move.l	bb_mem,a0
	move.l	4(a0),d0
	bsr.s	.bbbin2hex
	move.l	d7,a1		; now copy the bb to the buffer...
	lea	78(a1),a1
	move.l	bb_mem,a0
	moveq	#15,d0		; ...check for illegal ASCII...
.loop1	moveq	#63,d1
	move.b	#10,(a1)+
.loop2	move.b	(a0)+,(a1)
	cmp.b	#31,(a1)
	bgt.s	.goon4
	move.b	#".",(a1)
.goon4	lea.l	1(a1),a1
	dbra	d1,.loop2
	dbra	d0,.loop1
	lea.l	about_tags,a0	; ...and setup the requester
	move.l	#0,ez_flags
	move.l	d7,a1
	loclea	show_gads,a2
	bsr	do_req
	move.l	d0,d2
.free_mem	move.l	d7,a1
	move.l	#1024+18+78,d0
	jsr	-210(a6)		; _LVOFreeMem
	move.l	#4,ez_flags
	move.l	d2,d0
.done	movem.l	(sp)+,d1/d2/d7/a0/a1/a2/a6
	rts

.bbbin2hex	lea	hextab,a0		; BIN: d0.l  HEX: -(a1)
	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

; -----  reads the bootblock from df0: into the buffer

read	movem.l	d0-d7/a0-a6,-(sp)
	move.w	#2,dev_cmd		; CMD_READ
	moveq	#0,d5		; unit 0
	bra	do_device

******************************************************
*   The following code is the modified GTB-Source.   *
*                                                    *
*   I know I should not patch it, but I did it for   *
*  faster work and the better "outfit" of my source. *
*        Now the executable is shorter too.          *
*                                                    *
*    Some bugs I killed (maybe I created some new)   *
*      and some superfluous commands I removed.      *
*                                                    *
*   Hope you will understand this, Jan. Sorry...     *
******************************************************

; -----  re-calculate the horizontal value for gadgets & bevel-boxes

compute_x	move.l	d1,-(sp)
	move.w	font_x,d1
	mulu	d1,d0
	addq.w	#4,d0
	lsr.w	#3,d0
	ext.l	d0
	move.l	(sp)+,d1
	rts

; -----  re-calculate the vertikal value for gadgets & bevel-boxes

compute_y	move.l	d1,-(sp)
	move.w	font_y,d1
	mulu	d1,d0
	addq.w	#4,d0
	lsr.w	#3,d0
	ext.l	d0
	move.l	(sp)+,d1
	rts

; -----  Calculate font`s size and check, if the window fits on the
; -----  screen using screen`s font. If not, use topaz 8.

compute_font lea.l	attr,a0
	move.l	a0,font
	move.l	screen,a1
	lea.l	84(a1),a1		; sc_RastPort
	move.l	52(a1),a1		; rp_Font
	move.l	10(a1),(a0)	; ?? (tf_Accessors)
	move.w	20(a1),4(a0)	; tf_YSize
	move.w	20(a1),font_y	; tf_YSize

.get_bigx	moveq	#100,d0		; breitestes x-Zeichen finden
	moveq	#0,d1
	move.l	40(a1),a0		; tf_CharSpace
.find_x	adda.l	#2,a0
	cmp.w	(a0)+,d1
	blt.s	.get_it
	dbra	d0,.find_x
	bra.s	.found
.get_it	move.w	-2(a0),d1
	dbra	d0,.find_x
.found	move.w	d1,font_x

	move.l	screen,a0
	move.b	36(a0),d0		; sc_WBorLeft
	ext.w	d0
	move.w	d0,off_x
	move.l	40(a0),a1		; sc_Font
	move.w	4(a1),d0		; tf_XSize
	addq.w	#1,d0
	move.b	35(a0),d1		; sc_WBorTop
	ext.w	d1
	add.w	d1,d0
	move.w	d0,off_y
	cmp.w	#0,d2
	beq.s	.comp_done
	cmp.w	#0,d3
	beq.s	.comp_done
	move.w	d2,d0
	bsr	compute_x
	add.w	off_x,d0
	move.b	37(a0),d1		; sc_WBorRight
	ext.w	d1
	add.w	d1,d0
	cmp.w	12(a0),d0		; sc_Width
	bhi.s	.use_topaz
	move.w	d3,d0
	bsr	compute_y
	add.w	off_y,d0
	move.b	38(a0),d1		: sc_WBorBottom
	ext.w	d1
	add.w	d1,d0
	cmp.w	14(a0),d0		; sc_Height
	bhi.s	.use_topaz
.comp_done	rts
.use_topaz	move.l	font,a0
	move.l	#topaz_name,(a0)	; ta_Name
	move.w	#8,font_y
	move.w	#8,font_x
	move.w	#8,4(a0)		; ta_YSize
	rts

; -----  get information about the active PubScreen

setup_scr	movem.l	d1-d3/a0-a2/a6,-(sp)
	move.l	intbase,a6
	move.l	pub_screen,a0
	jsr	-510(a6)		; _LVOLockPubScreen
	move.l	d0,screen
	cmp.l	#0,d0
	beq.s	.s_error
	moveq	#0,d2
	moveq	#0,d3
	bsr	compute_font
	move.l	screen,a0
	move.l	gadbase,a6
	lea.l	vi_tags,a1
	jsr	-126(a6)		; _LVOGetVisualInfoA
	move.l	d0,visualinfo
	beq.s	.v_error
	moveq	#0,d0
.done	movem.l	(sp)+,d1-d3/a0-a2/a6
	rts
.s_error	moveq	#1,d0
	bra.s	.done
.v_error	moveq	#2,d0
	bra.s	.done

; -----  free the information

close_scr	movem.l	d0-d1/a0-a1/a6,-(sp)
	move.l	gadbase,a6
	move.l	visualinfo,a0
	cmpa.l	#0,a0
	beq.s	.no_vis
	jsr	-132(a6)		; _LVOFreeVisualInfo
	move.l	#0,visualinfo
.no_vis	move.l	intbase,a6
	move.l	#0,a0
	move.l	screen,a1
	cmpa.l	#0,a1
	beq.s	.no_scr
	jsr	-516(a6)		; _LVOUnlockPubScreen
	move.l	#0,screen
.no_scr	movem.l	(sp)+,d0-d1/a0-a1/a6
	rts

; -----  draw the BackFill-Pattern (thanx Jan) and the BevelBox
; -----  into the window

wnd_render	movem.l	d0-d5/a0-a2/a6,-(sp)
	move.l	window,a0
	bsr	.draw_ptrn
	move.l	window,a0
	move.w	wnd_width,d2
	move.w	wnd_height,d3
	bsr	compute_font
	move.l	visualinfo,bevel_tags+4
	move.l	gadbase,a6
	move.l	window,a0
	move.l	50(a0),a2		; wd_RastPort
	move.l	a2,a0
	lea.l	bevel_tags,a1
	moveq	#3,d0
	bsr	compute_y
	add.w	off_y,d0
	move.l	d0,d1
	move.l	#418,d0		; width of BevelBox
	bsr	compute_x
	move.l	d0,d2
	moveq	#42,d0		; height of BevelBox
	bsr	compute_y
	move.l	d0,d3
	moveq	#7,d0		; top edge of BevelBox
	bsr	compute_x
	add.w	off_x,d0
	bsr.s	.drawbevel
	movem.l	(sp)+,d0-d5/a0-a2/a6
	rts

; -----  This is used instead of a simple DrawBevelBox(), because
; -----  the BackFill-Pattern is still visible IN the BevelBox after
; -----  DrawBevelBox(). So I have to clear the rect (using RectFill)
; -----  IN the BevelBox before calling DrawBevelBox()

.drawbevel	movem.l	d0-d3/a0/a1/a6,-(sp)
	move.l	screen,a0
	move.l	intbase,a6
	jsr	-690(a6)		; _LVOGetScreenDrawInfo
	move.l	d0,d6
	move.l	d0,a0
	move.l	$04(a0),a0		; dri_Pens
	move.w	$0e(a0),d2		; BACKGROUNDPEN
	move.l	screen,a0
	move.l	d6,a1
	jsr	-696(a6)		; _LVOFreeScreenDrawInfo
	move.l	a2,a1
	moveq	#0,d0
	move.w	d2,d0
	move.l	gfxbase,a6
	jsr	-342(a6)		; _LVOSetAPen
	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	-306(a6)		; _LVORectFill
	movem.l	(sp)+,d0-d3/a0/a1/a6
	jmp	-120(a6)		; _LVODrawBevelBox

; -----  draw the BackFill-Pattern into the window and init str_extend
	
.draw_ptrn	movem.l	d1-d7/a0-a6,-(sp)
	move.l	a0,d7
	move.l	$2e(a0),a0		; wd_WScreen
	move.l	intbase,a6
	jsr	-690(a6)		; _LVOGetScreenDrawInfo
	cmp.l	#0,d0
	beq	.failed
	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

; -----  patch the String-Extend-Structure of the String-Gadget to
; -----  change the color through activation
	
	move.l	gad_list,a1
	move.l	(a1),a1
	move.l	(a1),a1
	move.l	(a1),a1		; a1: ^StringGadget
	move.l	$22(a1),a1		; a1: SpecialInfo
	move.l	$18(a1),a1		; a1: StringExtend

	move.b	$05(a0),$04(a1)	; TEXTPEN
	move.b	$0f(a0),$05(a1)	; SHINEPEN
	move.b	$05(a0),$06(a1)	; TEXTPEN
	move.b	$07(a0),$07(a1)	; HIFILLPEN

; -----  ok, pen-copy done
	
	move.l	d7,a0
	move.l	$2e(a0),a0		; wd_WScreen
	move.l	d6,a1
	jsr	-696(a6)		; _LVOFreeScreenDrawInfo
	move.l	d7,a0
	move.l	50(a0),a0		; wd_RastPort
	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		; SHINEPEN
	move.l	gfxbase,a6
	jsr	-342(a6)		; _LVOSetAPen
	move.l	d6,a1
	move.l	d4,d0		; BACKGROUNDPEN
	jsr	-348(a6)		; _LVOSetBPen
	move.l	d6,a1
	moveq	#1,d0		; JAM2
	jsr	-354(a6)		; _LVOSetDrMd
	move.l	d7,a0
	moveq	#0,d0
	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		; all ok
	movem.l	(sp)+,d1-d7/a0-a6
	rts
.failed	moveq	#-1,d0		; no DrawInfo
	movem.l	(sp)+,d1-d7/a0-a6
	rts

; -----  open the xInstall-Window (font-sensitive !)
; -----  1. calculate window`s dimensions and check if it 
; -----     fits to the screen
; -----  2. create the gadget-list (font-sensitive)
; -----  3. open the window
; -----  4. render the pattern and the bevel-box
; -----  5. add the gadget-list to the window

setup_wnd	movem.l	d1-d4/a0-a4/a6,-(sp)
	move.l	screen,a0
	moveq	#0,d3
	moveq	#0,d2
	move.w	wnd_width,d2
	move.w	wnd_height,d3
	bsr	compute_font
	move.l	screen,a0
	move.l	d2,d0
	bsr	compute_x
	move.l	d0,d4
	move.w	wnd_left,d2
	add.w	d2,d0
	add.w	off_x,d0
	move.b	37(a0),d1		; sc_WBorRight
	ext.w	d1
	add.w	d1,d0
	cmp.w	12(a0),d0		; sc_Width
	bls.s	.width_ok
	move.w	12(a0),d0		; sc_Width
	sub.w	d4,d0
	move.w	d0,d2
.width_ok	move.l	d3,d0
	bsr	compute_y
	move.l	d0,d4
	move.w	wnd_top,d3
	add.w	d3,d0
	add.w	off_y,d0
	move.b	38(a0),d1		; sc_WBorBottom
	ext.w	d1
	add.w	d1,d0
	cmp.w	14(a0),d0		; sc_Height
	bls.s	.height_ok
	move.w	14(a0),d0		; sc_Height
	sub.w	d4,d0
	move.w	d0,d3
.height_ok	move.l	gadbase,a6
	lea.l	gad_list,a0
	jsr	-114(a6)		; _LVOCreateContext
	move.l	d0,a3
	cmp.l	#0,d0
	beq	.c_error
	movem.w	d2-d3,-(sp)
	moveq	#0,d3
	lea.l	gad_tags,a4
.make_gads	move.l	4.w,a6
	lea.l	new_gads,a0
	move.l	d3,d0
	mulu	#30,d0
	add.l	d0,a0
	lea.l	ng_buffer,a1
	moveq	#30,d0
	jsr	-624(a6)		; _LVOCopyMem
	lea.l	ng_buffer,a0
	move.l	visualinfo,22(a0)	; ng_VisualInfo
	move.l	font,12(a0)	; ng_GadgetFont
	move.w	(a0),d0		; ng_Left
	bsr	compute_x
	add.w	off_x,d0
	move.w	d0,(a0)
	move.w	2(a0),d0		; ng_Top
	bsr	compute_y
	add.w	off_y,d0
	move.w	d0,2(a0)
	move.w	4(a0),d0		; ng_Width
	bsr	compute_x
	move.w	d0,4(a0)
	move.w	6(a0),d0		; ng_Height
	bsr	compute_y
	move.w	d0,6(a0)
	move.l	gadbase,a6
	lea.l	gad_types,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	ng_buffer,a1
	move.l	a4,a2
	jsr	-30(a6)		; _LVOCreateGadgetA
	cmp.l	#0,d0
	bne.s	.create_ok
	movem.w	(sp)+,d2-d3
	bra	.g_error
.create_ok	

; -----  make Show a ToggleSelect-Button

	movem.l	a0,-(sp)
	move.l	d0,a0
	cmp.w	#8,$26(a0)		; gg_GadgetID
	bne.s	.goon1
	eor.w	#$100,$0e(a0)	; gg_Activation
	move.l	a0,show_gg
.goon1	movem.l	(sp)+,a0

; -----  done

	move.l	d0,a3
	move.l	d3,d0
	asl.l	#2,d0
	lea.l	gadgets,a0
	add.l	d0,a0
	move.l	a3,(a0)
.tag_loop	tst.l	(a4)
	beq.s	.do_next
	addq.w	#8,a4
	bra.s	.tag_loop
.do_next	addq.w	#4,a4
	addq.w	#1,d3
	cmp.w	#gad_count,d3
	bmi	.make_gads
	movem.w	(sp)+,d2-d3
	move.l	screen,tag_screen+4
	ext.l	d2
	ext.l	d3
	move.l	d2,tag_left+4
	move.l	d3,tag_top+4
	move.l	screen,a0
	move.w	wnd_width,d0
	bsr	compute_x
	add.w	off_x,d0
	move.b	37(a0),d1		; sc_WBorRight
	ext.w	d1
	add.w	d1,d0
	move.l	d0,tag_width+4
	move.w	wnd_height,d0
	bsr	compute_y
	add.w	off_y,d0
	move.b	38(a0),d1		; sc_WBorBottom
	ext.w	d1
	add.w	d1,d0
	move.l	d0,tag_height+4
	move.l	intbase,a6
	move.l	#0,a0
	lea.l 	window_tags,a1
	jsr	-606(a6)		; _LVOOpenWindowTagList
	move.l	d0,window
	beq.s	.w_error
	bsr	wnd_render	
	move.l	window,a0
	move.l	gad_list,a1
	moveq	#-1,d0
	moveq	#-1,d1
	move.l	#0,a2
	move.l	intbase,a6
	jsr	-438(a6)		; _LVOAddGList
	move.l	gad_list,a0
	move.l	window,a1
	moveq	#-1,d0
	jsr	-432(a6)		; _LVORefreshGList
	move.l	window,a0
	move.l	#0,a1
	move.l	gadbase,a6
	jsr	-84(a6)		; _LVOGT_RefreshWindow
	moveq	#0,d0
.done	movem.l	(sp)+,d1-d4/a0-a4/a6
	rts
.c_error	moveq	#1,d0
	bra.s	.done
.g_error	moveq	#2,d0
	bra.s	.done
.w_error	moveq	#4,d0
	bra.s	.done

; -----  close the window

close_wnd	movem.l	d0-d1/a0-a2/a6,-(sp)
	move.l	intbase,a6
	move.l	window,a0
	cmpa.l	#0,a0
	beq.s	.no_wnd
	jsr	-72(a6)		; _LVOCloseWindow
	move.l	#0,window
.no_wnd	move.l	gadbase,a6
	move.l	gad_list,a0
	cmp.l	#0,a0
	beq.s	.no_gads
	jsr	-36(a6)		; _LVOFreeGadgets
	move.l	#0,gad_list
.no_gads	movem.l	(sp)+,d0-d1/a0-a2/a6
	rts

; -----  this gets the loc-string or the default (english)

get_string	movem.l	d0/d1/a0/a1/a6,-(sp)
	move.l	catalog,d0
	beq.s	.done
	move.l	24(sp),a1		; a1 -> string
	moveq	#0,d0
	move.l	a1,d1
	lea.l	locale_start,a0
	sub.l	a0,d1
	beq.s	.get_it
.loop	tst.b	(a0)+
	bne.s	.ok
	addq.l	#1,d0
.ok	subq.l	#1,d1
	bne.s	.loop
.get_it	move.l	locbase,a6
	move.l	catalog,a0
	jsr	-72(a6)		; _LVOGetCatalogStr
	move.l	d0,24(sp)
.done	movem.l	(sp)+,d0/d1/a0/a1/a6
	rts

 SECTION "xInstall_DATA",DATA

******************************************************
*                   XInstall v1.4                    *
*          now all datas, structures etc             *
******************************************************

	dc.b	"$VER: xInstall 1.4 (30.09.94)"
	even

req_name	dc.b	"reqtools.library",0
	even
dos_name	dc.b	"dos.library",0
	even
loc_name	dc.b	"locale.library",0
	even
cat_name	dc.b	"xinstall.catalog",0
	even
track_name	dc.b	"trackdisk.device",0
	even
port_name	dc.b	"xInstall_PORT",0

	cnop	0,4

pattern	dc.w	$aaaa,$5555

thistask	dc.l	0
reqbase	dc.l	0
intbase	dc.l	0
gfxbase	dc.l	0
dosbase	dc.l	0
gadbase	dc.l	0
locbase	dc.l	0
bb_mem	dc.l	0
wbenchmsg	dc.l	0
catalog	dc.l	0
show_gg	dc.l	0
dev_cmd	dc.w	3

dis_tab	dc.l	6,7

getfile_1	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)
	cnop	0,4	

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
	cnop	0,4

; -----  Defs 4 About-Requester (text: look at LOCALE at the bottom...)

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
ez_flags	dc.l	4
	dc.l	0

about_gad	dc.b	"_OK",0
	even

reqtitle	dc.b	"xInstall v1.4",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

bb_path	ds.b	256
	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,0
	dc.l	0

; -----  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	df0,df1,df2,df3	; Buttons df0-df3
	dc.l	read		; Button "Read"
	dc.l	load		; Button "Load"
	dc.l	get_msg		; Button "Show"
	dc.l	about		; Button "Show"

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	"q",0
	dc.l	quit
	dc.b	"b",0
	dc.l	bootblock2
	dc.b	"f",0
	dc.l	filesys2
	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
about_key1	dc.w	0
	dc.l	about
show_key1	dc.w	0
	dc.l	show
read_key1	dc.w	0
	dc.l	read
load_key1	dc.w	0
	dc.l	load
about_key2	dc.w	0
	dc.l	about
show_key2	dc.w	0
	dc.l	show
read_key2	dc.w	0
	dc.l	read
load_key2	dc.w	0
	dc.l	load
	dc.b	0		; this is the end of tab
	even

; -----  Errors trackdisk.device (will be initialized later)

td_errtab	dc.l	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

	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.l	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.l	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.l	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
	lea.l	320+12(a1),a1
	jsr	-198(a6)		; _LVOInitRastPort

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

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

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

	moveq	#107,d0
	move.l	d7,a0
	lea.l	320+12+100(a0),a0
	move.l	a0,a2
	lea.l	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.l	$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.l	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.l	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.l	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.l	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.l	cop_adress(pc),a0
	move.l	d0,(a0)
	beq.s	.back_1
	lea.l	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.l	$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.l	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.l	bad_text(pc),a1
	lea.l	71(a1),a1
	move.l	42(a6),d0		; ColdCapture
	bsr	.bbbin2hex
	lea.l	36(a1),a1
	move.l	46(a6),d0		; CoolCapture
	bsr	.bbbin2hex
	lea.l	27(a1),a1
	move.l	546(a6),d0		; KickMemPtr
	bsr	.bbbin2hex
	lea.l	36(a1),a1
	move.l	550(a6),d0		; KickTagPtr
	bsr	.bbbin2hex
	lea.l	33(a1),a1
	move.l	554(a6),d0		; KickCheckSumPtr
	bsr	.bbbin2hex
	lea.l	35(a1),a1
	move.l	300(a6),d0		; ResModules
	bsr	.bbbin2hex

	lea.l	int_lib(pc),a1
	moveq	#33,d0
	jsr	-552(a6)		; _LVOOpenLibrary
	move.l	d0,a6
	beq.s	.back_2
	lea.l	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	lea.l	8(a1),a1
	lea.l	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.l	fontname(pc),a0	; alloc and init all you need
	lea.l	textattr(pc),a1
	move.l	a0,(a1)

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

 	move.l	d0,a6
	lea.l	textattr(pc),a0
	jsr	-72(a6)		; _LVOOpenFont
	cmp.l	#0,d0
	beq	.error_2
	lea.l	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.l	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.l	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.l	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.l	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.l	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.l	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	p-

******************************************************
*    Below you find the modified GTB-datas used by   *
*          the modified GTB-source above.            *
*                                                    *
*  Excuse me, Jan, for this. But this works a little *
*   bit better and the executable is much smaller    *
******************************************************

gad_count	equ	10		; number of gadgets

screen	dc.l	0		; certain pointers etc.
visualinfo	dc.l	0
pub_screen	dc.l	0
window	dc.l	0
gad_list	dc.l	0
vi_tags	dc.l	0
font	dc.l	0
font_x	dc.w	0
font_y	dc.w	0
off_x	dc.w	0
off_y	dc.w	0

gadgets	dcb.l	10,0		; needed by gadget-creation

attr	dc.l	0		; for topaz.font
	dc.w	0
	dc.b	0,0

ng_buffer	dc.w	0,0,0,0		; later this newgadget-struc
	dc.l	0,0		; will be filled
	dc.w	0
	dc.l	0,0,0

bevel_tags	dc.l	$80080034,$00000000	; tags 4 bevelbox
	dc.l	$80080033,$00000000
	dc.l	$00000000

wnd_left	dc.w	0		; window`s position
wnd_top	dc.w	11		; (if font = topaz 8)
wnd_width	dc.w	433
wnd_height	dc.w	64

topaz_name	dc.b	"topaz.font",0
	even

gad_types	dc.w	7		; the gadget-types
	dc.w	7		; 2x CycleGad 
	dc.w	1		; and Buttons
	dc.w	1
	dc.w	1
	dc.w	1
	dc.w	1
	dc.w	1
	dc.w	1
	dc.w	1

new_gads	dc.w	95,7,120,14	; CYCLE: Bootblock
	dc.l	gadget0txt,0
	dc.w	0
	dc.l	$01,0,0
	
	dc.w	95,23,120,14	; CYCLE: FileSys
	dc.l	gadget1txt,0
	dc.w	1
	dc.l	$01,0,0

	dc.w	7,48,91,14		; BUTTON: df0
	dc.l	gadget2txt,0
	dc.w	2
	dc.l	$10,0,0

	dc.w	116,48,91,14	; BUTTON: df1
	dc.l	gadget3txt,0
	dc.w	3
	dc.l	$10,0,0

	dc.w	225,48,91,14	; BUTTON: df2
	dc.l	gadget4txt,0
	dc.w	4
	dc.l	$10,0,0

	dc.w	334,48,91,14	; BUTTON: df3
	dc.l	gadget5txt,0
	dc.w	5
	dc.l	$10,0,0

	dc.w	233,23,89,14	; BUTTON: Read
gad6_text	dc.l	0,0
	dc.w	6
	dc.l	$10,0,0

	dc.w	326,23,89,14	; BUTTON: Load
gad7_text	dc.l	0,0
	dc.w	7
	dc.l	$10,0,0

	dc.w	326,7,89,14	; BUTTON: Show
gad8_text	dc.l	0,0
	dc.w	8
	dc.l	$10,0,0

	dc.w	233,7,89,14	; BUTTON: About
gad9_text	dc.l	0,0
	dc.w	9
	dc.l	$10,0,0

gad_tags	dc.l	$8008000E,gad0_lab	; tags for every gadget
	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$8008000E,gad1_lab
	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

	dc.l	$80080040,"_"
	dc.l	$00000000

gadget0txt	dc.b	"_Bootblock",0	; gadget`s texts
	even
gadget1txt	dc.b	"_FileSys",0
	even
gadget2txt	dc.b	"DF_0",0
	even
gadget3txt	dc.b	"DF_1",0
	even
gadget4txt	dc.b	"DF_2",0
	even
gadget5txt	dc.b	"DF_3",0
	even

gad0_lab	dc.l	0,0,0,0,0,0,0	; labels for both CycleGads

gad1_lab	dc.l	gad1lab0
	dc.l	gad1lab1
	dc.l	gad1lab2
	dc.l	gad1lab3
	dc.l	gad1lab4
	dc.l	gad1lab5
	dc.l	0

gad1lab0	dc.b	"OFS",0
	even
gad1lab1	dc.b	"FFS",0
	even
gad1lab2	dc.b	"OFS int",0
	even
gad1lab3	dc.b	"FFS int",0
	even
gad1lab4	dc.b	"DC-OFS",0
	even
gad1lab5	dc.b	"DC-FFS",0
	even

window_tags			; tags for window...

tag_left	dc.l	$80000064,0
tag_top	dc.l	$80000065,0
tag_width	dc.l	$80000066,0
tag_height	dc.l	$80000067,0
	dc.l	$8000006A,$00200244
	dc.l	$8000006B,$0001100E
	dc.l	$8000006E,wnd_title
	dc.l	$8000006F,scr_title
tag_screen	dc.l	$80000079,0
	dc.l	$00000000

wnd_title	dc.b	"xInstall v1.4   © 1994 by Jens Tröger",0
	even

scr_title	dc.b	"xInstall v1.4",0
	even

; -----  the localized texts
; -----  (the catalog was created with MakeCat 38.05)

; -----  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 ?

LOCALE_START
;	CATALOG	xinstall
;	VERSION	1.4
;	CATDATE	30.09.94

err_txt1	dc.b	"Cannot open trackdisk.device",0
; D	"Kann trackdisk.device nicht öffnen",0

err_txt2	dc.b	"TDError #20: Error not specified",0
; D	"TDFehler #20: Fehler nicht spezifizierbar",0
	
err_txt3	dc.b	"TDError #21: No Sector-Header",0
; D	"TDFehler #21: Sektor-Kopf nicht gefunden",0

err_txt4	dc.b	"TDError #22: Bad Sector Preamble",0
; D	"TDFehler #22: Fehler in Sektor-Präambel",0

err_txt5	dc.b	"TDError #23: Bad Sector ID",0
; D	"TDFehler #23: Fehler in Sektor-ID",0

err_txt6	dc.b	"TDError #24: Bad Header CheckSumm",0
; D	"TDFehler #24: Checksummen-Fehler im Header",0

err_txt7	dc.b	"TDError #25: Bad Sector CheckSumm",0
; D	"TDFehler #25: Checksummen-Fehler im Sektor",0

err_txt8	dc.b	"TDError #26: Too few Sectors",0
; D	"TDFehler #26: Zuwenige Sektoren auf Track",0

err_txt9	dc.b	"TDError #27: Bad Sector Header",0
; D	"TDFehler #27: Sektor-Kopf nicht lesbar",0

err_txt10	dc.b	"TDError #28: Disk write protected",0
; D	"TDFehler #29: Diskette ist schreibgeschützt",0

err_txt11	dc.b	"TDError #29: No Disk in drive",0
; D	"TDFehler #29: Keine Diskette im Laufwerk",0

err_txt12	dc.b	"TDError #30: Seek error",0
; D	"TDFehler #30: Lesekopf-Position falsch",0

err_txt13	dc.b	"TDError #31: Not enough memory",0
; D	"TDFehler #31: Zuwenig Speicher",0

err_txt14	dc.b	"TDError #32: Bad unit number",0
; D	"TDFehler #32: Laufwerk nicht angschlossen",0

err_txt15	dc.b	"TDError #33: Bad drive type",0
; D	"TDFehler #33: Falsches Laufwerk",0

err_txt16	dc.b	"TDError #34: Drive is in use",0
; D	"TDFehler #34: Laufwerk wird gerade benutzt",0

err_txt17	dc.b	"TDError #35: Post Reset done",0
; D	"TDFehler #35: Nach Reset kein Zugriff mehr",0

freq_title	dc.b	"Load BootBlock-File",0
; D	"BootBlock-Datei laden",0

err1_gad	dc.b	"_Yoop",0
; D	"_Klar",0

err1_text	dc.b	"Can`t lock selected file.",0
; D	"Bekomme keinen Lock() auf Datei.",0

err2_text	dc.b	"Can`t open selected file.",0
; D	"Kann gewählte Datei nicht öffnen.",0

err3_text	dc.b	"File is not a BootBlock.",0
; D	"Datei ist kein BootBlock.",0

err4_text	dc.b	"Error while reading BootBlock-File.",0
; D	"Fehler beim Lesen der BootBlock-Datei.",0

fmt_text	dc.b	"Enter the Scroll-Text !!",10
	dc.b	"[max 50 chars]",0
; D	"Bitte Fließ-Text eingeben !!",10
; D	"[max 50 Zeichen]",0

funny_msg1	dc.b	10,$9b,"1mxInstall v1.4"
	dc.b	$9b,"0m  (c) 1994 by Jens Tröger. All rights reserved.",10,10
	dc.b	"ignoring all arguments... opening GUI... ",0
; D        10,$9b,"1mxInstall v1.4",$9b,"0m  (c) 1994 by Jens Tröger. Alle Rechte vorbehalten.",10,10
; D        "ignoriere alle Argumente... öffne GUI... ",0

funny_msg2	dc.b	"hard work done.",10,"Quitting away now - bye !",10,10,0
; D	"harte Arbeit getan.",10,"Verkrümle mich jetzt - tschüß !",10,10,0

gadget6txt	dc.b	"_Read",0
; D	"_Lesen",0

gadget7txt	dc.b	"_Load",0
; D	"L_aden",0

gadget8txt	dc.b	"_Show",0
; D	"_Zeige",0

gadget9txt	dc.b	"_About",0
; D	"_Über",0

bb1_text	dc.b	"Empty",0
; D	"Leer",0

bb2_text	dc.b	"Standard",0
; D	"Standard",0

bb3_text	dc.b	"Message",0
; D	"Botschaft",0

bb4_text	dc.b	"Scroller",0
; D	"Fließtext",0

bb5_text	dc.b	"MemCheck",0
; D	"SysTest",0

bb6_text	dc.b	"[Buffer]",0
; D	"[Puffer]",0

show_text	dc.b	"Bootblock:               ",10
	dc.b	"FileSys:                 ",10
	dc.b	"CheckSum:                ",10,0
; D	"Bootblock:               ",10
; D	"FileSys:                 ",10
; D	"CheckSumme:              ",10,0

show_gads	dc.b	" _Install | _Cancel ",0
; D	" _Installieren | _Abbruch ",0

about_text	dc.b	"xInstall v1.4",10
	dc.b	"(c) 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	"Oliver Reiff",10
	dc.b	"Holger Gzella",10,10
	dc.b	"xInstall`s Layout created",10
	dc.b	"with GadToolsBox.",0

; D	"xInstall v1.4",10
; D	"(c) 1994 by Jens Tröger",10,10
; D	"Das Programm ist Freeware.",10,10
; D	"Grüße an:",10
; D	"PackMAN",10
; D	"Jan van den Baard",10
; D	"Oliver Reiff",10
; D	"Holger Gzella",10,10
; D	"xInstall`s Oberfläche erstellt",10
; D	"mit GadToolsBox.",0

LOCALE_END

	end
