;----------------------------------------------------------------------------
;File name:	NEOLOAD.S			Revision date:	1995.09.27
;Disassembler:	Ulf Ronald Andersson		Disassembled:	1994.08.29
;----------------------------------------------------------------------------
;Remarks:
;
; 1:	As yet I have not made all references of this code fully symbolic,
;	so any changes must preserve all relative distances between all
;	reference points.
;
; 2:	The main errors found are in the XBRA-linked xgemdos routine, and
;	mainly affect the operation of AES function 'shel_find' .
;
; 3:	Most affected code portions may be found by seeking for occurences
;	of triple semicolons (';;;').
;----------------------------------------------------------------------------
;
	include	URAn_DOS.S
	include	URAn_XB.S
;
;----------------------------------------------------------------------------
;
	SECTION	text
;
;----------------------------------------------------------------------------
;
start:
	bra.s	start_1
;
;----------------------------------------------------------------------------
;
	dc.l	L019F
	dc.l	$00000400
	dc.w	0,0,0
;
;----------------------------------------------------------------------------
;	Pure C compiler text block signature:
;
;NB:	NeoLoad contains several bugs!!!
;	Bug patches may be inserted here by removing some of the text below
;	so changes do not affect any code offsets in the program.
;	Original text is 80 bytes (5 lines of 16 bytes each).
;
	dc.b	'>>>> PURE-C <<<<'
	dc.b	'  for ATARI-ST  '
	dc.b	'  Version  1.0  '
	dc.b	'(C)88-90 Borland'
	dc.b	' International  '
;
;----------------------------------------------------------------------------
;
L0000:
	dc.b	$00,$00
;
;
start_1:
	movea.l	a0,a3		;a3 = a0 -> basepage if running as ACC
	move.l	a3,d0
	bne.s	L0002
	movea.l	4(sp),a3	;a3 -> basepage of non_ACC
	moveq	#1,d0		;d0 = 1 for non_ACC
	bra.s	L0003
;
;
L0002:
	clr.w	d0		;d0 = 0 for ACC
L0003:
	move.l	a3,basepage_p
	move.w	d0,non_acc_f
	movea.l	bp_textlen(a3),a0
	adda.l	bp_datalen(a3),a0
	adda.l	bp_bss_len(a3),a0
	adda.w	#$100,a0
	move.l	a0,prog_size
	move.l	a3,d0
	add.l	a0,d0
	and.b	#-4,d0
	movea.l	d0,sp
	sub.l	#$300,d0
	move.l	d0,L019D	;NB: this label is never ref'd again ???
	tst.w	non_acc_f
	beq	L000D
	sub.l	#$fa,d0
	and.b	#-4,d0
	movea.l	d0,a1
	movea.l	a1,a4
	movea.l	44(a3),a2
	move.l	a2,(a1)+
L0004:
	tst.b	(a2)+
	bne.s	L0004
	move.l	a2,(a1)+
	tst.b	(a2)+
	bne.s	L0004
	clr.l	-(a1)
	gemdos	Mshrink,#0,(a3),a0
;
	lea	bp_arglen(a3),a0
	move.b	(a0),d1
	cmp.b	#$7e,d1			;ARGV ?
	bmi.s	L0006
	addq.l	#1,a0
	moveq	#-1,d1
L0005:
	addq.w	#1,d1
	move.b	(a0)+,d0
	bne.s	L0005
	lea	bp_arglen(a3),a0
L0006:
	move.w	#1,d3
	ext.w	d1
	lea	1(a0,d1.w),a1
	clr.b	(a1)
	clr.l	-(sp)
	bra.s	L000A
;
;
L0007:
	cmpi.b	#$21,(a1)
	bpl.s	L0008
	clr.b	(a1)
	tst.b	1(a1)
	beq.s	L0008
	pea	1(a1)
	addq.w	#1,d3
	bra.s	L000A
;
;
L0008:
	cmpi.b	#$22,(a1)
	bne.s	L000A
	move.b	#0,(a1)
L0009:
	subq.w	#1,a1
	cmpi.b	#$22,(a1)
	dbeq	d1,L0009
	subq.w	#1,d1
	bmi.s	L000B
	pea	1(a1)
	addq.w	#1,d3
	clr.b	(a1)
L000A:
	subq.l	#1,a1
	dbra	d1,L0007	;loop back for each arg char
L000B:
	tst.b	1(a1)
	beq.s	L000C
	pea	1(a1)
	addq.w	#1,d3
L000C:
	pea	L0000
	movea.l	sp,a2
L000D:
	jsr	L014C
	move.w	d3,d0
	movea.l	a2,a0
	movea.l	a4,a1
	jsr	main
	move.w	d0,-(sp)
	move.l	L0172,d0	;normally 0
	beq.s	L000E
	movea.l	d0,a0
	jsr	(a0)
L000E:
	move.l	L0173,d0	;normally 0
	beq.s	L000F
	movea.l	d0,a0
	jsr	(a0)
L000F:
	jsr	free_blocks
	gemdos	Pterm,()
;
;----------------------------------------------------------------------------
;
L0010:
	dc.b	$00,$00
L0011:
	dcb.w	2,0
L0012:
	dcb.w	2,0
;
;
L0013:
	movea.l	L0011(pc),a1
	move	a1,usp
	move.l	a0,L0012
	move.l	d0,-(sp)
	move.w	#$20,-(sp)	;super
	trap	#1
	pea	$100.w
	move.l	L0012(pc),-(sp)
	move.l	#$4a0000,-(sp)	;Mshrink
	trap	#1
	st	L0010
	bsr	appl_init_sub
	move.l	8(sp),d0
	move.l	d0,L01AD
	move.l	d0,prog_size
	bsr	L0131
	clr	-(sp)
	trap	#1		;gemdos	Pterm0
;
;----------------------------------------------------------------------------
;
	XB_define	nu_hdv_mediach,'NLdr'
	move.w	L017C(pc),d0
	cmp.w	4(sp),d0
	bne.s	.L0016
	moveq	#2,d0
	move.w	#-1,L017C
	rts
;
;
.L0016:
	movea.l	nu_hdv_mediach+xb_next(pc),a0
	jmp	(a0)
;
;----------------------------------------------------------------------------
;
	dc.b	'XBRA','NLdr'
nu_hdv_rw+xb_next:
	dcb.w	2,0
nu_hdv_rw+xb_code:
	move.w	L017C(pc),d0
	cmp.w	14(sp),d0
	bne.s	L0019
	moveq	#-$e,d0
	move.w	#-1,L017C
	rts
;
;
L0019:
	movea.l	nu_hdv_rw+xb_next(pc),a0
	jmp	(a0)
;
;----------------------------------------------------------------------------
;
L001A:
	lea	L0085(pc),a0
	st	(a0)
	st	3(a0)
	st	91(a0)
	st	95(a0)
	st	110(a0)
	st	114(a0)
	st	115(a0)
	rts
;
;
shel_write_d0_d1_d2_a0_a1:
	move.l	a2,-(sp)
	lea	aes_intin(pc),a2
	move.w	d0,(a2)+
	move.w	d1,(a2)+
	move.w	d2,(a2)
	lea	aes_addrin(pc),a2
	move.l	a0,(a2)+
	move.l	a1,(a2)
	movea.l	(sp)+,a2
	lea	aes_contrl(pc),a1
	move.l	#$790003,(a1)+	;AES shel_write
	move.l	#$10002,(a1)+
	clr.w	(a1)
	bra.s	aes_call
;
;
wrong_folder_al:
	lea	wrong_folder_al_s(pc),a0
	bra.s	L001E
;
;
	lea	wrong_version_al_s(pc),a0
	bra.s	L001E
;
;
sorry_no_run_al:
	lea	sorry_no_run_al_s(pc),a0
L001E:
	move.l	a0,aes_addrin
	lea	aes_contrl(pc),a0
	move.w	#$34,(a0)
	moveq	#1,d0
	move.w	d0,2(a0)
	move.w	d0,6(a0)
	move.w	d0,aes_intin
	bra.s	aes_call
;
;
L001F:
	move.w	aes_global(pc),d0
	cmpi.w	#$104,d0
	blo.s	L0020
	st	TOS_ge_104_f
	cmpi.w	#$200,d0
	blo.s	L0020
	move.w	#3,L0070
	cmpi.w	#$400,d0
	bcs.s	L0020
	bsr	L001A
	moveq	#0,d0
L0020:
	rts
;
;
appl_init_sub:
	move.w	#$a,aes_contrl
	move.w	#1,aes_contrl+2*2	;sintout
	bsr.s	aes_call
	move.w	d0,-(sp)
	bsr.s	L001F
	move.w	(sp)+,d0
	rts
;
;
aes_call:
	movem.l	a0-a2/d0-d2,-(sp)
	lea	aes_pb(pc),a0
	move.l	a0,d1
	move.w	#$c8,d0	;aes-aufruf
	trap	#2
	movem.l	(sp)+,a0-a2/d0-d2
	rts
;
;
L0023:
	lea	aes_contrl(pc),a0
	move.l	#$4f0000,(a0)+
	move.l	#$50000,(a0)+
	clr.w	(a0)
	bra.s	aes_call
;
;
link_vectors:
	move	usp,a0
	move.l	a0,L0011
	bsr	_a_init_safe
	bsr	L0027
	move.w	aes_global(pc),d0
	beq.s	L0026
	cmpi.w	#$3ff,d0
	bhi.s	.L0025
	subq.w	#2,sp
	bsr	parent_check
	tst.w	(sp)+
	beq.s	.L0025
	moveq	#0,d0
	rts
;
;
.L0025:
	bsr	link_xgemdos
	st	xgem_link_f
L0026:
	bsr	L002D
	moveq	#1,d0
	rts
;
;
L0027:
	movea.l	(_sysbase).w,a0
	move.l	os_selfbeg_p(a0),L00CE
	move.l	os_gem_mpb_p(a0),L00CF
	move.w	os_version(a0),d0
	cmpi.w	#$100,d0
	bls.s	.L0028
	move.l	os_currbp_p_p(a0),loc_curr_bp_p_p
	rts
;
.L0028:
	move.w	os_config(a0),d0
	lsr.w	#1,d0	; \/ NB: ERROR this test will always fail
	cmpi.w	#4,d0	; /\     old os_config only had 3 bits
	bne.s	.L0029
	move.l	#$873C,loc_curr_bp_p_p	;curr_bp_p_p of one TOS 1.0!
.L0029:
	rts
;
;
L002A:
	movem.l	a0/d0,-(sp)
	move.l	12(sp),d0
	clr.l	12(sp)
	movea.l	L00CE(pc),a0
	cmp.l	a0,d0
	blt.s	L002B
	cmp.l	L00CF(pc),d0
	bge.s	L002B
	st	15(sp)
