;----------------------------------------------------------------------------
;File name:	AMCGDOS.S		Revision date:	1998.10.16
;Disassembler:	Ulf Ronald Andersson	Disassembled:	1995.10.01
;Revision:	1.2
;----------------------------------------------------------------------------
;
	output	.PRG
;
;----------------------------------------------------------------------------
;
workstation_max = 50
virtual_max	= 40
;
;----------------------------------------------------------------------------
;
	include	RA_SIM.I
	include	RA_JAR.I
	include	RA_XB.I
	include	RA_LA.I
;----------------------------------------------------------------------------
	SECTION	text
;----------------------------------------------------------------------------
;Desert	Drain V1.41   68000er Disassembler  01.10.1995 20:00:02
;DATEI:	AMCGDOS.ORG   8054 Bytes
;TEXT:	 5204	$01454
;DATA:	 2408	$00968
;BSS:	12996  $0032C4
;------------------------------------
;
start:
	movea.l	4(sp),a0		;a0 -> basepage
	move.l	#$12345678,stack_beg
	movea.l	#stack_end,sp
	move.l	a0,basepage_p
	move.l	#$100,d0
	add.l	bp_textlen(a0),d0
	add.l	bp_datalen(a0),d0
	add.l	bp_bss_len(a0),d0
	move.l	d0,program_size
;
	gemdos	Mshrink,!,(a0),d0
	bios	Kbshift,?
;
	tst.w	d0
	bne.s	.exit_not_installed
	bsr.s	init_GDOS
	tst.w	d0
	bmi.s	.exit_error
	cmpi.l	#$12345678,stack_beg
	beq.s	.exit_installed
	move.l	#stack_overflow_s,d0
	bsr	disp_string
.exit_installed:
	move.l	#AMC_GDOS_installed_s,d0
	bsr	disp_string
	gemdos	Ptermres,program_size,!
;
;------------------------------------
;
.exit_not_installed:	move.l	#AMC_GDOS_not_installed_s,d0
	bsr	disp_string
	move.l	#release_key_s,d0
	bsr	disp_string
.T_9A:
	bios	Kbshift,?
	tst.w	d0
	bne.s	.T_9A
.T_AA:
	gemdos	Pterm,d0
;
;------------------------------------
;
.exit_error:
	move.l	#AMC_GDOS_not_installed_s,d0
	bsr	disp_string
	move.l	#press_key_s,d0
	bsr	disp_string
	gemdos	Crawcin
	bra.s	.T_AA
;
;----------------------------------------------------------------------------
;
init_GDOS:
	move	#-1,d0
	trap	#2			;vq_driver
	move.l	d0,old_VDI_sub_p
;
	bsr.s	get_drv_path
	bsr	install_GEMSYS
	move	d0,-(sp)
	gemdos	Mfree|_ind,filebase_p
	move	(sp)+,d0
	bsr.s	set_drv_path
	tst.w	d0
	bmi.s	.T_122
;
	gemdos	Super,!
	move.l	d0,-(sp)
	lea	(ev_xgem).w,a0
	lea	nu_xgem(pc),a1
	bsr	install_XB
	move.l	d0,d3
	gemdos	Super,()
	move.l	d3,d0
	rts
;
;------------------------------------
;
.T_122:	moveq	#E_ERROR,d0
	rts
;
;----------------------------------------------------------------------------
;
get_drv_path:
	movem.l	d0-a6,-(sp)
	gemdos	Dgetdrv
	move	d0,B_2614
	addq.w	#1,d0
	gemdos	Dgetpath,B_2616,d0
	movem.l	(sp)+,d0-a6
	rts
;
;----------------------------------------------------------------------------
;
set_drv_path:
	movem.l	d0-a6,-(sp)
	gemdos	Dsetdrv,B_2614
	gemdos	Dsetpath,D_1456
	gemdos	Dsetpath,B_2616
	movem.l	(sp)+,d0-a6
	rts
;
;----------------------------------------------------------------------------
;
install_GEMSYS:
	move.l	#ASSIGN_SYS_s,d0
	bsr	find_filesize
	tst.w	d0
	bmi.s	.T_1d2
	move.l	d1,filesize
	gemdos	Malloc,d1
	tst.l	d0
	bpl.s	.T_1B8
	move.l	#too_little_RAM_s,d0
	bsr	disp_string
	move	#-1,d0
	rts
;
;------------------------------------
;
.T_1B8:	move.l	d0,filebase_p
	gemdos	Fopen,ASSIGN_SYS_s,!
	move	d0,d7
	bpl.s	.T_1E2
.T_1d2:	move.l	#ASSIGN_SYS_not_found_S,d0
	bsr	disp_string
	move	#-1,d0
	rts
;
;------------------------------------
;
.T_1E2:
	gemdos	Fread|_ind,d7,filesize,filebase_p
	move.l	d0,d6
	gemdos	Fclose,d7
	cmp.l	filesize,d6
	bne.s	.T_1d2
	bsr	scan_GEMSYS_path
	bmi.s	.T_228
	bsr	disp_GEMSYS_path
	bsr	set_gemsys_drv_path
	bpl.s	.T_22E
	move.l	#path_not_found_s,d0
	bsr	disp_string
.T_228:	move	#-1,d0
	rts
;
;------------------------------------
;
.T_22E:
	bsr	pre_scan_device_font_count
	move	device_count,d0
	beq	.T_3a6
	ext.l	d0
	asl.l	#6,d0			;d0 = 64*device_count
	gemdos	Malloc,d0
	move.l	d0,device_struct_t_p
	bgt.s	.T_262
	move.l	#too_little_RAM_s,d0
	bsr	disp_string
	move	#-1,d0
	rts
;
;------------------------------------
;
.T_262:	move	max_font_count,d0
	beq.s	.T_294
	mulu	device_count,d0
	asl.l	#4,d0			;d0 = 4*device_count*max_font_count
	gemdos	Malloc,d0
	move.l	d0,font_p_t_p
	bgt.s	.T_294
	move.l	#too_little_RAM_s,d0
	bsr	disp_string
	move	#-1,d0
	rts
;
;------------------------------------
;
.T_294:
	bsr	scan_devices_and_fonts
	tst.w	d0
	bmi.s	.T_228
	move	device_count,d5
	beq	.T_3a6
	movea.l	device_struct_t_p,a5
	clr.w	d7
	subq.w	#1,d5
.T_2B0:				;loop target for each device driver load
	move	2(a5),d0
	beq	.T_33A		;goto .T_33A for ROM driver
	cmpi.w	#1,d0
	beq.s	.load_driver	;goto .load_driver for RAM resident driver
	clr.l	$12(a5)
	bra.s	.T_342
;
.load_driver:
	move.l	a5,d0
	addq.l	#6,d0
	bsr	load_driver_sub
	tst.l	d0
	beq.s	.T_32A
	move.l	d0,$16(a5)		;store -> driver basepage
	movea.l	d0,a0			;a0 -> driver basepage
	addi.l	#$100,d0		;d0 -> driver code start
	move.l	d0,$12(a5)		;store -> driver code start
	movem.l	d1-a6,-(sp)
	gemdos	Malloc,bp_datalen(a0)	;reserve extra resident data area
	movem.l	(sp)+,d1-a6
	tst.l	d0
	ble.s	.T_316
	movea.l	d0,a1			;a1 -> resident data area
	move.l	d0,$22(a5)		;store -> resident data area
	move.l	bp_datalen(a0),d0	;d0 = original data size
	move.l	d0,$26(a5)		;store resident data size
	movea.l	bp_databeg_p(a0),a0	;a1 -> original data area
	bra.s	.T_310
;
.T_30E:
	move.b	(a0)+,(a1)+		;copy original data to resident area
.T_310:
	subq.l	#1,d0
	bpl.s	.T_30E
	bra.s	.T_342
;
.T_316:
	move.l	$16(a5),-(sp)		;push -> driver basepage
	clr.l	$12(a5)			;clear -> driver code
	clr.l	$16(a5)			;clear -> driver basepage
	gemdos	Mfree,()		;release driver RAM
.T_32A:
	move.l	#driver_not_found_s,d0
	bsr	disp_string
	move	#-1,d0
	rts
;
.T_33A:
	move.l	old_VDI_sub_p,$12(a5)
.T_342:
	lea	$40(a5),a5
	addq.w	#1,d7
	dbra	d5,.T_2B0		;loop back for each device driver load
;
	move	device_count,d5
	subq.w	#1,d5
	movea.l	device_struct_t_p,a5
	movea.l	font_p_t_p,a4
	move	max_font_count,d3
	asl.w	#4,d3
.T_368:
	movea.l	a4,a3
	move	4(a5),d4
	beq.s	.T_39C
	subq.w	#1,d4
.T_372:
	tst.w	(a3)
	beq.s	.T_394
	move.l	a3,d0
	addq.l	#6,d0
	bsr	load_font_sub
	tst.l	d0
	bne.s	.T_390
	move.l	#font_not_found_s,d0
	bsr	disp_string
	clr.w	(a3)
	clr.l	d0
.T_390:
	move.l	d0,2(a3)
.T_394:
	lea	$10(a3),a3
	dbra	d4,.T_372
.T_39C:
	adda.w	d3,a4
	lea	$40(a5),a5
	dbra	d5,.T_368
.T_3a6:
	clr.w	d0
	rts
;
;----------------------------------------------------------------------------
;
pre_scan_device_font_count:
	movem.l	d1/a0,-(sp)
	clr.w	d1
	clr.w	max_font_count
	clr.w	device_count
	move	file_pos,-(sp)
