f



bam10006.h header for monochrome windows programs on Linux.

 bam10006.h is next */
// This is the first line of this header file.
// bam10006.h
// ( Written by Eric Matteson )
// Traditional 32-bit C Windows applications
// programs use WinMain instead of main and
// DispatchMessage calls LRESULT CALLBACK
// with type of message such as WM_KEYDOWN
// and WM_PAINT
// ...............
// int WINAPI WinMain(HINSTANCE,
//                   HINSTANCE,LPSTR,int);
// WINAPI does not really exist in the c language
// HINSTANCE is an undefined symbol or null
// and is not used
// There is a LPSTR with the command line argument
// and the rightmost int should be
// the length of the command
// line argument.
// ..................................
//   typedef LRESULT (CALLBACK *WNDPROC)(HWND,
//                         UINT,WPARAM,LPARAM);
// CALLBACK does not really exist in the
// c language.
// ......................
//  int SetDIBitsToDevice(HDC bamdc,
//      int XDest,int YDest,DWORD dwWidth,
//      DWORD dwHeight,
//  int zeroXSrc,int zeroYSrc,UINT zeStartScan,
//      UINT cScanLines,
//      VOID* lpvBits,
//      BITMAPINFO* lpbmi,
//                             UINT fuColorUse);
// SetDIBitsToDevice is used to draw a bitmap
// structure that is located in memory onto
// the screen. bam10006.h (Even numbered header)
// provides a high speed one-bit per pixel
// implementation of SetDIBitsToDevice.
// There are 12 arguments 1-12 only some
// are nonzero.
// Argument 1 is usully null and is not checked.
// Arguments 2 and 3 are the ( 0 minimum )
// coordinates of the upper left corner
// of the bitmap even though drawing starts
// at the lower left corner because bitmaps
// themselves are upside down.
// Argument 2 xCoord must be a multiple of 8.
// Arguments 4 and 5 are the width and height
// of the bitmap and must match the width
// and height inside the bitmap data structure.
// Argument 4 width must be a multiple of 8.
// ( 8 pixels per undividable whole byte. )
// Arguments 6 and 7 and 8 must be 0.
// Argument 9 must equal the height.
// Argument 10 is a pointer to a set of bytes
// that is eight pixels per byte for the
// required monochrome bitmap. Dots on screen
// are dark for 0 or white for 1.
// Argument 10 points to bitmapstructure+62
// at the required monochrome bitmap.
// Argument 11 points to bitmapstructure+14
// to verify width and height and one bit
// per pixel plus anything else that needs
// verifying.
// Argument 12 must be 0.
//    REM bitmap header for bitmaps
//    REM 0  00 2 "BM"  value 19778
//    REM    02 4 bfsize
//    REM    06 2 2r1
//    REM    08 2 2r2
//    REM    0a 4 bfoffbits to start of bitmap
//    REM    0e 4 bisize of header  (*arg11_here)
//    REM 18 12 4 biwidth  IN PIXELS (multiple of 8)
//    REM 22 16 4 biheight IN PIXELS
//    REM    1a 2 biplanes srt to 0001
//    REM 28 1c 2 bibitcount = {1,4,8,24} (1 here!)
//    REM    1e 4 NZ_bicompression must be 0 here.
//    REM    22 4 bisize size of image or 0 (0 here)
//    REM    26 4 bixpelspermeter    (Not checked)
//    REM    2a 4 biypelspermeter    (Not checked)
//    REM 46 2e 4 biclrused is number of colors
//    used while > 0 AND [1C]=8           (0 here)
//    REM    32 4 biclrimportant or 0     (0 here)
//    REM 54 36 4*[1C] or 0 for [1C]==24
//                            COLORTABLE BGR0 BGR0
//    REM 62 3E bitmap in upside down format after
//                   colortable each line of dwords
// -------------------------------------------
// SetDIBitsToDevice then has to convert the
// upside down windows bitmap to upside up
// and also reverse the order of bits within
// each byte to provide the first buffer
// character array with a valid pattern
// to later send to the XWindows display.
// SetDIBitsToDevice also has to keep track of
// the target XWindow width promoted
// to the next whole multiple of 8
// if not a remainder of 0.
// .................................
//  int GetMessage(MSG* gmsg,int zgm2,
//                   int zgm3,int zgm4);
// Unknown first parameter is null in this
// example. Internal global variables kkep
// track of message type from Linux XWindows
// and translate it into Windows message type.
//  Returns nonzero until time to close
// Window and quit program.
// GetMessage is usually at top of while loop
// and calling DispatchMessage after it
// calls LRESULT CALLBACK.
// ......................
//  int (*kellycb)(HWND cbh,UINT cbmess,
//                    WPARAM cbwp,LPARAM cbl);
// Often called LRESULT CALLBACK this is the
// declaration for the function pointer to
// the users application program that handles
// events. cbmess is message type like
// WM_KEYDOWN that uses cbwp as its raw
// keycode. WM_PAINT means it is time to call
// the redraw screen sequence BeginPaint
// SetDIBitsToDevice and EndPaint.
// ...............................
// int (*kellywm)(HINSTANCE wma1,HINSTANCE wmp2,
//                        LPSTR cmd3,int awid4);
// Template for WinMain. wma1 and wma2 are
// probably null and cmd3 is a string of
// the command line argument if present and
// awid4 is the length of the command line
// argument.
//  int DispatchMessage(MSG* mcb);
// mcb might be null. Internal
// global variables that
// were set by previous call  to
// GetMessage are used in this
// functions call to LRESULT CALLBACK
// in the users applications program
// to process each event.
// ......
// int GetWindowRect(HWND gwrhh,RECT* gwrwh);
// gets the Window rectangle width and
// height of host Linux XWindow.
// int RedrawWindow(HWND rdwh,RECT* rdwr,
//                       int rw3,int rwor4);
// sends a xexpose event to redraw the
// XWindow by setting next event to
// expose ythen returns WM_PAINT
// request from GetMessage then
//  call to next DispatchMessage
// is a WM_PAINT
// ................................
//  int EndPaint(HWND ephw,PAINTSTRUCT* eps);
// Arguments are ignored. might be null.
// The internal character array that was
// previously written to by SetDIBitsToDevice
// is placed into another buffer and then
// written to XWindows screen now.
// Then the GC is deleted.
// ...........
// HWND CreateWindow(char* jn,char* snw,
//         int olap3,int xul,int yul,
//                   int widcw,int hgtcw,
//  int cw8,int cw9,char* cwinstance,int cwii);
// widcw and hgtcw are the two arguments that
// work in this function
// widcw should be a multiple of 8 and
// less than 640.
// hgtcw should be less than 480.
// .................................
// HDC BeginPaint(HWND bphw,PAINTSTRUCT* bps);
// Creates the Graphics context called a GC
// BeginPaint is called before SetDIBitsToDevice
// and EndPaint is called after SetDIBitsToDevice
// These functions are called if cbmess is
// WM_PAINT within the LRESULT CALLBACK.
// ......................................
//  int PostQuitMessage(int qmess);
// Call this with qmess=0 to end the
// Windows Applications program.
// .................................
//  int TranslateMessage(MSG* tcb);
// Does nothing. Microsoft started by failing
// to translate arrow keys and other similar
// keys. In here it does NOTHING.
// -----------------------
// int RegisterClass(WNDCLASS* kelwnd);
// Used to set
//  kellycb = (*(kelwnd)).lpfnWndProc;
// within the WNDCLASS structure in WinMain
// to set the name of the LRESULT CALLBACK
// routine within the users application program
// -----------------------------------------
// beginning of compilable header file.
// The following two arrays of constants
// were written by a computer program
   int trev[]={0,-128,64,-64,32,-96,96,-32,
    16,-112,80,-48,48,-80,112,-16,
    8,-120,72,-56,40,-88,104,-24,
    24,-104,88,-40,56,-72,120,-8,
    4,-124,68,-60,36,-92,100,-28,
    20,-108,84,-44,52,-76,116,-12,
    12,-116,76,-52,44,-84,108,-20,
    28,-100,92,-36,60,-68,124,-4,
    2,-126,66,-62,34,-94,98,-30,
    18,-110,82,-46,50,-78,114,-14,
    10,-118,74,-54,42,-86,106,-22,
    26,-102,90,-38,58,-70,122,-6,
    6,-122,70,-58,38,-90,102,-26,
    22,-106,86,-42,54,-74,118,-10,
    14,-114,78,-50,46,-82,110,-18,
    30,-98,94,-34,62,-66,126,-2,
    1,-127,65,-63,33,-95,97,-31,
    17,-111,81,-47,49,-79,113,-15,
    9,-119,73,-55,41,-87,105,-23,
    25,-103,89,-39,57,-71,121,-7,
    5,-123,69,-59,37,-91,101,-27,
    21,-107,85,-43,53,-75,117,-11,
    13,-115,77,-51,45,-83,109,-19,
    29,-99,93,-35,61,-67,125,-3,
    3,-125,67,-61,35,-93,99,-29,
    19,-109,83,-45,51,-77,115,-13,
    11,-117,75,-53,43,-85,107,-21,
    27,-101,91,-37,59,-69,123,-5,
    7,-121,71,-57,39,-89,103,-25,
    23,-105,87,-41,55,-73,119,-9,
    15,-113,79,-49,47,-81,111,-17,
    31,-97,95,-33,63,-65,127,-1};
   int wkey[]={399,399,399,399,
               399,399,399,399,
    399,27,49,50,51,52,53,54,
    55,56,57,48,189,187,8,399,
//  24
    81,87,69,82,84,89,85,73,
    79,80,219,221,13,399,65,83,
    68,70,71,72,74,75,76,186,
    222,192,16,220,90,88,67,86,
    66,78,77,188,190,191,16,106,
//  64
    399,32,399,399,399,399,399,399,
    399,399,399,399,399,399,399,55,
//  80
    56,57,109,52,53,54,107,49,
    50,51,48,110,399,399,399,399,
//  96
    399,36,38,33,37,399,39,35,
//  104
    40,34,45,46,13,399,36,38,
//  112
    33,37,39,35,40,34,45,46,
//  120
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,399,
    399,399,399,399,399,399,399,-1};
// The preceeding two arrays were created
// by a computer program.
// This bam10006.h  header file is used
// to compile c language applications
// programs written for Microsoft Windows
// into Linux. One bit per pixel is provided
// so monochrome bitmaps can be displayed.
// This bam10006.h  header file is written by
// Eric Matteson.
// Copyright C 2008 by Eric Matteson
// Permission is hereby granted to copy
// this source code file bam10006.h and
// to publish it on the Internet and
// to use it at least for non-profit use.
// name parts
// bam identifies as a bambi header file
// Windows to Linux Xwindows.
// five digit number 10006
// even numbers are for one-bit-per-pixel
// monochrome versions of this header.
// ----------------------------------------
// char debline[]={"DEBUG LINE *******--"};
//   #include<stdio.h>
// ----------------------
   #include<fcntl.h>
   #include<sys/stat.h>
   #include<unistd.h>
   #include<dirent.h>
// ---------------------
   #include<X11/Xutil.h>
   int wlisawid,validkelly,kelmoupos;
   int kellyulxz,kellyulyz;
   int kellywid,kellyhgt,needfindc;
   int typekelly,keykelly,kellygm;
   int kellynum,kellydepth;
   int kellymask;
   char* kellynull;
   GC kellygc;
   Pixmap kellymap;
   Display* kellydis;
   Window kellywin;
   XEvent xekelly;
   XEvent sekelly;
   XSizeHints* ksizeh;
   XWMHints* kwmhints;
   XClassHint* kclassh;
   struct dirent *xfiveep;
   DIR* xfivedp;
   char** argkb;
   int argkd;
