home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / murutil / snap.asm < prev    next >
Encoding:
Assembly Source File  |  1988-01-10  |  3.6 KB  |  127 lines

  1.     PAGE    57,132
  2.     TITLE    SNAP -- Screen Snapshot Program.
  3.     NAME    SNAP
  4. ;
  5. ;    This program takes a "snapshot" of the current screen  display
  6. ;    and writes it to SNAP.0nn, where "SNAP.0nn" is the next avail-
  7. ;    able file in the series SNAP.001, SNAP.002, . . . SNAP.099.
  8. ;
  9. ;    If there are more than 99 SNAP files, the program aborts.
  10. ;
  11. ;    Program by Harry M. Murphy,  29 December 1986.
  12. ;    Version:  10 January 1988.
  13. ;
  14.     .RADIX    10
  15. BEL    EQU    07H        ;ASCII bell code.
  16. CR    EQU    0DH        ;Carriage Return code.
  17. CTLZ    EQU    1AH        ;Control-Z code.
  18. DOS    EQU    21H        ;DOS interrupt.
  19. LF    EQU    0AH        ;Line Feed code.
  20. VIDEO    EQU    0B800H        ;Start of video memory.
  21. ;
  22. SNAP    SEGMENT 'CODE'
  23.     ORG    100H
  24.     ASSUME    CS:SNAP,DS:SNAP,ES:SNAP
  25. ;
  26. START:    JMP    BEGIN
  27. ;
  28. FHANDLE    DW    0
  29. VERNUM    DW    0
  30. ENDMSG    DB    '>>>>>>>>>> Screen snapshot written to '
  31. FNAME    DB    'SNAP.000',0,CR,LF,'$'
  32. VERERR    DB    'Too many SNAP outputs!  (SNAP.001 ==> SNAP.099!)'
  33.     DB    CR,LF,BEL,'$'
  34. OPNERR    DB    'OPEN ERROR!',CR,LF,'$'
  35. WRTERR    DB    'WRITE ERROR!',CR,LF,'$'
  36. CLSERR    DB    'CLOSE ERROR!',CR,LF,'$'
  37.     EVEN
  38. ;
  39. BEGIN:    MOV    BX,25            ;BX counts the 25 rows.
  40.     MOV    AX,VIDEO        ;ES points to
  41.     MOV    ES,AX            ;  the video buffer segment.
  42.     XOR    AX,AX            ;SI indexes the
  43.     MOV    SI,AX            ;  video buffer and
  44.     MOV    DI,AX            ;    DI indexes the output buffer.
  45. ;
  46. L1:    MOV    CX,80            ;Main loop starts here.
  47. ;                    ;Initialize CX for 80 columns.
  48. L2:    MOV    AL,BYTE PTR ES:[SI]    ;Copy byte from video buffer
  49.     MOV    BUFFER[DI],AL        ;  to output buffer via AL.
  50.     INC    SI            ;Video buffer consists of double
  51.     INC    SI            ;  bytes;  increment twice.
  52.     INC    DI            ;Increment output buffer
  53.     LOOP    L2            ;  and loop for 80 columns.
  54. ;
  55. L3:    DEC    DI            ;Scan the output
  56.     CMP    BUFFER[DI],' '        ;  buffer for last non-blank
  57.     JE    L3            ;    character.
  58. ;
  59.     INC    DI            ;Append
  60.     MOV    BUFFER[DI],CR        ;  CR
  61.     INC    DI            ;    and
  62.     MOV    BUFFER[DI],LF        ;      LF.
  63.     INC    DI            ;Increment index,
  64.     DEC    BX            ;  decrement row count and
  65.     JNZ    L1            ;    loop for next row.
  66. ;
  67.     MOV    BUFFER[DI],CTLZ        ;Append final Control-Z.
  68.     INC    DI            ;DI = final byte count.
  69. ;
  70. OPEN:    INC    VERNUM            ;Increment the file version
  71.     MOV    AX,VERNUM        ;  number and copy to AX.
  72.     MOV    DX,OFFSET VERERR    ;If more than
  73.     CMP    AX,99            ;  99 versions,
  74.     JA    EXIT            ;    abort with an error message.
  75. ;
  76.     MOV    BL,10            ;Load BL with decimal divisor.
  77.     DIV    BL            ;Translate the
  78.     ADD    AH,'0'            ;  file
  79.     MOV    FNAME+7,AH        ;    version
  80.     XOR    AH,AH            ;      number
  81.     DIV    BL            ;        into the
  82.     ADD    AH,'0'            ;          file
  83.     MOV    FNAME+6,AH        ;            extension.
  84.     MOV    AX,4300H        ;Use "get file attribute"
  85.     MOV    DX,OFFSET FNAME        ;  to ensure that the
  86.     INT    DOS            ;    file doesn't already
  87.     JNC    OPEN            ;      exist.
  88. ;
  89.     MOV    AH,3CH            ;Open
  90.     XOR    CX,CX            ;  output
  91.     MOV    DX,OFFSET FNAME        ;    file,
  92.     INT    DOS            ;      SNAP.0nn.
  93.     MOV    DX,OFFSET OPNERR    ;If error, exit with
  94.     JC    EXIT            ;  error message.
  95. ;
  96.     MOV    FHANDLE,AX        ;Save the file handle.
  97. ;
  98. WRITE:    MOV    AH,40H            ;Write
  99.     MOV    BX,FHANDLE        ;  output
  100.     MOV    CX,DI            ;    buffer
  101.     MOV    DX,OFFSET BUFFER    ;      to output
  102.     INT    DOS            ;        file.
  103.     JNC    CLOSE            ;If OK, skip to close.
  104. ;
  105.     MOV    DX,OFFSET WRTERR    ;If not,
  106.     MOV    AH,09H            ;  output an
  107.     INT    DOS            ;    error message.
  108. ;
  109. CLOSE:    MOV    AH,3EH            ;Close
  110.     MOV    BX,FHANDLE        ;  the output
  111.     INT    DOS            ;    file.
  112.     MOV    DX,OFFSET CLSERR    ;If error, exit
  113.     JC    EXIT            ;  with error message.
  114. ;
  115. DONE:    MOV    FNAME+8,'.'        ;Replace zero byte with ".".
  116.     MOV    DX,OFFSET ENDMSG    ;"Snapshot written" message.
  117. ;
  118. EXIT:    MOV    AH,09H            ;Display
  119.     INT    DOS            ;  message and
  120.     MOV    AX,4C00H        ;    terminate
  121.     INT    DOS            ;      this process.
  122. ;
  123. BUFFER0    DB    0    ;BUFFER MUST be preceded by a zero byte and
  124. BUFFER    DB    0    ;  MUST be the last data block in SNAP.
  125. SNAP    ENDS
  126.     END    START
  127.