| Previous | Table of Contents | Next |
To check the current video display mode from a program, the video BIOS function call 15 to get the CRT mode can be used. To invoke the function, have register AH set to 15 and execute interrupt 10H. On exit from the interrupt, register AL has the current CRT mode, register AH has the number of columns on the screen, and register BH has the current active page number. This call can be used after a set CRT mode call to verify that the system is using the correct mode.
To write a new pixel value to the display, on entry have register AH set to 0CH, register DX set with the row number, register CX set with the column number, register AL set with the color value data, and register BH set to display page number (this value is normally set to 0 for graphics). Execute an interrupt 10H to invoke the function call.
To read the current value of a pixel, on entry have register AH set to 0DH, register DX set to the row number, register CX set to the column number, and register BH set to display page number (normally a value of 0). On return from the interrupt 10H function, register AL has the color value of the pixel.
The following code example shows how to draw a horizontal line in graphics mode.
.CODE
;draw line code
draw_line proc near c, line_color:BYTE, line_length:WORD,
line_row_start:WORD, line_col_start:WORD
mov AL,line_color
mov DX,line_row_start
mov CX,line_col_start
mov BX,0 ;display page
mov SI,line_length
mov AH,12
draw_line_loop:
push AX
push BX
push CX
push DX
push SI
int 10H ;video BIOS call
pop SI
pop DX
pop CX
pop BX
pop AX
inc CX ;point to next line pixel position
dec SI ;adjust line length counter
jnz draw_line_loop
ret
draw_line endp
| Previous | Table of Contents | Next |