1 TITLE PC graphics module
4 ; Michael Gordon - 8-Dec-86
6 ; Certain routines were taken from the Hercules BIOS of Dave Tutelman - 8/86
7 ; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
9 ; modified slightly by Colin Kelley - 22-Dec-86
10 ; added header.mac, parameterized declarations
11 ; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
13 ; modified and added to for use in plot(3) routines back end.
16 ; Assemble with masm ver. 4.
24 GPg1_Base equ 0B800h ; Graphics page 1 base address
30 public _PC_line, _PC_color, _PC_mask, _PC_curloc, _PC_puts, _Vmode
31 public _erase, _save_stack, _ss_interrupt
34 ror word ptr linemask,1
45 mov ah,0ch ; ah = write pixel
58 lineproc _PC_line, pcpixel
61 ; erase - clear page 1 of the screen buffer to zero (effectively, blank
75 rep stosw ; zero out screen page
96 mov word ptr linemask,ax
117 mov dh, byte ptr [bp+X] ; row number
118 mov dl, byte ptr [bp+X+2] ; col number
127 ; thanks to watale!broehl for finding a bug here--I wasn't pushing BP
128 ; and reloading AH before INT 10H, which is necessary on genuine IBM
135 mov bl,byte ptr color
136 mov si,[bp+X] ; offset
139 mov es,[bp+X+2] ; segment if large or compact data model
151 mov ah,0eh ; write TTY char
162 ; for those without MSC 4.0
163 ; Use BIOS interrupt 16h to determine if a key is waiting in the buffer.
164 ; Return nonzero if so.
168 mov ah, 1 ; function code 1 is keyboard test
169 int 16h ; keyboard functions
170 jnz kbfin ; Exit if char available
171 xor ax, ax ; No char: return zero.
176 ; _save_stack and _ss_interrupt are needed due to a bug in the MSC 4.0
177 ; code when run under MS-DOS 3.x. Starting with 3.0, MS-DOS automatically
178 ; switches to an internal stack during system calls. This leaves SS:SP
179 ; pointing at MS-DOS's stack when the ^C interrupt (INT 23H) is triggered.
180 ; MSC should restore its own stack before calling the user signal() routine,
183 ; Presumably this code will be unnecessary in later releases of the compiler.
186 ; _save_stack saves the current SS:SP to be loaded later by _ss_interrupt.
189 beginproc _save_stack
198 ; _ss_interrupt is called on ^C (INT 23H). It restores SS:SP as saved in
199 ; _save_stack and then jumps to the C routine interrupt().
201 beginproc _ss_interrupt
202 cli ; no interrupts while the stack is changed!
203 mov ax,-1 ; self-modifying code again
204 save_ss equ this word - 2
207 save_sp equ this word - 2
209 jmp far ptr _inter; now it's safe to call the real routine