;PROJECT: SONIX MUSIC SYSTEM
;FILE: BS.ASM

;COPYRIGHT 1986 BY MARK RILEY

;4/4/86: CREATED!

 INCLUDE "I:MACROS.ASM"
 INCLUDE "I:DOS.ASM"
 INCLUDE "I:DEVICES.ASM"
 INCLUDE "I:INTEQUATES.ASM"
 INCLUDE "I:SYSTEM.ASM"

STACKSIZE EQU $1000

;*** STARTUP-SEQUENCE BOOTSTRAP ***

MAIN
 MOVE.L #SXNAME,D1
 DOSLIB LOADSEG
 MOVE.L D0,SEGMENT
 BEQ ERROR

 MOVE.L #NONAME,D1
 MOVEQ #0,D2
 MOVE.L D0,D3
 MOVE.L #STACKSIZE,D4
 DOSLIB CREATEPROC
 TST.L D0
 BEQ ERROR

 SUB.L #PROC.MSGPORT,D0
 MOVE.L D0,A2

 MOVE.L #ROOTNAME,D1
 MOVE.L #SHARED_LOCK,D2
 DOSLIB LOCK
 MOVE.L #ARGLIST,A0
 MOVE.L D0,WA.LOCK(A0)
 BEQ ERROR

 INITPORT #REPLYPORT

 LEA PROC.MSGPORT(A2),A0
 MOVE.L #STARTUPMSG,A1
 MOVE.L #ARGLIST,SM.ARGLIST(A1)
 MOVE.B #NT_MESSAGE,MSG.NODE+NODE.TYPE(A1)
 MOVE.L #REPLYPORT,MSG.REPLYPORT(A1)
 SYSLIB PUTMSG

 MOVE.L #REPLYPORT,A0
 SYSLIB WAITPORT
 MOVE.L #REPLYPORT,A0
 SYSLIB GETMSG

 QUITPORT #REPLYPORT

 CLR.L D0

QUIT
 RTS

ERROR
 MOVE.L SEGMENT,D1
 BEQ.S 1$
 DOSLIB UNLOADSEG

1$
 MOVEQ #21,D0
 BRA.S QUIT

;*** DATA AREA ***

SEGMENT DC.L 0
STARTUPMSG DCB.B SIZE.SM,0
ARGLIST DCB.B SIZE.WA,0
REPLYPORT DCB.B SIZE.MP,0
ROOTNAME DC.B ':',0
SXNAME DC.B 'Sonix'
NONAME DC.B 0
 FIXPC

 END

