home *** CD-ROM | disk | FTP | other *** search
- ;; SHADOW.ASM - Fast video shadow box window example.
- ;;
- ;; This program can be assembled using the A86 or TASM assemblers
- ;;
- ;; Not tested with Masm, should work?
- ;;
- ;; This code is "PUBLIC DOMAIN"
- ;;
- ;; by William Cravener 02/01/93
- ;;
- ;; CIS: 72230,1306
- ;;-----------------------------------------------------
- ;;
- code SEGMENT
- ASSUME cs:code, ds:code, es:code, ss:code
- ORG 100h ; COM files begin here
- start:
- jmp begin ; go show off
- ;;
- ;;-----------------------------------------------------
- ;; Equates
- scrn_columns EQU 80 ; dealing with 80 columns
- shadow_row1 EQU 6 ; starting row for side shadow
- shadow_col1 EQU 69 ; starting column for side shadow
- shadow_row2 EQU 19 ; starting row for bottom shadow
- shadow_col2 EQU 14 ; starting column for bottom shadow
- shad_length1 EQU 14 ; side shadow length
- shad_length2 EQU 55 ; bottom shadow length
- shadow_color EQU 8 ; shadow color attribute value
- bkgrd_char EQU 0FB1h ; character and color for background
- window_color EQU 31 ; brite white on blue
- window_length EQU 57 ; window length
- ;; Data
- EVEN
- save_cursor DW 0 ; save cursor location for exit
- video_seg DW 0 ; storage for video segment address
- ;;
- window DB '╔═══════════════════════════════════════════════════════╗'
- DB '║ Public Domain Code by ║'
- DB '║ ▄▄▄▄ ▄ ▄ ▄ ▄▄▄▄ ▄▄▄▄▄ ║'
- DB '║ ──█──────█───█───█─ █ ──█────────── ║'
- DB '║ ─────█▄▄▄───█─█─█─ █ ──█▄▄────█───── ║'
- DB '║ █ █ █ █ █ █ █ ║'
- DB '║ ────────────█─ █ █ ───█───█─── █ - WARE. ║'
- DB '║ ▀▀▀▀ ▀ ▀ ▀ ▀ ▀ ║'
- DB '║ ║'
- DB '║ William Cravener ║'
- DB '║ 520 N. Stateline Rd. ║'
- DB '║ Sharon, Pa. 16146 ║'
- DB '║ CIS: 72230,1306 ║'
- DB '╚═══════════════════════════════════════════════════════╝'
- ;;
- ;;-----------------------------------------------------
- ;; Code
- begin:
- mov ah, 0fh ; BIO's get -
- int 10h ; current video mode
- cmp al, 7 ; if 7 its monochrome
- je mono_vid ; go setup for it
- mov video_seg, 0b800h ; no-it be color mode
- jmp video_out ; skip over mono
- mono_vid:
- mov video_seg, 0b000h ; monochrome segment
- video_out:
- mov ah, 3
- mov bh, 0 ; retrieve cursor
- int 10h ; start location
- mov save_cursor, dx ; save it for exit
-
- mov ah, 2 ; set cursor
- mov bh, 0 ; page 0
- mov dx, 1900h ; off screen
- int 10h
-
- call save_current_screen ; save a copy of screen
-
- push es ; push ES on stack
- mov ax, video_seg ; load AX with video seg
- mov es, ax ; ES now points to it
- xor di, di ; zero out offset pointer
- mov cx, 2000 ; one screen full to fill
- mov ax, bkgrd_char ; character and color
- rep stosw ; store it to video
- pop es ; restore ES
-
- mov dh, 5 ; starting row
- mov dl, 12 ; and column
- mov si, OFFSET window ; point to example window
- mov cx, 14 ; write 14 rows total
- boxloop:
- call fast_write ; fast screen writes
- inc dh ; increment row
- loop boxloop ; go write next line
-
- call window_shadows ; now shadow the window
-
- mov ah, 0 ; wait for user
- int 16h ; to press a key
-
- call restore_current_screen ; restore original screen
-
- mov ah, 2 ; set cursor
- mov bh, 0 ; page 0
- mov dx, save_cursor ; original location
- int 10h
-
- int 20h ; exit to DOS
- ;;
- ;;**************************************
- ;; Very fast video write
- fast_write:
- push es
- push cx ; save used registers
- push dx
- call calculate_video_address ; calculate video address
- mov cx, window_length ; length of window box
- window_loop:
- lodsb ; get box character
- mov ah, window_color ; color value to use
- stosw ; store character and color
- loop window_loop ; get all box characters
- pop dx
- pop cx ; restore used registers
- pop es
- ret
- ;;
- ;;**********************************
- ;; Shadows right side and bottom side of window
- window_shadows:
- mov dh, shadow_row1 ; starting row of side
- mov dl, shadow_col1 ; starting column of side
- mov bp, 2 ; need 2 column rows
- nxt_shadow:
- mov cx, shad_length1 ; length of columns
- shad_back1:
- call get_char ; change character to shadow
- inc dh ; increment to next
- loop shad_back1 ; repeat until done
- mov dh, shadow_row1 ; starting row of side
- mov dl, shadow_col1 ; starting column of side
- inc dl ; move to next column
- dec bp ; decrement 2 column count
- cmp bp, 0 ; did 2 columns ?
- jnz nxt_shadow ; no-do next
- ; done-get ready for bottom
- mov dh, shadow_row2 ; starting row of bottom
- mov dl, shadow_col2 ; starting column of bottom
- mov cx, shad_length2 ; length of bottom row
- shad_back2:
- call get_char ; change character to shadow
- inc dl ; increment to next
- loop shad_back2 ; repeat until done
- ret
- ;;
- ;;**********************************
- ;; Get one character from video -
- ;; change its attribute to shadow color
- get_char:
- push dx
- push ds ; save used registers
- push es
- call calculate_video_address ; calculate video address
- mov si, di ; zero out SI
- mov ax, es ; need DS same
- mov ds, ax ; as ES segment
- lodsw ; retrieve character
- mov ah, shadow_color ; change color value to -
- stosw ; shadow color and return it
- pop es
- pop ds ; restore used registers
- pop dx
- ret
- ;;
- ;;**********************************
- ;; Calculates video offset address
- ;; enter with DH = row DL = column
- ;; returns with DI = video offset ES = video segment
- calculate_video_address:
- mov ax, video_seg ; current video segment
- mov es, ax ; need it in ES register
- xor ax, ax ; zero out AX
- xor bx, bx ; zero out BX
- mov al, dh ; place row in AL
- xor dh, dh ; zero out DH
- mov di, dx ; place column in DI
- mov bl, scrn_columns ; dealing with 80 columns
- mul bx ; mutiply
- add di, ax ; add to columns
- shl di, 1 ; offset of video memory
- ret
- ;;
- ;;**********************************
- ;; Store a copy of original video screen in buffer
- save_current_screen:
- push ds ; save DS on stack
- mov di, OFFSET storage ; point DI at storage
- mov ax, video_seg ; video segment
- mov ds, ax ; place in DS
- xor si, si ; zero SI
- mov cx, 2000 ; one screen full
- rep movsw ; store character and color
- pop ds ; done-restore DS
- ret
- ;;
- ;;**********************************
- ;; Restore copy of original video screen from buffer
- restore_current_screen:
- push es ; save ES on stack
- mov si, OFFSET storage ; point SI at storage
- mov ax, video_seg ; video segment
- mov es, ax ; place in ES
- xor di, di ; zero out DI
- mov cx, 2000 ; one screen full
- rep movsw ; restore character and color
- pop es ; done-restore ES
- ret
- ;;
- ;;**********************************
- ;;
- storage: ; store video screen
- ;; ; at the end of coding
- ;;**********************************
- ;; Optional method would be -
- ;; to use a 4000 byte buffer.
- ;;
- ;; Example:
- ;; storage DB 4000 DUP (0) ; video buffer storage
- ;;
- ;;
- ;;**********************************
- ;;
- code ENDS ; end of coding
-
- END start
-
-
-
-