home *** CD-ROM | disk | FTP | other *** search
- ;
- ; pr_drive.asm
- ;
- ; Purpose: Printer primitives.
- ;
- ; Blackstar C Function Libarary
- ; (c) Copyright 1985,1989 Sterling Castle Software
- ;
-
- include model
- include blackstr.mac
-
- extrnf pr_prtscr ; print screen routine
-
-
- dseg 'DATA'
-
- bwstat equ 03bah ; B/W video status port
- busyf equ 'B' ; busy flag - already printing screen
- msdosf equ 21h ; interrupt for msdos function
- prntcom equ 0 ; BIOS command for print character
- prntint equ 17h ; printer interrupt vector
-
- ; local stack for printer interrupt
- ;
- sstk db 'Start of stack'; start of stack
- stck_m db 256 dup(?)
- pstack equ $-2 ; start it here
- estk db 'End of stack' ; end of stack
-
- status db 00 ;busy/idle screen print flag
-
- enddseg
-
-
- cseg pr_prtsc_
-
-
- ;-----------------
- ; pr_prtsc_ printer interrupt service routine
- ;-----------------
- ; Usage: pr_prtsc_();
- ;
- ; int pr_prtsc_(void);
-
- public pr_prtsc_
-
- pr_prtsc_ proc
- ifdef Large_data
- mov ax,seg dgroup
- mov ds,ax
- endif
-
- mov al,byte ptr status
- cmp al,busyf ;already printing screen?
- je int_x
-
- prtsc1: mov byte ptr status, busyf ;make it busy
- push eax
- push ebx
- push ecx
-
- ; set up our own stack
-
- mov bx,ss ;save old stack on stack
- mov ecx,esp
-
- ifdef Large_data
- mov ax,seg dgroup ;stack is in this seg
- else
- mov ax,ds
- endif
-
- cli
- ifndef asm_386
- mov ss,ax ;set stack segment to here
- endif
- mov esp,offset dgroup:pstack
- sti
-
- push ebx
- push ecx
- push edx
- push edi
- push esi
- push ebp
- push ds
- push es
-
- ifdef Large_data
- mov ax,seg dgroup
- else
- mov ax,ds
- endif
-
- mov ds,ax ;point ds to dgroup
- mov es,ax ;and es
- call pr_prtscr
-
- ; exit from print screen interrupt
-
- int_exit:
- pop es
- pop ds
- pop ebp
- pop esi
- pop edi
- pop edx
- pop ecx
- pop ebx
-
- ; restore beginning stack
-
- cli
- mov esp,ecx
- ifndef asm_386
- mov ss,bx
- endif
- sti
-
- pop ecx
- pop ebx
- pop eax
- mov byte ptr status,0 ;no more busy
-
- int_x: iret
- pr_prtsc_ endp
-
-
- ;------------------
- ; pr_putc_ print character to standard printer device
- ;------------------
- ; Usage: pr_putc_(c);
- ;
- ; int pr_putc_(char c);
- ;
- ; Returns FALSE if character was not printed, TRUE (1) if it was
-
- public pr_putc_
-
- pr_putc_ proc
- parms<<c,byte>>
- prolog
-
- ifdef Large_data
- mov ax,seg dgroup
- mov ds,ax
- endif
-
- mov al,c ;get byte to print to dl
- mov ah,prntcom ;print command
- mov edx,0 ;use printer 0
- int prntint ;do dos funtion interrupt
- cmp al,1 ;was it printed
- mov eax,0
- je printc1 ;if not, return FALSE
- mov eax,1 ;return TRUE in eax
-
- printc1:
- epilog
- pr_putc_ endp
-
-
- ;------------------
- ; pr_stat_ get printer status
- ;------------------
- ; Usage: pr_stat_(port, command);
- ;
- ; int pr_stat_(int port, int command);
- ;
-
- public pr_stat_
-
- pr_stat_ proc
- parm386<<number,dword>,<command,byte>>
- parm86<<number,word>,<command,byte>>
- prolog
-
- mov edx,number ;get printer number to edx
- mov ah,command
- int prntint ;do printer interrupt
- mov al,ah ;return in al
- mov ah,0
-
- ifdef asm_386
- movsx eax,ax
- endif
-
- epilog
- pr_stat_ endp
-
- endcseg pr_prtsc_
- end
-
-