%include "INC:DICT.IMP"
%option  "-low-nocheck-nodiag-notrace-noline-nostack"
%begin
!DAK MSF clock board decoder server initialization
!DAK Copyright (C) David A Kerr & EUCSD 1985
!DAK preloads the background job to start server
!DAK the background job is 68000 assembler in ???:MSFSYS.ASM and .MOB

@16_00F80000 %byte MSFboard
@16_365E %half lend
@16_3750 %integer DTXAST,DTXA6,DTXMASK
%constant %string (25) sys file = "USEFUL:MSFSYS.MOB"
%constant %string (25) this file = "USEFUL:MSFGO"
%string (255) line
%integer end, start, i
  
%on %event 0 %start
  %if event_sub = 2 %or event_sub = 3 %start
    byteinteger(end-6+shortinteger(end-6))=16_FF
    %stop
  %finish
%finish

start = refname(sys file,fildict)
%if start > 0 %start
  !** background job object already preloaded
  end = integer(start+4)
  dtxa6 = 0
  dtxmask = 1
  dtxast = end-2 + shortinteger(end-2)
  !** ether board will now call background job if anything arrives of port 0
  printstring("MSF system installed".SNL)
  i = MSFboard
  !** event 0,2 {or 3?} generated if no MSF board present
%finish %else %start
  !** background job object not preloaded, preload then re-execute this
  line = "PRELOAD ".sys file.tostring(nl)." ".this file.tostring(nl)
  %for i=1,1,length(line) %cycle
    byte integer(lend+i-1)=charno(line,i)
  %repeat
  lend = lend + length(line)
%finish

%end %of %program
