Beispiel #1
0
s32 main(s32 argc, const char* argv[])
{
	padInfo padinfo;
	padData paddata;
	int i;
	
	tiny3d_Init(1024*1024);

	ioPadInit(7);

	// Load texture

    LoadTexture();

	
	// Ok, everything is setup. Now for the main loop.
	while(1) {

        /* DRAWING STARTS HERE */

        // clear the screen, buffer Z and initializes environment to 2D

        tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL);

        // Enable alpha Test
        tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL);

        // Enable alpha blending.
        tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
            TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_BLEND_FUNC_DST_ALPHA_ZERO,
            TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD);
      

		// Check the pads.
		ioPadGetInfo(&padinfo);

		for(i = 0; i < MAX_PADS; i++){

			if(padinfo.status[i]){
				ioPadGetData(i, &paddata);
				
				if(paddata.BTN_CROSS){
					return 0;
				}
			}
			
		}

        drawScene(); // Draw

        /* DRAWING FINISH HERE */

        tiny3d_Flip();
		
	}

	return 0;
}
Beispiel #2
0
s32 main(s32 argc, const char* argv[])
{
	PadInfo padinfo;
	PadData paddata;
	int i;
    int frame = 0;
	
	tiny3d_Init(1024*1024);

	ioPadInit(7);
    
    SysLoadModule(SYSMODULE_PNGDEC);

    atexit(exiting); // Tiny3D register the event 3 and do exit() call when you exit  to the menu

	// Load texture

    LoadTexture();

   
	
	// Ok, everything is setup. Now for the main loop.
	while(1) {

        /* DRAWING STARTS HERE */

        // clear the screen, buffer Z and initializes environment to 2D
        
        tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL);
        
        // Enable alpha Test
        tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL);

        // Enable alpha blending.
        tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
            NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO,
            TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD);


        drawScene(frame);

        frame++;

		// Check the pads.
		ioPadGetInfo(&padinfo);

		for(i = 0; i < MAX_PADS; i++){

			if(padinfo.status[i]){
				ioPadGetData(i, &paddata);
				
				if(paddata.BTN_CROSS){
					return 0;
				}
			}
			
		}

        /* DRAWING FINISH HERE */

        tiny3d_Flip();
		
	}

	return 0;
}
Beispiel #3
0
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;
}
Beispiel #4
0
s32 main(s32 argc, const char* argv[])
{

	tiny3d_Init(1024*1024);

	ioPadInit(7);

    atexit(exiting); // Tiny3D register the event 3 and do exit() call when you exit  to the menu

	// Load texture

    LoadTexture();

	
	// Ok, everything is setup. Now for the main loop.
	while(1) {

        static long frame_count = 0;


        /* DRAWING STARTS HERE */

        // clear the screen, buffer Z and initializes environment to 2D

        double sx = (double) Video_Resolution.width;
        double sy = (double) Video_Resolution.height;
        double px = (double) (1000 + videoscale_x)/1000.0;
        double py = (double) (1000 + videoscale_y)/1000.0;
        
        tiny3d_UserViewport(1, 
            (float) ((sx - sx * px) / 2.0), // 2D position
            (float) ((sy - sy * py) / 2.0), 
            (float) ((sx * px) / 848.0),    // 2D scale
            (float) ((sy * py) / 512.0),
            (((float) Video_Resolution.width) / 1920.0f) * (float) (1000 + videoscale_x)/1000.0f,  // 3D scale
            (((float) Video_Resolution.height) / 1080.0f) * (float) (1000 + videoscale_y)/1000.0f);

        tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL);

        // Enable alpha Test
        tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL);

        // Enable alpha blending.
        tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
            TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_BLEND_FUNC_DST_ALPHA_ZERO,
            TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD);
      
        ps3pad_read();

        if(!(frame_count & 3)) {
            if(old_pad & BUTTON_UP) {if(videoscale_y > -179) videoscale_y--;}
            if(old_pad & BUTTON_DOWN) {if(videoscale_y < 10) videoscale_y++;}
            if(old_pad & BUTTON_LEFT) {if(videoscale_x > -199) videoscale_x--;}
            if(old_pad & BUTTON_RIGHT) {if(videoscale_x < 10) videoscale_x++;}
        }

        
        if(new_pad & BUTTON_CROSS) break;

        drawScene(); // Draw

        /* DRAWING FINISH HERE */

        tiny3d_Flip();
        
        frame_count++;
		
	}
	
	return 0;
}
Beispiel #5
0
s32 main(s32 argc, const char* argv[])
{
	PadInfo padinfo;
	PadData paddata;
	int i;
	
	tiny3d_Init(1024*1024);

	ioPadInit(7);
    
    SysLoadModule(SYSMODULE_PNGDEC);

	// Load texture

    LoadTexture();

    /* data for the ghost */

    ghost[0].x     = 0.0f;
    ghost[0].y     = 0.0f;
    ghost[0].dx    = 1.5f;
    ghost[0].dy    = 1.5f;
    ghost[0].frame = 0;
    ghost[0].color = 0xffffff80;

    ghost[1].x     = (847.0f - 64.0f);
    ghost[1].y     = 0.0f;
    ghost[1].dx    = -1.5f;
    ghost[1].dy    = 1.5f;
    ghost[1].frame = 0;
    ghost[1].color = 0x8f8fff80;

    ghost[2].x     = 0.0f;
    ghost[2].y     = (511.0f - 64.0f);
    ghost[2].dx    = 1.5f;
    ghost[2].dy    = -1.5f;
    ghost[2].frame = 0;
    ghost[2].color = 0xff8f8f80;

    ghost[3].x     = (847.0f - 64.0f);
    ghost[3].y     = (511.0f - 64.0f);
    ghost[3].dx    = -1.5f;
    ghost[3].dy    = -1.5f;
    ghost[3].frame = 0;
    ghost[3].color = 0x8fff8f80;
	
	// Ok, everything is setup. Now for the main loop.
	while(1) {

        /* DRAWING STARTS HERE */

        // clear the screen, buffer Z and initializes environment to 2D

        tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL);

        // Enable alpha Test
        tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL);

        // Enable alpha blending.
        tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
            NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO,
            TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD);
      

		// Check the pads.
		ioPadGetInfo(&padinfo);

		for(i = 0; i < MAX_PADS; i++){

			if(padinfo.status[i]){
				ioPadGetData(i, &paddata);
				
				if(paddata.BTN_CROSS){
					return 0;
				}
			}
			
		}

        drawScene(); // Draw

        /* DRAWING FINISH HERE */

        tiny3d_Flip();
		
	}
	
    SysUnloadModule(SYSMODULE_PNGDEC);

	return 0;
}