.T_3C2:
	bsr	scan_pass_blank
	bsr	scan_char
	bmi.s	.T_3F8
	cmpi.b	#'0',d0
	blt.s	.font_line
	cmpi.b	#'9',d0
	bgt.s	.font_line
.device_line:
	cmp.w	max_font_count,d1
	ble.s	.T_3E6
	move	d1,max_font_count
.T_3E6:
	clr.w	d1
	addq.w	#1,device_count
	bra.s	.T_3F2
;
;------------------------------------
;
.font_line:
	addq.w	#1,d1
.T_3F2:
	bsr	pass_line
	bra.s	.T_3C2
;
;------------------------------------
;
.T_3F8:	cmp.w	max_font_count,d1
	ble.s	.T_406
	move	d1,max_font_count
.T_406:	move	(sp)+,file_pos
	movem.l	(sp)+,d1/a0
	rts
;
;----------------------------------------------------------------------------
;
scan_devices_and_fonts:
	movem.l	d1-d2/a0-a2,-(sp)
	move.l	device_struct_t_p,B_2608
	subi.l	#64,B_2608
	move.l	font_p_t_p,B_2610
	bsr	scan_pass_blank
	bsr	scan_char
	bmi	.T_4d0
	cmp.b	#'0',d0
	blt.s	.no_driver_error
	cmp.b	#'9',d0
	ble.s	.next_driver
.no_driver_error:
	move.l	#driver_expected_s,d0
	bsr	disp_string
.exit_error:
	movem.l	(sp)+,d1-d2/a0-a2
	move	#-1,d0
	rts
;
;------------------------------------
;
.next_driver:
	addi.l	#64,B_2608
	bsr.s	scan_device_code
	bmi.s	.exit_error
	bsr	scan_device_name
	bmi.s	.exit_error
	move.l	B_2610,B_260C
	move	max_font_count,d0
	asl.w	#4,d0
	ext.l	d0
	add.l	d0,B_2610
	clr.w	d2
.T_490:	bsr	scan_pass_blank
	bsr	scan_char
	bmi.s	.T_4C6
	cmp.b	#'0',d0
	blt.s	.T_4B2
	cmp.b	#'9',d0
	bgt.s	.T_4B2
	movea.l	B_2608,a1
	move	d2,4(a1)
	bra.s	.next_driver
;
;------------------------------------
;
.T_4B2:
	bsr	scan_fontnames
	bmi.s	.T_4C6
	addq.w	#1,d2
	addi.l	#$10,B_260C
	bra.s	.T_490
;
;------------------------------------
;
.T_4C6:
	movea.l	B_2608,a1
	move	d2,4(a1)
.T_4d0:
	movem.l	(sp)+,d1-d2/a0-a2
	clr.w	d0
	rts
;
;----------------------------------------------------------------------------
;
scan_device_code:
	movem.l	d7-a1,-(sp)
	movea.l	B_2608,a0
	move	#64/4-1,d0
	moveq	#0,d7
.T_4E8:
	move.l	d7,(a0)+	;clear 64 bytes
	dbra	d0,.T_4E8
	movea.l	B_2608,a1
	subq.w	#1,file_pos
	bsr	scan_char
	move	d0,d7
	sub.w	#'0',d7
	bsr	scan_char
	bpl.s	.T_512
.unexpected_EOF:
	move.l	#unexpected_EOF_s,d0
	bra.s	.exit_disp_error
;
;------------------------------------
;
.T_512:	cmp.b	#'0',d0
	blt.s	.T_52A
	cmp.b	#'9',d0
	bgt.s	.T_52A
	mulu	#10,d7
	ext.w	d0
	sub.w	#'0',d0
	add.w	d0,d7
.T_52A:	move	d7,(a1)			;store device code in struct
	bsr	scan_char
	bmi.s	.unexpected_EOF
	cmp.b	#'0',d0
	blt.s	.T_546
	cmp.b	#'9',d0
	bgt.s	.T_546
	move.l	#bad_driver_code_s,d0
	bra.s	.exit_disp_error
;
;------------------------------------
;
.T_546:	cmp.b	#' ',d0
	bne.s	.T_554
	move	#2,2(a1)		;flag reloadable driver in struct
	bra.s	.exit_ok
;
;------------------------------------
;
.T_554:	cmp.b	#'p',d0
	beq.s	.T_560
	cmp.b	#'P',d0
	bne.s	.T_566
.T_560:	clr.w	2(a1)			;flag ROM driver in struct
	bra.s	.exit_ok
;
;------------------------------------
;
.T_566:	cmp.b	#'r',d0
	beq.s	.T_572
	cmp.b	#'R',d0
	bne.s	.T_57A
.T_572:	move	#1,2(a1)		;flag RAM resident driver in struct
	bra.s	.exit_ok
;
;------------------------------------
;
.T_57A:	move.l	#blank_option_expected_s,d0
	bra.s	.exit_disp_error
;
;------------------------------------
;
.exit_ok:
	movem.l	(sp)+,d7-a1
	clr.w	d0
	rts
;
;------------------------------------
;
.exit_disp_error:
	bsr	disp_string
	movem.l	(sp)+,d7-a1
	move	#-1,d0
	rts
;
;----------------------------------------------------------------------------
;
scan_device_name:
	movem.l	d7-a2,-(sp)
	movea.l	B_2608,a1
	bsr	scan_pass_blank
	lea	6(a1),a2
	move	#8,d7
.T_5AE:
	bsr	scan_char
	bmi.s	.T_5DA
	cmp.b	#'.',d0
	beq.s	.T_5DA
	cmp.b	#' ',d0
	ble.s	.T_5DA
	move.b	d0,(a2)+
	dbra	d7,.T_5AE
	move.l	#name_too_long_s,d0
	bsr	disp_string
	movem.l	(sp)+,d7-a2
	move	#-1,d0
	rts
;
;------------------------------------
;
.T_5DA:	clr.b	(a2)+
	bsr	pass_line
	movem.l	(sp)+,d7-a2
	clr.w	d0
	rts
;
;----------------------------------------------------------------------------
;
scan_fontnames:
	movem.l	d7-a2,-(sp)
	clr	d1
	subq	#1,file_pos
	bsr	scan_char
	bpl.s	.T_602
.T_5FA:
	move.l	#unexpected_EOF_s,d0
	bra.s	.exit_disp_error
;
;------------------------------------
;
.T_602:
	cmp.b	#'r',d0
	beq.s	.T_60E
	cmp.b	#'R',d0
	bne.s	.T_62C
.T_60E:
	bsr	scan_char
	subq	#1,file_pos
	tst	d0
	bmi.s	.T_5FA
	cmp.b	#' ',d0
	bne.s	.T_62C
	addq	#2,file_pos
	move	#1,d1
.T_62C:
	movea.l	B_260C,a1
	move	d1,(a1)
	clr.l	2(a1)
	lea	6(a1),a1
	move	#8,d7
	subq	#1,file_pos
.T_646:
	bsr	scan_char
	bmi.s	.exit_ok
	cmp.b	#'.',d0
	beq.s	.exit_ok
	cmp.b	#' ',d0
	ble.s	.exit_ok
	move.b	d0,(a1)+
	dbra	d7,.T_646
	move.l	#name_too_long_s,d0
.exit_disp_error:
	bsr	disp_string
	movem.l	(sp)+,d7-a2
	move	#-1,d0
	rts
;
;------------------------------------
;
.exit_ok:
	clr.b	(a1)
	bsr	pass_line
	movem.l	(sp)+,d7-a2
	clr.w	d0
	rts
;
;----------------------------------------------------------------------------
;
scan_GEMSYS_path:
	movem.l	d1-d2/a0-a2,-(sp)
	clr.w	file_pos
	bsr	scan_pass_blank
	lea	path_lc_s,a1
	lea	PATH_uc_s,a2
	clr.w	d2
.T_69C:	bsr	scan_char
	bmi	T_74E
	cmp.b	0(a1,d2.w),d0
	beq.s	.T_6B2
	cmp.b	0(a2,d2.w),d0
	bne	T_74E
.T_6B2:	addq.w	#1,d2
	cmp.w	#4,d2
	blt.s	.T_69C
	bsr	scan_pass_blank
	bsr	scan_char
	bmi	T_760
	cmp.b	#'=',d0
	bne	T_760
	bsr	scan_pass_blank
	move	file_pos,d7
	bsr	scan_char
	clr.w	d6
	move.b	d0,d6
	bsr	scan_char
	cmp.b	#':',d0
	beq.s	T_6FC
	move	B_2614,gemsys_drive
	move	d7,file_pos
	bra.s	T_72C
;
;------------------------------------
;
T_6FC:	cmp.b	#'A',d6
	blt.s	T_714
	cmp.b	#'Z',d6
	ble.s	T_722
	cmp.b	#'a',d6
	blt.s	T_714
	cmp.b	#'z',d6
	ble.s	T_71C
T_714:	move.l	#invalid_drive_spec_s,d0
	bra.s	T_766
;
;------------------------------------
;
T_71C:	sub.w	#'a',d6
	bra.s	T_726
;
;------------------------------------
;
T_722:	sub.w	#'A',d6
T_726:	move	d6,gemsys_drive
T_72C:	lea	gemsys_path_s,a1
T_732:	bsr	scan_char
	bmi.s	T_742
	cmp.b	#' ',d0
	beq.s	T_742
	move.b	d0,(a1)+
	bra.s	T_732
;
;------------------------------------
;
T_742:	clr.b	(a1)
	bsr.s	pass_line
T_746:	clr.w	d0
T_748:	movem.l	(sp)+,d1-d2/a0-a2
	rts
;
;------------------------------------
;
T_74E:	clr.w	file_pos
	move	B_2614,gemsys_drive
	bra.s	T_746