L002B:
	movem.l	(sp)+,a0/d0
	rts
;
;
link_xgemdos:
	move.l	(ev_xgemdos).w,nu_xgemdos+8
	move.l	#nu_xgemdos+12,(ev_xgemdos).w
	rts
;
;
L002D:
	move.l	(ev_gemdos).w,nu_gemdos+8
	move.l	#nu_gemdos+12,(ev_gemdos).w
	move.w	$446.w,d0
	add.w	#$41,d0
	move.b	d0,L00BC
	movea.l	(ev_bios).w,a0
	cmpi.l	#-$415f4542,-4(a0)
	bne.s	L002F
	lea	6(a0),a0
	lea	L00C5(pc),a1
	moveq	#3,d0
L002E:
	cmpm.l	(a0)+,(a1)+
	bne.s	L002F
	dbra	d0,L002E
	move.l	136(a0),nu_bios+8
	move.l	#nu_bios+12,136(a0)
	rts
;
;
L002F:
	move.l	(ev_bios).w,nu_bios+8
	move.l	#nu_bios+12,(ev_bios).w
	rts
;
;
;----------------------------------------------------------------------------
;Start of:	BIOS functions with XBRA
;----------------------------------------------------------------------------
;
;
L0030:
	st	L01A6
	bra	go_old_bios
;
;
L0031:
	sf	L01A6
	bra	go_old_bios
;
;
L0032:
	move	usp,a0
L0033:
	cmpi.l	#$4d445741,(a0)		;'MDWA' ?
	beq.s	L0030
	cmpi.l	#$4d44474f,(a0)		;'MDGO' ?
	beq.s	L0031
	bra.s	go_old_bios
;
;
	XB_define	nu_bios,'NLdr'
	jmp	(L0037).l
nu_bios_link	= *-4
;
L0037:
	btst	#5,(sp)		;Super mode ?
	beq.s	L0032
	lea	6(sp),a0
	tst.w	(_longframe).w
	beq.s	L0038
	addq.w	#2,a0
L0038:
	cmpi.l	#$50101,(a0)	;Setexc(itv_critic,...) ?
	bne.s	L0033
	move.b	xgem_link_f(pc),d0
	beq.s	L003A
	move.l	#nu_xgemdos+12,(ev_xgemdos).w	;relink xgemdos
;;;BUG!!!	This is a ___GROSS___ violation of the XBRA protocol
	move.l	(etv_critic).w,d0
	move.l	4(a0),d1
	bmi.s	L0039
	move.l	d1,(etv_critic).w
L0039:
	rte
;
;
L003A:
	move.l	4(a0),d0
	bmi.s	go_old_bios
	move.l	d0,-(sp)
	bsr	L002A
	tst.l	(sp)+
	beq.s	go_old_bios
	st	xgem_link_f
	move.l	2(sp),bios_link_xgem_retadr
	move.l	#L003C,2(sp)
go_old_bios:
	movea.l	nu_bios+8(pc),a0
	jmp	(a0)
;
;
L003C:
	bsr	link_xgemdos
	movea.l	bios_link_xgem_retadr(pc),a0
	jmp	(a0)
;
;
;----------------------------------------------------------------------------
;End of:	BIOS functions with XBRA
;----------------------------------------------------------------------------
;Start of:	GEMDOS functions with XBRA
;----------------------------------------------------------------------------
;
;
	XB_define	nu_gemdos,'NLdr'
	cmpi.l	#$12345678,$380.w	;bombed ?
	bne	unbombed_gemdos
	clr.l	$380.w
	clr.l	L01AC
	movem.l	a4-a5/a0/d4-d5,-(sp)
	dc.w	$a00a
	moveq	#0,d0
	move.b	$3c4.w,d0
	move.w	d0,-(sp)
	cmp.b	#9,d0
	bgt.s	L003F
	subq.l	#2,d0
	bra.s	L0041
;
;
L003F:
	cmp.b	#$f,d0
	bne.s	L0040
	moveq	#9,d0
	bra.s	L0041
;
;
L0040:
	moveq	#8,d0
L0041:
	lea	L0175(pc),a0
	lsl.w	#2,d0
	move.l	0(a0,d0.w),-(sp)
	pea	L0174(pc)
	pea	L01A1(pc)
	jsr	L0100(pc)
	jsr	L012C(pc)
	move.w	#7,(sp)		;gemdos	Crawcin
	trap	#1
	lea	14(sp),sp
	bclr	#5,d0
	cmpi.b	#$52,d0
	bne	L0047
	pea	L0176(pc)
	jsr	L012C(pc)
	addq.w	#4,sp
	lea	$384.w,a4
	lea	$3a4.w,a5
	moveq	#7,d4
	moveq	#$30,d5
L0042:
	move.l	(a5)+,-(sp)
	move.w	d5,-(sp)
	move.l	(a4)+,-(sp)
	move.w	d5,-(sp)
	pea	L0177(pc)
	pea	L01A1(pc)
	jsr	L0100(pc)
	jsr	L012C(pc)
	lea	20(sp),sp
	addq.w	#1,d5
	dbra	d4,L0042
	move.l	$3d6.w,-(sp)
	moveq	#$f,d4
	move.w	#-$58e1,d5
	move.w	$3d4.w,d0
L0043:
	ror.w	#1,d0
	bcc.s	L0044
	move.w	#$31,-(sp)
	bra.s	L0045
;
;
L0044:
	move.w	#$30,-(sp)	;#'0'
L0045:
	ror.w	#1,d5
	bcs.s	L0046
	addq.w	#2,sp
L0046:
	dbra	d4,L0043
	move.w	$3d4.w,-(sp)
	move.w	$3d2.w,-(sp)
	move.l	$3c8.w,-(sp)
	move.l	$3c0.w,-(sp)
	pea	L0178(pc)
	pea	L01A1(pc)
	jsr	L0100(pc)
	jsr	L012C(pc)
	move.w	#7,(sp)		;gemdos	Crawcin
	trap	#1
	lea	44(sp),sp
L0047:
	movem.l	(sp)+,a4-a5/a0/d4-d5
unbombed_gemdos:
	movem.l	a0-a1/d0,L00CD
	move	usp,a0
	btst	#5,(sp)
	beq.s	L0049
	lea	6(sp),a0
	tst.w	(_longframe).w
	beq.s	L0049
	addq.w	#2,a0
L0049:
	move.w	(a0),d0
	beq.s	L004A
	sub.w	#$31,d0
	bcs.s	go_next_gemdos
	cmpi.w	#$1d,d0
	bhi.s	go_next_gemdos
	lea	L0053(pc),a1
	move.b	0(a1,d0.w),d0
	blt.s	go_next_gemdos
	lea	L0054(pc),a1
	move.w	0(a1,d0.w),d0
	jmp	gemdos_ref(pc,d0.w)
;
gemdos_ref:
;
nu_Pterm_any:
	clr.l	L01AC
	bsr	L005F
go_next_gemdos:
	movem.l	L00CD(pc),a0-a1/d0
	move.l	nu_gemdos+xb_next(pc),-(sp)
	rts
;
;
nu_Fsnext:
	tst.b	L00D9			;\ / Semaphore avoids
	beq.s	go_next_gemdos		; X  repeating
	clr.b	L00D9			;/ \ unique jobs
;
	move.l	2(a0),-(sp)		;push -> name with path
	bsr	find_pure_name		;modifies ptr on stack
	move	#Fsfirst&$ff,-(sp)	;push gemdos Fsfirst opcode
;
	tst.w	(_longframe).w		;\
	beq.s	L004C			; \
	move.w	-2(a0),-(sp)		;  \/ Push exception frame with
L004C:					;  /\ return address nu_post_Fsnext
	pea	nu_post_Fsnext(pc)	; /
	move	sr,-(sp)		;/
;
	bra.s	go_next_gemdos		;let next gemdos handle it
;
;
nu_Malloc:
	moveq	#-1,d0
	cmp.l	2(a0),d0
	beq.s	go_next_gemdos
	lea	nu_post_Malloc(pc),a1
	bra.s	L004D
;
;
nu_Mreleases:			;Mfree & Mshrink
	lea	nu_post_Mreleases(pc),a1
L004D:
	tst.b	L0181
	beq.s	go_next_gemdos
	move.l	2(sp),L0057
	move.l	a1,2(sp)
	movea.l	loc_curr_bp_p_p(pc),a1
	move.l	(a1),L0058
	move.l	#L01B3,(a1)
	move.l	2(a0),L0056
	bra.s	go_next_gemdos
;
;
nu_Fopen:
	tst.b	L00DA
	beq.s	go_next_gemdos
	clr.b	L00DA
	move.l	2(a0),-(sp)
	bsr.s	find_pure_name
	move.l	(sp)+,2(a0)
	bra	go_next_gemdos
;
;
nu_Pexec:
	tst.w	2(a0)
	bne	go_next_gemdos
	move.l	d2,-(sp)
	move.l	4(a0),-(sp)
	pea	L01A2(pc)
	bsr	strcpycnt_a0_a1
	addq.w	#8,sp
	move.l	12(a0),L00B7
	movea.l	L00B9(pc),a0
	cmpa.l	#L00B8,a0
	beq.s	L004E
	move.l	6(sp),-(a0)
	move.l	a0,L00B9
	move.l	#L0076,6(sp)
L004E:
	move.l	(sp)+,d2
	bra	go_next_gemdos
;
;
find_pure_name:
	move.l	a1,-(sp)
	move.l	a2,-(sp)
	movea.l	12(sp),a2
	movea.l	a2,a1		;a2 -> initial possible name start
.L0050:
	tst.b	(a1)
	beq.s	.L0051
	cmpi.b	#'\',(a1)+	;'\' ?  (means a2 was wrong)
	bne.s	.L0050
	movea.l	a1,a2		;a2 -> new possible name start
	bra.s	.L0050
;
;
.L0051:
	move.l	a2,12(sp)	;store -> name without path
	movea.l	(sp)+,a2
	movea.l	(sp)+,a1
	rts
;
;
nu_post_Fsnext:
	tst	d0
	seq	L00DA
	addq	#6,sp
	rte
;
;----------------------------------------------------------------------------
;
L0053:	;indexes used for the implemented patches, -1 means unimplemented
	dc.b	$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;Ptermres
	dc.b	$ff,$ff,$ff,$ff,$02,$ff,$ff,$ff	;Fopen
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$04	;Malloc
	dc.b	$06,$06,$08,$00,$ff,$0a		;Mfree,Mshrink,Pexec,Pterm,Fsnext
