home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / baswind4.arj / NEWVID.ASM < prev    next >
Assembly Source File  |  1987-12-29  |  5KB  |  122 lines

  1.  
  2. igroup        group     Newvid_TEXT
  3.               assume    cs: igroup
  4.               public    SCRNSAVE,SCRNREST,SCRNBUFF
  5. Newvid_TEXT   segment   word public 'CODE'
  6.  
  7. SCRNSAVE      proc      far
  8.               jmp       near ptr codego
  9.  
  10.               even                            ; Align buffer on word!
  11. SCRNBUFF      dw        2010 dup(0bbh)        ; 10 extra byte guard
  12.  
  13. codego:       push      bp                    ;Save for BASIC
  14.               mov       bp,sp                 ;
  15.               push      ds
  16.               push      es                    ;
  17.               push      di
  18.               push      si
  19.               call      GET_SET
  20.               push      es                    ;Put ES in DS
  21.               pop       ds                    ; since we are moving from screen
  22.               mov       si, seg Newvid_TEXT   ; Set buffer segment!
  23.               mov       es, si
  24.               xor       si,si                 ;Set source index to 0
  25.               mov       di, offset Newvid_TEXT:SCRNBUFF
  26.               call      GO                    ;do it
  27.               pop       si
  28.               pop       di
  29.               pop       es
  30.               pop       ds
  31.               pop       bp
  32.               ret
  33. SCRNSAVE      endp
  34.  
  35. SCRNREST      proc      far
  36.               push      bp
  37.               mov       bp,sp
  38.               push      ds
  39.               push      es
  40.               push      di
  41.               push      si
  42.               mov       si, seg Newvid_TEXT   ; Get buffer
  43.               mov       ds, si                ;      segment!
  44.               mov       si, offset Newvid_TEXT:SCRNBUFF
  45.               xor       di,di                 ; Set destination index to 0
  46.               call      GET_SET
  47.               call      GO
  48.               pop       si
  49.               pop       di
  50.               pop       es
  51.               pop       ds
  52.               pop       bp
  53.               ret
  54. SCRNREST      endp
  55.  
  56. GET_SET       proc      near
  57.  
  58.               mov  ax,0
  59.               mov  ah,15                      ;Video mode BIOS Call
  60.               int  010H                       ;Do the BIOS Call
  61.               cmp  al,07H                     ;See if it's Monochrome
  62.               jz   is_mono                    ;Yes
  63.               mov  ax,0B800H                  ;Set it up for C/G
  64.               jmp  ok                         ;
  65. is_mono:      mov  ax,0B000H                  ;Set it up for Monochrome
  66.  
  67. ok:           mov       es,ax
  68.               cld                             ; set up for auto increment
  69.               mov       ah,6                  ; number of blocks to copy
  70.               ret
  71. GET_SET       endp
  72.  
  73. GO            proc      near
  74.  
  75. begin:        mov       cx,240                ; number of words to move during VRTCE
  76.               mov       dx,3DAH               ; C/G adapter status port
  77.               cli                             ; disable interrupts
  78.  
  79. wait_vert_refresh:
  80.  
  81.               in        al,dx                 ; read status
  82.               test      al,8                  ; test vertical retrace bit
  83.               jnz       wait_vert_refresh     ; loop until in refresh
  84.  
  85. wait_vert_retrace:
  86.  
  87.               in        al,dx                 ;read status
  88.               test      al,8                  ;test vertical retrace bit
  89.               jz        wait_vert_retrace     ;loop until retrace starts
  90.               rep       movsw                 ;move a block of words
  91.  
  92.               mov       cx,188                ;number of bytes to move during
  93.                                               ;horizontal retrace periods
  94.               mov       dx,3DAH
  95.  
  96. wait_horiz_refresh:
  97.  
  98.               in        al,dx                 ;read status
  99.               test      al,1                  ;test horizontal retrace bit
  100.               jnz       wait_horiz_refresh    ;loop until in a retrace
  101.  
  102. wait_horiz_retrace:
  103.  
  104.               in        al,dx                 ;read status
  105.               test      al,1                  ;test horizontal retrace bit
  106.               jz        wait_horiz_retrace    ;loop until retrace starts
  107.               movsb                           ;copy a byte
  108.               loop      wait_horiz_refresh
  109.  
  110.               sti
  111.               dec       ah                    ;reduce the block count
  112.               cmp       ah,0                  ;done?
  113.               jnz       short begin
  114.  
  115.               ret
  116.  
  117. GO            endp
  118.  
  119. Newvid_TEXT   ends
  120.               end
  121. 
  122.