;
;------------------------------------
;
T_760:	move.l	#invalid_path_spec_s,d0
T_766:	bsr	disp_string
	move	#-1,d0
	bra.s	T_748
;
;------------------------------------
;
disp_GEMSYS_path:
	movem.l	d0-a6,-(sp)
	move.l	#GEMSYS_path_colon_s,d0
	bsr	disp_string
	move	gemsys_drive,d0
	add.w	#'A',d0
	gemdos	Cconout,d0
	gemdos	Cconout,#':'
	move.l	#gemsys_path_s,d0
	bsr	disp_string
	move.l	#CRLF_s,d0
	bsr	disp_string
	movem.l	(sp)+,d0-a6
	rts
;
;----------------------------------------------------------------------------
;
pass_line:
	movem.l	d1/a0,-(sp)
	movea.l	filebase_p,a0
	adda.w	file_pos,a0
.T_7C8:
	move	file_pos,d1
	ext.l	d1
	cmp.l	filesize,d1
	bge.s	.exit_error
	move.b	(a0)+,d0
	addq.w	#1,file_pos
	cmpi.b	#LF,d0
	bne.s	.T_7C8
.T_7E6:
	move	file_pos,d1
	ext.l	d1
	cmp.l	filesize,d1
	bge.s	.exit_error
	move.b	(a0)+,d0
	addq.w	#1,file_pos
	cmpi.b	#' ',d0
	ble.s	.T_7E6
	move	d1,file_pos
	movem.l	(sp)+,d1/a0
	clr.w	d0
	rts
;
;------------------------------------
;
.exit_error:
	movem.l	(sp)+,d1/a0
	move	#-1,d0
	rts
;
;----------------------------------------------------------------------------
;
scan_char:
	movem.l	d1/a0,-(sp)
	movea.l	filebase_p,a0
	adda.w	file_pos,a0
	move	file_pos,d1
	ext.l	d1
	cmp.l	filesize,d1
	bge.s	.exit_error
	move.b	(a0)+,d0
	addq.w	#1,file_pos
	cmpi.b	#' ',d0
	ble.s	.exit_blank
	cmpi.b	#';',d0
	beq.s	.exit_blank
.exit:
	movem.l	(sp)+,d1/a0
	andi.w	#$FF,d0
	rts
;
;------------------------------------
;
.exit_error:
	movem.l	(sp)+,d1/a0
	move	#-1,d0
	rts
;
;------------------------------------
;
.exit_blank:
	move	#' ',d0
	bra.s	.exit
;
;----------------------------------------------------------------------------
;
scan_pass_blank:
	movem.l	d1/a0,-(sp)
	movea.l	filebase_p,a0
	adda.w	file_pos,a0
.T_87A:
	move	file_pos,d1
	ext.l	d1
	cmp.l	filesize,d1
	bge.s	.exit_error
	move.b	(a0)+,d0
	addq.w	#1,file_pos
	cmpi.b	#' ',d0
	ble.s	.T_87A
	cmpi.b	#';',d0
	bne.s	.exit
.pass_remark:
	move	file_pos,d1
	ext.l	d1
	cmp.l	filesize,d1
	bge.s	.exit_error
	move.b	(a0)+,d0
	addq.w	#1,file_pos
	cmpi.b	#LF,d0
	bne.s	.pass_remark
	bra.s	.T_87A
;
;------------------------------------
;
.exit:	movem.l	(sp)+,d1/a0
	subq.w	#1,file_pos
	rts
;
;------------------------------------
;
.exit_error:
	movem.l	(sp)+,d1/a0
	move	#-1,d0
	rts
;
;----------------------------------------------------------------------------
;
set_gemsys_drv_path:
	movem.l	d1-a6,-(sp)
	gemdos	Dsetdrv,gemsys_drive
	gemdos	Dsetpath,gemsys_path_s
	tst.w	d0
	bmi.s	T_8FA
	clr.w	d0
T_8FA:
	movem.l	(sp)+,d1-a6
	rts
;
;----------------------------------------------------------------------------
;
load_driver_sub:
	movem.l	d1-a6,-(sp)
	movea.l	d0,a0
	lea	filename_s,a1
.T_90C:	move.b	(a0)+,(a1)+
	bne.s	.T_90C
	subq.l	#1,a1
	move.b	#'.',(a1)+
	move.b	#'S',(a1)+
	move.b	#'Y',(a1)+
	move.b	#'S',(a1)+
	clr.b	(a1)
	move.l	#filename_s,d0
	bsr	find_filesize
	tst.w	d0
	bmi.s	.exit_error
	move.l	d1,B_2660
	gemdos	Fopen,filename_s,!
	tst.w	d0
	bpl.s	.T_960
.exit_error:
	clr.l	d0
	movem.l	(sp)+,d1-a6
	rts
;
;------------------------------------
;
.close_error:
	gemdos	Fclose,d7
	bra.s	.exit_error
;
;------------------------------------
;
.T_960:
	move	d0,d7
	gemdos	Fread,d7,#ph_size,proghead_buf
	cmpi.l	#ph_size,d0
	bne.s	.close_error
	lea	proghead_buf,a0
	cmpi.w	#$601A,ph_codebra(a0)
	bne.s	.close_error
	move.l	#$100,d0
	add.l	B_2660,d0
	add.l	ph_bss_len(a0),d0
	sub.l	ph_symblen(a0),d0	;d0 = RAM needed + ph_size
	move.l	B_2660,d1
	sub.l	ph_symblen(a0),d1
	sub.l	ph_textlen(a0),d1
	sub.l	ph_datalen(a0),d1
	subi.l	#ph_size,d1		;d1 = relocation data size
	move.l	d1,B_2660
	gemdos	Malloc,d0		;Allocate RAM for driver
	move.l	d0,driver_basepage_p
	ble.s	.close_error
	movea.l	d0,a0			;a0 -> basepage of new driver
	movea.l	basepage_p,a1
	lea	proghead_buf,a2
	move.l	bp_selfbeg_p(a1),bp_selfbeg_p(a0)	;\/ VERY VERY
	move.l	bp_selfend_p(a1),bp_selfend_p(a0)	;/\ DUBIOUS
	add.l	#$100,d0
	move.l	d0,bp_textbeg_p(a0)
	move.l	ph_textlen(a2),bp_textlen(a0)
	add.l	bp_textlen(a0),d0
	move.l	d0,bp_databeg_p(a0)
	move.l	ph_datalen(a2),bp_datalen(a0)
	add.l	bp_datalen(a0),d0
	move.l	d0,bp_bss_beg_p(a0)
	move.l	ph_bss_len(a2),bp_bss_len(a0)
	move.l	#bp_arglen,d0
	add.l	bp_selfbeg_p(a1),d0			;VERY VERY DUBIOUS
	move.l	d0,bp_dta_p(a0)
	move.l	bp_parent_p(a1),bp_parent_p(a0)
	move.l	bp_environ_p(a1),bp_environ_p(a0)
	clr.w	bp_arglen(a0)
	movea.l	bp_textbeg_p(a0),a4
	lea	proghead_buf,a5
	move.l	ph_textlen(a5),d5
	add.l	ph_datalen(a5),d5
	gemdos	Fread,d7,d5,(a4)	;load 'text' and 'data' sections of driver
	cmp.l	d0,d5
	beq.s	.relocate_driver
.free_error:
	gemdos	Mfree|_ind,driver_basepage_p
	bra	.close_error
;
;------------------------------------
;
.relocate_driver:
	gemdos	Fseek,ph_symblen(a5),d7,#1	;seek relocation data past symbols
	movea.l	driver_basepage_p,a3
	move.l	bp_bss_beg_p(a3),d0
	add.l	bp_bss_len(a3),d0
	move.l	d0,driver_stack_limit		;NB: end of RAM allocated for driver
	gemdos	Fread|_ind,d7,B_2660,d0		;BUG!!! buffer is unallocated !!!
	cmp.l	B_2660,d0
	bne.s	.free_error
	movea.l	driver_basepage_p,a0
	movea.l	bp_textbeg_p(a0),a3		;a3 -> driver code start
	movea.l	driver_stack_limit,a4		;a4 -> relocation data
	move.l	a3,d3				;d3 -> driver code start (relative zero)
	move.l	(a4)+,d0			;d0 = first relocation offset
	beq.s	.relocate_end			;skip relocation if first offset NULL
	adda.l	d0,a3				;a3 -> first relocation point
	add.l	d3,(a3)				;relocate first point
	clr.w	d0				;preclear d0 for relocation offset
.relocate_loop:				;loop target to relocate entire code
	move.b	(a4)+,d0			;d0 = next relocation offset byte
	beq.s	.relocate_end			;exit loop if offset NULL
	cmp.b	#1,d0				;d0 == 1 ?  (step 254 command)
	bne.s	.T_ADA				;else go relocate at location (a3,d0)
	lea	$FE(a3),a3			;a3 += 254  after step command
	bra.s	.relocate_loop		;loop back for next offset byte
;
.T_ADA:
	adda.w	d0,a3
	add.l	d3,(a3)
	bra.s	.relocate_loop		;loop back for next offset byte
;
;------------------------------------
;
.relocate_end:
	movea.l	driver_basepage_p,a0
	movea.l	bp_bss_beg_p(a0),a1
	move.l	bp_bss_len(a0),d0
	bra.s	.T_AF2
;
;------------------------------------
;
.T_AF0:	clr.b	(a1)+
.T_AF2:	subq.l	#1,d0
	bpl.s	.T_AF0
	gemdos	Fclose,d7
	move.l	driver_basepage_p,d7
	move.l	driver_stack_limit,d0
	sub.l	d7,d0
	gemdos	Mshrink|_ind,!,d7,d0
	move.l	d7,d0
	movem.l	(sp)+,d1-a6
	rts
