📄 topcat.c
字号:
/*Copyright (c) 1986, 1987 by Hewlett-Packard CompanyCopyright (c) 1986, 1987 by the Massachusetts Institute of TechnologyPermission to use, copy, modify, and distribute thissoftware and its documentation for any purpose and withoutfee is hereby granted, provided that the above copyrightnotice appear in all copies and that both that copyrightnotice and this permission notice appear in supportingdocumentation, and that the name of M.I.T. not be used inadvertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARDTO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard shall not be liable for errors contained herein or direct, indirect, special, incidental or consequential damages in connection with the furnishing, performance, or use of this material.This software is not subject to any license of the AmericanTelephone and Telegraph Company or of the Regents of theUniversity of California.*//***********************************************************Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the names of Digital or MIT not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************/#include <stdio.h>#include <sys/types.h>#include <fcntl.h>#include <sys/ioctl.h>#include <grfioctl.h>#include "X.h"#define NEED_EVENTS#include "Xproto.h"#include "scrnintstr.h"#include "cursorstr.h"#include "pixmapstr.h"#include "inputstr.h"#include "regionstr.h"#include "hppriv.h"#include "topcat.h"#include "windowstr.h"#include "resource.h"#include "mibstore.h"extern int TopcatBrainDamage;extern int catseyeMono;extern int lastEventTime;extern void hpChangeScreens();extern Bool hpInitCursor(), cfbCreateDefColormap();extern RegionPtr hpcCopyArea();extern void mfbRegisterCopyAreaProc();extern hpPrivScreenPtr hp_screens[];static char _topcat_ident[] = "@(#)98544A, 98545A, 98547A";static BooltopcatSaveScreen(pScreen, on) ScreenPtr pScreen; Bool on;{ TOPCAT *gp_hardware = getTcHardware(pScreen); if (on != SCREEN_SAVER_ON) { lastEventTime = GetTimeInMillis(); /* Turn on Video */ gp_hardware -> nblank = TC_VIDEO_ON; getPrivScreenPtr(pScreen)->screenBlanked = FALSE; } else { /* Turn off video */ gp_hardware -> nblank = TC_VIDEO_OFF; getPrivScreenPtr(pScreen)->screenBlanked = TRUE; } return TRUE;}static voidtopcatUpdateColormap(pScreen, index, count, rmap, gmap, bmap) ScreenPtr pScreen; register int index, count; register u_char *rmap, *gmap, *bmap;{ register TOPCAT *gp_hardware = getTcHardware(pScreen); hpPrivScreenPtr pPrivScreen = getPrivScreenPtr(pScreen); register i; Bool toggleScreenSaver = pPrivScreen->screenBlanked; if (pPrivScreen->planesMask == 0x01) return; if (toggleScreenSaver) /* We hang in status check unless video enabled */ (void) topcatSaveScreen(pScreen, SCREEN_SAVER_OFF); while (count--) { unsigned short id; /* Wait for color map not busy */ while (gp_hardware -> colormap_status & 0x04) for (i=0; i<20; i++); gp_hardware->plane_mask = 0xff; gp_hardware->red_data = rmap[index]; id = gp_hardware->id_reset; gp_hardware->green_data = gmap[index];; id = gp_hardware->id_reset; gp_hardware->blue_data = bmap[index];; id = gp_hardware->id_reset; gp_hardware->color_index = ~index; id = gp_hardware->id_reset; gp_hardware->colormap_writestrobe = 0xff; id = gp_hardware->id_reset; /* * Not sure just why we have to do this, but it sure doesn't work * without it. Delay loop slowed and delay after last status added. * Seemed to be needed for faster 350 processor. HACK! */ while (gp_hardware -> colormap_status & 0x04) { id = gp_hardware->id_reset; for (i=0; i<100; i++); } for (i=0; i<1000; i++); gp_hardware -> red_data = 0; id = gp_hardware->id_reset; gp_hardware -> green_data = 0; id = gp_hardware->id_reset; gp_hardware -> blue_data = 0; id = gp_hardware->id_reset; gp_hardware -> color_index = 0; id = gp_hardware->id_reset; index++; } if (toggleScreenSaver) (void) topcatSaveScreen(pScreen, SCREEN_SAVER_ON);}static voidcatseyeUpdateColormap(pScreen, index, count, rmap, gmap, bmap) ScreenPtr pScreen; int index; register int count; u_char *rmap, *gmap, *bmap;{ register TOPCAT *gp_hardware = getTcHardware(pScreen); hpPrivScreenPtr pPrivScreen = getPrivScreenPtr(pScreen); Bool toggleScreenSaver = pPrivScreen->screenBlanked; int tmp; if (pPrivScreen->planesMask == 0x01) return; /* We hang in status check unless video enabled */ if (toggleScreenSaver) (void) topcatSaveScreen(pScreen, SCREEN_SAVER_OFF); { register int i; register u_char *rp, *gp, *bp; i = index; rp = &rmap[i]; gp = &gmap[i]; bp = &bmap[i]; for (; count--; i++) { /* Wait for color map not busy */ do { tmp = 0x04; } while (gp_hardware->colormap_status & tmp); gp_hardware->plane_mask = 0xff; gp_hardware->color_index = ~i; gp_hardware->red_data = *rp++; gp_hardware->green_data = *gp++; gp_hardware->blue_data = *bp++; gp_hardware->colormap_writestrobe = 0xff; } } do { tmp = 0x04; } while (gp_hardware->colormap_status & tmp); gp_hardware->color_index = 0; if (toggleScreenSaver) (void) topcatSaveScreen(pScreen, SCREEN_SAVER_ON);}BooltopcatScreenInfo(index, argv, argc) int index; char **argv; int argc;{ hpPrivScreenPtr thisScreen; topcatPrivPtr topcat; int fd, gcid; thisScreen = (hpPrivScreenPtr) xalloc(sizeof(hpPrivScreen) + sizeof(topcatPriv)); if (!thisScreen) return FALSE; topcat = (topcatPrivPtr) (thisScreen + 1); hp_screens[index] = thisScreen; thisScreen->pHardwareScreen = (pointer)topcat; topcat->topcatDev = (TOPCAT *)NULL; topcat->InstalledMap = (ColormapPtr)NULL; if ((fd = open(argv[2], O_WRONLY)) < 0) { perror(argv[0]); ErrorF("%s: couldn't open %s \n", argv[0], argv[2]); return FALSE; } { struct grfinfo gi; if (ioctl(fd, GRFIOCGINFO, &gi) < 0 || ioctl(fd, GRFIOCON, 0) < 0) { ErrorF("%s: couldn't GCON and GCID %s \n", argv[0], argv[2]); return FALSE; } thisScreen->fbOffset = gi.gd_regsize; gcid = gi.gd_id; } if (gcid != GCID_TOPCAT) /* Not a Topcat */ { ErrorF("%s: device %s not this kind of display.\n", argv[0], argv[2]); close(fd); return FALSE; } thisScreen->fd = fd; thisScreen->gcid = gcid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -