diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2015-08-28 17:55:26 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2015-08-28 17:55:26 +0000 |
commit | 739a8290a8b05645a2d055aed8e5eb76ba2e24e6 (patch) | |
tree | 13713efb9e01a6f2912ce4fe0a12af4869a7593b /src/winNT_portio.c | |
parent | 863ac0a263247d43d48c06ed942ddd470f811507 (diff) |
one-true indentation
svn path=/trunk/externals/zexy/; revision=17537
Diffstat (limited to 'src/winNT_portio.c')
-rw-r--r-- | src/winNT_portio.c | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/src/winNT_portio.c b/src/winNT_portio.c index 1138ca7..b514912 100644 --- a/src/winNT_portio.c +++ b/src/winNT_portio.c @@ -19,17 +19,17 @@ static BOOL bPrivException = FALSE; int read_parport(int port) { - unsigned char value; + unsigned char value; #ifdef _MSC_VER - __asm mov edx,port - __asm in al,dx - __asm mov value,al + __asm mov edx,port + __asm in al,dx + __asm mov value,al #else - /* hmm, i should read some documentation about inline assembler */ - post("lpt: cannot read from parport (recompile!)"); - return 0; + /* hmm, i should read some documentation about inline assembler */ + post("lpt: cannot read from parport (recompile!)"); + return 0; #endif - return (int)value; + return (int)value; } void write_parport(int port, int invalue) @@ -41,88 +41,88 @@ void write_parport(int port, int invalue) __asm mov al,value __asm out dx,al #else - /* - * hmm, i should read some documentation about inline assembler - * and probably about assembler in general... - */ - post("lpt: cannot write to parport (recompile!)"); - /* - asm( - "mov %%edx,%0\n" - "mov %%al,%1\n" - "out %%dx,%%al\n" - : - : "a"(port),"b"(value) - ); - */ + /* + * hmm, i should read some documentation about inline assembler + * and probably about assembler in general... + */ + post("lpt: cannot write to parport (recompile!)"); + /* + asm( + "mov %%edx,%0\n" + "mov %%al,%1\n" + "out %%dx,%%al\n" + : + : "a"(port),"b"(value) + ); + */ #endif } static LONG WINAPI HandlerExceptionFilter ( EXCEPTION_POINTERS *pExPtrs ) { - if (pExPtrs->ExceptionRecord->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION) - { - pExPtrs->ContextRecord->Eip ++; /* Skip the OUT or IN instruction that caused the exception */ - bPrivException = TRUE; - return EXCEPTION_CONTINUE_EXECUTION; - } - else - return EXCEPTION_CONTINUE_SEARCH; + if (pExPtrs->ExceptionRecord->ExceptionCode == + EXCEPTION_PRIV_INSTRUCTION) { + pExPtrs->ContextRecord->Eip + ++; /* Skip the OUT or IN instruction that caused the exception */ + bPrivException = TRUE; + return EXCEPTION_CONTINUE_EXECUTION; + } else { + return EXCEPTION_CONTINUE_SEARCH; + } } -static BOOL StartUpIoPorts(UINT PortToAccess, BOOL bShowMessageBox, HWND hParentWnd) +static BOOL StartUpIoPorts(UINT PortToAccess, BOOL bShowMessageBox, + HWND hParentWnd) { - HANDLE hUserPort; + HANDLE hUserPort; + + hUserPort = CreateFile("\\\\.\\UserPort", GENERIC_READ, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + CloseHandle(hUserPort); /* Activate the driver */ + Sleep(100); /* We must make a process switch */ - hUserPort = CreateFile("\\\\.\\UserPort", GENERIC_READ, 0, NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - CloseHandle(hUserPort); /* Activate the driver */ - Sleep(100); /* We must make a process switch */ + SetUnhandledExceptionFilter(HandlerExceptionFilter); - SetUnhandledExceptionFilter(HandlerExceptionFilter); - - bPrivException = FALSE; - read_parport(PortToAccess); /* Try to access the given port address */ + bPrivException = FALSE; + read_parport(PortToAccess); /* Try to access the given port address */ - if (bPrivException) - { - if (bShowMessageBox) - { + if (bPrivException) { + if (bShowMessageBox) { #if 0 - MessageBox(hParentWnd,"Privileged instruction exception has occured!\r\n\r\n" - "To use this external under Windows NT, 2000 or XP\r\n" - "you need to install the driver 'UserPort.sys' and grant\r\n" - "access to the ports used by this program.\r\n\r\n" - "See the file README for further information!\r\n", NULL, MB_OK); + MessageBox(hParentWnd, + "Privileged instruction exception has occured!\r\n\r\n" + "To use this external under Windows NT, 2000 or XP\r\n" + "you need to install the driver 'UserPort.sys' and grant\r\n" + "access to the ports used by this program.\r\n\r\n" + "See the file README for further information!\r\n", NULL, MB_OK); #endif - } - return FALSE; - } - return TRUE; + } + return FALSE; + } + return TRUE; } - /* check if we are running NT/2k/XP */ +/* check if we are running NT/2k/XP */ static int IsWinNT(void) { - OSVERSIONINFO OSVersionInfo; - OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + OSVERSIONINFO OSVersionInfo; + OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&OSVersionInfo); + GetVersionEx(&OSVersionInfo); - return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT; + return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT; } - /* open parport */ +/* open parport */ int open_port(int port) { - if(IsWinNT()) /* we are under NT and need kernel driver */ - { - if(StartUpIoPorts(port, 1, 0)) - return(0); - return(-1); - } - else /* no need to use kernel driver */ - { - return(0); - } + if(IsWinNT()) { /* we are under NT and need kernel driver */ + if(StartUpIoPorts(port, 1, 0)) { + return(0); + } + return(-1); + } else { /* no need to use kernel driver */ + return(0); + } } #endif /* __WIN32__ & Z_WANT_LPT */ |