;
;----------------------------------------------------------------------------
;
load_font_sub:
	movem.l	d1-a6,-(sp)
	lea	filename_s,a1
	movea.l	d0,a0		;a0 -> font filename
.T_B32:
	move.b	(a0)+,(a1)+
	bne.s	.T_B32
	subq.l	#1,a1
	move.b	#'.',(a1)+
	move.b	#'F',(a1)+
	move.b	#'N',(a1)+
	move.b	#'T',(a1)+
	clr.b	(a1)
	move.l	#filename_s,d0
	bsr	find_filesize
	tst.w	d0
	bmi.s	.T_B72
	move.l	d1,filesize
	gemdos	Fopen,filename_s,!
	move	d0,d7
	bpl.s	.T_B90
.T_B72:	clr.l	d0
	movem.l	(sp)+,d1-a6
	rts
;
;------------------------------------
;
.T_B7A:
	gemdos	Mfree|_ind,d6
.T_B84:
	gemdos	Fclose,d7
	bra.s	.T_B72
;
;------------------------------------
;
.T_B90:
	gemdos	Malloc,filesize
	tst.l	d0
	bmi.s	.T_B84
	beq.s	.T_B84
	move.l	d0,d6
	gemdos	Fread|_ind,d7,filesize,d6
	cmp.l	filesize,d0
	bne.s	.T_B7A
	gemdos	Fclose,d7
	movea.l	d6,a0
	btst	#2,$43(a0)
	bne.s	.T_C44
	move.l	$44(a0),d0
	swap	d0
	move.l	d0,$44(a0)
	move.l	$48(a0),d0
	swap	d0
	move.l	d0,$48(a0)
	move.l	$4C(a0),d0
	swap	d0
	move.l	d0,$4C(a0)
	movea.l	a0,a1
	move	#2,d0
	bsr.s	swap_d0_bytepairs_ia1
	lea	$24(a0),a1
	move	#$1A,d0
	bsr.s	swap_d0_bytepairs_ia1
	move	$26(a0),d3
	sub.w	$24(a0),d3
	addq.w	#2,d3
	btst	#1,$43(a0)
	beq.s	.T_C34
	movea.l	a0,a1
	adda.l	$44(a0),a1
	move	d3,d0
	bsr.s	swap_d0_bytepairs_ia1
	btst	#1,$43(a0)
	beq.s	.T_C34
	movea.l	a0,a1
	adda.l	$44(a0),a1
	move	d3,d0
	bsr.s	swap_d0_bytepairs_ia1
.T_C34:	movea.l	a0,a1
	adda.l	$48(a0),a1
	move	d3,d0
	bsr.s	swap_d0_bytepairs_ia1
	bset	#2,$43(a0)
.T_C44:	add.l	d6,$44(a0)
	add.l	d6,$48(a0)
	add.l	d6,$4C(a0)
	clr.l	$54(a0)
	move.l	a0,d0
	movem.l	(sp)+,d1-a6
	rts
;
;----------------------------------------------------------------------------
;
swap_d0_bytepairs_ia1:
	subq.w	#1,d0
.T_C5E:	move.b	(a1),d1
	move.b	1(a1),(a1)+
	move.b	d1,(a1)+
	dbra	d0,.T_C5E
	rts
;
;----------------------------------------------------------------------------
;
find_filesize:
	movem.l	d2-a6,-(sp)
	clr.w	-(sp)
	move.l	d0,-(sp)
	gemdos	Fgetdta
	move.l	d0,global_dta_p
	gemdos	Fsetdta,local_dta
	gemdos	Fsfirst,(),()
	move	d0,d7
	gemdos	Fsetdta|_ind,global_dta_p
	move.l	local_dta+dta_fsize,d1
	move	d7,d0
	movem.l	(sp)+,d2-a6
	rts
;
;----------------------------------------------------------------------------
;
disp_string:
	movem.l	d1-a6,-(sp)
	gemdos	Cconws|_ind,d0
	movem.l	(sp)+,d1-a6
	rts
;
;----------------------------------------------------------------------------
;Start of:	XGEM exception routine with XBRA
;----------------------------------------------------------------------------
;
non_VDI_XGEM:
	cmpi.w	#$C8,d0
	beq.s	go_old_XGEM
	cmpi.w	#-1,d0
	beq.s	nu_vq_driver
	cmpi.w	#-2,d0
	beq.s	nu_vq_gdos
go_old_XGEM:
	move.l	nu_xgem+xb_next(pc),-(sp)
	rts
;
;------------------------------------
;
nu_vq_driver:
	move.l	old_VDI_sub_p,d0
	rte
;
;------------------------------------
;
nu_vq_gdos:
	move.l	#T_CFA,d0
	rte
;
;------------------------------------
;
	XB_define	nu_xgem,'AMCG'
	cmpi.w	#$73,d0			;VDI/GEMDOS call ?
	bne.s	non_VDI_XGEM
T_CFA:
	movem.l	d0-d1/a0-a1,-(sp)
	move.l	d1,ext_vdipb_p
	movea.l	d1,a0			;a0 -> VDIPB
	movea.l	(a0),a0			;a0 -> contrl
	move	(a0),d0			;d0 =  VDI opcode
	bmi.s	T_d26			;d0 negative ?
	cmpi.w	#$96,d0			;d0 > legal codes ?
	bgt.s	T_d26
	lsl.w	#2,d0			;conv d0 from (byte *) to (long *)
	lea	VDI_func_t,a1
	movea.l	0(a1,d0.w),a1
	jsr	(a1)
	movem.l	(sp)+,d0-d1/a0-a1
	rte
;
;------------------------------------
;
T_d26:	bsr.s	nu_VDI_sub
	movem.l	(sp)+,d0-d1/a0-a1
	rte
;
;----------------------------------------------------------------------------
;End of:	XGEM exception routine with XBRA
;----------------------------------------------------------------------------
;Start of:	XGEM VDI subroutine with XBRA
;----------------------------------------------------------------------------
;
T_d2E:	movem.l	d0-a6,-(sp)
	bra	invalid_handle_al_sub
;
;------------------------------------
;
nu_VDI_sub:
	move	12(a0),d0	;d0 = vwk_handle
	subq.w	#1,d0		;d0 = vwk_index
	bmi.s	T_d2E
	lsl.w	#2,d0
	lea	workstation_link_t,a1
	movea.l	0(a1,d0.w),a1
	move.l	a1,d0
	bmi.s	T_D84
	beq.s	T_DB8
	move	$2C(a1),12(a0)	;driver wk_handle in control = $2c(a1)
	tst.w	$1E(a1)
	bne.s	T_d7E
	move	$1A(a1),d0
	move	$1C(a1),d1
	move	d0,-(sp)
	move	d1,-(sp)
	bsr.s	T_DBE
	move.l	ext_vdipb_p,d1
	movea.l	$12(a1),a0
	jsr	(a0)
	move	(sp)+,d1
	move	(sp)+,d0
	bra	T_E0C
;
;------------------------------------
;
T_d7E:	movea.l	$12(a1),a0
	jmp	(a0)
;
;------------------------------------
;
T_D84:	lea	virtual_struct_t,a1
	lsl	#4,d0
	add	d0,a1
	move	10(a1),12(a0)
	tst	4(a1)
	bne.s	T_DBA
	move	6(a1),d0
	move	8(a1),d1
	move	d0,-(sp)
	move	d1,-(sp)
	bsr.s	T_DBE
	move.l	ext_vdipb_p,d1
	movea.l	(a1),a0
	jsr	(a0)
	move	(sp)+,d1
	move	(sp)+,d0
	bra.s	T_E0C
;
;------------------------------------
;
T_DB8:	rts
;
;----------------------------------------------------------------------------
;
T_DBA:	movea.l	(a1),a0
	jmp	(a0)
;
;------------------------------------
;
T_DBE:	movem.l	d2-d5/a0-a2,-(sp)
	movea.l	ext_vdipb_p,a0
	movea.l	8(a0),a2
	move.l	a2,ext_vdi_ptsin_p
	lea	B_1E08,a1
	move.l	a1,8(a0)
	movea.l	(a0),a0
	move	2(a0),d2
	beq.s	T_E06
	subq.w	#1,d2
	move	d1,d4
	subq.w	#1,d4
T_DEA:	move	(a2)+,d3
	muls	d0,d3
	add.l	d3,d3
	swap	d3
	move	d3,(a1)+
	move	(a2)+,d3
	muls	d1,d3
	add.l	d3,d3
	swap	d3
	move	d4,d5
	sub.w	d3,d5
	move	d5,(a1)+
	dbra	d2,T_DEA
T_E06:	movem.l	(sp)+,d2-d5/a0-a2
	rts
;
;----------------------------------------------------------------------------
;
T_E0C:	movem.l	d2-d5/a1-a2,-(sp)
	movea.l	ext_vdipb_p,a2
	movea.l	a2,a1
	move.l	ext_vdi_ptsin_p,8(a1)
	movea.l	(a2),a1
	move	4(a1),d2
	beq.s	T_E52
	subq.w	#1,d2
	movea.l	$10(a2),a1
	move	d1,d4
	subq.w	#1,d4
T_E32:	clr.l	d3
	move	(a1),d3
	swap	d3
	asr.l	#1,d3
	divs	d0,d3
	move	d3,(a1)+
	clr.l	d5
	move	(a1),d3
	move	d4,d5
	sub.w	d3,d5
	swap	d5
	asr.l	#1,d5
	divs	d1,d5
	move	d5,(a1)+
	dbra	d2,T_E32
