Article View: net.micro.pc
Article #6054Re: Printer-Code Interceptor
From: dlsutton
Date: Tue, 25 Mar 1986 00:02
Date: Tue, 25 Mar 1986 00:02
209 lines
8192 bytes
8192 bytes
Here is a simple interrupt handler that I have written to translate
fx80 codes to caompatible mx80 codes for the IBM in graphics mode.
It should be easily modifiable for your project. Have fun, and
call if you have any questions.
It is written in TURBO PASCAL (v3.0).:
-----------------------------(CUT HERE OR DIE)----------------------
program gp(input,output);
{$C-}
{$K-}
{VARIABLE SECTION FOR 'GP'}
type
RegType = record
ax,bx,cx,dx,bp,si,di,ds,es,flags : integer
end;
HalfRegType = record
al,ah,bl,bh,cl,ch,dl,dh : byte
end;
IntrType = record
ip,cs : integer
end;
const
UserInt = $61; { ***HERE IT IS*** }
{if GP will not work with your other
resident stuff, change this number to
a free interrupt}
PrtInt = $17;
ProgSize : integer = $3000; { approx. program size in bytes }
Regs : regtype = (ax:0;bx:0;cx:0;dx:0;bp:0;si:0;di:0;ds:0;es:0;flags:0)
;
SaveDS : integer = 0;
flags : integer = 0;
var
SaveReg : RegType;
SaveHalf : HalfRegType absolute SaveReg;
HalfReg : HalfRegType absolute regs;
esc_flg : boolean;
count : integer;
bv : byte;
sl,through : boolean;
procedure ProcessInt; { Start of interrupt service }
begin
{when invoked, this procedure saves the registers into the structured constant
'REGS' and restores the ds from the previously saved integer constant 'saveds'}
inline(
$53/ {PUSH BX}
$BB/regs/ {MOV BX,OFFSET REGS}
$2E/$89/$47/$00/ {CS:MOV [BX]0,AX}
$58/ {POP AX}
$2E/$89/$47/$02/ {CS:MOV [BX]2,AX}
$2E/$89/$4F/$04/ {CS:MOV [BX]4,CX}
$2E/$89/$57/$06/ {CS:MOV [BX]6,DX}
$2E/$89/$6F/$08/ {CS:MOV [BX]8,BP}
$2E/$89/$77/$0A/ {CS:MOV [BX]A,SI}
$2E/$89/$7F/$0C/ {CS:MOV [BX]C,DI}
$2E/$8C/$5F/$0E/ {CS:MOV [BX]E,DS}
$2E/$8C/$47/$10/ {CS:MOV [BX]10,ES}
$9C/ {PUSHF}
$58/ {POP AX}
$2E/$89/$47/$12/ {CS:MOV [BX]12,AX}
$2E/$8E/$1E/saveds {CS:MOV DS,SAVEDS -- PUT PROPER DS}
);
if ((through) and (count = 0) and (esc_flg)) then
esc_flg:= false; {turn off esc flag}
if (halfreg.ah = 0) {check for print request}
then
if not(esc_flg)
then
if (halfreg.al = $1B) {if esc in al then set esc flag}
then {and notify program that task is}
begin {not finished by setting through}
esc_flg:= true; {to false.}
through:= false
end
else
Intr(userint,regs) {if not a print request, send it to BIOS}
else
if (count > 0 ) {if skipping, sub one from skip count}
then
count:= count - 1
else
case halfreg.al of
$33 : begin {set line spacing}
halfreg.ah:= $00;
halfreg.al:= $1B;
intr(userint,regs);
halfreg.ah:= $00;
halfreg.al:= $33;
intr(userint,regs);
halfreg.ah:= $00;
halfreg.al:= $18;
intr(userint,regs);
through:= true;
count:= 1
end;
$51 : begin {skip this mode - gp doesn't support it}
count:= 1;
through:= true
end;
$2A : begin
halfreg.ah:= $00; {set to 960 dot mode, and send dot data}
halfreg.al:= $0A;
intr(userint,regs);
halfreg.al:= $0D;
halfreg.ah:= $00;
intr(userint,regs);
halfreg.ah:= $00;
halfreg.al:= $1B;
through:= true;
intr(userint,regs);
halfreg.ah:= $00;
halfreg.al:= $4C;
Intr(userint,regs);
count:= 1
end;
else
begin {else send request to BIOS}
bv:= halfreg.al;
halfreg.ah:= $00;
halfreg.al:= $1B;
intr(userint,regs);
halfreg.ah:= $00;
halfreg.al:= bv;
through:= true;
intr(userint,regs)
end
end
else
Intr(userint,regs);
{when invoked this routine restores the registers from the structure constant}
inline(
$BB/REGS/ {MOV BX,OFFSET REGS}
$2E/$8E/$47/$10/ {CS:MOV ES,[BX]10}
$2E/$8E/$5F/$0E/ {CS:MOV DS,[BX]0E}
$2E/$8B/$7F/$0C/ {CS:MOV DI,[BX]0C}
$2E/$8B/$77/$0A/ {CS:MOV SI,[BX]0A}
$2E/$8B/$6F/$08/ {CS:MOV BP,[BX]08}
$2E/$8B/$57/$06/ {CS:MOV DX,[BX]06}
$2E/$8B/$4F/$04/ {CS:MOV CX,[BX]04}
$2E/$8B/$47/$00/ {CS:MOV AX,[BX]00}
$2E/$FF/$77/$12/ {CS:PUSH [BX]12}
$9D/ {POPF}
$2E/$8B/$5F/$02/ {CS:MOV BX,[BX]02}
$5D/ {POP BP}
{restore the stack pointer}
$5D {POP BP}
);
inline ($CA/$02/$00
) {RETF 02}
end;
{ PROGRAM 'GP' }
{ Program installation }
begin
SaveDS := dseg;
count:= 0;
esc_flg:= false;
through:= false;
SaveReg.ax := $3500 + UserInt;
Intr($21,SaveReg); { get user interrupt }
if SaveReg.es <> $00 then
writeln('User Interrupt in use -- cant install GP.')
else
begin
writeln('Installing GP');
savereg.ax := $3500 + PrtInt;
Intr($21,savereg); { get keyboard interrupt }
savereg.ax := $2500 + UserInt;
savereg.ds := savereg.es;
savereg.dx := savereg.bx;
Intr($21,savereg); { put in user interrupt }
savereg.ax := $2500 + PrtInt;
savereg.ds := cseg;
savereg.dx := ofs(ProcessInt);
Intr($21,savereg); { install our interrupt processor }
savereg.dx := ProgSize;
Intr($27,savereg); { terminate and stay resident }
end;
inline($CD/$20); { terminate if interrupt in use }
end.
------------------------(CUT HERE AGAIN)-------------------------------
Sincerely,
David L. Sutton
(405)787-1880
"if you can't flame em, join em," (1985, "the adventures of NETMOUSE")
Technical Details
Message-ID:
<4900019@uok.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!okstate.UUCP!uok.UUCP!dlsuttonReferences:
<1565@gitpyr.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site uok.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!okstate.UUCP!uok.UUCP!dlsutton From: dlsutton@uok.UUCP Newsgroups: net.micro.pc Subject: Re: Printer-Code Interceptor Message-ID: <4900019@uok.UUCP> Date: Mon, 24-Mar-86 19:02:00 EST Article-I.D.: uok.4900019 Posted: Mon Mar 24 19:02:00 1986 Date-Received: Thu, 27-Mar-86 07:06:17 EST References: <1565@gitpyr.UUCP> Lines: 209 Nf-ID: #R:gitpyr.UUCP:1565:uok.UUCP:4900019:000:7356 Nf-From: uok.UUCP!dlsutton Mar 24 18:02:00 1986