; DummyLevBasic.asm
; Copyright Xerox Corporation 1979, 1980, 1983
; Last modified July 1, 1983  1:46 PM by Boggs

; outgoing
.ent OsFinish, Junta
.bext SerialNumber, AltoVersion
.bext OsVersion, OsVersionCompatible
.bext lvUserFinishProc, OsFinishCode
.bext UserName, UserPassword, ErrorLogAddress
.bext lvBFN

; incoming
.bext bootLoaderPacket, mayDayPacket

lUserName = 10.
lUserPassword = 10.

	.srel

Junta:			.Junta
OsFinish:		.OsFinish
SerialNumber:		-1
AltoVersion:		0
OsVersion:		16.
OsVersionCompatible:	16.
lvUserFinishProc:	UserFinishProc
OsFinishCode:		0
lvBFN:			BFN
UserName:		.UserName
UserPassword:		.UserPassword
ErrorLogAddress:	.ErrorLogAddress

	.nrel

			lUserName
.UserName:		.blk lUserName
			lUserPassword
.UserPassword:		.blk lUserPassword
.ErrorLogAddress:	3*400+200	; net 3 host 200 (maxc)
			0		; well known event report
			30		; protocol socket
	

.Junta:	mkzero 3 3
	sta 3 @displayListHead	; turn off display
	lda 2 firstFrame	; reset stack to tippy top of memory
	sta 2 0 2		; link base frame to self
	mov 1 3			; after junta procedure
	jsr 0 3			; call it
	 0			; no parameters
	jsr @353		; finish if it returns

firstFrame:		176774
displayListHead:	420

.OsFinish: sta 0 @.OsFinishCode	; save finish code
osf1:	lda 3 UserFinishProc
	snz 3 3			; is there a user finish procedure?
	 jmp boot		; no
	lda 0 @.OsFinishCode	; yes. call it with the finish code as arg
	jsr 0 3
	 1
	jmp osf1		; check for more of them
boot:	dir			; There is no return from here
	lda 3 @lvMayDayPacket
	lda 0 BFN
	sta 0 5,3		; BFN goes in low half of Pup ID
	lda 0 @lvBootLoaderPacket
	inc 0 0			; compute page0Image-1
	lda 1 c400		; ending blt address
	lda 3 lblt
	blt			; move loader into page 0
	jmp 6			; dive into loader

UserFinishProc:		.blk 1
.OsFinishCode:		OsFinishCode
BFN:			10		; default is net exec
lvBootLoaderPacket:	bootLoaderPacket
lvMayDayPacket:		mayDayPacket
c400:			400
lblt:			-401+3

	.end