T_E52:	movem.l	(sp)+,d2-d5/a1-a2
	rts
;
;----------------------------------------------------------------------------
;
nu_v_opnwk:
	movem.l	d0-a6,-(sp)
	movea.l	ext_vdipb_p,a0
	lea	loc_vdi_vdipb,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	lea	workstation_link_t,a1
	clr	d7
.T_E7A:
	tst.l	(a1)+			;link free (zero) ?
	beq.s	.T_E88			;goto .T_E88 when free link found
	addq	#1,d7
	cmp	#workstation_max,d7
	blt.s	.T_E7A
	bra.s	.exit_error
;
;------------------------------------
;
.T_E88:					;d7 is index to free link
	move	d7,B_26a0
	movea.l	ext_vdi_intin_p,a0
	move	(a0),d1			;d1 = device code  (as in ASSIGN.SYS)
	movea.l	device_struct_t_p,a4	;a4 -> device structure table
	move	device_count,d2		;d2 = device search loop counter
	subq	#1,d2			;d2 -= 1 for dbra
	bmi.s	.exit_error		;.exit_error if no devices defined
	clr	d6			;d6 = 0  as device search index
.T_EA8:				;loop target to find correct device index
	cmp	(a4),d1			;found structure of device code ?
	beq.s	.found_struct
	lea	64(a4),a4		;step a4 -> next device structure
	addq	#1,d6			;step d6 to next device index
	dbra	d2,.T_EA8	;loop back to find correct device index
.exit_error:
	movea.l	ext_vdi_control_p,a0
	clr	12(a0)
	movem.l	(sp)+,d0-a6
	rts
;
;------------------------------------
;
.found_struct:
	lea	workstation_link_t,a1
	asl	#2,d7
	move.l	a4,0(a1,d7)		;set link -> device structure
	move	d6,$10(a4)		;device_index
	tst.l	$12(a4)			;driver ?
	bne.s	.T_F06
	bsr	get_drv_path
	bsr	set_gemsys_drv_path
	tst	d0
	bmi.s	.exit_error
	move.l	a4,d0
	addq.l	#6,d0
	bsr	load_driver_sub
	bsr	set_drv_path
	tst.l	d0
	beq.s	.exit_error
	move.l	d0,$16(a4)		;-> driver basepage
	addi.l	#$100,d0
	move.l	d0,$12(a4)		;-> driver code
.T_F06:
	move.l	a4,-(sp)		;push -> device structure
	movea.l	$12(a4),a4		;a4 -> driver code
	move.l	ext_vdipb_p,d1		;d1 -> external vdipb
	jsr	(a4)			;call driver to initialize it
	movea.l	ext_vdi_control_p,a1
	move	#1,12(a1)
	movea.l	(sp)+,a1
	movea.l	ext_vdi_control_p,a0
	move	12(a0),$2C(a1)
	beq.s	.T_F82
	movea.l	ext_vdi_intout_p,a0
	move	(a0),$1A(a1)
	addq.w	#1,$1A(a1)
	move	2(a0),$1C(a1)
	addq.w	#1,$1C(a1)
	clr.w	$20(a1)
	clr.w	$2A(a1)
	movea.l	ext_vdi_intin_p,a0
	move	$14(a0),$1E(a1)
	bne.s	.exit_ok
	move	$1A(a1),d0
	move	$1C(a1),d1
	bsr	T_E0C
.exit_ok:
	movea.l	ext_vdi_control_p,a0
	move	B_26a0,12(a0)
	addq.w	#1,12(a0)		;return new wk_handle = link index + 1
	movem.l	(sp)+,d0-a6
	rts
;
;------------------------------------
;
.T_F82:	move	2(a1),d0
	beq	.exit_error
	cmpi.w	#1,d0
	beq	.exit_error
	clr.l	$12(a1)
	gemdos	Mfree|_ind,$16(a1)
	bra	.exit_error
;
;----------------------------------------------------------------------------
;
nu_v_clswk:
	movem.l	d0-a6,-(sp)
	movea.l	ext_vdipb_p,a0
	lea	loc_vdi_vdipb,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	movea.l	ext_vdi_control_p,a0
	move	12(a0),d0		;d0 = wk_handle
	subq	#1,d0			;d0 = device workstation link index
	bmi	invalid_handle_al_sub
	lea	workstation_link_t,a0
	asl	#2,d0
	adda	d0,a0
	tst.l	(a0)
	ble	invalid_handle_al_sub	;vwk_handles are not wk_handles
;;;patch start
	move.l	ext_vdi_control_p,a1
	movem.l	(a1),d1-d7		;save control array in regs
	movem.l	d0-d7/a0-a1,-(sp)	;and push them, with d0/a0-a1
;
	move.l	ext_vdi_control_p,a1
	move	12(a1),d7		;d7 = wk_handle
	subq	#1,d7			;d7 = link_index of device
	asl	#2,d7
	lea	workstation_link_t,a0
	move.l	(a0,d7),a0		;a0 -> device struct
	tst	$20(a0)			;any users for the fonts ?
	bne.s	.do_fonts
	tst	$2A(a0)			;fonts loaded ?
	beq.s	.done_fonts		;if not, skip unloading
.do_fonts:
	move	#1,$20(a0)		;pretend to have 1 user only
	move.l	ext_vdi_control_p,a1
	move	#vst_unload_fonts&$ff,(a1)	;Specify vst_unload_fonts function
	move.l	ext_vdi_intin_p,a1
	clr.l	(a1)
	bsr	nu_vst_unload_fonts
.done_fonts:
;
	movem.l	(sp),d0-d7/a0-a1	;reload regs pushed at patch start
	movem.l	d1-d7,(a1)		;restore control array
	move.l	ext_vdi_control_p,a1
	move	12(a1),d7		;d7 = wk_handle
	subq	#1,d7			;d7 = link_index of device
	clr	d6			;d6 = 0 as search link_index
	lea	workstation_link_t,a0
	lea	virtual_struct_t,a1
	move	#workstation_max-1,d2
.link_loop:
	tst.l	(a0)+			;what type is current link
	bge.s	.next_link		;not interested in physical device or free link
	move	-2(a0),d0		;d0 = virtual_index
	asl	#4,d0
	cmp	12(a1,d0),d7		;does this vwk belong to our device ?
	bne.s	.next_link		;else not interested
	movem.l	d0-d7/a0-a6,-(sp)
;
	move	d6,d0			;d0 = link_index of vwk
	addq	#1,d0			;d0 = vwk_handle
	move.l	ext_vdi_control_p,a1
	move	#v_clsvwk&$ff,(a1)	;\/ Specify v_clsvwk function
	move	d0,12(a1)		;/\ for vwk_handle d0
	bsr	nu_v_clsvwk
;
	movem.l	(sp)+,d0-d7/a0-a6
.next_link:
	addq	#1,d6
	dbra	d2,.link_loop
	movem.l	(sp)+,d0-d7/a0-a1	;pull regs pushed at patch start
	movem.l	d1-d7,(a1)		;restore control array
;;;patch end
	movea.l	(a0),a1			;a1 -> device_struct
	clr.l	(a0)			;clear workstation link
	move.l	a1,-(sp)		;push -> device_struct
	move.l	ext_vdipb_p,d1
	movea.l	$12(a1),a1
	jsr	(a1)			;call driver to close workstation
	movea.l	(sp)+,a0
	cmp	#1,2(a0)		;resident driver
	beq.s	T_1018
	cmp	#2,2(a0)		;reloadable driver  (else ROM driver)
	bne.s	T_1012
	clr.l	$12(a0)
	gemdos	Mfree|_ind,$16(a0)
T_1012:
	movem.l	(sp)+,d0-a6
	rts
;
;------------------------------------
;
T_1018:	movea.l	$22(a0),a1
	move.l	$26(a0),d0
	movea.l	$16(a0),a2
	movea.l	$10(a2),a3
	bra.s	T_102C
;
;------------------------------------
;
T_102A:	move.b	(a1)+,(a3)+
T_102C:	subq.l	#1,d0
	bpl.s	T_102A
	movea.l	$18(a2),a3
	move.l	$1C(a2),d0
	bra.s	T_103C
;
;------------------------------------
;
T_103A:	clr.b	(a3)+
T_103C:	subq.l	#1,d0
	bpl.s	T_103A
	bra.s	T_1012
;
;------------------------------------
;
invalid_handle_al_sub:
	gemdos	Cconout,#BEL
	move.l	#loc_aes_aespb,d1
	move	#$C8,d0
	trap	#2			;aes
	movea.l	ext_vdipb_p,a0
	movea.l	(a0),a0
	clr	12(a0)
	movem.l	(sp)+,d0-a6
	rts
;
;----------------------------------------------------------------------------
;
nu_v_opnvwk:
	movem.l	d0-a6,-(sp)
	movea.l	ext_vdipb_p,a0
	lea	loc_vdi_vdipb,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	movea.l	ext_vdi_control_p,a0
	tst.w	12(a0)
	beq.s	invalid_handle_al_sub
	bmi.s	invalid_handle_al_sub
	lea	workstation_link_t,a1
	clr.w	d7
.T_109C:
	tst.l	(a1)+			;link free (zero) ?
	beq.s	.T_10AA			;goto .T_10AA when free link found
	addq	#1,d7
	cmp	#workstation_max,d7
	blt.s	.T_109C
	bra.s	.exit_error
;
;------------------------------------
;
.T_10AA:				;d7 is index to free link
	lea	virtual_struct_t,a0
	clr	d0			;d0 = 0 as virtual_index
