home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / sfast / window.asm < prev    next >
Assembly Source File  |  1992-11-29  |  7KB  |  149 lines

  1. ;; WINDOW.ASM - Super fast direct video windows.
  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      57      ; string length (can be any length)
  26. color_to_use            DB      0       ; color values
  27. row                     DB      6       ; screen row
  28. column                  DB      12      ; screen column
  29. colorflag               DB      0       ; equal 1 for snow checking
  30. ;;                                      ; otherwise it equals 0
  31. ;;
  32. window                  DB      '╔═══════════════════════════════════════════════════════╗'
  33.                         DB      '║                    Public Domain by                   ║'
  34.                         DB      '║             ▄▄▄▄   ▄   ▄   ▄   ▄▄▄▄ ▄▄▄▄▄             ║'
  35.                         DB      '║           ──█──────█───█───█─ █    ──█──────────    ║'
  36.                         DB      '║        ─────█▄▄▄───█─█─█─ █ ──█▄▄────█─────         ║'
  37.                         DB      '║                █   █ █ █   █   █      █               ║'
  38.                         DB      '║    ────────────█─  █ █ ───█───█───  █ - WARE.       ║'
  39.                         DB      '║             ▀▀▀▀    ▀ ▀    ▀   ▀      ▀               ║'
  40.                         DB      '║                                                       ║'
  41.                         DB      '║                   William  Cravener                   ║'
  42.                         DB      '║                  520 N. Stateline Rd.                 ║'
  43.                         DB      '║                   Sharon, Pa. 16146                   ║'
  44.                         DB      '║                    CIS: 72230,1306                    ║'
  45.                         DB      '╚═══════════════════════════════════════════════════════╝'
  46.  
  47. ;;
  48. ;-----------------------------------------------------
  49. ;;
  50. begin:
  51.         call    get_video                       ; get current video state
  52.         mov     si, OFFSET window               ; point to example
  53.         mov     bp, 14                          ; write 14 rows total
  54. boxloop:
  55.         mov     dh, row                         ; current row
  56.         mov     dl, column                      ; and column
  57.         call    fast_write                      ; fast screen writes
  58.         inc     row                             ; increment row
  59.         dec     bp                              ; do 14 rows total
  60.         jnz     boxloop                         ; go write next
  61.                                                 ; all finished
  62.         mov     ah, 2                           ; set cursor off screen
  63.         mov     bh, 0                           ; while we -
  64.         mov     dx, 1900h 
  65.         int     10h
  66.         mov     ah, 0                           ; wait for user
  67.         int     16h                             ; to press a key
  68.         int     20h                             ; yes - exit to DOS
  69. ;;
  70. ;;**************************************
  71. ;; very fast video write 
  72. fast_write:
  73.         push    es                              ; save ES register
  74.         mov     ax, video_seg                   ; current video segment
  75.         mov     es, ax                          ; need it in ES for STOSW
  76.         xor     ax, ax                          ; zero out AX
  77.         xor     bx, bx                          ; zero out BX
  78.         mov     al, dh                          ; place row in AL
  79.         xor     dh, dh                          ; zero out DH
  80.         mov     di, dx                          ; place column in DI
  81.         mov     bl, columns                     ; dealing with 80 columns
  82.         mul     bx                              ; mutiply
  83.         add     di, ax                          ; add to columns
  84.         shl     di, 1                           ; offset of video memory
  85.         mov     cx, string_length               ; length of string to write
  86.         mov     ah, color_to_use                ; color value to use
  87. string_loop:
  88.         cmp     colorflag, 0                    ; if = 1 check for retrace
  89.         je      noneed                          ; if = 0 skip to noneed
  90.         mov     dx, status_reg                  ; status register
  91.         cli                                     ; disable interrupts
  92. @low:
  93.         in      al, dx                          ; get port value
  94.         test    al, 1
  95.         jnz     @low                            ; if not zero
  96. @high:
  97.         in      al, dx                          ; get port value
  98.         test    al, 1
  99.         jz      @high                           ; if zero
  100.         sti                                     ; enable interrupts
  101. noneed:
  102.         lodsb                                   ; get character
  103.         stosw                                   ; store character and color
  104.         loop    string_loop                     ; get all 80 character
  105.         pop     es                              ; restore ES register
  106.         ret
  107. ;;
  108. ;;**********************************
  109. ;;  gets video information needed by "fast_write"
  110. get_video:
  111.         mov     ah, 0fh                         ; BIO's get
  112.         int     10h                             ; current video mode
  113.         cmp     al, 7                           ; if 7 its monochrome
  114.         je      mono_vid                        ; go setup for it
  115.         mov     video_seg, 0b800h               ; must be a color mode
  116.         mov     status_reg, 03dah               ; segment and status
  117.         mov     color_to_use, 15                ; brite white
  118.         jmp     video_out                       ; leave
  119. mono_vid:
  120.         mov     video_seg, 0b000h               ; segment
  121.         mov     status_reg, 03bah               ; status
  122.         mov     color_to_use, 15                ; brite white 
  123. video_out:
  124.         ret
  125. ;;
  126. ;-------------------------------
  127. ;;  1 second delay 
  128. delay:
  129.         push    es                              ; save ES
  130.         mov     ax, 40h                         ; BIO's
  131.         mov     es, ax                          ; segment
  132.         mov     bx, 6ch                         ; tick count
  133.         mov     ax, es:[bx]                     ; place in AX
  134.         mov     cx, 18                          ; about 1 second
  135. dl1:
  136.         cmp     ax, es:[bx]                     ; are they equal
  137.         je      dl1                             ; yes 
  138.         mov     ax, es:[bx]                     ; no get new count
  139.         loop    dl1                             ; loop for 18
  140.         pop     es                              ; restore ES
  141.         ret
  142. ;;
  143. ;-------------------------------
  144. ;;
  145. code                    ENDS                    ; end of coding
  146.  
  147. END             start
  148.  
  149.