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

  1. ;**************************************************************************
  2. ;***                                                                    ***
  3. ;***    Screen Dump for the Kaypro 2 and older Kaypro 4's               ***
  4. ;***           Original Version Micro Cornucopia Magazine               ***
  5. ;***                    Adapted for Kaypro by Monte T. Schmiege         ***
  6. ;***        Micro Cornucopia Release 1.....M80 coding...DmC         ***
  7. ;***                 Release 2.....Removed hard address     ***
  8. ;***                           for KBDIN so it will     ***
  9. ;***                           run on both BIOS Versions***
  10. ;***                           DmC 5/9/84               ***
  11. ;***                                                                    ***
  12. ;**************************************************************************
  13.  
  14.     .z80
  15.  
  16.     CR    equ    0Dh            ; Ascii carriage return
  17.     LF    equ    0Ah            ; Ascii line feed
  18.     CHAR    equ    017h            ; dump scrn char ( CNTL W )
  19.     CPM    equ    05h            ; BDOS
  20.     CRTMEM    equ    03000h            ; begin CRT memory
  21.     BITDAT    equ    1Ch            ; system bit port
  22.  
  23.     CONIN    equ    0FA0Ah
  24.     BIOSLST    equ    0FA0FH            ; BIOS LST: output
  25.     SDADDR    equ    0E300H            ; address of screen dump code
  26.     OFFSET    equ    SDADDR-SDBEG        ; offset for address calc
  27.  
  28.  
  29.     ASEG
  30.     ORG    100h
  31.  
  32. ; Set up local stack 
  33.  
  34.     ld    hl,0                ; zero hl register
  35.     add    hl,sp                ; pickup stack pointer
  36.     ld    (STSTOR),hl            ; save the pointer
  37.     ld    sp,SCRSTK            ; set up local stack
  38.  
  39.     ld    a,char                ; plug dump screen character
  40.     ld    (dchar),a            ; into routine here for easy
  41.                         ; patching later
  42.  
  43. ; Do block move of screen dump code ***************************************
  44.  
  45.     ld    hl,(conin)
  46.     ld    a,h
  47.     cp    0E3h
  48.     jr    z,allred            ; already loaded
  49.     
  50.     ld    c,9                ; print string function
  51.     ld    de,MSG                ; message pointer
  52.     call    5                ; call BDOS
  53.  
  54.     ld    hl,SDBEG            ; beginning of screen dump
  55.                         ; code is source
  56.     ld    de,SDADDR            ; destination for code
  57.     ld    bc,SDEND-SDBEG            ; byte count for LDIR
  58.  
  59.     ldir                    ; move the code to high mem
  60.  
  61. ; Setup new vector and change top of TPA address **************************
  62.  
  63.     ld    hl,CPM                ; source code address
  64.     ld    de,SDADDR            ; destination address
  65.     ld    bc,3                ; byte count
  66.  
  67.     ldir                    ; move jump vector
  68.  
  69.     ld    hl,SDADDR            ; take address of new vector
  70.     ld    (CPM+1),hl            ; replace old vector
  71.  
  72.     ld    hl,(conin)            ; get conin vector
  73.     ld    (kbdin+OFFSET),hl        ; and load into our code
  74.     ld    hl,SDADDR+3            ; address of new conin
  75.     ld    (conin),hl            ; patch old conin vector
  76.  
  77. getbak:    ld    hl,(STSTOR)            ; get old stack pointer
  78.     ld    sp,hl                ; put it back
  79.     ret                    ; go back to CCP control
  80.  
  81. MSG:    'Installing Screen Dump$'
  82. MSG1:    'Screen Dump Already Installed$'
  83.  
  84. allred:    ld    c,9
  85.     ld    de,MSG1
  86.     call    5
  87.     jr    getbak    
  88.  
  89. SDBEG:    jp    0                ; patch in address later
  90. SCRDMP:    DB    0CDH
  91. KBDIN:    DS    2                ; get key board character
  92.     push    hl                ;
  93.     ld    hl,DCHAR+OFFSET            ; see if screen dump char
  94.     cp    (hl)
  95.     pop    hl
  96.     ret    nz                ; return if not screendump
  97.  
  98. SCR:    ld    (STSTOR+OFFSET),sp        ; save the stack pointer
  99.     ld    sp,SCRSTK+OFFSET        ; new stack pointer
  100.     push    hl
  101.     push    de
  102.     push    bc
  103.     push    ix
  104.     ld    hl,CRTMEM            ; hl gets start of CRTMEM
  105.     ld    a,018h
  106.     ld    (LCNT+OFFSET),a            ; load a with lines/screen
  107.  
  108. SCR2:    push    hl                ; save the starting location
  109.     pop    ix                ; save hl in ix
  110.     ld    b,50h                ; b gets character count
  111. SCR3:    DI                    ; disable interrupts during 
  112.                         ; other memory bank access
  113.     in    a,(BITDAT)            ; switch memory bank to
  114.     set    7,a                ; bank where CRT memory 
  115.     out    (BITDAT),a            ; resides...............
  116.     ld    c,(hl)                ; get char from CRT memory
  117.     in    a,(BITDAT)            ; back to normal memory bank
  118.     res    7,a
  119.     out    (BITDAT),a
  120.     EI                    ; reenable interrupts 
  121.     inc    hl                ; point to next character
  122.     push    hl                ; save pointer
  123.     push    bc                ; save character count
  124.     res    7,C                ; clear high bit ( in case 
  125.                         ; the cursor was here )
  126.  
  127.     call    BIOSLST                ; character to printer
  128.     pop    bc                ; get character counter
  129.     pop    hl                ; get character pointer
  130.     djnz    SCR3                 ; repeat til line is done
  131.     call    CRLF+OFFSET            ; and new line at end 
  132.  
  133. NXTLN:    push    ix                ; get start back to hl
  134.     pop    hl
  135.     ld    a,(LCNT+OFFSET)            ; find out where we are 
  136.     dec    a                ; bump line counter
  137.     ld    (LCNT+OFFSET),a
  138.     jr    z,FIN                ; if line count = 0 we are 
  139.     ld    de,080h                ; de gets logical line length
  140.     or    a
  141.     add    hl,de                ; hl points to next line
  142.     jr    SCR2                ; do another line
  143.  
  144.  
  145. ; Finish Screen Dump ******************************************************
  146.  
  147. FIN:    call    CRLF+OFFSET
  148.     pop    ix
  149.     pop    bc
  150.     pop    de
  151.     pop    hl
  152.     ld    sp,(STSTOR+OFFSET)        ; restore stack
  153.     jr    SCRDMP                ; done dumping get next key-
  154.                         ; board character
  155.  
  156. ; Newline Routine *********************************************************
  157.  
  158. CRLF:    ld    c,CR
  159.     CALL    BIOSLST    
  160.     ld    c,LF
  161.     call    BIOSLST
  162.     ret
  163.  
  164. ; High memory Scratch Ram *************************************************
  165.  
  166.     LCNT:    defs    1
  167.     DCHAR:    defs    1
  168.     STSTOR:    defs    2
  169.         defs    24
  170.     SCRSTK:    defs    2
  171.     SDEND:    DEFS    1            ; end of program
  172.  
  173. ;**************************************************************************
  174.     end
  175.  
  176.  
  177.