!
!
! This True BASIC library file was generated automatically.
!

external

def InitCode(x0,x1)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call s_call(-72,3,s$)
   let InitCode = Unpackb(s$,1,-32)
end def

def InitStruct(x9,x10,x0)
   call Packb(s$,1,32*4,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call Packb(s$,97,32,x10)
   call s_call(-78,1537,s$)
   let InitStruct = Unpackb(s$,1,-32)
end def

def MakeLibrary(x8,x9,x10,x0,x1)
   call Packb(s$,1,32*6,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call Packb(s$,97,32,x8)
   call Packb(s$,129,32,x9)
   call Packb(s$,161,32,x10)
   call s_call(-84,1795,s$)
   let MakeLibrary = Unpackb(s$,1,-32)
end def

def MakeFunctions(x8,x9,x10)
   call Packb(s$,1,32*4,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call Packb(s$,97,32,x10)
   call s_call(-90,1792,s$)
   let MakeFunctions = Unpackb(s$,1,-32)
end def

def FindResident(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-96,512,s$)
   let FindResident = Unpackb(s$,1,-32)
end def

def InitResident(x9,x1)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x1)
   call Packb(s$,65,32,x9)
   call s_call(-102,514,s$)
   let InitResident = Unpackb(s$,1,-32)
end def

def Alert(x7,x13)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x7)
   call Packb(s$,65,32,x13)
   call s_call(-108,8320,s$)
   let Alert = Unpackb(s$,1,-32)
end def

def Debug
   call Packb(s$,1,32,12)
   call s_call(-114,0,s$)
   let Debug = Unpackb(s$,1,-32)
end def

def Disable
   call Packb(s$,1,32,12)
   call s_call(-120,0,s$)
   let Disable = Unpackb(s$,1,-32)
end def

def Enable
   call Packb(s$,1,32,12)
   call s_call(-126,0,s$)
   let Enable = Unpackb(s$,1,-32)
end def

def Forbid
   call Packb(s$,1,32,12)
   call s_call(-132,0,s$)
   let Forbid = Unpackb(s$,1,-32)
end def

def Permit
   call Packb(s$,1,32,12)
   call s_call(-138,0,s$)
   let Permit = Unpackb(s$,1,-32)
end def

def SetSR(x0,x1)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call s_call(-144,3,s$)
   let SetSR = Unpackb(s$,1,-32)
end def

def SuperState
   call Packb(s$,1,32,12)
   call s_call(-150,0,s$)
   let SuperState = Unpackb(s$,1,-32)
end def

def UserState(x0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call s_call(-156,1,s$)
   let UserState = Unpackb(s$,1,-32)
end def

def SetIntVector(x0,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-162,513,s$)
   let SetIntVector = Unpackb(s$,1,-32)
end def

def AddIntServer(x0,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-168,513,s$)
   let AddIntServer = Unpackb(s$,1,-32)
end def

def RemIntServer(x0,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-174,513,s$)
   let RemIntServer = Unpackb(s$,1,-32)
end def

def Cause(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-180,512,s$)
   let Cause = Unpackb(s$,1,-32)
end def

def Allocate(x8,x0)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x8)
   call s_call(-186,257,s$)
   let Allocate = Unpackb(s$,1,-32)
end def

def Deallocate(x8,x9,x0)
   call Packb(s$,1,32*4,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x8)
   call Packb(s$,97,32,x9)
   call s_call(-192,769,s$)
   let Deallocate = Unpackb(s$,1,-32)
end def

def AllocMem(x0,x1)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call s_call(-198,3,s$)
   let AllocMem = Unpackb(s$,1,-32)
end def

def AllocAbs(x0,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-204,513,s$)
   let AllocAbs = Unpackb(s$,1,-32)
end def

def FreeMem(x9,x0)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-210,513,s$)
   let FreeMem = Unpackb(s$,1,-32)
end def

def AvailMem(x1)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x1)
   call s_call(-216,2,s$)
   let AvailMem = Unpackb(s$,1,-32)
end def

def AllocEntry(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-222,256,s$)
   let AllocEntry = Unpackb(s$,1,-32)
end def

def FreeEntry(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-228,256,s$)
   let FreeEntry = Unpackb(s$,1,-32)
end def

