home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / grafik / shadow / shadow.asm < prev    next >
Encoding:
Assembly Source File  |  1993-02-02  |  11.4 KB  |  238 lines

  1. ;; SHADOW.ASM - Fast video shadow box window example.
  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 02/01/93
  10. ;;
  11. ;; CIS: 72230,1306
  12. ;;-----------------------------------------------------
  13. ;;
  14. code                    SEGMENT
  15. ASSUME          cs:code, ds:code, es:code, ss:code
  16. ORG             100h                                ; COM files begin here
  17. start:
  18.         jmp     begin                               ; go show off
  19. ;;
  20. ;;-----------------------------------------------------
  21. ;; Equates
  22. scrn_columns            EQU     80      ; dealing with 80 columns
  23. shadow_row1             EQU     6       ; starting row for side shadow
  24. shadow_col1             EQU     69      ; starting column for side shadow
  25. shadow_row2             EQU     19      ; starting row for bottom shadow
  26. shadow_col2             EQU     14      ; starting column for bottom shadow
  27. shad_length1            EQU     14      ; side shadow length
  28. shad_length2            EQU     55      ; bottom shadow length
  29. shadow_color            EQU     8       ; shadow color attribute value
  30. bkgrd_char              EQU     0FB1h   ; character and color for background
  31. window_color            EQU     31      ; brite white on blue
  32. window_length           EQU     57      ; window length 
  33. ;; Data
  34. EVEN
  35. save_cursor             DW      0       ; save cursor location for exit
  36. video_seg               DW      0       ; storage for video segment address
  37. ;;
  38. window                  DB      '╔═══════════════════════════════════════════════════════╗'
  39.                         DB      '║                 Public Domain Code by                 ║'
  40.                         DB      '║             ▄▄▄▄   ▄   ▄   ▄   ▄▄▄▄ ▄▄▄▄▄             ║'
  41.                         DB      '║           ──█──────█───█───█─ █    ──█──────────    ║'
  42.                         DB      '║        ─────█▄▄▄───█─█─█─ █ ──█▄▄────█─────         ║'
  43.                         DB      '║                █   █ █ █   █   █      █               ║'
  44.                         DB      '║    ────────────█─  █ █ ───█───█───  █ - WARE.       ║'
  45.                         DB      '║             ▀▀▀▀    ▀ ▀    ▀   ▀      ▀               ║'
  46.                         DB      '║                                                       ║'
  47.                         DB      '║                   William  Cravener                   ║'
  48.                         DB      '║                  520 N. Stateline Rd.                 ║'
  49.                         DB      '║                   Sharon, Pa. 16146                   ║'
  50.                         DB      '║                    CIS: 72230,1306                    ║'
  51.                         DB      '╚═══════════════════════════════════════════════════════╝'
  52. ;;
  53. ;;-----------------------------------------------------
  54. ;; Code
  55. begin:
  56.         mov     ah, 0fh                         ; BIO's get -
  57.         int     10h                             ; current video mode
  58.         cmp     al, 7                           ; if 7 its monochrome
  59.         je      mono_vid                        ; go setup for it
  60.         mov     video_seg, 0b800h               ; no-it be color mode
  61.         jmp     video_out                       ; skip over mono
  62. mono_vid:
  63.         mov     video_seg, 0b000h               ; monochrome segment
  64. video_out:
  65.         mov     ah, 3
  66.         mov     bh, 0                           ; retrieve cursor
  67.         int     10h                             ; start location
  68.         mov     save_cursor, dx                 ; save it for exit
  69.  
  70.         mov     ah, 2                           ; set cursor
  71.         mov     bh, 0                           ; page 0
  72.         mov     dx, 1900h                       ; off screen
  73.         int     10h
  74.  
  75.         call    save_current_screen             ; save a copy of screen
  76.  
  77.         push    es                              ; push ES on stack
  78.         mov     ax, video_seg                   ; load AX with video seg
  79.         mov     es, ax                          ; ES now points to it
  80.         xor     di, di                          ; zero out offset pointer
  81.         mov     cx, 2000                        ; one screen full to fill
  82.         mov     ax, bkgrd_char                  ; character and color
  83.         rep     stosw                           ; store it to video
  84.         pop     es                              ; restore ES
  85.  
  86.         mov     dh, 5                           ; starting row
  87.         mov     dl, 12                          ; and column
  88.         mov     si, OFFSET window               ; point to example window
  89.         mov     cx, 14                          ; write 14 rows total
  90. boxloop:
  91.         call    fast_write                      ; fast screen writes
  92.         inc     dh                              ; increment row
  93.         loop    boxloop                         ; go write next line
  94.  
  95.         call    window_shadows                  ; now shadow the window
  96.  
  97.         mov     ah, 0                           ; wait for user
  98.         int     16h                             ; to press a key
  99.  
  100.         call    restore_current_screen          ; restore original screen
  101.  
  102.         mov     ah, 2                           ; set cursor
  103.         mov     bh, 0                           ; page 0
  104.         mov     dx, save_cursor                 ; original location
  105.         int     10h
  106.  
  107.         int     20h                             ; exit to DOS
  108. ;;
  109. ;;**************************************
  110. ;;  Very fast video write 
  111. fast_write:
  112.         push    es 
  113.         push    cx                              ; save used registers
  114.         push    dx
  115.         call    calculate_video_address         ; calculate video address
  116.         mov     cx, window_length               ; length of window box
  117. window_loop:
  118.         lodsb                                   ; get box character 
  119.         mov     ah, window_color                ; color value to use
  120.         stosw                                   ; store character and color
  121.         loop    window_loop                     ; get all box characters
  122.         pop     dx 
  123.         pop     cx                              ; restore used registers
  124.         pop     es
  125.         ret
  126. ;;
  127. ;;**********************************
  128. ;;  Shadows right side and bottom side of window
  129. window_shadows:
  130.         mov     dh, shadow_row1                 ; starting row of side
  131.         mov     dl, shadow_col1                 ; starting column of side
  132.         mov     bp, 2                           ; need 2 column rows
  133. nxt_shadow:
  134.         mov     cx, shad_length1                ; length of columns
  135. shad_back1:
  136.         call    get_char                        ; change character to shadow
  137.         inc     dh                              ; increment to next
  138.         loop    shad_back1                      ; repeat until done
  139.         mov     dh, shadow_row1                 ; starting row of side 
  140.         mov     dl, shadow_col1                 ; starting column of side
  141.         inc     dl                              ; move to next column
  142.         dec     bp                              ; decrement 2 column count
  143.         cmp     bp, 0                           ; did 2 columns ?
  144.         jnz     nxt_shadow                      ; no-do next
  145.                                                 ; done-get ready for bottom
  146.         mov     dh, shadow_row2                 ; starting row of bottom
  147.         mov     dl, shadow_col2                 ; starting column of bottom
  148.         mov     cx, shad_length2                ; length of bottom row
  149. shad_back2: 
  150.         call    get_char                        ; change character to shadow
  151.         inc     dl                              ; increment to next
  152.         loop    shad_back2                      ; repeat until done
  153.         ret
  154. ;;
  155. ;;**********************************
  156. ;;  Get one character from video -
  157. ;;   change its attribute to shadow color
  158. get_char:
  159.         push    dx
  160.         push    ds                              ; save used registers
  161.         push    es
  162.         call    calculate_video_address         ; calculate video address
  163.         mov     si, di                          ; zero out SI
  164.         mov     ax, es                          ; need DS same
  165.         mov     ds, ax                          ; as ES segment
  166.         lodsw                                   ; retrieve character
  167.         mov     ah, shadow_color                ; change color value to -
  168.         stosw                                   ; shadow color and return it
  169.         pop     es
  170.         pop     ds                              ; restore used registers
  171.         pop     dx 
  172.         ret
  173. ;;
  174. ;;**********************************
  175. ;;  Calculates video offset address
  176. ;;  enter with  DH = row  DL = column
  177. ;;  returns with  DI = video offset  ES = video segment
  178. calculate_video_address:
  179.         mov     ax, video_seg                   ; current video segment
  180.         mov     es, ax                          ; need it in ES register
  181.         xor     ax, ax                          ; zero out AX
  182.         xor     bx, bx                          ; zero out BX
  183.         mov     al, dh                          ; place row in AL
  184.         xor     dh, dh                          ; zero out DH
  185.         mov     di, dx                          ; place column in DI
  186.         mov     bl, scrn_columns                ; dealing with 80 columns
  187.         mul     bx                              ; mutiply
  188.         add     di, ax                          ; add to columns
  189.         shl     di, 1                           ; offset of video memory
  190.         ret
  191. ;;
  192. ;;**********************************
  193. ;;  Store a copy of original video screen in buffer
  194. save_current_screen:
  195.         push    ds                              ; save DS on stack
  196.         mov     di, OFFSET storage              ; point DI at storage
  197.         mov     ax, video_seg                   ; video segment
  198.         mov     ds, ax                          ; place in DS
  199.         xor     si, si                          ; zero SI
  200.         mov     cx, 2000                        ; one screen full
  201.         rep     movsw                           ; store character and color
  202.         pop     ds                              ; done-restore DS
  203.         ret
  204. ;;
  205. ;;**********************************
  206. ;;  Restore copy of original video screen from buffer
  207. restore_current_screen:
  208.         push    es                              ; save ES on stack
  209.         mov     si, OFFSET storage              ; point SI at storage
  210.         mov     ax, video_seg                   ; video segment
  211.         mov     es, ax                          ; place in ES
  212.         xor     di, di                          ; zero out DI
  213.         mov     cx, 2000                        ; one screen full
  214.         rep     movsw                           ; restore character and color
  215.         pop     es                              ; done-restore ES
  216.         ret
  217. ;;
  218. ;;**********************************
  219. ;;
  220. storage:                                        ; store video screen
  221. ;;                                              ; at the end of coding
  222. ;;**********************************
  223. ;;  Optional method would be -
  224. ;;  to use a 4000 byte buffer.
  225. ;;
  226. ;; Example:
  227. ;;      storage         DB      4000 DUP (0)    ; video buffer storage
  228. ;;
  229. ;;
  230. ;;**********************************
  231. ;;
  232. code                    ENDS                    ; end of coding
  233.  
  234. END             start
  235.  
  236.  
  237.  
  238.