⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 topcat.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
    /*     * Map the topcat in to our address space.  We could ask the O.S.     * to map it in where it prefers, but this would limit the amount of     * data we can malloc() at a later time.     * However, we don't know how much address space it will take up until     * we can examine its memWide and memHigh values....     */    {	u_char *Addr = (u_char *) 0;	char *str_addr = (char *)getenv("XDISPADDR");	if (str_addr)	    Addr = (u_char *) atoi(str_addr);	if (ioctl (fd, GRFIOCMAP, &Addr) < 0)	{	    (void) ioctl (fd, GRFIOCOFF, 0);	    perror("GRFIOCMAP:");	    ErrorF("%s: Error getting address of %s\n", argv[0], argv[1]);	    close(fd);	    return FALSE;	}	topcat->topcatDev = (TOPCAT *) Addr;    }    {	TOPCAT *tc;	tc = topcat->topcatDev;	thisScreen->memHeight = (tc->t_memhigh << 8) | tc->b_memhigh;	thisScreen->memWidth  = (tc->t_memwide << 8) | tc->b_memwide;	if (tc->id_second == ID2_TC)	    topcat->UpdateColormap = topcatUpdateColormap;	else	    topcat->UpdateColormap = catseyeUpdateColormap;	/* Set up the appropriate wholeGlyph routine */#define ceWholeGlyph tcWholeGlyph	if (tc->id_second < ID2_LCC)	{#if 0	    if (tc->bits)		thisScreen->WholeGlyph = mrtcWholeGlyph;	    else#endif 		thisScreen->WholeGlyph = tcWholeGlyph;	}	else	    thisScreen->WholeGlyph = ceWholeGlyph;    }    /* store the screen minor number in the devPrivate structure;     * if there are four arguments, the fourth is the screen minor number;     */    if (argc == 4)	thisScreen->minor_num = atoi(argv[3]);    else	thisScreen->minor_num = 0;    thisScreen->screenBlanked = FALSE;    return TRUE;}/* * Configure the topcat hardware masks; */voidtopcatMaskConfig(pScreen, writeEnableMask, replacementRule)    register ScreenPtr pScreen;    register int writeEnableMask, replacementRule;{    register TOPCAT *gp_hardware = getTcHardware(pScreen);    register unsigned int planes = getPlanesMask(pScreen);    waitbusy(planes, gp_hardware); /* wait for all planes to quiet */    writeEnableMask &= planes;    gp_hardware -> write_enable = writeEnableMask;    gp_hardware -> frame_buf_write_enable = writeEnableMask;    gp_hardware -> pixel_write_replacement_rule = replacementRule;}/* * Wait for the topcat mover hardware to be not-busy and then initiate * the requested move operation. */voidtopcatMoveBits(pScreen, planeMask, alu,	    sourceX, sourceY, destX, destY, width, height)    ScreenPtr pScreen;    u_char    planeMask;    int       alu, sourceX, sourceY, destX, destY, width, height;{    u_char pMask		 = getPlanesMask(pScreen);    register TOPCAT *gp_hardware = getTcHardware(pScreen);    int       k;        /* wait for hardware ready. test all possible planes */    while ((gp_hardware -> move_active) & pMask)	for (k=0; k<100; k++); /* delay to let topcat mover work */        /* return without doing any other work if no planes are effected...     Note: we have assured that any previous mover operation has completed.*/    if ((planeMask &= pMask) == 0) return;    /* XXX catseye */    gp_hardware -> frame_buf_write_enable = planeMask;    gp_hardware -> write_enable = planeMask;    gp_hardware -> window_move_replacement_rule = alu;    gp_hardware -> source_x = sourceX;    gp_hardware -> source_y = sourceY;    gp_hardware -> dest_x = destX;    gp_hardware -> dest_y = destY;    gp_hardware -> window_width = width;    gp_hardware -> window_height = height;    /* start move on all GC enabled planes supported by hardware */      gp_hardware -> start_move = planeMask;}    extern Bool tcCloseScreen();static BooltopcatCloseScreen(index, pScreen)    int index;    ScreenPtr pScreen;{    register topcatPrivPtr topcat = (topcatPrivPtr)	getPrivScreenPtr(pScreen)->pHardwareScreen;    register u_char pMask	 = getPlanesMask(pScreen);    register TOPCAT *gp_hardware = topcat->topcatDev;    static u_char colors[2] = {0x00, 0xff};    getPrivScreenPtr(pScreen)->screenBlanked = FALSE;	    (*topcat->UpdateColormap)(pScreen,0,2,colors,colors,colors);    waitbusy (pMask, gp_hardware);    gp_hardware -> nblank = TC_VIDEO_ON;    gp_hardware -> write_enable = ~0;    gp_hardware -> window_move_replacement_rule = GXclear;    gp_hardware -> write_enable = ~0;    gp_hardware -> pixel_write_replacement_rule = GXclear;    gp_hardware -> source_x = 0;    gp_hardware -> source_y = 0;    gp_hardware -> dest_x = 0;    gp_hardware -> dest_y = 0;    gp_hardware -> window_width = pScreen->width;    gp_hardware -> window_height = pScreen->height;    gp_hardware -> start_move = ~0;    return tcCloseScreen(index, pScreen);}static inttcNumPlanes(base, pMask)     VOLATILE u_char *base;     u_char *pMask;{    u_char sample0, sample1, rwBits;    int numPlanes;    *base = 0;    sample0 = *base;    *base = 0xff;    sample1 = *base;    rwBits = sample0 ^ sample1;    switch(rwBits)    {      case 0x00: numPlanes = 0; break;      case 0x01: numPlanes = 1; break;      case 0x03: numPlanes = 2; break;      case 0x07: numPlanes = 3; break;      case 0x0f: numPlanes = 4; break;      case 0x1f: numPlanes = 5; break;      case 0x3f: numPlanes = 6; break;      case 0x7f: numPlanes = 7; break;      case 0xff: numPlanes = 8; break;      default: numPlanes = -1;    }    *pMask = rwBits;    if (TopcatBrainDamage || (numPlanes < 4 && catseyeMono))    {	*pMask = 0x01;	numPlanes = 1;    }    return numPlanes;}BooltopcatScreenInit(index, pScreen, argc, argv)    int index;    ScreenPtr pScreen;    int argc;		/* these two may NOT be changed */    char **argv;{    int dpi;    u_char numPlanes;    topcatPrivPtr topcat;    TOPCAT *gp_hardware;    hpPrivScreenPtr pPrivScreen;    /* always restore the devPrivate field here;     * if it has not been allocated, this will null it out so code elsewhere     * will be sure to allocate one;     * If we've already allocated one, this will restore it;     */    pScreen->devPrivate = (pointer)hp_screens[index];    pPrivScreen = getPrivScreenPtr(pScreen);    topcat = (topcatPrivPtr)(pPrivScreen->pHardwareScreen);    gp_hardware = topcat->topcatDev;    pPrivScreen->MoveBits = topcatMoveBits;    pPrivScreen->MaskConfig = topcatMaskConfig;    pPrivScreen->ChangeScreen = hpChangeScreens;    /* Video card initialized */        gp_hardware -> write_enable = ~0;    gp_hardware -> pixel_write_replacement_rule = GXcopy;    gp_hardware -> frame_buf_write_enable = ~0;    /* XXX catseye */    if (gp_hardware->id_second != ID2_TC)    {        char *foo = (char *) gp_hardware;	*((short *)(foo + 0x4510)) = 0x0;	/* VB      */	*((short *)(foo + 0x4512)) = 0x0;	/* TCNTRL  */	*((short *)(foo + 0x4514)) = 0x0;	/* ACNTRL  */	*((short *)(foo + 0x4516)) = 0x0;	/* PNCNTRL */	*((short *)(foo + 0x4206)) = 0x90;	/* RUG Command/Status */	*((short *)(foo + 0x60A2)) = 0x0;	/* Overlay Mask       */	*((short *)(foo + 0x60BC)) = 0x0;	/* Ram Select	      */	dpi = 109; /* XXX probably bogus */    }    else	dpi = 85;    /*     * Set up the color map     */    numPlanes = tcNumPlanes(((u_char *) gp_hardware) + pPrivScreen->fbOffset,			    &pPrivScreen->planesMask);    if (!tcScreenInit(pScreen,		      ((u_char *) gp_hardware) + pPrivScreen->fbOffset,		      (gp_hardware->t_dispwide << 8)+gp_hardware->b_dispwide,		      (gp_hardware->t_disphigh << 8)+gp_hardware->b_disphigh,		      dpi, dpi, numPlanes))	return FALSE;    pScreen->SaveScreen = topcatSaveScreen;    pScreen->CloseScreen = topcatCloseScreen;    mfbRegisterCopyPlaneProc (pScreen, tcCopyPlane);    mfbRegisterCopyAreaProc (pScreen, hpcCopyArea);    if (!hpInitCursor(pScreen, 8))	return FALSE;    if (!cfbCreateDefColormap(pScreen))    {	ErrorF("Can't alloc black & white pixels in topcatScreenInit\n");	return FALSE;    }    (void) topcatSaveScreen (pScreen, SCREEN_SAVER_OFF);    return TRUE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -