Example #1
0
STATICFN VOID NEAR ViewChar(
    UINT uiChar)
{
    INT i;
    INT iNext;

    switch (uiChar) {
        /*
         * Advance to the next screen color.
         */
        case '+':
            iNext = 0;
            for (i = 0; i < 16; i++) {
                if (grgbScreen == gargbDefaultColor[i]) {
                    iNext = i + 1;
                    break;
                }
            }

            if (iNext >= 16)
                iNext = 0;

            SetScreenColor(gargbDefaultColor[iNext]);

            break;

        /*
         * Back up to the prior screen color.
         */
        case '-':
            iNext = 16 - 1;
            for (i = 0; i < 16; i++) {
                if (grgbScreen == gargbDefaultColor[i]) {
                    iNext = i - 1;
                    break;
                }
            }

            if (iNext < 0)
                iNext = 16 - 1;

            SetScreenColor(gargbDefaultColor[iNext]);

            break;
    }
}
Example #2
0
/** State - Start game */
void StateStartGame()
{
	game.page = 0;
	SetPage8(game.page);
	game.yOffset = 0;

	SetScreenColor(0, 0, BG_COLOR);
	ClearScreen8(BG_COLOR);

	game.bAnaglyph = TRUE;
	switch(game.anaglyphFx)
	{
		case 0:	game.bAnaglyph = FALSE; break;
		case 1:	game.power3d = 4; break;
		case 2: game.power3d = 8; break;
		case 3: game.power3d = 12; break;
	}
	switch(game.gameSpeed)
	{
		case 0: game.ballSpeed = 10; break;
		case 1: game.ballSpeed = 15; break;
		case 2: game.ballSpeed = 20; break;
	}

	game.page = 0;
	game.yOffset = 0;
	InitBackground();
	game.lineNum[0] = 0;
	game.lineNum[1] = 0;
	game.bestScore = 0;

	// Player 0
	game.players[0].score = 0;
	VEC_SET(game.players[0].position, F10_SET(50), F10_SET(50), F10_SET(0));
	game.players[0].angle = 0;

	// Player 1
	game.players[1].score = 0;
	VEC_SET(game.players[1].position, F10_SET(-50), F10_SET(-50), F10_SET(FIELD_DEPTH));
	game.players[1].angle = 0;

	// Ball
	VEC_SET(game.ballPos, 0, 0, F10_SET(128));
	VEC_SET(game.ballDir, 0, 0, F10_SET(game.ballSpeed));

	game.state = StateUpdateGame;
}
Example #3
0
/** State - initialize system */
void StateInitialize()
{
	u16 x;
	u8 i;

	// Init
	VideoInitialize();
	SetFreq(FREQ_60);
	SetScreen8(LINES_212);
	SetSpriteMode(SPRITE_OFF, 0, 0, 0);
	SetScreenColor(0, 0, COLOR8_BLACK);

	// Clear all VRAM
	ClearScreen8(COLOR8_BLACK);

	// Initialize (ASCII table) sprites
	for(x=0; x<sizeof(g_CharTable) / 8; x++)
	{
		RAMtoVRAM(Modulo2(x * 8, 256), 248 + (x / 32), 8, 1, (u16)&g_CharTable[x * 8]);
	}

	// Create default 8 bytes patern from a 8 bits byte
	for(x=0; x<256; x++)
	{
		for(i=0; i<8; i++)
		{
			if(x & (1 << (7 - (i & 0x07))))
				game.bitToByte[x * 8 + i] = 0xFF;
			else
				game.bitToByte[x * 8 + i] = 0x00;
		}		
	}

	// Create 3D projection table
	for(x=0; x<512; x++)
	{
		game.projZ[x] = (512 - x) >> 3; // (512 - x) << 6 / 512
	}
	game.lineNum[0] = 0;
	game.lineNum[1] = 0;
	game.anaglyphFx = 2;
	game.playerNum = 2;
	game.gameSpeed = 0;

	game.page = 0;
	game.state = StateTitle;
}
Example #4
0
/** State - Initialize title */
void StateTitle()
{
	// Hide working screen (0)
	SetPage8(1);
	SetScreenColor(0, 0, COLOR8_BLACK);
	ClearScreen8(COLOR8_BLACK);

	// Build title
	DrawText(50, 32,       "PONGLYPH", COLOR8_RED);
	DrawText(52, 32 + 256, "PONGLYPH", COLOR8_CYAN);
	DrawText(150, 64,       "PHENIX 2011", COLOR8_GRAY);
	DrawText(150, 64 + 256, "PHENIX 2011", COLOR8_GRAY);

	InitializeMenu(0);
	game.pressed = 0;
	game.page = 0;
	game.state = StateMainMenu;
}
Example #5
0
STATICFN VOID NEAR ColorEdit(VOID)
{
    /*
     * This array of custom colors is initialized to all white colors.
     * The custom colors will be remembered between calls, but not
     * between sessions.
     */
    static DWORD argbCust[16] = {
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255)
    };
    CHOOSECOLOR cc;
    DWORD rgbOld;
    BOOL fResult;
    INT idPrevDlg;

    switch (gfModeLeft) {
        case MODE_COLOR:
            /*
             * The monochrome palette cannot be edited.
             */
            if (gnColorPalColors == 2)
                return;

            rgbOld = gargbCurrent[giColorLeft];
            break;

        case MODE_SCREEN:
            rgbOld = grgbScreen;
            break;

        case MODE_INVERSE:
            rgbOld = grgbInverse;
            break;
    }

    cc.lStructSize = sizeof(CHOOSECOLOR);
    cc.hwndOwner = ghwndMain;
    cc.hInstance = ghInst;
    cc.rgbResult = rgbOld;
    cc.lpCustColors = argbCust;
    cc.Flags = CC_RGBINIT | CC_SHOWHELP;
    cc.lCustData = 0;
    cc.lpfnHook = NULL;
    cc.lpTemplateName = NULL;

    EnteringDialog(DID_COMMONFILECHOOSECOLOR, &idPrevDlg, TRUE);
    fResult = ChooseColor(&cc);
    EnteringDialog(idPrevDlg, NULL, FALSE);

    if (fResult && rgbOld != cc.rgbResult) {
        switch (gfModeLeft) {
            case MODE_COLOR:
                gargbCurrent[giColorLeft] = cc.rgbResult;
                break;

            case MODE_SCREEN:
                SetScreenColor(cc.rgbResult);
                break;

            case MODE_INVERSE:
                SetScreenColor(ComputeInverseColor(cc.rgbResult));
                break;
        }

        SetLeftColor(giColorLeft, gfModeLeft);
        InvalidateRect(GetDlgItem(ghwndColor, DID_COLORBOX), NULL, TRUE);
    }
}
Example #6
0
WINDOWPROC ViewWndProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_CREATE:
            {
                HMENU hmenu = GetSystemMenu(hwnd, FALSE);

                RemoveMenu(hmenu, 7, MF_BYPOSITION);    // Second separator.
                RemoveMenu(hmenu, 5, MF_BYPOSITION);    // First separator.

                RemoveMenu(hmenu, SC_RESTORE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_SIZE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_MINIMIZE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_MAXIMIZE, MF_BYCOMMAND);
                RemoveMenu(hmenu, SC_TASKLIST, MF_BYCOMMAND);
            }

            return 0;

        case  WM_PAINT:
            {
                HDC hdc;
                PAINTSTRUCT ps;
                HBRUSH hbrOld;
                RECT rc;

                hdc = BeginPaint(hwnd, &ps);

                /*
                 * The view window should not be showing if there
                 * is not an image to view!
                 */
                if (gpImageCur) {
                    DrawMarginBorder(hwnd, hdc);

                    GetClientRect(hwnd, &rc);
                    hbrOld = SelectObject(hdc, ghbrScreen);
                    PatBlt(hdc, PALETTEMARGIN + 1, PALETTEMARGIN + 1,
                            rc.right - (PALETTEMARGIN * 2) - 2,
                            rc.bottom - (PALETTEMARGIN * 2) - 2,
                            PATCOPY);
                    SelectObject(hdc, hbrOld);

                    BitBlt(hdc, PALETTEMARGIN + gViewBackMargin,
                            PALETTEMARGIN + gViewBackMargin,
                            gcxImage, gcyImage, ghdcImage, 0, 0, SRCCOPY);
                }

                EndPaint(hwnd, &ps);
            }

            break;

        case WM_ACTIVATE:
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = DID_VIEW;

            break;

        case WM_LBUTTONDOWN:
            SetScreenColor(gargbCurrent[giColorLeft]);
            break;

        case WM_CHAR:
            ViewChar(wParam);
            break;

        case WM_CLOSE:
            /*
             * The user closed the view window from the system menu.
             * Hide the window (we don't actually destroy it so
             * that it will appear in the same spot when they show
             * it again).
             */
            ViewShow(FALSE);
            gfShowView = FALSE;
            break;

        case WM_DESTROY:
            {
                RECT rc;

                /*
                 * Save the position of the toolbox.
                 */
                GetWindowRect(hwnd, &rc);
                WriteWindowPos(&rc, FALSE, szViewPos);

                /*
                 * Null out the global window handle for the view window
                 * for safety's sake.
                 */
                ghwndView = NULL;
            }

            break;

        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return 0;
}