Пример #1
0
static int render_cursor(HexPad* prPad) {
    CursorPos* prPos = NULL;
    ColorConfig* prColor = NULL;
    int bp = 0;
    int ap = 0;
    int x = 0;
    int y = 0;
    char sFmt[20];
    if (prPad == NULL) {
        return HEXPAD_NULLPTR;
    }
    bp = 3 + prPad->digit;
    ap = 12 - bp - 1;
    sprintf(sFmt, "%%%ds^%%-%ds", bp, ap);
    prColor = hexpad_get_panelcolor(prPad);
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    prPos = hexpad_get_position(prPad);
    x = prPos->x;
    y = prPos->y + 13;
    pspDebugScreenSetXY(x, y);
    pspDebugScreenKprintf(sFmt, "", "");
    return HEXPAD_SUCCESS;
}
Пример #2
0
static int render_row(HexView* prView, const int row) {
    ColorConfig* prPcolor = NULL;
    ColorConfig* prCcolor = NULL;
    CursorPos* prCursor = NULL;
    CursorPos* prPos = NULL;
    Dimension* prSize = NULL;
    SceUInt32 address = 0;

    if (prView == NULL) {
        return HEXVIEW_NULLPTR;
    }

    prPcolor = get_panelcolor(prView);
    prCcolor = get_cursorcolor(prView);
    prCursor = get_cursorpos(prView);
    prPos = get_position(prView);
    prSize = get_size(prView);

    pspDebugScreenSetXY(prPos->x, prPos->y + row);
    if (row == prCursor->y) {
        if (cursor_color(prView) < 0) {
            return HEXVIEW_FAILURE;
        }
    } else {
        if (panel_color(prView) < 0) {
            return HEXVIEW_FAILURE;
        }
    }
    address = row_address(prView, row);
    pspDebugScreenKprintf("0x%08X", address);

    pspDebugScreenSetBackColor(prPcolor->background);
    pspDebugScreenSetTextColor(prPcolor->text);

    return HEXVIEW_SUCCESS;
}
Пример #3
0
static int drawCursor(HexEditor* prHex) {
    AddressColumn* prCol = NULL;
    ByteColumn* prBcol = NULL;
    AsciiColumn* prAcol = NULL;
    SceChar8* pcVal = NULL;
    SceUChar8* pucVal = NULL;
    AppletConfig* prApCfg = NULL;
    ColorConfig* prColor = NULL;
    ColorConfig* prEdit = NULL;

    if (prHex == NULL) {
        return HEXEDITOR_MEMORY;
    }
    prApCfg = prHex->prApCfg;
    int x = prHex->cursor.x;
    int y = prHex->cursor.y;
    int tt = prHex->config.table_pos.y;
    int iDcols = prHex->config.bytes_per_line;
    SceUInt32 poff = hexEditorTell(prHex);
    int iRow = prHex->cursor.y;
    SceUInt32 roff = getRowOffset(prHex, iRow);
    int iCol = prHex->cursor.x;
    int iDcol = 0;
    int iDx = 0;
    int iDigit = 0;

    if (x == 0) {
        prCol = &(prHex->rEditRow.rAddress);
        prColor = &prApCfg->rPanel.rCursor;
        colorconfig_setcolor(&prCol->color, prColor->background, prColor->text);
        prEdit = &prApCfg->rPanel.rEdit;
        colorconfig_setcolor(&prCol->edit, prEdit->background, prColor->text);
        colorconfig_setcolor(&prCol->editdigit, prEdit->background,
                prEdit->text);
        prCol->prefix = 1;
        if (prCol->inedit == 0) {
            addresscolumn_setvalue(prCol, getSelectedRowAddress(prHex));
        }
        pspDebugScreenSetXY(x, tt + y);
        addresscolumn_redraw(prCol);
    }
    if (x > 0 && x <= iDcols) {
        prBcol = &(prHex->rEditRow.rByte);
        prColor = &prApCfg->rPanel.rCursor;
        colorconfig_setcolor(&prBcol->color, prColor->background,
                prColor->text);
        prBcol->prefix = 0;
        iDcol = x - 1;
        if (prBcol->inedit == 0) {
            pucVal = (SceUChar8*) (poff + roff + iDcol);
            prBcol->value = (unsigned int)*pucVal;
        }
        if (iDcol >= 0 && iDcol < 4) {
            iDx = 11 + (iDcol * 2);
        }
        if (iDcol >= 4 && iDcol < 8) {
            iDigit = iDcol - 4;
            iDx = 20 + (iDigit * 2);
        }
        if (iDcol >= 8 && iDcol < 12) {
            iDigit = iDcol - 8;
            iDx = 29 + (iDigit * 2);
        }
        if (iDcol >= 12 && iDcol < 16) {
            iDigit = iDcol - 12;
            iDx = 38 + (iDigit * 2);
        }
        pspDebugScreenSetXY(iDx, tt + y);
        bytecolumn_redraw(prBcol);
    }
    if (x > iDcols && x <= (iDcols * 2)) {
        prAcol = &(prHex->rEditRow.rAscii);
        prColor = &prApCfg->rPanel.rCursor;
        colorconfig_setcolor(&prAcol->color, prColor->background,
                prColor->text);
        iDcol = x - iDcols - 1;
        pcVal = (SceChar8*) (poff + roff + iDcol);
        if (prAcol->in_edit == 0) {
            asciicolumn_setvalue(prAcol, *pcVal);
        }
        iDx = 47 + iDcol;
        pspDebugScreenSetXY(iDx, tt + y);
        asciicolumn_redraw(prAcol);
    }
    return HEXEDITOR_SUCCESS;
}
Пример #4
0
static void playmedia(char *rootpath, char *modname)
{
    char filename[200];
    u32 buttonsold;
    SceCtrlData pad;
    u32 remoteButtons, remoteButtonsOld = 0;
    int codec;
    int finished = 0;

    filename[0] = 0;
    strcat2(filename, rootpath);
    strcat2(filename, modname);

    pspDebugScreenClear();
    printf("%s\n\n", banner);
    printf("loading media File : %s\n", modname);

    //determine codec of the file
    for (codec = 0; codec <= codecnum; codec++) {
	char *ptr = &(stubs[codec].extension[0]);
	while (*ptr != 0) {
	    if (strncasecmp(&modname[strlen(modname) - 3], ptr, 3) == 0) {
		decoder = &stubs[codec];
		break;
	    }
	    ptr += 4;
	}
    }

    decoder->init(0);
    if (decoder->load(filename)) {
	decoder->play();

	pspDebugScreenSetXY(0, 32);
	printf("X = Pause/Resume.  START = Tune Select\n");
	pspDebugScreenSetXY(0, 26);
	printf("Playing\n\n");

	forceskip = 0;

	sceCtrlReadBufferPositive(&pad, 1);
	sceHprmPeekCurrentKey(&remoteButtons);

	buttonsold = pad.Buttons;
	remoteButtonsOld = remoteButtons;
	while (finished == 0) {
	    sceDisplayWaitVblankStart();
	    sceCtrlReadBufferPositive(&pad, 1);
	    sceHprmPeekCurrentKey(&remoteButtons);

	    // Check if we have hit the end of tune
	    if (loopmode != 0) {
		if (decoder->eos != 0) {
		    if (decoder->eos() == 1) {	// End of file, advance in playlist
			pad.Buttons = PSP_CTRL_RTRIGGER;
		    }
		}
	    }

	    if (pad.Buttons != buttonsold) {
		if (pad.Buttons & PSP_CTRL_LTRIGGER) {	// Previous tune
		    forceskip = 1;
		    finished = 1;
		}
		if (pad.Buttons & PSP_CTRL_RTRIGGER) {	// Next tune
		    forceskip = 2;
		    finished = 1;
		}
		if (pad.Buttons & PSP_CTRL_TRIANGLE)
		    loopmode = !loopmode;
		if (pad.Buttons & PSP_CTRL_CIRCLE)
		    decoder->stop();
		if (pad.Buttons & PSP_CTRL_CROSS)
		    decoder->pause();
		if (pad.Buttons & PSP_CTRL_START)
		    finished = 1;
		buttonsold = pad.Buttons;
	    }
	    if (remoteButtons != remoteButtonsOld && !(remoteButtons & PSP_HPRM_HOLD)) {
		if (remoteButtons & PSP_HPRM_PLAYPAUSE)
		    decoder->pause();
		if (remoteButtons & PSP_HPRM_BACK) {
		    forceskip = 1;
		    finished = 1;
		}
		if (remoteButtons & PSP_HPRM_FORWARD) {
		    forceskip = 2;
		    finished = 1;
		}
		remoteButtonsOld = remoteButtons;
	    }
	    //  Show loop status
	    pspDebugScreenSetXY(58, 1);
	    if (loopmode == 0) {
		printf(" LOOP  ");
	    } else {
		printf("ADVANCE");
	    }
	    //  Show the time
	    if (decoder->time != NULL) {
		char time[200];
		decoder->time(time);
		pspDebugScreenSetXY(58, 0);
		printf("%s", time);
		pspDebugScreenSetXY(0, 32);
	    }
	}
	decoder->stop();
	decoder->end();
    }
}
Пример #5
0
LoadingWindow_PSP::~LoadingWindow_PSP()
{
	pspDebugScreenSetXY( 0, 0 );
	pspDebugScreenSetTextColor( 0xFF000000 );
	pspDebugScreenPuts( text );
}
Пример #6
0
static int draw_dword_results(SearchPanel* prPanel) {
    SearchEngine* prEngine = NULL;
    SearchResult* prResult = NULL;
    DwordResultRow rRow;
    AddressColumn* prAddr = NULL;
    DwordColumn* prVal = NULL;
    AppletConfig* prApCfg = NULL;
    ColorConfig* prColor = NULL;
    ColorConfig* prCursor = NULL;
    int iStart = 0;
    int iEnd = 0;
    int iResults = 0;
    int iRows = 0;
    int iRow = 0;
    int iTop = 0;
    int iX = 0;
    int iY = 0;
    int iSelRes = 0;
    unsigned int vaddr;

    if (prPanel == NULL) {
        return SEARCHPANEL_NULLPTR;
    }
    prEngine = prPanel->prEngine;
    if (prEngine == NULL) {
        return SEARCHPANEL_NULLPTR;
    }
    prApCfg = prPanel->prApCfg;
    iRows = prPanel->config.tablesize.height;
    iResults = prEngine->result_count;
    iStart = prPanel->pagepos;
    iTop = prPanel->config.tabletop.y;
    iX = prPanel->config.tabletop.x;
    if (iStart > iResults) {
        iStart = 0;
    }
    if (iResults < iRows) {
        iRows = iResults;
    }
    iEnd = iStart + iRows;
    prAddr = &rRow.rAddress;
    prVal = &rRow.rValue;
    addresscolumn_init(prAddr);
    dwordcolumn_init(prVal);
    prColor = appletconfig_get_panelcolor(prApCfg);
    prCursor = appletconfig_get_cursorcolor(prApCfg);
    iY = iTop;
    iSelRes = prPanel->cursor.y;
    for (iRow = iStart; iRow < iEnd; iRow++) {
        prResult = searchengine_get_result(prEngine, iRow);
        if (prResult == NULL) {
            continue;
        }
        pspDebugScreenSetXY(iX, iY);
        vaddr = prResult->address & ~0x40000000;
        addresscolumn_setvalue(prAddr, vaddr);
        colorconfig_setcolor(&prAddr->color, prColor->background, 
                prColor->text);
        if (iSelRes > 4) {
            if ((iY - iTop) == (iSelRes - 5)) {
                colorconfig_setcolor(&prAddr->color, prCursor->background, 
                        prCursor->text);
            }
        }
        addresscolumn_redraw(prAddr);

        pspDebugScreenSetXY(iX + 12, iY);
        dwordcolumn_setvalue(prVal, prResult->value);
        colorconfig_setcolor(&prVal->color, prColor->background, 
                prColor->text);
        if (iSelRes > 4) {
            if ((iY - iTop) == (iSelRes - 5)) {
                colorconfig_setcolor(&prVal->color, prCursor->background, 
                        prCursor->text);
            }
        }
        dwordcolumn_redraw(prVal);
        iY++;
    }

    return SEARCHPANEL_SUCCESS;
}
Пример #7
0
static int draw_query_panel(SearchPanel* prPanel) {
    SearchPanelConfig* prPcfg = NULL;
    SearchEngine* prEngine = NULL;
    SearchQuery* prQuery = NULL;
    AppletConfig* prApCfg = NULL;
    ColorConfig* prColor = NULL;
    ColorConfig* prCursor = NULL;
    int x = 0;
    int y = 0;
    char *sMode = "None";
    char *sSize = "None";
    char *fs = "0x%08X";
    int row = 0;

    if (prPanel == NULL) {
        return SEARCHPANEL_MEMORY;
    }
    prPcfg = &prPanel->config;
    prEngine = prPanel->prEngine;
    prQuery = &prEngine->rQuery;
    prApCfg = prPanel->prApCfg;
    ESearchMode rMode = prQuery->searchMode;
    ESearchSize rSize = prQuery->searchSize;
    x = prPcfg->top.x;
    y = prPcfg->top.y + 2;
    row = prPanel->cursor.y;
    if (prApCfg != NULL) {
        prColor = appletconfig_get_panelcolor(prApCfg);
        prCursor = appletconfig_get_cursorcolor(prApCfg);
    } else {
        prColor = &prPcfg->color;
        prCursor = &prPcfg->cursor;
    }
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenSetXY(x, y);
    pspDebugScreenKprintf("%-10s", "Mode:");
    switch (rMode) {
        case ESM_Immediate:
            sMode = "Immediate Value";
            break;
        case ESM_Text:
            sMode = "Text";
            break;
        case ESM_Byte:
            sMode = "Exact Value";
            break;
    }
    if (row == 0) {
        pspDebugScreenSetBackColor(prCursor->background);
        pspDebugScreenSetTextColor(prCursor->text);
    }
    pspDebugScreenKprintf("%-50s", sMode);
    y++;

    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenSetXY(x, y);
    pspDebugScreenKprintf("%-10s", "Size:");
    switch (rSize) {
        case ESZ_Byte:
            sSize = "Byte (8-bits)";
            break;
        case ESZ_Dword:
            sSize = "Word (32-bits or 4 bytes)";
            break;
        case ESZ_Word:
            sSize = "Half-Word (16-bits or 2 bytes)";
            break;
    }
    if (row == 1) {
        pspDebugScreenSetBackColor(prCursor->background);
        pspDebugScreenSetTextColor(prCursor->text);
    }
    pspDebugScreenKprintf("%-50s", sSize);
    y++;

    /* Search Range Row */
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenSetXY(x, y);
    pspDebugScreenPuts("Range:    Start ");
    DwordColumn *prStart = &prPanel->rStartAddr;
    DwordColumn *prEnd = &prPanel->rEndAddr;
    colorconfig_setcolor(&prStart->color, prColor->background, prColor->text);
    colorconfig_setcolor(&prEnd->color, prColor->background, prColor->text);
    if (row == 2) {
        pspDebugScreenSetBackColor(prCursor->background);
        pspDebugScreenSetTextColor(prCursor->text);
        if (prPanel->cursor.x == 0) {
            colorconfig_setcolor(&prStart->color, prCursor->background,
                    prCursor->text);
        } else {
            colorconfig_setcolor(&prEnd->color, prCursor->background,
                    prCursor->text);
        }
    }
    if (searchpanel_is_editing(prPanel) == 0) {
        dwordcolumn_setvalue(prStart, prQuery->startAddr & 0xBFFFFFFF);
        dwordcolumn_setvalue(prEnd, prQuery->endAddr & 0xBFFFFFFF);
    }
    dwordcolumn_redraw(prStart);
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenPuts(" End ");
    dwordcolumn_redraw(prEnd);
    y++;

    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenSetXY(x, y);
    pspDebugScreenKprintf("%-10s", "Query:");
    DwordColumn *prCol = &prPanel->rQueryCol;
    prCol->color.background = prColor->background;
    prCol->color.text = prColor->text;
    if (row == 3) {
        pspDebugScreenSetBackColor(prCursor->background);
        pspDebugScreenSetTextColor(prCursor->text);
        prCol->color.background = prCursor->background;
        prCol->color.text = prCursor->text;
    }
    if (rMode == ESM_Text) {
        pspDebugScreenKprintf("%-50s", prQuery->text);
    } else {
        if (searchpanel_is_editing(prPanel) == 1) {
            dwordcolumn_redraw(prCol);
        } else {
            switch (rSize) {
                case ESZ_Byte:
                    fs = "      0x%02X";
                    break;
                case ESZ_Dword:
                    fs = "0x%08X";
                    break;
                case ESZ_Word:
                    fs = "    0x%04X";
                    break;
            }
            pspDebugScreenKprintf(fs, prQuery->value);
        }
    }
    
    return SEARCHPANEL_SUCCESS;
}
Пример #8
0
int main(int argc, char** argv)
{
	pspDebugScreenInit();
	pspDebugScreenEnableBackColor(0);
	
	SetupCallbacks();
	
	char* scriptFilename = "script.lua";
	
	lua_State *L;
	L = lua_open();
	luaL_openlibs(L);
	
	Aalib_init(L);
	Color_init(L);
	g2D_init(L);
	intraFont_init(L);
	Ctrl_init(L);
	Power_init(L);
	Time_init(L);
	Timer_init(L);
	Savedata_init(L);
	sceIo_init(L);
	Utility_init(L);
	USB_init(L);
	Xtream_init(L);
	
	
	SceCtrlData keys, oldkeys;
	int status = 0, i;
	
	while (1)
	{
	status = luaL_loadfile(L, scriptFilename);
		
	if (status == 0) 
		status = lua_pcall(L, 0, LUA_MULTRET, 0);
	

		if (status != 0) //If an error has occured
		{
		sceCtrlReadBufferPositive(&oldkeys, 1);
		
		pspDebugScreenInit();
		pspDebugScreenEnableBackColor(1);
		
			while (1)
			{			
				sceCtrlReadBufferPositive(&keys, 1);
			
				pspDebugScreenSetXY(0,0);
				printf("Lua Error:\n%s\n", lua_tostring(L, -1));
				printf("Press Start to reset.\n");
				
				if ((keys.Buttons &PSP_CTRL_START) && !(oldkeys.Buttons &PSP_CTRL_START))
					break;
				
				oldkeys = keys;
				
				for (i = 0; i < 10; i++)
					sceDisplayWaitVblankStart();
			}
			
		pspDebugScreenInit();
		pspDebugScreenEnableBackColor(0);
		
		lua_pop(L, 1);
		}
	}
		
	lua_close(L);

	intraFontShutdown();
	g2dTerm();
	cleanUSBDrivers();

	sceKernelExitGame();

	return 0;
}
Пример #9
0
void JGE::Run()
{
    static const int keyCodeList[] = {
        PSP_CTRL_SELECT, // Select button.
        PSP_CTRL_START, // Start button.
        PSP_CTRL_UP, // Up D-Pad button.
        PSP_CTRL_RIGHT, // Right D-Pad button.
        PSP_CTRL_DOWN, // Down D-Pad button.
        PSP_CTRL_LEFT, // Left D-Pad button.
        PSP_CTRL_LTRIGGER, // Left trigger.
        PSP_CTRL_RTRIGGER, // Right trigger.
        PSP_CTRL_TRIANGLE, // Triangle button.
        PSP_CTRL_CIRCLE, // Circle button.
        PSP_CTRL_CROSS, // Cross button.
        PSP_CTRL_SQUARE, // Square button.
        PSP_CTRL_HOLD, // Hold button.
    };
    u64 curr;
    long long int nextInput = 0;
    u64 lastTime;
    u32 oldButtons;
    u32 veryOldButtons;
    u32 gTickFrequency = sceRtcGetTickResolution();

    sceRtcGetCurrentTick(&lastTime);
    oldButtons = veryOldButtons = 0;

    while (!mDone)
    {
        if (!mPaused)
        {
            sceRtcGetCurrentTick(&curr);
            float dt = (curr - lastTime) / (float)gTickFrequency;
            mDeltaTime = dt;
            sceCtrlPeekBufferPositive(&gCtrlPad, 1);
            for (signed int i = sizeof(keyCodeList)/sizeof(keyCodeList[0]) - 1; i >= 0; --i)
            {
                if (keyCodeList[i] & gCtrlPad.Buttons)
                {
                    if (!(keyCodeList[i] & oldButtons))
                        HoldKey(keyCodeList[i]);
                }
                else
                    if (keyCodeList[i] & oldButtons)
                        ReleaseKey(keyCodeList[i]);
            }
            oldButtons = gCtrlPad.Buttons;
            Update(dt);
            Render();
            if (mDebug)
            {
                if (strlen(mDebuggingMsg)>0)
                {
                    pspDebugScreenSetXY(0, 0);
                    pspDebugScreenPrintf(mDebuggingMsg);
                }
            }
            veryOldButtons = gCtrlPad.Buttons;
        }
        else
            sceKernelDelayThread(1);
        lastTime = curr;
    }
}
Пример #10
0
int hcMiscMenuShowMenu( int xpos, int ypos )
{
  int i;
  int r;
  int btn;
  char sdesc[512];
  SceCtrlData pad;

  sceCtrlSetSamplingCycle(0);
  sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

  pspDebugScreenSetTextColor( MenuColorSelected );
  pspDebugScreenSetXY( xpos, ypos );
  printf( MenuName );

  pspDebugScreenSetTextColor( MenuColorNormal );
  for( i=1; i<=MenuEntryCount; i++ )
  {
    pspDebugScreenSetXY( xpos, ypos+i+1 );
    printf( "   %s", MenuEntries[i-1] );
  }

  r = 0;
  i = 0;
  while( r == 0 )
  {
    pspDebugScreenSetXY( xpos, ypos+i+2 );
    pspDebugScreenSetTextColor( MenuColorSelected );
    printf( "-> %s", MenuEntries[i] );
    pspDebugScreenSetXY( 0, ypos+5+MenuEntryCount );
    printf( "                                                                   \n" );
    printf( "                                                                   \n" );
    printf( "                                                                   \n" );
    printf( "                                                                   \n" );
    printf( "                                                                   " );
    pspDebugScreenSetXY( 0, ypos+5+MenuEntryCount );
    sprintf( sdesc, MenuDesc[i] );
    pspDebugScreenSetTextColor( MenuColorDesc );
    printf( sdesc );
    pspDebugScreenSetTextColor( MenuColorNormal );

    btn=1;
    while( btn != 0 )
    {
      sceCtrlReadBufferPositive( &pad, 1 );
      btn = pad.Buttons & 0xFFFF;
    }
    btn=0;
    while( btn == 0 )
    {
      sceCtrlReadBufferPositive( &pad, 1 );
      btn = pad.Buttons & 0xFFFF;
    }
    pspDebugScreenSetXY( xpos, ypos+i+2 );
    pspDebugScreenSetTextColor( MenuColorNormal );
    printf( "   %s", MenuEntries[i] );
    if( btn == PSP_CTRL_UP ) { i--; }
    if( btn == PSP_CTRL_DOWN ) { i++; }
    if( (MenuEntryIds[i] == -1) & (btn == PSP_CTRL_UP) ) { i--; }
    if( (MenuEntryIds[i] == -1) & (btn == PSP_CTRL_DOWN) ) { i++; }
    if( i > MenuEntryCount-1 ) { i = 0; }
    if( i < 0 ) { i = MenuEntryCount-1; }
    if( btn == PSP_CTRL_CROSS ) { r = MenuEntryIds[i]; }
  }

  return r;
}
Пример #11
0
static int render_titlecolor_row(OptionsPanel* prPanel) {
    CursorPos* prPos = NULL;
    CursorPos* prCursor = NULL;
    ColorConfig* prPcolor = NULL;
    ColorConfig* prCcolor = NULL;
    ColorConfig* prColor = NULL;
    Dimension* prSize = NULL;
    int cr = 0;
    char sFmt[10];

    if (prPanel == NULL) {
        return OPTIONSPANEL_NULLPTR;
    }
    
    prPos = get_position(prPanel);
    prCursor = get_cursorpos(prPanel);
    prPcolor = get_panelcolor(prPanel);
    prCcolor = get_cursorcolor(prPanel);
    prColor = get_titlecolor(prPanel);
    prSize = get_size(prPanel);
    
    pspDebugScreenSetXY(prPos->x, prPos->y + 6);
    if (prColor != NULL) {
        pspDebugScreenSetBackColor(prColor->background);
        pspDebugScreenSetTextColor(prColor->text);
    }
    pspDebugScreenPuts(OPTIONSPANEL_L_TITLEC);
    if (prPcolor != NULL) {
        pspDebugScreenSetBackColor(prPcolor->background);
        pspDebugScreenSetTextColor(prPcolor->text);
    }
    if (prCursor->y == 4) {
        if (prCursor->x == 0) {
            if (prCcolor != NULL) {
                pspDebugScreenSetBackColor(prCcolor->background);
                pspDebugScreenSetTextColor(prCcolor->text);
            }
        }
    }
    pspDebugScreenKprintf("0x%08X", prColor->background);
    if (prPcolor != NULL) {
        pspDebugScreenSetBackColor(prPcolor->background);
        pspDebugScreenSetTextColor(prPcolor->text);
    }
    pspDebugScreenPuts(" ");
    if (prCursor->y == 4) {
        if (prCursor->x == 1) {
            if (prCcolor != NULL) {
                pspDebugScreenSetBackColor(prCcolor->background);
                pspDebugScreenSetTextColor(prCcolor->text);
            }
        }
    }
    pspDebugScreenKprintf("0x%08X", prColor->text);
    cr = prSize->width - strlen(OPTIONSPANEL_L_TITLEC) - 22;
    sprintf(sFmt, "%%-%ds", cr);
    if (prPcolor != NULL) {
        pspDebugScreenSetBackColor(prPcolor->background);
        pspDebugScreenSetTextColor(prPcolor->text);
    }
    pspDebugScreenKprintf(sFmt, "");
    return OPTIONSPANEL_SUCCESS;
}
Пример #12
0
int main(void)
{
	SceCtrlData pad;

	pspDebugScreenInit();
	SetupCallbacks();

	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

	while(!done){
		pspDebugScreenSetXY(0, 2);

    		sceCtrlReadBufferPositive(&pad, 1); 

		printf("Analog X = %d ", pad.Lx);
		printf("Analog Y = %d \n", pad.Ly);

		if (pad.Buttons != 0){
			if (pad.Buttons & PSP_CTRL_SQUARE){
				printf("Square pressed \n");
			}
			if (pad.Buttons & PSP_CTRL_TRIANGLE){
				printf("Triangle pressed \n");
			} 
			if (pad.Buttons & PSP_CTRL_CIRCLE){
				printf("Cicle pressed \n");
			} 
			if (pad.Buttons & PSP_CTRL_CROSS){
				printf("Cross pressed \n");
			} 

			if (pad.Buttons & PSP_CTRL_UP){
				printf("Up pressed \n");
			} 
			if (pad.Buttons & PSP_CTRL_DOWN){
				printf("Down pressed \n");
			} 
			if (pad.Buttons & PSP_CTRL_LEFT){
				printf("Left pressed \n");
			} 
			if (pad.Buttons & PSP_CTRL_RIGHT){
				printf("Right pressed \n");
			}      

			if (pad.Buttons & PSP_CTRL_START){
				printf("Start pressed \n");
			}
			if (pad.Buttons & PSP_CTRL_SELECT){
				printf("Select pressed \n");
			}
			if (pad.Buttons & PSP_CTRL_LTRIGGER){
				printf("L-trigger pressed \n");
			}
			if (pad.Buttons & PSP_CTRL_RTRIGGER){
				printf("R-trigger pressed \n");
			}      
		}
	}

	sceKernelExitGame();
	return 0;
}
Пример #13
0
int main(int argc, char* argv[])
{
	unsigned int i,j;

	pspDebugScreenInit();
	SetupCallbacks();

#ifdef ENABLE_PROFILER
	// Enable profiling 
	pspDebugProfilerClear();
	pspDebugProfilerEnable();
#endif

	// initialize global context
	g_context.iterationCount = NUM_VERTEX_BUFFERS * NUM_ITERATIONS;
	g_context.t = 0;
	g_context.sint = 0;

	// initialize torus
	for (i = 0; i < NUM_SLICES; ++i)
	{
		for (j = 0; j < NUM_ROWS; ++j)
		{
			float s = i + 0.5f, t = j;
			float x,y,z;

			x = (RING_SIZE + RING_RADIUS * cosf(s * ((GU_PI*2)/NUM_SLICES))) * cosf(t * ((GU_PI*2)/NUM_ROWS));
			y = (RING_SIZE + RING_RADIUS * cosf(s * ((GU_PI*2)/NUM_SLICES))) * sinf(t * ((GU_PI*2)/NUM_ROWS));
			z = RING_RADIUS * sinf(s * ((GU_PI*2)/NUM_SLICES));

			torus_vertices[j + i * NUM_ROWS].x = x;
			torus_vertices[j + i * NUM_ROWS].y = y;
			torus_vertices[j + i * NUM_ROWS].z = z;
		}
	}

	// initialize torus modifiers

	for (j = 0; j < NUM_ROWS; ++j)
	{
		float t = j;
		torus_modifiers[j].x = 0;
		torus_modifiers[j].y = 0;
		torus_modifiers[j].z = 0.3*cosf( t * 8.0f *((GU_PI*2)/NUM_ROWS) );
	}

	// init GU and set callbacks
	sceGuInit();

	// 0x01 - user callback
	// 0x04 - 'rendering finished' callback
	sceGuSetCallback(1, &mySignalHandler);
	sceGuSetCallback(4, &myFinishHandler);

	// setup GU
	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_8888,(void*)0,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)0x88000,BUF_WIDTH);
	sceGuDepthBuffer((void*)0x110000,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(0xc350,0x2710);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuAlphaFunc(GU_GREATER,0,0xff);
	sceGuEnable(GU_ALPHA_TEST);
	sceGuDepthFunc(GU_GEQUAL);
	sceGuEnable(GU_DEPTH_TEST);
	sceGuFrontFace(GU_CW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuEnable(GU_CULL_FACE);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuFinish();
	sceGuSync(0,0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);

	// run sample

#ifdef USING_SIGNALS
	sceGuCallMode(1);
#endif

	// generate callable command-list with texture setup
	{
		sceGuStart(GU_CALL, smallList1);

		// setup texture
		sceGuTexMode(GU_PSM_5551,0,0,0);
		sceGuTexImage(0,32,32,32,ball_start); // width, height, buffer width, tbp
		sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA); // NOTE: this enables reads of the alpha-component from the texture, otherwise blend/test won't work
		sceGuTexFilter(GU_NEAREST,GU_NEAREST);
		sceGuTexWrap(GU_CLAMP,GU_CLAMP);
		sceGuTexScale(1,1);
		sceGuTexOffset(0,0);
		sceGuAmbientColor(0xffffffff);

		sceGuFinish();
		sceGuSync(0,0);
	}

	// generate callable command-list for cube rendering
	{
		sceGuStart(GU_CALL, smallList2);

		// draw cube
		sceGuDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,cubeVertices);

		sceGuFinish();
		sceGuSync(0,0);
	}

	for(;;)
	{
		sceGuStart(GU_DIRECT,list);

		unsigned int i = 0;
		for( ; i < NUM_VERTEX_BUFFERS; i++ )
			g_context.vbuffer[i] = sceGuGetMemory((NUM_SLICES/g_context.iterationCount) * 2 * NUM_ROWS * sizeof(Vertex));
		g_context.vertsRendered = 0;

		// clear screen
		sceGuClearColor(0x00334455);
		sceGuClearDepth(0);
		sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

		// setup matrices
		sceGumMatrixMode(GU_PROJECTION);
		sceGumLoadIdentity();
		sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

		sceGumMatrixMode(GU_VIEW);
		sceGumLoadIdentity();

		sceGumMatrixMode(GU_MODEL);
		{
			ScePspFVector3 pos = {0.0f,0.0f,-3.5f};
			ScePspFVector3 rot = {g_context.t * 0.3f * (GU_PI/180.0f), g_context.t * 0.7f * (GU_PI/180.0f), g_context.t * 1.3f * (GU_PI/180.0f)};

			sceGumLoadIdentity();
			sceGumTranslate(&pos);
			sceGumRotateXYZ(&rot);
		}

		sceGumStoreMatrix(&g_context.world);

		// call pregenerated command-list to setup texture		
		sceGuCallList(smallList1);

		// start billboard rendering
		render_billboards(0);

		// call pregenerated command-list to render cube
		{
			ScePspFVector3 scale = {0.3f, 0.3f, 0.3f};
			sceGumScale(&scale);
		}

		sceGumUpdateMatrix();
		sceGuCallList(smallList2);	

#ifndef USING_SIGNALS
		// HACK: sceGuFinish() is called inside the signal interupt handler when all rendering job is done
		// this is done in order to stall GPU if it is ahead of CPU
		sceGuFinish();
#endif
		sceGuSync(0,0);

#ifndef ENABLE_FRAMERATE
		// wait for next frame
		sceDisplayWaitVblankStart();
#endif
		sceGuSwapBuffers();

		pspDebugScreenSetXY(0,0);

#ifdef ENABLE_PROFILER
		// Print profile information to the screen
		pspDebugProfilerPrint();
#endif

#ifdef ENABLE_FRAMERATE
		// simple frame rate counter
		static float curr_ms = 1.0f;
		static struct timeval time_slices[16];
		static int t = 0;

		float curr_fps = 1.0f / curr_ms;

		t++;
		
		float vertsPerSec = g_context.vertsRendered*curr_fps;
		float kbPerSec = vertsPerSec * sizeof(Vertex) / 1024.0f;
		gettimeofday(&time_slices[t & 15],0);
		pspDebugScreenPrintf("fps: %d.%03d  ms: %d  vert/s: %dK  MB/s: %d.%03d",(int)curr_fps, ((int)(curr_fps*1000.0f)%1000), (int)(curr_ms*1000.0f),
			(int)(vertsPerSec/1000.0f),
			(int)(kbPerSec/1024.0f), (int)((1000.0f/1024.0f)*((int)kbPerSec%1024)) );

		if (!(t & 15))
		{
			struct timeval last_time = time_slices[0];
			unsigned int i;

			curr_ms = 0;
			for (i = 1; i < 16; ++i)
			{
				struct timeval curr_time = time_slices[i];

				int curr_time_usec = curr_time.tv_usec + curr_time.tv_sec * 1000000;
				int last_time_usec = last_time.tv_usec + last_time.tv_sec * 1000000;

				if( last_time_usec < curr_time_usec )
					curr_ms += (( curr_time_usec - last_time_usec ) * (1.0f/1000000.0f));

				last_time = time_slices[i];
			}
			curr_ms /= 15.0f;
		}
#endif
	}

	sceGuTerm();

	sceKernelExitGame();
	return 0;
}
Пример #14
0
int main(int argc, char* argv[]) {
	/* Setup Homebutton Callbacks */
	setupCallbacks();

	sceKernelDcacheWritebackAll();

	// setup GU

	SceCtrlData pad;
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

	sceGuInit();

	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_8888,(void*)0,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)0x88000,BUF_WIDTH);
	sceGuDepthBuffer((void*)0x110000,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(0xc350,0x2710);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuDepthFunc(GU_GEQUAL);
	sceGuEnable(GU_DEPTH_TEST);
	sceGuFrontFace(GU_CCW);
	sceGuColor(0xffffffff);
	sceGuShadeModel(GU_SMOOTH);
//	sceGuEnable(GU_CULL_FACE);
	sceGuEnable(GU_CLIP_PLANES);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_8888, 0, 0, 0);
	sceGuTexImage(0, 16, 16, 16, texture);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
	sceGuTexEnvColor(0xffffff);
	sceGuTexFilter(GU_LINEAR, GU_LINEAR);
	sceGuTexWrap(GU_REPEAT, GU_REPEAT);
	sceGuTexScale(1.0f, 1.0f);
	sceGuTexOffset(0.0f, 0.0f);
	sceGuAmbientColor(0xffffffff);

	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);
	
	void* buffer = 0;

	pspDebugScreenInit();

	unsigned int old = 0;
	unsigned int flags = PSP_CTRL_CIRCLE | PSP_CTRL_CROSS;

	int tex = 1;

	while(running()) {
		sceGuStart(GU_DIRECT,list);

		sceGuClearColor(0);
		sceGuClearDepth(0);
		sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);

		sceGumMatrixMode(GU_PROJECTION);
		sceGumLoadIdentity();
		sceGumPerspective(90.0f, 480.0/272.0f, 0.1f, 10.0f);

		sceGumMatrixMode(GU_VIEW);
		sceGumLoadIdentity();
		ScePspFVector3 trans = { 0.0f, 0.0f, -1.8f };
		sceGumTranslate(&trans);
		
		sceGumMatrixMode(GU_MODEL);
		sceGumLoadIdentity();

		sceGumDrawArray(objects[o].prim, objects[o].flags, objects[o].count, 0, objects[o].data);

		sceCtrlReadBufferPositive(&pad, 1);
		if(old != pad.Buttons) {
			if(pad.Buttons & PSP_CTRL_CROSS) {
				o++;
				if(o >= sizeof(objects) / sizeof(Object)) {
					o = 0;
				}
			}
			if(pad.Buttons & PSP_CTRL_CIRCLE) {
				tex = !tex;
				if(tex) {
					sceGuEnable(GU_TEXTURE_2D);
				} else {
					sceGuDisable(GU_TEXTURE_2D);
				}
			}
		}
		old = pad.Buttons;

		sceGuFinish();
		sceGuSync(0,0);

		pspDebugScreenSetOffset((int)buffer);
		pspDebugScreenSetXY(0, 0);
		pspDebugScreenPrintf("Mode: %s (X to change)    Texture: %s (O to change)", objects[o].text, tex ? "on " : "off");

		sceDisplayWaitVblankStart();
		buffer = sceGuSwapBuffers();
	}

	sceGuTerm();

	sceKernelExitGame();
	return 0;
}
Пример #15
0
//*************************************************************************************
//Used to check for compatible FW, we don't allow anything lower than 4.01
//*************************************************************************************
static void DaedalusFWCheck()
{
// ##define PSP_FIRMWARE Borrowed from Davee
#define PSP_FIRMWARE(f) ((((f >> 8) & 0xF) << 24) | (((f >> 4) & 0xF) << 16) | ((f & 0xF) << 8) | 0x10)

	u32 ver = sceKernelDevkitVersion();
/*
	FILE * fh = fopen( "firmware.txt", "a" );
	if ( fh )
	{
		fprintf( fh,  "version=%d, firmware=0x%08x\n", kuKernelGetModel(), ver );
		fclose(fh);
	}
*/
	if( (ver < PSP_FIRMWARE(0x401)) )
	{
		pspDebugScreenInit();
		pspDebugScreenSetTextColor(0xffffff);
		pspDebugScreenSetBackColor(0x000000);
		pspDebugScreenSetXY(0, 0);
		pspDebugScreenClear();
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf("XXXXXXX       XXXXXXX        66666666         444444444\n" );
		pspDebugScreenPrintf("X:::::X       X:::::X       6::::::6         4::::::::4\n" );
		pspDebugScreenPrintf("X:::::X       X:::::X      6::::::6         4:::::::::4\n" );
		pspDebugScreenPrintf("X::::::X     X::::::X     6::::::6         4::::44::::4\n" );
		pspDebugScreenPrintf("XXX:::::X   X:::::XXX    6::::::6         4::::4 4::::4\n" );
		pspDebugScreenPrintf("   X:::::X X:::::X      6::::::6         4::::4  4::::4\n" );
		pspDebugScreenPrintf("    X:::::X:::::X      6::::::6         4::::4   4::::4\n" );
		pspDebugScreenPrintf("     X:::::::::X      6::::::::66666   4::::444444::::444\n" );
		pspDebugScreenPrintf("     X:::::::::X     6::::::::::::::66 4::::::::::::::::4\n" );
		pspDebugScreenPrintf( "   X:::::X:::::X    6::::::66666:::::64444444444:::::444\n" );
		pspDebugScreenPrintf("   X:::::X X:::::X   6:::::6     6:::::6         4::::4\n" );
		pspDebugScreenPrintf("XXX:::::X   X:::::XXX6:::::6     6:::::6         4::::4\n" );
		pspDebugScreenPrintf("X::::::X     X::::::X6::::::66666::::::6         4::::4\n" );
		pspDebugScreenPrintf("X:::::X       X:::::X 66:::::::::::::66        44::::::44\n" );
		pspDebugScreenPrintf("X:::::X       X:::::X   66:::::::::66          4::::::::4\n" );
		pspDebugScreenPrintf("XXXXXXX       XXXXXXX     666666666            4444444444\n" );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "--------------------------------------------------------------------\n" );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "	Unsupported Firmware Detected : 0x%08X\n", ver );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "	Daedalus requires atleast 4.01 M33 Custom Firmware\n" );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "--------------------------------------------------------------------\n" );
		sceKernelDelayThread(1000000);
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf( "\n" );
		pspDebugScreenPrintf("\nPress O to Exit or [] to Ignore");
		for (;;)
		{
			SceCtrlData pad;
			sceCtrlPeekBufferPositive(&pad, 1);
			if (pad.Buttons & PSP_CTRL_CIRCLE)
				break;
			if (pad.Buttons & PSP_CTRL_SQUARE)
				return;
		}
		sceKernelExitGame();
	}

}
Пример #16
0
void imposter_quickedit()
{
	pspDebugScreenSetXY(1, 6);
	pspDebugScreenSetTextColor(lblue);
	unsigned int *p1 = (unsigned int*) (0x00bc0038+0x08800000);
	int namelength;
	int letcounter = 0;
	int valcounter = 0;
	pspDebugScreenSetXY(1, 7);
	tcolor(red);
	print("Name: ");
	while(letcounter<13)
	{
		unsigned char *letbuffer = (unsigned char*) (offset+letcounter);
		sprintf(namebuffer, " %c ", *letbuffer);
		sprintf(namebuffer2, "%d", strlen(namebuffer));
		if(strlen(namebuffer)==1)
		{
			sprintf(namebuffer, "   ");
		}
		print(namebuffer);
		letcounter++;
	}
		
	pspDebugScreenSetXY(1, 8);
	print("Hex:  ");
	while(valcounter<13)
	{
		unsigned char *letbuffer = (unsigned char*) (offset+valcounter);
		sprintf(namebuffer1, "%02hX ", *letbuffer);
		print(namebuffer1);
		valcounter++;
	}
	unsigned char *let1 = (unsigned char*) (offset);
	unsigned char *let2 = (unsigned char*) (offset+1);
	unsigned char *let3 = (unsigned char*) (offset+2);
	unsigned char *let4 = (unsigned char*) (offset+3);
	unsigned char *let5 = (unsigned char*) (offset+4);
	unsigned char *let6 = (unsigned char*) (offset+5);
	unsigned char *let7 = (unsigned char*) (offset+6);
	unsigned char *let8 = (unsigned char*) (offset+7);
	unsigned char *let9 = (unsigned char*) (offset+8);
	unsigned char *let10 = (unsigned char*) (offset+9);
	unsigned char *let11 = (unsigned char*) (offset+10);
	unsigned char *let12 = (unsigned char*) (offset+11);
	unsigned char *let13 = (unsigned char*) (offset+12);
	unsigned char *let14 = (unsigned char*) (offset+13);
	unsigned char *let15 = (unsigned char*) (offset+14);
	unsigned char *let16 = (unsigned char*) (offset+15);
	//Hex
	pspDebugScreenSetXY(7, 9);
	tcolor(pcletselect);
	switch(pclet)
	{
		case 1:
			print("^                              ");
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				pclet=2;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let1=*let1+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let1=*let1-0x10;
			}
			}
			break;
		case 2:
			
			print(" ^                             ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=1;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=3;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let1=*let1+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let1=*let1-0x01;
			}
			}
			break;
		case 3:
			print("   ^                           ");
				if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=2;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=4;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let2=*let2+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let2=*let2-0x10;
			}
			}
			break;
		case 4:
		print("    ^                          ");

			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=3;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=5;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let2=*let2+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let2=*let2-0x01;
			}
			}
			break;
		case 5:
		print("      ^                        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=4;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=6;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let3=*let3+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let3=*let3-0x10;
			}
			}
			break;
		case 6:
			print("       ^                       ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=5;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=7;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let3=*let3+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let3=*let3-0x01;
			}
			}
			break;
		case 7:
						print("         ^                     ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=6;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=8;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let4=*let4+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let4=*let4-0x10;
			}
			}
			break;
			case 8:
			print("          ^                    ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=7;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=9;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let4=*let4+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let4=*let4-0x01;
			}
			}
			break;
			case 9:
			print("            ^                   ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=8;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=10;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let5=*let5+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let5=*let5-0x10;
			}
			}
			break;
			case 10:
			print("             ^                  ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=9;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=11;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let5=*let5+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let5=*let5-0x01;
			}
			}
			break;
			case 11:
			print("               ^                ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=10;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=12;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let6=*let6+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let6=*let6-0x10;
			}
			}
			break;
			case 12:
			print("                ^               ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=11;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=13;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let6=*let6+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let6=*let6-0x01;
			}
			}
			break;
			case 13:
			print("                  ^             ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=12;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=14;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let7=*let7+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let7=*let7-0x10;
			}
			}
			break;
			case 14:
			print("                   ^            ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=13;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=15;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let7=*let7+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let7=*let7-0x01;
			}
			}
			break;
			case 15:
			print("                     ^          ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=14;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=16;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let8=*let8+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let8=*let8-0x10;
			}
			}
			break;
			case 16:
			print("                      ^         ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=15;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=17;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let8=*let8+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let8=*let8-0x01;
			}
			}
			break;
			case 17:
			print("                        ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=16;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=18;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let9=*let9+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let9=*let9-0x10;
			}
			}
			break;
			case 18:
			print("                         ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=17;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=19;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let9=*let9+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let9=*let9-0x01;
			}
			}
			break;
