home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1990 / 10 / dtp / postshot.asm next >
Encoding:
Assembly Source File  |  1990-08-18  |  7.7 KB  |  276 lines

  1. ;***********************************************************
  2. ;*  POSTSHOT.ASM:       PostScript-Snapshot für MCGA-Modus *
  3. ;*  Assemblieren mit Microsoft MASM ab Version 5.0 oder    *
  4. ;*  einem kompatiblen Assembler.                           *
  5. ;*  Anschließend EXE-File mit dem DOS-Programm EXE2BIN in  *
  6. ;*  ein COM-File umwandeln.                                *
  7. ;*  (C) 1990 Ulrich Schmitz & TOOLBOX                      *
  8. ;***********************************************************
  9.  
  10. TITLE POSTSHOT.ASM
  11.  
  12. intnr     equ 5h                        ;PrintScreen-Vektor
  13. CR        equ 13
  14. LF        equ 10
  15. Kopfbytes equ 324
  16. ;-------------------------  M A K R O S --------------------
  17.  
  18. CR_LF MACRO
  19. ;- CR und LF in Datei schreiben
  20.           mov bx, Handle
  21.           mov cx, 2                     ;20 Bytes
  22.           mov ax, CS
  23.           mov DS, ax
  24.           mov ah, 40h                   ;Funktionsnummer
  25.           mov dx, OFFSET Crlf
  26.           int 21h                       ;Datei beschreiben
  27. ENDM
  28.  
  29. GET_VIDEO MACRO
  30. ;- liest den Videomodus aus
  31.           mov ah, 0Fh
  32.           int 10h
  33. ENDM
  34.  
  35. ;-----------------------------------------------------------
  36. code segment para
  37.      assume  cs:code, ds:code, es:code
  38.      org     100h
  39.  
  40. anfang:
  41.      jmp  install
  42.  
  43. ;--- Daten -------------------------------------------------
  44.  
  45. intsave   EQU THIS DWORD
  46. Handle    DW '??'
  47. Dateiname DB 'PICTURE.EPS', 0
  48.  
  49.  
  50. ;-- Kopfdaten
  51. Kopf      DB '%!PS-Adobe-2.0 EPSF-1.2', CR, LF
  52.           DB '%%BoundingBox:  27 540 387 765', CR, LF
  53.           DB '%%Creator: POSTSHOT by'
  54.           DB ' Ulrich Schmitz & toolbox', CR, LF
  55.           DB '%%Title: PICTURE.EPS', CR, LF
  56.           DB '%%EndComments' , CR, LF
  57.           DB 'gsave', CR, LF
  58.           DB '/picstr 320 string def', CR, LF
  59.           DB '27 765 moveto', CR, LF
  60.           DB '360 225 scale', CR, LF
  61.           DB '0 -1 rmoveto', CR, LF
  62.           DB 'currentpoint translate', CR, LF
  63.           DB '320 200 8', CR, LF
  64.           DB '[320 0 0 -200 0 200]', CR, LF
  65.           DB '{ currentfile picstr readhexstring pop }'
  66.           DB CR, LF
  67.           DB 'image', CR, LF
  68. ;-- 20 Bytes Kopfende
  69. Kopfende  DB 'grestore', CR, LF
  70.           DB 'showpage', CR, LF
  71. Punkt     DB '*'
  72. Crlf      DB 13, 10
  73. Zeile     DB 1
  74. Vga       DW 0A000h           ;VGA-Bildschirmadresse
  75. Z_Offset  DW 0
  76. Kennung   DW '**'
  77.  
  78. ;--- Eigene Interruptroutine -------------------------------
  79. einsprung:
  80.           pushf
  81.           push ax
  82.           push bx
  83.           push cx
  84.           push dx
  85.           push di
  86.           push si
  87.           push ES
  88.           push DS
  89.  
  90.  
  91. ;--- richtiger Videomodus? ---------------------------------
  92.           GET_VIDEO
  93.           cmp al, 13h        ;256 Farben, 320 x 200 Punkte
  94.           je los_gehts
  95.           jmp bye_bye        ;unzulässiger Video-Modus
  96. los_gehts:
  97. ;--- Datei anlegen -----------------------------------------
  98.           mov ah, 3Ch
  99.           mov bx, CS
  100.           mov DS, bx
  101.           mov dx, OFFSET Dateiname
  102.           mov cx, 0
  103.           int 21h
  104.           mov Handle, ax
  105.  
  106. ;--- Postscript-Kopf schreiben (für 8 Bit/Punkt, 320 x 200)
  107.           mov bx, Handle
  108.           mov cx, Kopfbytes             ;Anzahl Kopf-Bytes
  109.           mov ax, CS
  110.           mov DS, ax
  111.           mov ah, 40h                   ;Funktionsnummer
  112.           mov dx, OFFSET Kopf
  113.           int 21h                       ;Datei beschreiben
  114.  
  115. ;--- Bilddaten aus Bildschirmspeicher schreiben ------------
  116.  
  117.           sub di, di
  118.           mov ax, Vga
  119.           mov ES, ax                    ;ES initialisieren
  120. anfang_1:
  121.           mov bx, CS:Z_Offset
  122.           mov al, ES:[di+bx]
  123.           mov cl, 4                     ;um 4 Bits
  124.           shr al, cl                    ;0000 1111
  125.           sub si, si                    ;si = 0
  126.           mov ah, 0
  127.   weiter_1:
  128.           cmp ax, si
  129.           je ende_1
  130.           inc si
  131.           jmp weiter_1
  132.   ende_1:
  133.           add al, 48                    ;+48 -> ASCII-Wert
  134.           cmp al, 57                    ;Wert 0 - 9
  135.           jle ende_11
  136.           add al, 7                     ;Wert A - F
  137.   ende_11:
  138.           mov Punkt, al
  139.  
  140. ;--- high Halb-Byte in Datei schreiben ---------------------
  141.           mov bx, Handle
  142.           mov cx, 1                     ;1 Byte
  143.           mov ax, CS
  144.           mov DS, ax
  145.           mov ah, 40h                   ;Funktionsnummer
  146.           mov dx, OFFSET Punkt
  147.           int 21h                       ;Datei beschreiben
  148.  
  149. anfang_2:
  150.           mov ax, Vga
  151.           mov ES, ax
  152.           mov bx, CS:Z_Offset
  153.           mov al, ES:[di+bx]
  154.           mov cl, 4                     ;um 4 Bits
  155.           shl al, cl                    ;Punktbyte in ax
  156.           mov cl, 4
  157.           shr al, cl                    ;Halbbyte isoliert
  158.           sub si, si                    ;si = 0
  159.           mov ah, 0
  160.   weiter_2:
  161.           cmp ax, si
  162.           je ende_2
  163.           inc si
  164.           jmp weiter_2
  165.   ende_2:
  166.           add al, 48                    ;+48 -> ASCII-Wert
  167.           cmp al, 57                    ;Wert 0 - 9
  168.           jle ende_22
  169.           add al, 7
  170.   ende_22:
  171.           mov Punkt, al
  172.  
  173. ;--- low Halb-Byte in Datei schreiben ----------------------
  174.           mov bx, Handle
  175.           mov cx, 1            ;1 Byte
  176.           mov ax, CS
  177.           mov DS, ax
  178.           mov ah, 40h          ;Funktionsnummer
  179.           mov dx, OFFSET Punkt
  180.           int 21h              ;Datei beschreiben
  181.  
  182. ;------**
  183.           inc di
  184.           cmp di, 320          ;eine Zeile (320 Bytes)
  185.           jl anfang_1
  186.           CR_LF                ;Carriage Return und Linefeed
  187.           CR_LF
  188.           mov ah, 0
  189.           mov al, CS:Zeile
  190.           cmp ax, 200          ;ganzes Bild gespeichert?
  191.           jge fertig
  192.           inc al
  193.           mov CS:Zeile, al
  194.           mov ax, CS:Z_Offset
  195.           add ax, 320          ;di + Zeilen_Offset + ES
  196.           mov CS:Z_Offset, ax
  197.           sub di, di
  198.           jmp anfang_1
  199. fertig:
  200.           CR_LF
  201.  
  202. ;--- Kopf-Ende schreiben
  203.           mov bx, Handle
  204.           mov cx, 20                    ;20 Bytes
  205.           mov ax, CS
  206.           mov DS, ax
  207.           mov ah, 40h                   ;Funktionsnummer
  208.           mov dx, OFFSET Kopfende
  209.           int 21h                       ;Datei beschreiben
  210.  
  211.  
  212. ;--- Datei schließen ! ------
  213.           mov ah, 3Eh
  214.           mov bx, Handle
  215.           int 21h
  216.  
  217. ;----------------------------
  218.  
  219. bye_bye:
  220.  
  221. ;--- Variablen zurücksetzen
  222.           mov CS:Zeile ,1
  223.           mov CS:Z_Offset ,0
  224.           mov CS:Vga ,0A000h
  225.  
  226.           pop DS
  227.           pop ES
  228.           pop si
  229.           pop di
  230.           pop dx
  231.           pop cx
  232.           pop bx
  233.           pop ax
  234.           popf
  235.  
  236.           iret
  237. ;--- bis hier wird das Programm resident gelassen !! -------
  238. install:
  239.  
  240. ;--- Vektor frei? - - - - - - - - - - - - - - - - - - - -
  241.      mov ah, 35h
  242.      mov al, intnr
  243.      int 21h                  ;Get Interrupt Vektor
  244.      mov al, ES:[bx]          ;Anfang Interrupt-Routine
  245.      cmp al, 0CFh             ;IRET ?
  246.      je continue              ;installiere Programm
  247.  
  248. ;--- Programm schon installiert? - - - - - - - - - - - -
  249.      dec bx                   ;residente Daten sind vor Code
  250.      mov al, ES:[bx]
  251.      cmp al, '*'              ;schon installiert?
  252.      jne continue
  253.      mov ah, 4Ch
  254.      int 21h                  ;Programm beenden
  255.  
  256. continue:
  257. ;--- INT auf eigene Routine verbiegen
  258.      mov dx,offset einsprung
  259.      mov ax,2500h+intnr
  260.      int 21h
  261.  
  262. ;--- Anzahl der resident bleibenden Paragraphen berechnen
  263.      mov dx,offset install
  264.      mov cl,4
  265.      shr dx,cl
  266.      inc dx
  267.      
  268.      mov ax,3100h
  269.      int 21h
  270.  
  271. code ends
  272.      end anfang
  273.  
  274. ;** ENDE POSTSHOT.ASM **************************************
  275.           
  276.