;
;index	$00	==	Ptermres, Pterm  (Pterm0 uses same code, but not via table)
;	$02	==	Fopen
;	$04	==	Malloc
;	$06	==	Mfree, Mshrink
;	$08	==	Pexec
;	$0a	==	Fsnext
;
;These indexes are used to find code offsets in table 'L0054' below
;----------------------------------------------------------------------------
;
L0054:	;code offsets for patches, indexed via table 'L0053' above
	dc.w	nu_Pterm_any-gemdos_ref	;ix $00 Ptermres, Pterm (Pterm0 via other means)
	dc.w	nu_Fopen-gemdos_ref	;ix $02 Fopen
	dc.w	nu_Malloc-gemdos_ref	;ix $04 Malloc
	dc.w	nu_Mreleases-gemdos_ref	;ix $06 Mfree, Mshrink
	dc.w	$009e	;ix $08 Pexec
	dc.w	nu_Fsnext-gemdos_ref	;ix $0a Fsnext
;
;These offsets are relative to 'gemdos_ref' further above
;----------------------------------------------------------------------------
;
L0055:
	dcb.w	6,0
L0056:
	dcb.w	2,0
L0057:
	dcb.w	2,0
L0058:
	dcb.w	2,0
;
;
nu_post_Malloc:
	tst.l	d0
	beq.s	nu_post_Mreleases
	movea.l	L01AF(pc),a0
	movea.l	(a0),a0
	adda.l	L01AE(pc),a0
	cmp.l	a0,d0
	bcs.s	nu_post_Mreleases
	movem.l	d1-d3,L0055
	movea.l	L01AE(pc),a0
	move.l	4(a0),d1
	cmp.l	d1,d0
	bcc.s	L005D
	move.l	d0,d1
	sub.l	L01AE(pc),d1
	add.l	L0056(pc),d1
	movea.l	L01AF(pc),a0
	move.l	d1,(a0)
	movea.l	d0,a0
	move.l	L0056(pc),d1
	moveq	#0,d3
	btst	#0,d0
	beq.s	L005A
	move.b	d3,(a0)+
	subq.l	#1,d1
L005A:
	move.w	d1,d2
	andi.w	#3,d2
L005B:
	subq.l	#4,d1
	blt.s	L005C
	move.l	d3,(a0)+
	bra.s	L005B
;
;
L005C:
	subq.w	#1,d2
	blt.s	L005D
	move.b	d3,(a0)+
	bra.s	L005C
;
;
L005D:
	movem.l	L0055(pc),d1-d3
nu_post_Mreleases:
	movea.l	loc_curr_bp_p_p(pc),a0
	move.l	L0058(pc),(a0)
	movea.l	L0057(pc),a0
	jmp	(a0)
;
;
L005F:
	movea.l	(ev_bios).w,a0
	cmpa.l	#L0037,a0
	beq.s	L0062
	move.l	a1,-(sp)
	lea	L00C6(pc),a1
	moveq	#3,d0
	addq.w	#4,a0
L0060:
	cmpm.l	(a0)+,(a1)+
	dbne	d0,L0060
	bne.s	L0061
	move.l	nu_bios+8(pc),nu_bios_link
	move.l	(ev_bios).w,nu_bios+8
	move.l	#L0037,(ev_bios).w
L0061:
	movea.l	(sp)+,a1
L0062:
	rts
;
;
L0063:
	move.w	4(sp),aes_intin
	move.l	6(sp),aes_addrin
	lea	aes_contrl(pc),a0
	move.l	#$4e0001,(a0)
	move.w	#1,6(a0)
	bsr	aes_call
	rts
;
;
L0064:
	move.w	#$101,d0
	bra.s	L0066
;
;
L0065:
	move.w	#$100,d0
L0066:
	pea	L00D4(pc)
	move.w	d0,-(sp)
	bsr.s	L0063
	addq.w	#6,sp
	rts
;
;
L0067:
	move.l	d7,-(sp)
	moveq	#0,d7
L0068:
	cmpi.w	#$a,d7
	bge.s	L0069
	bsr.s	L0065
	addq.w	#1,d7
	bra.s	L0068
;
;
L0069:
	movea.l	L00FE(pc),a0
	move.w	#1,-598(a0)
L006A:
	movea.l	L00FE(pc),a0
	move.w	-598(a0),d0
	beq.s	L006B
	bsr.s	L0064
	bra.s	L006A
;
;
L006B:
	move.l	(sp)+,d7
	rts
;
;
parent_check:
	move.w	d1,-(sp)
	clr.w	6(sp)			;pre_clear result flag
	movea.l	loc_curr_bp_p_p(pc),a0	;a0 -> -> current basepage
	movea.l	(a0),a0			;a0 -> current basepage
	movea.l	36(a0),a0		;a0 -> parents basepage
	move.l	a0,-(sp)		;push -> parents basepage
	beq.s	L006E			;go exit if NULL (no parent)
	move.w	L0070(pc),d1	;d1 = ???  (loop limit)
L006D:
	tst.l	(a0)		;does tested basepage have a parent ?
	movea.l	36(a0),a0	;a0 -> that parent or NULL
	dbeq	d1,L006D	;loop until NULL
	sne	10(sp)		;set result flag if not null
L006E:
	movea.l	(sp)+,a0	;a0 -> closest parent basepage  (NULL if none)
	move.w	(sp)+,d1	;restore entry d1  (-> aes_pb)
	rts
;
;
loc_curr_bp_p_p:
	dc.b	$00,$00,$60,$2c
L0070:
	dc.b	$00,$02
L0071:
	move.l	a0,-(sp)
	movea.l	L00B9(pc),a0
	move.l	(a0)+,8(sp)
	move.l	a0,L00B9
	movea.l	(sp)+,a0
	rts
;
;
L0072:
	dcb.w	2,0
L0073:
	cmpi.l	#L01A2,4(sp)
	bne.s	L0074
	lea	12(sp),sp
	bra.s	L0075
;
;
L0074:
	subq.w	#4,sp
L0075:
	move.l	a0,L0072
	movea.l	L00B9(pc),a0
	move.l	(a0)+,(sp)
	move.l	a0,L00B9
	movea.l	L0072(pc),a0
	clr.b	L01A2
	rts
;
;
L0076:
	tst.b	L00D6
	beq.s	L0073
	clr.b	L00D6
	tst.w	L00D0
	bne.s	L0077
	clr.w	-(sp)
	trap	#1	;gemdos Pterm0
;
;
L0077:
	bsr	L0067
	bsr	L0065
	pea	L00C2(pc)
	move.w	#9,-(sp)	;cconws
	trap	#1
	move.w	L00D1(pc),d0
	bne.s	L0078
	move.l	#L00C0,2(sp)
	trap	#1
	move.l	#L00C1,2(sp)
	trap	#1
	bra.s	L0079
;
;
L0078:
	lea	aes_intin(pc),a0
	move.l	a1,(sp)
	move.l	#$1000e,(a0)+
	move.l	#L017A,(a0)+
	clr.l	(a0)
	lea	aes_contrl(pc),a0
	move.l	#$690006,(a0)
	clr.w	6(a0)
	bsr	aes_call
	lea	L017A(pc),a1
	move.l	a1,aes_addrin
	lea	aes_intin(pc),a0
	moveq	#8,d0
	move.l	d0,(a0)+
	lea	16(a1),a1
	move.l	(a1)+,(a0)+
	move.l	(a1),(a0)
	lea	aes_contrl(pc),a0
	move.l	#$2a0006,(a0)
	move.w	#1,6(a0)
	bsr	aes_call
	bsr	L0064
	movea.l	(sp),a1
L0079:
	addq.w	#6,sp
	cmpi.l	#L01A2,4(sp)
	beq.s	L007A
	subq.w	#4,sp
	bra.s	L007B
;
;
L007A:
	lea	12(sp),sp
L007B:
	bsr	L0071
L007C:
	move.l	L00B7(pc),-(sp)
	pea	L00C4(pc)
	pea	L01A2(pc)
	move.l	#$4b0000,-(sp)
	addq.b	#1,L00D7
	trap	#1
	subq.b	#1,L00D7
	bne.s	L007D
	tst.b	TOS_ge_104_f
	bne.s	L007D
	tst.w	L00D2
	beq.s	L007E
L007D:
	rts
;
;
L007E:
	move.l	a0,-(sp)
	movea.l	L00D3(pc),a0
	tst.w	d0
	seq	1(a0)
	movea.l	(sp)+,a0
	rts
;
;
seek_env_var:
	bsr.s	L0084
	movea.l	bp_environ_p(a0),a0
L0080:
	movea.l	L00CA(pc),a1
	clr.b	d0
L0081:
	tst.b	(a0)
	bne.s	L0082
	addq.w	#1,a0
	tst.b	(a0)
	bne.s	L0080
	suba.l	a0,a0
	rts
;
;
L0082:
	cmpm.b	(a0)+,(a1)+
	beq.s	L0083
	addq.b	#1,d0
	bra.s	L0081
;
;
L0083:
	tst.b	d0
	bne.s	L0081
	tst.b	(a1)
	bne.s	L0081
	rts
;
;
L0084:
	movea.l	12(a1),a2
	move.w	#1,(a2)
	movea.l	16(a1),a2
	movea.l	loc_curr_bp_p_p(pc),a0
	movea.l	(a0),a0
	rts
;
;
;----------------------------------------------------------------------------
;
;
L0085:
;10
	dc.b	$00,$ff,$ff,$01,$ff,$ff,$ff,$ff	;appl_init..appl_find..
	dc.b	$ff,$ff,$ff,$ff,$ff,$02,$02,$02	;..evnt_mesag,evnt_timer,evnt_multi
;26
	dc.b	$ff,$ff,$ff,$ff,$0d,$ff,$ff,$ff	;...menu_icheck...
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
;42
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
;58
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
;74
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff	;...
;90
	dc.b	$03,$04,$ff,$ff,$ff,$ff,$ff,$ff	;fsel_input,fsel_exinput...
	dc.b	$ff,$ff,$ff,$05,$06,$06,$ff,$07	;..wind_open,wind_close,wind_delete..wind_set
;106
	dc.b	$ff,$ff,$ff,$ff,$08,$ff,$ff,$ff	;..rsrc_load..
	dc.b	$ff,$ff,$ff,$ff,$ff,$ff,$09,$0a	;..shel_read,shel_write
;122
	dc.b	$ff,$ff,$0b,$0c			;shel_find,shel_envrn