case 19:
			print("                           ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=18;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=20;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let10=*let10+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let10=*let10-0x10;
			}
			}
			break;
			case 20:
			print("                            ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=19;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=21;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let10=*let10+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let10=*let10-0x01;
			}
			}
			break;
			case 21:
			print("                              ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=20;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=22;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let11=*let11+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let11=*let11-0x10;
			}
			}
			break;
			case 22:
			print("                               ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=21;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=23;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let11=*let11+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let11=*let11-0x01;
			}
			}
			break;
			case 23:
			print("                                 ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=22;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=24;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let12=*let12+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let12=*let12-0x10;
			}
			}
			break;
			case 24:
			print("                                  ^        ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=23;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=25;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let12=*let12+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let12=*let12-0x01;
				
			}
			}
			break;
			case 25:
			print("                                    ^      ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=24;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=26;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let13=*let13+0x10;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let13=*let13-0x10;
				
			}
			}
			break;
			case 26:
			print("                                     ^     ");
			if(pad.Buttons & PSP_CTRL_LEFT)
			{
				
				pclet=25;
			}
			if(pad.Buttons & PSP_CTRL_RIGHT)
			{
				
				pclet=26;
			}
			if(pad.Buttons & PSP_CTRL_CROSS)
			{
				if(pcletselect==red)
				{
					pcletselect=yellow;
				}
				else
				{				
					pcletselect=red;
				}
			}
			if(pcletselect==red)
			{
			if(pad.Buttons & PSP_CTRL_UP)
			{
				*let13=*let13+0x01;
			}
			if(pad.Buttons & PSP_CTRL_DOWN)
			{
				*let13=*let13-0x01;
				
			}
			}
			break;
		}
	}
Пример #17
0
int main(int argc, char* argv[])
{
	setupCallbacks();

	int i, j;

	// Load emd mesh from file
	EMD_MESH* mesh = EMD_LoadMeshFromFile("scene.emd");
	int vert_count = EMD_GetVertexCount(mesh);
	int idx_count = 0;

	int elem_count = EMD_GetElementCount(mesh);
	for (i=0; i<elem_count; i++)
	{
		idx_count += EMD_GetIndexCount(mesh, i);
	}

	VERTEX* vert_buf = (VERTEX*)memalign(16, sizeof(VERTEX) * vert_count);
	GW_UINT16* idx_buf = (GW_UINT16*)memalign(16, sizeof(GW_UINT16) * idx_count);

	for (i=0; i<vert_count; i++)
	{
		EMD_GetVertexByIndex(mesh, i, &vert_buf[i].x, &vert_buf[i].y, &vert_buf[i].z);
		EMD_GetTexcoordByIndex(mesh, i, &vert_buf[i].u, &vert_buf[i].v);
		EMD_GetNormalByIndex(mesh, i, &vert_buf[i].nx, &vert_buf[i].ny, &vert_buf[i].nz);
		//vert_buf[i].color = 0xffffffff;
	}

	GW_UINT32 idx_head = 0;
	GW_UINT32* data;
	GW_UINT32 count;

	// Pack 32-bit index into 16-bit buffer
	for (i=0; i<elem_count; i++)
	{
		count = EMD_GetIndexCount(mesh, i);
		data = EMD_GetIndexArray(mesh, i);
		for (j=0; j<count; j++)
		{
			idx_buf[j + idx_head] = (GW_UINT16)data[j];
		}

		idx_head += count;
	}

	EMD_FreeMesh(mesh);


	// flush cache so that no stray data remains

	sceKernelDcacheWritebackAll();

	// setup GU

	void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
	void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
	void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

	pspDebugScreenInit();
	sceGuInit();

	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
	sceGuDepthBuffer(zbp,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(65535,0);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuDepthFunc(GU_GEQUAL);
	sceGuEnable(GU_DEPTH_TEST);
	sceGuFrontFace(GU_CCW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuEnable(GU_CULL_FACE);
	//sceGuDisable(GU_TEXTURE_2D);
	sceGuEnable(GU_CLIP_PLANES);
	sceGuEnable(GU_LIGHTING);
	sceGuEnable(GU_LIGHT0);
	sceGuEnable(GU_LIGHT1);
	sceGuFinish();
	sceGuSync(0,0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);

	// run sample

	int val = 0;

	while(running())
	{
		sceGuStart(GU_DIRECT,list);

		// clear screen

		sceGuClearColor(0xff554433);
		sceGuClearDepth(0);
		sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

		
		// setup lights

		ScePspFVector3 light_dir = { 1.0f, 1.0f, 1.0f };

		// GU_DIRECTIONAL
		// GU_POINTLIGHT
		sceGuLight(0, GU_POINTLIGHT, GU_DIFFUSE, &light_dir);
		sceGuLightColor(0, GU_DIFFUSE, 0xffffffff);
		sceGuAmbient(0x00202020);

		light_dir.x = -light_dir.x;
		light_dir.y = -light_dir.y;
		light_dir.z = -light_dir.z;

		sceGuLight(1, GU_DIRECTIONAL, GU_DIFFUSE_AND_SPECULAR, &light_dir);
		sceGuLightColor(1, GU_DIFFUSE, 0xff7f7f7f);
		

		// setup matrices for cube

		sceGumMatrixMode(GU_PROJECTION);
		sceGumLoadIdentity();
		sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

		sceGumMatrixMode(GU_VIEW);
		sceGumLoadIdentity();

		sceGumMatrixMode(GU_MODEL);
		sceGumLoadIdentity();
		{
			ScePspFVector3 pos = { 0, 0, -5.0f };
			ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
			sceGumTranslate(&pos);
			sceGumRotateXYZ(&rot);
		}

		// setup texture

		//sceGuTexMode(GU_PSM_4444,0,0,0);
		// sceGuTexImage(0,64,64,64,logo_start);
		//sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB);
		//sceGuTexEnvColor(0xffff00);
		//sceGuTexFilter(GU_LINEAR,GU_LINEAR);
		//sceGuTexScale(1.0f,1.0f);
		//sceGuTexOffset(0.0f,0.0f);
		//sceGuAmbientColor(0xff7f7f7f);

		// draw cube

		sceGuColor(0xffffff);
		sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D,
				idx_count, idx_buf, vert_buf);
		

		pspDebugScreenSetXY(0, 0);
		pspDebugScreenPrintf("v: %d", vert_count);
		pspDebugScreenSetXY(0, 1);
		pspDebugScreenPrintf("i: %d", idx_count);

		sceGuFinish();
		sceGuSync(0,0);

		sceDisplayWaitVblankStart();
		sceGuSwapBuffers();

		val++;
	}

	sceGuTerm();

	// Release buffers
	free(vert_buf);
	free(idx_buf);

	sceKernelExitGame();
	return 0;
}
Пример #18
0
int main(int argc, char* argv[])
{
	pspDebugScreenInit();

	setupCallbacks();

	// setup GU

	void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
	void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
	void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

	sceGuInit();

	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
	sceGuDepthBuffer(zbp,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(65535,0);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);

	int val = 0;

	gettimeofday(&base_time,0);

	while(running())
	{
		struct Vertex* vertices;
		struct timeval tv;

		sceGuStart(GU_DIRECT,list);

		// clear screen

		sceGuClearColor(0);
		sceGuClearDepth(0);
		sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

		// draw triangle 1 (normal)

		sceGuColor(0xffffffff);

		vertices = (struct Vertex*)sceGuGetMemory(3*sizeof(struct Vertex));
		vertices[0].x = (SCR_WIDTH/2) + cosf(val * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].y = (SCR_HEIGHT/2) + sinf(val * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].z = 0;
		vertices[1].x = (SCR_WIDTH/2) + cosf((val+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].y = (SCR_HEIGHT/2) + sinf((val+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].z = 0;
		vertices[2].x = (SCR_WIDTH/2) + cosf((val+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].y = (SCR_HEIGHT/2) + sinf((val+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].z = 0;
		sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_2D,3,0,vertices);

		// draw triangle 2 (affected by logic op)

		sceGuEnable(GU_COLOR_LOGIC_OP);
		sceGuLogicalOp(curr_state);

		sceGuColor(0xffff00ff);

		vertices = (struct Vertex*)sceGuGetMemory(3*sizeof(struct Vertex));
		vertices[0].x = (SCR_WIDTH/2) + cosf((val*1.1f) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].y = (SCR_HEIGHT/2) + sinf((val*1.1f) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].z = 0;
		vertices[1].x = (SCR_WIDTH/2) + cosf((val*1.1f+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].y = (SCR_HEIGHT/2) + sinf((val*1.1f+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].z = 0;
		vertices[2].x = (SCR_WIDTH/2) + cosf((val*1.1f+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].y = (SCR_HEIGHT/2) + sinf((val*1.1f+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].z = 0;
		sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_2D,3,0,vertices);

		sceGuDisable(GU_COLOR_LOGIC_OP);

		sceGuFinish();
		sceGuSync(0,0);

		gettimeofday(&tv,0);
		if ((tv.tv_sec-base_time.tv_sec) > TIME_SLICE)
		{
			curr_state = (curr_state + 1) & 15;
			base_time = tv;
		}

		sceDisplayWaitVblankStart();
		sceGuSwapBuffers();
		pspDebugScreenSetXY(0,0);
		pspDebugScreenPrintf("%s",names[curr_state]);

		val++;
	}

	sceGuTerm();

	sceKernelExitGame();
	return 0;
}
Пример #19
0
/* main routine */
int main(int argc, char *argv[])
{
    SceCtrlData pad;

    //init screen and callbacks
    pspDebugScreenInit();
    pspDebugScreenClear();
    SetupCallbacks();

    // Setup Pad
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(0);

    // Load modules
    int status = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC);
    if (status<0)
    {
        ERRORMSG("ERROR: sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC) returned 0x%08X\n", status);
    }

    status = sceUtilityLoadModule(PSP_MODULE_AV_MP3);
    if (status<0)
    {
        ERRORMSG("ERROR: sceUtilityLoadModule(PSP_MODULE_AV_MP3) returned 0x%08X\n", status);
    }

    // Open the input file
    int fd = sceIoOpen( MP3FILE, PSP_O_RDONLY, 0777 );
    if (fd<0)
    {
        ERRORMSG("ERROR: Could not open file '%s' - 0x%08X\n", MP3FILE, fd);
    }

    // Init mp3 resources
    status = sceMp3InitResource();
    if (status<0)
    {
        ERRORMSG("ERROR: sceMp3InitResource returned 0x%08X\n", status);
    }

    // Reserve a mp3 handle for our playback
    SceMp3InitArg mp3Init;
    mp3Init.mp3StreamStart = 0;
    mp3Init.mp3StreamEnd = sceIoLseek32( fd, 0, SEEK_END );
    mp3Init.unk1 = 0;
    mp3Init.unk2 = 0;
    mp3Init.mp3Buf = mp3Buf;
    mp3Init.mp3BufSize = sizeof(mp3Buf);
    mp3Init.pcmBuf = pcmBuf;
    mp3Init.pcmBufSize = sizeof(pcmBuf);

    int handle = sceMp3ReserveMp3Handle( &mp3Init );
    if (handle<0)
    {
        ERRORMSG("ERROR: sceMp3ReserveMp3Handle returned 0x%08X\n", handle);
    }

    // Fill the stream buffer with some data so that sceMp3Init has something to work with
    fillStreamBuffer( fd, handle );

    status = sceMp3Init( handle );
    if (status<0)
    {
        ERRORMSG("ERROR: sceMp3Init returned 0x%08X\n", status);
    }

    int channel = -1;
    int samplingRate = sceMp3GetSamplingRate( handle );
    int numChannels = sceMp3GetMp3ChannelNum( handle );
    int lastDecoded = 0;
    int volume = PSP_AUDIO_VOLUME_MAX;
    int numPlayed = 0;
    int paused = 0;
    int lastButtons = 0;
    int loop = 0;
    while (isrunning)
    {
        sceDisplayWaitVblankStart();
        pspDebugScreenSetXY(0, 0);
        printf("PSP Mp3 Sample v1.0 by Raphael\n\n");
        printf("Playing '%s'...\n", MP3FILE);
        printf(" %i Hz\n", samplingRate);
        printf(" %i kbit/s\n", sceMp3GetBitRate( handle ));
        printf(" %s\n", numChannels==2?"Stereo":"Mono");
        printf(" %s\n\n", loop==0?"No loop":"Loop");
        int playTime = samplingRate>0?numPlayed / samplingRate:0;
        printf(" Playtime: %02i:%02i\n", playTime/60, playTime%60 );
        printf("\n\n\nPress CIRCLE to Pause/Resume playback\nPress TRIANGLE to reset playback\nPress CROSS to switch loop mode\nPress SQUARE to stop playback and quit\n");

        if (!paused)
        {
            // Check if we need to fill our stream buffer
            if (sceMp3CheckStreamDataNeeded( handle )>0)
            {
                fillStreamBuffer( fd, handle );
            }

            // Decode some samples
            short* buf;
            int bytesDecoded;
            int retries = 0;
            // We retry in case it's just that we reached the end of the stream and need to loop
            for (; retries<1; retries++)
            {
                bytesDecoded = sceMp3Decode( handle, &buf );
                if (bytesDecoded>0)
                    break;

                if (sceMp3CheckStreamDataNeeded( handle )<=0)
                    break;

                if (!fillStreamBuffer( fd, handle ))
                {
                    numPlayed = 0;
                }
            }
            if (bytesDecoded<0 && bytesDecoded!=0x80671402)
            {
                ERRORMSG("ERROR: sceMp3Decode returned 0x%08X\n", bytesDecoded);
            }

            // Nothing more to decode? Must have reached end of input buffer
            if (bytesDecoded==0 || bytesDecoded==0x80671402)
            {
                paused = 1;
                sceMp3ResetPlayPosition( handle );
                numPlayed = 0;
            }
            else
            {
                // Reserve the Audio channel for our output if not yet done
                if (channel<0 || lastDecoded!=bytesDecoded)
                {
                    if (channel>=0)
                        sceAudioSRCChRelease();

                    channel = sceAudioSRCChReserve( bytesDecoded/(2*numChannels), samplingRate, numChannels );
                }
                // Output the decoded samples and accumulate the number of played samples to get the playtime
                numPlayed += sceAudioSRCOutputBlocking( volume, buf );
            }
        }

        sceCtrlPeekBufferPositive(&pad, 1);

        if (pad.Buttons!=lastButtons)
        {
            if (pad.Buttons & PSP_CTRL_CIRCLE)
            {
                paused ^= 1;
            }

            if (pad.Buttons & PSP_CTRL_TRIANGLE)
            {
                // Reset the stream and playback status
                sceMp3ResetPlayPosition( handle );
                numPlayed = 0;
            }

            if (pad.Buttons & PSP_CTRL_CROSS)
            {
                loop = (loop==0?-1:0);
                status = sceMp3SetLoopNum( handle, loop );
                if (status<0)
                {
                    ERRORMSG("ERROR: sceMp3SetLoopNum returned 0x%08X\n", status);
                }
            }

            if (pad.Buttons & PSP_CTRL_SQUARE)
            {
                break;
            }

            lastButtons = pad.Buttons;
        }
    }

    // Cleanup time...
    if (channel>=0)
        sceAudioSRCChRelease();

    status = sceMp3ReleaseMp3Handle( handle );
    if (status<0)
    {
        ERRORMSG("ERROR: sceMp3ReleaseMp3Handle returned 0x%08X\n", status);
    }

    status = sceMp3TermResource();
    if (status<0)
    {
        ERRORMSG("ERROR: sceMp3TermResource returned 0x%08X\n", status);
    }

    status = sceIoClose( fd );
    if (status<0)
    {
        ERRORMSG("ERROR: sceIoClose returned 0x%08X\n", status);
    }

    sceKernelExitGame();

    return 0;
}
Пример #20
0
static bool psp_frame(void *data, const void *frame,
                      unsigned width, unsigned height, unsigned pitch, const char *msg)
{
    static char fps_txt[128], fps_text_buf[128];
    psp1_video_t *psp = (psp1_video_t*)data;

#ifdef DISPLAY_FPS
    static uint64_t currentTick,lastTick;
    static float fps=0.0;
    static int frames;
#endif

    if (!width || !height)
        return false;

    sceGuSync(0, 0);

    pspDebugScreenSetBase(psp->draw_buffer);

    pspDebugScreenSetXY(0,0);

    if(g_settings.fps_show)
    {
        gfx_get_fps(fps_txt, sizeof(fps_txt), fps_text_buf, sizeof(fps_text_buf));
        pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
        pspDebugScreenPuts(fps_text_buf);
        pspDebugScreenSetXY(0,1);
    }
    else
        gfx_get_fps(fps_txt, sizeof(fps_txt), NULL, 0);

    if (msg)
        pspDebugScreenPuts(msg);

    if (psp->vsync)
        sceDisplayWaitVblankStart();



#ifdef DISPLAY_FPS
    frames++;
    sceRtcGetCurrentTick(&currentTick);
    uint32_t diff = currentTick - lastTick;
    if(diff > 1000000)
    {
        fps = (float)frames * 1000000.0 / diff;
        lastTick = currentTick;
        frames = 0;
    }

    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("%f", fps);
#endif

    psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
    g_extern.frame_count++;

    psp->frame_coords->v0.x = (SCEGU_SCR_WIDTH - width * SCEGU_SCR_HEIGHT / height) / 2;
//   psp->frame_coords->v0.y = 0;
//   psp->frame_coords->v0.u = 0;
//   psp->frame_coords->v0.v = 0;

    psp->frame_coords->v1.x = (SCEGU_SCR_WIDTH + width * SCEGU_SCR_HEIGHT / height) / 2;
//   psp->frame_coords->v1.y = SCEGU_SCR_HEIGHT;
    psp->frame_coords->v1.u = width;
    psp->frame_coords->v1.v = height;

    sceGuStart(GU_DIRECT, psp->main_dList);

    if ((uint32_t)frame&0x04000000) // frame in VRAM ? texture/palette was set in core so draw directly
    {
        sceGuClear(GU_COLOR_BUFFER_BIT);
        sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_4444 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, (void*)(psp->frame_coords));
    }
    else
    {
        if (frame!=NULL)
        {
            sceKernelDcacheWritebackRange(frame,pitch * height);
            sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2, 0, width, height, pitch >> psp->bpp_log2, (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture);
        }

        sceGuClear(GU_COLOR_BUFFER_BIT);
        sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture);
        sceGuCallList(psp->frame_dList);
    }
Пример #21
0
static int draw_button_panel(SearchPanel* prPanel) {
    SearchEngine* prEngine = NULL;
    AppletConfig* prApCfg = NULL;
    ColorConfig* prColor = NULL;
    char* sLabel = "Search";
    int y = 0;
    int x = 0;
    int row = 0;
    int col = 0;
    u32 bg = 0;
    u32 fg = 0;

    if (prPanel == NULL) {
        return SEARCHPANEL_MEMORY;
    }
    prEngine = prPanel->prEngine;
    if (prEngine == NULL) {
        return SEARCHPANEL_MEMORY;
    }
    prApCfg = prPanel->prApCfg;
    if (prEngine->rState == ESS_Searching) {
        sLabel = "Cancel";
    }
    if (prEngine->rState == ESS_Finished) {
        sLabel = "Continue";
    }
    x = prPanel->config.top.x + 2;
    y = prPanel->config.top.y + 7;
    row = prPanel->cursor.y;
    col = prPanel->cursor.x;
    if (prApCfg != NULL) {
        prColor = appletconfig_get_panelcolor(prApCfg);
    } else {
        prColor = &prPanel->config.color;
    }
    if (row == 4) {
        if (col == 0) {
            if (prApCfg != NULL) {
                prColor = appletconfig_get_cursorcolor(prApCfg);
            } else {
                prColor = &prPanel->config.cursor;
            }
        }
    }
    pspDebugScreenSetXY(x, y);
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenKprintf("%-10s", sLabel);

    x += 10;
    if (prApCfg != NULL) {
        prColor = appletconfig_get_panelcolor(prApCfg);
    } else {
        prColor = &prPanel->config.color;
    }
    if (row == 4) {
        if (col == 1) {
            if (prApCfg != NULL) {
                prColor = appletconfig_get_cursorcolor(prApCfg);
            } else {
                prColor = &prPanel->config.cursor;
            }
        }
    }
    pspDebugScreenSetXY(x, y);
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenKprintf("%-10s", "Reset");

    return SEARCHPANEL_SUCCESS;
}
Пример #22
0
int main_thread(SceSize args, void *argp) {
sceKernelDelayThread(3000000);
        u32 keycombination;
    SceCtrlData pad;
    u32 oldButtons = 0;
       int extra = 0;
         keycombination = PSP_CTRL_RTRIGGER; //Button to start interpreter (Basic)
         u32 keycombination2 = PSP_CTRL_RTRIGGER + PSP_CTRL_LTRIGGER; // Button to start interpreter (Extra PSP Go)
        while(1){
            oldButtons = pad.Buttons;
            if (go==0){
             sceCtrlPeekBufferPositive(&pad, 1);
                          if(oldButtons != pad.Buttons)
                          {
            if(pad.Buttons & keycombination2)
			{
			pauseGame(thid1);
                    go=1;
					extra=1;
                    pspDebugScreenInit();
                    pspDebugScreenClear();
                    oldButtons = pad.Buttons;
			}else if(pad.Buttons & keycombination)
            {
                	pauseGame(thid1);
                    go=1;
                    pspDebugScreenInit();
                    pspDebugScreenClear();
                    oldButtons = pad.Buttons;
            }
            }
            }
                if (go ==1){
    pspDebugScreenSetXY(0,0);
    pspDebugScreenSetTextColor(0xffffff);
       
        int go2=1;
        SceUID id;
        if (((kuKernelGetModel() + 1) == 4) || ((kuKernelGetModel() + 1) == 5)){
		if (extra==1){
		id = sceIoDopen("ms0:/seplugins/script"); //PSP Go MS Support
		}else{
        id = sceIoDopen("ef0:/seplugins/script"); //PSP Go Internal HD Support
		}
        }else{
        id = sceIoDopen("ms0:/seplugins/script");
        }
                                 SceIoDirent entry;
                                 int script_files = -2;
                                 memset(&entry, 0, sizeof(SceIoDirent));
                             while (sceIoDread(id, &entry) > 0)
                                {
                                        script_files = script_files+1;
                                        memset(&entry, 0, sizeof(SceIoDirent));
                                }
                                sceIoDclose(id);
                                char script[256];
                                if (((kuKernelGetModel() + 1) == 4) || ((kuKernelGetModel() + 1) == 5)){
								if (extra==1){
								strcpy(script,"ms0:/seplugins/script/index.lua"); //PSP Go MS Support
								}else{
                                strcpy(script,"ef0:/seplugins/script/index.lua"); //PSP Go Internal HD Support
                                }
								}else{
                                 strcpy(script,"ms0:/seplugins/script/index.lua");
                                 }
        while(go2==1)
        {
                                 
                                const char *errMsg;
                                if (script_files>1){            
                                errMsg = runScript(extralibs, true);
                                }else{
    SceUID fp = sceIoOpen(script, PSP_O_RDONLY,0777);  
    int size = sceIoLseek(fp, 0, SEEK_END);
    sceIoLseek(fp, 0, SEEK_SET);
    unsigned char *buffer;
    buffer = malloc((size+1) * sizeof (char));
    sceIoRead(fp, buffer, size);
        buffer[size]=0;
    sceIoClose(fp);
    errMsg = runScript(buffer, true);
    free(buffer);
    }
	// System.restart sourcecode
	if (strstr(errMsg, "lpp_restart")){
    go2=0;
	// End System.restart sources
    // Temp replacing for loadfile/dofile functions: System.protodofile
    }else if (strstr(errMsg, "lpp_open")){
    char dum1[20], dum2[20], dum3[20];
    char script_path2[256];
    sscanf( errMsg, "%s %s %s %s", dum1, dum2, dum3, script_path2 );
    strcpy(script,script_path2);
    script_files=1;
    // End System.protodofile sources
                                }else if (strstr(errMsg, "resumeThread")){
                                go=0;
                                go2=0;
                                }else{
                if (errMsg != NULL);
                {
                                                pspDebugScreenClear();
                                                pspDebugScreenSetTextColor(0xffffff);
                        debugOutput("\nError: %s\n", errMsg);
                }
                debugOutput("\nPress start to restart\nPress select to resume thread\n");
                SceCtrlData pad;
               
                                int restore = 0;
                while(restore==0){
                                sceCtrlPeekBufferPositive(&pad, 1);
                                if (pad.Buttons&PSP_CTRL_START){
                                restore=1;
                                go2=0;
                                }
                                if (pad.Buttons&PSP_CTRL_SELECT){
                                resumeGame(thid1);
                                restore=1;
                                go=0;
                                go2=0;
                                }
                                }
                                }
        }


}
sceDisplayWaitVblankStart();
        }
       
        sceKernelSleepThread();
return 0;
}
Пример #23
0
static int draw_status_panel(SearchPanel* prPanel) {
    SearchEngine* prEngine = NULL;
    AppletConfig* prApCfg = NULL;
    ColorConfig* prColor = NULL;
    char* sStatus = "Unknown Status";
    char sSmsg[60];
    int x = 0;
    int y = 0;
    ESearchState rEss;
    SceUInt32 pos = 0;
    SceUInt32 max = 0;
    SceUInt32 min = 0;
    SceUInt32 vpos = 0;
    int tdist = 0;
    int edist = 0;
    int cp = 0;

    if (prPanel == NULL) {
        return SEARCHPANEL_MEMORY;
    }
    prEngine = prPanel->prEngine;
    if (prEngine == NULL) {
        return SEARCHPANEL_MEMORY;
    }
    prApCfg = prPanel->prApCfg;
    x = prPanel->config.top.x;
    y = prPanel->config.status_line;
    rEss = prEngine->rState;
    switch (rEss) {
        case ESS_Fault:
            sStatus = "SearchEngine encountered fault.";
            break;
        case ESS_Stopped:
            sStatus = "SearchEngine not running.";
            break;
        case ESS_Idle:
            sStatus = "Idle.";
            break;
        case ESS_Searching:
            pos = searchengine_tell(prEngine);
            max = prEngine->rConfig.max_position;
            min = prEngine->rConfig.min_position;
            tdist = max - min;
            edist = pos - min;
            cp = ((edist / tdist) * 100);
            vpos = pos & ~0x40000000;
            sprintf(sSmsg, "Searching...0x%08X %d%%", vpos, cp);
            sStatus = sSmsg;
            break;
        case ESS_Finished:
            sStatus = "Search Finished.";
            break;
    }
    pspDebugScreenSetXY(x, y);
    if (prApCfg != NULL) {
        prColor = appletconfig_get_statuscolor(prApCfg);
    } else {
        prColor = &prPanel->config.status;
    }
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    pspDebugScreenKprintf("Status: %-59s", sStatus);

    return SEARCHPANEL_SUCCESS;
}
Пример #24
0
static int selectmedia()
{
    SceCtrlData pad;
    static int highlight = 0;
    int highlightold;
    int finished = 0;
    int count;
    int x, y;
    u32 buttonsold = 0;
    int basepos;

    if (forceskip != 0) {	// we are forcing a skip
	if (forceskip == 1) {	// previous tune
	    if (highlight != 0)
		highlight--;
	} else if (forceskip == 2) {	// next tune
	    if (highlight < (files_infonum - 1))
		highlight++;
	    else
		highlight = 0;	// move back to top of list
	}
	forceskip = 0;
	return highlight;
    }

    printf("Select media to play:\n\n");
    // Save screen position
    x = pspDebugScreenGetX();
    y = pspDebugScreenGetY();

    sceCtrlReadBufferPositive(&pad, 1);
    buttonsold = pad.Buttons;

    pspDebugScreenSetXY(0, 32);
    printf("Up/Down = Move cursor.  X = Select.  SELECT = Exit.\n");
#ifdef USB_ENABLED
    printf("SQUARE = Toggle USB.");
#endif

    highlightold = -1;
    while (finished == 0) {	// Draw the menu firstly
	sceDisplayWaitVblankStart();
	//  Show loop status
	pspDebugScreenSetXY(58, 1);
	if (loopmode == 0) {
	    printf(" LOOP  ");
	} else {
	    printf("ADVANCE");
	}
	if (highlightold != highlight) {
	    // Calc position in the list, given number of files and highlight position
	    if (highlight < 11)
		basepos = 0;
	    else		//  we must scroll
		basepos = highlight - 11;

	    pspDebugScreenSetXY(x, y);
	    for (count = basepos; count < basepos + 22; count++) {
		if (count >= files_infonum)
		    printf("\n");
		else {
		    if (highlight == count)
			printf("-> %02d - %-50s \n", count, files_info[count].filename);
		    else
			printf("   %02d - %-50s \n", count, files_info[count].filename);
		}
	    }
	}
	highlightold = highlight;
	// Now read the keys and act appropriately
	sceCtrlReadBufferPositive(&pad, 1);

	if (buttonsold != pad.Buttons) {
	    if (pad.Buttons & PSP_CTRL_RIGHT)
		if (highlight < (files_infonum - 11))
		    highlight += 10;
		else
		    highlight = files_infonum - 1;
	    if (pad.Buttons & PSP_CTRL_LEFT)
		if (highlight >= 10)
		    highlight -= 10;
		else
		    highlight = 0;
	    if (pad.Buttons & PSP_CTRL_UP)
		if (highlight >= 1)
		    highlight--;
	    if (pad.Buttons & PSP_CTRL_DOWN)
		if (highlight < (files_infonum - 1))
		    highlight++;
	    if (pad.Buttons & PSP_CTRL_TRIANGLE)
		loopmode = !loopmode;
#ifdef USB_ENABLED
	    if (pad.Buttons & PSP_CTRL_SQUARE)
		usb_toggle();
#endif
	    if (pad.Buttons & PSP_CTRL_CROSS)
		return highlight;
	    if (pad.Buttons & PSP_CTRL_SELECT)
		return -1;
	}
	buttonsold = pad.Buttons;
    }
}
Пример #25
0
static bool psp_frame(void *data, const void *frame,
      unsigned width, unsigned height, unsigned pitch, const char *msg)
{
   static char fps_txt[128], fps_text_buf[128];
   psp1_video_t *psp = (psp1_video_t*)data;

#ifdef DISPLAY_FPS
   static uint64_t currentTick,lastTick;
   static float fps=0.0;
   static int frames;
#endif

   if (!width || !height)
      return false;

   if (((uint32_t)frame&0x04000000) || (frame == RETRO_HW_FRAME_BUFFER_VALID))
      psp->hw_render = true;
   else if (frame)
      psp->hw_render = false;

   if (!psp->hw_render)
      sceGuSync(0, 0); /* let the core decide when to sync when HW_RENDER */

   pspDebugScreenSetBase(psp->draw_buffer);

   pspDebugScreenSetXY(0,0);

   video_monitor_get_fps(fps_txt, sizeof(fps_txt),
         g_settings.fps_show ? fps_text_buf : NULL,
         g_settings.fps_show ? sizeof(fps_text_buf) : 0);

   if(g_settings.fps_show)
   {
      pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
      pspDebugScreenPuts(fps_text_buf);
      pspDebugScreenSetXY(0,1);
   }

   if (msg)
      pspDebugScreenPuts(msg);

   if ((psp->vsync)&&(psp->vblank_not_reached))
      sceDisplayWaitVblankStart();

   psp->vblank_not_reached = true;

#ifdef DISPLAY_FPS
   frames++;
   sceRtcGetCurrentTick(&currentTick);
   uint32_t diff = currentTick - lastTick;
   if(diff > 1000000)
   {
      fps = (float)frames * 1000000.0 / diff;
      lastTick = currentTick;
      frames = 0;
   }

   pspDebugScreenSetXY(0,0);
   pspDebugScreenPrintf("%f", fps);
#endif

   psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
   g_extern.frame_count++;


   RARCH_PERFORMANCE_INIT(psp_frame_run);
   RARCH_PERFORMANCE_START(psp_frame_run);

   if (psp->should_resize)
      psp_update_viewport(psp);

   psp_set_tex_coords(psp->frame_coords, width, height);

   sceGuStart(GU_DIRECT, psp->main_dList);

   sceGuTexFilter(psp->tex_filter, psp->tex_filter);
   sceGuClear(GU_COLOR_BUFFER_BIT);

   /* frame in VRAM ? texture/palette was 
    * set in core so draw directly */
   if (psp->hw_render) 
      sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
            GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
            (void*)(psp->frame_coords));
   else
   {
      if (frame)
      {
         sceKernelDcacheWritebackRange(frame,pitch * height);
         sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2,
               0, width, height, pitch >> psp->bpp_log2,
               (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture);
      }
      sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture);
      sceGuCallList(psp->frame_dList);
   }

   sceGuFinish();

   RARCH_PERFORMANCE_STOP(psp_frame_run);

   if(psp->menu.active)
   {
      sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage));
      sceGuSync(0, 0);
   }

   return true;
}
Пример #26
0
int main() {
	pspDebugScreenInit();
	SetupCallbacks();

	// Colors
	enum colors {
		RED =	0xFF0000FF,
		GREEN =	0xFF00FF00,
		BLUE =	0xFFFF0000,
		WHITE =	0xFFFFFFFF,
		LITEGRAY = 0xFFBFBFBF,
		GRAY =  0xFF7F7F7F,
		DARKGRAY = 0xFF3F3F3F,		
		BLACK = 0xFF000000,
	};
    
    pspDebugScreenPrintf("intraFont 0.31 - 2009 by BenHur\n\nLoading fonts: 0%%");
        
    // Init intraFont library
    intraFontInit();
    
     // Load fonts
    intraFont* ltn[16];                                         //latin fonts (large/small, with/without serif, regular/italic/bold/italic&bold)
    char file[40];
    int i;
    for (i = 0; i < 16; i++) {
        sprintf(file, "flash0:/font/ltn%d.pgf", i); 
        ltn[i] = intraFontLoad(file,0);                                             //<- this is where the actual loading happens 
		intraFontSetStyle(ltn[i], 1.0f, WHITE, DARKGRAY, 0);
		pspDebugScreenSetXY(15,2);
        pspDebugScreenPrintf("%d%%",(i+1)*100/20);
    }

    intraFont* jpn0 = intraFontLoad("flash0:/font/jpn0.pgf",INTRAFONT_STRING_SJIS); //japanese font with SJIS text string encoding
	intraFontSetStyle(jpn0, 0.8f, WHITE, DARKGRAY, 0);                              //scale to 80%
    pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("%d%%",17*100/20);
        
	intraFont* kr0 = intraFontLoad("flash0:/font/kr0.pgf", INTRAFONT_STRING_UTF8);  //Korean font (not available on all systems) with UTF-8 encoding
	intraFontSetStyle(kr0, 0.8f, WHITE, DARKGRAY, 0);                               //scale to 80%
	pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("%d%%",18*100/20);
           
	intraFont* arib = intraFontLoad("flash0:/font/arib.pgf",0);                     //Symbols (not available on all systems)
	intraFontSetStyle(arib, 0.8f, WHITE, DARKGRAY, 0);                              //scale to 80%
	pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("%d%%",19*100/20);

	intraFont* chn = intraFontLoad("flash0:/font/gb3s1518.bwfon", 0);               //chinese font
	intraFontSetStyle(chn, 0.8f, WHITE, DARKGRAY, 0);                               //scale to 80%
	pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("done\n");

	// Make sure the important fonts for this application are loaded
	if(!ltn[0] || !ltn[4] || !ltn[8]) sceKernelExitGame();

	// Set alternative fonts that are used in case a certain char does not exist in the main font
	intraFontSetAltFont(ltn[8], jpn0);                     //japanese font is used for chars that don't exist in latin
	intraFontSetAltFont(jpn0, chn);                        //chinese font (bwfon) is used for chars that don't exist in japanese (and latin)
	intraFontSetAltFont(chn, kr0);                         //korean font is used for chars that don't exist in chinese (and jap and ltn)
	intraFontSetAltFont(kr0, arib);                        //symbol font is used for chars that don't exist in korean (and chn, jap & ltn)
	// NB: This is an extreme case - usually you need only one alternative font (e.g. japanese & chinese)
	// Also: if one of the fonts failed to load (e.g. chn) the chain breaks and all subequent fonts are not used (e.g. kr0 and arib)
	
	initGraphics();
	float x_scroll1 = 80, x_scroll2 = 225, x_scroll3 = 370,  x_scroll4 = 385;

	while(running)	{
		clearScreen(GRAY);

		// Must be called before any of the intraFont functions
		guStart();

		// Draw various text
        float x,y = 20;
		intraFontSetStyle(ltn[4], 1.0f,BLACK,WHITE,INTRAFONT_ALIGN_CENTER);
		intraFontPrint(ltn[4], 240, y, "intraFont 0.31 - 2009 by BenHur");
        intraFontSetStyle(ltn[4], 1.0f,WHITE,DARKGRAY,0);
		        
		y += 21;
		intraFontPrint(ltn[8],  10, y, "Latin Sans-Serif:");
		intraFontPrint(ltn[0], 180, y, "regular,");
        intraFontPrint(ltn[2], 270, y, "italic,");
        intraFontPrint(ltn[4], 330, y, "bold,");
        intraFontPrint(ltn[6], 390, y, "both");
        
        y += 17;
        intraFontPrint(ltn[8],  10, y, "Latin Sans-Serif small:");
		intraFontPrint(ltn[8], 180, y, "regular,");
        intraFontPrint(ltn[10], 270, y, "italic,");
        intraFontPrint(ltn[12], 330, y, "bold,");
        intraFontPrint(ltn[14], 390, y, "both");
        
        y += 17;
        intraFontPrint(ltn[8],  10, y, "Latin with Serif:");
		intraFontPrint(ltn[1], 180, y, "regular,");
        intraFontPrint(ltn[3], 270, y, "italic,");
        intraFontPrint(ltn[5], 330, y, "bold,");
        intraFontPrint(ltn[7], 390, y, "both");
        
        y += 17;
        intraFontPrint(ltn[8],  10, y, "Latin with Serif small:");
		intraFontPrint(ltn[9], 180, y, "regular,");
        intraFontPrint(ltn[11], 270, y, "italic,");
        intraFontPrint(ltn[13], 330, y, "bold,");
        intraFontPrint(ltn[15], 390, y, "both");
		
        y += 17;
		intraFontSetEncoding(ltn[8], INTRAFONT_STRING_UTF8);   //set text string encoding to UTF-8
		intraFontPrint(ltn[8], 10, y, "LTN (UTF8):");          //(has no effect on std ascii)
		intraFontPrint(ltn[8], 110, y, "\xC3\xA5 \xC3\xA8 \xC3\xAD \xC3\xB4 \xC3\xBC \xC3\xB1"); //UTF-8 encoded chars with accents on top of them
		
		intraFontPrint(ltn[8], 250, y, "Symbols: ");
        unsigned short ucs2_arib[] = { 57786, 57787, 57788, 57789, 57790, 0 };
        x = intraFontPrintUCS2(arib, 350, y, ucs2_arib);
		if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]");

		y += 17;
        intraFontPrint(ltn[8], 10, y, "JPN (UTF8):");
        char utf8_jpn[] = {0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0xAB, 0xE3, 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0x20, 0xE4, 0xB8, 0x96, 0xE7, 0x95, 0x8C, 0};
		intraFontSetEncoding(jpn0, INTRAFONT_STRING_UTF8);     //temporarely switch to UTF-8 (INTRAFONT_STRING_SJIS was set in intraFontLoad call)
        x = intraFontPrint(jpn0, 110, y, utf8_jpn);            //print UTF-8 encoded string
		if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]");
		intraFontSetEncoding(jpn0, INTRAFONT_STRING_SJIS);     //switch back to S-JIS
        
		intraFontPrint(ltn[8], 250, y, "JPN (S-JIS):");
        x = intraFontPrint(jpn0, 350, y, "イントラフォント");  //S-JIS encoded text string (flag INTRAFONT_STRING_SJIS set in intraFontLoad call)
		if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]");

		y += 17;
		intraFontPrint(ltn[8], 10, y, "CHN (GBK):");
        char gbk_chn[] = { 0xbc,0xf2, 0xcc,0xe5, 0xd6,0xd0, 0xce,0xc4, 0};
        intraFontSetEncoding(chn, INTRAFONT_STRING_GBK);
        x = intraFontPrint(chn, 110, y, gbk_chn);              //print GBK-encoded string (simplified chinese)
		if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]");
        intraFontPrint(ltn[8], 250, y, "CHN (BIG5):");
        char big5_chn[] = { 0xc1,0x63, 0xc5,0xe9, 0xa4,0xa4, 0xa4,0xe5, 0};
        intraFontSetEncoding(chn, INTRAFONT_STRING_BIG5);
        x = intraFontPrint(chn, 350, y, big5_chn);             //print BIG5-encoded string (trad. chinese)
		if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]");

		y += 17;   
		intraFontPrint(ltn[8], 10, y, "KOR (UTF8):");
		char utf8_kr[] = {0xed, 0x99, 0x98, 0xec, 0x98, 0x81, 0x20, 0xeb, 0x8c, 0x80, 0xed, 0x95, 0x9c, 0xeb, 0xaf, 0xbc, 0xea, 0xb5, 0xad, 0};
        x = intraFontPrint(kr0, 110, y, utf8_kr);              //print UTF-8 string (flag INTRAFONT_STRING_UTF8 set in intraFontLoad call)
		if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]");

		intraFontPrint(ltn[8], 250, y, "MIX (UCS2):");
		unsigned short ucs2_all[] = { 0x0041, 0x0192, 0x3401, 0x3402, 0x4E01, 0x4E02, 0xAC01, 0xAC02, 0xE1BE, 0};
        x = intraFontPrintUCS2(ltn[8], 350, y, ucs2_all);      //print chars from all fonts (using alternative fonts, which were set after font loading)
		

        y += 17;
		intraFontPrint(ltn[8], 10, y, "Colors: ");
        intraFontSetStyle(ltn[8], 1.0f,RED,BLUE,0);
		x = intraFontPrint(ltn[8], 80, y, "colorful, ");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,0,0);
        x = intraFontPrint(ltn[8], x, y, "no shadow, ");
        intraFontSetStyle(ltn[8], 1.0f,0,DARKGRAY,0);
        x = intraFontPrint(ltn[8], x, y, "no text, ");
        intraFontSetStyle(ltn[8], 1.0f,0x7FFFFFFF,DARKGRAY,0);
        x = intraFontPrint(ltn[8], x, y, "transparent, ");		
        intraFontSetStyle(ltn[8], 1.0f,GRAY,WHITE,0);
        x = intraFontPrint(ltn[8], x, y, "glowing, ");
		float t = ((float)(clock() % CLOCKS_PER_SEC)) / ((float)CLOCKS_PER_SEC);
		int val = (t < 0.5f) ? t*511 : (1.0f-t)*511;
		intraFontSetStyle(ltn[8], 1.0f,LITEGRAY,(0xFF<<24)+(val<<16)+(val<<8)+(val),0);
		x = intraFontPrint(ltn[8], x, y, "flashing");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);
        
        y += 17;
        intraFontPrint(ltn[8], 10, y, "Spacing: ");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_WIDTH_FIX);
		x = intraFontPrint(ltn[8], 80, y, "fixed (default), ");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_WIDTH_FIX | 12);
        x = intraFontPrint(ltn[8], x, y, "fixed (12), ");		
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);
        x = intraFontPrint(ltn[8], x, y, "variable width");
        
        y += 22;
        intraFontPrint(ltn[8], 10, y, "Scaling: ");
		intraFontSetStyle(ltn[0], 0.5f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], 80, y, "tiny, ");
        intraFontSetStyle(ltn[0], 0.75f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "small, ");
        intraFontSetStyle(ltn[0], 1.0f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "regular, ");
        intraFontSetStyle(ltn[0], 1.25f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "large, ");
        intraFontSetStyle(ltn[0], 1.5f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "huge"); 
		intraFontSetStyle(ltn[0], 1.0f,WHITE,DARKGRAY,0);
		
        y += 17;
        intraFontPrint(ltn[8], 10, y, "Align: ");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_LEFT);
		t = ((float)(clock() % (CLOCKS_PER_SEC*10))) / ((float)CLOCKS_PER_SEC);
		int length = (t < 5.0f) ? t*5.8f : (10.0f-t)*5.8f;
		intraFontPrintColumnEx(ltn[8],  80, y,  90, "left aligned w. linebreaks  ", length);
		//NB: intraFontPrintColumnEx() is used to print a sub-string of a given length (last parameter)
		//    if you want to print the whole string, simply use intraFontPrintColumn() and omit the length parameter
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_CENTER);
		intraFontPrintColumnEx(ltn[8], 225, y, 110, "center aligned w. linebreaks", length);
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_RIGHT);
        intraFontPrintColumnEx(ltn[8], 370, y,  90, "right aligned w. linebreaks ", length);
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_FULL);
        intraFontPrintColumnEx(ltn[8], 380, y,  90, "full justified w. linebreaks", length);
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);

		y += 28;
        intraFontPrint(ltn[8], 10, y, "Scrolling: ");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_LEFT);
		x_scroll1 = intraFontPrintColumn(ltn[8], x_scroll1, y, 80, "This text is scrolled to the left.");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_SEESAW);
        x_scroll2 = intraFontPrintColumn(ltn[8], x_scroll2, y, 90, "Back & forth like a seesaw.");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_RIGHT);
		x_scroll3 = intraFontPrintColumn(ltn[8], x_scroll3, y, 80, "Scrolling to the right...");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_THROUGH);
        x_scroll4 = intraFontPrintColumn(ltn[8], x_scroll4, y, 80, "This text is scrolled through.");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);

		// End drawing
		sceGuFinish();
		sceGuSync(0,0);
		
		// Swap buffers (waiting for vsync)
		sceDisplayWaitVblankStart();
		flipScreen();
	}
    
    //create screenshot (optional)
    //saveImage("scrshot.png", getVramDisplayBuffer(), SCREEN_WIDTH, SCREEN_HEIGHT, PSP_LINE_SIZE, 0);

	// Unload our fonts
    for (i = 0; i < 16; i++) {
        intraFontUnload(ltn[i]);
    }
    intraFontUnload(jpn0);
	intraFontUnload(kr0);
    intraFontUnload(arib);
	intraFontUnload(chn);
	
	// Shutdown font library
	intraFontShutdown();

	sceKernelExitGame();

	return 0;
}