.T_10B2:
	tst.l	(a0)
	beq.s	.T_10d2
	addq	#1,d0			;d0 = next virtual_index
	lea	16(a0),a0		;a0 -> next struct
	cmp	#virtual_max,d0
	blt.s	.T_10B2
.exit_error:
	movea.l	ext_vdi_control_p,a0
	clr	12(a0)
	movem.l	(sp)+,d0-a6
	rts
;
;------------------------------------
;
.T_10d2:				;d0 = free virtual_index
	subq.l	#4,a1			;a1 -> found free workstation_link
	move	#-1,(a1)+		;high word of link = -1  as virtual_flag
	move	d0,(a1)			;low word of link = virtual_index
	move	d0,B_26a0
	movea.l	ext_vdi_control_p,a0
	move	12(a0),d0		;d0 = device wk_handle
	subq	#1,d0			;d0 = device workstation link index
	move	d0,-(sp)		;push d0 = device workstation link index
	move	d7,-(sp)		;push d7 = virtual workstation link index
	lea	workstation_link_t,a0
	asl	#2,d0
	tst.l	(a0,d0)
	ble.s	.pop_error
	movea.l	(a0,d0),a0		;a0 -> device_struct
	tst.l	$12(a0)
	ble.s	.pop_error
	movea.l	$12(a0),a0		;a0 -> driver code
	jsr	(a0)			;call driver
	move	(sp)+,d7		;pull d7 = new workstation link index
	move	(sp)+,d1		;pull d1 = device workstation link index
	movea.l	ext_vdi_control_p,a0
	tst.w	12(a0)			;good vwk_handle from driver ?
	bne.s	.T_1124			;if so, goto .T_1124
	lea	workstation_link_t,a0
	asl.w	#2,d7
	clr.l	0(a0,d7.w)		;clear new link, so it remains free
	movem.l	(sp)+,d0-a6
	rts
;
.pop_error:
	addq	#4,sp
	bra.s	.exit_error
;
;------------------------------------
;
.T_1124:
	lea	virtual_struct_t,a0
	move	B_26a0,d0		;d0 = virtual_index of new vwk
	asl.w	#4,d0
	adda.w	d0,a0
	move	d1,12(a0)
	clr.w	14(a0)
	lea	workstation_link_t,a1
	asl.w	#2,d1
	movea.l	0(a1,d1.w),a1		;a1 -> device_struct
	move.l	$12(a1),(a0)		;-> driver code
	move	$1A(a1),6(a0)		;xrez
	move	$1C(a1),8(a0)		;yrez
	movea.l	ext_vdi_intin_p,a1
	move	$14(a1),4(a0)		;NDC=0/def=1=RC=2 coordinate type
	bne.s	.T_1172
	move	6(a0),d0
	move	8(a0),d1
	bsr	T_E0C
.T_1172:
	movea.l	ext_vdi_control_p,a1
	move	12(a1),10(a0)		;driver vwk_handle (for driver calls ONLY)
	addq.w	#1,d7			;d7 = virtual workstation link_index + 1
	move	d7,12(a1)		;return d7 as external vwk_handle
	movem.l	(sp)+,d0-a6
	rts
;
;----------------------------------------------------------------------------
;
nu_v_clsvwk:	movem.l	d0-a6,-(sp)
	movea.l	ext_vdipb_p,a0
	lea	loc_vdi_vdipb,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	movea.l	ext_vdi_control_p,a0	;a0 -> external control
	move	12(a0),d0		;d0 = vwk_handle
	subq.w	#1,d0			;d0 = workstation_index
	bmi	invalid_handle_al_sub
	lea	workstation_link_t,a0
	asl.w	#2,d0
	adda.w	d0,a0
	tst.l	(a0)
	bpl	invalid_handle_al_sub	;wk_handles are not legal vwk_handles
	move	2(a0),d0
	clr.l	(a0)			;release this link
	lea	virtual_struct_t,a0
	asl.w	#4,d0
	adda.w	d0,a0
	movea.l	(a0),a1
	clr.l	(a0)
	move.l	ext_vdipb_p,d1
	movea.l	ext_vdi_control_p,a2
	move	10(a0),12(a2)
	jsr	(a1)
	movem.l	(sp)+,d0-a6
	rts
;
;----------------------------------------------------------------------------
;
nu_vst_load_fonts:
	movem.l	d0-a6,-(sp)
	movea.l	ext_vdipb_p,a0		;a0 -> external vdipb
	lea	loc_vdi_vdipb,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	movea.l	ext_vdi_control_p,a0	;a0 -> external control
	move	12(a0),d7		;d7 = wk_handle/vwk_handle
	subq	#1,d7			;d7 = link_index
	bmi	invalid_handle_al_sub
	bsr	get_drv_path
	bsr	set_gemsys_drv_path
	tst	d0
	bmi.s	.exit_error
	move	d7,d0			;d0 = link_index
	lea	workstation_link_t,a0
	asl	#2,d0
	movea.l	0(a0,d0),a0		;a0 = link
	move.l	a0,d0			;legal link ?
	beq	invalid_handle_al_sub	;unused link is useless here
	bpl.s	.physical		;goto .physical if wk_handle
.virtual:
	lea	virtual_struct_t,a0
	asl	#4,d0
	lea	0(a0,d0),a0		;a0 -> virtual_struct of vwk
	movea.l	ext_vdi_control_p,a1
	move	10(a0),12(a1)		;move driver vwk_handle to control
	tst	14(a0)			;fonts already loaded ?
	seq	new_load_f
	move	#1,14(a0)		;mark virtual fonts loaded for future calls
	lea	workstation_link_t,a1
	move	12(a0),d0		;d0 = device link_index
	asl	#2,d0
	movea.l	0(a1,d0),a0		;a0 -> device_struct
	bra.s	.T_1298
;
;------------------------------------
;
.exit_error:
	movea.l	ext_vdi_intout_p,a0
	clr.w	(a0)
	bra	.exit
;
;------------------------------------
;
.physical:
	movea.l	ext_vdi_control_p,a1
	move	$2C(a0),12(a1)		;move device wk_handle to control
	tst	$2A(a0)			;fonts already loaded ?
	seq	new_load_f
	move	#1,$2A(a0)		;mark device fonts loaded for future calls
.T_1298:
	move	$10(a0),d7		;d7 = device_index
	move	d7,last_device_index
	tst	$20(a0)			;is anyone using fonts of this device
	beq.s	.T_12AA			;if not, go load them
	addq	#1,$20(a0)		;increment font user count for this device
	bra	.T_133A			;skip past the actual loading
;
;------------------------------------
;
.T_12AA:
	movea.l	font_p_t_p,a1		;a1 -> font_p_t
	mulu	max_font_count,d7	;d7 = device_index * max_font_count
	asl	#4,d7			;d7 *= 16
	adda	d7,a1			;a1 -> font_struct array of this device
	movea.l	a1,a4			;a4 -> font_struct array of this device
	move	4(a0),d6		;d6 = number of fonts for device
	beq.s	.exit_error		;if none, break loading
	subq	#1,d6			;d6 = prep for dbra
	clr	d5			;d5 = font_index
;
.T_12C8:			;loop target for each font file to load
	tst.l	2(a1)			;already have this font ? (resident)
	bne.s	.T_12DC			;if so, skip loading it
	move.l	a1,d0
	addq.l	#6,d0
	bsr	load_font_sub
	move.l	d0,2(a1)		;mark font as loaded
	beq.s	.T_12DE
.T_12DC:
	addq	#1,d5			;increment valid font count
.T_12DE:
	lea	$10(a1),a1
	dbra	d6,.T_12C8	;loop back for each font file to load
;
	movea.l	a4,a1		;a1 -> font array of this device
	move	d5,d6		;d6 = number of valid fonts in array
	beq	.exit_error	;exit if none valid
	subq	#1,d6		;d6 -= 1
	addq	#1,$20(a0)	;increment font user count for this device
.T_12F4:
	tst.l	2(a1)		;valid font ?
	bne.s	.T_1300
	lea	$10(a1),a1	;a1 -> next font_struct
	bra.s	.T_12F4
;
.T_1300:
	move.l	2(a1),font_root_p	;-> first valid font
	movea.l	a1,a2			;a2 -> valid font_struct
	subq	#1,d6
	bmi.s	.T_1332
;
	lea	$10(a1),a1	;a1 -> next font_struct
.T_1312:
	tst.l	2(a1)		;valid font ?
	bne.s	.T_131E
	lea	$10(a1),a1	;a1 -> next font_struct
	bra.s	.T_1312
;
.T_131E:
	movea.l	2(a2),a2	;a2 -> previous font
	move.l	2(a1),$54(a2)	;link current font into previous font
	movea.l	a1,a2
	lea	$10(a1),a1	;a1 -> next font_struct
	dbra	d6,.T_1312
;
.T_1332:
	movea.l	2(a2),a2	;a2 -> final font
	clr.l	$54(a2)		;clear final link
.T_133A:
	tst.b	new_load_f
	beq.s	.simulate		;simulate driver on redundant loads
	move.l	ext_vdi_control_p,a1
	move.l	#B_28B0,14(a1)		;-> scratchpad
	move	#1000,$12(a1)		;offset to 2nd scratchpad
	move.l	font_root_p,$14(a1)	;font_root
	move.l	ext_vdipb_p,d1
	movea.l	$12(a0),a0
	jsr	(a0)			;call VDI driver
	move	last_device_index(pc),d7
	add	d7,d7
	lea	load_fonts_result_t(pc),a1
	move.l	ext_vdi_intout_p(pc),a0
	move	(a0),(a1,d7)
.exit:
	move.l	ext_vdi_intout_p(pc),a0
	move	(a0),d0
	ext.l	d0
	move.l	d0,(sp)			;future d0 on stack = intout[0]
	bsr	set_drv_path
	movem.l	(sp)+,d0-a6
	rts