;
;
L0086:
	dc.w	nu_appl_init-aes_def,nu_appl_find-aes_def
	dc.w	$03dc,$0260			;evnt_xxx,	fsel_input
	dc.w	$026e,$0318			;fsel_exinput,	wind_open
	dc.w	$0330,$0302			;w_cls_del,	wind_set
	dc.w	nu_rsrc_load-aes_def,nu_shel_read-aes_def
	dc.w	nu_shel_write-aes_def,nu_shel_find-aes_def
	dc.w	nu_shel_envrn-aes_def,nu_menu_icheck-aes_def
;
;
;----------------------------------------------------------------------------
;	XBRA linked xgemdos functions
;
;NB 1:	The 'shel_find' function bugs out attempting to store intout using
;	D1 as ptr to 'aes_pb', when actually D1 at that time is garbage.
;	The entry value of D1 must somehow be preserved until it is needed.
;
;NB 2:	The main routine below was inefficient, and would slow down VDI by
;	pushing/pulling registers, needlessly since this code is for AES.
;
	XB_define	nu_xgemdos,'NLdr'
;
;;;	movem.l	d2/a0-a3,-(sp)	;\ / original code did not 
;;;	cmpi.w	#$c8,d0		; X  preserve d1, and used
;;;	bne.s	aes_def		;/ \ pushes for VDI as well
;
	cmpi.w	#$c8,d0			;;;\ / new code pushes only
	bne.s	go_next_xgemdos		;;; X  for AES, never for VDI
	movem.l	d1-d2/a0-a3,-(sp)	;;;/ \ and places D1 at (sp)
;
	movea.l	d1,a1		;a1 -> aes_pb
	movea.l	(a1),a2		;a2 -> contrl
	move.w	(a2),d2		;d2 = aes_opcode
	sub.w	#$a,d2
	bcs.s	aes_def
	cmpi.w	#$73,d2		;aes code > 125 ?   (NB: $73+$a == 125)
	bhi.s	aes_def
	lea	L0085(pc),a3
	move.b	0(a3,d2.w),d2
	blt.s	aes_def
	lea	L0086(pc),a3
	add.w	d2,d2
	move.w	0(a3,d2.w),d2
	jmp	aes_def(pc,d2.w)
;
;
aes_def:
;;;	movem.l	(sp)+,d2/a0-a3		;original could smash D1
	movem.l	(sp)+,d1-d2/a0-a3	;;;new code preserves D1
go_next_xgemdos:
	move.l	nu_xgemdos+8(pc),-(sp)
	rts
;
;
nu_appl_init:
	btst	#5,20(sp)
	bne.s	aes_def
	move	usp,a2
	move.l	22(sp),-(a2)
	move	a2,usp
	move.l	#L00A6,22(sp)
	bra.s	aes_def
;
;
nu_appl_find:
	lea	L01A2(pc),a2
	movea.l	a2,a0
L008B:
	tst.b	(a2)
	beq.s	L008C
	cmpi.b	#$5c,(a2)+
	bne.s	L008B
	movea.l	a2,a0
	bra.s	L008B
;
;
L008C:
	movea.l	16(a1),a2
	movea.l	(a2),a2
L008D:
	tst.b	(a0)
	beq.s	L008E
	cmpi.b	#$2e,(a0)
	beq.s	L008E
	cmpm.b	(a0)+,(a2)+
	beq.s	L008D
	bra.s	aes_def
;
;
L008E:
	tst.b	(a2)
	beq.s	L008F
	cmpi.b	#$20,(a2)
	bne.s	aes_def
L008F:
	movea.l	12(a1),a0
	clr.w	(a0)
	bra.s	go_exit_xgemdos_1
;
;
nu_shel_envrn:
	subq.w	#2,sp
	bsr	parent_check
	tst.w	(sp)+
	beq.s	aes_def
	bsr	L0084
	move.l	4(a2),L00CA
	bsr	seek_env_var
	movea.l	(a2),a1
	move.l	a0,(a1)
	bra.s	go_exit_xgemdos_1
;
;
nu_shel_read:
	subq.w	#2,sp
	bsr	parent_check
	tst.w	(sp)+
	beq	aes_def
	bsr	L0084
	movea.l	(a2),a1
	clr.b	(a1)
	pea	128(a0)
	move.l	4(a2),-(sp)
	bsr	strcpycnt_a0_a1
	move.l	#L01A2,4(sp)
	move.l	(a2),(sp)
	bsr	strcpycnt_a0_a1
	addq.w	#8,sp
go_exit_xgemdos_1:
;;;	movem.l	(sp)+,d2/a0-a3		;original could smash D1
	movem.l	(sp)+,d1-d2/a0-a3	;;;new code preserves D1
	rte
;
;
nu_shel_find:
	subq.w	#2,sp
	bsr	parent_check	;This code preserves D1 ok. Why not below as well ?
	tst.w	(sp)+
	beq	aes_def
;;;	move.l	d0,-(sp)	;Why save D0 (constant $C8) but not D1 (-> aes_pb)
;;;removing this push saves the 2 bytes needed to revive the constant later
	pea	L00CC(pc)
	move.w	#$2f,-(sp)	;fgetdta	NB: ERROR can destroy D1, needed later
	trap	#1
	move.l	d0,L00CB
	move.w	#$1a,(sp)	;fsetdta	NB: ERROR can destroy D1, needed later
	trap	#1
	addq.w	#6,sp
	move.l	#path_eq_s,L00CA
	bsr	seek_env_var	;This also preserves D1
	move.l	a0,d0
	bne.s	L0091
	lea	comma_root_s(pc),a0
L0091:
	lea	L00C4(pc),a1	;a1 -> temp string for individual paths
.L0092:
	tst.b	(a0)
	beq.s	.L0093
	cmpi.b	#',',(a0)
	beq.s	.L0093
	cmpi.b	#';',(a0)
	beq.s	.L0093
	move.b	(a0)+,(a1)+
	bra.s	.L0092
;
;
.L0093:
	cmpa.l	#L00C4,a1
	beq.s	.L0094
	cmpi.b	#'\',-1(a0)
	beq.s	.L0094
	move.b	#'\',(a1)+
.L0094:
	movea.l	(a2),a3
.L0095:
	move.b	(a3)+,(a1)+
	bne.s	.L0095
	move.l	a0,-(sp)
	gemdos	Fsfirst,L00C4(pc),#$27	;NB: ERROR, destroys D1, needed later
	movea.l	(sp)+,a0
	tst.w	d0
	beq.s	.L0096
	cmpi.w	#E_FILNF,d0		;file not found ?
	bne.s	.L0097
	tst.b	(a0)+
	bne.s	L0091
	bra.s	.L0097
;
;
.L0096:
	pea	L00C4(pc)
	move.l	(a2),-(sp)
	bsr	strcpycnt_a0_a1
	addq.w	#8,sp
	moveq	#1,d0
	bra.s	.L0098
;
;
.L0097:
	clr.w	d0
.L0098:
;;;	movea.l	d1,a1		;NB: ERROR, assumes D1 is intact (not true)
	movea.l	(sp),a1		;;;New code has -> aes_pb on stack
	movea.l	12(a1),a2	;a2 -> intout
	move.w	d0,(a2)		;intout[0]=result flag
	gemdos	Fsetdta|_ind,L00CB(pc)
;;;	move.l	(sp)+,d0	;this was a word constant $C8 on stack
	move	#$C8,d0		;this takes the same code space, but is faster
;this op uses 2 words, but there were 2 stack ops, so this evens out
	bra	go_exit_xgemdos_1
;
;
nu_shel_write:
	cmpi.w	#-1,L00B0
	beq	aes_def
	subq.w	#2,sp
	bsr	parent_check
	tst.w	(sp)+
	beq	aes_def
	moveq	#1,d2
	movea.l	12(a1),a0
	move.w	d2,(a0)
	move.l	a0,L00D3
	movea.l	8(a1),a0
	lea	L00D0(pc),a2
	move.l	(a0)+,(a2)+
	move.w	(a0),(a2)
	move.b	-3(a2),d2
	cmpi.b	#1,d2
	bhi	aes_def
	st	L00D6
	movea.l	16(a1),a0
	move.l	(a0)+,-(sp)
	pea	L01A2(pc)
	bsr	strcpycnt_a0_a1
	addq.l	#8,sp
	move.b	d2,L00C3
	bne.s	L009A
	clr.b	L00D6
go_exit_xgemdos_2:
;;;	movem.l	(sp)+,d2/a0-a3		;original could smash D1
	movem.l	(sp)+,d1-d2/a0-a3	;;;new code preserves D1
	rte
;
;
L009A:
	move.l	(a0),-(sp)
	pea	L00C4(pc)
	bsr	strcpycnt_a0_a1
	addq.l	#8,sp
	moveq	#5,d2
	move.l	d2,aes_intin
	lea	aes_contrl(pc),a0
	move.l	#$680002,(a0)+
	move.w	d2,(a0)+
	clr.w	(a0)
	bsr	aes_call
	lea	L017B(pc),a0
	move.l	aes_intout_1(pc),(a0)+
	move.l	aes_intout_3(pc),(a0)
	move.w	(a0),24(a0)
	movea.l	L00FE(pc),a1
	move.w	-46(a1),d2
	addq.w	#2,d2
	move.w	d2,26(a0)
;;;	movem.l	(sp)+,d2/a0-a3		;original could smash D1
	movem.l	(sp)+,d1-d2/a0-a3	;;;new code preserves D1
	tst.b	TOS_ge_104_f
	bne.s	L009B
	tst.w	L00D2
	beq.s	L009C
L009B:
	rte
;
;
L009C:
	move.w	(sp)+,d0
	move.l	(sp)+,L00C7
	tst.w	(_longframe).w
	beq.s	L009D
	addq.w	#2,sp
L009D:
	clr.b	L00D6
	move	d0,sr
	move.l	L00C7(pc),-(sp)
	bsr	L007C
	rts
;
;
L009E:
	dcb.w	2,0
L009F:
	dcb.w	2,0
	tst.l	L01B2
	beq	aes_def
	suba.l	a0,a0
	bra.s	L00A0
;
;
	tst.l	L01B2
	beq	aes_def
	movea.l	16(a1),a2
	movea.l	8(a2),a0
L00A0:
	move.l	a0,L009E
;;;	movem.l	(sp)+,d2/a0-a3		;original could smash D1
	movem.l	(sp)+,d1-d2/a0-a3	;;;new code preserves D1
	move.l	2(sp),L009F
	move.l	#L00A1,2(sp)
	rte
