home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
graphics
/
int_70h.arc
/
INT70H.DOC
< prev
Wrap
Text File
|
1988-12-07
|
9KB
|
331 lines
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
├───┼───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┼───┤
├───┤ ├───┤
├───┤ ════╦════ ╔═╗ ║ ═════╦═════ ├───┤
├───┤ ║ ║ ╚╗ ║ ║ ├───┤
├───┤ ║ ║ ╚╗ ║ ║ ├───┤
├───┤ ║ ║ ╚╗ ║ ║ ├───┤
├───┤ ════╩════ ║ ╚═╝ ║ ├───┤
├───┤ ├───┤
├───┤ ╔══════╗ ╔═════╗ ║ ├───┤
├───┤ ╔╝ ║ ╔╦═╣ ║ ├───┤
├───┤ ╔═╝ ║ ╔╬╝ ║ ╠═══╗ ├───┤
├───┤ ║ ╠═╩╝ ║ ║ ║ ├───┤
├───┤ ║ ╚═════╝ ║ ║ ├───┤
├───┤ ├───┤
├───┼───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┼───┤
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
b y
T e d O ' C o n n o r
The program INT 70h is a very simple driver for the
hercules graphics card (aka the HGC). It is intended to ease
the use of the graphics while still allowing full use of the
card at machine language speed. It even has its own language
for accessing the different functions.
There are only 8 commands in the INT 70h language:
0 Stop the interupt program
1 Turn graphics on
2 Turn text on
3 Draw a point
4 Draw a line
5 Set the active page
6 Clear the given page
7 Fill the given page
Since there are only 7 instructions, I use the four most
significant bits in a byte to specify a function in a command
byte. The four least significant bits specify a page of
memory in some functions (the hercules graphics card has two
graphics/text pages).
The language is a very simple one. You set a byte in
memory to a value as specified above. If it needs parameters
(i.e. screen coordinates for a point), you use the next few
WORDS of memory to specify them. You use memory words (2
bytes) because a screen coordinate may be more than 255 which
is as large a value as a byte can handle. One last important
note:
Always follow your program code by a
byte value of 0 in the command byte
position. This tells the interrupt when
to stop executing your code.
This is an example of what your code should look like:
┌─────────────────────────────────────────────────────┐
(1) │ DB 11h ; turn on the graphics mode │
│ ; (page 1) │
(2) │ DB 51h ; set active page │
(3) │ DB 42h ; draw a line using XOR │
(4) │ DW 10, 20, 40, 80 ; from (10,20) to (40,80) │
└─────────────────────────────────────────────────────┘
line (1): 10h ---> turn on graphics
+ 1h ---> page 1 (you can use page 0 or 1)
----
11h
line (2): 50h ---> set active page (for plotting points
and lines)
+ 1h ---> page 1 is active
----
51h
line (3): 40h ---> draw a line
+ 2h ---> use the XOR method
----
42h
line (4): 10, 20, 40, 80 ---> words (specified w/ DW
instead of DB)
So, this program would turn on the graphics page, without
clearing it and plot a line using an exclusive or method.
To call this interrupt, you must do two things:
1) put the address in the AX & BX registers
2) use the instruction INT 70h
The address in AX & BX is the segment where the code is being
kept is put into AX and the offset within that segment is put
into BX. This can be accomplished in one of two ways:
MOV AX, SEG <codename>
MOV BX, OFFSET <codename>
INT 70h
or
MOV AX, DS
LEA BX, <codename>
INT 70h
Functions:
number of purpose of
number name parameters parameters
────── ──────────────── ────────── ─────────────
10h Turn on graphics 0 *
20h Turn on text 0 *
30h Draw a point 2 ^ X & Y coordinates
40h Draw a line 4 ^ X&Y coordinates
of both end point
50h Set the active pg 0 *
60h Clear page 0 *
70h Fill page 1 * value to fill with
^ -- this means that the type of plotting used is in the four
least significant bits:
1: turn the points chosen on
2: use exclusive or to plot the points
(i.e. if the point is on, turn it
off. if it is off, turn it on.)
3: turn the points chosen off
* -- this means that the page number for the function should
be in the four least significant bits
0: page 0 (the page it usually is on when you
start)
1: page 1 (used by the CGA card)
This is an example of a full MASM program using INT 70h:
CSEG SEGMENT
ORG 100h
ASSUME CS:CSEG, DS:CSEG, SS:CSEG
START: MOV AX, CS ; this gets the segment value
LEA BX, Gr_code ; this gets the offset
INT 70h ; call the graphics interupt
MOV AH, 7 ; DOS fn to get a key
INT 20h ; call the DOS interupt
MOV AX, CS ; get the segment value
LEA BX, Reset ; get the offset
INT 70h ; call the graphics interupt
INT 20h ; end the program
Gr_code DB 11h ; turn on graphics (page 1)
DB 61h ; clear page 1
DB 51h ; make page 1 the active page
DB 31h ; put a point (using OR)
DW 5, 5 ; at (5, 5) on the screen
DB 42h ; draw a line (using XOR)
DW 10, 20, 40, 80 ; from (10, 20) to (40, 80)
DB 32h ; switch a point (using XOR)
DW 6, 5 ; at (6, 5)
DB 33h ; turn off a point (mask using
AND)
DW 5, 5 ; at (5, 5)
DB 0 ; signify end of code
Reset DB 20h ; reset to text mode
DB 70h ; fill page 0 with . . .
DB 32, 7 ; spaces with normal attributes
DB 0 ; signify end of code
CSEG ENDS
END START