;
.simulate:
	move	last_device_index(pc),d7
	add	d7,d7
	lea	load_fonts_result_t(pc),a1
	move.l	ext_vdi_intout_p(pc),a0
	move	(a1,d7),(a0)			;intout[0]=font_family_count
	move.l	ext_vdi_control_p(pc),a0
	move	#1,8(a0)			;sintout=1
	bra.s	.exit
	
;
;----------------------------------------------------------------------------
;
nu_vst_unload_fonts:
	movem.l	d0-a6,-(sp)
	movea.l	ext_vdipb_p,a0
	lea	loc_vdi_vdipb,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	movea.l	ext_vdi_control_p,a0
	move	12(a0),d0		;d0 = wk_handle/vwk_handle
	subq.w	#1,d0			;d0 = link_index
	bmi	invalid_handle_al_sub
	move	d0,d7			;d7 = link_index
	lea	workstation_link_t,a0
	asl.w	#2,d0
	movea.l	0(a0,d0.w),a0		;a0 = link
	move.l	a0,d0			;d0 = link
	beq	invalid_handle_al_sub	;unused link is useless here
	bpl.s	.T_13D8			;goto .T_13D8 for wk_handle
	lea	virtual_struct_t,a0
	asl	#4,d0			;d0 *= 16
	adda	d0,a0			;a0 -> virtual_struct for this vwk
	clr	14(a0)			;mark fonts as not loaded for future calls
	movea.l	ext_vdi_control_p,a1
	move	10(a0),12(a1)		;move driver vwk_handle to control
	move	12(a0),d0		;d0 = device link_index
	lea	workstation_link_t,a0
	asl	#2,d0
	movea.l	0(a0,d0.w),a0		;a0 -> device_struct
	bra.s	.T_13E8
;
;------------------------------------
;
.T_13D8:
	clr.w	$2A(a0)			;mark fonts as not loaded for future calls
	movea.l	ext_vdi_control_p,a1
	move	$2C(a0),12(a1)		;move driver wk_handle to control
.T_13E8:
	subq.w	#1,$20(a0)		;decrement user count for this device's fonts
	bne.s	.T_1446			;simplify unload if users remain
	movea.l	font_p_t_p,a5
	move	$10(a0),d7
	mulu	max_font_count,d7
	asl.w	#4,d7
	adda.w	d7,a5			;a5 -> font_struct array for this device
	move	4(a0),d7		;d7 = number of fonts for this device
	beq.s	.T_1440			;skip unload if no fonts
	subq.w	#1,d7
	movem.l	d7/a5,-(sp)
	move.l	ext_vdipb_p,d1
	movea.l	$12(a0),a0
	jsr	(a0)			;call driver to unload fonts
	movem.l	(sp)+,d7/a5
.T_141E:			;loop target for each font to unload
	tst.w	(a5)			;resident font ?
	bne.s	.T_1438			;if so, try next one
	tst.l	2(a5)			;valid font ?
	beq.s	.T_1438			;if not, try next one
	move.l	2(a5),-(sp)
	clr.l	2(a5)
	gemdos	Mfree,()		;release RAM of font
.T_1438:
	lea	$10(a5),a5		;a5 -> next font_struct
	dbra	d7,.T_141E	;loop back for each font to unload
.T_1440:
	movem.l	(sp)+,d0-a6
	rts
;
;------------------------------------
;
.T_1446:
	move.l	ext_vdipb_p,d1
	movea.l	$12(a0),a0
	jsr	(a0)
	bra.s	.T_1440
;
;----------------------------------------------------------------------------
;Start of:	Supexec subroutine	'install_XB'
;----------------------------------------------------------------------------
;entry:	a0 -> XBRA chain root
;  "	a1 -> XBRA structure to install
;exit:	a0 = used link/garbage/garbage  \/ depending on
;  "	d0 = 0/E_ACCDN/E_SEEK (flagged) /\ success/conflict/vector_smash
;
install_XB:
	movem.l	a1-a3,-(sp)
	move	sr,-(sp)
	ori	#$0700,sr
	move.l	a0,a3
	move.l	xb_id(a1),d0
.loop:
	move.l	(a0),a2			;a2 -> xb_code of next vector
	lea	-xb_code(a2),a2		;a2 -> XBRA structure
	cmp.l	#'XBRA',xb_magic(a2)
	bne.s	.smashed
	cmp.l	xb_id(a2),d0
	beq.s	.found
	lea	xb_next(a2),a0		;a0 -> xb_next -> next xb_code
	tst.l	(a0)
	bgt.s	.loop
.unused:
.smashed:
	move.l	a3,a0
	move.l	(a0),xb_next(a1)
	lea	xb_code(a1),a1
	move.l	a1,(a0)
	moveq	#E_OK,d0
	bra.s	.exit
;
.found:
	moveq	#E_ACCDN,d0
.exit:
	move	(sp)+,sr
	tst.l	d0
	movem.l	(sp)+,a1-a3
	rts
;
;----------------------------------------------------------------------------
;End of:	Supexec subroutine	'install_XB'
;----------------------------------------------------------------------------
	SECTION	DATA
;----------------------------------------------------------------------------
;
	dc.b	NUL,NUL
D_1456:
	dc.b	'\\',NUL
path_lc_s:
	dc.b	'path',NUL,NUL
PATH_uc_s:
	dc.b	'PATH',NUL,NUL
AMC_GDOS_installed_s:
	dc.b	CR,LF
	dc.b	'AMC-GDOS Ver: 3.21 CRX  URAn rev: 1.2  ',CR,LF
	dc.b	'Revised 1995.10.18 Ulf Ronald Andersson',CR,LF
	dc.b	'This revision work is freeware,  so the',CR,LF
	dc.b	'copyrights remain as originally stated:',CR,LF
	dc.b	'Copyright 1987,88,89 Arnd Beižner',CR,LF
	dc.b	CR,LF
	dc.b	'AMC-GDOS successfully installed.',CR,LF
	dc.b	CR,LF,NUL,NUL
AMC_GDOS_not_installed_s:
	dc.b	CR,LF
	dc.b	'AMC-GDOS Ver: 3.21 CRX (dt) URAn rev: 1',CR,LF
	dc.b	'AMC-GDOS not installed.',CR,LF
	dc.b	CR,LF,NUL
ASSIGN_SYS_s:
	dc.b	'ASSIGN.SYS',NUL,NUL
ASSIGN_SYS_not_found_S:
	dc.b	CR,LF,'- "ASSIGN.SYS" not found',NUL
too_little_RAM_s:
	dc.b	CR,LF,'- too little free RAM',NUL,NUL
path_not_found_s:
	dc.b	CR,LF,'- Path not found',NUL
driver_not_found_s:
	dc.b	CR,LF,'- Device driver not found',NUL,NUL
font_not_found_s:
	dc.b	CR,LF,'- Font not found',NUL,NUL
press_key_s:
	dc.b	'- Please press a key',CR,LF,CR,LF,NUL,NUL
GDOS_error_inv_handle_al:
	dc.b	'[3][GDOS-error: Invalid handle][ Exit ]',1,NUL
release_key_s:
	dc.b	'- Please release the key again',CR,LF,CR,LF,NUL
driver_expected_s:
	dc.b	CR,LF,'ASSIGN.SYS - Device driver entry expected',NUL,NUL
bad_driver_code_s:
	dc.b	CR,LF,'ASSIGN.SYS - Too many digits in device driver code',NUL
blank_option_expected_s:
	dc.b	CR,LF,'ASSIGN.SYS - Blank or option-letter expected',NUL
name_too_long_s:
	dc.b	CR,LF,'ASSIGN.SYS - Filename too long (more than 8 char)',NUL
invalid_path_spec_s:
	dc.b	CR,LF,'ASSIGN.SYS - Invalid path specified',NUL
unexpected_EOF_s:
	dc.b	CR,LF,'ASSIGN.SYS - Unexpected end of file',NUL
invalid_drive_spec_s:
	dc.b	CR,LF,'ASSIGN.SYS - Invalid drive specified',NUL
stack_overflow_s:
	dc.b	CR,LF,'ACHTUNG! Internal stack overflow!',NUL
GEMSYS_path_colon_s:
	dc.b	CR,LF,'GEMSYS-path: ',NUL
CRLF_s:
	dc.b	CR,LF,NUL,NUL
;
	even
;
gemsys_drive:	dc.w	-1
;
gemsys_path_s:
	dc.b	'\\',$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
	dc.b	$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
	dc.b	$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
	dc.b	$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
	dc.b	$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
	dc.b	$0,$0,$0,$0,$0,$0,$0,$0,$0
;
loc_aes_aespb:
	dc.l	loc_aes_cntrl
	dc.l	loc_aes_global
	dc.l	loc_aes_intin
	dc.l	loc_aes_intout
	dc.l	loc_aes_addrin
	dc.l	loc_aes_addrout
;
loc_aes_cntrl:		dc.w	form_alert&$ff,1,1,1,0
			ds.w	7
loc_aes_intin:		dc.w	1
			ds.w	29
loc_aes_intout:		dc.w	0
			ds.w	44
loc_aes_addrin:		dc.l	GDOS_error_inv_handle_al
			ds.l	2
loc_aes_addrout:	dc.l	0
loc_aes_global:		dc.w	$1E
			ds.w	14
