home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Der Mediaplex Sampler - Die 6 von Plex
/
6_v_plex.zip
/
6_v_plex
/
DISK5
/
DOS_42
/
SHOWVECT.ZIP
/
SHOWVECT.ASM
next >
Wrap
Assembly Source File
|
1992-03-20
|
25KB
|
881 lines
;-----------------------------------------------------------------------;
; Show-Vectors, Version 1.00, Copyright (c) 1992 SoftCircuits ;
; Redistributed by permission. ;
; ;
; Created by: ;
; ;
; SoftCircuits Programming ;
; P.O. Box 16262 ;
; Irvine, CA 92714 ;
; ;
; Revision History: ;
; 03/06/92 JBW Original version ;
;-----------------------------------------------------------------------;
_TEXT SEGMENT PUBLIC
ASSUME cs:_TEXT,ds:_TEXT,ss:_TEXT
ORG 100h ;.COM program
start: jmp main ;Jump past data
copyright DB "Show-Vectors, Version 1.00, "
DB "Copyright (c) 1992 SoftCircuits",0
header DB " Int Vector Address Description",0
status DB " <",18h,"> <",19h,"> <PgUp> <PgDn> "
DB "<Home> <End> <Esc>=Exit ",0B3h
DB " Redistributed by permission",0
start_line DW 00h ;Int # for first line of display
display_rows DB 25 ;Display variables
display_columns DB 80
display_address LABEL DWORD ;Display address
display_offset DW 0000h ; Offset (logical cursor)
display_segment DW 0B000h ; Segment
display_page DB 00h ;Current display page
is_color DB 00h ;01h if system supports color
snow_check DB 00h ;01h if CGA adapter
display_color DB 07h ;Main information window color
copyright_color DB 70h ;Copyright bar color (1st row)
header_color DB 70h ;Column headers color (2nd row)
status_color DB 70h ;Status color (bottom row)
command_table DW 4800h,OFFSET line_up
DW 5000h,OFFSET line_down
DW 4900h,OFFSET page_up
DW 5100h,OFFSET page_down
DW 4700h,OFFSET jump_home
DW 4F00h,OFFSET jump_end
DW 0000h ;Indicates end of table
MSG_00 DB "Divide overflow",0
MSG_01 DB "Single step",0
MSG_02 DB "Non-maskable interrupt",0
MSG_03 DB "Breakpoint",0
MSG_04 DB "Overflow",0
MSG_05 DB "ROM BIOS print screen",0
MSG_06 DB "Reserved",0
MSG_08 DB "IRQ0-System timer",0
MSG_09 DB "IRQ1-Keyboard",0
MSG_0A DB "IRQ2-Reserved",0
MSG_0B DB "IRQ3-Reserved",0
MSG_0C DB "IRQ4-Reserved",0
MSG_0D DB "IRQ5-Reserved",0
MSG_0E DB "IRQ6-Floppy disk",0
MSG_0F DB "IRQ7-Reserved",0
MSG_10 DB "ROM BIOS Video services",0
MSG_11 DB "ROM BIOS Equipment determination",0
MSG_12 DB "ROM BIOS Memory-size service",0
MSG_13 DB "ROM BIOS Disk services",0
MSG_14 DB "ROM BIOS Communication services",0
MSG_15 DB "ROM BIOS Miscellaneous services",0
MSG_16 DB "ROM BIOS Keyboard services",0
MSG_17 DB "ROM BIOS Printer services",0
MSG_18 DB "ROM BASIC",0
MSG_19 DB "ROM BIOS Bootstrap",0
MSG_1A DB "ROM BIOS Time-of-day service",0
MSG_1B DB "ROM BIOS Ctrl-Break handler",0
MSG_1C DB "ROM BIOS Timer tick",0
MSG_1D DB "ROM BIOS Video parameter table",0
MSG_1E DB "ROM BIOS Floppy disk parameters",0
MSG_1F DB "ROM BIOS Font (characters 80H-FFH)",0
MSG_20 DB "MS-DOS Process termination",0
MSG_21 DB "MS-DOS General services",0
MSG_22 DB "MS-DOS Terminate address",0
MSG_23 DB "MS-DOS Ctrl-C handler",0
MSG_24 DB "MS-DOS Critical error handler",0
MSG_25 DB "MS-DOS Absolute disk read service",0
MSG_26 DB "MS-DOS Absolute disk write service",0
MSG_27 DB "MS-DOS Terminate and stay resident service",0
MSG_28 DB "MS-DOS Idle interrupt",0
MSG_29 DB "MS-DOS Reserved",0
MSG_2F DB "MS-DOS Multiplex interrupt",0
MSG_33 DB "Mouse driver",0
MSG_40 DB "ROM BIOS Floppy-disk driver (if fixed disk"
DB " installed)",0
MSG_41 DB "ROM BIOS Fixed disk parameters",0
MSG_42 DB "ROM BIOS Default video driver (if EGA installed)",0
MSG_43 DB "EGA, MCGA, VGA character table",0
MSG_44 DB "ROM BIOS Font (characters 00H-7FH)",0
MSG_46 DB "ROM BIOS Fixed disk parameters (drive 1)",0
MSG_4A DB "ROM BIOS Alarm handler",0
MSG_60 DB "User interrupts",0
MSG_67 DB "Expanded memory driver",0
MSG_70 DB "IRQ8 CMOS real-time clock",0
MSG_71 DB "IRQ9-Reserved",0
MSG_72 DB "IRQ10-Reserved",0
MSG_73 DB "IRQ11-Reserved",0
MSG_74 DB "IRQ12-Reserved",0
MSG_75 DB "IRQ13-Reserved",0
MSG_76 DB "IRQ14-Reserved",0
MSG_77 DB "IRQ15-Reserved",0
MSG_80 DB "Reserved for BASIC",0
descript_table LABEL WORD
;00h-0Fh
DW OFFSET MSG_00,OFFSET MSG_01,OFFSET MSG_02,OFFSET MSG_03
DW OFFSET MSG_04,OFFSET MSG_05,OFFSET MSG_06,OFFSET MSG_06
DW OFFSET MSG_08,OFFSET MSG_09,OFFSET MSG_0A,OFFSET MSG_0B
DW OFFSET MSG_0C,OFFSET MSG_0D,OFFSET MSG_0E,OFFSET MSG_0F
;10h-1Fh
DW OFFSET MSG_10,OFFSET MSG_11,OFFSET MSG_12,OFFSET MSG_13
DW OFFSET MSG_14,OFFSET MSG_15,OFFSET MSG_16,OFFSET MSG_17
DW OFFSET MSG_18,OFFSET MSG_19,OFFSET MSG_1A,OFFSET MSG_1B
DW OFFSET MSG_1C,OFFSET MSG_1D,OFFSET MSG_1E,OFFSET MSG_1F
;20h-2Fh
DW OFFSET MSG_20,OFFSET MSG_21,OFFSET MSG_22,OFFSET MSG_23
DW OFFSET MSG_24,OFFSET MSG_25,OFFSET MSG_26,OFFSET MSG_27
DW OFFSET MSG_28,OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29
DW OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_2F
;30h-3Fh
DW OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_33
DW OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29
DW OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29
DW OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29,OFFSET MSG_29
;40h-4Fh
DW OFFSET MSG_40,OFFSET MSG_41,OFFSET MSG_42,OFFSET MSG_43
DW OFFSET MSG_44,OFFSET MSG_06,OFFSET MSG_46,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_4A,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
;50h-5Fh
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
;60h-6Fh
DW OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60
DW OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_67
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
;70-7Fh
DW OFFSET MSG_70,OFFSET MSG_71,OFFSET MSG_72,OFFSET MSG_73
DW OFFSET MSG_74,OFFSET MSG_75,OFFSET MSG_76,OFFSET MSG_77
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
DW OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06,OFFSET MSG_06
;80h-80h
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;90h-9Fh
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;A0h-AFh
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;B0h-BFh
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;C0h-CFh
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;D0h-DFh
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;E0h-EFh
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
DW OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80,OFFSET MSG_80
;F0h-FFh
DW OFFSET MSG_80,OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60
DW OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60
DW OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60
DW OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60,OFFSET MSG_60
;-----------------------------------------------------------------------;
main:
call init_display ;Initialize display
main_loop:
call get_key ;Read next available keystroke
cmp ax,011Bh ;Was Esc pressed?
je end_program ;Yes, exit
mov bx,OFFSET command_table ;Else use bx to index command table
scan_loop:
cmp [bx],ax ;Does keystroke match this entry?
je handle_command ;Yes, process this command
add bx,4 ;Else bump bx to next entry
cmp WORD PTR [bx],0000h ;End of table?
jne scan_loop ;No
call beep ;Else sound error
jmp main_loop ;Get next command
handle_command:
call flush_kbd ;Discard any additional keystrokes
call WORD PTR [bx+0002h] ;Call handler for this command
jmp main_loop ;Go back for next keystroke
end_program:
mov bh,07h ;Restore screen
call clear_screen
sub dx,dx
call set_text_cursor
mov ax,4C00h ;Terminate
int 21h
;-----------------------------------------------------------------------;
; Moves the display up 1 line. ;
;-----------------------------------------------------------------------;
line_up PROC
push ax
push cx
push dx
cmp start_line,0 ;Are we already home?
je end_line_up ;Yes, ignore request
dec start_line ;Else move up 1 line
mov al,-1 ;Negative scroll
call scroll_page
mov dh,2 ;Display new line
mov cx,start_line
call paint_line
end_line_up:
pop dx
pop cx
pop ax
ret
line_up ENDP
;-----------------------------------------------------------------------;
; Moves the display down 1 line. ;
;-----------------------------------------------------------------------;
line_down PROC
push ax
push cx
push dx
mov al,display_rows ;Calculate maximum start vector
sub al,3
neg al
sub ah,ah
cmp start_line,ax ;Are we already at end?
je end_line_down ;Yes, ignore request
inc start_line ;Else move down 1 line
mov al,01h ;Positive scroll
call scroll_page
mov dh,display_rows ;Display new bottom row
sub dh,02h
mov cx,start_line
add cl,dh
sub cl,2
call paint_line ;Display new line
end_line_down:
pop dx
pop cx
pop ax
ret
line_down ENDP
;-----------------------------------------------------------------------;
; Moves the display up 1 page. ;
;-----------------------------------------------------------------------;
page_up PROC
push ax
push dx
cmp start_line,0 ;Are we already home?
je end_page_up ;Yes, ignore request
mov dl,display_rows ;Else move up 1 page
sub dl,3
sub dh,dh
sub start_line,dx
jnc show_page_up
mov start_line,0
show_page_up:
call paint_page ;Update display
end_page_up:
pop dx
pop ax
ret
page_up ENDP
;-----------------------------------------------------------------------;
; Moves the display down 1 page. ;
;-----------------------------------------------------------------------;
page_down PROC
push ax
push dx
mov dl,display_rows ;Calculate maximum start vector
sub dl,3
sub dh,dh
mov ax,dx
neg al
cmp start_line,ax ;Are we already at end?
je end_page_down ;Yes, ignore request
add start_line,dx ;Else move down 1 page
cmp start_line,ax
jna show_page_down
mov start_line,ax
show_page_down:
call paint_page ;Update display
end_page_down:
pop dx
pop ax
ret
page_down ENDP
;-----------------------------------------------------------------------;
; Moves the display to the first page. ;
;-----------------------------------------------------------------------;
jump_home PROC
cmp start_line,0 ;Are we already home?
je end_jump_home ;Yes, ignore request
mov start_line,0 ;Else move home
call paint_page ;Update display
end_jump_home:
ret
jump_home ENDP
;-----------------------------------------------------------------------;
; Moves the display to the last page. ;
;-----------------------------------------------------------------------;
jump_end PROC
push ax
mov al,display_rows ;Calculate maximum start vector
sub al,3
neg al
sub ah,ah
cmp start_line,ax ;Are we already at end?
je end_jump_end ;Yes, ignore request
mov start_line,ax ;Else move to end
call paint_page ;Update display
end_jump_end:
pop ax
ret
jump_end ENDP
;-----------------------------------------------------------------------;
; Prints a screen full of information. ;
;-----------------------------------------------------------------------;
paint_page PROC
push cx
push dx
mov dh,02h ;Starting row number
mov dl,display_rows ;Ending row number
dec dl
mov cx,start_line ;Interrupt for first line
page_loop:
call paint_line ;Display 1 line
inc cx ;Next interrupt vector
inc dh ;Next row
cmp dh,dl ;Screen full?
jb page_loop ;No, do it again
pop dx
pop cx
ret
paint_page ENDP
;-----------------------------------------------------------------------;
; Paints one line of information to the display. ;
; ;
; Input: dh Screen row. ;
; cx Interrupt number. ;
; ;
;-----------------------------------------------------------------------;
paint_line PROC
push ax
push bx
push dx
push si
mov bh,display_color ;Select color attribute
mov dl,1 ;Set starting column
call set_cursor
mov dx,cx ;Write interrupt number
call write_hex
call get_cursor ;Put spaces between int# and vector
add dl,4
call set_cursor
call get_vector ;Get vector for interrupt in cx
call write_hex ;Write segment in dx
push cx ;Preserve interrupt number
mov dl,':' ;Write ':'
mov cx,01h
call write_char
pop cx
mov dx,ax ;Write offset in ax
call write_hex
call get_cursor ;Put spaces between vector and
add dx,4 ; description
call set_cursor
mov si,cx ;Write description
shl si,1
mov dx,descript_table[si]
call write_string
call clear_eol ;Clear to end of line
pop si
pop dx
pop bx
pop ax
ret
paint_line ENDP
;-----------------------------------------------------------------------;
; Returns the interrupt vector address for the given interrupt. ;
; ;
; Input: cx Interrupt number. ;
; ;
; Output: dx:ax Segment:offset of interrupt vector. ;
; ;
;-----------------------------------------------------------------------;
get_vector PROC
push bx
push es
sub bx,bx ;Read from 0000:(int x 4)
mov es,bx
mov bx,cx
shl bx,1
shl bx,1
mov dx,es:[bx+02h] ;Segment in dx
mov ax,es:[bx+00h] ;Offset in ax
pop es
pop bx
ret
get_vector ENDP
;-----------------------------------------------------------------------;
; Writes a null-terminated string to the display. ;
; ;
; Input: ds:dx String address. ;
; bh Color attribute ;
; ;
;-----------------------------------------------------------------------;
write_string PROC
push ax
push cx
push dx
push si
pushf
cld
mov cx,01h ;Write 1 copy of each character
mov si,dx
string_loop:
lodsb
or al,al
jz end_write_string
mov dl,al
call write_char
jmp string_loop
end_write_string:
popf
pop si
pop dx
pop cx
pop ax
ret
write_string ENDP
;-----------------------------------------------------------------------;
; Writes a 16-bit value to the screen in hexadecimal format. ;
; ;
; Input: dx 16-bit value ;
; bh Color attribute. ;
; ;
;-----------------------------------------------------------------------;
write_hex PROC
push cx
push dx
mov cx,4
hex_loop:
rol dx,1 ;Move next digit to low nibble
rol dx,1
rol dx,1
rol dx,1
call write_hex_char ;Write this digit
loop hex_loop ;Repeat for each digit
pop dx
pop cx
ret
write_hex ENDP
;-----------------------------------------------------------------------;
; Writes a 4-bit number to the screen in hexadecimal format. ;
; ;
; Input: dl Lower nibble contains 4-bit number. ;
; bh Color attribute. ;
; ;
;-----------------------------------------------------------------------;
write_hex_char PROC
push cx
push dx
and dl,0Fh ;Isolate lower nibble
or dl,30h ;Convert to ASCII
cmp dl,'9' ;Will a decimal digit suffice?
jna hex_char_ready ;Yes
add dl,07h ;Else adjust for 'A'-'F'
hex_char_ready:
mov cx,01h ;Write 1 copy of digit
call write_char
pop dx
pop cx
ret
write_hex_char ENDP
;-----------------------------------------------------------------------;
; Writes a single character to the display. ;
; ;
; Input: dl Character to write. ;
; bh Color attribute. ;
; cx Number of times to print character. ;
; ;
;-----------------------------------------------------------------------;
write_char PROC
push ax
push bx
push cx
push dx
push di
push es
jcxz end_write_char ;Don't try to write 0 times
mov bl,dl ;bl = character, bh = color
les di,display_address ;es:di = screen address
cmp snow_check,0 ;Are we testing video retrace?
je direct_write ;No, write direct
mov dx,03DAh ;dx = video status port address
snow_write:
cli ;Disable interrupts
wait_low:
in al,dx ;Make sure the video controller scan
shr al,1 ; status is low
jc wait_low
wait_high:
in al,dx ;After port has gone low, it must go
shr al,1 ; high before it is safe to write
jnc wait_high ; directly to screen memory
mov es:[di],bx ;Write character/attribute to screen
sti ;Enable interrupts
add di,02h
loop snow_write
jmp end_write_char
direct_write:
mov ax,bx
rep stosw
end_write_char:
mov display_offset,di ;Update display offset
pop es
pop di
pop dx
pop cx
pop bx
pop ax
ret
write_char ENDP
;-----------------------------------------------------------------------;
; Writes spaces from the current cursor location to the end of the line ;
; using the current display attribute. ;
; ;
; Input: bh Color attribute. ;
; ;
;-----------------------------------------------------------------------;
clear_eol PROC
push cx
push dx
mov cl,display_columns
call get_cursor
sub cl,dl
jbe end_clear_eol ;Exit if already at end of line
mov dl,' ' ;Write spaces
call write_char
end_clear_eol:
pop dx
pop cx
ret
clear_eol ENDP
;-----------------------------------------------------------------------;
; Clears the entire screen. ;
; ;
; Input: bh Color attribute ;
; ;
;-----------------------------------------------------------------------;
clear_screen PROC
push ax
push cx
push dx
sub al,al
mov ch,00h
mov dh,display_rows
dec dh
mov cl,00h
mov dl,display_columns
dec dl
call scroll
pop dx
pop cx
pop ax
ret
clear_screen ENDP
;-----------------------------------------------------------------------;
; Scrolls the information area of the display. This procedure is used ;
; by the scrolling/position routines. ;
; ;
; Input: al Scroll type (see scroll). ;
; ;
;-----------------------------------------------------------------------;
scroll_page PROC
push bx
push cx
push dx
mov bh,display_color ;Use information area color
mov ch,02h ;Get information area coordinates
mov dh,display_rows
sub dh,02h
mov cl,00h
mov dl,display_columns
dec dl
call scroll ;Do scroll
pop dx
pop cx
pop bx
ret
scroll_page ENDP
;-----------------------------------------------------------------------;
; Scrolls or clears an area of the display. ;
; ;
; Input: al Number of lines to scroll. Positive numbers ;
; scroll up, negative numbers scroll down, 0 ;
; clears the window. ;
; bh Color attribute. ;
; ch Top row. ;
; dh Bottom row. ;
; cl Left column. ;
; dl Right column. ;
; ;
;-----------------------------------------------------------------------;
scroll PROC
push ax
push bx
push si
push di
push bp
mov ah,06h
cmp al,00h
jge scroll_ready
mov ah,07h
neg al
scroll_ready:
int 10h ;Call ROM BIOS
pop bp
pop di
pop si
pop bx
pop ax
ret
scroll ENDP
;-----------------------------------------------------------------------;
; Sets the logical write position. ;
; ;
; Input: dh Row coordinate (0-based) ;
; dl Column coordinate (0-based) ;
; ;
;-----------------------------------------------------------------------;
set_cursor PROC
push ax
push dx
mov al,dh ;Multiply row by number of columns
mul display_columns
sub dh,dh ;Add column
add ax,dx
shl ax,1 ;Adjust for attribute bytes
mov display_offset,ax ;Set video offset
pop dx
pop ax
ret
set_cursor ENDP
;-----------------------------------------------------------------------;
; Returns the logical write position. ;
; ;
; Output: dh Row coordinate (0-based) ;
; dl Column coordinate (0-based) ;
; ;
;-----------------------------------------------------------------------;
get_cursor PROC
push ax
mov ax,display_offset ;Load current video offset into ax
shr ax,1 ;Calculate column value
div display_columns
mov dh,al ;Row
mov dl,ah ;Column
pop ax
ret
get_cursor ENDP
;-----------------------------------------------------------------------;
; Initializes the display. ;
;-----------------------------------------------------------------------;
init_display PROC
push bx
push dx
call init_video ;Determine display type
cmp is_color,00h ;Is color supported?
je default_colors ;No, use default colors
mov display_color,1Fh ;Else use attributes suitable
mov copyright_color,70h ; color systems
mov header_color,4Eh
mov status_color,30h
default_colors:
mov dh,display_rows ;Hide hardware cursor off screen
call set_text_cursor
mov bh,display_color ;Initialize screen by clearing it
call clear_screen
mov bh,copyright_color ;Write copyright bar
sub dx,dx
call set_cursor
call clear_eol
add dl,10 ;Write copyright
call set_cursor
mov dx,OFFSET copyright
call write_string
mov bh,header_color ;Write column header bar
mov dx,0100h
call set_cursor
call clear_eol
call set_cursor ;Write column header
mov dx,OFFSET header
call write_string
mov bh,status_color ;Write status bar
sub dl,dl
mov dh,display_rows
dec dh
call set_cursor
call clear_eol
call set_cursor ;Write status
mov dx,OFFSET status
call write_string
call paint_page ;Show first page of information
pop dx
pop bx
ret
init_display ENDP
;-----------------------------------------------------------------------;
; Initializes the display variables to match the current condition of ;
; the host display. ;
;-----------------------------------------------------------------------;
init_video PROC
push ax
push bx
push cx
push dx
push si
push di
push bp
push es
mov ah,0Fh ;Get miscellaneous data
int 10h
mov display_page,bh
mov display_columns,ah
int 11h ;Determine color or mono
and ax,30h
cmp ax,30h
je mono
mov is_color,01h ;Indicate color system
mov display_segment,0B800h
mov snow_check,01h
mono:
mov ah,12h ;Get number of text rows
mov bl,10h
int 10h
cmp bl,10h ;Was function supported?
je end_init_video ;No, use default rows
cmp is_color,bh ;Is EGA/VGA active?
je end_init_video ;No, use default rows
mov ax,1130h
int 10h
inc dl
mov display_rows,dl
mov snow_check,00h
end_init_video:
pop es
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
init_video ENDP
;-----------------------------------------------------------------------;
; Returns the next available keystroke. ;
; ;
; Output: ax Keystroke: al = ASCII code, ah = scan code. ;
; ;
;-----------------------------------------------------------------------;
get_key PROC
sub ah,ah
int 16h
ret
get_key ENDP
;-----------------------------------------------------------------------;
; Removes any keystrokes waiting in the keyboard buffer. ;
;-----------------------------------------------------------------------;
flush_kbd PROC
push ax
flush_loop:
mov ah,01h ;Anything in keyboard buffer?
int 16h
jz end_flush_kbd ;No, done
call get_key ;Else read keystroke
jmp flush_loop ;Repeat
end_flush_kbd:
pop ax
ret
flush_kbd ENDP
;-----------------------------------------------------------------------;
; Sets the actual hardware cursor position. ;
; ;
; Input: dh Row coordinate (0-based) ;
; dl Column coordinate (0-based) ;
; ;
;-----------------------------------------------------------------------;
set_text_cursor PROC
push ax
push bx
push si
push di
push bp
mov ah,02h ;ROM BIOS set cursor service
mov bh,display_page
int 10h
pop bp
pop di
pop si
pop bx
pop ax
ret
set_text_cursor ENDP
;-----------------------------------------------------------------------;
; Sounds the computer's internal speaker. ;
;-----------------------------------------------------------------------;
beep PROC
push ax
push dx
mov ah,02h ;DOS write character service
mov dl,07h ;Write 'bell' character
int 21h
pop dx
pop ax
ret
beep ENDP
_TEXT ENDS
END start