home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bbs / emx-util.lbr / SYSOP.MZC / SYSOP.MAC
Encoding:
Text File  |  1988-01-30  |  7.9 KB  |  454 lines

  1. ;
  2. ; v1.15
  3. ;
  4. ; Sends to a disk file any comments as entered by a remote user. Limited
  5. ; editing.  For use with EMX313.MAC
  6. ;
  7. ; (c)1984 Simon J. Ewins
  8. ;
  9.     .Z80
  10.     ASEG
  11.     ORG    100H
  12. ;
  13.     JP    START
  14. ;
  15. VER::    DB    1
  16. VERR::    DB    15
  17. ;
  18.     INCLUDE    EMXHDR.MAC
  19.     INCLUDE    GETTIM.MAC
  20. ;
  21. DSKFIL::DB    'SYSOP.EMX',0,0,0,0
  22. ;
  23. ; Special open file whose name pointed to by HL register
  24. ;
  25. SPOPEN::PUSH    IY
  26.     PUSH    IX
  27.     CALL    BFCB        ; HL->filename
  28.     LD    DE,FCB        ; Point to file name
  29.     LD    C,15        ; Open function
  30.     CALL    BDOS        ; Do it
  31.     POP    IX
  32.     POP    IY
  33.     CP    0FFH        ; Errors?
  34.     RET    NZ        ; Nope....
  35. ;                ; yep, so....... create file
  36.     PUSH    IY
  37.     PUSH    IX
  38.     LD    DE,FCB        ; Point to file name
  39.     LD    C,22
  40.     CALL    BDOS        ; Make new file
  41.     POP    IX
  42.     POP    IY
  43.     CP    0FFH        ; Errors?
  44.     JR    NZ,INIT        ; Nope....
  45.     CALL    PRINT
  46.     DB    CR,LF,LF
  47.     DB    '++ FATAL ERROR IN CREATING NEW FILE ++'
  48.     DB    CR,LF,LF,0
  49.     JP    EXIT
  50. ;.....
  51. ;
  52. INIT::
  53. ;
  54. INIFLG    EQU    $+1
  55. ;
  56.     LD    A,0        ; In-code modification
  57.     OR    A
  58.     RET    Z        ; If still 0 then not SYSOP.EMX open call
  59.     LD    HL,1        ; Set next record to write
  60.     LD    (RNDBUF),HL    ; Into random buffer
  61.     LD    HL,64        ; Size of record(s)
  62.     LD    (RRSZ),HL    ; Set in place
  63.     LD    HL,0        ; This record we're writing
  64.     CALL    PUT        ; Write it
  65.     CALL    CLOSE        ; Close file
  66.     LD    HL,DSKFIL
  67.     JP    SPOPEN        ; Go open it again with the record # set
  68. ;
  69. ;-----------------------------------------------------------------------
  70. ;
  71. START::    LD    A,0CDH
  72.     LD    (0),A        ; Disable ^c
  73.     LD    HL,0
  74.     ADD    HL,SP
  75.     LD    (CCPSTK),HL    ; Save ccp stack pointer
  76.     LD    SP,STACK    ; Set up local stack
  77. ;
  78. ; Get the end address of the file and store for buffer use
  79. ;
  80.     CALL    ENDEMX
  81.     LD    (MSG),HL
  82. ;
  83. ; Set to drive where SYSOP.EMX is located
  84. ;
  85.     LD    A,(SYSDRV)
  86.     LD    E,A
  87.     LD    C,LOGDRV
  88.     CALL    BDOS
  89. ;
  90. ; And to user area where SYSOP.EMX is located
  91. ;
  92.     LD    A,(SYSUSR)
  93.     LD    E,A
  94.     LD    C,LOGUSR
  95.     CALL    BDOS
  96. ;
  97. ; Patch error:: so it jumps to exit instead of running BYE
  98. ;
  99.     LD    A,0C3H        ; Jump
  100.     LD    (ERROR),A
  101.     LD    HL,EXIT        ; To exit
  102.     LD    (ERROR+1),HL
  103. ;
  104.     CALL    PRINT
  105.     DB    CR,LF,LF
  106.     DB    'SYSOP v',0
  107.     LD    HL,(VER)    ; H=revision, l=version
  108.     CALL    PVER        ; Show version number
  109.     CALL    PRINT
  110.     DB    CR,LF,LF
  111.     DB    'Comments entered here are not readable by anyone else:',0
  112. ;
  113. ;-----------------------------------------------------------------------
  114. ;
  115. ; Based on routines from EMX.MAC by Simon J. Ewins
  116. ;
  117. ; (c)1984  --  All rights reserved.
  118. ;
  119. ;-----------------------------------------------------------------------
  120. ;
  121.     LD    HL,LASTCAL    ; Get last caller file
  122.     CALL    SPOPEN
  123.     LD    HL,LSTLEN
  124.     LD    (RRSZ),HL    ; Set record size
  125.     LD    HL,0        ; Record number
  126.     CALL    GET        ; Get record
  127.     LD    HL,RNDBUF
  128.     LD    DE,LSTCLR
  129.     LD    BC,LSTLEN
  130.     LDIR            ; Move this caller's info to memory
  131.     CALL    CLOSE
  132.     JP    ENTER
  133. ;
  134. LINES::    DB    0
  135. ;
  136. WARN::    PUSH    BC
  137.     PUSH    HL
  138.     PUSH    DE
  139.     CALL    PRINT
  140.     DB    CR,LF
  141.     DB    '--> 15 lines. Last line next...'
  142.     DB    CR,LF,LF,0
  143.     POP    DE
  144.     POP    HL
  145.     POP    BC
  146.     RET
  147. ;
  148. ENTER::    CALL    PRINT
  149.     DB    CR,LF,LF
  150.     DB    'Enter up to 16 lines '
  151.     DB    'with 2 carriage returns to end.',CR,LF
  152.     DB    'The date, time and your name '
  153.     DB    'will be added as a last line.',CR,LF
  154.     DB    LF,'Enter text:'
  155.     DB    CR,LF,LF,0
  156.     LD    IY,(MSG)
  157.     LD    B,16
  158. ;
  159. ENTLP::    PUSH    BC
  160.     LD    A,17
  161.     SUB    B
  162.     PUSH    AF
  163.     CP    10
  164.     JP    NC,EPNUM
  165.     CALL    PRINT
  166.     DB    ' ',0
  167. ;
  168. EPNUM::    LD    H,0
  169.     POP    AF
  170.     LD    L,A
  171.     CALL    PB2ASC
  172.     CALL    PRINT
  173.     DB    '> ',0
  174.     LD    B,64        ; Input length
  175.     LD    C,0        ; No caps forced
  176.     XOR    A        ; Allow echo
  177.     LD    D,1        ; Want word-wrap at 53rd character
  178.     CALL    INPUT        ; Get line
  179.     CP    0
  180.     JP    Z,ENTDON
  181.     PUSH    IY
  182.     POP    DE
  183.     LD    BC,64
  184.     LDIR
  185.     PUSH    DE
  186.     POP    IY
  187.     CALL    PRINT
  188.     DB    CR,LF,0
  189.     POP    BC
  190.     LD    A,17
  191.     SUB    B
  192.     LD    (LINES),A
  193.     CP    15
  194.     CALL    Z,WARN
  195. ;
  196. ENTCNT::DJNZ    ENTLP
  197.     CALL    PRINT
  198.     DB    CR,LF
  199.     DB    '--> 16 lines entered.',0
  200. ;
  201. ENTDON::LD    A,(LINES)
  202.     OR    A
  203.     JP    Z,EXIT        ; If nothing entered then abort
  204. ;
  205.     CALL    PRINT
  206.     DB    CR,LF
  207.     DB    'Edit, List, Save, Continue, Quit: ',0
  208.     LD    B,1
  209.     LD    C,20H
  210.     XOR    A
  211.     LD    D,A
  212.     CALL    INPUT
  213.     LD    A,(HL)
  214.     CP    'E'
  215.     JP    Z,EDIT
  216.     CP    'S'
  217.     JP    Z,SAVE
  218.     CP    'L'
  219.     JP    Z,LIST
  220.     CP    'C'
  221.     JP    Z,CONT
  222.     CP    'Q'
  223.     JP    Z,EXIT
  224.     JP    ENTDON
  225. ;
  226. CONT::    CALL    PRINT
  227.     DB    CR,LF,LF
  228.     DB    'Continuing at line ',0
  229.     LD    A,(LINES)
  230.     INC    A
  231.     CP    17
  232.     JP    NC,NOCNT
  233.     LD    H,0
  234.     LD    L,A
  235.     CALL    PB2ASC
  236.     CALL    PRINT
  237.     DB    '.',CR,LF,LF,0
  238.     POP    BC        ; Reset line count
  239.     INC    B
  240.     JP    ENTCNT
  241. ;
  242. NOCNT::    LD    H,0
  243.     LD    L,A
  244.     CALL    PB2ASC
  245.     CALL    PRINT
  246.     DB    ' not allowed.... 16 line maximum.',0
  247.     JP    ENTDON
  248. ;
  249. LIST::    CALL    PRINT
  250.     DB    CR,LF,LF,0
  251.     LD    A,(LINES)
  252.     LD    B,A
  253.     LD    HL,(MSG)
  254. ;
  255. LSTLP::    PUSH    BC
  256.     PUSH    HL
  257.     PUSH    HL
  258.     LD    A,(LINES)
  259.     SUB    B
  260.     PUSH    AF
  261.     CP    9
  262.     JP    NC,PNUM
  263.     CALL    PRINT
  264.     DB    ' ',0
  265. ;
  266. PNUM::    LD    H,0
  267.     POP    AF
  268.     LD    L,A
  269.     INC    HL        ; Make base 1
  270.     CALL    PB2ASC
  271.     CALL    PRINT
  272.     DB    '> ',0
  273.     LD    B,64
  274.     POP    HL
  275.     CALL    PRINTL
  276.     CALL    PRINT
  277.     DB    CR,LF,0
  278.     LD    DE,64
  279.     POP    HL
  280.     ADD    HL,DE
  281.     POP    BC
  282.     DJNZ    LSTLP
  283.     JP    ENTDON
  284. ;
  285. SAVE::    LD    A,(LINES)    ; Bump # lines by one for 'from' info
  286.     INC    A
  287.     LD    (LINES),A
  288.     CALL    PRINT
  289.     DB    CR,LF,LF
  290.     DB    'Wait...',0
  291.     LD    A,1
  292.     LD    (WRTLOC),A
  293.     LD    (INIFLG),A    ; Set flag for this routine calling
  294.     LD    HL,DSKFIL
  295.     CALL    SPOPEN        ; Open file for comments
  296.     LD    HL,64
  297.     LD    (RRSZ),HL    ; Set record size
  298.     LD    HL,0        ; Get record number
  299.     CALL    GET
  300.     LD    HL,(RNDBUF)    ; Is first 2 bytes of record 0
  301.     PUSH    HL        ; Save this comment's record number
  302.     LD    A,(LINES)
  303.     LD    D,0
  304.     LD    E,A
  305.     ADD    HL,DE        ; New number for next comment
  306.     LD    (RNDBUF),HL    ; Store it
  307.     LD    HL,0        ; Record number
  308.     CALL    PUT        ; And write it
  309. ;
  310. ;
  311. ; And finally, write each 64 byte line to sequential records
  312. ;
  313. WRITE::    POP    HL        ; Get starting record number back
  314.     LD    (RRNO),HL
  315.     LD    IY,(MSG)    ; Point to message
  316.     LD    A,(LINES)
  317.     DEC    A        ; Less one because of 'from' line
  318.     LD    B,A        ; Set up counter
  319. ;
  320. WRTLP::    PUSH    BC
  321.     PUSH    IY
  322.     POP    HL
  323.     LD    DE,RNDBUF
  324.     LD    BC,64
  325.     LDIR
  326.     PUSH    HL
  327.     POP    IY
  328.     LD    HL,(RRNO)
  329.     CALL    PUT
  330.     LD    HL,(RRNO)
  331.     INC    HL
  332.     LD    (RRNO),HL
  333.     POP    BC
  334.     DJNZ    WRTLP
  335.     XOR    A
  336.     LD    HL,RNDBUF
  337.     LD    (HL),A
  338.     LD    DE,RNDBUF+1
  339.     LD    BC,63
  340.     LDIR            ; Clear random buffer
  341.     LD    HL,LSTCLR
  342.     LD    DE,RNDBUF
  343.     LD    BC,64
  344.     LDIR            ; Add line with caller's name
  345.     CALL    GETTIM        ; Get date and time
  346.     LD    HL,TIME
  347.     LD    DE,RNDBUF
  348.     LD    BC,8
  349.     LDIR            ; Move time string into place
  350.     LD    HL,DATE
  351.     INC    DE
  352.     LD    BC,8
  353.     LDIR            ; And date
  354.     LD    HL,(RRNO)
  355.     CALL    PUT        ; Write last line
  356.     CALL    CLOSE        ; All done
  357.     XOR    A
  358.     LD    (WRTLOC),A
  359.     CALL    PRINT
  360.     DB    CR,LF,LF
  361.     DB    'Returning to CP/M....'
  362.     DB    CR,LF,LF,0
  363.     JP    EXIT
  364. ;.....
  365. ;
  366. ; Edit the line asked for by retyping entire line
  367. ;
  368. EDIT::    CALL    PRINT
  369.     DB    CR,LF,LF
  370.     DB    'Edit which line? ',0
  371.     LD    B,2
  372.     XOR    A
  373.     LD    C,A
  374.     LD    D,A
  375.     CALL    INPUT        ; Get input
  376.     CP    0        ; Any?
  377.     JP    Z,ENTDON    ; No
  378.     LD    B,0        ; Preset tens amount
  379.     CP    2        ; Need to calc tens?
  380.     JP    NZ,EDIT1    ; No
  381.     LD    A,(HL)        ; Get digit
  382.     SUB    30H        ; Make it a number
  383.     INC    HL        ; Point to second digit
  384.     LD    DE,10        ; Mult digit by 10
  385.     PUSH    HL
  386.     LD    H,0
  387.     LD    L,A
  388.     CALL    MLDL        ; Mult
  389.     LD    A,L
  390.     POP    HL
  391.     LD    B,A        ; Tens amount in 'B'
  392. ;
  393. EDIT1::    LD    A,(HL)        ; Get units digit
  394.     SUB    30H        ; Make it a number
  395.     ADD    A,B        ; Add to tens (if any)
  396.     LD    B,A
  397.     LD    A,(LINES)    ; Okay?
  398.     CP    B
  399.     JP    C,EDIT        ; No, greater than # lines entered
  400.     LD    A,B        ; Get back number
  401.     CP    17        ; Legal #?
  402.     JP    NC,EDIT        ; No
  403.     LD    HL,64        ; Ok, so get line length
  404.     DEC    A        ; Adjust line number to base 0
  405.     LD    E,A        ; For array
  406.     LD    D,0
  407.     CALL    MLDL        ; Offset
  408.     EX    DE,HL        ; To de
  409.     LD    HL,(MSG)    ; And add to msg pointer
  410.     AND    A        ; Clear carry
  411.     ADD    HL,DE        ; Add 'em
  412.     PUSH    HL
  413.     CALL    PRINT
  414.     DB    CR,LF,LF
  415.     DB    'Line is now:'
  416.     DB    CR,LF,0
  417.     LD    B,64
  418.     POP    HL        ; Pointer
  419.     PUSH    HL        ; Save it
  420.     CALL    PRINTL        ; Show line
  421.     CALL    PRINT
  422.     DB    CR,LF
  423.     DB    'Enter new line or <return> to leave the same:'
  424.     DB    CR,LF,0
  425.     LD    B,64
  426.     XOR    A
  427.     LD    C,A
  428.     LD    D,A
  429.     CALL    INPUT
  430.     CP    0
  431.     JP    Z,EDIT
  432.     POP    DE        ; Point to line in array
  433.     LD    BC,64
  434.     LDIR            ; Move new line in place
  435.     JP    ENTDON
  436. ;
  437. EXIT::    CALL    PRINT
  438.     DB    CR,LF,0
  439.     LD    A,0C3H
  440.     LD    (0),A
  441.     LD    HL,(CCPSTK)    ; Ready for 'soft' return
  442.     LD    SP,HL        ; If we are done and going
  443.     RET            ; Directly to cp/m
  444. ;
  445. ; Stack area
  446. ;
  447.     DS    128
  448. ;
  449. STACK::    DW    0H
  450. CCPSTK::DW    0H        ; Stack storage
  451. MSG::    DW    0        ; Message storage
  452. ;
  453.     END
  454.