home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtosi.mac < prev    next >
Text File  |  2020-01-01  |  24KB  |  622 lines

  1.     .title    KRTOSI    One shot init
  2.     .ident    "V03.63"
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman  V03.63
  5. ;
  6. ;    fix test for running LTC to accomodate QED's fast PDP-11s
  7.  
  8. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  9. ;
  10. ;    check for indirect command file running program, for error handling
  11. ;    dump unused BUFDEF stuff
  12. ;    add Jim Whitlock's VBGEXE fetch pointer fixes
  13.  
  14. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  15. ;
  16. ;    "pic" code dumped
  17. ;    if TSX, line number saved in tsxsav during init, for t.ttxon
  18. ;    store clock rate (50/60 Hz) in clkflg, use elsewhere for timers
  19. ;    add init for TSX activation char list
  20. ;    call assdev when PRO-350 tries to automatically assign CL or XC
  21. ;    .SERR is set here and then left on forever..
  22. ;    VT200 now sets con8bit
  23. ;    cleaned up init code
  24. ;    increase ALSIZE to 1024. (user_defined modem and ph numb buffer)
  25. ;    under RT-11 display memory free for handlers at sign-on
  26.  
  27. ;    23-May-86  18:23:36 BDN    Creation.
  28. ;    07-Jun-86  05:39:17 BDN XM edits.
  29. ;
  30. ; /BBS/    20-Oct-91  Updated  this  narrative  to  reflect  mods made.
  31. ;    [Note in KRTTSX the mapped part of the root actually spans 3
  32. ;    pages (APR1 thru APR3), and was padded with command dispatch
  33. ;    tables and SL to the end of APR3 to allow the most efficient
  34. ;    allocation of the remaining memory..]
  35. ;
  36. ;     There are some significant assumptions made  here.  One for
  37. ;    the  virtual  (RT-11XM)  Kermit  (KRTTSX.SAV)  is  that APR7
  38. ;    (160000-177777) is available and does NOT contain  any  code
  39. ;    overlays,  because  in  the  XM  image  we  create a dynamic
  40. ;    region mapped from APR7 to allow placement  of  buffers  and
  41. ;    the like  up there.   In the case of the disk overlaid image
  42. ;    (KRT.SAV) we just  do  a  .SETTOP  to  177776  and  allocate
  43. ;    buffers there,  allowing the USR to swap if need be over the
  44. ;    buffers.  Additionally, the .FETCH buffer is, for  the  disk
  45. ;    overlaid   (non-virtual)   KRT.SAV,   allocated   from  this
  46. ;    .SETTOP area.  In  the  case  of  XM,  however,  we  have  a
  47. ;    problem.  In  order  to reduce the size of the ROOT to allow
  48. ;    Kermit to run as a foreground job we ended up  with  the top
  49. ;    of the  root mapped by APR1 (20000-37777).  Now it is a well
  50. ;    known fact that XM places many constraints on what  you  can
  51. ;    put in the range,  QUE elements being the best known example
  52. ;    of something you CAN NOT put there.  It also turns  out that
  53. ;    you  must NEVER try to load a handler into that area either.
  54. ;    If you do, depending on the address,  you  can  expect  very
  55. ;    erratic  behavior  from the handler, if not outright failure
  56. ;    and a system crash.  Such was the case on  the PRO/350.  The
  57. ;    XC  driver  would  MOST  of the time work ok, but the system
  58. ;    would ALWAYS crash on a .HRESET directive.  Additionally the
  59. ;    XC  OFFDRV  .SPFUN, while setting the "shutdown" flag in the
  60. ;    driver,   would  be  ignored  at  program  exit.   Thus   an
  61. ;    outstanding  XC  read  would attempt to enter a non-existent
  62. ;    completion routine when the remote server timed out (sending
  63. ;    a NAK packet that'd be read by XC), and hang the PRO.
  64. ;
  65. ;     The correct method to control this buffer (XM version only)
  66. ;    is to with the extend size for the psect HNBUFF at link time
  67. ;    using the /e:0000 option in KRTLNK.COM.
  68. ;
  69. ;     There are  a couple of things here for TSX+ also.  The TSX+
  70. ;    directive for  altering  the physical address space limit is
  71. ;    used,  which is simply an  EMT 375  with  R0  pointing to an
  72. ;    argument block of the form
  73. ;
  74. ;    .byte    0,141
  75. ;    .word    TOP_ADDRESS_DESIRED
  76. ;
  77. ;     This is done because, as in the case of  the  RSTS/E  RT-11
  78. ;    emulator,  the  .SETTOP  directive  only returns the current
  79. ;    high limit, it has no effect on the memory allocation.  Both
  80. ;    systems  thus  have special directives to actually alter the
  81. ;    memory size.  KRTXM.MAC also patches  location 56  so KRTTSX
  82. ;    will start on TSX+ systems with a default  memory allocation
  83. ;    less  than  64Kb.  The  TSX+  "Line Number"  is  checked  to
  84. ;    determine if the operating system is TSX+.  I have left that
  85. ;    in the init code as it works even in older versions of TSX+.
  86.  
  87.  
  88.     .include "IN:KRTMAC.MAC"
  89.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MAC failed>
  90.  
  91.     .sbttl    Macro references, various handy constants defined
  92.  
  93. ; /62/    .PEEK bypassed for V4, also expanded to allow assembly under same
  94. ; /62/    .CRAW,.CRRG,.RDBBK,.WDBBK expanded as well..
  95.  
  96.     .MCALL    .CSTAT    ,.DSTAT    ,.EXIT    ,.GTIM    ,.GTJB    ,.GVAL
  97.     .MCALL    .LOOKUP    ,.PURGE    .QSET    ,.RCTRLO,.SERR    ,.SETTOP
  98.  
  99.  
  100.     CNTXT    = 320        ; /62/ pointer to impure area of current job
  101.     CONFIG    = 300        ; RT-11 primary configuration word
  102.         SJSYS    = 1    ; clear if a SJ system
  103.         HERTZ50    = 40    ; /BBS/ 50Hz clock if set
  104.         XMSYS    = 10000    ; XM if set and SJSYS off
  105.     CONFG2    = 370        ; /62/ RT-11 configuration word 2
  106.         EIS$    = 400    ; /62/ extended instruction set is present
  107.     CURPRI    = -16.        ; /BBS/ offset to TSX current priority
  108.     STATWD    = 366        ; /62/ DCL indirect file status word
  109.         IFACTV    = 400    ; /62/ indirect file active bit
  110.     SYSGEN    = 372        ; /BBS/ sysgen features word
  111.         MARKTIM    = 2000    ; SJ timer support is present
  112.     SYSVER    = 276        ; the monitor version number
  113.     TOPMEM    = 50        ; location of address of top of memory
  114.     TS.VER    = -32.        ; /BBS/ offset to TSX version number
  115.     VRUN$    = 20000        ; /62/ VBGEXE bit in job state word
  116.  
  117.  
  118.     .sbttl    APR7 buffer allocation    ; /BBS/ moved here..
  119.  
  120. ;    ALSIZE is the SET DIAL,PHONE buffer length, and lives in KRTMAC.MAC
  121.     BINLSIZ    = 40*4            ; binary types list buffer size
  122. ;    $ALLSIZ is the packet buffer length, and lives in KRTMAC.MAC
  123.     MAXSIZ    ==   1000        ; individual file buffer size
  124.     $$BUFP    = <<MAXSIZ+2>*4>    ; 4 file buffers: in, out, log, take
  125.     $.1    = 82.+200+60        ; /62/ dirnam + dirbfr + phnum buffers
  126.     $.2    = <34*2*2>*2        ; totp.r and totp.s stats buffers
  127.     $.3    = <LN$MAX+2>*2        ; cmdbuf and argbuf allocations
  128.     $.4    = <<LN$MAX+2>*LN$CNT>    ; SL editor command line buffers
  129.  
  130.     TOTALL    == <ALSIZE+BINLSIZE+$ALLSIZ+$$BUFP+$.1+$.2+$.3+$.4>
  131.  
  132.     .if eq TOTALL-<<TOTALL/100>*100> ; 32-word boundary
  133.     ALLOC    == TOTALL        ; landed right on it
  134.     .iff
  135.     ALLOC    == <TOTALL&177700>+100    ; force to next 32-word boundary
  136.     .endc
  137.  
  138.  
  139.     .sbttl    Local data
  140.  
  141.     .psect    mapwin    ,rw,d,gbl,rel,con  ; ensure window data in ROOT
  142. apr7re:    ; /62/    .rdbbk    alloc/100    ; define symbols and reserve space
  143.     R.GID=:0            ; /62/ expanded to assemble under V4
  144.     R.GSIZ=:2.            ; /62/ even though it won't run there
  145.     R.GSTS=:4.
  146.     R.GNAM=:6.
  147.     R.GBAS=:10.
  148.     R.GLGH=:12.
  149.     RS.CRR=:^o100000
  150.     RS.UNM=:^o40000
  151.     RS.NAL=:^o20000
  152.     RS.NEW=:^o10000
  153.     RS.GBL=:^o4000
  154.     RS.CGR=:^o2000
  155.     RS.AGE=:^o1000
  156.     RS.EGR=:^o400
  157.     RS.EXI=:^o200
  158.     RS.CAC=:^o100
  159.     RS.BAS=:^o40
  160.     RS.NSM=:^o20
  161.     .WORD    0,alloc/100,0,0,0,0
  162. apr7wi:    ; /62/    .wdbbk    7,alloc/100,0,0,alloc/100,ws.map ; for memory region
  163.     W.NID=:0            ; /62/ expanded to assemble under V4
  164.     W.NAPR=:1            ; /62/ even though it won't run there
  165.     W.NBAS=:2.
  166.     W.NSIZ=:4.
  167.     W.NRID=:6.
  168.     W.NOFF=:^o10
  169.     W.NLEN=:^o12
  170.     W.NSTS=:^o14
  171.     W.NLGH=:^o16
  172.     WS.CRW=:^o100000
  173.     WS.UNM=:^o40000
  174.     WS.ELW=:^o20000
  175.     WS.MAP=:^o400
  176.     .BYTE    0,7
  177.     .WORD    0,alloc/100,0,0,alloc/100,ws.map
  178. mapwrk:    .word    0 ,0            ; mapping work buffer
  179.  
  180.     .psect    $rwdata    ,rw,d,lcl,rel,con
  181. chkbuf:    .word    0 ,0            ; /BBS/ check for running clock buff
  182. timbuf:    .word    0 ,0            ; roll the clock over buffer
  183. tsxmem:    .byte    0 ,141            ; TSX-Plus get more memory emt
  184.     .word    0            ; /BBS/ xinit puts size in here
  185.  
  186.     .psect    $pdata
  187. cl0asn:    .byte    0 ,155            ; try to assign
  188.     .word    0            ; CL0 to
  189.     .word    3            ; line 3
  190. cl1asn:    .byte    0 ,155            ; try to assign
  191.     .word    1            ; CL1 to
  192.     .word    3            ; line 3
  193. tsxjob:    .byte    0 ,144            ; /62/ TSX job status info emt args
  194. tsxj.l:    .byte    0 , 0            ; /62/ line_# ,subfunct (line status)
  195.     .word    chkbuf            ; /62/ borrow a buffer to return stats
  196. tsxlin:    .byte    0 ,110            ; TSX get line number emt
  197. tsxon:    .byte    0 ,152            ; /BBS/ TSX nowait TT input mode
  198.     .word    'U&137    ,0
  199. tsxsin:    .byte    0 ,152            ; /BBS/ TSX single char activation
  200.     .word    'S&137    ,0
  201. tsxtrm:    .byte    0 ,137            ; TSX get terminal type
  202. km.r50:    .rad50    "KM "            ; /62/ to test for KM
  203. pi.r50:    .rad50    "PI "            ; used to test for PRO hardware
  204. xc.r50:    .rad50    "XC "            ; device names for
  205. xl.r50:    .rad50    "XL "            ; testing for same
  206.  
  207. trmlst:    .byte    0.    ,1.    ,2.    ,3.    ,4. ; terminal types
  208.     .byte    5.    ,6.    ,7.    ,8.    ,9. ; data table
  209.     .byte    -1
  210.     .even
  211. trmtyp:    .word    NOSCOPE    ,TTY    ,VT100    ,TTY    ,TTY
  212.     .word    NOSCOPE    ,NOSCOPE,TTY    ,TTY    ,VT200
  213.  
  214. cl0text:.asciz    "CL0:"            ; asciz names
  215. cl1text:.asciz    "CL1:"            ; for TSX
  216. fatal:    .asciz    "?KRTOSI-F-"
  217. noxcmt:    .ascii    "This system lacks KM, XC and XL drivers.  "    ; /62/
  218.     .ascii    "TT must be used for transfers."<cr><lf>
  219.     .ascii    "Packet length has been set to 60. bytes "
  220.     .asciz    "to avoid overflowing the console port."<cr><lf>
  221. nolog:    .ascii    "Packet stats display disabled for FRUNed Kermit."<cr><lf>
  222.     .asciz    "Use SET UPDATE to enable stats during transfers."<cr><lf>
  223. osi.01:    .asciz    "RT-11SJ must be SYSGENNED with timer support"<cr><lf>
  224. osi.02:    .asciz    "Line Time Clock is not running"<cr><lf>
  225. osi.03:    .asciz    "CPU has no EIS support, rebuild KRT with KRTASM.NON"<cr><lf>
  226. osi.04:    .asciz    "HIMEM in TSGEN.MAC must be at least "
  227. osi.05:    .asciz    ". bytes"<cr><lf>
  228. osi.06:    .asciz    "CRRG/CRAW error #"
  229. osi.07:    .ascii    "Insufficient space available for buffer allocation"<cr><lf>
  230.     .asciz    "TOTALL = "
  231. osi.08:    .asciz    ",  MAXTOP-HILIMIT = "
  232. osi.09:    .ascii    "Program high limit exceeds top of memory"<cr><lf>
  233.     .asciz    "HILIMIT = "
  234. osi.10:    .asciz    ",  MAXTOP = "
  235. osi.11:    .asciz    <cr><lf>"You are "
  236. osi.12:    .asciz    " from happiness.."<cr><lf>
  237. osi.13:    .asciz    ". word"
  238. osi.14: .asciz    "s"            ; /63/ not 1, so make it plural
  239. osi.15:    .asciz    " free to load handlers"<cr><lf>
  240.     .even
  241.  
  242.  
  243.     .psect    $code
  244.     .sbttl    Init for RT-11/TSX-Plus
  245.  
  246. xinit::    .gtim    #rtwork    ,#timbuf    ; ensure clock rollover
  247.     mov    #60.    ,clkflg        ; /BBS/ preset clock rate at 60Hz
  248.     mov    #17.    ,break+2    ; /BBS/ assume 60Hz for break length
  249.     .gval    #rtwork    ,#config    ; get RMON configuration word into r0
  250.     bit    #hertz50,r0        ; /BBS/ is clock 50Hz?
  251.     beq    10$            ; /BBS/ nope..
  252.     mov    #50.    ,clkflg        ; /BBS/ ya, overwrite 60Hz default
  253.     mov    #14.    ,break+2    ; /BBS/ and fix break length for 50Hz
  254. 10$:    bit    #sjsys    ,r0        ; is this the SJ monitor?
  255.     bne    20$            ; it's FB or XM
  256.     dec    montyp            ; /BBS/ it's SJ, exec type saved
  257.     .gval    #rtwork    ,#sysgen    ; /BBS/ check for
  258.     bit    #marktime,r0        ; /BBS/ timer support
  259.     bne    30$            ; /BBS/ found it
  260.     wrtall    #fatal            ; /BBS/ fatal error message prefix
  261.     wrtall    #osi.01            ; /63/ "must SYSGEN w/timer support"
  262.     jmp    180$            ; go die..
  263.  
  264. 20$:    bit    #xmsys    ,r0        ; XM system?  r0=config_word
  265.     beq    30$            ; no, must be FB
  266.     inc    montyp            ; it's XM, save flag
  267.     mov    #$limit+2,hilimit    ; we really want VIRTUAL limit
  268.  
  269. 30$:    clr    r2            ; /63/ init a 64k pass loop counter
  270. 40$:    .gtim    #rtwork    ,#chkbuf    ; /BBS/ check to see if clock is on
  271.     cmp    chkbuf+2,timbuf+2    ; /63/ well?
  272.     bne    50$            ; /62/ there is a clock..
  273.     sob    r2    ,40$        ; /63/ not yet, try it again
  274.     wrtall    #fatal            ; /BBS/ no clock, Kermit must die
  275.     wrtall    #osi.02            ; /63/ "LTC is not running"
  276.     jmp    180$
  277.  
  278. 50$:    neg    r2            ; /63/ convert to # clock test loops
  279.     mov    r2    ,qedtst        ; /63/ save so count can be EXAMINEd
  280.     .if ndf    NONEIS            ; /62/ if KRT was built for an EIS CPU
  281.     .gval    #rtwork    ,#confg2    ; /62/ check to see
  282.     bit    #eis$    ,r0        ; /62/ if an EIS CPU is running this..
  283.     bne    60$            ; /62/ it is
  284.     wrtall    #fatal            ; /62/ no EIS present
  285.     wrtall    #osi.03            ; /63/ "CPU has no EIS support ..."
  286.     jmp    180$
  287.     .endc    ; ndf NONEIS
  288.  
  289. 60$:    .gtjb    #rtwork    ,#jobsts    ; so we know if BG or FG job
  290.     .gval    #rtwork    ,#statwd    ; /62/ DCL indirect file status word
  291.     bit    #ifactv    ,r0        ; /62/ indirect file running this pgm?
  292.     beq    70$            ; /62/ no
  293.     inc    jobtype            ; /62/ ya, flag it for error handling
  294. 70$:    .qset    #rtque    ,#nrtque    ; allocate extra queue elements
  295.  
  296. ; /62/    W A R N I N G:  the following 70. lines of code may seem somewhat
  297. ;    kludgey, however to get this all to run across all the various OS
  298. ;    versions and hardware and options and etc, this it it -
  299.  
  300.     .serr    ;; /BBS/ NOTE: .serr is set here and remains enabled forever..
  301.     mov    #totall    ,r2        ; /BBS/ need this much buffer space
  302.     .gval    #rtwork    ,#sysver    ; /62/ get monitor version number
  303.     movb    r0    ,rt11ver    ; /62/ save it here
  304.     swab    r0            ; /62/ now get the
  305.     movb    r0    ,rt11upd    ; /62/ release level
  306.     cmp    rt11ver    ,#5        ; /62/ what version is this?
  307.     blt    80$            ; /62/ VBGEXE doesn't exist before V5
  308.     .gval    #rtwork    ,#cntxt        ; /62/ get pointer to impure area
  309.     mov    r0    ,r1        ; /62/ save a copy of it
  310.     beq    80$            ; /62/ if cntxt=0, it's TSX
  311. ; /62/    .peek    #rtwork    ,r1        ; /62/ get job state word
  312.     MOV    #rtwork    ,R0        ; /62/ expanded for assy under V4
  313.     MOV    #28.*^o400+1.,@R0    ; /62/ even though V4 can't run it
  314.     MOV    r1    ,2.(R0)        ; /62/
  315.     EMT    ^o375            ; /62/
  316.     bit    #vrun$    ,r0        ; /62/ running under VBGEXE today?
  317.     beq    80$            ; /62/ nope..
  318.     mov    sp    ,vbgexe        ; /62/ ya
  319. 80$:    tst    imgtyp            ; /62/ is this virtual overlay image?
  320.     beq    90$            ; no
  321.     add    #160000    ,r2        ; top limit minimum for virtual memory
  322.     br    110$            ; skip low memory stuff
  323.  
  324. 90$:    tst    vbgexe            ; /62/ is VBGEXE running this program?
  325.     beq    100$            ; /62/ no
  326.     mov    #topmem    ,hilimit    ; /62/ ya use location 50 not $limit+2
  327. 100$:    add    @#topmem,r2        ; /BBS/ disk overlaid, add high limit
  328.     add    #4    ,r2        ; /BBS/ fudge factor for TSX
  329.  
  330. 110$:    mov    #tsxmem    ,r0        ; /BBS/ grab some extra TSX memory
  331.     mov    r2    ,2(r0)        ; /BBS/ pass size to tsxmem emt..
  332.     emt    375            ; call TSX now
  333.     bcs    120$            ; must be RT-11 today
  334.     cmp    r0    ,r2        ; TSX+, did it give us enough?
  335.     bhis    120$            ; yes, keep on going
  336.     wrtall    #fatal            ; /BBS/ no
  337.     wrtall    #osi.04            ; /63/ "HIMEM .. must be at least .."
  338.     mov    r2    ,r0        ; copy needed value for L10266
  339.     call    L10266            ; /BBS/ what it needs..
  340.     wrtall    #osi.05            ; /63/    ". bytes"<cr><lf>
  341.     jmp    180$            ; /BBS/ die
  342.  
  343. 120$:    mov    #freept    ,r2        ; setup pointer to start of free core
  344.     mov    #160000,@r2        ; /62/ assume /v ovrlys and force APR7
  345.     tst    imgtyp            ; /62/ is it really /v overlays today?
  346.     bne    130$            ; /62/ yes
  347.     mov    @hilimit,@r2        ; no, free core list for SJ/FB .fetch
  348. 130$:    add    #3    ,@r2        ; +2 to pointer above us please
  349.     bic    #1    ,@r2        ; whilst ensuring even address
  350.     tst    imgtyp            ; /62/ running the XM image?
  351.     beq    150$            ; /BBS/ no, use .settop for buffers
  352.  
  353.                     ; it's KRTTSX.SAV on RT-11XM or TSX+
  354. ; /62/    .crrg    #mapwrk    ,#apr7re    ; we will instead create a region
  355.     MOV    #mapwrk    ,R0        ; /62/ expanded to assemble under V4
  356.     MOV    #30.*^o400+0.,@R0    ; /62/ even though it can't run there
  357.     MOV    #apr7re    ,2.(R0)        ; /62/
  358.     EMT    ^o375            ; /62/
  359.     bcs    140$            ; didn't work..
  360.     mov    apr7re+r.gid,apr7wi+w.nrid  ; this will allow future expansion
  361. ; /62/    .craw    #mapwrk    ,#apr7wi    ; create address window and map it
  362.     MOV    #mapwrk    ,R0        ; /62/ expanded to assemble under V4
  363.     MOV    #30.*^o400+2.,@R0    ; /62/ even though it can't run there
  364.     MOV    #apr7wi    ,2.(R0)        ; /62/
  365.     EMT    ^o375            ; /62/
  366.     bcs    140$            ; if failed..
  367.     mov    #alloc+160000,maxtop    ; /BBS/ success, save copy of the top
  368.     jmp    A200$            ; continue
  369.  
  370. 140$:    movb    @#errbyt,r0        ; region failed, get the error code
  371.     wrtall    #fatal            ; fatal error message prefix
  372.     wrtall    #osi.06            ; /63/ "CRRG/CRAW error #"
  373.     call    L10266            ; /BBS/ dump error byte
  374.     .newline
  375.     br    180$            ; /BBS/ die on mapping failure
  376.  
  377. 150$:    .settop    #-2            ; SJ or FB, or TSX and disk overlays
  378.     mov    r0    ,maxtop        ; save the current max address
  379.     cmp    @r2    ,r0        ; is there REALLY space available?
  380.     bhi    160$            ; no, die
  381.     sub    @r2    ,r0        ; compute space available now
  382.     cmp    #totall    ,r0        ; space available for buffer pool?
  383.     blos    A200$            ; yes, it's ok
  384.  
  385.     wrtall    #fatal            ; /BBS/ added this..
  386.     wrtall    #osi.07            ; /63/ "Insufficient space ..TOTALL ="
  387.     octout    #totall            ; dump octal value to TT
  388.     wrtall    #osi.08            ; /63/ ",  MAXTOP-HILIMIT = "
  389.     octout    r0            ; dump octal value to TT
  390.     sub    #totall    ,r0        ; get diff for reporting
  391.     br    170$            ; and go display it
  392.  
  393. 160$:    wrtall    #fatal            ; /BBS/ added this too..
  394.     wrtall    #osi.09            ; /63/ "..high limit exceeds top.."
  395.     octout    @r2            ; dump octal value to TT
  396.     wrtall    #osi.10            ; /63/ ",  MAXTOP = "
  397.     octout    r0            ; r0 still contains maxtop here
  398.     sub    @r2    ,r0        ; get diff for reporting
  399.  
  400. 170$:    wrtall    #osi.11            ; /63/ <cr><lf>"You are "
  401.     neg    r0            ; fix sign, args were flipped
  402.     call    plural            ; display value and "word" or "words"
  403.     wrtall    #osi.12            ; /63/ " from happiness.."<cr><lf>
  404. 180$:    clr    r0            ; do a hard exit (includes .hreset)
  405.     .exit
  406.  
  407. plural:    asr    r0            ; /BBS/ display size in words
  408.     mov    r0    ,r1        ; copy to test for singular/plural
  409.     call    L10266            ; dump size to TT
  410.     wrtall    #osi.13            ; /63/ ". word"
  411.     dec    r1            ; just one word?
  412.     beq    190$            ; ya, don't make it plural
  413.     wrtall    #osi.14            ; /63/ no, add an "s"
  414. 190$:    return
  415.  
  416.  
  417.     .sbttl    Allocate and init buffers
  418.  
  419. ; /BBS/     NOTE:    if you add or change any buffer here you must also
  420. ;        conform the constants from which TOTALL is derived
  421. ;        at the top of this file
  422.  
  423. A200$:    mov    @r2    ,r0        ; /62/ save top to clear when done
  424.     mov    #2    ,r3        ; offset into buflst
  425.     mov    #4    ,r4        ; /62/ four buffers to set up
  426. 210$:    mov    @r2    ,buflst(r3)    ; setup our buffer addresses now
  427.     add    #maxsiz    ,@r2        ; fix freept up to point to next
  428.     add    #2    ,r3        ; point to next list entry
  429.     sob    r4    ,210$        ; /62/ simple
  430.     mov    @r2    ,xklgbuf    ; a special buffer for XC/XL/CL
  431.     add    #$allsiz,@r2        ; add in the allocation now
  432.     mov    @r2    ,albuff        ; allocate this buffer
  433.     add    #alsize    ,@r2        ; and move the pointer up
  434.     mov    @r2    ,dirnam        ; allocate more static buffers
  435.     add    #82.    ,@r2        ; /62/ allow for max .csispc can do
  436.     mov    @r2    ,dirbfr        ; allocate more dir listing buffers
  437.     add    #200    ,@r2        ; /62/ and move on up
  438.     mov    @r2    ,phnum        ; save a phonenumber for REDIAL
  439.     add    #60    ,@r2        ; allocate it
  440.     mov    @r2    ,bintyp        ; more to go
  441.     add    #binlsiz,@r2        ; binary file types list lives here
  442.     mov    @r2    ,totp.s        ; send packet stats
  443.     add    #34*2*2    ,@r2        ; 28. double precision numbers here
  444.     mov    @r2    ,totp.r        ; receive packet stats
  445.     add    #34*2*2    ,@r2        ; 28. double precision numbers here
  446.     mov    #ln$cnt    ,r3        ; recall buffer count
  447.     mov    #lastli    ,r4        ; where to stuff the addresses
  448. 220$:    mov    @r2    ,(r4)+        ; command line editing
  449.     add    #ln$max+2,@r2        ; move up
  450.     sob    r3    ,220$        ; keep going
  451.     mov    @r2    ,cmdbuf        ; insert command line buffer
  452.     add    #ln$max+2,@r2        ; /63/ next
  453.     mov    @r2    ,argbuf        ; argument buffer
  454.     add    #ln$max+2,@r2        ; /63/ next
  455.  
  456. 230$:    clr    (r0)+            ; /62/ clear out now
  457.     cmp    r0    ,@r2        ; done?
  458.     blos    230$            ; no
  459.  
  460.     mov    r2    ,fetpt        ; yes, setup pointers for .fetch now
  461.     mov    @hilimit,fetptmax    ; max address for .fetching
  462.     tst    vbgexe            ; /62/ is VBGEXE running this program?
  463.     bne    240$            ; /62/ ya
  464.     tst    montyp            ; if this is XM, then we must
  465.     ble    240$            ; force handlers into lowcore
  466.     mov    #xmflow    ,xmfetpt    ; ensure APR0 fetching
  467.     add    #3    ,xmfetpt    ; ensure
  468.     bic    #1    ,xmfetpt    ; .even
  469.     mov    #xmfetpt,fetpt        ; now insert address of pointer
  470.     mov    #xmftop    ,fetptmax    ; this is the top of XM .fetch space
  471.     .br    240$            ; /63/
  472.  
  473.  
  474.     .sbttl    Set/get terminal config..   ; /BBS/ moved here
  475.  
  476.     TTMODE    = 20 ! 100 ! 10000 ! 40000  ; nosl ,nowait ,spec ,lc
  477.     $TCFIG    = 424            ; offset to addr of term config word
  478.     $SCOPE    = 100000        ; and its SET TT SCOPE bit
  479.  
  480. 240$:    bis    #ttmode    ,@#jsw        ; this pgm runs in single char mode
  481.     .rctrlo                ; force read of new jsw..
  482.     mov    @#jsw    ,ttparm        ; save jsw
  483.     mov    sp    ,remote        ; /62/ assume remote mode
  484.  
  485.     .lookup    #rtwork,#lun.sr,#dkblk    ; get physical name of os's DK
  486.     bcs    250$            ; failed..
  487.     .cstat    #rtwork,#lun.sr,#cstat    ; get device data
  488.     bcs    250$            ; failed..
  489.     calls    rdtoa    ,<#dkname,cstat+12> ; device name
  490.     movb    cstat+10,r0        ; get unit number
  491.     add    #'0    ,r0        ; convert to ascii
  492.     movb    r0    ,dkname+2    ; stuff unit number into name
  493.     movb    #':    ,dkname+3    ; tag it with a colon
  494.     clrb    dkname+4        ; null terminate the string
  495. 250$:    .purge    #lun.sr            ; dump the channel to the device
  496.     strcpy    #defdir    ,#dkname    ; /62/ set default device name
  497.     mov    sp    ,tt$io        ; /62/ init with I/O through TT
  498. ;
  499. ; ---    use tried-and-true method to detect TSX+
  500. ;
  501.     mov    #tsxlin    ,r0        ; load TSX get line number emt arg
  502.     emt    375            ; try to get it
  503.     bcc    260$            ; /62/ got it
  504.     jmp    350$            ; /62/ if failed it's not TSX
  505. 260$:    mov    r0    ,tsxsav        ; /BBS/ stash TSX line number here
  506.  
  507.     movb    r0    ,tsxj.l        ; /62/ copy to check line status
  508.     mov    #tsxjob    ,r0        ; /62/ point to argument block
  509.     emt    375            ; /62/ inquire
  510.     bcs    270$            ; /62/ something failed..
  511.     bit    #2    ,chkbuf        ; /62/ is this a detached job?
  512.     beq    270$            ; /62/ no
  513.     mov    #-1    ,jobtyp        ; /62/ ya, flag it
  514.  
  515. 270$:    mov    #tsxon    ,r0        ; /BBS/ TSX nowait TT input mode
  516.     emt    375            ; /BBS/ enable it
  517.     mov    #tsxsin    ,r0        ; /BBS/ TSX single char activation
  518.     emt    375            ; /BBS/ enable this too..
  519.  
  520.     .gval    #rtwork    ,#-4        ; /BBS/ moved here, get TSX lead-in
  521.     cmpb    #35    ,r0        ; is it the default?
  522.     beq    290$            ; ya..
  523.     movb    r0    ,m.tsxr        ; no, set in
  524.     movb    r0    ,m.tsxs        ; place
  525.  
  526.     clr    r1            ; /BBS/ start at first one
  527.     mov    #11.    ,r2        ; /BBS/ 11. of 'em to do
  528. 280$:    movb    r0    ,limits(r1)    ; /BBS/ load lead-in char into init $
  529.     add    #3    ,r1        ; /BBS/ bump to next one
  530.     sob    r2    ,280$        ; /BBS/ and go do it
  531.  
  532. 290$:    wrtall    #m.tsxs            ; /BBS/ kill LF after CR under TSX
  533.     .gval    #rtwork    ,#ts.ver    ; /BBS/ get TSX version
  534.     bcs    300$            ; /BBS/ this doesn't work before V6.0
  535.     mov    r0    ,tsxver        ; /BBS/ save it
  536.  
  537. 300$:    .gval    #rtwork    ,#curpri    ; /BBS/ get current priority
  538.     mov    r0    ,defpri        ; /BBS/ save it
  539.     mov    r0    ,cl.pri        ; /BBS/ and init this
  540.  
  541.     mov    #tsxtrm    ,r0        ; now get terminal type
  542.     emt    375            ; do it
  543.     bcs    320$            ; oops
  544.     clr    r1            ; map terminal type now
  545. 310$:    inc    r1            ; next please
  546.     tstb    trmlst-1(r1)        ; end of the list yet?
  547.     bmi    320$            ; yes
  548.     cmpb    r0    ,trmlst-1(r1)    ; no, a match?
  549.     bne    310$            ; no, keep looking
  550.     asl    r1            ; /BBS/ word index here
  551.     mov    trmtyp-2(r1),vttype    ; save internal code for TT type
  552.     cmp    vttype    ,#vt200        ; /BBS/ is it an 8-bit terminal?
  553.     bne    320$            ; /BBS/ nope ..
  554.     mov    sp    ,con8bit    ; /BBS/ ya, do this for CONNECT
  555. 320$:    mov    tsxsav    ,r0        ; /BBS/ recover line number
  556.     dec    r0            ; which line (1=console) is this?
  557.     bne    340$            ; not console
  558.     .dstat    #rtwork    ,#pi.r50    ; console, see if this is a PRO
  559.     bcs    340$            ; can't be
  560.     mov    #cl0text,r1        ; for the strcpy
  561.     mov    #cl0asn    ,r0        ; try to assign
  562.     emt    375            ; line 3 to CL0
  563.     bcc    330$            ; success
  564.     mov    #cl1text,r1        ; for the strcpy
  565.     mov    #cl1asn    ,r0        ; CL0 is busy,
  566.     emt    375            ; try CL1
  567.     bcs    340$            ; CL0 and CL1 are busy (unlikely)
  568. 330$:    calls    assdev    ,<r1>        ; /BBS/ assign the device
  569.     tst    r0            ; /BBS/ ok?
  570.     bne    340$            ; /BBS/ no
  571.     clr    remote            ; say we are a local Kermit
  572.     strcpy    #ttname    ,r1        ; copy the CL name
  573.     mov    #3    ,cl$line    ; /BBS/ save line # for defterm
  574.     mov    sp    ,z.atch        ; /BBS/ flag assign done by Kermit
  575. 340$:    return                ; /62/
  576.  
  577. 350$:    .gval    #rtwork    ,#$tcfig    ; get term config word address
  578.     cmp    rt11ver    ,#5        ; /62/ is this RT-11 V5 or above?
  579.     bge    360$            ; /62/ ya, .peek will work
  580.     tst    montyp            ; /62/ if XM and V4..
  581.     bgt    380$            ; /62/ ..tough luck
  582.     mov    (r0)    ,r0        ; /62/ otherwise, this is it
  583.     br    370$
  584. 360$:    mov    r0    ,r1        ; save copy for peek
  585. ; /62/    .peek    #rtwork    ,r1        ; got to do it this way for XM!
  586.     MOV    #rtwork    ,R0        ; /62/ expanded for assy under V4
  587.     MOV    #28.*^o400+1.,@R0    ; /62/ even though V4 can't run it
  588.     MOV    r1    ,2.(R0)        ; /62/
  589.     EMT    ^o375            ; /62/
  590. 370$:    mov    r0    ,ttpar2        ; save it
  591.     bit    #$scope    ,r0        ; hard copy terminal?
  592.     beq    380$            ; ya
  593.     mov    #vt100    ,vttype        ; no, make it a VT-100
  594. 380$:    mov    #par$space,parity    ; /BBS/ force 8-bit quoting for RT-11
  595.     .dstat    #rtwork    ,#xc.r50    ; /39/ check for KM, XC or XL
  596.     bcc    390$            ; /39/ found it
  597.     .dstat    #rtwork    ,#xl.r50    ; /39/ no XC, try XL
  598.     bcc    390$            ; /39/ found it
  599.     .dstat    #rtwork    ,#km.r50    ; /62/ no XL, try KM
  600.     bcc    390$            ; /62/ found it
  601.     wrtall    #noxcmt            ; /39/ No, warn user of such fact
  602.     mov    #60.    ,senlen        ; /62/ console port won't XOFF fast
  603.     movb    #60.    ,senpar+p.spsiz    ; /62/ enough, do receive size too
  604.     clr    dolong            ; /BBS/ can't do long packets now..
  605.  
  606. 390$:    tst    jobsts            ; /54/ FRUNed?
  607.     beq    400$            ; /54/ no
  608.     clr    blip            ; /54/ yes, no packet status display
  609.     wrtall    #nolog            ; /54/ inform
  610.     br    410$            ; /BBS/ can't fetch from foreground
  611.  
  612. 400$:    tst    vbgexe            ; /62/ any hope getting a good number?
  613.     bne    410$            ; /62/ not if VBGEXE runs the program
  614.     mov    fetptmax,-(sp)        ; /BBS/ this is top of memory, which
  615.     sub    @fetpt    ,@sp        ; /BBS/ minus top of program + buffers
  616.     mov    (sp)+    ,r0        ; /BBS/ = what's left for handlers
  617.     call    plural            ; /BBS/ display it
  618.     wrtall    #osi.15            ; /63/ " free to load hand.."<cr><lf>
  619. 410$:    return
  620.  
  621.     .end
  622.