def Insert(x8,x9,x10)
   call Packb(s$,1,32*4,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call Packb(s$,97,32,x10)
   call s_call(-234,1792,s$)
   let Insert = Unpackb(s$,1,-32)
end def

def AddHead(x8,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call s_call(-240,768,s$)
   let AddHead = Unpackb(s$,1,-32)
end def

def AddTail(x8,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call s_call(-246,768,s$)
   let AddTail = Unpackb(s$,1,-32)
end def

def Remove(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-252,512,s$)
   let Remove = Unpackb(s$,1,-32)
end def

def RemHead(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-258,256,s$)
   let RemHead = Unpackb(s$,1,-32)
end def

def RemTail(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-264,256,s$)
   let RemTail = Unpackb(s$,1,-32)
end def

def Enqueue(x8,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call s_call(-270,768,s$)
   let Enqueue = Unpackb(s$,1,-32)
end def

def FindName(x8,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call s_call(-276,768,s$)
   let FindName = Unpackb(s$,1,-32)
end def

def AddTask(x9,x10,x11)
   call Packb(s$,1,32*4,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call Packb(s$,65,32,x10)
   call Packb(s$,97,32,x11)
   call s_call(-282,3584,s$)
   let AddTask = Unpackb(s$,1,-32)
end def

def RemTask(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-288,512,s$)
   let RemTask = Unpackb(s$,1,-32)
end def

def FindTask(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-294,512,s$)
   let FindTask = Unpackb(s$,1,-32)
end def

def SetTaskPri(x9,x0)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-300,513,s$)
   let SetTaskPri = Unpackb(s$,1,-32)
end def

def SetSignal(x0,x1)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call s_call(-306,3,s$)
   let SetSignal = Unpackb(s$,1,-32)
end def

def SetExcept(x0,x1)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call s_call(-312,3,s$)
   let SetExcept = Unpackb(s$,1,-32)
end def

def Wait(x0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call s_call(-318,1,s$)
   let Wait = Unpackb(s$,1,-32)
end def

def Signal(x9,x0)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-324,513,s$)
   let Signal = Unpackb(s$,1,-32)
end def

def AllocSignal(x0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call s_call(-330,1,s$)
   let AllocSignal = Unpackb(s$,1,-32)
end def

def FreeSignal(x0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call s_call(-336,1,s$)
   let FreeSignal = Unpackb(s$,1,-32)
end def

def AllocTrap(x0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call s_call(-342,1,s$)
   let AllocTrap = Unpackb(s$,1,-32)
end def

def FreeTrap(x0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call s_call(-348,1,s$)
   let FreeTrap = Unpackb(s$,1,-32)
end def

def AddPort(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-354,512,s$)
   let AddPort = Unpackb(s$,1,-32)
end def

def RemPort(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-360,512,s$)
   let RemPort = Unpackb(s$,1,-32)
end def

def PutMsg(x8,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call s_call(-366,768,s$)
   let PutMsg = Unpackb(s$,1,-32)
end def

def GetMsg(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-372,256,s$)
   let GetMsg = Unpackb(s$,1,-32)
end def

def ReplyMsg(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-378,512,s$)
   let ReplyMsg = Unpackb(s$,1,-32)
end def

def WaitPort(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-384,256,s$)
   let WaitPort = Unpackb(s$,1,-32)
end def

def FindPort(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-390,512,s$)
   let FindPort = Unpackb(s$,1,-32)
end def

def AddLibrary(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-396,512,s$)
   let AddLibrary = Unpackb(s$,1,-32)
end def

def RemLibrary(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-402,512,s$)
   let RemLibrary = Unpackb(s$,1,-32)
end def

def OldOpenLibrary(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-408,512,s$)
   let OldOpenLibrary = Unpackb(s$,1,-32)
end def

def CloseLibrary(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-414,512,s$)
   let CloseLibrary = Unpackb(s$,1,-32)
end def

def SetFunction(x9,x8,x0)
   call Packb(s$,1,32*4,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x8)
   call Packb(s$,97,32,x9)
   call s_call(-420,769,s$)
   let SetFunction = Unpackb(s$,1,-32)
end def

def SumLibrary(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-426,512,s$)
   let SumLibrary = Unpackb(s$,1,-32)
end def

def AddDevice(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-432,512,s$)
   let AddDevice = Unpackb(s$,1,-32)
end def

def RemDevice(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-438,512,s$)
   let RemDevice = Unpackb(s$,1,-32)
end def

def OpenDevice(x8,x0,x9,x1)
   call Packb(s$,1,32*5,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x1)
   call Packb(s$,97,32,x8)
   call Packb(s$,129,32,x9)
   call s_call(-444,771,s$)
   let OpenDevice = Unpackb(s$,1,-32)
end def

def CloseDevice(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-450,512,s$)
   let CloseDevice = Unpackb(s$,1,-32)
end def

def DoIO(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-456,512,s$)
   let DoIO = Unpackb(s$,1,-32)
end def

def SendIO(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-462,512,s$)
   let SendIO = Unpackb(s$,1,-32)
end def

def CheckIO(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-468,512,s$)
   let CheckIO = Unpackb(s$,1,-32)
end def

def WaitIO(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-474,512,s$)
   let WaitIO = Unpackb(s$,1,-32)
end def

def AbortIO(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-480,512,s$)
   let AbortIO = Unpackb(s$,1,-32)
end def

def AddResource(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-486,512,s$)
   let AddResource = Unpackb(s$,1,-32)
end def

def RemResource(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-492,512,s$)
   let RemResource = Unpackb(s$,1,-32)
end def

def OpenResource(x9,x0)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-498,513,s$)
   let OpenResource = Unpackb(s$,1,-32)
end def

def GetCC
   call Packb(s$,1,32,12)
   call s_call(-528,0,s$)
   let GetCC = Unpackb(s$,1,-32)
end def

def TypeOfMem(x9)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x9)
   call s_call(-534,512,s$)
   let TypeOfMem = Unpackb(s$,1,-32)
end def

def Procure(x8,x9)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call Packb(s$,65,32,x9)
   call s_call(-540,768,s$)
   let Procure = Unpackb(s$,1,-32)
end def

def Vacate(x8)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x8)
   call s_call(-546,256,s$)
   let Vacate = Unpackb(s$,1,-32)
end def

def OpenLibrary(x9,x0)
   call Packb(s$,1,32*3,0)
   call Packb(s$,1,32,12)
   call Packb(s$,33,32,x0)
   call Packb(s$,65,32,x9)
   call s_call(-552,513,s$)
   let OpenLibrary = Unpackb(s$,1,-32)
end def

!
!
!    The following routines were hand-coded.  They represent the Exec
! Support Library, which is documented in an appendix to the ROM Kernal
! manual.
!

def NewList(mp)
   call pokel(mp,mp+4)
   call pokel(mp+4,0)
   call pokel(mp+8,mp)
end def

def BeginIO(ioReq)
   declare def peekl
   call packb(s$,1,32,ioReq)
   call packb(s$,33,32,peekl(ioReq+20))
   call s_call(-30,2^9+2^14,s$)
   let BeginIO = Unpackb(s$,1,-32)
end def

def CreatePort(name,pri)
   declare def AllocSignal, FreeSignal, AllocMem, FindTask, AddPort, NewList
   let sigBit = AllocSignal(-1)
   if sigBit = 0 then exit def
   let port = AllocMem(34,2^16+2^0) ! MEMF_CLEAR, MEMF_PUBLIC
   if port = 0 then
      let xxx = FreeSignal(sigBit)
      exit def
   end if
   call pokeb(port+8,4) ! ln_Type (NT_MSGPORT)
   call pokeb(port+9,pri) ! ln_Pri 
   call pokel(port+10,name) ! ln_Name
   call pokeb(port+15,sigBit) ! mp_SigBit
   call pokel(port+16,FindTask(0)) ! mp_SigTask
   if name <> 0 then 
      let xxx = AddPort(port)
   else
      let xxx = NewList(port+20) ! mp_MsgList
   end if
   let CreatePort = port
end def

def DeletePort(port)
   declare def peekl, upeekb, RemPort, FreeSignal, FreeMem
   if peekl(port+10) <> 0 then let xxx = RemPort(port)
   call pokeb(port+8,-1) ! ln_Type
   call pokel(port+20,-1) ! mp_MsgList
   let xxx = FreeSignal(upeekb(port+15))
   let xxx = FreeMem(port,34)
end def

def CreateStdIO(ioReplyPort)
   declare def AllocMem
   if ioReplyPort = 0 then exit def
   let ioReq = AllocMem(56,2^16+2^0) ! MEMF_CLEAR, MEMF_PUBLIC
   if ioReq = 0 then exit def
   call pokeb(ioReq+8,5) ! ln_Type (NT_MESSAGE)
   call pokel(ioReq+14,ioReplyPort) ! mn_ReplyPort
   let CreateStdIO = ioReq
end def

def DeleteStdIO(ioReq)
   declare def FreeMem
   call pokeb(ioReq+8,-1) ! ln_Type 
   call pokel(ioReq+20,0) ! io_Device
   call pokel(ioReq+24,0) ! io_Unit
   let xxx = FreeMem(ioReq,56)
end def

def CreateExtIO(ioReplyPort,size)
   declare def AllocMem
   if ioReplyPort = 0 then exit def
   let ioReq = AllocMem(size,2^16+2^0) ! MEMF_CLEAR, MEMF_PUBLIC
   if ioReq = 0 then exit def
   call pokeb(ioReq+8,5) ! ln_Type (NT_MESSAGE)
   call pokel(ioReq+14,ioReplyPort) ! mn_ReplyPort
   let CreateExtIO = ioReq
end def

def DeleteExtIO(ioReq,size)
   declare def FreeMem
   call pokeb(ioReq+8,-1) ! ln_Type 
   call pokel(ioReq+20,0) ! io_Device
   call pokel(ioReq+24,0) ! io_Unit
   let xxx = FreeMem(ioReq,size)
end def