;
;
L00A1:
	movem.l	a0-a3/d0-d2,-(sp)
	movea.l	d1,a1
	movea.l	4(a1),a0
	move.w	4(a0),d0
	movea.l	12(a1),a3
	move.l	L009E(pc),-(sp)
	pea	2(a3)
	movea.l	16(a1),a2
	movea.l	4(a2),a1
	movea.l	(a2),a0
	movea.l	L01B2(pc),a2
	jsr	(a2)
	addq.w	#8,sp
	move.w	d0,(a3)
	movem.l	(sp)+,a0-a3/d0-d2
	move.l	L009F(pc),-(sp)
	rts
;
;
L00A2:
	move.w	4(a0),d2
	add.w	d2,d2
	add.w	d2,d2
	lea	L017E(pc),a1
	cmpi.w	#-1,6(a0)
	beq.s	L00A3
	move.w	6(a0),2(a1,d2.w)
L00A3:
	cmpi.w	#-1,8(a0)
	beq	aes_def
	move.w	8(a0),0(a1,d2.w)
	bra	aes_def
;
;
	movea.l	8(a1),a0
	cmpi.w	#$13,2(a0)
	beq.s	L00A2
	cmpi.w	#$a,2(a0)
	bne	aes_def
;;;	movem.l	(sp)+,d2/a0-a3		;original could smash D1
	movem.l	(sp)+,d1-d2/a0-a3	;;;new code preserves D1
	move.l	2(sp),L00C8
	move.l	#L00A8,2(sp)
	bra	go_next_xgemdos
;
;
	movea.l	8(a1),a0
	tst.w	(a0)
	bne	aes_def
	movea.l	12(a1),a0
	move.w	#1,(a0)
	bra	go_exit_xgemdos_2
;
;
nu_menu_icheck:
	movea.l	8(a1),a0
	tst.w	(a0)
	beq	aes_def
	movea.l	16(a1),a0
	movea.l	(a0),a0
	movea.l	L00FD(pc),a1
	move.w	-12(a1),d2
	move.w	d2,20(a0)
	move.w	d2,44(a0)
	bra	aes_def
;
;
nu_rsrc_load:
	tst.b	TOS_ge_104_f
	beq	aes_def
	movea.l	16(a1),a0
	movea.l	(a0),a0
	tst.b	(a0)
	beq	aes_def
	cmpi.b	#':',1(a0)
	beq	aes_def
L00A4:
	cmpi.b	#'\',(a0)
	beq	aes_def
	tst.b	(a0)+
	bne.s	L00A4
	st	L00D9
	bra	aes_def
;
;
L00A5:
	dcb.w	3,0
;
;
L00A6:
	move.l	a0,-(sp)
	move.w	d0,-(sp)
	movea.l	d1,a0
	movea.l	4(a0),a0
	move.w	(a0),d0
	beq.s	L00A7
	move.w	d0,aes_global
	bsr	L001F
	bcc.s	L00A7
	move.w	4(a0),d0
	subq.w	#2,d0
	bcs.s	L00A7
	cmpi.w	#5,d0
	bhi.s	L00A7
	lea	L00A5(pc),a0
	st	0(a0,d0.w)
L00A7:
	move.w	(sp)+,d0
	movea.l	(sp)+,a0
	rts
;
;
	movea.l	4(a1),a2
	move.w	4(a2),d2
	subq.w	#2,d2
	bcs	aes_def
	cmpi.w	#5,d2
	bhi	aes_def
	lea	L00A5(pc),a2
	sf	0(a2,d2.w)
	bra	aes_def
;
;
L00A8:
	tst.l	L01AC
	beq.s	L00A9
	movem.l	a0-a3/d0-d2,-(sp)
	movea.l	L01AC(pc),a0
	jsr	(a0)
	movem.l	(sp)+,a0-a3/d0-d2
L00A9:
	move.l	L00C8(pc),-(sp)
	rts
;
;
strcpycnt_a0_a1:
	movem.l	a0-a1,-(sp)
	movea.l	12(sp),a0
	movea.l	16(sp),a1
	moveq	#-1,d2
.L00AB:
	addq.w	#1,d2
	move.b	(a1)+,(a0)+
	bne.s	.L00AB
	movem.l	(sp)+,a0-a1
	rts
;
;
aes_pb:
	dc.l	aes_contrl
	dc.l	aes_global
	dc.l	aes_intin
	dc.l	aes_intout
	dc.l	aes_addrin
	dc.l	aes_addrout
;
;
aes_contrl:
	dcb.w	2,0
L00AE:
	dcb.w	3,0
aes_global:
	dc.b	$00,$00
L00B0:
	dcb.w	14,0
aes_intin:
	dcb.w	5,0
aes_intout:
	dc.b	$00,$00
aes_intout_1:
	dcb.w	2,0
aes_intout_3:
	dcb.w	2,0
aes_addrin:
	dcb.w	10,0
aes_addrout:
	dcb.w	10,0
L00B7:
	dcb.w	2,0
L00B8:
	dcb.w	10,0
L00B9:
	dc.l	L00B9
;
path_eq_s:
	dc.b	'PATH=',$00
comma_root_s:
	dc.b	',\,'
L00BC:
	dc.b	'A:\',NUL
;
sorry_no_run_al_s:
	dc.b	'[1]['
	dc.b	'Sorry, but you must run|'
	dc.b	'NEOLOAD.PRG at least once|'
	dc.b	'from either the built-in|'
	dc.b	'desktop or the AUTO folder]'
	dc.b	'[Abort]'
	dc.b	NUL
;
wrong_version_al_s:
	dc.b	'[1]['
	dc.b	'The NEOLOAD.PRG that is|'
	dc.b	'resident is not the same|'
	dc.b	'version as the one|'
	dc.b	'currently running]'
	dc.b	'[Abort]'
	dc.b	NUL
;
wrong_folder_al_s:
	dc.b	'[1]['
	dc.b	'NEODESK.EXE must be in the|'
	dc.b	'same folder as NEOLOAD.PRG|'
	dc.b	'in order to run NeoDesk]'
	dc.b	'[Abort]'
	dc.b	NUL
;
L00C0:
	dc.b	ESC,'E',NUL
L00C1:
	dc.b	ESC,'e',NUL
L00C2:
	dc.b	ESC,'f',NUL
L00C3:
	dc.b	NUL
L00C4:
	dc.b	$00,$00,$00,$00,$00,$00,$00,$00,$00
	dcb.w	66,0
L00C5:
	dc.b	$66,$00,$00,$94,$08,$17,$00,$05
	dc.b	$67,$08,$2f,$08,$41,$ef,$00,$0a
L00C6:
	dc.b	$4e,$68,$08,$17,$00,$05,$67,$04
	dc.b	$41,$ef,$00,$06,$4a,$29,$00,$05
	dcb.w	2,0
L00C7:
	dcb.w	2,0
L00C8:
	dcb.w	2,0
bios_link_xgem_retadr:
	dcb.w	2,0
L00CA:
	dc.l	0
L00CB:
	dcb.w	2,0
L00CC:
	dcb.w	22,0
L00CD:
	dcb.w	6,0
L00CE:
	dcb.w	2,0
L00CF:
	dcb.w	2,0
L00D0:
	dc.b	$00,$00
L00D1:
	dc.b	$00,$00
L00D2:
	dc.b	$00,$00
L00D3:
	dcb.w	2,0
L00D4:
	dc.b	$00,$00
xgem_link_f:
	dc.b	$00
L00D6:
	dc.b	$00
L00D7:
	dc.b	$00
TOS_ge_104_f:
	dc.b	$00
L00D9:
	dc.b	$00
L00DA:
	dc.b	$00,$00,$00,$00,$00
;
;
nu_iv_time_c_code:
	tas	L00F0
	bne	L00EA
	movem.l	sp/a5/a0-a2/d0-d2,L00EB
	lea	L01A0,sp
	tst.w	L01A4
	ble	L00E0
	tst.b	L017F
	bne	L00E0
	tst.w	L01A3
	bne.s	L00DC
	btst	#0,-$5ff.w
	bne.s	L00E0
	bra.s	L00DD
;
;
L00DC:
	suba.l	a5,a5
	movea.l	$50e.w,a0
	jsr	(a0)
	tst.w	d0
	beq.s	L00E0
L00DD:
	move	sr,d2
	ori.w	#$700,sr
	movea.l	L01A7(pc),a1
	movea.l	(a1),a2
	move.w	L01A3(pc),d0
	beq.s	L00DE
	move.w	d2,-(sp)
	move.b	(a2),d0
	ext.w	d0
	move.w	d0,-(sp)
	move.w	d0,-(sp)
	movea.l	$512.w,a0
	jsr	(a0)
	addq.w	#4,sp
	movea.l	L01A7(pc),a1
	move.w	(sp)+,d2
	bra.s	L00DF
;
;
L00DE:
	movea.w	#-$7800,a0
	move.b	#7,(a0)
	move.b	(a0),d0
	bset	#7,d0
	move.b	d0,2(a0)
	move.b	(a2),d0
	move.b	#$f,(a0)
	move.b	d0,2(a0)
	move.b	#$e,(a0)
	move.b	(a0),d0
	bclr	#5,d0
	move.b	d0,2(a0)
	move.b	(a0),d0
	bset	#5,d0
	move.b	d0,2(a0)
L00DF:
	addq.l	#1,(a1)
	subq.w	#1,L01A4
	move	d2,sr
L00E0:
	tst.b	L00F1
	beq.s	L00E3
	move.l	L01B1(pc),d0
	beq.s	L00E1
	movea.l	d0,a0
	moveq	#0,d0
	jsr	(a0)
	bra.s	L00E2
;
;
L00E1:
	lea	L01B0(pc),a0
	movea.w	#-$7dc0,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0),(a1)
	clr.b	-$7d82.w
L00E2:
	sf	L0180
	sf	L00F1
L00E3:
	movea.l	L00ED(pc),a0
	move.w	8(a0),d0
	cmp.w	L00EF(pc),d0
	beq.s	L00E7
	move.w	d0,L00EF
	addq.w	#1,d0
	cmp.w	4(a0),d0
	bcs.s	L00E4
	moveq	#1,d0
L00E4:
	movea.l	kbshift_p(pc),a1
	move.b	(a1),d1
	andi.b	#$f,d1
	cmpi.b	#$c,d1
	bne.s	L00E7
	movea.l	(a0),a0
	move.b	0(a0,d0.w),d0
	cmpi.b	#$61,d0
	bne.s	L00E6
	clr.l	$420.w
	clr.l	$43a.w
	clr.l	$426.w
L00E5:
	movea.l	(_sysbase).w,a0
	movea.l	16(a0),a0
	jmp	(a0)
;
;
L00E6:
	cmpi.b	#$53,d0
	beq.s	L00E5