;
;------------------------------------
;
VDI_func_t:
	dc.l	0	;$00
	dc.l	nu_v_opnwk	;$01	v_opnwk
	dc.l	nu_v_clswk	;$02	v_clswk
	dc.l	nu_VDI_sub	;$03
	dc.l	nu_VDI_sub	;$04
	dc.l	nu_VDI_sub	;$05
	dc.l	nu_VDI_sub	;$06
	dc.l	nu_VDI_sub	;$07
	dc.l	nu_VDI_sub	;$08
	dc.l	nu_VDI_sub	;$09
	dc.l	nu_VDI_sub	;$0a
	dc.l	nu_VDI_sub	;$0b
	dc.l	nu_VDI_sub	;$0c
	dc.l	nu_VDI_sub	;$0d
	dc.l	nu_VDI_sub	;$0e
	dc.l	nu_VDI_sub	;$0f
	dc.l	nu_VDI_sub	;$10
	dc.l	nu_VDI_sub	;$11
	dc.l	nu_VDI_sub	;$12
	dc.l	nu_VDI_sub	;$13
	dc.l	nu_VDI_sub	;$14
	dc.l	nu_VDI_sub	;$15
	dc.l	nu_VDI_sub	;$16
	dc.l	nu_VDI_sub	;$17
	dc.l	nu_VDI_sub	;$18
	dc.l	nu_VDI_sub	;$19
	dc.l	nu_VDI_sub	;$1a
	dc.l	nu_VDI_sub	;$1b
	dc.l	nu_VDI_sub	;$1c
	dc.l	nu_VDI_sub	;$1d
	dc.l	nu_VDI_sub	;$1e
	dc.l	nu_VDI_sub	;$1f
	dc.l	nu_VDI_sub	;$20
	dc.l	nu_VDI_sub	;$21
	dc.l	nu_VDI_sub	;$22
	dc.l	nu_VDI_sub	;$23
	dc.l	nu_VDI_sub	;$24
	dc.l	nu_VDI_sub	;$25
	dc.l	nu_VDI_sub	;$26
	dc.l	nu_VDI_sub	;$27
	dc.l	nu_VDI_sub	;$28
	dc.l	nu_VDI_sub	;$29
	dc.l	nu_VDI_sub	;$2a
	dc.l	nu_VDI_sub	;$2b
	dc.l	nu_VDI_sub	;$2c
	dc.l	nu_VDI_sub	;$2d
	dc.l	nu_VDI_sub	;$2e
	dc.l	nu_VDI_sub	;$2f
	dc.l	nu_VDI_sub	;$30
	dc.l	nu_VDI_sub	;$31
	dc.l	nu_VDI_sub	;$32
	dc.l	nu_VDI_sub	;$33
	dc.l	nu_VDI_sub	;$34
	dc.l	nu_VDI_sub	;$35
	dc.l	nu_VDI_sub	;$36
	dc.l	nu_VDI_sub	;$37
	dc.l	nu_VDI_sub	;$38
	dc.l	nu_VDI_sub	;$39
	dc.l	nu_VDI_sub	;$3a
	dc.l	nu_VDI_sub	;$3b
	dc.l	nu_VDI_sub	;$3c
	dc.l	nu_VDI_sub	;$3d
	dc.l	nu_VDI_sub	;$3e
	dc.l	nu_VDI_sub	;$3f
	dc.l	nu_VDI_sub	;$40
	dc.l	nu_VDI_sub	;$41
	dc.l	nu_VDI_sub	;$42
	dc.l	nu_VDI_sub	;$43
	dc.l	nu_VDI_sub	;$44
	dc.l	nu_VDI_sub	;$45
	dc.l	nu_VDI_sub	;$46
	dc.l	nu_VDI_sub	;$47
	dc.l	nu_VDI_sub	;$48
	dc.l	nu_VDI_sub	;$49
	dc.l	nu_VDI_sub	;$4a
	dc.l	nu_VDI_sub	;$4b
	dc.l	nu_VDI_sub	;$4c
	dc.l	nu_VDI_sub	;$4d
	dc.l	nu_VDI_sub	;$4e
	dc.l	nu_VDI_sub	;$4f
	dc.l	nu_VDI_sub	;$50
	dc.l	nu_VDI_sub	;$51
	dc.l	nu_VDI_sub	;$52
	dc.l	nu_VDI_sub	;$53
	dc.l	nu_VDI_sub	;$54
	dc.l	nu_VDI_sub	;$55
	dc.l	nu_VDI_sub	;$56
	dc.l	nu_VDI_sub	;$57
	dc.l	nu_VDI_sub	;$58
	dc.l	nu_VDI_sub	;$59
	dc.l	nu_VDI_sub	;$5a
	dc.l	nu_VDI_sub	;$5b
	dc.l	nu_VDI_sub	;$5c
	dc.l	nu_VDI_sub	;$5d
	dc.l	nu_VDI_sub	;$5e
	dc.l	nu_VDI_sub	;$5f
	dc.l	nu_VDI_sub	;$60
	dc.l	nu_VDI_sub	;$61
	dc.l	nu_VDI_sub	;$62
	dc.l	nu_VDI_sub	;$63
	dc.l	nu_v_opnvwk	;$64	v_opnvwk
	dc.l	nu_v_clsvwk	;$65	v_clsvwk
	dc.l	nu_VDI_sub	;$66
	dc.l	nu_VDI_sub	;$67
	dc.l	nu_VDI_sub	;$68
	dc.l	nu_VDI_sub	;$69
	dc.l	nu_VDI_sub	;$6a
	dc.l	nu_VDI_sub	;$6b
	dc.l	nu_VDI_sub	;$6c
	dc.l	nu_VDI_sub	;$6d
	dc.l	nu_VDI_sub	;$6e
	dc.l	nu_VDI_sub	;$6f
	dc.l	nu_VDI_sub	;$70
	dc.l	nu_VDI_sub	;$71
	dc.l	nu_VDI_sub	;$72
	dc.l	nu_VDI_sub	;$73
	dc.l	nu_VDI_sub	;$74
	dc.l	nu_VDI_sub	;$75
	dc.l	nu_VDI_sub	;$76
	dc.l	nu_vst_load_fonts	;$77	vst_load_fonts
	dc.l	nu_vst_unload_fonts	;$78	vst_unload_fonts
	dc.l	nu_VDI_sub	;$79
	dc.l	nu_VDI_sub	;$7a
	dc.l	nu_VDI_sub	;$7b
	dc.l	nu_VDI_sub	;$7c
	dc.l	nu_VDI_sub	;$7d
	dc.l	nu_VDI_sub	;$7e
	dc.l	nu_VDI_sub	;$7f
	dc.l	nu_VDI_sub	;$80
	dc.l	nu_VDI_sub	;$81
	dc.l	nu_VDI_sub	;$82
	dc.l	nu_VDI_sub	;$83
	dc.l	nu_VDI_sub	;$84
	dc.l	nu_VDI_sub	;$85
	dc.l	nu_VDI_sub	;$86
	dc.l	nu_VDI_sub	;$87
	dc.l	nu_VDI_sub	;$88
	dc.l	nu_VDI_sub	;$89
	dc.l	nu_VDI_sub	;$8a
	dc.l	nu_VDI_sub	;$8b
	dc.l	nu_VDI_sub	;$8c
	dc.l	nu_VDI_sub	;$8d
	dc.l	nu_VDI_sub	;$8e
	dc.l	nu_VDI_sub	;$8f
	dc.l	nu_VDI_sub	;$90
	dc.l	nu_VDI_sub	;$91
	dc.l	nu_VDI_sub	;$92
	dc.l	nu_VDI_sub	;$93
	dc.l	nu_VDI_sub	;$94
	dc.l	nu_VDI_sub	;$95
	dc.l	nu_VDI_sub	;$96
;
;------------------------------------
;
;----------------------------------------------------------------------------
	SECTION	BSS
;----------------------------------------------------------------------------
;
workstation_link_t:
	ds.l	workstation_max
;
virtual_struct_t:
	ds.b	virtual_max*16
;
load_fonts_result_t:
	ds.w	workstation_max
;
ext_vdipb_p:
	ds.l	1			;=4
loc_vdi_vdipb:
ext_vdi_control_p:
	ds.l	1			;=4
ext_vdi_intin_p:
	ds.l	1			;=4
ext_vdi_ptsin_p:
	ds.l	1			;=4
ext_vdi_intout_p:
	ds.l	2			;=8
proghead_buf:
	ds.l	7			;=28
font_root_p:
	ds.l	1			;=4
driver_basepage_p:
	ds.l	1
basepage_p:	ds.l	1
program_size:	ds.l	1
old_VDI_sub_p:	ds.l	1
new_load_f:	ds.b	1
		ds.b	1
last_device_index:
		ds.w	1
B_1E08:	ds.l	512			;=2048
B_2608:	ds.l	1			;=4
B_260C:	ds.l	1			;=4
B_2610:	ds.l	1			;=4
B_2614:	ds.w	1			;=2
B_2616:	ds.l	16			;=64
file_pos:	ds.w	1
filesize:	ds.l	1
filebase_p:	ds.l	1
B_2660:	ds.l	1			;=4
driver_stack_limit:
	ds.l	1
global_dta_p:	ds.l	1
local_dta:	ds.b	dta_size
device_struct_t_p:
	ds.l	1	;device_count 64_byte structures
font_p_t_p:
	ds.l	1	;device_count*max_font_count font pointers
B_26a0:	ds.w	1			;=2
max_font_count:	ds.w	1			;=2
device_count:	ds.w	1			;=2
filename_s:
	ds.b	14
stack_beg:
	ds.l	126			;=504
stack_end:
	ds.l	1			;=4
B_28B0:
	ds.l	2548			;=10192
;
;----------------------------------------------------------------------------
	End
;----------------------------------------------------------------------------
;End of file:	AMCGDOS.S
;----------------------------------------------------------------------------
