home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
assemblr
/
library
/
screen
/
sfast
/
fast.asm
next >
Wrap
Assembly Source File
|
1992-11-29
|
8KB
|
159 lines
;; FAST.ASM - Super fast direct video writing.
;;
;; 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 11/28/92
;;
;-----------------------------------------------------------------------------
;;
code SEGMENT
ASSUME cs:code, ds:code, es:code, ss:code
ORG 100h ; COM files begin here
start:
jmp begin ; go show off
;;
;-----------------------------------------------------
;;
columns EQU 80 ; dealing with 80 columns
;;
video_seg DW 0 ; video segment
status_reg DW 0 ; status register
string_length DW 0 ; string length (can be any length)
color_to_use DB 0 ; color values
row DB 0 ; screen rows
column DB 0 ; screen column
colorflag DB 0 ; equal 1 for snow checking
;; ; otherwise it equals 0
;;
test_string1 DB ' This is a Test String This is a Test String This is a Test String '
test_string2 DB ' Super Fast Video Writes Super Fast Video Writes Super Fast Video Writes '
;;
;-----------------------------------------------------
;;
begin:
call get_video ; get current video state
begin1:
mov si, OFFSET test_string1 ; first example string
mov string_length, 80 ; length is 80 characters
mov dh, row ; place row in DH
mov dl, column ; place column in DL
call fast_write ; call fast write
cmp row, 24 ; have we reach 24 rows ?
je over1 ; yes - go write next example
inc row ; no - increment row
jmp begin1 ; go setup for next row
over1:
mov ah, 2 ; set cursor off screen
mov bh, 0 ; while we delay for
mov dx, 1900h ; a short bit
int 10h
call delay ; go delay a second
mov row, 0 ; set row to top
inc color_to_use ; increment color value
begin2:
mov si, OFFSET test_string2 ; second example string
mov string_length, 80 ; length is 80 characters
mov dh, row ; place row in DH
mov dl, column ; place column in DL
call fast_write ; call fast write
cmp row, 24 ; have we reach 24 rows ?
je over2 ; yes - go check for key press
inc row ; no - increment row
jmp begin2 ; go setup for next row
over2:
mov ah, 2 ; set cursor off screen
mov bh, 0 ; while we delay for
mov dx, 1900h ; a short bit
int 10h
call delay ; go delay a second
mov row, 0 ; set row to top
inc color_to_use ; increment color value
mov ah, 1 ; check to see -
int 16h ; if user pressed any key
jz begin1 ; no - go to begin1
int 20h ; yes - exit to DOS
;;
;;**************************************
;; very fast video write
fast_write:
push es ; save ES register
mov ax, video_seg ; current video segment
mov es, ax ; need it in ES for STOSW
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, columns ; dealing with 80 columns
mul bx ; mutiply
add di, ax ; add to columns
shl di, 1 ; offset of video memory
mov cx, string_length ; length of string to write
mov ah, color_to_use ; color value to use
string_loop:
cmp colorflag, 0 ; if = 1 check for retrace
je noneed ; if = 0 skip to noneed
mov dx, status_reg ; status register
cli ; disable interrupts
@low:
in al, dx ; get port value
test al, 1
jnz @low ; if not zero
@high:
in al, dx ; get port value
test al, 1
jz @high ; if zero
sti ; enable interrupts
noneed:
lodsb ; get character
stosw ; store character and color
loop string_loop ; get all 80 character
pop es ; restore ES register
ret
;;
;;**********************************
;; gets video information needed by "fast_write"
get_video:
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 ; must be a color mode
mov status_reg, 03dah ; segment and status
mov color_to_use, 1 ; begin with blue on black
jmp video_out ; leave
mono_vid:
mov video_seg, 0b000h ; segment
mov status_reg, 03bah ; status
mov color_to_use, 1 ; doesn't really matter
video_out:
ret
;;
;-------------------------------
;; 1 second delay
delay:
push es ; save ES
mov ax, 40h ; BIO's
mov es, ax ; segment
mov bx, 6ch ; tick count
mov ax, es:[bx] ; place in AX
mov cx, 18 ; about 1 second
dl1:
cmp ax, es:[bx] ; are they equal
je dl1 ; yes
mov ax, es:[bx] ; no get new count
loop dl1 ; loop for 18
pop es ; restore ES
ret
;;
;-------------------------------
;;
code ENDS ; end of coding
END start