home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / sfast / fast.asm next >
Assembly Source File  |  1992-11-29  |  8KB  |  159 lines

  1. ;; FAST.ASM - Super fast direct video writing.
  2. ;;
  3. ;; This program can be assembled using the A86 or TASM assemblers 
  4. ;;
  5. ;; Not tested with Masm, should work?
  6. ;;
  7. ;; This code is "PUBLIC DOMAIN"
  8. ;;
  9. ;; by William Cravener 11/28/92
  10. ;;
  11. ;-----------------------------------------------------------------------------
  12. ;;
  13. code                    SEGMENT
  14. ASSUME          cs:code, ds:code, es:code, ss:code
  15. ORG             100h                                ; COM files begin here
  16. start:
  17.         jmp     begin                               ; go show off
  18. ;;
  19. ;-----------------------------------------------------
  20. ;;
  21. columns                 EQU     80      ; dealing with 80 columns
  22. ;;
  23. video_seg               DW      0       ; video segment
  24. status_reg              DW      0       ; status register
  25. string_length           DW      0       ; string length (can be any length)
  26. color_to_use            DB      0       ; color values
  27. row                     DB      0       ; screen rows
  28. column                  DB      0       ; screen column
  29. colorflag               DB      0       ; equal 1 for snow checking
  30. ;;                                      ; otherwise it equals 0
  31. ;;
  32. test_string1            DB      '    This is a Test String     This is a Test String     This is a Test String   '
  33. test_string2            DB      '   Super Fast Video Writes   Super Fast Video Writes   Super Fast Video Writes  '
  34. ;;
  35. ;-----------------------------------------------------
  36. ;;
  37. begin:
  38.         call    get_video                       ; get current video state
  39. begin1:
  40.         mov     si, OFFSET test_string1         ; first example string
  41.         mov     string_length, 80               ; length is 80 characters
  42.         mov     dh, row                         ; place row in DH
  43.         mov     dl, column                      ; place column in DL
  44.         call    fast_write                      ; call fast write 
  45.         cmp     row, 24                         ; have we reach 24 rows ?
  46.         je      over1                           ; yes - go write next example
  47.         inc     row                             ; no - increment row 
  48.         jmp     begin1                          ; go setup for next row
  49. over1:
  50.         mov     ah, 2                           ; set cursor off screen
  51.         mov     bh, 0                           ; while we delay for 
  52.         mov     dx, 1900h                       ; a short bit 
  53.         int     10h
  54.         call    delay                           ; go delay a second 
  55.         mov     row, 0                          ; set row to top
  56.         inc     color_to_use                    ; increment color value
  57. begin2:
  58.         mov     si, OFFSET test_string2         ; second example string
  59.         mov     string_length, 80               ; length is 80 characters
  60.         mov     dh, row                         ; place row in DH
  61.         mov     dl, column                      ; place column in DL
  62.         call    fast_write                      ; call fast write 
  63.         cmp     row, 24                         ; have we reach 24 rows ?
  64.         je      over2                           ; yes - go check for key press
  65.         inc     row                             ; no - increment row
  66.         jmp     begin2                          ; go setup for next row
  67. over2:
  68.         mov     ah, 2                           ; set cursor off screen
  69.         mov     bh, 0                           ; while we delay for
  70.         mov     dx, 1900h                       ; a short bit
  71.         int     10h
  72.         call    delay                           ; go delay a second
  73.         mov     row, 0                          ; set row to top
  74.         inc     color_to_use                    ; increment color value
  75.         mov     ah, 1                           ; check to see -
  76.         int     16h                             ; if user pressed any key
  77.         jz      begin1                          ; no - go to begin1
  78.         int     20h                             ; yes - exit to DOS
  79. ;;
  80. ;;**************************************
  81. ;; very fast video write 
  82. fast_write:
  83.         push    es                              ; save ES register
  84.         mov     ax, video_seg                   ; current video segment
  85.         mov     es, ax                          ; need it in ES for STOSW
  86.         xor     ax, ax                          ; zero out AX
  87.         xor     bx, bx                          ; zero out BX
  88.         mov     al, dh                          ; place row in AL
  89.         xor     dh, dh                          ; zero out DH
  90.         mov     di, dx                          ; place column in DI
  91.         mov     bl, columns                     ; dealing with 80 columns
  92.         mul     bx                              ; mutiply
  93.         add     di, ax                          ; add to columns
  94.         shl     di, 1                           ; offset of video memory
  95.         mov     cx, string_length               ; length of string to write
  96.         mov     ah, color_to_use                ; color value to use
  97. string_loop:
  98.         cmp     colorflag, 0                    ; if = 1 check for retrace
  99.         je      noneed                          ; if = 0 skip to noneed
  100.         mov     dx, status_reg                  ; status register
  101.         cli                                     ; disable interrupts
  102. @low:
  103.         in      al, dx                          ; get port value
  104.         test    al, 1
  105.         jnz     @low                            ; if not zero
  106. @high:
  107.         in      al, dx                          ; get port value
  108.         test    al, 1
  109.         jz      @high                           ; if zero
  110.         sti                                     ; enable interrupts
  111. noneed:
  112.         lodsb                                   ; get character
  113.         stosw                                   ; store character and color
  114.         loop    string_loop                     ; get all 80 character
  115.         pop     es                              ; restore ES register
  116.         ret
  117. ;;
  118. ;;**********************************
  119. ;;  gets video information needed by "fast_write"
  120. get_video:
  121.         mov     ah, 0fh                         ; BIO's get
  122.         int     10h                             ; current video mode
  123.         cmp     al, 7                           ; if 7 its monochrome
  124.         je      mono_vid                        ; go setup for it
  125.         mov     video_seg, 0b800h               ; must be a color mode
  126.         mov     status_reg, 03dah               ; segment and status
  127.         mov     color_to_use, 1                 ; begin with blue on black
  128.         jmp     video_out                       ; leave
  129. mono_vid:
  130.         mov     video_seg, 0b000h               ; segment
  131.         mov     status_reg, 03bah               ; status
  132.         mov     color_to_use, 1                 ; doesn't really matter 
  133. video_out:
  134.         ret
  135. ;;
  136. ;-------------------------------
  137. ;;  1 second delay 
  138. delay:
  139.         push    es                              ; save ES
  140.         mov     ax, 40h                         ; BIO's
  141.         mov     es, ax                          ; segment
  142.         mov     bx, 6ch                         ; tick count
  143.         mov     ax, es:[bx]                     ; place in AX
  144.         mov     cx, 18                          ; about 1 second
  145. dl1:
  146.         cmp     ax, es:[bx]                     ; are they equal
  147.         je      dl1                             ; yes 
  148.         mov     ax, es:[bx]                     ; no get new count
  149.         loop    dl1                             ; loop for 18
  150.         pop     es                              ; restore ES
  151.         ret
  152. ;;
  153. ;-------------------------------
  154. ;;
  155. code                    ENDS                    ; end of coding
  156.  
  157. END             start
  158.  
  159.