home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / omron / omronFsBm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-29  |  6.1 KB  |  275 lines

  1. /*
  2.  * $XConsortium: omronFsBm.c,v 1.1 91/06/29 13:48:56 xguest Exp $
  3.  *
  4.  * Copyright 1991 by OMRON Corporation
  5.  * 
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of OMRON not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  OMRON makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OMRON
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24. #if defined(luna1) && defined(uniosu)
  25.  
  26. #include "omron.h" 
  27.  
  28. #include "omronFb.h" 
  29.  
  30. #define PALADR(p)        (p->reg.addr)
  31. #define PALCONT(p)        (p->reg.control)
  32. #define PALCDATA(p)        (p->reg.coldata)
  33. #define PALOVCDATA(p)    (p->reg.ovcdata)
  34.  
  35. /*
  36. **    color palette 
  37. */
  38. struct pal{
  39.     unsigned char red;
  40.     unsigned char green;
  41.     unsigned char blue;
  42. };
  43.  
  44. static struct pal paldata[256] = {
  45.     {~0,~0,~0}, {0,0,0},
  46.     {~0,~0,~0}, {0,0,0},
  47.     {~0,~0,~0}, {0,0,0},
  48.     {~0,~0,~0}, {0,0,0},
  49.     {~0,~0,~0}, {0,0,0},
  50.     {~0,~0,~0}, {0,0,0},
  51.     {~0,~0,~0}, {0,0,0},
  52.     {~0,~0,~0}, {0,0,0}
  53. };
  54.  
  55. static struct pal palinit[256] = {
  56.     {~0,~0,~0}, {0,0,0},
  57.     {~0,~0,~0}, {0,0,0},
  58.     {~0,~0,~0}, {0,0,0},
  59.     {~0,~0,~0}, {0,0,0},
  60.     {~0,~0,~0}, {0,0,0},
  61.     {~0,~0,~0}, {0,0,0},
  62.     {~0,~0,~0}, {0,0,0},
  63.     {~0,~0,~0}, {0,0,0}
  64. };
  65.  
  66. static struct pal palsave[256];
  67.  
  68. static int      pagesize;
  69.  
  70. static Bool omronFsBmPalCreate();
  71. static void omronFsBmPalInit();
  72. static void omronFsBmSetPal();
  73.  
  74. Bool
  75. omronFsBmCreate(omron_fb_info)
  76. OmronFbInfoPtr omron_fb_info;
  77. {
  78.     FsBmMapPtr fs_bm_reg = (caddr_t)0xd0000000;    /* frame buffer i/o port */
  79.  
  80.     /* Set transparent Mapping. */
  81.     if(sys9100(S91TPTRE, 0xd0, 0, 0) < 0) {
  82.         return FALSE;
  83.     }
  84.  
  85.     omron_fb_info->plane = (char *)0xd0200000;    
  86.  
  87.     omron_fb_info->fbmap = (char *)fs_bm_reg;
  88.     omron_fb_info->refresh_reg = &(fs_bm_reg->refresh.reg);
  89.     omron_fb_info->palmap      = (char *) &(fs_bm_map->palette);
  90.  
  91.     if (!omronFsBmPalCreate(omron_fb_info)) {
  92.         return FALSE;
  93.     }
  94.  
  95.     return TRUE;
  96. }
  97.  
  98.  
  99. static Bool
  100. omronFsBmSaveScreen(pScreen, on)
  101. ScreenPtr     pScreen;
  102. Bool          on;
  103. {
  104. static int omronScreenIsSaved = FALSE;
  105.     struct pal savepal[256];     
  106.     OmronFbInfoPtr pFbInfo =
  107.         (OmronFbInfoPtr)pScreen->devPrivates[omronScreenIndex].ptr;
  108.  
  109.     if (on != SCREEN_SAVER_ON) {
  110.         omronSetLastEventTime();
  111.         if(omronScreenIsSaved == TRUE) {
  112.             omronFsBmSetPal(pFbInfo, palsave);
  113.             omronScreenIsSaved = FALSE;
  114.         }
  115.         return TRUE;
  116.     }
  117.  
  118.     bzero(savepal, sizeof(savepal));
  119.     omronFsBmSetPal(pFbInfo, savepal);
  120.     omronScreenIsSaved = TRUE;
  121.     return TRUE;
  122. }
  123.  
  124. Bool
  125. omronFsBmInit(index, pScreen, argc, argv)
  126.     int           index;
  127.     ScreenPtr     pScreen;
  128.     int           argc;
  129.     char          **argv;
  130. {
  131.     OmronFbInfoPtr pFbInfo;
  132.     extern miPointerScreenFuncRec  omronPointerScreenFuncs;
  133.     
  134.     pFbInfo = (OmronFbInfoPtr) pScreen->devPrivates[omronScreenIndex].ptr;
  135.  
  136.     omronFsBmPalInit(pFbInfo);
  137.  
  138.     if (!monitorResolution) {
  139.         if (pFbInfo->fb_type == DT_PLASMA)
  140.             monitorResolution = PLASMA_TV_RESOLUTION;
  141.         else
  142.             monitorResolution = MONO_TV_RESOLUTION; 
  143.     }
  144.  
  145.     if(!mfbScreenInit(pScreen,(pointer)pFbInfo->plane,
  146.             pFbInfo->scr_width,pFbInfo->scr_height,
  147.             monitorResolution,monitorResolution,pFbInfo->fb_width)){
  148.         ErrorF("mfbScreenInit Error.\n");
  149.         return FALSE;
  150.     }
  151.  
  152.        pScreen->whitePixel = 0;
  153.        pScreen->blackPixel = 1;
  154.  
  155.     miDCInitialize (pScreen, &omronPointerScreenFuncs);
  156.  
  157.     mfbCreateDefColormap(pScreen);
  158.  
  159.     pScreen->SaveScreen = omronFsBmSaveScreen;
  160.  
  161.     omronFsBmSaveScreen(pScreen, SCREEN_SAVER_FORCER);
  162.  
  163.     return TRUE;
  164.  
  165. }
  166.  
  167. static void
  168. omronFsBmPalClose(omron_fb_info)
  169. OmronFbInfoPtr omron_fb_info;
  170. {
  171.     union fs_palette *fs_bm_pal;
  172.  
  173.     omronFsBmSetPal(omron_fb_info, paldata);
  174.  
  175.     fs_bm_pal = (union fs_palette *)(omron_fb_info->palmap);
  176.  
  177.     /* read mask register */
  178.     PALADR(Fs_bm_pal)=    0x4L;
  179.     PALCONT(fs_bm_pal) = 0L;
  180.  
  181.     /* blink mask register */
  182.     PALADR(fs_bm_pal) = 0x5L;
  183.     PALCONT(fs_bm_pal) = 0x0L;
  184.  
  185.     /* command register */
  186.     PALADR(fs_bm_pal) = 0x6L;
  187.     PALCONT(fs_bm_pal) = 0x2L;
  188. }
  189.  
  190.  
  191. static Bool
  192. omronFsBmPalCreate(omron_fb_info)
  193. OmronFbInfoPtr omron_fb_info;
  194. {
  195.     union fs_palette *fs_bm_pal;
  196.  
  197.     fs_bm_pal = (union fs_palette *)(omron_fb_info->palmap);
  198.  
  199.     /* read mask register */
  200.     PALADR(fs_bm_pal)=    0x4L;
  201.     PALCONT(fs_bm_pal) = (1 << (omron_fb_info->fb_depth) ) - 1;
  202.  
  203.     /* blink mask register */
  204.     PALADR(fs_bm_pal) = 0x5L;
  205.     PALCONT(fs_bm_pal) = 0x0L;
  206.  
  207.     /* command register */
  208.     PALADR(fs_bm_pal) = 0x6L;
  209.     PALCONT(fs_bm_pal) = 0x40L;
  210.  
  211.     return TRUE; 
  212. }
  213.  
  214.  
  215. static void
  216. omronFsBmPalInit(omron_fb_info)
  217. OmronFbInfoPtr omron_fb_info;
  218. {
  219.     bcopy(palinit, palsave, sizeof(palinit));
  220.     omronFsBmSetPal(omron_fb_info, palsave);
  221. }
  222.  
  223.  
  224. static void
  225. omronFsBmSetPal(omron_fb_info, pal)
  226. OmronFbInfoPtr omron_fb_info;
  227. struct pal *pal;
  228. {
  229.     union fs_palette       *fs_bm_pal;
  230.     register int       i, j;
  231.     unsigned char      *palp;
  232.  
  233.     fs_bm8_pal = (union palette_bm8 *)(omron_fb_info->palmap);
  234.     for (i = 0; i < 256; i++) {
  235.         palp = &pal++->red;
  236.         PALADR(fs_bm_pal) = i;
  237.         for (j = 0; j < 3; j++) {
  238.             PALCDATA(fs_bm_pal) = *palp++;
  239.         }
  240.     }
  241. }
  242.  
  243.  
  244. static void
  245. omronFsBmFbClear(omron_fb_info)
  246. OmronFbInfoPtr omron_fb_info;
  247. {
  248.     register int *f;
  249.     register int nw,height;
  250.     int nwidth,nlwidth,nlwExtra;
  251.  
  252.     f = (int *)omron_fb_info->plane;
  253.     nlwidth  = (omron_fb_info->fb_width)>>5;
  254.     nwidth   = (omron_fb_info->scr_width)>>5;
  255.     nlwExtra = nlwidth - nwidth;
  256.     height =omron_fb_info->scr_height;
  257.  
  258.     while(height--) {
  259.         nw = nwidth;
  260.         while(nw--)
  261.             *f++ = 0;
  262.         f += nlwExtra;
  263.     }
  264. }
  265.  
  266.  
  267. void
  268. omronFsBmGiveUp(omron_fb_info)
  269. OmronFbInfoPtr omron_fb_info;
  270. {
  271.     omronFsBmFbClear(omron_fb_info);
  272.     omronFsBmPalClose(omron_fb_info);
  273. }
  274. #endif
  275.