//This program will use the delays obtained from sync.cpp to display your light show #include #include #include #include /* Definitions in the build of inpout32.dll are: */ /* short _stdcall Inp32(short PortAddress); */ /* void _stdcall Out32(short PortAddress, short data); */ /* prototype (function typedef) for DLL function Inp32: */ typedef short (_stdcall *inpfuncPtr)(short portaddr); typedef void (_stdcall *oupfuncPtr)(short portaddr, short datum); #define PPORT_BASE 0x378 /* After successful initialization, these 2 variables will contain function pointers. */ inpfuncPtr inp32fp; oupfuncPtr oup32fp; /* Wrapper functions for the function pointers - call these functions to perform I/O. */ short Inp32 (short portaddr) { return (inp32fp)(portaddr); } void Out32 (short portaddr, short datum) { (oup32fp)(portaddr,datum); } void Delay(DWORD nTimeMs) { MSG msg; DWORD endTick; endTick = clock() + nTimeMs; while(clock() < endTick) { if(PeekMessage(&msg, NULL, 0, 0, TRUE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return; } int main(void) { HINSTANCE hLib; short x; int i; /* Load the library */ hLib = LoadLibrary("inpout32.dll"); if (hLib == NULL) { fprintf(stderr,"LoadLibrary Failed.\n"); return -1; } /* get the address of the function */ inp32fp = (inpfuncPtr) GetProcAddress(hLib, "Inp32"); if (inp32fp == NULL) { fprintf(stderr,"GetProcAddress for Inp32 Failed.\n"); return -1; } oup32fp = (oupfuncPtr) GetProcAddress(hLib, "Out32"); if (oup32fp == NULL) { fprintf(stderr,"GetProcAddress for Oup32 Failed.\n"); return -1; } /*******************************************************/ /** IF WE REACHED HERE, INITIALIZED SUCCESSFUL ******/ /*******************************************************/ /* Here is where the fun stuff will go on, simple replace the Hex and delay's to make your music! */ system("pause"); Out32(PPORT_BASE,0xff); Delay(250); Out32(PPORT_BASE,0x00); Delay(109); Out32(PPORT_BASE,0xff); Delay(109); Out32(PPORT_BASE,0x00); Delay(250); Out32(PPORT_BASE,0xff); Delay(485); Out32(PPORT_BASE,0x00); Delay(251); Out32(PPORT_BASE,0x95); /* finished - unload library and exit */ FreeLibrary(hLib); system("pause"); return 0; }