L00E7:
	move.l	L01B1(pc),d0
	beq.s	L00E8
	movea.l	d0,a0
	jsr	(a0)
L00E8:
	lea	L00F2(pc),a0
	addq.b	#1,(a0)
	move.b	(a0),d0
	cmpi.b	#-$38,d0
	bne.s	L00E9
	addq.b	#1,L01A9
	clr.b	(a0)
L00E9:
	movem.l	L00EB(pc),sp/a5/a0-a2/d0-d2
	clr.b	L00F0
L00EA:
	move.l	old_iv_time_c_p(pc),-(sp)
	rts
;
;
L00EB:
	dcb.w	16,0
old_iv_time_c_p:
	dcb.w	2,0
L00ED:
	dcb.w	2,0
kbshift_p:
	dcb.w	2,0
L00EF:
	dc.b	$ff,$ff
L00F0:
	dc.b	$00
L00F1:
	dc.b	$00
L00F2:
	dc.b	$00,$00
;
;
	dc.b	'XBRA','NLdr'
L00F3:
	dcb.w	2,0
L00F4:
	clr.w	L017D
	tst.b	L0180
	bne.s	L00F6
L00F5:
	move.l	L00F3(pc),-(sp)
	rts
;
;
L00F6:
	st	L00F1
	bra.s	L00F5
;
;
L00F7:
	move.l	a0,L01AB
	move.l	(a0)+,L00FB
	move.l	(a0),L00FC
	move.l	a1,L00FA
	move.l	#L00F9,(a1)
	rts
;
;
L00F8:
	movea.l	L00FA(pc),a0
	clr.l	(a0)
	clr.l	L01AB
	rts
;
;
L00F9:
	lea	L00FB(pc),a0
	movea.l	L01AB(pc),a1
	movea.l	a1,a2
	cmpm.l	(a0)+,(a1)+
	bne.s	L00F8
	cmpm.l	(a0)+,(a1)+
	bne.s	L00F8
	jmp	(a2)
;
;
L00FA:
	dcb.w	2,0
L00FB:
	dcb.w	2,0
L00FC:
	dcb.w	2,0
L00FD:
	dcb.w	2,0
L00FE:
	dcb.w	6,0
;
;
_a_init_safe:
	movem.l	a0-a2/d0,-(sp)
	dc.w	$a000
	movem.l	a0-a2/d0,L00FD
	movem.l	(sp)+,a0-a2/d0
	rts
;
;
L0100:
	move.l	d2,-(sp)
	pea	16(sp)
	move.l	16(sp),-(sp)
	move.l	16(sp),-(sp)
	bsr	L0101
	lea	12(sp),sp
	move.l	(sp)+,d2
	rts
;
;
L0101:
	movem.l	a2-a6/d2-d7,-(sp)
	lea	-10(sp),sp
	movea.l	58(sp),a4
	movea.l	62(sp),a3
	movea.l	66(sp),a2
	bra	L011B
;
;
L0102:
	cmp.w	#$25,d3
	bne	L011A
	move.b	(a3)+,d3
	ext.w	d3
	cmp.w	#$2d,d3
	bne.s	L0103
	moveq	#1,d4
	bra.s	L0104
;
;
L0103:
	clr.w	d4
L0104:
	tst.b	d4
	beq.s	L0105
	move.b	(a3)+,d3
	ext.w	d3
L0105:
	cmp.w	#$30,d3
	bne.s	L0106
	moveq	#$30,d5
	move.b	(a3)+,d3
	ext.w	d3
	bra.s	L0107
;
;
L0106:
	moveq	#$20,d5
L0107:
	clr.w	d6
	moveq	#1,d7
	bra.s	L0109
;
;
L0108:
	moveq	#$a,d0
	muls	d6,d0
	add.w	d3,d0
	add.w	#-$30,d0
	move.w	d0,d6
	move.b	(a3)+,d3
	ext.w	d3
L0109:
	cmp.w	#$30,d3
	blt.s	L010A
	cmp.w	#$39,d3
	ble.s	L0108
L010A:
	cmp.w	#$6c,d3
	bne.s	L010B
	moveq	#1,d0
	bra.s	L010C
;
;
L010B:
	clr.w	d0
L010C:
	move.b	d0,8(sp)
	beq.s	L010D
	move.b	(a3)+,d3
	ext.w	d3
L010D:
	move.w	d3,d0
	moveq	#6,d1
	lea	L010F(pc),a0
L010E:
	cmp.w	(a0)+,d0
	dbeq	d1,L010E
	bne	L011A
	move.w	12(a0),d0
	jmp	L010F(pc,d0.w)
;
;
L010F:
	dc.b	$00,$44,$00,$58,$00,$63,$00,$64
	dc.b	$00,$6f,$00,$73,$00,$78,$00,$64
	dc.b	$00,$62,$00,$1c,$00,$68,$00,$68
	dc.b	$00,$26,$00,$5e
	move.b	1(a2),(a4)+
	addq.w	#2,a2
	bra	L011B
;
;
	movea.l	a2,a5
	movea.l	(a5)+,a6
	movea.l	a6,a0
	bsr	L0152
	sub.w	d0,d6
	tst.b	d4
	bne.s	L0112
	bra.s	L0111
;
;
L0110:
	move.b	d5,(a4)+
L0111:
	move.w	d6,d0
	subq.w	#1,d6
	tst.w	d0
	bgt.s	L0110
L0112:
	movea.l	a5,a2
	bra.s	L0114
;
;
L0113:
	move.b	(a6)+,(a4)+
L0114:
	move.b	(a6),d0
	bne.s	L0113
	tst.b	d4
	beq.s	L011B
	bra.s	L0116
;
;
L0115:
	move.b	d5,(a4)+
L0116:
	move.w	d6,d0
	subq.w	#1,d6
	tst.w	d0
	bgt.s	L0115
	bra.s	L011B
;
;
	clr.b	d7
	bra.s	L0117
;
;
	clr.b	d7
	addq.b	#1,8(sp)
L0117:
	move.b	8(sp),d0
	beq.s	L0118
	move.l	a2,(sp)
	movea.l	a2,a0
	addq.l	#4,(sp)
	move.l	(a0),4(sp)
	movea.l	(sp),a2
	bra.s	L0119
;
;
L0118:
	move.w	(a2)+,d0
	ext.l	d0
	move.l	d0,4(sp)
L0119:
	move.b	d4,d0
	ext.w	d0
	move.w	d0,-(sp)
	move.b	d5,d1
	ext.w	d1
	move.w	d1,-(sp)
	move.b	d7,d2
	ext.w	d2
	move.w	d2,-(sp)
	movea.l	a4,a0
	move.l	10(sp),d0
	move.w	d3,d1
	move.w	d6,d2
	bsr	L011C
	addq.w	#6,sp
	movea.l	a0,a4
	bra.s	L011B
;
;
L011A:
	move.b	d3,(a4)+
L011B:
	move.b	(a3)+,d3
	ext.w	d3
	bne	L0102
	clr.b	(a4)
	lea	10(sp),sp
	movem.l	(sp)+,a2-a6/d2-d7
	rts
;
;
L011C:
	movem.l	a3/d3-d7,-(sp)
	lea	-20(sp),sp
	movea.l	a0,a3
	move.l	d0,d5
	move.w	d1,d3
	move.w	d2,d7
	move.w	48(sp),d6
	sub.w	#$58,d1
	beq.s	L011E
	sub.w	#$17,d1
	beq.s	L011D
	sub.w	#9,d1
	beq.s	L011E
	bra.s	L011F
;
;
L011D:
	moveq	#8,d3
	bra.s	L0120
;
;
L011E:
	moveq	#$10,d3
	bra.s	L0120
;
;
L011F:
	moveq	#$a,d3
L0120:
	clr.w	d4
	tst.l	d5
	bne.s	L0121
	move.b	#$30,0(sp,d4.w)
	addq.w	#1,d4
	bra.s	L0125
;
;
L0121:
	tst.w	d6
	beq.s	L0122
	move.l	d5,d0
	and.l	#-$80000000,d0
	beq.s	L0122
	move.l	d5,d1
	neg.l	d1
	move.l	d1,d5
	bra.s	L0124
;
;
L0122:
	clr.w	d6
	bra.s	L0124
;
;
L0123:
	move.l	d5,d0
	move.w	d3,d1
	ext.l	d1
	bsr	L015F
	lea	L0191,a0
	move.b	0(a0,d0.w),0(sp,d4.w)
	addq.w	#1,d4
	move.l	d5,d0
	move.w	d3,d1
	ext.l	d1
	bsr	L015A
	move.l	d0,d5
L0124:
	tst.l	d5
	bne.s	L0123
	tst.w	d6
	beq.s	L0125
	move.b	#$2d,0(sp,d4.w)
	addq.w	#1,d4
L0125:
	sub.w	d4,d7
	move.w	52(sp),d0
	bne.s	L0129
	bra.s	L0127
;
;
L0126:
	move.b	51(sp),(a3)+
L0127:
	move.w	d7,d0
	subq.w	#1,d7
	tst.w	d0
	bgt.s	L0126
	bra.s	L012B
;
;
L0128:
	move.b	51(sp),0(sp,d4.w)
	addq.w	#1,d4
L0129:
	move.w	d7,d0
	subq.w	#1,d7
	tst.w	d0
	bgt.s	L0128
	bra.s	L012B
;
;
L012A:
	move.b	0(sp,d4.w),(a3)+
L012B:
	move.w	d4,d0
	subq.w	#1,d4
	tst.w	d0
	bne.s	L012A
	movea.l	a3,a0
	lea	20(sp),sp
	movem.l	(sp)+,a3/d3-d7
	rts
;
;
L012C:
	move.l	d2,-(sp)
	move.l	a2,-(sp)
	movea.l	12(sp),a2
	bra.s	L012E
;
;
L012D:
	move.b	(a2)+,d0
	ext.w	d0
	bsr	crawio_d0
L012E:
	move.b	(a2),d0
	bne.s	L012D
	movea.l	(sp)+,a2
	move.l	(sp)+,d2
	rts
;
;
ptermres_progsize_ok:
	clr.w	d1
	move.l	prog_size,d0
	bsr	ptermres_d0_d1
	rts
;
;
L0130:
	bsr	dgetdrv_sub
	movea.l	NLdr_cookie,a0
	movea.l	110(a0),a1
	move.b	d0,(a1)
	movea.l	NLdr_cookie,a0
	movea.l	110(a0),a0
	addq.w	#1,a0
	clr.w	d0
	bsr	dgetpath_ia0_d0
	lea	L0192,a1
	movea.l	NLdr_cookie,a0
	movea.l	110(a0),a0
	addq.w	#1,a0
	bsr	L014D
	rts
;
;
L0131:
	movem.l	a3/d3-d4,-(sp)
	lea	-14(sp),sp
	lea	L0185,a3
	lea	4(a3),a0
	lea	2(sp),a1
	moveq	#$b,d0
L0132:
	move.b	(a0)+,(a1)+
	dbra	d0,L0132
	move.w	L0010,d0
	bne.s	L0133
	move.w	aes_global,d1
	beq	L013B
L0133:
	cmpi.w	#$400,aes_global
	bge.s	L0138
	movea.l	L01A8,a0
	move.b	#1,(a0)
	clr.w	d3
	move.w	d3,d4
	bra.s	L0137
;
;
L0134:
	clr.w	d3
	move.w	d3,d0
	bra.s	L0136
;
;
L0135:
	movea.l	-4(a3),a0
	move.b	0(a0,d0.w),d1
	ext.w	d1
	add.w	d1,d3
	addq.w	#1,d0
L0136:
	cmp.w	#6,d0
	blt.s	L0135
	movea.l	-8(a3),a0
	movea.l	106(a0),a1
	add.w	(a1),d3
	pea	(sp)
	pea	4(sp)
	lea	8(sp),a1
	lea	8(sp),a0
	bsr	L0023
	addq.w	#8,sp
	tst.w	d3
	bne.s	L0137
	addq.w	#1,d4
L0137:
	cmp.w	#$14,d4
	blt.s	L0134
	tst.w	d3
	bne.s	L0134
	movea.l	L01A8,a0
	clr.b	(a0)
	bra.s	L0139
;
;
L0138:
	bsr	L001A
L0139:
	moveq	#-1,d0
	movea.l	(a3),a0
	move.b	d0,15(a0)
	movea.l	(a3),a0
	move.b	d0,14(a0)
	movea.l	(a3),a0
	move.b	d0,13(a0)
	movea.l	(a3),a0
	move.b	d0,(a0)
	movea.l	-8(a3),a0
	movea.l	110(a0),a1
	move.b	(a1),d0
	ext.w	d0
	bsr	dsetdrv_d0
	movea.l	-8(a3),a0
	movea.l	110(a0),a0
	addq.w	#1,a0
	bsr	dsetpath_ia0
	moveq	#$37,d0
	lea	2(sp),a0
	bsr	fsfirst_ia0_d0
	tst.w	d0
	beq.s	L013A
	bsr	wrong_folder_al
	bra.s	L013C
;
;
L013A:
	lea	L0193,a1
	lea	2(sp),a0
	moveq	#1,d2
	moveq	#1,d1
	moveq	#1,d0
	bsr	shel_write_d0_d1_d2_a0_a1	;call NeoDesk ???
	bra.s	L013C
;
;
L013B:
	pea	L0194
	bsr	L012C
	addq.w	#4,sp
L013C:
	movea.l	L01A8,a0
	clr.b	(a0)
	move.l	L01AD,d0
	cmp.l	prog_size,d0
	beq.s	L013D
	bsr	ptermres_progsize_ok
L013D:
	lea	14(sp),sp
	movem.l	(sp)+,a3/d3-d4
	rts
;
;----------------------------------------------------------------------------
;Start of:	'Main' routine
;----------------------------------------------------------------------------
;
main:
	movem.l	a2-a3/d3,-(sp)
	moveq	#-1,d0
	bsr	kbshift_d0
	moveq	#8,d1
	cmp.l	d0,d1		;'Alternate' key pressed ?
	beq	.exit_zero
	lea	prog_size,a2
	lea	NLdr_cookie,a3
	clr.l	-(sp)
	move.l	#'CJar',-(sp)
	clr.w	-(sp)
	move.w	#'CJ',-(sp)
	bsr	xbios_sub
	lea	12(sp),sp
	cmp.w	#'ar',d0
	beq.s	.L013F
	lea	You_must_run_Jarxxx_s,a0
	bsr	cconws_ia0
	bra	.get_key_exit_with_1
;
;
.L013F:
	move.l	(a2),L01AD
	moveq	#1,d0
	bsr	Iorec_d0
	move.l	a0,L00ED
	suba.l	a0,a0
	bsr	super_ia0
	move.l	d0,d3
	moveq	#os_version,d1
	add.l	(_sysbase).w,d1
	movea.l	d1,a0
	cmpi.w	#$100,(a0)	;TOS 1.00 ?
	ble.s	.L0140
	moveq	#os_kbshift_p,d2
	add.l	(_sysbase).w,d2
	movea.l	d2,a1
	move.l	(a1),d0		;d0 = kbshift_p -> kbshift byte
	bra.s	.L0141
;
;
.L0140:
	move.l	#$e1b,d0
.L0141:
	move.l	d0,kbshift_p
;
	pea	(a3)		;\
	move.l	#'NLdr',-(sp)	; \
	clr.w	-(sp)		;  \/ Seek 'NLdr'
	move.w	#'CJ',-(sp)	;  /\ cookie
	bsr	xbios_sub	; /
	lea	12(sp),sp	;/
;
	cmp.w	#'ar',d0
	beq	.L0144		;'NLdr' found, so skip linking
;
	pea	(a3)		;\
	move.l	#'NLdr',-(sp)	; \
	moveq	#1,d0		;  \
	move.w	d0,-(sp)	;   X Create 'NLdr' cookie
	move.w	#'CJ',-(sp)	;  /
	bsr	xbios_sub	; /
	lea	12(sp),sp	;/
;
	cmp.w	#'ar',d0
	beq.s	.L0143		;'NLdr' created, so link vectors etc...
	lea	cookie_jar_full_s,a0
	bsr	cconws_ia0
.get_key_exit_with_1:
	bsr	crawcin_sub
	moveq	#1,d0
	bra	.exit_d0
;
;
.L0143:
	movea.l	d3,a0
	bsr	super_ia0
	bsr	L0130
	bsr	appl_init_sub
	suba.l	a0,a0
	bsr	super_ia0
	move.l	d0,d3
	bsr	link_vectors
	tst.w	d0
	beq.s	.L0145
	clr.l	$380.w
	move.l	(hdv_mediach).w,nu_hdv_mediach+xb_next
	move.l	#nu_hdv_mediach+xb_code,(hdv_mediach).w
	move.l	(hdv_rw).w,nu_hdv_rw+xb_next
	move.l	#nu_hdv_rw+xb_code,(hdv_rw).w
	move.l	(iv_time_c).w,old_iv_time_c_p
	move.l	#nu_iv_time_c_code,(iv_time_c).w
	bsr	kbdvbase_sub
	move.l	32(a0),L00F3
	move.l	#L00F4,32(a0)
	movea.l	d3,a0
	bsr	super_ia0
	move.l	#L0181,L01A8
	movea.l	(a3),a0
	movea.l	74(a0),a1
	move.l	a2,(a1)
	movea.l	(a3),a0
	movea.l	70(a0),a1
	move.l	basepage_p,(a1)
	bsr	L0131
	bsr	ptermres_progsize_ok
.L0144:
	movea.l	(a3),a0
	cmpi.w	#$304,(a0)
	beq.s	.L0146
.L0145:
	movea.l	d3,a0
	bsr	super_ia0
	bsr	sorry_no_run_al
	bra.s	.exit_zero
;
;
.L0146:
	bsr	L0130
	movea.l	(a3),a0
	movea.l	70(a0),a1
	move.l	basepage_p,(a1)
	move.l	L01AD,d0
	cmp.l	(a2),d0
	bne.s	.L0147
;
	clr.l	-(sp)
	move.l	#'MiNT',-(sp)
	clr.w	-(sp)
	move.w	#'CJ',-(sp)
	bsr	xbios_sub
	lea	12(sp),sp
;
	cmp.w	#'ar',d0
	beq.s	.L0147
	move.l	d3,d0
	movea.l	basepage_p,a0
	movea.l	(a3),a1
	movea.l	86(a1),a1
	jsr	(a1)
.L0147:
	movea.l	d3,a0
	bsr	super_ia0
	bsr	appl_init_sub
	movea.l	(a3),a0
	move.l	58(a0),8(a3)
	movea.l	(a3),a0
	move.l	78(a0),4(a3)
	movea.l	(a3),a0
	move.l	66(a0),L01A8
	movea.l	74(a0),a1
	move.l	a2,(a1)
	bsr	L0131
.exit_zero:
	clr.w	d0
.exit_d0:
	movem.l	(sp)+,a2-a3/d3
	rts
;
;----------------------------------------------------------------------------
;End of:	'Main' routine
;----------------------------------------------------------------------------
;
L014A:
	lea	L014B(pc),a0
	moveq	#8,d0
	movea.l	d0,a1
	move.l	(a1),d0
	move.l	a0,(a1)
	clr.w	L0197
	lea	(sp),a0
	move.w	#3,-$5be.w
	move.w	#-$8000,L0197
	move.w	#-1,L0198
L014B:
	lea	(a0),sp
	move.l	d0,(a1)
	rts
;
;
L014C:
	move.l	a2,-(sp)
	xbios	Supexec,L014A(pc)
	movea.l	(sp)+,a2
	rts
;
;
L014D:
	move.l	a0,d0
L014E:
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	beq.s	L014F
	tst.b	(a0)+
	bne.s	L014E
L014F:
	subq.w	#1,a0
L0150:
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	beq.s	L0151
	move.b	(a1)+,(a0)+
	bne.s	L0150
L0151:
	movea.l	d0,a0
	rts
;
;
L0152:
	movea.l	a0,a1
L0153:
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	beq.s	L0154
	tst.b	(a0)+
	bne.s	L0153
L0154:
	move.l	a0,d0
	sub.l	a1,d0
	subq.l	#1,d0
	rts
;
;
free_blocks:
	move.l	a3,-(sp)
	movea.l	L0199,a3
L0156:
	move.l	a3,d0
	beq.s	L0157
	move.l	a3,-(sp)
	movea.l	(a3),a3
	move.w	#$49,-(sp)	;mfree
	trap	#1
	addq.w	#6,sp
	bra.s	L0156
;
;
L0157:
	movea.l	L019A,a3
L0158:
	move.l	a3,d0
	beq.s	L0159
	move.l	a3,-(sp)
	movea.l	(a3),a3
	move.w	#$49,-(sp)	;mfree
	trap	#1
	addq.w	#6,sp
	bra.s	L0158
;
;
L0159:
	movea.l	(sp)+,a3
	rts
;
;
L015A:
	move.l	d1,d2
	swap	d2
	tst.w	d2
	bne.s	L015C
	move.l	d0,d2
	swap	d2
	tst.w	d2
	bne.s	L015B
	divu	d1,d0
	swap	d0
	clr.w	d0
	swap	d0
	rts
