home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / mike40c / scrn.asm < prev    next >
Encoding:
Assembly Source File  |  1986-10-23  |  4.3 KB  |  169 lines

  1. page ,132
  2.         title    movscrn.asm - no snow screen update routine
  3.  
  4. ;************************************************************************
  5. ;* No-snow screen display routine                        *
  6. ;*  This routine moves screen data from a user buffer to the         *
  7. ;*  screen buffer during horizontal retrace time, resulting in            *
  8. ;*  no screen flicker.                                     *
  9. ;*                                         *
  10. ;* definition:  void putscrn (char *, int);                     *
  11. ;* definition:  void getscrn (char *, int);                     *
  12. ;* calling sequence:  putscrn (buffer, video page);                *
  13. ;*   where:  buffer = (character, attribute) array, 2 * 80 * 25 (4000)    *
  14. ;*           video page = Text page to move buffer to                   *
  15. ;*   returns: void                                *
  16. ;*                                        *
  17. ;* note: designed for use with Microsoft 'C' (4.0)                *
  18. ;*     : set switches PROG, DATA for memory model type                *
  19. ;*                                        *
  20. ;* edit date: 9/30/86          by Mike Elkins                    *
  21. ;* release: 2.0                                                         *
  22. ;************************************************************************
  23.  
  24. SMALL    =    0        ;near
  25. LARGE    =    1        ;far
  26. PROG    =    SMALL        ;set this as req'd  ***
  27. DATA    =    SMALL        ;set this as req'd  ***
  28.  
  29. _text        segment    byte public 'code'
  30.         assume    cs:_text
  31.  
  32.         public    _putscrn,_getscrn
  33.         if    PROG
  34. _putscrn    proc    far
  35.         else
  36. _putscrn    proc    near
  37.         endif
  38.  
  39. ; buffer = +4
  40. ; page = +6
  41.         push    bp            ;save calling environment
  42.         mov    bp,sp
  43.         push    si
  44.         push    di
  45.  
  46.           mov    ah,15            ;get current mode
  47.            int    10h            ;system video
  48.               mov    dx,3BAh            ;monochrome port address
  49.              mov    di,0            ;offset for monochrome buffer
  50.            cmp    al,7            ;is b/w?
  51.             je    put001                  ;no pages for mono
  52.         mov    dx,3DAh            ;color port
  53.         mov    di,8000h        ;offset for color buffer
  54.                 mov     ax,[bp+6]               ;get page
  55.                 cmp     ax,0
  56.                 je      put001
  57.                 mov     di,9000h                ;page 1
  58.                 cmp     ax,1
  59.                 je      put001
  60.                 mov     di,0A000h               ;page 2
  61.                 cmp     ax,2
  62.                 je      put001
  63.                 mov     di,0B000h               ;page3
  64.  
  65. put001:        mov    ax,0B000h
  66.         mov    es,ax
  67.  
  68.         if    DATA
  69.         push    ds
  70.         lds    si,[bp+4]
  71.         else
  72.         mov    si,[bp+4]        ;source buffer pointer
  73.         endif
  74.         mov    cx,80*25        ;block length
  75.  
  76. put002:        in    al,dx            ;screen status
  77.         test    al,1            ;is 'high'?
  78.         jnz    put002            ;yes - wait
  79. put004:        in    al,dx            ;screen status
  80.         test    al,1            ;is 'low'?
  81.         jz    put004            ;yes - wait
  82.         movsw                ;mov 2 bytes to screen
  83.                                                 ;ds:si -> es:di
  84.         loop    put002            ;do until done
  85.  
  86.         if    DATA
  87.         pop    ds
  88.         endif
  89.         pop    di
  90.         pop    si
  91.         pop    bp
  92.         ret
  93.  
  94. _putscrn    endp
  95.  
  96.         if    PROG
  97. _getscrn    proc    far
  98.         else
  99. _getscrn    proc    near
  100.         endif
  101.  
  102. ; buffer = +4
  103.  
  104.         push    bp            ;save calling environment
  105.         mov    bp,sp
  106.         push    si
  107.         push    di
  108.         push    ds
  109.         push    es
  110.  
  111.          mov    ah,15            ;get current mode
  112.          int    10h            ;system video
  113.          mov    dx,3BAh            ;monochrome port address
  114.          mov    si,0            ;offset for monochrome buffer
  115.          cmp    al,7            ;is b/w?
  116.          je    get001
  117.         mov    dx,3DAh            ;color port
  118.         mov    si,8000h        ;offset for color buffer
  119.                 mov     ax,[bp+6]               ;get page
  120.                 cmp     ax,0
  121.                 je      get001
  122.                 mov     si,9000h                ;page 1
  123.                 cmp     ax,1
  124.                 je      get001
  125.                 mov     si,0A000h               ;page 2
  126.                 cmp     ax,2
  127.                 je      get001
  128.                 mov     si,0B000h               ;page3
  129.  
  130.  
  131. get001:        mov    ax,0B000h
  132.         push    ds
  133.                 pop     es
  134.         mov    ds,ax
  135.  
  136.         if    DATA
  137.         les    di,[bp+4]
  138.         else
  139.         mov    di,[bp+4]        ;source buffer pointer
  140.         endif
  141.         mov    cx,80*25        ;block length
  142.  
  143. get002:        in    al,dx            ;screen status
  144.         test    al,1            ;is 'high'?
  145.         jnz    get002            ;yes - wait
  146. ;get003:        cli                ;the timing is very tight - no interruption wanted
  147. get004:        in    al,dx            ;screen status
  148.         test    al,1            ;is 'low'?
  149.         jz    get004            ;yes - wait
  150.         movsw                ;mov 2 bytes to screen
  151.                                                 ;ds:si -> es:di
  152. ;        sti
  153.         loop    get002            ;do until done
  154.  
  155.         pop    es
  156.         pop    ds
  157.         pop    di
  158.         pop    si
  159.         pop    bp
  160.         ret
  161.  
  162. _getscrn    endp
  163.  
  164. _text        ends
  165.  
  166.         end
  167.  
  168.  
  169.