home *** CD-ROM | disk | FTP | other *** search
/ Amiga Dream 59 / CDDream59.ISO / Amiga / Emulation / cp4.lha / cp4 / c2p_src / c2p_windowcard.c < prev    next >
C/C++ Source or Header  |  1998-12-03  |  14KB  |  501 lines

  1. /* :ts=4                            c2p_windowcard.c
  2.  *
  3.  *    cp4 - Commodore C+4 emulator
  4.  *    Copyright (C) 1998 Gßti Gergely
  5.  *
  6.  *    This program is free software; you can redistribute it and/or modify
  7.  *    it under the terms of the GNU General Public License as published by
  8.  *    the Free Software Foundation; either version 2 of the License, or
  9.  *    (at your option) any later version.
  10.  *
  11.  *    This program is distributed in the hope that it will be useful,
  12.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *    GNU General Public License for more details.
  15.  *
  16.  *    You should have received a copy of the GNU General Public License
  17.  *    along with this program; if not, write to the Free Software Foundation,
  18.  *    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  *
  20.  *    e-mail: gatig@dragon.klte.hu
  21.  */
  22. #include <proto/graphics.h>
  23. #include <graphics/gfxbase.h>
  24. #include <proto/exec.h>
  25. #include <exec/alerts.h>
  26. #include <proto/intuition.h>
  27. #include <intuition/pointerclass.h>
  28. #include <proto/gadtools.h>
  29. #include <proto/layers.h>
  30.  
  31. #define C2P_INFO        "Workbench window driver. Works on GFX cards and AGA too."
  32. #define C2P_VERSION        "1"
  33. #define C2P_REVISION    "1"
  34. #define C2P_AUTHOR        "gega <Gßti Gergely>"
  35. #define C2P_NAME        "WindowCard"
  36.  
  37. #include "c2p_module.c"
  38. #include "c2p_windowcard_palette.c"
  39. #include "c2p_color_priority.c"
  40.  
  41.  
  42. struct GfxBase *GfxBase=NULL;
  43. struct ExecBase *SysBase;
  44. struct IntuitionBase *IntuitionBase=NULL;
  45. struct Library *GadToolsBase=NULL;
  46. struct Library *LayersBase=NULL;
  47. static struct BitMap *bmap;
  48. static struct Window *win=NULL;
  49. static int offx=0,offy=0;
  50. static int maxx,maxy;
  51. static int borhoriz,borvert;
  52. static struct BitMap mybmap;
  53. static void *mypointer=NULL;
  54. static UWORD *mypntchip0=NULL;
  55. static UWORD *mypntchip1=NULL;
  56. static struct ColorMap *colmap=NULL;
  57. static struct BitMap *bmapwpx;
  58. static struct RastPort *tmpraswpx;
  59. static struct RastPort *raswpx;
  60. static int winsleeped=0;
  61. static struct Requester InvisibleRequester;
  62. static LONG PenTable[256];
  63. static unsigned char PenArray[SCRSIZE];
  64. static struct Menu *mMenus=NULL;
  65. static APTR visualinfo=NULL;
  66. /* LORES-POINTER
  67.  */
  68. #define POINTERHEIGHT    31
  69. static UWORD pointerp0[]={ 0,384,384,3504,3504,3504,28080,28080,28080,28086,28086,28086,32758,32758,32766,32766,32764,16380,16376,16376,0,32764,0,32764,32740,32764,32740,32764,32764,32736,28672 };
  70. static UWORD pointerp1[]={ 384,960,4080,8184,8184,32760,65528,65528,65534,65535,65535,65535,65535,65535,65535,65535,65534,32766,32764,32764,65534,65534,65534,32770,32794,32770,32794,32770,32770,32768,32768 };
  71.  
  72. /* prefs
  73.  */
  74. static int WTop,WLeft,WHeight,WWidth,Wx,Wy;
  75. static char *WPubName=NULL;
  76.  
  77. /* Protos
  78.  */
  79. static char *initgfx(void);
  80. static void freegfx(void);
  81. static int mReset(struct IntuiMessage *imsg);
  82. static int mHReset(struct IntuiMessage *imsg);
  83. static int mDebug(struct IntuiMessage *imsg);
  84. static int mPrefs(struct IntuiMessage *imsg);
  85. static int mJump(struct IntuiMessage *imsg);
  86. static int mQuit(struct IntuiMessage *imsg);
  87.  
  88.  
  89. /* Menu
  90.  */
  91. static struct NewMenu mNewMenu[]={
  92.     {    NM_TITLE, (STRPTR)"Project", NULL, 0, NULL, NULL    },
  93.     {    NM_ITEM, (STRPTR)"Reset", (STRPTR)"R", 0, 0L, (APTR)mReset },
  94.     {    NM_ITEM, (STRPTR)"HardReset", (STRPTR)"H", 0, 0L, (APTR)mHReset },
  95.     {    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL    },
  96.     {    NM_ITEM, (STRPTR)"Debug...", (STRPTR)"D", 0, 0L, (APTR)mDebug },
  97.     {    NM_ITEM, (STRPTR)"Prefs...", (STRPTR)"P", 0, 0L, (APTR)mPrefs },
  98.     {    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL    },
  99.     {    NM_ITEM, (STRPTR)"Quit", (STRPTR)"X", 0, 0L, (APTR)mQuit },
  100.     {    NM_TITLE, (STRPTR)"Options", NULL, 0, NULL, NULL    },
  101.     {    NM_ITEM, (STRPTR)"Jump PubScreen", (STRPTR)"J", 0, 0L, (APTR)mJump },
  102.     {    NM_END, NULL, NULL, 0, 0L, NULL    }
  103. };
  104.  
  105.  
  106. /* Handle MenuPick
  107.  */
  108. static int mReset(struct IntuiMessage *imsg) {
  109.     return(RET_RESET);
  110. } // mReset()
  111.  
  112. static int mHReset(struct IntuiMessage *imsg) {
  113.     return(RET_HRESET);
  114. } // mHReset()
  115.  
  116. static int mDebug(struct IntuiMessage *imsg) {
  117.     return(RET_DEBUG);
  118. } // mDebug()
  119.  
  120. static int mPrefs(struct IntuiMessage *imsg) {
  121.     return(RET_PREFS);
  122. } // mPrefs()
  123.  
  124. static int mQuit(struct IntuiMessage *imsg) {
  125.     return(RET_QUIT);
  126. } // mQuit()
  127.  
  128. static int mJump(struct IntuiMessage *imsg) {
  129. static char newname[MAXPUBSCREENNAME+1];
  130.     int r=RET_OK,i;
  131.     char *s;
  132.  
  133.     if(NULL!=(NextPubScreen(vec.c2p_Scr,newname))) {
  134.         if(NULL!=(s=AllocVec(MAXPUBSCREENNAME+1,MEMF_ANY))) {
  135.             freegfx();
  136.             r=RET_NEWWIN;
  137.             for(i=0;newname[i]!='\0';i++);
  138.             CopyMem(newname,s,i+1);
  139.             if(WPubName) FreeVec(WPubName);
  140.             WPubName=s;
  141.             if(NULL!=(initgfx())) {
  142.                 freegfx();
  143.                 // PANIC!!!
  144.                 Alert(AT_Recovery|AG_NoMemory|AO_Unknown);
  145.                 return(RET_ERROR);
  146.             }
  147.         }
  148.     }
  149.     return(r);
  150. } // mJump()
  151.  
  152.  
  153. static INLINE void calcwinsizes() {
  154.     borhoriz=win->BorderRight+win->BorderLeft-1;
  155.     borvert=win->BorderTop+win->BorderBottom-1;
  156.     maxx=SCRWIDTH-(win->Width-borhoriz);
  157.     maxy=SCRHEIGHT-(win->Height-borvert);
  158.     if(offx>maxx) {
  159.         ScrollLayer(0,win->RPort->Layer,-(offx-maxx),0);
  160.         offx=maxx;
  161.     }
  162.     if(offy>maxy) {
  163.         ScrollLayer(0,win->RPort->Layer,0,-(offy-maxy));
  164.         offy=maxy;
  165.     }
  166. }
  167.  
  168.  
  169. static char *initgfx(void) {
  170. static char pname[MAXPUBSCREENNAME+1];
  171.     ULONG r,g,b;
  172.     int planes,i,j,mx,my;
  173.  
  174.     for(i=0;i<256;i++) PenTable[i]=-1;
  175.  
  176.     /* Get the required PubScreen
  177.      */
  178.     if(NULL==(vec.c2p_Scr=LockPubScreen(WPubName))) {
  179.         vec.c2p_Scr=LockPubScreen(NULL);
  180.         GetDefaultPubScreen(pname);
  181.         if(WPubName) FreeVec(WPubName);
  182.         for(i=0;pname[i]!='\0';i++);
  183.         if(NULL==(WPubName=AllocVec(i+2,MEMF_ANY))) return(C2P_NOMEM);
  184.         CopyMem(pname,WPubName,i+1);
  185.     }
  186.  
  187.     /* ScreenToFront
  188.      */
  189.     ScreenToFront(vec.c2p_Scr);
  190.  
  191.     /* Get Screen Attribs
  192.      */
  193.     planes=vec.c2p_Scr->BitMap.Depth;
  194.     colmap=vec.c2p_Scr->ViewPort.ColorMap;
  195.     if(!(visualinfo=GetVisualInfo(vec.c2p_Scr,TAG_DONE))) return("Can't find VisualInfo");
  196.  
  197.     /* Allocate bitmap
  198.      */
  199.     if(NULL==(bmap=AllocBitMap(SCRWIDTH,SCRHEIGHT,planes,BMF_DISPLAYABLE|BMF_CLEAR,NULL))) return(C2P_NOMEM);
  200.  
  201.     /* SetUp Menu
  202.      */
  203.     if(!(mMenus=CreateMenus(mNewMenu,GTMN_FrontPen,0L,TAG_DONE,0L))) return("Can't Create Menu");
  204.     LayoutMenus(mMenus,visualinfo,GTMN_TextAttr,(ULONG)vec.c2p_Scr->Font,GTMN_NewLookMenus,TRUE,TAG_DONE,0L);
  205.  
  206.     /* Open window
  207.      */
  208.     if((win=(struct Window *)OpenWindowTags(NULL,
  209.                 WA_Left, WLeft,
  210.                 WA_Top, WTop,
  211.                 WA_Width, WWidth,
  212.                 WA_Height, WHeight,
  213.                 WA_Title, (ULONG)"cp4 WindowCard",
  214.                 WA_Flags,    WFLG_SIZEGADGET|
  215.                             WFLG_SIZEBBOTTOM|
  216.                             WFLG_DRAGBAR|
  217.                             WFLG_DEPTHGADGET|
  218.                             WFLG_CLOSEGADGET|
  219.                             WFLG_SUPER_BITMAP|
  220.                             WFLG_GIMMEZEROZERO|
  221.                             WFLG_ACTIVATE,
  222.                 WA_SuperBitMap, (ULONG)bmap,
  223.                 WA_AutoAdjust, TRUE,
  224.                 WA_RptQueue, 25,
  225.                 WA_IDCMP,     IDCMP_MOUSEMOVE|
  226.                             IDCMP_CLOSEWINDOW|
  227.                             IDCMP_MENUPICK|
  228.                             IDCMP_NEWSIZE|
  229.                             IDCMP_MOUSEBUTTONS,
  230.                 WA_PubScreen, (ULONG)vec.c2p_Scr,
  231.                 WA_PubScreenFallBack, TRUE,
  232.                 WA_NewLookMenus, TRUE,
  233.                 TAG_DONE,0L ))==NULL)
  234.         return("Can't open Window");
  235.     SetMenuStrip(win,mMenus);
  236.     vec.c2p_Win=win;
  237.     winsleeped=0;
  238.     offx=offy=0;
  239.     calcwinsizes();
  240.     WindowLimits(win,borhoriz+80,borvert+20,SCRWIDTH+borhoriz,borvert+SCRHEIGHT);
  241.     offx+=Wx;        offy+=Wy;
  242.     mx=Wx;            my=Wy;
  243.     if(offx<0)        { mx-=offx; offx=0; }
  244.     if(offx>maxx)    { mx-=offx-maxx; offx=maxx; }
  245.     if(offy<0)        { my-=offy; offy=0; }
  246.     if(offy>maxy)    { my-=offy-maxy; offy=maxy; }
  247.     ScrollLayer(0,win->RPort->Layer,mx,my);
  248.  
  249.     /* Allocate & Init TMP rasters for WritePixel...
  250.      */
  251.     bmapwpx=AllocBitMap(SCRWIDTH,1,planes,BMF_CLEAR,NULL);
  252.     if(bmapwpx==NULL) return(C2P_NOMEM);
  253.     tmpraswpx=AllocVec(sizeof(struct RastPort),MEMF_ANY);
  254.     if(tmpraswpx==NULL) return(C2P_NOMEM);
  255.     InitRastPort(tmpraswpx);
  256.     tmpraswpx->BitMap=bmapwpx;
  257.     raswpx=AllocVec(sizeof(struct RastPort),MEMF_ANY);
  258.     if(raswpx==NULL) return(C2P_NOMEM);
  259.     InitRastPort(raswpx);
  260.     raswpx->BitMap=bmap;
  261.  
  262.     /* SetUp PenTable
  263.      */
  264.     if(colmap==NULL) return("Can't Find ColorMap");
  265.     for(i=0;i<256;i++) {
  266.         j=ColorPriority[i]*3;
  267.         r=Palette[j];
  268.         g=Palette[j+1];
  269.         b=Palette[j+2];
  270.         if(-1==(PenTable[ColorPriority[i]]=ObtainBestPen(colmap,r,g,b,OBP_Precision,PRECISION_GUI,TAG_DONE))) return("Can't Obtain Pens");
  271.     }
  272.     return(NULL);
  273. } // initgfx()
  274.  
  275.  
  276. static void freegfx(void) {
  277.     int i;
  278.     mawake();
  279.     if(GfxBase) {
  280.         WaitTOF();
  281.         if(colmap) for(i=0;i<256;i++) if(PenTable[i]!=-1) ReleasePen(colmap,PenTable[i]);
  282.     }
  283.     if(win) {
  284.         WTop=win->TopEdge;
  285.         WLeft=win->LeftEdge;
  286.         WHeight=win->Height;
  287.         WWidth=win->Width;
  288.         vec.c2p_AddOptionInt("WINTOP",WTop);
  289.         vec.c2p_AddOptionInt("WINLEFT",WLeft);
  290.         vec.c2p_AddOptionInt("WINHEIGHT",WHeight);
  291.         vec.c2p_AddOptionInt("WINWIDTH",WWidth);
  292.         Wx=offx;
  293.         Wy=offy;
  294.         vec.c2p_AddOptionInt("OFFX",Wx);
  295.         vec.c2p_AddOptionInt("OFFY",Wy);
  296.         ClearMenuStrip(win);
  297.         CloseWindow(win);
  298.         win=NULL;
  299.     }
  300.     vec.c2p_Win=NULL;
  301.     if(mMenus) { FreeMenus(mMenus); mMenus=NULL; }
  302.     if(visualinfo) { FreeVisualInfo(visualinfo); visualinfo=NULL; }
  303.     if(vec.c2p_Scr) {
  304.         vec.c2p_AddOptionStr("PUBSCREEN",WPubName);
  305.         UnlockPubScreen(NULL,vec.c2p_Scr);
  306.         vec.c2p_Scr=NULL;
  307.     }
  308.     if(bmap) { FreeBitMap(bmap); bmap=NULL; }
  309.     if(bmapwpx) { FreeBitMap(bmapwpx); bmapwpx=NULL; }
  310.     if(tmpraswpx) { FreeVec(tmpraswpx); tmpraswpx=NULL; }
  311.     if(raswpx) { FreeVec(raswpx); raswpx=NULL; }
  312. } // freegfx()
  313.  
  314.  
  315. char *SAVEDS minit(ULONG scrmode, ULONG overscan, unsigned char *linedeltatab) {
  316.     int i;
  317.     ULONG res;
  318.     char *s;
  319.  
  320.     SysBase=*((struct ExecBase **)4L);
  321.     if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39))) return("Can't open Graphics.library V39");
  322.     if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39))) return("Can't open Intuition.library V39");
  323.     if(!(GadToolsBase=OpenLibrary("gadtools.library",37))) return("Can't open GadTools.library V37");
  324.     if(!(LayersBase=OpenLibrary("layers.library",33))) return("Can't open Layers.library V33");
  325.  
  326.     /* Set up pointer
  327.      */
  328.     if(NULL==(mypntchip0=AllocVec((POINTERHEIGHT+1)*2,MEMF_CHIP))) return(C2P_NOMEM);
  329.     if(NULL==(mypntchip1=AllocVec((POINTERHEIGHT+1)*2,MEMF_CHIP))) return(C2P_NOMEM);
  330.     CopyMem(pointerp0,mypntchip0,2*POINTERHEIGHT);
  331.     CopyMem(pointerp1,mypntchip1,2*POINTERHEIGHT);
  332.     InitBitMap(&mybmap,2,16,POINTERHEIGHT);
  333.     mybmap.Planes[0]=(PLANEPTR)mypntchip0;
  334.     mybmap.Planes[1]=(PLANEPTR)mypntchip1;
  335.     res=POINTERYRESN_DEFAULT;
  336.     if(((GfxBase->ChipRevBits0&GFXF_HR_AGNUS)!=0)&&((GfxBase->ChipRevBits0&GFXF_HR_DENISE)!=0)) res=POINTERXRESN_SCREENRES;
  337.     mypointer=NewObject(NULL,"pointerclass",
  338.         POINTERA_BitMap, (ULONG)&mybmap,
  339.         POINTERA_XOffset, -6,
  340.         POINTERA_WordWidth, 1,
  341.         POINTERA_XResolution, res,
  342.         POINTERA_YResolution, res,
  343.         TAG_DONE );
  344.     if(mypointer==NULL) return("Can't Create Pointer");
  345.  
  346.     /* Get Options
  347.      */
  348.     Wx=vec.c2p_GetOptionInt("OFFX",0);
  349.     Wy=vec.c2p_GetOptionInt("OFFY",0);
  350.     WTop=vec.c2p_GetOptionInt("WINTOP",0);
  351.     WLeft=vec.c2p_GetOptionInt("WINLEFT",0);
  352.     WHeight=vec.c2p_GetOptionInt("WINHEIGHT",100);
  353.     WWidth=vec.c2p_GetOptionInt("WINWIDTH",300);
  354.     s=vec.c2p_GetOptionStr("PUBSCREEN","Workbench");
  355.     for(i=0;s[i]!='\0';i++);
  356.     if(NULL==(WPubName=AllocVec(i+2,MEMF_ANY))) return(C2P_NOMEM);
  357.     CopyMem(s,WPubName,i+1);
  358.  
  359.     return(initgfx());
  360. } // minit
  361.  
  362.  
  363. void SAVEDS mfree(void) {
  364.     freegfx();
  365.     if(mypntchip0) { FreeVec(mypntchip0); mypntchip0=NULL; }
  366.     if(mypntchip1) { FreeVec(mypntchip1); mypntchip1=NULL; }
  367.     if(mypointer) { DisposeObject(mypointer); mypointer=NULL; }
  368.     if(GfxBase) CloseLibrary((struct Library *)GfxBase);
  369.     if(IntuitionBase) { CloseLibrary((struct Library *)IntuitionBase); IntuitionBase=NULL; }
  370.     if(GadToolsBase) { CloseLibrary(GadToolsBase); GadToolsBase=NULL; }
  371.     if(LayersBase) CloseLibrary(LayersBase);
  372.     return;
  373. } // free
  374.  
  375.  
  376. int SAVEDS mdo(unsigned char *chunky,unsigned char *delta,int numscreen) {
  377.     return(mdofull(chunky,numscreen));
  378. } // do
  379.  
  380.  
  381. int SAVEDS mdofull(unsigned char *chunky,int numscreen) {
  382.     struct IntuiMessage *imsg;
  383.     struct MenuItem *n;
  384.     int (*func)(struct IntuiMessage *);
  385.     int ret=RET_OK,i,move=0,lastx=0,lasty=0;
  386.     unsigned char *p,*c;
  387.  
  388.     while((imsg=(struct IntuiMessage *)RemHead(&vec.c2p_MsgList))) {
  389.         switch(imsg->Class) {
  390.             case IDCMP_CLOSEWINDOW :
  391.                 ret=RET_QUIT;
  392.                 break;
  393.             case IDCMP_MENUPICK :
  394.                 while(imsg->Code!=MENUNULL) {
  395.                     n=ItemAddress(mMenus,imsg->Code);
  396.                     func=(void *)(GTMENUITEM_USERDATA(n));
  397.                     ret=func(imsg);
  398.                     if(ret==RET_NEWWIN||ret==RET_ERROR) {
  399.                         move=0;
  400.                         break;
  401.                     }
  402.                     imsg->Code=n->NextSelect;
  403.                 }
  404.                 break;
  405.             case IDCMP_NEWSIZE :
  406.                 calcwinsizes();
  407.                 break;
  408.             case IDCMP_MOUSEBUTTONS :
  409.                 if(imsg->Code==SELECTDOWN) {
  410.                     move=1;
  411.                     lastx=imsg->MouseX;
  412.                     lasty=imsg->MouseY;
  413.                 } else move=0;
  414.                 break;
  415.         }
  416.     }
  417.  
  418.     /* Handle Drag Window
  419.      */
  420.     if(move!=0) {
  421.         int mx,my,class,t1,t2;
  422.  
  423.         ReportMouse(TRUE,win);
  424.         SetWindowPointer(win,WA_Pointer,(ULONG)mypointer,TAG_DONE);
  425.         while(move!=0) {
  426.             WaitPort(win->UserPort);
  427.             imsg=(struct IntuiMessage *)GetMsg(win->UserPort);
  428.             mx=imsg->MouseX;
  429.             my=imsg->MouseY;
  430.             class=imsg->Class;
  431.             ReplyMsg((struct Message *)imsg);
  432.             switch(class) {
  433.                 case IDCMP_MOUSEBUTTONS :
  434.                     move=0;
  435.                     break;
  436.                 case IDCMP_MOUSEMOVE :
  437.                     offx+=lastx-mx;    offy+=lasty-my;
  438.                     t1=mx;            t2=my;
  439.                     mx=lastx-mx;    my=lasty-my;
  440.                     lastx=t1;        lasty=t2;
  441.                     if(offx<0)        { mx-=offx; offx=0; }
  442.                     if(offx>maxx)    { mx-=offx-maxx; offx=maxx; }
  443.                     if(offy<0)        { my-=offy; offy=0; }
  444.                     if(offy>maxy)    { my-=offy-maxy; offy=maxy; }
  445.                     ScrollLayer(0,win->RPort->Layer,mx,my);
  446.                     break;
  447.             }
  448.         }
  449.         SetWindowPointer(win,TAG_DONE);
  450.         ReportMouse(FALSE,win);
  451.     }
  452.  
  453.     if(chunky!=NULL) {
  454.         /* Convert chunky into PenArray
  455.          */    
  456.         i=SCRSIZE;
  457.         c=chunky;
  458.         p=PenArray;
  459.         do { *p++=PenTable[*c++]; } while(--i);
  460.  
  461.         if(ret!=RET_NEWWIN||ret!=RET_ERROR) {
  462.             /* Do the c2p
  463.              */
  464.             WritePixelArray8(raswpx,0,0,SCRWIDTH-1,SCRHEIGHT-1,PenArray,tmpraswpx);
  465.  
  466.             /* Copy into the window
  467.              */
  468.             LockLayerRom(win->RPort->Layer);
  469.             CopySBitMap(win->RPort->Layer);
  470.             UnlockLayerRom(win->RPort->Layer);
  471.         }
  472.     }
  473.     return(ret);
  474. } // dofull
  475.  
  476.  
  477. int SAVEDS mdont(void) {
  478.     return(mdofull(NULL,0));
  479. } // dont
  480.  
  481.  
  482. void SAVEDS msleep(void) {
  483.     if(win) {
  484.         InitRequester(&InvisibleRequester);
  485.         Request(&InvisibleRequester,win);
  486.         SetWindowPointer(win,WA_BusyPointer,TRUE,TAG_DONE);
  487.         winsleeped=1;
  488.     }
  489. }
  490.  
  491.  
  492. void SAVEDS mawake(void) {
  493.     if(winsleeped) {
  494.         if(win) {
  495.             EndRequest(&InvisibleRequester,win);
  496.             SetWindowPointerA(win,NULL);
  497.             winsleeped=0;
  498.         }
  499.     }
  500. }
  501.