Category : Assembly Language Source Code
Archive   : BLOCK.ZIP
Filename : BLOCK.ASM

 
Output of file : BLOCK.ASM contained in archive : BLOCK.ZIP

PAGE 60,132
TITLE BLOCK v1.0 by Tom Strickland 05/25/87 Public Domain.
; This program will change the cursor size.
; NOTE:
; the command syntax is: BLOCK cmd
; where cmd is ON or OFF to turn the cursor to large
; block on or large block off (back to normal).
; Also you may misspell OFF as fof ffo or on as no.
; I am not a very good typists so built in a reasonable
; hit as accepting the command.
;
; If any error occurs the usage message will apear.
; This program does not support the EGA and the color mode
; is untested.
;
; program is .COM format

CR equ 0dh
LF equ 0ah

mem segment
assume cs:mem,ds:mem ;all segments must be the same
org 100h ;to make .COM program

start: jmp main ; skip data

mode db ?
count db 0
usage_msg db CR,LF
db ' Usage: BLOCK cmd Where cmd is ON or OFF',CR,LF
db ' ',CR,LF
db ' This will NOT work with an EGA. The color mode is untested.',CR,LF
db CR,LF
db ' BLOCK v1.0 Public Domain - Tom Strickland 05/25/87 ',CR,LF
db '$'
upcase_table db 65 dup('*')
db '*****',03h,'*******',02h,01h,'***********'
db 6d dup ('*')
db '*****',03h,'*******',02h,01h,'***********'
db 133 dup ('*')
; end of table.

main:
call get_tail ;what should do on or off?
cmp count,0
je exite
call get_mode ;get the video mode.
cmp mode,0
je exite
call set_cursor ;go set cursor
mov al,0h ;exit no error.
jmp exit
exite:
mov dx,offset usage_msg
call prompt
mov al,1h ;exit with error (return code 1)
exit:
mov ah,4ch ;end program
int 21h


;-------------------------------------------------------------------------
; This routine sets the cursor according to mode and count.
; ENTRY: mode must be set:
; mode=1 color mode.
; mode=2 mono mode.
; count must be set:
; count = 07h off
; count = 03h on
; EXIT: cursor changed.
; NOTE: For Mono 07 normal setting CH=11 CL=12
; For Text color 00-03 normal setting CH=6 CL=7

set_cursor proc near
cmp mode,1 ;is this color monitor?
jne sc2 ;no, jmp to mono
cmp count,03h ;Turn block ON?
jne sc3 ;no.
;color and block on
mov ch,0
mov cl,7
jmp sc_exit
sc3:
;color and block off
mov ch,6
mov cl,7
jmp sc_exit
sc2:
cmp count,03h ;Turn block ON?
jne sc4 ;no.
;mono and block on
mov ch,0
mov cl,12
jmp sc_exit
sc4:
;mono and block off
mov ch,11
mov cl,12
sc_exit:
mov ah,01h
int 10h
ret
set_cursor endp

;-------------------------------------------------------------------------
; This routine determines the video card mode.
; Entry: None.
; Exit: mode=0 ERROR has occured. (Could be EGA card)
; mode=1 color mode.
; mode=2 mono mode.

get_mode proc near
mov ah,0fh
int 10h ;get the video mode
mov mode,1
cmp al,04h ;is the mode <=03h (color) ?
jb gm_exit ;yes leave mode=1 (color)
mov mode,2
cmp al,07h ;is it monochrome mode?
je gm_exit ;yes, leave mode=2 (mono)
mov mode,0 ;mode=0 is error or EGA
gm_exit:
ret
get_mode endp

;*************************************************************************
; A note on dos tail
; starts at CS:0080h the length, then the dos tail including
; any leading blanks or delimiters.
; The tail is in ASCII.
;*************************************************************************
;-------------------------------------------------------------------------
;exit: count = 07h off
; count = 03h on
; count - 0 h error
;
get_tail proc near
mov count,0
mov bp,080h ;location of dos tail
xor cx,cx
mov cl,byte ptr [bp] ;get length of DOS tail
cmp cx,0 ;is there a tail
je wrong_tail ;no.
dec cx
cmp cx,3 ;is the tail too long for valid input?
ja wrong_tail ;yes display usage. (4 allows for space)
inc bp ;skip space
tail_loop:
inc bp ;point to next character
mov al,byte ptr [bp] ;get the command character.
mov bx,offset upcase_table
xlat ;translate al to upper case only
cmp al,'*'
je wrong_tail
add count,al
loop tail_loop
cmp count,07h
je tail_end
cmp count,03h
je tail_end
wrong_tail:
mov count,0
tail_end:
ret
get_tail endp

;-------------------------------------------------------------------------
; This routine sends a message to Standard output Via int 21h Func. 09h
; Entry: DS:DX load with ptr to message out must be terminated with $

prompt proc near
mov ah,9 ;set function to print string
int 21h
ret
prompt endp

mem ends ;Segment ends
end start