void LoadTexture() { u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) if(!texture_mem) return; // fail! texture_pointer = texture_mem; ResetFont(); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); // here you can add more textures using 'texture_pointer'. It is returned aligned to 16 bytes jpg1.jpg_in= (void *) psl1ght_jpg_bin; jpg1.jpg_size= sizeof(psl1ght_jpg_bin); LoadJPG(&jpg1, NULL); jpg1_offset = 0; if(jpg1.bmp_out) { memcpy(texture_pointer, jpg1.bmp_out, jpg1.wpitch * jpg1.height); free(jpg1.bmp_out); jpg1.bmp_out= texture_pointer; texture_pointer += (jpg1.wpitch/4 * jpg1.height + 3) & ~3; // aligned to 16 bytes (it is u32) and update the pointer jpg1_offset = tiny3d_TextureOffset(jpg1.bmp_out); // get the offset (RSX use offset instead address) } }
bool Init( u32 size ) { //printf("RsxMem::Init( %08x )\n", size ); //make sure we're not already inited if( memSize ) { printf("RsxMem::Init( %08x ) failed: init is already called\n", size ); return false; } //create mutex mutex_init( &rsxMutex ); //try to grab the big chunk of memory memStart = (u32*)tiny3d_AllocTexture( size ); if( !memStart ) { printf("RsxMem::Init( %08x ) failed to allocate memory\n", size ); return false; } //set variables memSize = size; //memset( (void*)&ptr, 0, sizeof( MemItr ) * RSX_MEM_MAX_TEXTURES ); //printf("memSize: %08x\nmemStart: %p\n", memSize, memStart ); return true; }
void LoadTexture() { int i; 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; // fail! texture_pointer = texture_mem; Load_PNG(); // copy texture datas from PNG to the RSX memory allocated for textures for(i = 0; i < 8; i++) { texture_ghost_offset[i] = 0; if(texture_ghost[i].bmp_out) { memcpy(texture_pointer, texture_ghost[i].bmp_out, texture_ghost[i].wpitch * texture_ghost[i].height); free(texture_ghost[i].bmp_out); texture_ghost[i].bmp_out= texture_pointer; texture_pointer += (texture_ghost[i].wpitch * texture_ghost[i].height + 3) & ~3; // aligned to 16 bytes (it is u32) and update the pointer texture_ghost_offset[i] = tiny3d_TextureOffset(texture_ghost[i].bmp_out); // get the offset (RSX use offset instead address) } } }
void LoadTexture() { 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; // fail! ResetFont(); texture_pointer = texture_mem; texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) msx , (u8 *) texture_pointer, 0, 254, 8, 8, 1, BIT7_FIRST_PIXEL); }
void LoadTexture() { 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; // fail! texture_pointer = texture_mem; ResetFont(); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font_b, (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) msx , (u8 *) texture_pointer, 0, 254, 8, 8, 1, BIT7_FIRST_PIXEL); // here you can add more textures using 'texture_pointer'. It is returned aligned to 16 bytes }
void LoadTexture() { 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) exit(0); // fail! texture_pointer = texture_mem; Load_PNG(); if(!png1.bmp_out) exit(0); // fail! ResetFont(); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) msx, (u8 *) texture_pointer, 0, 254, 8, 8, 1, BIT7_FIRST_PIXEL); // build AYUV 32 bits map from PNG texture[0].addr = (void *) texture_pointer; texture[0].offset = tiny3d_TextureOffset(texture_pointer); texture[0].w = png1.width; texture[0].h = png1.height; texture[0].stride = png1.wpitch; texture_pointer = (u32 *) build_AYUV_32bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); // build Y 8 bits map from PNG (width * height) * 1 texture[1].addr = (void *) texture_pointer; texture[1].offset = tiny3d_TextureOffset(texture_pointer); texture[1].w = png1.width; texture[1].h = png1.height; texture[1].stride = png1.wpitch/4; texture_pointer = (u32 *) build_Y_8bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); // build U 8 bits map from PNG (width/2 * height/2) * 1 texture[2].addr = (void *) texture_pointer; texture[2].offset = tiny3d_TextureOffset(texture_pointer); texture[2].w = png1.width/2; texture[2].h = png1.height/2; texture[2].stride = texture[2].w; texture_pointer = (u32 *) build_U_8bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); // build V 8 bits map from PNG (width/2 * height/2) * 1 texture[3].addr = (void *) texture_pointer; texture[3].offset = tiny3d_TextureOffset(texture_pointer); texture[3].w = png1.width/2; texture[3].h = png1.height/2; texture[3].stride = texture[3].w; texture_pointer = (u32 *) build_V_8bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); }
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; }