home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / kaypro / dump1084.mac < prev    next >
Text File  |  1994-07-13  |  8KB  |  231 lines

  1. ;**************************************************************************
  2. ;***                                                                    ***
  3. ;***                    Screen to printer DUMP                          ***
  4. ;***          Kaypro 10 Version copyright (c) 1984 Reliable Software    ***
  5. ;***            This program can be freely used and distributed for     ***
  6. ;***              Non Commercial purposes                               ***
  7. ;***       Micro Cornucopia Release 2.4    New 4 version 3/14/84        ***
  8. ;***                        2.5    Remove hard address for      ***
  9. ;***                           kbdin     DmC  5/7/84    ***
  10. ;***                    2.6    Fix addressing for new       ***
  11. ;***                                       u board  (subtle bug)        ***
  12. ;***                                 DmC 5/10/84        ***
  13. ;**************************************************************************
  14. ; initialize patch by copying to FF10h
  15.  
  16.     ASEG
  17.     .z80
  18.     org     100h
  19.  
  20.     FALSE    equ    0000
  21.     TRUE    equ    NOT FALSE
  22.  
  23. ;************************************************************************
  24. ;*                                    *
  25. ;*    Set the following equate as appropriate for your system        *
  26. ;*                                    *
  27. ;*    New Kaypro 4 - 0F600h                        *
  28. ;*    Kaypro 10    - 0EA00h                        *
  29. ;*                                    *
  30.     bios    equ    0EA00h        ;BIOS base page            *
  31. ;*                                    *
  32. ;************************************************************************
  33.  
  34. conin    equ    bios + 0Ah
  35. vidout    equ    bios + 0Ch
  36. prntout    equ    bios + 0Fh
  37.  
  38.     ld    de,(conin)        ; make sure we don't patch twice
  39.     ld    a,d
  40.     cp    0ffh
  41.     jr    z,allred        ; jump here if program already in MEM
  42.  
  43.     ld    de,0ff10h        ; destination address
  44.     ld    hl,code            ; source address
  45.     ld    bc,codend-0ff10h    ; length of patch
  46.     ldir
  47.  
  48. ; initialize bios by changing the conin jump table entry to jump to this 
  49. ; program first to see if screen dump desired
  50.  
  51.     ld    de,(conin)
  52.     ld    (kbdin),de
  53.     ld    hl,entry        ; this is our conin jump entry
  54.     ld    (conin),hl        ; patch into bios jump table
  55.  
  56.     ld    de,MSG            ; tell user we are on line
  57.     ld    c,9            ; bdos print string function
  58.     call    5            ; calling Mr. Bdos
  59.     ret                ; takes us back to CCP control
  60.  
  61. MSG:     db    'Screen Print On$'
  62.  
  63. allred:    ld    de,ALR            ; tell user already on line
  64.     ld    c,9            ; bdos print string function
  65.     call    5            ; call Bdos Brothers
  66.  
  67.     ret                ; to CCP control
  68.  
  69. ALR:    db     'Screen Print Already On$'     
  70.  
  71.  
  72. ; main body of dump code....................................................
  73. ;
  74. ; This program intercepts any bios CONIN call and replaces the return address
  75. ; with a return to here. This code tests for 1Ch ( cntrl-backslash ) from the
  76. ; keyboard and dumps the screen memory to the printer if true. Any other key
  77. ; hit is passed to the calling program by jumping to the address originally
  78. ; located at conin vector. Absolute addresses are used to prevent problems
  79. ; caused if User were to run the dumpscreen installation twice...............
  80.   
  81. code    equ    $
  82.  
  83.     .phase    0FF10h
  84.  
  85. entry:    db    0CDh            ; call op code
  86. kbdin:    ds    2            ; get keyboard character
  87.     cp    00h            ; if ^W will dump screen
  88.     ret    nz            ; else will return normally
  89.  
  90. ;**************************************************************************
  91. ;***    Now the actual screen dumping is done                           ***
  92. ;***                                                                    ***
  93. ;**************************************************************************
  94.  
  95.  
  96.     ld    c,27            ; remember cursor position
  97.     call    vidout            ;
  98.     ld    c,'B'            
  99.     call    vidout
  100.     ld    c,'6'
  101.     call    vidout
  102.  
  103. main:    ld    c,27            ; move cursor to 0,0 (home position) 
  104.     call    vidout
  105.     ld    c,'='
  106.     call    vidout
  107.     ld    c,32            ; <---: not a fixed number
  108. row    equ    $-1            ; this keeps track of row we are
  109.     call    vidout            ; dumping 
  110.     ld    c,32
  111.     call    vidout
  112.  
  113. ; Now we find out where we are in video memory and pick up the address
  114.  
  115.     ld    a,14            ; select crtc register 14
  116.     out    (1Ch),a            ; (cursor position)
  117.     in    a,(1Dh)            ; read in cursor pos H
  118.     and    7            ; not to exceed 800h
  119.     ld    h,a
  120.     ld    a,15            ; select video register 15 (CUR pos)
  121.     out    (1CH),a            
  122.     in    a,(1Dh)            ; read in cursor position to L
  123.     ld    l,a
  124.     ld    d,80            ; chars/line
  125.     call    advid
  126.  
  127. ; The Kaypro model 10 and the new 4 use the 6545 intelligent video controller
  128. ; This chip contains various control registers which can be used to set
  129. ; cursor characteristics, to interface a light pen, and to load/unload data
  130. ; to video memory, Thhese Kaypros comunicate with video memory via I/O ports
  131. ; as illustrated above. Although the 6545 can address 16K of video memory
  132. ; ( actually more in special setups ) the Kaypros use 2048 bytes for storing
  133. ; the screen. The other 2K of video memory present on the Kaypro board is
  134. ; used for the storage of video attributes. The Kaypro bios contains a
  135. ; variable for storing the address of row 0, column 0. This is used to 
  136. ; calculate all cursor postioning. This variable is incremented by 80 each
  137. ; time the screen is scrolled one line. This technique allows wrapping
  138. ; around the 2K of video memory rather than assigning fixed addresses to
  139. ; every screen location.
  140. ;
  141. ;
  142. ; The 6545 allows loading/unloading of video data by accessing a dummy
  143. ; register (31). Every access of 31 causes the update address to be
  144. ; incremented by one. The first version of this program used this feature
  145. ; but characters were lost when the wrap at 800h occurred. ????????
  146. ;..........................................................................
  147. ; The next 3 instructions were commented out because the time required    :
  148. ; to complete the loop is sufficient to insure that the 6845 status will  :
  149. ; indicate ready. When using quicker loops ( such as saving the screen to :
  150. ; memory) the staus register must be polled                               :
  151. ; This version actually uncomments these lines                            :
  152. ;..........................................................................
  153.  
  154. l1:    in    a,(1Ch)            ; get status
  155.     or    a            ; ready if bit 7 high
  156.     jp    p,l1
  157.  
  158. l2:    in    a,(1Fh)            ; attempt a read
  159.     cp    20h            ; everthing in video memory should 
  160.     jp    m,l2            ; be greater than 20h
  161.     ld    c,a
  162.     CALL    print            ; this routine dumps one char to  
  163.                     ; the printer
  164.     inc    hl            ; bump video address counter
  165.     ld    a,8            ; check for wrap at 800h
  166.     cp    h
  167.     jp    nz,nowrap        ; not yet:: jump over next two inst. 
  168.  
  169.     ld    hl,00            ; start over at 0
  170.     call    advid            ; set 0 as new address
  171.  
  172. nowrap:    dec    d            ; now check to see if we got
  173.     jr    z,lindon        ; all characters on the line
  174.                     ; if so we will do a carriage return
  175.                     ; line feed
  176.     jp    l1            ; else get next character
  177.  
  178. lindon:    call    CRLF            ; done with line
  179.     ld    d,80            ; char count for next line
  180.     ld    a,(row)            ; update row count
  181.     inc    a
  182.     ld    (row),a
  183.     cp    57            ; last row (rows begin at 32) 
  184.     jp    nz,main            ; nope do more
  185.  
  186. done:    call    CRLF            ;linefeed to flush buffer
  187.     call    prntout
  188.     ld    c,27
  189.     call    vidout
  190.     ld    c,'C'
  191.     call     vidout
  192.     ld    c,'6'
  193.     call    vidout
  194.     ld    a,32
  195.     ld    (row),a            ;re initialize (row) for next dump
  196.     jp    entry            ;return for next char
  197.  
  198.  
  199. CRLF:    ld    c,0dh            ;routine to output newline
  200.     call    print
  201.     ld    c,0ah
  202.     call    print
  203.     ret
  204.  
  205. print:    push    af            ; routine to put char to LST: device
  206.     push    bc
  207.     push    de
  208.     push    hl
  209.     call    prntout
  210.     pop    hl
  211.     pop    de
  212.     pop    bc
  213.     pop    af
  214.     ret
  215.  
  216. advid:    ld    a,18            ; routine to give address in hl
  217.                     ; to Video controller
  218.     out    (1Ch),a
  219.     ld    a,h
  220.     out    (1Dh),a
  221.     ld    a,19
  222.     out    (1Ch),a
  223.     ld    a,l
  224.     out    (1Dh),a
  225.     ld    a,31
  226.     out    (1Ch),a
  227.     ret
  228.     nop
  229. codend    equ    $
  230.     end
  231.