void drawScene() { /* tiny3d_Project3D(); tiny3d_SetProjectionMatrix(NULL); DrawBackground3D(0xffff00ff) ; // yellow */ tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates) // fix Perspective Projection Matrix DrawBackground2D(0x0040ffff) ; // light blue SetFontSize(16, 24); SetFontColor(0xffffffff, 0x0); SetFontAutoCenter(1); DrawString(0, (512 - 24)/2 - 64, "Use LEFT/RIGHT/UP/DOWN to adjust the screen"); DrawFormatString(0, (512 - 24)/2, "Video Scale X: %i Y: %i", videoscale_x, videoscale_y); DrawString(0, (512 - 24)/2 + 64, "Press 'X' to exit"); SetFontAutoCenter(0); }
/* * User Cheats Game Selection Menu */ void Draw_UserCheatsMenu_Ani() { int c = 0, w = 0, h = 0; int div = 12, max = MENU_ANI_MAX, ani = 0; for (ani = 0; ani < max; ani++) { tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); tiny3d_AlphaTest(1, 0x0, TINY3D_ALPHA_FUNC_GEQUAL); tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 0x00000303 | 0x00000000, TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); tiny3d_Project2D(); u8 icon_a = (u8)(((ani * 2) > 0xFF) ? 0xFF : (ani * 2)); DrawHeader_Ani(menu_textures[header_ico_cht_png_index], "Cheats", "User List", 0x00000000, 0xffffffff, ani, div); int _game_a = (int)(icon_a - (max / 2)) * 2; if (_game_a > 0xFF) _game_a = 0xFF; u8 game_a = (u8)(_game_a < 0 ? 0 : _game_a); DrawGameList(menu_old_sel[1], user_game_list, user_game_count, game_a); tiny3d_Flip(); if (_game_a == 0xFF) return; } }
void drawScene() { float x, y; tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates) DrawBackground2D(0x0040ffff) ; // light blue SetFontSize(12, 24); x= 0.0; y = 0.0; SetCurrentFont(1); SetFontColor(0xffffffff, 0x0); x = DrawString(x,y, "Hello World!. My nick is "); SetFontColor(0x00ff00ff, 0x0); SetCurrentFont(0); x = DrawString(x,y, "Hermes "); SetCurrentFont(1); SetFontColor(0xffffffff, 0x0); x = DrawString(x,y, "and this is one sample working with\nfonts."); SetCurrentFont(2); x= 0; y += 64; SetCurrentFont(1); DrawString(x, y, "I am using 3 fonts:"); SetCurrentFont(0); y += 64; SetFontColor(0xffffffff, 0x00a000ff); DrawString(x, y, "Font 0 is one array of 224 chars 16 x 32 pix and 2 bit depth"); SetCurrentFont(1); y += 64; SetFontColor(0xffffffff, 0xa00000ff); DrawString(x, y, "Font 1 is one array of 224 chars 16 x 32 pix and 2 bit depth"); SetCurrentFont(2); y += 64; SetFontColor(0x000000ff, 0xffff00ff); DrawString(x, y, "Font 2 is one array of 255 chars 8 x 8 pix and 1 bit depth"); y += 64; SetCurrentFont(1); SetFontSize(32, 64); SetFontColor(0xffffffff, 0x000000ff); SetFontAutoCenter(1); DrawString(0, y, "You can resize letters"); SetFontAutoCenter(0); SetFontSize(12, 24); SetFontColor(0xffffffff, 0x00000000); y += 72; DrawString(0, y, "change the color, background color and center the text\nwith SetFontAutoCenter()"); y += 72; SetFontColor(0x00ff00ff, 0x00000000); DrawFormatString(0, y, "Here %s font 0 uses %i bytes as texture", "using DrawFormatString()", 224*(16*2/8)*32); }
void tiny3d_Dirty_Status() { tiny3d_Disable_YUV(); n_vertex = 0; polygon = -1; flag_vertex = (flag_vertex & VERTEX_MASK) | VERTEX_LOCK; tiny3d_Project2D(); }
void tiny3d_ClearSurface(u32 color, clear_flags flags, u32 rsx_offset, u32 width, u32 height, u32 stride, u32 format) { flag_vertex |= VERTEX_LOCK; render_target.target = 1; render_target.w = width; render_target.p = stride; render_target.h = height; if(flags & TINY3D_CLEAR_COLOR) { tiny3d_Project2D(); tiny3d_SetProjectionMatrix(&matrix_ident); tiny3d_SetMatrixModelView(&matrix_ident); internal_reality_ZControl(context, 0, 1, 1); // disable viewport culling internal_reality_DepthTestFunc(context, REALITY_ZFUNC_LESSOREQUAL); internal_reality_DepthWriteEnable(context, 1); internal_reality_DepthTestEnable(context, 1); internal_reality_AlphaEnable(context, 0); internal_reality_BlendEnable(context, 0); internal_reality_Viewport(context, width, height); int n; for(n = 0; n < 8; n++) internal_reality_ViewportClip(context, n, width, height); setupRenderTarget2(rsx_offset, stride, width, height, format); rsxSetClearColor(context, color); } if(flags & TINY3D_CLEAR_ZBUFFER) { rsxSetClearDepthValue(context, 0xffffffff); } internal_reality_ClearBuffers(context, flags); }
void Draw_CheatsMenu_Options_Ani_Exit(void) { int c = 0, w = 0, h = 0; int div = 12, max = MENU_ANI_MAX, ani = 0, left = MENU_SPLIT_OFF; for (ani = max - 1; ani >= 0; ani--) { tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); tiny3d_AlphaTest(1, 0x0, TINY3D_ALPHA_FUNC_GEQUAL); tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 0x00000303 | 0x00000000, TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); tiny3d_Project2D(); u8 icon_a = (u8)((int)(((848 - left) / 848.0) * 255.0)); left = MENU_SPLIT_OFF + ((max - ani) * div * 3); if (left > 848) left = 848; u8 rgbVal = 0xFF; rgbVal -= (u8)((848 - left) / div); if (rgbVal < 0xD0) rgbVal = 0xD0; Draw_CheatsMenu_Selection(menu_old_sel[5], (rgbVal << 24) | (rgbVal << 16) | (rgbVal << 8) | 0xFF); DrawTexture(menu_textures[edit_shadow_png_index], left - (menu_textures[edit_shadow_png_index].texture.width * 1) + 1, -marginVertical, 0, menu_textures[edit_shadow_png_index].texture.width, 512 + (marginVertical * 2), icon_a); DrawHeader(menu_textures[header_ico_opt_png_index], left, "Cheat Option", selected_centry.name, 0x00000000 | icon_a, 0xffffffff, 1); int _game_a = (int)(icon_a - (max / 2)) * 2; if (_game_a > 0xFF) _game_a = 0xFF; u8 game_a = (u8)(_game_a < 0 ? 0 : _game_a); //DrawOptions(selected_centry.options[option_index], game_a, 18, menu_old_sel[7]); //DrawScrollBar2(menu_old_sel[7], selected_centry.options[option_index].size, 18, 700, game_a); tiny3d_Flip(); if (left == 848) return; } }
void Draw_CheatsMenu_View_Ani(void) { int c = 0, w = 0, h = 0; int div = 12, max = MENU_ANI_MAX, ani = 0, left = MENU_SPLIT_OFF; for (ani = 0; ani < max; ani++) { tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); tiny3d_AlphaTest(1, 0x0, TINY3D_ALPHA_FUNC_GEQUAL); tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 0x00000303 | 0x00000000, TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); tiny3d_Project2D(); u8 icon_a = (u8)(((ani * 4 + 0x40) > 0xFF) ? 0xFF : (ani * 4 + 0x40)); left = 848 - (ani * div * 3); if (left < MENU_SPLIT_OFF) left = MENU_SPLIT_OFF; u8 rgbVal = 0xFF; rgbVal -= (u8)((848 - left) / div); if (rgbVal < 0xD0) rgbVal = 0xD0; Draw_CheatsMenu_Selection(menu_sel, (rgbVal << 24) | (rgbVal << 16) | (rgbVal << 8) | 0xFF); DrawTexture(menu_textures[edit_shadow_png_index], left - (menu_textures[edit_shadow_png_index].texture.width * 1) + 1, -marginVertical, 0, menu_textures[edit_shadow_png_index].texture.width, 512 + (marginVertical * 2), icon_a); DrawHeader(menu_textures[header_ico_opt_png_index], left, "Cheat View", selected_centry.name, 0x00000000 | icon_a, 0xffffffff, 1); u8 game_a = (u8)(icon_a < 0x8F ? 0 : icon_a); int nlines = DrawCodes(selected_centry, game_a, 20, left, menu_old_sel[6]); DrawScrollBar(menu_old_sel[6], nlines, 20, 800, game_a); tiny3d_Flip(); if ((848 - (ani * div * 3)) < (MENU_SPLIT_OFF / 2)) return; } }
void drawScene(int frame) { int type = 0; tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates) if(!((frame/300) & 1)) { // enable YUV tiny3d_Enable_YUV(USE_AYUV_32BITS_TEXTURE); // set AYUV 32 bits texture tiny3d_SetTextureWrap(0, texture[0].offset, texture[0].w, texture[0].h, texture[0].stride, TINY3D_TEX_FORMAT_A8R8G8B8, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); type = 0; } else { tiny3d_Enable_YUV(USE_YUV_8BIT_TEXTURES); // set Y 8 bit texture tiny3d_SetTextureWrap(0, texture[1].offset, texture[1].w, texture[1].h, texture[1].stride, TINY3D_TEX_FORMAT_L8, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); // set U 8 bit texture tiny3d_SetTextureWrap(1, texture[2].offset, texture[2].w, texture[2].h, texture[2].stride, TINY3D_TEX_FORMAT_L8, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); // set V 8 bit texture tiny3d_SetTextureWrap(2, texture[3].offset, texture[3].w, texture[3].h, texture[3].stride, TINY3D_TEX_FORMAT_L8, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); type = 1; } // draw YUV image // r g b a result = (color + a) * (r, g, b) DrawColorSquare(0, 0, 0, 847.0, 511.0, 1.0, 1.0, 1.0, 0.0); tiny3d_Disable_YUV(); SetFontSize(16, 32); SetFontColor(0x0040ffff, 0x0); if(!type) { DrawString(16, 16, "Drawing AYUV 32bits, surface A8R8G8B8"); DrawFormatString(16, 16 + 48, "AYUV (%i x %i x 4)", texture[0].w, texture[0].h); } else { DrawString(16, 16, "Drawing Y,U,V 8 bits, 3 surfaces L8"); DrawFormatString(16, 16 + 48, "Y (%i x %i), U (%i x %i), V (%i x %i)", texture[1].w, texture[1].h, texture[2].w, texture[2].h, texture[3].w, texture[3].h); } }
s32 main(s32 argc, const char* argv[]) { int count = 0; int n; padInfo padinfo; padData paddata; char *cur_device = "/ntfs0:"; char path[1024]; // map file functions to libc open, fopen, ... NTFS_init_system_io(); tiny3d_Init(1024*1024); tiny3d_Project2D(); u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) u32 * texture_pointer; // use to asign texture space without changes texture_mem if(!texture_mem) return 0; // fail! texture_pointer = texture_mem; ResetFont(); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); initConsole(); ioPadInit(7); DbgHeader("NTFS EXT2/3/4 Example"); /* // Mount all NTFS volumes on all inserted block devices mountCount = ntfsMountAll(&mounts, NTFS_DEFAULT | NTFS_RECOVER); // mountCount = ntfsMountDevice (&__io_ntfs_usb000, &mounts, NTFS_DEFAULT | NTFS_RECOVER); if (mountCount == -1) DPrintf("Error whilst mounting devices (%i).\n", errno); else if (mountCount == 0) DPrintf("No NTFS volumes were found and/or mounted.\n"); else DPrintf("%i NTFS volumes(s) mounted!\n\n", mountCount); */ int i; count = 1; while(1) { if(count > 0) { count--; if(count == 0) { int k; initConsole(); for(k = 0; k < 8; k++) { for (i = 0; i < mountCount[k]; i++) DPrintf("%i - %s:/ (%s) (from usb00%i)\n", i + 1, (mounts[k]+i)->name, ntfsGetVolumeName((mounts[k] + i)->name), ((mounts[k] + i)->interface->ioType & 0xff) - '0'); } int r; cur_device = NULL; r = NTFS_Test_Device("ext0"); DPrintf("\nTest ext0 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext0:"; r = NTFS_Test_Device("ext1"); DPrintf("Test ext1 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext1:"; r = NTFS_Test_Device("ext2"); DPrintf("Test ext2 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext2:"; r = NTFS_Test_Device("ext3"); DPrintf("Test ext3 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ext3:"; r = NTFS_Test_Device("ntfs0"); DPrintf("Test ntfs0 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs0:"; r = NTFS_Test_Device("ntfs1"); DPrintf("Test ntfs1 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs1:"; r = NTFS_Test_Device("ntfs2"); DPrintf("Test ntfs2 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs2:"; r = NTFS_Test_Device("ntfs3"); DPrintf("Test ntfs3 %i\n" , r); if(r>=0 && !cur_device) cur_device = "/ntfs3:"; if(!cur_device) cur_device = "/ntfs0:"; // by default } } DbgHeader("NTFS EXT2/3/4 Example"); DbgMess("Press X to list device, O to test file and /\\ to exit"); for(i = 0; i < 8 ; i++) { int r = NTFS_Event_Mount(i); if(r == 1) { // mount device NTFS_UnMount(i); mounts[i] = NULL; mountCount[i] = 0; mountCount[i] = ntfsMountDevice (disc_ntfs[i], &mounts[i], NTFS_DEFAULT | NTFS_RECOVER); if(mountCount[i]>0) {count = 1;} // update counter } else if(r == -1) { // unmount device NTFS_UnMount(i); count = 1; } } // DbgMess(); DbgDraw(); tiny3d_Flip(); ioPadGetInfo(&padinfo); for(n = 0; n < MAX_PADS; n++) { static u32 btn_flags = 0; if(padinfo.status[n]) { ioPadGetData(n, &paddata); if(paddata.BTN_CROSS) { if((btn_flags & 1)==0){ btn_flags|=1; max_list = 0; initConsole(); count = 300; DPrintf("Listing 10 entries from %s (5 seconds)\n", cur_device); sprintf(path, "%s", cur_device); list(path, 0); } } else btn_flags&=~1; if(paddata.BTN_CIRCLE) { if((btn_flags & 2)==0){ btn_flags|=2; DPrintf("\n\nWriting / Reading a file from %s\n", cur_device); sprintf(path, "%s/0text", cur_device); mkdir(path, 0777); sprintf(path, "%s/0text/test.txt", cur_device); FILE *fp; fp =fopen(path, "wb"); if(fp) { int i; i = fwrite(message, 1, strlen(message), fp); if(i != strlen(message)) DPrintf("Error writing the file!\n"); fclose(fp); } else DPrintf("Error creating the file!\n"); memset(buffer, 0, 1024); sprintf(path, "%s/0text/test.txt", cur_device); fp = fopen(path, "rb"); if(fp) { int i; // NOTE: for files > 2GB you can use 64 bit method #ifdef USE_64BIT_SEEK struct _reent reent1; DPrintf ("Using _lseek64_r for large files\n"); s64 size = _lseek64_r(&reent1, fp->_file, 0, SEEK_END); _lseek64_r(&reent1, fp->_file, 0, SEEK_SET); DPrintf ("Size of file %i bytes\n", (int) size); #else fseek(fp, 0, SEEK_END); int size = ftell(fp); DPrintf ("Size of file %i bytes\n", size); fseek(fp, 0, SEEK_SET); #endif i = fread(buffer, 1, size, fp); if(i != size) DPrintf("Error reading the file %i!\n", i); fclose(fp); } else DPrintf("Error Reading the file!\n"); DPrintf("Readed From file: %s\n\n", buffer); } } else btn_flags&=~2; if(paddata.BTN_TRIANGLE){ goto out; } } } } out:; DPrintf("Umounting\n"); DbgDraw(); tiny3d_Flip(); NTFS_UnMountAll(); return 0; }
void BoxBrowser::Draw() { if( !visible ) return; if( needToUpdateBoxes ) { needToUpdateBoxes = false; viewMode = viewFlow; Shift( 0 ); } if( viewMode == viewFlow ) { //draw text and any other 2D elements ( and leave it in 2D for the rest of the gui ) gameText->Draw(); //change to 3D context to draw boxes tiny3d_Project3D(); //draw the surface DrawSurface(); //update camera motion UpdateCamera(); for( int i = 0; i < NUM_BOXES; i++ ) { int mtxIdx = ( ( i * ANIMATION_FRAMES ) + animFrame ); if( mtxIdx >= (int)mtxBox.size() || mtxIdx < 0 ) { continue; } tiny3d_SetMatrixModelView( &mtxBox[ mtxIdx ] ); box[ i ]->DrawNoMtx(); } UpdateAnimation(); } else if( viewMode == viewZoom ) { //draw text and any other 2D elements ( and leave it in 2D for the rest of the gui ) if( bgImg2 ) { bgImg2->Draw(); } if( bgImg1 ) { //make sure this image is positioned correctly if( !bgLoaded && bgImg1->IsLoaded() ) { bgLoaded = true; //this image should either be 1000px wide or 1920 if( bgImg1->GetWidth() <= 1000 ) bgImg1->SetPosition( 124, 69, 0xfff0 );//these values seem to work for all my guitar hero & rockband games else bgImg1->SetPosition( 0, 0, 0xfff0 );//i dont have any games that fit this category, but i assume this is right } bgImg1->Draw(); } //change to 3D tiny3d_Project3D(); //update camera motion UpdateCamera(); //set matrix for zoomed box SetZoomMatrix(); //the center box hopefully is the selected one box[ NUM_BOXES / 2 ]->DrawNoMtx(); } //done in 3D mode, switch to 2D tiny3d_SetMatrixModelView( NULL ); // set matrix identity tiny3d_Project2D(); busy = false; inputIdx = 0; }
void tiny3d_Clear(u32 color, clear_flags flags) { flag_vertex |= VERTEX_LOCK; render_target.target = 0; if(flags & TINY3D_CLEAR_COLOR) { tiny3d_Project2D(); tiny3d_SetProjectionMatrix(&matrix_ident); tiny3d_SetMatrixModelView(&matrix_ident); internal_reality_ZControl(context, 0, 1, 1); // disable viewport culling internal_reality_DepthTestFunc(context, REALITY_ZFUNC_LESSOREQUAL); internal_reality_DepthWriteEnable(context, 1); internal_reality_DepthTestEnable(context, 1); internal_reality_AlphaEnable(context, 0); internal_reality_BlendEnable(context, 0); internal_reality_Viewport(context, Video_Resolution.width, Video_Resolution.height); int n; for(n = 0; n < 8; n++) { internal_reality_ViewportClip(context, n, Video_Resolution.width, Video_Resolution.height); } setupRenderTarget(Video_currentBuffer); rsxSetClearColor(context, color); } if(flags & TINY3D_CLEAR_ZBUFFER) { rsxSetClearDepthValue(context, 0xffffffff); } internal_reality_ClearBuffers(context, flags); if((flags & TINY3D_CLEAR_COLOR) && tiny_3d_alarm) { tiny3d_SetPolygon(TINY3D_QUADS); tiny3d_VertexPos(848/2 , 0 , 65535); tiny3d_VertexColor(0xff0000ff); tiny3d_VertexPos(847, 0 , 65535); tiny3d_VertexPos(847, 511, 65535); tiny3d_VertexPos(848/2 , 511, 65535); tiny3d_End(); internal_reality_Viewport(context, Video_Resolution.width*15/16, Video_Resolution.height); int n; for(n = 0; n < 8; n++) internal_reality_ViewportClip(context, n, Video_Resolution.width*15/16, Video_Resolution.height); internal_reality_ClearBuffers(context, flags); } }
void drawScene() { int i; static int count_frames =0; static float rotZ = 0.0f; static int rotar =0; if(!rotar && (rand() & 255)==1) rotar = 180; rotZ += 0.1f; tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates) // fix Perspective Projection Matrix DrawBackground2D(0x0040ffff) ; // light blue count_frames++; for(i = 0; i < 4; i++) { int cur_text = ghost[i].frame; // get current texture index for frame // Load sprite texture tiny3d_SetTexture(0, texture_ghost_offset[cur_text], texture_ghost[cur_text].width, texture_ghost[cur_text].height, texture_ghost[cur_text].wpitch, TINY3D_TEX_FORMAT_A8R8G8B8, 1); if(!rotar) { // draw sprite DrawSprites2D(ghost[i].x, ghost[i].y, (float) i, 64, 64, ghost[i].color); } else { // draw with rotation DrawSpritesRot2D(ghost[i].x, ghost[i].y, (float) i, 64, 64, ghost[i].color, rotZ); } // update frame if(count_frames>8) { ghost[i].frame = ((ghost[i].frame + 1) & 3) | (ghost[i].frame & 4); } // update position ghost[i].x += ghost[i].dx; ghost[i].y += ghost[i].dy; // test the limits if(ghost[i].x <= 0.0f || ghost[i].x >= (847.0f - 64.0f)) { ghost[i].x = (ghost[i].x <= 0.0f) ? 0 : (847.0f - 64.0f); ghost[i].dx = -ghost[i].dx; } if(ghost[i].y <= 0.0f || ghost[i].y >= (511.0f - 64.0f)) { ghost[i].y = (ghost[i].y <= 0.0f) ? 0 : (511.0f - 64.0f); ghost[i].dy = -ghost[i].dy; } // change frames to left - right if(ghost[i].dx >= 0.0f) ghost[i].frame |= 4; else ghost[i].frame &= ~4; } if(rotar) rotar--; else rotZ = 0.0f; if(count_frames > 8) count_frames = 0; }