;
;
L015B:
	clr.w	d0
	swap	d0
	swap	d2
	divu	d1,d0
	movea.w	d0,a0
	move.w	d2,d0
	divu	d1,d0
	swap	d0
	move.w	a0,d0
	swap	d0
	rts
;
;
L015C:
	movea.l	d1,a0
	swap	d0
	moveq	#0,d1
	move.w	d0,d1
	clr.w	d0
	moveq	#$f,d2
	add.l	d0,d0
	addx.l	d1,d1
L015D:
	sub.l	a0,d1
	bcc.s	L015E
	add.l	a0,d1
L015E:
	addx.l	d0,d0
	addx.l	d1,d1
	dbra	d2,L015D
	not.w	d0
	rts
;
;
L015F:
	move.l	d1,d2
	swap	d2
	tst.w	d2
	bne.s	L0161
	move.l	d0,d2
	swap	d2
	tst.w	d2
	bne.s	L0160
	divu	d1,d0
	clr.w	d0
	swap	d0
	rts
;
;
L0160:
	clr.w	d0
	swap	d0
	swap	d2
	divu	d1,d0
	move.w	d2,d0
	divu	d1,d0
	clr.w	d0
	swap	d0
	rts
;
;
L0161:
	movea.l	d1,a0
	move.l	d0,d1
	clr.w	d0
	swap	d0
	swap	d1
	clr.w	d1
	moveq	#$f,d2
	add.l	d1,d1
	addx.l	d0,d0
L0162:
	sub.l	a0,d0
	bcc.s	L0163
	add.l	a0,d0
L0163:
	addx.l	d1,d1
	addx.l	d0,d0
	dbra	d2,L0162
	roxr.l	#1,d0
	rts
;
;
xbios_sub:
	move.l	(sp)+,L01B4
	move.l	a2,L01B5
	trap	#$e
	movea.l	L01B5,a2
	movea.l	L01B4,a1
	jmp	(a1)
;
;
kbshift_d0:
	pea	(a2)
	bios	Kbshift,d0
	movea.l	(sp)+,a2
	rts
;
;
super_ia0:
	pea	(a2)
	gemdos	Super,(a0)
	movea.l	(sp)+,a2
	rts
;
;
ptermres_d0_d1:
	gemdos	Ptermres,d0,d1
;
;
dsetdrv_d0:
	pea	(a2)
	gemdos	Dsetdrv,d0
	movea.l	(sp)+,a2
	rts
;
;
dgetdrv_sub:
	pea	(a2)
	gemdos	Dgetdrv
	movea.l	(sp)+,a2
	rts
;
;
crawio_d0:
	pea	(a2)
	gemdos	Crawio,d0
	movea.l	(sp)+,a2
	rts
;
;
crawcin_sub:
	pea	(a2)
	gemdos	Crawcin
	movea.l	(sp)+,a2
	rts
;
;
fsfirst_ia0_d0:
	pea	(a2)
	gemdos	Fsfirst,(a0),d0
	movea.l	(sp)+,a2
	rts
;
;
dsetpath_ia0:
	pea	(a2)
	gemdos	Dsetpath,(a0)
	movea.l	(sp)+,a2
	rts
;
;
dgetpath_ia0_d0:
	pea	(a2)
	gemdos	Dgetpath,(a0),d0
	movea.l	(sp)+,a2
	rts
;
;
cconws_ia0:
	pea	(a2)
	gemdos	Cconws,(a0)
	movea.l	(sp)+,a2
	rts
;
;
kbdvbase_sub:
	pea	(a2)
	xbios	Kbdvbase
	movea.l	d0,a0
	movea.l	(sp)+,a2
	rts
;
;
Iorec_d0:
	pea	(a2)
	xbios	Iorec,d0
	movea.l	d0,a0
	movea.l	(sp)+,a2
	rts
;
;
;----------------------------------------------------------------------------
;
;
	SECTION	data
;
;
;----------------------------------------------------------------------------
;
;
	dc.b	$00,$00
L0172:
	dcb.w	2,0
L0173:
	dcb.w	2,0
L0174:
	dc.b	ESC,'f'
	dc.b	ESC,'b',$20+3,ESC,'c',$20+0
	dc.b	ESC,'H',BEL
	dc.b	'A%s error has occurred (%d bombs).',ESC,'K',CR,LF
	dc.b	'Press "R" for a list of the '
	dc.b	"system's Registers, or any key to exit.',ESC,'K',NUL
	even
L0175:
	dc.l	L0186
	dc.l	L0188
	dc.l	L0189
	dc.l	L018A
	dc.l	L018B
	dc.l	L018C
	dc.l	L018D
	dc.l	L018E
	dc.l	L018F
	dc.l	L0190
L0176:
	dc.b	CR,ESC,'J',CR,LF,NUL
L0177:
	dc.b	'    d%c: %08X   a%c: %08X',CR,LF,NUL
L0178:
	dc.b	CR,LF
	dc.b	'   ssp: %08X',CR,LF
	dc.b	'   usp: %08X',CR,LF
	dc.b	'instr.: %04x',CR,LF
	dc.b	'    sr: %04x = {t:%c  s:%c  interrupt:%c%c%c'
	dc.b	'  x:%c  n:%c  z:%c  v:%c  c:%c}',CR,LF
	dc.b	'    pc: %08X',NUL
	even
L0179:
	dc.l	L01A2
	dc.l	L0187
	dc.l	L0187
	dc.b	$00,$03,$00,$00,$00,$02,$11,$80
	dc.b	$00,$00,$ff,$ff,$00,$0c,$00,$01
L017A:
	dc.b	$ff,$ff,$00,$01,$00,$01,$00,$14
	dcb.w	3,0
	dc.b	$00,$43
L017B:
	dcb.w	5,0
	dc.b	$ff,$ff,$ff,$ff,$00,$16,$00,$20
	dc.b	$00,$00
	dc.l	L0179
	dcb.w	4,0
L017C:
	dc.b	$ff,$ff
L017D:
	dc.b	$00,$00
L017E:
	dcb.w	4,0
	dc.b	$11,$00,$11,$00,$11,$00,$11,$a1
	dc.b	$11,$00,$11,$00,$11,$80,$11,$80
	dcb.w	4,0
	dc.b	$11,$00,$11,$00,$11,$00,$11,$00
	dc.b	$11,$00,$11,$00,$11,$00,$11,$00
	dc.b	$11,$11,$11,$11,$11,$00,$11,$00
	dc.b	$11,$00,$11,$00,$11,$00,$11,$00
	dc.b	$11,$00,$11,$00,$11,$11,$11,$11
	dc.b	$11,$00,$11,$00
;
;
L017F:
	dc.b	$01
L0180:
	dc.b	$00
L0181:
	dc.b	$00
L0182:
	dc.b	$01
;
;
L0183:
	dc.b	$03,$04
	dc.l	L0101
	dc.l	L012C
	dc.l	L017C
	dc.l	L017F
	dc.l	L01A3
	dc.l	L01A7
	dc.l	L01A4
	dc.l	L017D
	dc.l	L0180
	dc.b	$00,$01,$00,$05
	dc.l	kbshift_p
	dc.l	L01B0
	dc.l	L01A9
	dc.l	L01AC
	dc.l	L0085
	dcb.w	2,0
	dc.l	L0181
	dc.l	L01AE
	dc.l	L01AF
	dc.l	L00A5
	dc.l	L01B1
	dc.l	L0013
	dc.l	L01B2
	dc.l	L01AB
	dc.l	L00F7
	dc.l	L00F8
	dc.l	L01A5
	dc.l	L01AA
	dc.l	L0182
	dc.l	L017E
;
NLdr_cookie:
	dc.l	L0183
	dc.l	L00A5
;
L0185:
	dc.l	L0085
	dc.b	'NEODESK.EXE',NUL
L0186:
	dc.b	' Bus'
L0187:
	dc.b	NUL
L0188:
	dc.b	'n Address',NUL
L0189:
	dc.b	'n Illegal Instruction',NUL
L018A:
	dc.b	' Divide by zero',NUL
L018B:
	dc.b	' CHK Instruction',NUL
L018C:
	dc.b	' TRAPV Instruction',NUL
L018D:
	dc.b	' Priviledge Violation',NUL
L018E:
	dc.b	' Trace',NUL
L018F:
	dc.b	' Reserved Vector',NUL
L0190:
	dc.b	'n Uninitialized Interrupt Vector',NUL
L0191:
	dc.b	'0123456789ABCDEF',NUL
L0192:
	dc.b	'\',NUL
L0193:
	dc.b	NUL,NUL
L0194:
	dc.b	CR,LF
	dc.b	'NeoDesk ¾ Loader v. 3.04 resident',CR,LF
	dc.b	NUL
You_must_run_Jarxxx_s:
	dc.b	ESC,'E',BEL
	dc.b	'You must run JARxxx before NEOLOAD',CR,LF
	dc.b	NUL
cookie_jar_full_s:
	dc.b	CR,LF,BEL
	dc.b	'No more room in Cookie Jar.',CR,LF
	dc.b	'Use a higher number in JARxxx.',CR,LF
	dc.b	NUL
	even
	dcb.w	10,0
L0197:
	dc.b	$00,$00
L0198:
	dc.b	$00,$00
L0199:
	dcb.w	2,0
L019A:
	dcb.w	2,0
;
;----------------------------------------------------------------------------
;
;
	SECTION	bss
;
;
;----------------------------------------------------------------------------
;
basepage_p:
	ds.l	1
non_acc_f:
	ds.w	1
L019D:
	ds.l	1
prog_size:
	ds.l	1
L019F:
	ds.b	224
L01A0:
	ds.b	1
L01A1:
	ds.b	200
L01A2:
	ds.b	121
L01A3:
	ds.w	1
L01A4:
	ds.w	1
L01A5:
	ds.b	1
L01A6:
	ds.b	1
L01A7:
	ds.l	1
L01A8:
	ds.l	1
L01A9:
	ds.b	1
L01AA:
	ds.b	81
L01AB:
	ds.b	8
L01AC:
	ds.l	1
L01AD:
	ds.l	1
L01AE:
	ds.l	1
L01AF:
	ds.l	1
L01B0:
	ds.b	32
L01B1:
	ds.l	1
L01B2:
	ds.l	1
L01B3:
	ds.b	256
L01B4:
	ds.l	1
L01B5:
	ds.b	1028
;
;----------------------------------------------------------------------------
	end
;----------------------------------------------------------------------------
;End of file:	NEOLOAD.S
;----------------------------------------------------------------------------
