<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 27 Sep 2001 12:27:33 +0100
From   : Ben Newsam <ben@...>
Subject: Re: Emulators and PC printer port reading ?

In message <5.1.0.14.2.20010922153626.00aeeb60@...>,
Evangelinos Dimitris <evangelinos@...> writes
>A PC's closest equivalent of the User Port is the printer port, which i know is
>accessible in windows programming via a simple .DLL. So, if any of the existing
>BBC emulators support printing, then it should in principle be able to read
it too.
>In such a case I could for example write to the author and investigate further.
>
>I'd be much obliged if you could provide me any tips regarding the issue.

The following method works well on the 16 bit side of things. It most
probably will not work in 32-bit only versions of Windows.

In C:

typedef unsigned short      WORD;
typedef WORD far            *LPWORD;

extern  WORD    _0040H;     // Imported address of selector from Kernel

LPWORD  lpBiosDataArea;     // Points to table of LPT addresses

int     nPort;              // Actual port address of highest LPT port

#define OUTPUTPORT  ( nPort )
#define INPUTPORT   ( nPort + 1 )

#define MAKELONG(a,b) ((LONG)(((WORD)(a))|((DWORD)((WORD)(b)))<<16))

void Setup ( void )
{
    lpBiosDataArea = (LPWORD) MAKELONG ( 0x0008, &_0040H );

    // Try LPT2 first, then try LPT1
    if ( ! ( nPort = * ( lpBiosDataArea + 1 ) ) )
        nPort = *lpBiosDataArea;
}

int ReadPort ( void )
{
    return ( inpw ( INPUTPORT ) );
}

-- 
Ben
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>