home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / sysutl / util-la.lbr / BLISTER.AZM / BLISTER.ASM
Encoding:
Assembly Source File  |  1994-06-07  |  9.9 KB  |  405 lines

  1. ;BLISTER.ASM 1.0   Generates page-pauses during BASIC LISTings to the console.
  2. ;Roy Lipscomb         Compatible with CP/M 2.2 and 8080/8085/Z80 CPUs
  3. ;9/16/87               Assemble with ASM.COM
  4. ;
  5. ;              (C) Copyright 1987, Logic Associates
  6. ;              Permission is hereby granted only for
  7. ;                non-fee copying and distribution.
  8. ;
  9. ;
  10. ; NOTE:  No separate .DOC file is provided.  All documentation is in this file.
  11. ;
  12. ;****************************************************************************
  13. ;"WHAT'S IT FOR?"
  14. ;
  15. ; BLISTER is an add-on for interpreted BASIC (any version).
  16. ;
  17. ; During long LISTings to the console, BLISTER suspends the LISTing after
  18. ; each "page-full" of lines.
  19. ;
  20. ; BLISTER permits the LISTing to resume as soon as any key is pressed (except
  21. ; that the LISTing is terminated if control-C is pressed).
  22. ;
  23. ;****************************************************************************
  24. ;INSTALLATION
  25. ;
  26. ; BLISTER relocates itself to very low memory not used by most programs.
  27. ;
  28. ; Do not run BLISTER if your system is using any of the CPU restart locations,
  29. ; (apart from the DDT vector).  See "CAUTION" below.  Otherwise, --
  30. ;
  31. ; Type "BLISTER."
  32. ;
  33. ;****************************************************************************
  34. ;REMOVAL
  35. ;
  36. ; Type "BLISTER OFF", or press reset.
  37. ;
  38. ;****************************************************************************
  39. ;CUSTOMIZING
  40. ;
  41. ; The distribution version of this program generates page pauses every 22
  42. ; lines.  You can change this page length by either of two methods:
  43. ;
  44. ;    []  Change the variable "pagelen" in this source code,
  45. ;        and then reassemble this source code,
  46. ;
  47. ;    or []  (after running BLISTER) POKE the desired page-length value
  48. ;        (1-255) into location 37H (55 decimal).
  49. ;
  50. ;****************************************************************************
  51. ;THEORY OF OPERATION
  52. ;
  53. ; By patching the BIOS jumptable, BLISTER is able to review all output to the
  54. ; console, and to monitor all console input.
  55. ;
  56. ; When it finds a line that does not begin with a digit, it resets its counter.
  57. ; When it finds a line that does begin with a digit, it decrements its counter.
  58. ; When its counter reaches zero, BLISTER pauses and waits for any keystroke.
  59. ; At the keystroke, BLISTER passes control back to BASIC.
  60. ;
  61. ; The above strategy allows BLISTER to work not only with BASIC but also
  62. ; with other programs that display lines prefixed with digits.
  63. ;
  64. ;****************************************************************************
  65. ; ===>>>>               *****>>>>>CAUTION<<<<<*****                 <<<<===
  66. ;
  67. ; BLISTER relocates itself to low memory locations 8H through 50H.  If your
  68. ; system uses any of this space (except the DDT vector at 38H), BLISTER will
  69. ; cause your system to crash.  It's ok to use DDT or other debugger, however.
  70. ;
  71. ; BLISTER works fine in all systems at our location, and should also work
  72. ; fine in most other systems.  But Logic Associates cannot be responsible
  73. ; for any damage resulting from use of this software.  Use it at your own risk.
  74. ;
  75. ;****************************************************************************
  76.  
  77.     org    100h
  78.     jmp    begin
  79.  
  80. ;----------------------------------------------------------------------------
  81. ;                                User-Customizable Constant.            ;
  82. ;----------------------------------------------------------------------------
  83.  
  84. pagelen    equ    22        ;recommended values:  11 or 22.
  85.  
  86.  
  87. ;----------------------------------------------------------------------------
  88. ;                                 Other constants                     ;
  89. ;----------------------------------------------------------------------------
  90.  
  91. bell    equ    7
  92. lf    equ    10
  93. cr    equ    13
  94.  
  95. bdos    equ    5
  96. loadpt    equ    8
  97. fcb    equ    05ch
  98.  
  99. display    equ    9
  100.  
  101. mlogon    db    cr,lf,'BLISTER 1.0     (C) Copyright 1987, Logic Associates.'
  102.     db    cr,lf
  103.     db    cr,lf,'Inserts page pauses into BASIC LISTings to the console.'
  104.     db    cr,lf,'(To remove, press reset or type "BLISTER OFF".)'
  105.     db    cr,lf
  106. crlf:    db    cr,lf,'$'
  107.  
  108. miok:    db    cr,lf,'Installed.$'
  109. mdok:    db    cr,lf,'De-installed.$'
  110.  
  111. miabort    db    cr,lf,bell,'Installation ABORTED:  BLISTER already installed.$'
  112. mdabort    db    cr,lf,bell,'De-installation ABORTED:  BLISTER not installed.$'
  113.  
  114. ;----------------------------------------------------------------------------
  115. ;                           MAINLINE                         ;
  116. ;----------------------------------------------------------------------------
  117. begin:
  118.     lxi    d,mlogon    ;display welcome message.
  119.     mvi    c,display
  120.     call    bdos
  121.  
  122.     call    tstoff        ;is request to turn BLISTER off?
  123.     jz    deinst        ;  yes, go do it.
  124.  
  125. ;install BLISTER.
  126.     call    tstact        ;is BLISTER already active?
  127.     lxi    d,miabort    ;(prepare error message)
  128.     jz    exit        ; yes, abort
  129.  
  130.     call    install        ;install BLISTER relocatable module.
  131.  
  132.     lxi    d,miok        ;notify of successful installation.
  133.     jmp    exit
  134.  
  135. ;De-install BLISTER.
  136. deinst:
  137.     call    tstact        ;is BLISTER active?
  138.     lxi    d,mdabort    ;(prepare error message)
  139.     jnz    exit        ; no, abort
  140.  
  141.     call    unpatch        ;unpatch the BIOS jumptable.
  142.  
  143.     lxi    d,mdok        ;notify of successful de-installation.
  144.  
  145. ;end of processing.
  146. exit:
  147.     mvi    c,display    ;inform user of results.
  148.     call    bdos
  149.  
  150.     lxi    d,crlf
  151.     mvi    c,display
  152.     call    bdos
  153.  
  154.     ret
  155.  
  156. ;----------------------------------------------------------------------------
  157. ;is request for de-installation?
  158. ;if yes, return z = yes.
  159.  
  160. tstoff:
  161.     lxi    h,fcb+1
  162.  
  163.     mov    a,m
  164.     cpi    'O'
  165.     jnz    tstoffx
  166.  
  167.     inx    h
  168.     mov    a,m
  169.     cpi    'F'
  170.     jnz    tstoffx
  171.  
  172.     inx    h
  173.     mov    a,m
  174.     cpi    'F'
  175.  
  176. tstoffx:
  177.     ret
  178.  
  179. ;----------------------------------------------------------------------------
  180. ;is BLISTER active?
  181. ;if yes, return z = yes.
  182.  
  183. tstact:
  184.     lhld    1            ;test for conin patch.
  185.     mvi    l,9+1
  186.  
  187.     mov    e,m
  188.     inx    h
  189.     mov    d,m
  190.  
  191.     lxi    h,-trconin
  192.     dad    d
  193.  
  194.     mov    a,h            ;is appropriate patch present?
  195.     ora    l
  196.     jnz    tstactx            ; no, exit.
  197.  
  198.     lhld    1            ;test for conout patch.
  199.     mvi    l,12+1
  200.  
  201.     mov    e,m
  202.     inx    h
  203.     mov    d,m
  204.  
  205.     lxi    h,-trconout
  206.     dad    d
  207.  
  208.     mov    a,h            ;is appropriate patch present?
  209.     ora    l
  210.  
  211. tstactx:
  212.     ret
  213.  
  214. ;----------------------------------------------------------------------------
  215. ;install the BLISTER relocatable module.
  216.  
  217. install:
  218.     call    fillmod        ;fill run-time addresses into module
  219.                 ;(must be done BEFORE patching, below.)
  220.  
  221.     call    movemod        ;move module into place.
  222.  
  223.     call    patch        ;patch the BIOS jumptable.
  224.  
  225.     ret
  226.  
  227. ;----------------------------------------------------------------------------
  228. ;copy run-time addresses into BLISTER relocatable module.
  229.  
  230. fillmod:
  231.     lhld    38h        ;copy DDT vector contents into module.
  232.     shld    ddtvect+adjust
  233.  
  234.     lda    38h+2
  235.     sta    ddtvect+adjust+2
  236.  
  237.     lhld    1        ;get conin-routine addr...
  238.     mvi    l,9+1
  239.     mov    e,m
  240.     inx    h
  241.     mov    d,m
  242.     xchg
  243.     shld    getkey+adjust+1    ; ...then copy into module.
  244.  
  245.     lhld    1        ;get conout-routine addr...
  246.     mvi    l,12+1
  247.     mov    e,m
  248.     inx    h
  249.     mov    d,m
  250.     xchg
  251.     shld    todisp+adjust+1    ; ...then copy into module.
  252.  
  253.     ret
  254.  
  255. ;----------------------------------------------------------------------------
  256. ;move module into place.
  257.  
  258. movemod:
  259.     mvi    b,modlen
  260.     lxi    d,loadpt
  261.     lxi    h,module
  262. movem1:
  263.     mov    a,m
  264.     stax    d
  265.     inx    d
  266.     inx    h
  267.     dcr    b
  268.     jnz    movem1
  269.  
  270.     ret
  271.  
  272. ;----------------------------------------------------------------------------
  273. ;patch BIOS jumptable.
  274.  
  275. patch:
  276.     lhld    1        ;patch conin vector in BIOS table.
  277.     mvi    l,9+1
  278.     lxi    d,trconin
  279.     mov    m,e
  280.     inx    h
  281.     mov    m,d
  282.  
  283.     lhld    1        ;patch conout vector in BIOS table.
  284.     mvi    l,12+1
  285.     lxi    d,trconout
  286.     mov    m,e
  287.     inx    h
  288.     mov    m,d
  289.  
  290.     ret
  291.  
  292. ;----------------------------------------------------------------------------
  293. ;unpatch BIOS jumptable.
  294.  
  295. unpatch:
  296.     lhld    getkey+1    ;unpatch conin vector in BIOS table.
  297.     xchg
  298.     lhld    1
  299.     mvi    l,9+1
  300.     mov    m,e
  301.     inx    h
  302.     mov    m,d
  303.  
  304.     lhld    todisp+1    ;unpatch conout vector in BIOS table.
  305.     xchg
  306.     lhld    1
  307.     mvi    l,12+1
  308.     mov    m,e
  309.     inx    h
  310.     mov    m,d
  311.  
  312.     ret
  313.  
  314. *****************************************************************************
  315.  
  316. ;----------------------------------------------------------------------------
  317. ;                           RELOCATABLE MODULE                     ;
  318. ;----------------------------------------------------------------------------
  319. module:
  320.  
  321. adjust    equ    $-loadpt    ;correction for addresses below.
  322.  
  323. ;............................................................................
  324.  
  325. trconout equ    $-adjust
  326.  
  327. oldout    equ    $-adjust+1
  328.     mvi    a,$-$        ;old char = lf?
  329.     cpi    lf
  330.  
  331.     mov    a,c
  332.     sta    oldout        ;(save new char.)
  333.  
  334.     cz    traplf        ; yes:  see if pause needed.
  335.  
  336. oldin    equ    $-adjust+1
  337.     mvi    a,$-$        ;last keystroke = ^C?
  338.     cpi    3
  339.     rz            ;yes, throw away display char.
  340.  
  341. todisp    equ    $-adjust
  342.     jmp    $-$        ;no, display character.
  343.  
  344. ;------------------------------------------------------
  345. ;trap routine for conin.
  346.  
  347. trconin    equ    $-adjust
  348.     call    reinit        ;reinitialize count.
  349.  
  350.     lxi    h,oldin
  351.     mov    a,m        ;get buffered character,
  352.     mvi    m,0        ; clear the buffer.
  353.  
  354.     ora    a        ;buffer empty?
  355.     rnz            ; no, return the buffered char.
  356.  
  357. getkey    equ    $-adjust
  358.     jmp    $-$        ;go get keystroke.
  359.  
  360. ;------------------------------------------------------
  361. ;new line:  reset line count if full page now displayed.
  362.  
  363. traplf    equ    $-adjust
  364.     sui    '0'        ;1st char on line is digit?
  365.     cpi    10
  366.     jnc    reinit        ; no, reset counter.
  367.  
  368.     lxi    h,counter    ;end of screen page?
  369.     jmp    continue
  370.  
  371. ;......................................................
  372.  
  373. counter equ    $-adjust
  374.     db    pagelen        ;lines left until pause.
  375.  
  376. initcnt    equ    $-adjust
  377.     db    pagelen        ;initial value of counter
  378.  
  379. ;......................................................
  380. ddtvect    equ    $-adjust    ;DDT vector location.
  381.     ds    3        ;(copied to here at run time.)
  382. ;......................................................
  383.  
  384. continue equ    $-adjust
  385.     dcr    m
  386.     rnz            ; no, exit.
  387.  
  388.     lda    oldin        ;^-C already in effect?
  389.     cpi    3
  390.  
  391.     push    b
  392.     cnz    getkey        ; no, wait for keypress, and...
  393.     pop    b
  394.  
  395.     sta    oldin        ;   ...save it for conin request.
  396.  
  397. reinit    equ    $-adjust
  398.     lda    initcnt        ;reset counter for next list-page.
  399.     sta    counter
  400.  
  401.     ret
  402.  
  403. ;----------------------------------------------------------------------------
  404. modlen    equ    $-module
  405.