home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol170 / comm7ins.aqm / COMM7INS.ASM
Encoding:
Assembly Source File  |  1985-02-10  |  11.8 KB  |  475 lines

  1. ;        comm7 installation program
  2. ;                by
  3. ;            pavel breder
  4. ;                and
  5. ;            paul traina
  6. ;
  7. ; changes telephone library text and numbers in program comm7
  8. ; and also sets configuration flags
  9.  
  10. ; latest changes
  11.  
  12. ;11/26/83  streamlined the help menu so it fits on one screen of
  13. ;the crt.  fg
  14.  
  15. ;8/8/83  added full support of comm7 options, renamed file from
  16. ;comm7cal to comm7ins to reflect that this is now a total instalation
  17. ;program, not just a program to change library phone numbers
  18. ;NOTE: this program will not work on versions of comm7 eariler than 724
  19. ;                            paul traina
  20.  
  21. ;1/15/83  added close-file after read as suggested by
  22. ;pavel.  fg
  23.  
  24. ;7/18/82  changed to work with comm7 and its 34-column,
  25. ;'a ', (not 30-column, 'a='), telephone library.  source code
  26. ;changed to comm7 style.  ret to cp/m stack pointer instead of
  27. ;warm boot.  frank gaude'
  28.  
  29. ;06/13/82  pavel
  30. ;corrected bug in 'fill' new name that passed garbage from fcb
  31. ;or from old entry in to new name if the user did not fill the
  32. ;rest of name with spaces.
  33.  
  34. ;06/10/82  originally written by pavel breder
  35.  
  36. SOURCE    ORG    100h
  37.  
  38. ; cp/m equates
  39.  
  40. BASE    EQU    0        ;cp/m base
  41. BDOS    EQU    BASE+5h        ;cp/m function entry address
  42. RDCON    EQU    1        ;wait for a character from console
  43. WRCON    EQU    2        ;char to console
  44. DIRECT    EQU    6        ;direct i/o
  45. PRINT    EQU    9        ;print string (de)
  46. RDCONBF    EQU    10        ;read kbd input string
  47. OPEN    EQU    15        ;open file
  48. CLOSE    EQU    16        ;close file
  49. ERASE    EQU    19        ;delete file
  50. READ    EQU    20        ;read file
  51. WRITE    EQU    21        ;write file
  52. MAKE    EQU    22        ;make file
  53. SETDMA    EQU    26        ;set dma
  54. FCB    EQU    BASE+5Ch    ;cp/m default file control block..
  55. CMDBUF    EQU    BASE+80h    ;..and buffer.
  56.  
  57. ; other equates and a set
  58.  
  59. CR    EQU    13            ;ascii carriage return
  60. LF    EQU    10            ;ascii line feed
  61. BOTTRAM    SET    LAST + 80h AND 0FF80h    ;file extension pointer
  62.  
  63. ; program begins
  64.  
  65. START    LXI    H,0        ;let's save cp/m stack pointer
  66.     DAD    SP
  67.     SHLD    STACK
  68.     LXI    SP,STACK    ;set new stack, 15 levels deep.
  69.     LDA    FCB+1        ;file name from user?
  70.     CPI    ' '        ;space means no..
  71.     JZ    HELLOMS        ;..name, so say hello.
  72.      LDA    FCB+17        ;destination file present?
  73.     CPI    ' '
  74.     JZ    ERRFC1        ;space means no file
  75.     CPI    '?'        ;let's not use wild cards
  76.     JZ    ERRFC1
  77.  
  78. ; get ready for work to be done
  79.  
  80.     LXI    H,BOTTRAM-80H    ;point to buffer where original..
  81.     SHLD    TBUF        ;..file goes (-80h fixed later).
  82.     MVI    A,33        ;set limit to command-line..
  83.     STA    CMDBUF        ;..buffer and store here.
  84.  
  85. ; store destination file in safe location
  86.  
  87.     LXI    H,FCB+16    ;get destination filename pointer
  88.     LXI    D,FCB2        ;this is where we store it
  89.     MVI    B,16        ; 16 bytes to move
  90. MOVEFCB    MOV    A,M        ;move the filename (fcb2 to fcb2)
  91.     STAX    D
  92.     INX    H
  93.     INX    D
  94.     DCR    B
  95.     JNZ    MOVEFCB
  96.  
  97. ; read original file into memory
  98.  
  99.     LXI    D,FCB        ; 1st argument
  100.     MVI    C,OPEN        ;open it
  101.     CALL    BDOS
  102.     INR    A        ;ffh --> 0 if no file..
  103.     JZ    ERRFCB        ;..error.
  104. READMR    LHLD    TBUF        ;contains address where..
  105.     LXI    D,80H        ;..file is to be loaded.
  106.     DAD    D        ;add one 128-byte block and..
  107.     SHLD    TBUF        ;..save for next time.
  108.     XCHG            ;address into de so we can..
  109.     MVI    C,SETDMA    ;..set the dma.
  110.     CALL    BDOS
  111.     LXI    D,FCB        ;now read block
  112.     MVI    C,READ
  113.     CALL    BDOS
  114.     ORA    A
  115.     JNZ    READLS        ;end read if end of file
  116.     LDA    SECTCTR        ;count blocks
  117.     INR    A
  118.     STA    SECTCTR
  119.     JMP    READMR        ;read more
  120.  
  121. ; store last address and get ready to search for library
  122.  
  123. READLS    LXI    D,FCB
  124.     MVI    C,CLOSE
  125.     CALL    BDOS
  126.     LDA    TBUF+1        ;get end of file
  127.     INR    A
  128.     MOV    D,A        ;only msb needed
  129.     LXI    H,BOTTRAM    ;start of file is here
  130. ;
  131.     INX    H        ;skip over initial jump
  132.     INX    H
  133.     INX    H
  134.     PUSH    D        ;save DE
  135.  
  136. BACK    LXI    D,YBAKUP    ;ask question
  137.     CALL    XMESG
  138.     CALL    KEYIN        ;get key
  139.     CALL    YESNO        ;make Y-y/N-n into 255/0
  140.     CPI    1        ;error?
  141.     JZ    BACK
  142.     MOV    M,A        ;store new value
  143.  
  144.     INX    H        ;point to expert flag
  145. XPERT    LXI    D,YXPRT        ;ask question
  146.     CALL    XMESG
  147.     CALL    KEYIN        ;get response
  148.     CALL    YESNO        ;convert it
  149.     CPI    1        ;error?
  150.     JZ    XPERT
  151.     CMA            ;flip it
  152.     MOV    M,A        ;store new value
  153.  
  154.     INX    H        ;point to saveccp flag
  155. SAVECCP    LXI    D,YSAVE        ;ask question
  156.     CALL    XMESG
  157.     CALL    KEYIN        ;get response
  158.     CALL    YESNO        ;convert it
  159.     CPI    1        ;error?
  160.     JZ    SAVECCP
  161.     CMA            ;it's backwards...
  162.     MOV    M,A
  163.  
  164.     INX    H        ;point to command character
  165. CMDCHR    LXI    D,YCMDCHR    ;ask question
  166.     CALL    XMESG
  167.     CALL    DKEYIN        ;get response
  168.     PUSH    PSW        ;save it
  169.     CPI    ' '        ;is it => space?
  170.     JNC    NORMAL        ;yes, so just print it
  171.     CPI    27        ;no, ok, is it escape?
  172.     CZ    PESC        ;yes, so print "<escape>"
  173.     JZ    BELL        ;...  and then go on to next question
  174.     CPI    30        ;no, ok, is it home?
  175.     CZ    PHOME        ;yes, so print "<home>"
  176.     JZ    BELL        ;...  and then go on to next question
  177.     ADI    '@'        ;turn the control character into printing char.
  178.     PUSH    PSW        ;save it
  179.     MVI    E,'^'        ;print carret
  180.     CALL    COUT
  181.     POP    PSW        ;restore the now-ascii character
  182. NORMAL    MOV    E,A        ;put character in right register
  183.     CALL    COUT        ;print response
  184. BELL    POP    PSW        ;get back original response
  185.     MOV    M,A
  186.  
  187.     INX    H        ;point to bell flag
  188. BELL1    LXI    D,YBELL
  189.     CALL    XMESG
  190.     CALL    KEYIN
  191.     CALL    YESNO
  192.     CPI    1        ;error?
  193.     JZ    BELL1
  194.     MOV    M,A        ;save bell flag
  195.     POP    D        ;restore de
  196.  
  197. ; now look for the telephone numbers (searches for 'a ' and 'b ')
  198.  
  199. SEARCH    MOV    A,H        ;let's not search too far
  200.     CMP    D        ;at end of file?
  201.     JZ    WRFILE        ;yes, must be the wrong file.
  202.     MOV    A,M        ;get char
  203.     INX    H        ;increment file pointer
  204.     CPI    'A'        ; 'a' ?
  205.     JNZ    SEARCH        ;no, search next.
  206.     MOV    A,M        ;have 'a', see if next is ' '.
  207.     CPI    ' '
  208.     JNZ    SEARCH        ;no, wrong 'a'.
  209.     DCX    H        ;adjust address
  210.     SHLD    NUMBLIB        ;save where 'a' is
  211.     LXI    D,34        ;the 'b' should be here + 34..
  212.     DAD    D        ;..so 34 is added.
  213.     MOV    A,M        ;see what's there
  214.     CPI    'B'        ;is it 'b'?
  215.     JNZ    NOTB        ;not this one
  216.     INX    H        ;got 'b'
  217.     MOV    A,M        ;is the next char ' '?
  218.     CPI    ' '
  219.     JZ    LOOP0        ;yes, have right file and pointer
  220. NOTB    LHLD    NUMBLIB        ;get back pointer to 'a'
  221.     INX    H        ;increment address..
  222.     JMP    SEARCH        ;..and continue search.
  223.  
  224. ; we now have pointer to library, let's print each number and
  225. ; ask user for new text and numbers.
  226.  
  227. LOOP0    CALL    CRLF        ;start with a fresh line
  228. LOOPLP    LHLD    NUMBLIB        ;here we should be
  229.     MVI    B,34        ; 34 characters to print
  230. LOPPRT    MOV    E,M        ;one at a time
  231.     CALL    COUT        ;to console
  232.     INX    H
  233.     DCR    B
  234.     JNZ    LOPPRT        ;not done, print next
  235.     MVI    E,'*'        ;show where last character is
  236.     CALL    COUT
  237.     LDA    NUMBCTR        ;count entry (a-z)
  238.     INR    A
  239.     STA    NUMBCTR
  240. LOOP    CALL    CRLF
  241.     LDA    NUMBCTR        ;again point to library table
  242.     ADI    64        ;make ascii and..
  243.     MOV    E,A        ;..send to console.
  244.     CALL    COUT
  245.     MVI    E,' '        ;print same as in file: ' '.
  246.     CALL    COUT
  247.     LXI    D,CMDBUF    ;point to input buffer
  248.     MVI    C,RDCONBF    ;get string from user
  249.     CALL    BDOS
  250.     LDA    CMDBUF+1    ;get character count entered
  251.     CPI    33        ;at limit?
  252.     JNC    LOONG        ;more than 32, too much.
  253.     ORA    A        ;else if 0 (cr only)..
  254.     JZ    NOFIL        ;..then go to next entry.
  255.     LHLD    NUMBLIB        ;current entry in file is here
  256.     INX    H        ;skip entry number..
  257.     INX    H        ;..and ' ' in file.
  258.     MVI    B,32        ;set up count to bytes to move
  259.     MOV    C,A
  260.     LXI    D,CMDBUF+2    ;from here
  261. FILL    LDAX    D        ;move them
  262.     MOV    M,A        ;one at a time
  263.     INX    H
  264.     INX    D
  265.     DCR    B
  266.     JZ    FILLY        ;have all 32 bytes
  267.     DCR    C
  268.     JNZ    FILL        ;one more to go
  269. FILLS    MVI    M,' '        ;fill the rest with spaces
  270.     INX    H
  271.     DCR    B
  272.     JNZ    FILLS
  273. FILLY    CALL    CRLF
  274. NOFIL0    SHLD    NUMBLIB        ;save new pointer to the file
  275.     LDA    NUMBCTR        ;at last entry?
  276.     CPI    'Z'-64        ; 'z' is the last
  277.     JZ    SAVEIT        ;yes, go save it
  278.     JMP    LOOPLP        ;go do next
  279.  
  280. NOFIL    LHLD    NUMBLIB
  281.     LXI    D,34
  282.     DAD    D
  283.     JMP    NOFIL0
  284.  
  285. LOONG    LXI    D,YLONG
  286.     CALL    XMESG
  287.     JMP    LOOP
  288.  
  289. ; produce destination file
  290.  
  291. SAVEIT    LXI    D,CMDBUF    ;reset dma to cp/m default
  292.     MVI    C,SETDMA
  293.     CALL    BDOS
  294.     LXI    D,FCB2
  295.     MVI    C,ERASE        ;delete the destination..
  296.     CALL    BDOS        ;..just in case.
  297.     LXI    D,FCB2
  298.     MVI    C,MAKE        ;make the destination file and..
  299.     CALL    BDOS
  300.     LXI    D,FCB2
  301.     MVI    C,OPEN        ;..open it.
  302.     CALL    BDOS
  303.     LXI    H,BOTTRAM-80H    ;file is here (+80h)
  304.     SHLD    NUMBLIB
  305. SAVE1    LHLD    NUMBLIB        ;get dma pointer
  306.     LXI    D,80H        ;increment by one 128-byte block
  307.     DAD    D
  308.     SHLD    NUMBLIB        ;save for next time
  309.     XCHG            ;dma call needs it in de
  310.     MVI    C,SETDMA    ;set dma
  311.     CALL    BDOS
  312.     LXI    D,FCB2        ;write the current block
  313.     MVI    C,WRITE
  314.     CALL    BDOS
  315.     ORA    A
  316.     JNZ    ERRWR        ;ouch!
  317.     LDA    SECTCTR        ;count down remaining blocks
  318.     DCR    A
  319.     STA    SECTCTR
  320.     JNZ    SAVE1        ;more to go
  321.     LXI    D,CMDBUF    ;reset dma to dir
  322.     MVI    C,SETDMA
  323.     CALL    BDOS
  324.     LXI    D,FCB2
  325.     MVI    C,CLOSE        ;close the file
  326.     CALL    BDOS
  327. EXIT    LHLD    STACK        ;all done, go home.
  328.     SPHL
  329.     RET
  330.  
  331. ; get 1 character response from console
  332.  
  333. KEYIN    PUSH    H        ;save all registers
  334.     PUSH    D
  335.     PUSH    B
  336.     MVI    C,RDCON        ;tell bdos to give us a character
  337.     CALL    BDOS
  338. KEYIN1    POP    B
  339.     POP    D
  340.     POP    H
  341.     RET            ;return with character in a
  342.  
  343. DKEYIN    PUSH    H        ;save all registers
  344.     PUSH    D
  345.     PUSH    B
  346. DKEYIN1    MVI    C,DIRECT    ;tell bdos to give us a character
  347.     MVI    E,255        ;tell bdos we want one
  348.     CALL    BDOS
  349.     ORA    A        ;if no character, loop
  350.     JZ    DKEYIN1
  351.     JMP    KEYIN1
  352.  
  353. ; convert yes/no into 255 (for yes) and 0 for no (and 1=error)
  354.  
  355. YESNO    ANI    5Fh
  356.     MOV    B,A        ;save it in B
  357.     CPI    'Y'        ;is it a yes?
  358.     MVI    A,255        ;assume that it was
  359.     RZ            ;yes, return
  360.     MOV    A,B        ;get it back again
  361.     CPI    'N'        ;is it a no?
  362.     MVI    A,0        ;assume that it was
  363.     RZ            ;yes, return
  364.     MVI    A,1        ;it was neither, so return an error
  365.     RET
  366.  
  367. ; print-to-console routines
  368.  
  369. XMESG    PUSH    H        ;string msg pointed to by de
  370.     PUSH    B
  371.     MVI    C,PRINT        ;string out, terminated by "$".
  372.     CALL    BDOS
  373.     POP    B
  374.     POP    H
  375.     RET
  376.  
  377. CRLF    MVI    E,CR
  378.     CALL    COUT
  379.     MVI    E,LF
  380. COUT    PUSH    H        ;character is in e, print it.
  381.     PUSH    B
  382.     PUSH    D
  383.     MVI    C,WRCON     ;byte out
  384.     CALL    BDOS
  385.     POP    D
  386.     POP    B
  387.     POP    H
  388.     RET
  389.  
  390. ; utility message routines
  391.  
  392. PESC    PUSH    PSW
  393.     LXI    D,YESC
  394.     CALL    XMESG
  395.     POP    PSW
  396.     RET
  397.  
  398. PHOME    PUSH    PSW
  399.     LXI    D,YHOME
  400.     CALL    XMESG
  401.     POP    PSW
  402.     RET
  403.  
  404. ; error message routines
  405.  
  406. HELLOMS    LXI    D,YHELLO
  407.     JMP    ERR2
  408.  
  409. WRFILE    LXI    D,YRFILE
  410.     JMP    ERR2
  411.  
  412. ERRWR    LXI    D,YRRWR
  413.     JMP    ERR2
  414.  
  415. ERRFC1    LXI    D,YNONAM
  416.     JMP    ERR2
  417.  
  418. ERRFCB    LXI    D,YRRFCB
  419. ERR2    CALL    XMESG        ;print message
  420.     CALL    EXIT        ;go home.
  421.  
  422. ; initialized storage
  423.  
  424. NUMBCTR    DB 0    ; a-to-z modem library letter and..
  425. SECTCTR    DB 0    ;..file sector counters.
  426. TBUF    DW 0    ;pointers for 1st argument (orig file)..
  427. NUMBLIB    DW 0    ;..and for library number table.
  428.  
  429. YBAKUP    DB CR,LF,'Do you wish to make .BAK files? $'
  430. YXPRT    DB CR,LF,'Should the menu be printed the first time? $'
  431. YSAVE    DB CR,LF,'Is it ok to overwrite the CCP? $'
  432. YCMDCHR    DB CR,LF,'What character do you want as attention character? $'
  433. YBELL    DB CR,LF,'Should Comm7 beep every time you toggle the printer? $'
  434. YESC    DB '<escape>$'
  435. YHOME    DB '<home>$'
  436. YLONG    DB CR,LF,'  ^^^^^ too l-o-n-g, retype ^^^^^$'
  437. YRRFCB    DB CR,LF,'++ Cannot find file ++',CR,LF,'$'
  438. YNONAM    DB CR,LF,'++ No destination file, or illegal name '
  439.     DB 'specified ++',CR,LF,'$'
  440. YRRWR    DB CR,LF,'++ Error extending file, or disk full ++'
  441.     DB CR,LF,'$'
  442. YRFILE    DB CR,LF,'++ Unable to find telephone library ++'
  443.     DB CR,LF,'$'
  444. YHELLO
  445. DB 9,9,'COMM7INS as of 11/12/83'
  446. DB CR,LF,LF,'This program allows changes to Comm7 to suit your tastes.'
  447. DB '  Although major '
  448. DB CR,LF,'options must be changed by modifying equates and re-assembling '
  449. DB 'program, '
  450. DB CR,LF,'the following values may be changed by this install '
  451. DB 'program:',LF
  452.     DB CR,LF,9,'Whether Comm7 should make .BAK files in batch mode.'
  453.     DB CR,LF,9,'Should the main menu be printed on startup.'
  454.     DB CR,LF,9,'Should the CCP be overwritten during memory saves.'
  455.     DB CR,LF,9,'The "command" character Comm7 uses in terminal mode.'
  456.     DB CR,LF,9,'Whether crt terminal beeps when the printer is '
  457.     DB       'toggled.',LF
  458. DB CR,LF,'Also, the telephone numbers may be changed in the library:'
  459. DB CR,LF,'Just enter text and numbers when at prompt A-to-Z.  If change'
  460. DB CR,LF,'not desired, press <RETURN> for next library letter.  '
  461. DB '^C aborts.'
  462. DB CR,LF,LF,'Two forms are available:',LF
  463.     DB CR,LF,9,'  A>comm7ins oldname.com newname.com'
  464.     DB CR,LF,'or',9,'  A>comm7ins oldname.com oldname.com',LF
  465. DB CR,LF,'Example:  A>comm7ins comm725.com comm7.com'
  466.     DB CR,LF,'$'
  467.  
  468. ; unitialized storage
  469.  
  470. FCB2    DS    33    ; 2nd argument (destination file) fcb
  471.     DS    30    ;new stack area
  472. STACK    DS    2    ;cp/m stack pointer here
  473.  
  474. LAST    END    SOURCE
  475.