home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol145 / bishow-2.a86 < prev    next >
Encoding:
Text File  |  1984-04-29  |  8.5 KB  |  323 lines

  1.  
  2.     TITLE    'BIDIRECT. VERSION SHOW'
  3.  
  4. ; CP/M-86 translation using XLT86 05/22/83 H.M. Van Tassell
  5. ; use GENCMD BISHOW 8080 CODE[M240] 64*128+400H OF CODE
  6.  
  7. ; CHANGED TO USE WYSE-100/200 SCRL KEYS BUT YOU CAN USE ANY
  8. ; KEYS TO SCROOL JUST MAKE SURE MESSAGES MATCH YOUR CHOICE
  9. ; ALSO CHECK THAT CLRSCR SEQUENCE WORKS ON YOUR TERMINAL
  10. ; HI-BIT MASKING ADDED SO WILL PRINT WORDSTAR FILES
  11. ;
  12. ; BISHOW.A86
  13. ;
  14. ;A buffered, bidirectional version of SHOW.ASM.
  15. ;Ver 1.0, 23 Aug 82
  16. ;Phil Cary, 748 Kenilworth Parkway, Baton Rouge, LA  70808
  17. ;Ver 1.1, 30 Mar 83 added BDOS function 6 W.F.McGee
  18. ;
  19. ; Begin code
  20. ;
  21. M    EQU    Byte Ptr 0[BX]        ;xlt86 way to make 'M'
  22. ;
  23. false    EQU    0
  24. true    EQU    not false
  25. ;
  26. ; BDOS equates
  27. ;
  28. boot    EQU    0            ;warm boot
  29. wrcon    EQU    2            ;console write
  30. bdos    EQU    5            ;bdos entry
  31. open    EQU    15            ;open file
  32. readr    EQU    33            ;read file random access
  33. stdma    EQU    26            ;set dma address
  34. ;
  35. ; FCB equates
  36. ;
  37. fcb    EQU    05ch            ;default fcb drive number
  38. fcbfn    EQU    fcb+1            ;start of filename
  39. fcbft    EQU    fcb+9            ;start of filetype
  40. fcbex    EQU    fcb+12            ;current extent number
  41. fcbcrr    EQU    fcb+33            ;current record number, random access
  42. ;
  43. ; ASCII equates
  44. ;
  45. cr    EQU    0dh            ;carriage return
  46. lf    EQU    0ah            ;line feed
  47. eof    EQU    01ah            ;end of file
  48. esc    EQU    01bh            ;escape
  49. bell    EQU    07h            ;bell
  50. ;
  51. ;
  52. ; Operational equates
  53. ;
  54. maxsec    EQU    64            ;number of sectors in buffer
  55. ;
  56.     ORG    100h
  57. ;
  58.     JMPS    start            ;skip over next subroutine
  59. mes0    DB    esc,'*','$'        ;Wyse-100/200 terminal.
  60.                     ;.. change as required
  61. clrscr:    mov    dx,offset mes0        ;code to erase screen and home cursor
  62.     call    prnstr
  63.     RET
  64. ;
  65. start:    CALL    clrscr            ;clear the screen
  66.     CALL    opnfil            ;open file in default fcb
  67.     XOR    AL,AL            ;get a 0
  68.     MOV    Byte Ptr lincnt,AL    ;store in line count
  69.     MOV    Byte Ptr .fcbex,AL    ;zero current extent
  70.     MOV    Byte Ptr .fcbcrr,AL    ;zero current record
  71.     MOV    Byte Ptr .fcbcrr+1,AL    ;..both bytes
  72.     MOV    Byte Ptr .fcbcrr+2,AL    ;..and the overflow
  73.     CALL    filbuf            ;fill the disk buffer
  74. ;
  75. wrtfwd:    MOV    BX,(Offset dskbuf)    ;point to beginning of buffer
  76. wrtfwd1:MOV    AL,M            ;get a character
  77.     CMP    AL,eof            ;if it is EOF
  78.     JZ    getcmd            ;..loop for another command
  79.     LAHF                ;save character from BDOS clobber
  80.     XCHG    AL,AH
  81.     PUSH    AX
  82.     XCHG    AL,AH
  83.     CALL    ctype            ;put it on console
  84.     POP    AX            ;get character
  85.     XCHG    AL,AH
  86.       and    al,7fh
  87.     CMP    AL,cr            ;see if end of line
  88.     JZ    fwdcnt            ;yes, count line
  89. wrtfwd2:INC    BX            ;no, bump buffer
  90.     MOV    DX,fulbuf        ;get end of buffer address
  91.     MOV    AL,DH            ;compare high
  92.     CMP    AL,BH            ;..order bytes
  93.     JNZ    wrtfwd1            ;if not equal, continue
  94.     MOV    AL,DL            ;else compare low
  95.     CMP    AL,BL            ;..order bytes
  96.     JNZ    L_1    
  97.     CALL    filbuf            ;if end of buffer, go refill
  98. L_1:
  99.     JZ    wrtfwd            ;..and start at beginning of buffer
  100.     JMPS    wrtfwd1            ;else, continue with next character
  101. ;
  102. fwdcnt:
  103.     MOV    AL,Byte Ptr lincnt    ;get number of lines displayed
  104.     INC    AL            ;bump it
  105.     MOV    Byte Ptr lincnt,AL    ;..and store it
  106.     XCHG    BX,DX            ;save the buffer pointer
  107.     MOV    BX,Offset linmax    ;point to max number of line for this pass
  108.     CMP    AL,M            ;compare with line count
  109.     XCHG    BX,DX            ;restore pointer
  110.     JNZ    wrtfwd2            ;if not there, continue, else get command
  111.     XOR    AL,AL            ;zero the
  112.     MOV    Byte Ptr lincnt,AL    ;..line count
  113. ;
  114. getcmd:
  115.     PUSH    BX
  116.     PUSH    DX
  117.     PUSH    CX
  118. getcmd1:
  119.     MOV    CL,06
  120.     MOV    DL,0FFH
  121.     INT    224
  122.     CMP    AL,00h            ;char. ready?
  123.     JZ    getcmd1
  124.     CMP    AL,esc            ;skip if esc
  125.     JZ    getcmd1
  126.     AND    AL,5fH            ;make it upper case
  127.     PUSH    AX            ;save char
  128.     MOV    AL,22            ;set up for only 22 lines on forward
  129.     MOV    Byte Ptr linmax,AL    ;..scrolls
  130.     POP    AX            ;get char 
  131.     POP    CX
  132.     POP    DX
  133.     POP    BX
  134.     CMP    AL,'W'            ;scroll forward?-WYSE-100 SCRL DOWN
  135.     JE     wrtfwd1            ;scroll forward
  136.     CMP    AL,'C'-40H        ;CTRL C
  137.     JE     wrtfwd1            ;scroll forward
  138.     CMP    AL,'Z'-40H        ;CTRL Z
  139.     JE     wrtfwd1            ;scroll forward
  140.     PUSH    AX            ;else save character again
  141.     MOV    AL,24            ;set up for full screen on scroll
  142.     MOV    Byte Ptr linmax,AL    ;..backward
  143.     POP    AX            ;get character
  144.     CMP    AL,'V'            ;scroll backward?-WYSE-100 SCRL UP
  145.     JZ    wrtbak            ;yes
  146.     CMP    AL,'R'-40H        ;CTRL R
  147.     JZ    wrtbak            ;yes
  148.     CMP    AL,'W'-40H        ;CTRL W
  149.     JZ    wrtbak            ;yes
  150.     CMP    AL,'X'            ;must be exit
  151.     JNZ    L_3    
  152.     JMP    exit            ;yes, or
  153. L_3:
  154.     mov    dx,offset mes1
  155.     call    prnstr
  156.     JMPS    getcmd            ;try again for command
  157. ;
  158. wrtbak:    MOV    AL,44
  159.     MOV    Byte Ptr lincnt,AL
  160.     push     bx
  161.     CALL    clrscr            ;clear the screen
  162.     pop    bx
  163. wrtbak1:MOV    DX,(Offset dskbuf)    ;get address of buffer start
  164.     MOV    AL,DH            ;compare high
  165.     CMP    AL,BH            ;..order bytes
  166.     JNZ    wrtbak2            ;continue if not equal
  167.     MOV    AL,DL            ;else, compare low
  168.     CMP    AL,BL            ;..order bytes
  169.     JNZ    wrtbak2            ;continue if not equal
  170.     JMPS    filbak            ;..and go write it
  171. wrtbak2:MOV    AL,M            ;get a character
  172.      and    al,7fh
  173.     CMP    AL,cr            ;see if end of line
  174.     LAHF                ;decrement buffer
  175.     DEC    BX
  176.     SAHF
  177.     JNZ    wrtbak1            ;..and loop if not
  178. ;
  179. bakcnt:    MOV    AL,Byte Ptr lincnt    ;else, get number of lines to move back
  180.     DEC    AL            ;..and decrement it
  181.     MOV    Byte Ptr lincnt,AL    ;..store it
  182.     JNZ    wrtbak1            ;..and loop if not there
  183.     INC    BX            ;else bump pointer to account for lf with cr
  184.     JMP    wrtfwd1            ;..and go write a screen
  185. ;
  186. filbak:    MOV    DX,maxsec        ;get the buffer size
  187.     MOV    BX,Word Ptr seccnt    ;..and number of sectors last read
  188.     ADD    BX,DX            ;add them
  189.     XCHG    BX,DX            ;..and put them in DE
  190.     MOV    AL,Byte Ptr .fcbcrr    ;subtract low order byte 
  191.     SUB    AL,DL            ;..from current record count
  192.     MOV    Byte Ptr .fcbcrr,AL    ;..and store in current record count
  193.     MOV    AL,Byte Ptr .fcbcrr+1    ;same with high order byte
  194.     SBB    AL,DH            ;..but with borrow
  195.     JS    filbeg            ;if beyond beginning of file, go zero count
  196.     MOV    Byte Ptr .fcbcrr+1,AL    ;else, store high order byte
  197.     CALL    filbuf            ;fill the buffer
  198.     MOV    BX,fulbuf        ;..and point to end of buffer
  199.     CALL    clrscr            ;clear the screen
  200.     JMPS    wrtbak2            ;continue moving back in file
  201. ;                
  202. filbeg:    XOR    AL,AL            ;if beyond beginning of file
  203.     MOV    Byte Ptr .fcbcrr,AL    ;..zero the current record field
  204.     MOV    Byte Ptr .fcbcrr+1,AL
  205.     MOV    Byte Ptr lincnt,AL    ;..and the line count
  206.     CALL    filbuf            ;fill the buffer again
  207.     JMP    wrtfwd            ;..and go write it
  208. ;
  209. filbuf:    MOV    DX,(Offset dskbuf)    ;load start of disk buffer
  210.     MOV    CH,maxsec        ;number of sectors to resd
  211.     MOV    BX,0            ;zero out the
  212.     MOV    Word Ptr seccnt,BX    ;..number of sectors in buffer
  213. filbuf1:PUSH    BX            ;save all
  214.     PUSH    DX            ;..registers from
  215.     PUSH    CX            ;..BDOS clobber
  216.     MOV    CL,stdma        ;set dma to
  217.     INT    224            ;..disk buffer
  218.     MOV    DX,fcb            ;set up to read
  219.     MOV    CL,readr        ;..a record
  220.     INT    224            ;do it
  221.     CMP    AL,0            ;read OK?
  222.     MOV    BX,Word Ptr .fcbcrr    ;get current record number
  223.     LAHF                ;..bump it
  224.     INC    BX
  225.     SAHF
  226.     MOV    Word Ptr .fcbcrr,BX    ;..and save it
  227.     MOV    BX,Word Ptr seccnt    ;get sectors in buffer
  228.     LAHF                ;bump it
  229.     INC    BX
  230.     SAHF
  231.     MOV    Word Ptr seccnt,BX    ;store it
  232.     JNZ    rderr            ;no, last sector read
  233.     POP    CX            ;yes, get sector count
  234.     DEC    CH            ;decrement it
  235.     POP    DX            ;get de off stack to expose return address
  236.     POP    BX            ;
  237.     JNZ    L_4    
  238.     RET                ;if done return
  239. L_4:
  240.     MOV    BX,128            ;else, add 128 to
  241.     ADD    BX,DX            ;..dma address
  242.     XCHG    BX,DX            ;put it in de
  243.     JMPS    filbuf1            ;read another sector
  244. ;
  245. rderr:    POP    CX            ;restore
  246.     POP    DX            ;..registers
  247.     POP    BX            ;..and
  248.     XOR    AL,AL            ;..get a zero to direct to start of buffer
  249.     RET                ;..on ret
  250. ;
  251. opnfil:    MOV    AL,Byte Ptr .fcbfn    ;point to first letter of filename
  252.     CMP    AL,' '            ;anything there?
  253.     JZ    help            ;no, give help message
  254.     MOV    DX,fcb            ;file name in default fcb
  255.     MOV    CL,open            ;set up to open
  256.     INT    224            ;do it
  257.     CMP    AL,0ffh            ;open OK?
  258.     JZ    L_5    
  259.     RET                ;yes
  260. ;
  261. L_5:    mov    dx,offset mes2
  262.     call    prnstr
  263.     JMP    exit1            ;leave msg on screen on exit
  264. ;
  265. help:    mov    dx,offset mes3
  266.     call    prnstr
  267.     JMP    exit1
  268. ;
  269. prnstr:    push    bx            ;print string
  270.     push    cx
  271.     mov    cl,9
  272.     int    224
  273.     pop    cx
  274.     pop    bx
  275.     ret
  276. ;
  277. ctype:    PUSH    CX            ;Save the registers
  278.     PUSH    DX            ;..from bdos
  279.     PUSH    BX            ;..clobber
  280.     CMP    AL,'O'-40H        ;wordstar uses ^O
  281.     JNE    NOTCO            ;as non-break space
  282.     MOV    AL,' '            ;..so substitute space
  283. NOTCO:    AND    AL,7FH            ;strip hi-bit
  284.     MOV    DL,AL            ;set up character
  285.     MOV    CL,wrcon        ;..to send to console
  286.     INT    224            ;do it
  287.     POP    BX            ;restore
  288.     POP    DX            ;..the registers
  289.     POP    CX
  290.     RET
  291. ;
  292. exit:    CALL    clrscr            ;clear the screen
  293. exit1:    MOV    CL,0            ;warm boot
  294.     MOV    DL,0
  295.     INT    224
  296. L_6    EQU    $
  297.     DSEG
  298.     ORG    Offset L_6
  299. ;
  300. ;
  301. mes1    DB    cr,lf,lf,'Use the SCRL keys (or ^C,^R) to go forward and '
  302.     DB    'backward, or X to exit.',cr,bell,'$'
  303. ;
  304. mes2    DB    cr,lf,lf,'Requested file is not on this disk.',cr,lf,bell
  305.     DB    'Please check your spelling or use DIR.',cr,lf,lf,bell,'$'
  306. ;
  307. mes3    DB    'Correct usage of SHOW',lf,lf
  308.     DB    '    A>SHOW filename  ',cr,lf,lf
  309.     DB    'After first page is displayed, use SCRL down (^C) to go'
  310.     DB    ' forward',cr,lf
  311.     DB    'and SCRL up (^R) for backward, or X to exit.'
  312.     DB    cr,lf,lf,bell,'$'
  313. ;
  314. ; Memory allocation
  315. ;
  316. seccnt    DW    0            ;number of sectors read into buffer
  317. linmax    DB    24            ;number of to write lines on console
  318. lincnt    DB    0            ;line number on write or move back in buffer
  319. dskbuf    EQU    (Offset $)        ;disk buffer area above the program
  320. fulbuf    EQU    (Offset dskbuf)+(maxsec*128)    ;need to know end of buffer
  321. ;
  322.     END
  323.