home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / pchdemo.zip / SOURCEFA.ZIP / SOURCE.ASM < prev    next >
Assembly Source File  |  1992-10-29  |  4KB  |  167 lines

  1. ;       Assemblerroutine SOURCE.ASM
  2. ;
  3. ;       Mit dieser Routine wird ein Bild digitalisiert und in den
  4. ;       anzugebenen Rambereich geschrieben.
  5. ;
  6. ;       Die Pixel sind wie folgt aufgebaut:
  7. ;               1.Pixel Bit 0..2 = B-Y (LSB)    Bit 3..7 = SW 1.Pixel
  8. ;               2.Pixel Bit 0..2 = B-Y (MSB)    Bit 3..7 = SW 2.Pixel
  9. ;               3.Pixel Bit 0..2 = R-Y (LSB)    Bit 3..7 = SW 3.Pixel
  10. ;               4.Pixel Bit 0..2 = R-Y (MSB)    Bit 3..7 = SW 4.Pixel
  11. ;
  12. ;
  13. ;       Der Digitalisierbereich beträgt horizontal 384 Pixel. In BL
  14. ;       kann der Startpunkt, ab wann digitalisiert werden soll, angegeben
  15. ;       werden (0 = ganz links).
  16. ;
  17. ;       Vertikal beträgt der Digitalisierbereich 288 Zeilen. In BH
  18. ;       kann die Startzeile angegeben werden (0 = 1.Zeile).
  19. ;
  20. ;       Folgende Parameter müssen übergeben werden:
  21. ;
  22. ;       AL      =       Kontrast 0..31 (normal 15)
  23. ;       BL      =       Startpixel 0..255
  24. ;       BH      =       Startzeile 0..255
  25. ;       CX      =       Bildgröße horizontal
  26. ;       DX      =       Bildgröße vertikal
  27. ;       ES:DI   =       Buffer des Bildes (Größe = CX * DX Bytes)
  28. ;
  29. ;       Rückgabewert
  30. ;
  31. ;       Wenn Carry gelöscht dann OK
  32. ;
  33. ;       Wenn Carry gesetzt und AX = 1  Kein Videosignal
  34. ;
  35.  
  36. .186
  37.  
  38. code    segment public
  39.  
  40. assume  cs:code
  41.  
  42. public  digit
  43.  
  44. ;       In anderen Jumperstellungen müssen die entsprechenden Adressen angege-
  45. ;       ben werden.
  46.  
  47.     Data    =    300h    ; I/O Adresse zum Einlesen der Pixel
  48.  
  49.     FF    =    302h    ; Register      Bit 0..4 = Kontrast
  50.                 ;               Bit 6  0 = Color
  51.                 ;                      1 = SW
  52.                                 ;               Bit 7  0 = Speicher 1
  53.                 ;                      1 = Speicher 2
  54.  
  55.     Reset    =    304h    ; 304 = Hor.Reset und ver.Zeilenzähler
  56.                 ; 305 = Ver.Reset
  57.  
  58.     Hbin    =    306h    ; 0 = 1.Halbbild
  59.                 ; 1 = 2.Halbbild
  60.  
  61. digit   proc near
  62.     jmp    digit0
  63. kontrast    db    0
  64. ram        db    0
  65. digit0:
  66.     push    bx
  67.     push    cx
  68.     push    dx
  69.     push    di
  70.     push    si
  71.     push    es
  72.     mov    cs:kontrast,al
  73.     call    rec            ; Bild digitalisieren
  74.         call    save_pic                ; Bild auslesen
  75.     pop    es
  76.     pop    si
  77.     pop    di
  78.     pop    dx
  79.     pop    cx
  80.     pop    bx
  81.     ret
  82. ;
  83. ;       Digitalisieren eines Bildes
  84. ;
  85. rec:
  86.     push    cx
  87.     push    dx
  88.     xor    byte ptr cs:ram,128    ; Auf das andere RAM umschalten
  89.         mov     dx,FF
  90.     mov    al,cs:kontrast        ; Kontrast nach AL
  91.     or    al,cs:ram        ; Bit 7 = RAM
  92.     out    dx,al            ; AL ausgeben
  93.     mov    dx,Hbin
  94.     mov    cx,0
  95. rec11:
  96.     dec    cx
  97.         jz      rec19
  98.     in    al,dx
  99.     and    al,1
  100.     jnz    rec11            ; Auf Ende des 1.Halbbildes warten
  101. rec12:
  102.     dec    cx
  103.         jz      rec19
  104.     in    al,dx
  105.     and    al,1
  106.     jz    rec12            ; Auf Ende des 2.Halbbildes warten
  107. rec13:
  108.     pop    dx
  109.     pop    cx
  110.     ret
  111. rec19:
  112.     mov    ax,1            ; Kein Videosignal
  113.     stc
  114.     pop    dx
  115.     pop    cx
  116.     ret
  117. ;
  118. ;       Übertragen eines Bildes in das RAM des Rechners
  119. ;
  120. save_pic:
  121.     push    es
  122.     push    di
  123.     mov    si,dx            ; Vertikal nach SI
  124.     mov    dx,Reset
  125.     in    ax,dx            ; Hor. + Ver. Reset
  126.     mov    ah,bh            ; Zeilen nach AH
  127.     add    ah,21            ; + 21 Leerzeilen
  128. save10:
  129.     in    al,dx            ; Vertikal + 1
  130.     dec    ah
  131.     jnz    save10
  132. save11:
  133.     push    cx            ; Horizontal retten
  134.         mov     dx,Data
  135.     mov    bh,bl            ; Startpixel / 4
  136.     shr    bh,1
  137.     shr    bh,1
  138.     inc    bh            ; + Dummy
  139. save12:
  140.     in    ax,dx
  141.     in    ax,dx
  142.     dec    bh
  143.     jnz    save12
  144.     shr    cx,1            ; Horizontal / 2
  145.     rep    insw            ; Pixel übertragen
  146.         mov     dx,Reset
  147.     in    al,dx            ; Hor. Reset + Vertikal + 1
  148.     pop    cx
  149.     push    cx
  150.     sub    di,cx
  151.     shr    cx,1
  152.     shr    cx,1
  153.     shr    cx,1
  154.     shr    cx,1
  155.     mov    ax,es
  156.     add    ax,cx
  157.     mov    es,ax
  158.     pop    cx
  159.     dec    si
  160.     jnz    save11
  161.     pop    di
  162.         pop     es
  163.     ret
  164. digit   endp
  165. code    ends
  166. end
  167.