Exemplo n.º 1
0
EXPORT int CALL angrylionRomOpen (void)
{
#ifndef HAVE_DIRECTDRAW
   screen_width = SCREEN_WIDTH;
   screen_height = SCREEN_HEIGHT;
   blitter_buf = (uint32_t*)calloc(screen_width * screen_height, sizeof(uint32_t));
   pitchindwords = screen_width * 4;
   screen_pitch = PRESCALE_WIDTH << 2;
#else
    DDPIXELFORMAT ftpixel;
    LPDIRECTDRAWCLIPPER lpddcl;
    RECT bigrect, smallrect, statusrect;
    POINT p;
    int rightdiff;
    int bottomdiff;
    GetWindowRect(gfx.hWnd,&bigrect);
    GetClientRect(gfx.hWnd,&smallrect);
    rightdiff = screen_width - smallrect.right;
    bottomdiff = screen_height - smallrect.bottom;

    if (gfx.hStatusBar)
    {
        GetClientRect(gfx.hStatusBar, &statusrect);
        bottomdiff += statusrect.bottom;
    }
    MoveWindow(gfx.hWnd, bigrect.left, bigrect.top, bigrect.right - bigrect.left + rightdiff, bigrect.bottom - bigrect.top + bottomdiff, true);

    res = DirectDrawCreateEx(0, (LPVOID*)&lpdd, &IID_IDirectDraw7, 0);
    if (res != DD_OK)
    {
        DisplayError("Couldn't create a DirectDraw object.");
        return; /* to-do:  move to InitiateGFX? */
    }
    res = IDirectDraw_SetCooperativeLevel(lpdd, gfx.hWnd, DDSCL_NORMAL);
    if (res != DD_OK)
    {
        DisplayError("Couldn't set a cooperative level.");
        return; /* to-do:  move to InitiateGFX? */
    }

    zerobuf(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS;
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
    res = IDirectDraw_CreateSurface(lpdd, &ddsd, &lpddsprimary, 0);
    if (res != DD_OK)
    {
        DisplayError("CreateSurface for a primary surface failed.");
        return; /* to-do:  move to InitiateGFX? */
    }

    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    ddsd.dwWidth = PRESCALE_WIDTH;
    ddsd.dwHeight = PRESCALE_HEIGHT;
    zerobuf(&ftpixel, sizeof(ftpixel));
    ftpixel.dwSize = sizeof(ftpixel);
    ftpixel.dwFlags = DDPF_RGB;
    ftpixel.dwRGBBitCount = 32;
    ftpixel.dwRBitMask = 0xff0000;
    ftpixel.dwGBitMask = 0xff00;
    ftpixel.dwBBitMask = 0xff;
    ddsd.ddpfPixelFormat = ftpixel;
    res = IDirectDraw_CreateSurface(lpdd, &ddsd, &lpddsback, 0);
    if (res == DDERR_INVALIDPIXELFORMAT)
    {
        DisplayError(
            "ARGB8888 is not supported. You can try changing desktop color "\
            "depth to 32-bit, but most likely that won't help.");
        return; /* InitiateGFX fails. */
    }
    else if (res != DD_OK)
    {
        DisplayError("CreateSurface for a secondary surface failed.");
        return; /* InitiateGFX should fail. */
    }

    res = IDirectDrawSurface_GetSurfaceDesc(lpddsback, &ddsd);
    if (res != DD_OK)
    {
        DisplayError("GetSurfaceDesc failed.");
        return; /* InitiateGFX should fail. */
    }
    if ((ddsd.lPitch & 3) || ddsd.lPitch < (PRESCALE_WIDTH << 2))
    {
        DisplayError(
            "Pitch of a secondary surface is either not 32 bit aligned or "\
            "too small.");
        return; /* InitiateGFX should fail. */
    }
    pitchindwords = ddsd.lPitch >> 2;

    res = IDirectDraw_CreateClipper(lpdd, 0, &lpddcl, 0);
    if (res != DD_OK)
    {
        DisplayError("Couldn't create a clipper.");
        return; /* InitiateGFX should fail. */
    }
    res = IDirectDrawClipper_SetHWnd(lpddcl, 0, gfx.hWnd);
    if (res != DD_OK)
    {
        DisplayError("Couldn't register a windows handle as a clipper.");
        return; /* InitiateGFX should fail. */
    }
    res = IDirectDrawSurface_SetClipper(lpddsprimary, lpddcl);
    if (res != DD_OK)
    {
        DisplayError("Couldn't attach a clipper to a surface.");
        return; /* InitiateGFX should fail. */
    }

    src.top = src.left = 0; 
    src.bottom = 0;
#if SCREEN_WIDTH < PRESCALE_WIDTH
    src.right = PRESCALE_WIDTH - 1; /* fix for undefined video card behavior */
#else
    src.right = PRESCALE_WIDTH;
#endif
    p.x = p.y = 0;
    GetClientRect(gfx.hWnd, &dst);
    ClientToScreen(gfx.hWnd, &p);
    OffsetRect(&dst, p.x, p.y);
    GetClientRect(gfx.hStatusBar, &statusrect);
    dst.bottom -= statusrect.bottom;
#endif

    rdp_init();
    overlay = 0;
    return 1;
}
Exemplo n.º 2
0
main(int argc, char** argv)
{
	int null = (char *)0x0;
	char* bigCharA = null;
	char* bigCharB = null;
	char* bigCharC = null;
	char* bigCharD = null;

	int count = 0;
	int term = 1000;

	int i;

	bigCharA = (char *)CreateBigNum();
	bigCharB = (char *)CreateBigNum();
	bigCharC = (char *)CreateBigNum();
	bigCharD = (char *)CreateBigNum();

	for (i = 0; i < DIGITS; ++i) {
		bigCharA[i] = 0;
		bigCharB[i] = 0;
		bigCharC[i] = 0;
		bigCharD[i] = 0;
	}

	if(!bigCharA || !bigCharB || !bigCharC || !bigCharD)
	{
		printf("Could not allocate memory !\n");
		return 0;
	}

	/* ------------------------------------------------- */

	*bigCharA = 2;	/* one */
	*bigCharB = 1;	/* zero */

	while(term--)
	{
		zerobuf(bigCharC);
		*bigCharC = 1;	/* zero */

		/* c = 2*a+b */
		AddBigNums(bigCharC, bigCharA);			
		AddBigNums(bigCharC, bigCharA);			
		AddBigNums(bigCharC, bigCharB);

		/* print c+a, "/" */
		zerobuf(bigCharD);
		*bigCharD = 1;		/* zero */
		AddBigNums(bigCharD, bigCharC);
		AddBigNums(bigCharD, bigCharA);
		if (VERBOSE) {
			OutputBigNum(bigCharD);
			printf(" / ");
		}

		/* print c */
		if (VERBOSE)
			OutputBigNum(bigCharC);

		/* count, newline */
		if(bn_length(bigCharD)>bn_length(bigCharC))
		{
			++count;
			if (VERBOSE)
				printf(" !! ");
		}

		if (VERBOSE)
			printf("\n");

		/* b = a */
		bn_copy(bigCharB, bigCharA);

		/* a = c */
		bn_copy(bigCharA, bigCharC);		
	}

	/* ------------------------------------------------- */

	/*
	 * XXX: the destroy() stuff segfaults on the wannabe
	 * compiler. not sure why. all it does is call free().
	 * anyway a modern unix/windows nt/donald operating system
	 * will automatically get rid of that stuff on exit.
	 */

	/*
	DestroyBigNum(bigCharA);
	DestroyBigNum(bigCharB);
	DestroyBigNum(bigCharC);
	DestroyBigNum(bigCharD);
	*/

	printf("%d\n", count);
	return 0;
}