// ---------------------
   char wkelly[541000];
// ---
// Begin Windows 98 Win 32 API declarations
// types and structures
   typedef unsigned long DWORD;
   typedef char *LPSTR;
   typedef void *kellyh;
   typedef kellyh HDC;
   typedef kellyh HANDLE;
   typedef kellyh HGLOBAL;
   typedef kellyh HINSTANCE;
   typedef kellyh HWND;
   typedef kellyh HBRUSH;
   typedef kellyh HCURSOR;
   typedef kellyh HICON;
   typedef kellyh kellyhan;
   typedef int BOOL;
   typedef unsigned int UINT;
   typedef unsigned int WPARAM;
   typedef long LPARAM;
   typedef unsigned char BYTE;
   typedef char *BITMAPINFO;
   typedef long LRESULT;
   typedef const char *LPCWSTR;
   typedef char POINT;
//   typedef char VOID;
   #define VOID void
// Numbers for Windows constants are
// chosen at random and these constants
// are not binary compaible with
// genuine Microsoft Windows!
// file access constants
   #define FILE_BEGIN 768
   #define FILE_CURRENT 769
   #define FILE_END 770
   #define GENERIC_READ 0x80000300
   #define GENERIC_WRITE 0x40000300
   #define CREATE_ALWAYS 770
   #define FILE_ATTRIBUTE_NORMAL 896
   #define FILE_SHARE_READ 769
   #define OPEN_EXISTING 771
   #define OPEN_ALWAYS 772
 #define FILE_FLAG_SEQUENTIAL_SCAN 134218496
   #define INVALID_HANDLE_VALUE NULL
// -----------------------
// graphics and keyboard constants
// are next with different
// random numbering rules.
   #define WM_MOUSEMOVE 1130
   #define WM_LBUTTONDOWN 1131
   #define WM_RBUTTONDOWN 1134
   #define MK_LBUTTON 619
   #define MK_RBUTTON 620
   #define GMEM_MOVEABLE 620
   #define GMEM_DDESHARE 8810
   #define CF_OEMTEXT 625
   #define WM_CREATE 619
   #define WM_DESTROY 620
   #define WM_PAINT 633
   #define WM_KEYDOWN 874
   #define WM_KEYUP 875
   #define RDW_ERASENOW 1130
   #define RDW_INVALIDATE 619
   #define CS_HREDRAW 620
   #define CS_VREDRAW 619
   #define IDI_APPLICATION 33130
   #define IDC_ARROW 33130
   #define COLOR_WINDOW 623
   #define WS_OVERLAPPEDWINDOW 13596570
   #define CALLBACK
   #define WINAPI
// ------------------
   typedef struct
   {
   long left;
   long top;
   long right;
   long bottom;
   }RECT;
    typedef struct
    {
    HDC hdc;
    BOOL fErase;
    RECT rcPaint;
    BOOL fRestore;
    BOOL sIncUpdate;
    BYTE rebReserved[32];
    } PAINTSTRUCT;
    typedef struct
    {
    char cFileName[144];
    }WIN32_FIND_DATA;
    typedef struct
    {
    HWND hwnd;
    UINT message;
    WPARAM wParam;
    LPARAM lParam;
    DWORD time;
    POINT pt;
    } MSG;
   typedef LRESULT (CALLBACK *WNDPROC)(HWND,
                         UINT,WPARAM,LPARAM);
// typedef int (WINAPI *WinMain)(HINSTANCE,
//                      HINSTANCE,LPSTR,int);
   int WINAPI WinMain(HINSTANCE,
                        HINSTANCE,LPSTR,int);
    typedef struct
    {
    UINT style;
  WNDPROC lpfnWndProc;
  int cbClsExtra;
  int cbWndExtra;
  HINSTANCE hInstance;
  HICON hIcon;
  HCURSOR hCursor;
  HBRUSH hbrBackground;
  LPCWSTR lpszMenuName;
  LPCWSTR lpszClassName;
  } WNDCLASS;
// ----------------------
// declare win32 API functions
// file accessing functions
 int ReadFile(HANDLE rhfile,VOID* rlpbuffer,
  DWORD rwidth,unsigned long *outwid,char* nelly);
 int WriteFile(HANDLE whfile,VOID* wlpbuffer,
  DWORD wwidth,unsigned long *outwid,char* nelly);
  DWORD SetFilePointer(HANDLE hsfile,long dmove,
                       long *dhigh,DWORD method);
  DWORD GetFileSize(HANDLE gfshan,char* gfsnelly);
  HANDLE CreateFile(char* gcfn,DWORD drwsel,
        DWORD zsm,char* securnel,DWORD dwcd,
                DWORD zattrib,HANDLE cfnelly);
  int CloseHandle(HANDLE chww);
  HANDLE FindFirstFile(char* fboot,
              WIN32_FIND_DATA* fffd);
  int FindNextFile(HANDLE fnfh,
              WIN32_FIND_DATA* fffn);
  int FindClose(HANDLE fcloh);
// graphics pixel functions
  int SetDIBitsToDevice(HDC bamdc,
      int XDest,int YDest,DWORD dwWidth,
      DWORD dwHeight,
  int zeroXSrc,int zeroYSrc,UINT zeStartScan,
      UINT cScanLines,
      VOID* lpvBits,
      BITMAPINFO* lpbmi,
                             UINT fuColorUse);
  int GetMessage(MSG* gmsg,int zgm2,
                   int zgm3,int zgm4);
  int (*kellycb)(HWND cbh,UINT cbmess,
                      WPARAM cbwp,LPARAM cbl);
  int (*kellywm)(HINSTANCE wma1,HINSTANCE wmp2,
                          LPSTR cmd3,int awid4);
  int DispatchMessage(MSG* mcb);
  int GetWindowRect(HWND gwrhh,RECT* gwrwh);
  int RedrawWindow(HWND rdwh,RECT* rdwr,
                         int rw3,int rwor4);
  int EndPaint(HWND ephw,PAINTSTRUCT* eps);
  HWND CreateWindow(char* jn,char* snw,
             int olap3,int xul,int yul,
                   int widcw,int hgtcw,
  int cw8,int cw9,char* cwinstance,int cwii);
  HDC BeginPaint(HWND bphw,PAINTSTRUCT* bps);
  int PostQuitMessage(int qmess);
  int TranslateMessage(MSG* tcb);
  int RegisterClass(WNDCLASS* kelwnd);
// used functions are above
// unimplemented functions are next
  int OpenClipboard(HWND ocbFrom);
  kellyhan GetClipboardData(int GCDtype);
  int CloseClipboard();
  kellyhan GlobalAlloc(int GAt,int GATsize);
  VOID* GlobalLock(kellyhan GLarea);
  int GlobalUnlock(kellyhan GUhan);
  kellyhan GlobalHandle(kellyhan GHahan);
  kellyhan SetClipboardData(int SCDtype,
                         kellyhan SCDhan);
  LRESULT DefWindowProc(HWND DWPa,UINT DWPb,
                    WPARAM DWPc,LPARAM DWPd);
  kellyhan LoadIcon(char* LIlpc,int LIona);
  kellyhan LoadCursor(char* LClpc,int LCona);
  int ShowWindow(HWND SWh,int SWnum);
  int UpdateWindow(HWND UWhan);
// - end of Windows 98 win32 API declarations
// ------------------------------------------
 void getgc(Window wigc,GC* wrgc,int zbnzw);
 Window makexw(XSizeHints* sizehints,
  XWMHints* wmhints,XClassHint* classhints);
 void deprint(char* depres,int depw,
                                 int depin);
   int mwrevcram(int repos,int revmany,
                          char* mwrfrom);
   int findscpy(int fdscmax,char* fdscl,
                             char* fdscr);
// ------------------------ begin functions
 int ReadFile(HANDLE rhfile,VOID* rlpbuffer,
  DWORD rwidth,unsigned long *outwid,char* nelly)
   {
   *outwid = read(rhfile,rlpbuffer,rwidth);
   return 0;
   }
 int WriteFile(HANDLE whfile,VOID* wlpbuffer,
  DWORD wwidth,unsigned long *outwid,char* nelly)
   {
   *outwid = write(whfile,wlpbuffer,wwidth);
   return 0;
   }
  DWORD SetFilePointer(HANDLE hsfile,long dmove,
                       long *dhigh,DWORD method)
  {
  DWORD sfpres;
  sfpres=0;
  if(method == FILE_BEGIN)
  {
  sfpres=lseek(hsfile,dmove,SEEK_SET);
  }
  if(method == FILE_CURRENT)
  {
  sfpres=lseek(hsfile,dmove,SEEK_CUR);
  }
  if(method == FILE_END)
  {
  sfpres=lseek(hsfile,dmove,SEEK_END);
  }
  return sfpres;
  }
  DWORD GetFileSize(HANDLE gfshan,char* gfsnelly)
  {
  DWORD gfsgfsr;
  long gfsdh[1];
  gfsgfsr=SetFilePointer(gfshan,0,gfsdh,FILE_END);
  SetFilePointer(gfshan,0,gfsdh,FILE_BEGIN);
  return gfsgfsr;
  }
  HANDLE CreateFile(char* gcfn,DWORD drwsel,
        DWORD zsm,char* securnel,DWORD dwcd,
                DWORD zattrib,HANDLE cfnelly)
  {
  HANDLE crfres;
  int opfres,latt;
  opfres=0;
  crfres = NULL;
  latt = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  latt = latt | S_IWGRP;
  latt = latt | S_IXUSR | S_IXGRP | S_IXOTH;
   if(drwsel == GENERIC_WRITE)
   {
  opfres=open(gcfn,O_WRONLY | O_CREAT | O_TRUNC,
   latt);
   }
 else if(drwsel==(GENERIC_READ | GENERIC_WRITE))
   {
   opfres=open(gcfn,O_RDWR | O_CREAT,
   latt);
   }
   else if(drwsel == GENERIC_READ)
   {
   opfres=open(gcfn,O_RDONLY,
   latt);
   }
   if((opfres > 0)&&(opfres <= 127))
   {
   crfres=(HANDLE)opfres;
   }
  return crfres;
  }
  int CloseHandle(HANDLE chww)
  {
  return close(chww);
  }
// -------------------- 361
//  void ldep(int lv)
//  {
//  deprint(debline,10,lv);
//  fwrite(debline,12,1,stdout);
//  }
// -----------------------------  367
  HANDLE FindFirstFile(char* fboot,
              WIN32_FIND_DATA* fffd)
  {
  HANDLE fffres;
  fffres=NULL;
//  ldep(fffres);
  xfivedp=opendir("./");
//  ldep(xfivedp);
  needfindc=1;
    if(xfivedp != NULL)
    {
    xfiveep=readdir(xfivedp);
//    ldep(xfiveep);
    if(xfiveep == NULL)
    {
    closedir(xfivedp);
    needfindc=0;
    }
    if(xfiveep != NULL)
    {
 if(findscpy(128,(*fffd).cFileName,(*xfiveep).d_name)>0)
    {
    fffres=xfivedp;
//    ldep(fffres);
    }
    if(fffres == NULL)
    {
    closedir(xfivedp);
    needfindc=0;
    }
    }
    }
//  ldep(fffres);
  return fffres;
  }
  int FindNextFile(HANDLE fnfh,
              WIN32_FIND_DATA* fffn)
  {
  int fnfres;
  char fnfnus[144];
  fnfnus[0]='\0';
  fnfnus[1]='\0';
//  findscpy(128,(*fffn).cFileName,fnfnus);
  fnfres=2;
  xfiveep=readdir(fnfh);
//  ldep(xfiveep);
  if(xfiveep != NULL)
  {
 if(findscpy(128,fnfnus,(*xfiveep).d_name)>0)
  {
//  ldep(*((*fffn).cFileName));
  fnfres=1;
  findscpy(128,(*fffn).cFileName,(*xfiveep).d_name);
  }
  }
  if(((fnfres & 1) == 0)&&(needfindc == 1))
  {
  closedir(fnfh);
  needfindc=0;
  }
  return fnfres;
  }
  int FindClose(HANDLE fcloh)
  {
  if(needfindc == 1)
  {
  closedir(fcloh);
  needfindc=0;
  }
  return needfindc;
  }
// end of file functions
   int findscpy(int fdscmax,char* fdscl,
                             char* fdscr)
   {
   int fdscilop,fdsclow;
   char fdscmid;
   fdscilop=0;
    while(fdscilop < fdscmax)
    {
    *(fdscl + fdscilop)='\0';
    fdscilop = fdscilop + 1;
    }
   fdsclow=1;
   fdscilop=0;
     while(fdsclow > 0)
     {
     fdscmid = *(fdscr + fdscilop);
     if(fdscmid < 33)fdsclow=0;
       if(fdsclow > 0)
       {
       *(fdscl + fdscilop) = fdscmid;
       fdscilop = fdscilop + 1;
       if(fdscilop >= fdscmax)fdsclow=0;
       }
      }
    if(fdscilop < fdscmax)
    {
    *(fdscl + fdscilop) = '\0';
    }
   return fdscilop;
   }
  void deprint(char* depres,int depw,int depin)
  {
  int deptop,depfrac,deprem,depbase;
  int depctr,deprod;
  deptop=depin;
  depbase=10;
  if(depin < 0)deptop=0-(depin+1);
  depctr=depw-1;
   while(depctr >= 0)
   {
   deprem=0-2;
   depfrac=deptop/depbase;
    while(deprem < 0)
    {
    deprod=depfrac*depbase;
    deprem=deptop-deprod;
    if(deprem < 0)depfrac=depfrac-1;
    }
   if(depin < 0)deprem=(depbase-1)-deprem;
   deprem=deprem+48;
   *(depres + depctr)=(char)deprem;
   deptop=depfrac;
   depctr=depctr-1;
   }
  *(depres+depw)='\015';
  *(depres+(depw+1))='\012';
  }
   int mwrevcram(int repos,int revmany,
                          char* mwrfrom)
   {
   int mwrevout,mwrctr,mwrterm;
   mwrevout=0;
   mwrctr=revmany-1;
    while(mwrctr >= 0)
    {
    mwrterm=(int)(*(mwrfrom+(mwrctr+repos)));
    if(mwrterm < 0)mwrterm=mwrterm+256;
    mwrevout=mwrevout*256;
    mwrevout=mwrevout+mwrterm;
    mwrctr=mwrctr-1;
    }
   return mwrevout;
   }
// ------
// bitmap header
// 00  2 19778
// 02 12 skipped
// 14  4 skipped   00  +14 is start (BITMAPINFO*)
// 18  4 biwidth   04
// 22  4 biheight  08
// 26  2 biplanes  12  always 1
// 28  2 bibitcount  14  values {1,4,8,24};
// 30  4 zerouncompressed  16 0
// 34 12 skipper  20
// 46  4 biclrused 36 number of colors used if > 0
// 50  4  36  skip
// 54  8  monochrome colortable 00  16777215
// 62     bottom line of pixels
//       increase width up to next dword
// --------
  int SetDIBitsToDevice(HDC bamdc,
      int XDest,int YDest,DWORD dwWidth,
      DWORD dwHeight,
      int zeroXSrc,int zeroYSrc,UINT zeStartScan,
      UINT cScanLines,
      VOID* lpvBits,
      BITMAPINFO* lpbmi,
      UINT fuColorUse)
  {
  char* lpvmi;
  char* lvvbits;
  int sbiwidth,sbiheight,sbibitcount;
  int sznocomp,setret;
  int sbiclrused,sctwhite,sctblack;
  int swwid,sbytewid;
  int shgtctr,swwdctr,svebase,svoutbase;
  int svchr,svisub,svosub;
  lpvmi=(char*)lpbmi;
  lvvbits=(char*)lpvBits;
  sbiwidth=mwrevcram(4,4,lpvmi);
  sbiheight=mwrevcram(8,4,lpvmi);
  sbibitcount=mwrevcram(14,2,lpvmi);
  sznocomp=mwrevcram(16,4,lpvmi);
  sbiclrused=mwrevcram(32,4,lpvmi);
  sctblack=mwrevcram(40,4,lpvmi);
  sctwhite=mwrevcram(44,4,lpvmi);
  setret=0;
  if(sbibitcount > 4)setret=982;
  if(sbibitcount != 1)setret=1;
  if(sznocomp != 0)setret=982;
  if(sbiclrused != 0)setret=982;
  if(sctblack != 0)setret=982;
  if(sctwhite != 16777215)setret=1;
  if(zeroXSrc != 0)setret=982;
  if(zeroYSrc != 0)setret=982;
  if(zeStartScan != 0)setret=982;
  if(cScanLines != dwHeight)setret=982;
  if(sbiheight != dwHeight)setret=982;
  if(sbiwidth != dwWidth)setret=982;
  swwid=0;
  sbytewid=0;
    if(sbibitcount == 1)
    {
    sbytewid=sbiwidth+31;
    swwid=sbytewid >> 5;
    sbytewid=swwid*4;
    swwid=(sbiwidth + 7) >> 3;
    }
    if((sbibitcount == 1)&&(setret == 0))
    {
    shgtctr=0;
     while(shgtctr < sbiheight)
     {
     svoutbase=(shgtctr + YDest)*wlisawid;
     svoutbase=svoutbase+(XDest >> 3);
     svebase=sbiheight-shgtctr;
     svebase=svebase-1;
     svebase=svebase*sbytewid;
     swwdctr=0;
      while(swwdctr < swwid)
      {
      svosub=swwdctr+svoutbase;
      svisub=swwdctr+svebase;
      svchr=(int)(*(lvvbits + svisub));
      if(svchr < 0)svchr=svchr+256;
      wkelly[svosub]=trev[svchr];
      swwdctr=swwdctr+1;
      }
     shgtctr=shgtctr+1;
     }
    }
    return setret;
    }
// end of SetDIBitsToDevice
  int GetMessage(MSG* gmsg,int zgm2,
                   int zgm3,int zgm4)
  {
  int t,sv;
  typekelly=0;
  validkelly=0;
  t=XCheckMaskEvent(kellydis,kellymask,&xekelly);
  if(t != 0)
  {
   if(xekelly.type == KeyRelease)
   {
    if(xekelly.xkey.send_event == 0)
    {
    sv=xekelly.xkey.keycode;
    keykelly=wkey[sv];
    typekelly=WM_KEYUP;
    validkelly=1;
    }
   }
   if(xekelly.type == KeyPress)
   {
    if(xekelly.xkey.send_event == 0)
    {
    sv=xekelly.xkey.keycode;
    keykelly=wkey[sv];
    typekelly=WM_KEYDOWN;
    validkelly=1;
    }
   }
   if(xekelly.type == ButtonPress)
   {
    if(xekelly.xbutton.send_event == 0)
    {
    keykelly=1;
    typekelly=WM_LBUTTONDOWN;
    validkelly=1;
// line 640
    kelmoupos = 65536 * xekelly.xbutton.y;
    kelmoupos = kelmoupos + xekelly.xbutton.x;
    }
   }
   if(xekelly.type == MotionNotify)
   {
    if(xekelly.xmotion.send_event == 0)
    {
    keykelly=0;
    typekelly=WM_MOUSEMOVE;
    validkelly=1;
    kelmoupos = 65536 * xekelly.xmotion.y;
    kelmoupos = kelmoupos + xekelly.xmotion.x;
    }
   }
// ---------------------------------
//   if(xekelly.type == CreateNotify)
//   {
//    if(xekelly.create.send_event == 0)
//    {
//    typekelly=WM_CREATE;
//    validkelly=1;
//    }
//  }
   if(xekelly.type == DestroyNotify)
   {
//    if(xekelly.create.send_event == 0)
//    {
    typekelly=WM_DESTROY;
    validkelly=1;
//    }
  }
   if(xekelly.type == Expose)
   {
    if(xekelly.xexpose.count == 0)
    {
    validkelly=1;
    typekelly=WM_PAINT;
    }
   }
   if(xekelly.type == ConfigureNotify)
   {
   if(xekelly.xconfigure.send_event == 0)
   {
   kellywid=xekelly.xconfigure.width;
   kellyhgt=xekelly.xconfigure.height;
   wlisawid = (kellywid + 7) >> 3;
   }
   }
  }
  return kellygm;
  }
// end of GetMessage
  int TranslateMessage(MSG* tcb)
  {
  return 0;
  }
  int DispatchMessage(MSG* mcb)
  {
  int dmr;
  LPARAM dmouxy;
  UINT cbmess;
  WPARAM cbwp;
   dmouxy=0;
   cbwp=0;
   dmr=1;
  cbmess=typekelly;
 if((typekelly==WM_KEYDOWN)||(typekelly==WM_KEYUP))
 {
 cbwp=keykelly;
 }
 if(typekelly==WM_LBUTTONDOWN)
 {
 cbwp = 1;
 dmouxy = kelmoupos;
 }
 if(typekelly==WM_MOUSEMOVE)
 {
 cbwp = 0;
 dmouxy = kelmoupos;
 }
   if(validkelly > 0)
   {
   dmr=(*kellycb)(NULL,cbmess,cbwp,dmouxy);
   }
  return dmr;
  }
  int GetWindowRect(HWND gwrhh,RECT* gwrwh)
  {
  (*gwrwh).left=0;
  (*gwrwh).top=0;
  (*gwrwh).right=kellywid+(*gwrwh).left;
  (*gwrwh).bottom=kellyhgt+(*gwrwh).top;
  return 0;
  }
  int RedrawWindow(HWND rdwh,RECT* rdwr,
                         int rw3,int rwor4)
  {
  sekelly.type=Expose;
  sekelly.xexpose.type=Expose;
  sekelly.xexpose.send_event=0;
  sekelly.xexpose.display=kellydis;
  sekelly.xexpose.window=kellywin;
  sekelly.xexpose.x=(*rdwr).left;
  sekelly.xexpose.y=(*rdwr).top;
  sekelly.xexpose.width=(*rdwr).right-(*rdwr).left;
  sekelly.xexpose.height=(*rdwr).bottom-(*rdwr).top;
  XSendEvent(kellydis,kellywin,
       1,ExposureMask,&sekelly);
  return 0;
  }
  HDC BeginPaint(HWND bphw,PAINTSTRUCT* bps)
  {
  getgc(kellywin,&kellygc,1);
  return 0;
  }
  int EndPaint(HWND ephw,PAINTSTRUCT* eps)
  {
  kellymap=XCreatePixmapFromBitmapData(kellydis,
    kellywin,wkelly,kellywid,kellyhgt,
    WhitePixel(kellydis,kellynum),
       BlackPixel(kellydis,kellynum),kellydepth);
  XCopyArea(kellydis,kellymap,kellywin,
              kellygc,0,0,kellywid,kellyhgt,0,0);
  XFreePixmap(kellydis,kellymap);
  XFreeGC(kellydis,kellygc);
  return 0;
  }
  HWND CreateWindow(char* jn,char* snw,
             int olap3,int xul,int yul,
                   int widcw,int hgtcw,
  int cw8,int cw9,char* cwinstance,int cwii)
  {
  kellyulxz=xul;
  kellyulyz=yul;
  kellywid=widcw;
  kellyhgt=hgtcw;
  wlisawid=(kellywid + 7) >> 3;
  kellynull = NULL;
  PostQuitMessage(1);
  kellydis=XOpenDisplay(kellynull);
  kellynum=DefaultScreen(kellydis);
  kellydepth=DefaultDepth(kellydis,kellynum);
  kellywin=makexw(ksizeh,kwmhints,kclassh);
  XSetWMProperties(kellydis,kellywin,0,0,
         argkb,argkd,ksizeh,kwmhints,kclassh);
//  getgc(kellywin,&kellygc,1);
  XMapWindow(kellydis,kellywin);
// backup initialization is next
  (*kellycb)(NULL,WM_CREATE,0,0);
  return 0;
  }
  int PostQuitMessage(int qmess)
  {
  kellygm=qmess;
  return 0;
  }
  int RegisterClass(WNDCLASS* kelwnd)
  {
  kellycb = (*(kelwnd)).lpfnWndProc;
  return 0;
  }
 void getgc(Window wigc,GC* wrgc,int zbnzw)
 {
 unsigned long vgcmask=0;
 XGCValues vgcvalues;
 unsigned int gclw=1;
 int linestyle=LineSolid;
 int capstyle=CapRound;
 int joinstyle=JoinRound;
 int fillstyle=FillSolid;
 *wrgc=XCreateGC(kellydis,wigc,vgcmask,&vgcvalues);
 XSetLineAttributes(kellydis,*wrgc,gclw,
           linestyle,capstyle,joinstyle);
 if(zbnzw == 0)
 {
 XSetBackground(kellydis,*wrgc,
      WhitePixel(kellydis,kellynum));
 }
 if(zbnzw == 1)
 {
 XSetBackground(kellydis,*wrgc,
      BlackPixel(kellydis,kellynum));
 }
 XSetFillStyle(kellydis,*wrgc,fillstyle);
 if(zbnzw == 0)XSetForeground(kellydis,*wrgc,
                 BlackPixel(kellydis,kellynum));
 if(zbnzw == 1)XSetForeground(kellydis,*wrgc,
                 WhitePixel(kellydis,kellynum));
 }
// end of getgc(Window,GC*,int);
 Window makexw(XSizeHints* sizehints,
  XWMHints* wmhints,XClassHint* classhints)
  {
//  int sbmask;
  Window trix;
 trix=XCreateSimpleWindow(kellydis,
        RootWindow(kellydis,kellynum),
        kellyulxz,kellyulyz,
        kellywid,kellyhgt,4,
     BlackPixel(kellydis,kellynum),
        WhitePixel(kellydis,kellynum));
// nzshift=0;
 sizehints = XAllocSizeHints();
 wmhints = XAllocWMHints();
 classhints = XAllocClassHint();
 (*(wmhints)).initial_state=NormalState;
 (*(wmhints)).input = True;
 (*(wmhints)).icon_pixmap = 0;
 (*(wmhints)).flags = StateHint | InputHint;
 (*(classhints)).res_name = 0;
 (*(classhints)).res_class = "Basicwin";
 (*(sizehints)).flags=PPosition|PSize|PMinSize;
 (*(sizehints)).min_width =  kellywid;
 (*(sizehints)).min_height = kellyhgt;
 kellymask = 0;
 kellymask = kellymask | KeyPressMask;
 kellymask = kellymask | KeyReleaseMask;
 kellymask = kellymask | ExposureMask;
 kellymask = kellymask | StructureNotifyMask;
 kellymask = kellymask | ButtonPressMask;
 kellymask = kellymask | PointerMotionMask;
// kellymask=kellymask | SubstructureNotifyMask;
 XSelectInput(kellydis,trix,kellymask);
  return trix;
  }
// ------------- bottom of windowmake
// ------------------------------------
  int OpenClipboard(HWND ocbFrom)
  {
  return 0;
  }
  kellyhan GetClipboardData(int GCDtype)
  {
  return NULL;
  }
  int CloseClipboard()
  {
  return 0;
  }
  kellyhan GlobalAlloc(int GAt,int GATsize)
  {
  return NULL;
  }
  VOID* GlobalLock(kellyhan GLarea)
  {
  return NULL;
  }
  int GlobalUnlock(kellyhan GUhan)
  {
  return 0;
  }
  kellyhan GlobalHandle(kellyhan GHahan)
  {
  return NULL;
  }
  kellyhan SetClipboardData(int SCDtype,
                         kellyhan SCDhan)
  {
  return NULL;
  }
  LRESULT DefWindowProc(HWND DWPa,UINT DWPb,
                     WPARAM DWPc,LPARAM DWPd)
  {
  return 1;
  }
  kellyhan LoadIcon(char* LIlpc,int LIona)
  {
  return NULL;
  }
  kellyhan LoadCursor(char* LClpc,int LCona)
  {
  return NULL;
  }
  int ShowWindow(HWND SWh,int SWnum)
  {
  return 0;
  }
  int UpdateWindow(HWND UWhan)
  {
  return 0;
  }
// -------------------------------------
  int main(int iiwi,char** argci)
  {
  int awid4;
  LPSTR cmd3;
  HINSTANCE wmp2;
  HINSTANCE wma1;
  int chteep,chwmt;
  argkd=0;
  argkb=NULL;
  kellywm = &WinMain;
  cmd3=NULL;
  awid4=0;
  chteep=0;
  chwmt=65;
  wmp2=0;
  wma1=0;
    if(iiwi == 2)
    {
    cmd3 = *(argci + 1);
      while(chwmt > 32)
      {
      chwmt = (int)(*(cmd3 + chteep));
        if(chwmt > 32)
        {
        chteep = chteep +1;
        if(chteep > 75)chwmt=0;
        }
      }
    awid4=chteep;
    }
  chteep=(*kellywm)(wma1,wmp2,cmd3,awid4);
  return 0;
  }
// main uses (*(*(argci + 1)+ctr)) if iiwi == 2
// bam10006.h
// This is the last line of this header file
/* after end of header file

0
ericmatteson2003nove
12/19/2009 2:05:02 PM
comp.emulators.ms-windows.wine 4950 articles. 0 followers. Post Follow

0 Replies
409 Views

Similar Articles

[PageSpeed] 35

Reply: