Graphics in vshex?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
TheBuzzer
Posts: 49
Joined: Mon Feb 06, 2006 10:02 am

Graphics in vshex?

Post by TheBuzzer »

Is there a way to be able to import a png and let it display in vshex?
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

you need to open it, make it to 8888 format and then write trought direct vram access. i tried it yesterday with a raw (something quick and buggy just to see how it worked :P) , this is the sourcecode (it's crimped to 150*141).

Code: Select all

#include <pspkernel.h>
#include <stdio.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
#include <string.h>
#include <pspgu.h>

PSP_MODULE_INFO&#40;"GFX", 0x1000, 1, 0&#41;;
//PSP_MAIN_THREAD_ATTR&#40;0&#41;;
int a = 0;



int mainThread&#40;SceSize args, void *argp&#41;
&#123;
	int fd = sceIoOpen&#40;"ms0&#58;/boot.raw", PSP_O_RDONLY, 0777&#41;;
	int lenght = sceIoLseek&#40;fd, 0, SEEK_END&#41;;
	int id = sceKernelAllocPartitionMemory&#40;2, "imgbuff", 0, lenght, NULL&#41;;
	u32 *mybuf=sceKernelGetBlockHeadAddr&#40;id&#41;;
	u64 starttick;
    u64 lasttick;
	sceIoLseek&#40;fd,0,SEEK_SET&#41;;
	sceIoRead&#40;fd, mybuf, lenght&#41;;
	sceIoClose&#40;fd&#41;;
	sceRtcGetCurrentTick&#40;&starttick&#41;;
	while&#40;1&#41;
	&#123;
		static u32* g_vram_base = &#40;u32 *&#41; 0x44000000; //0x04000000;
		int y = 0;
		int x = 0;
		sceDisplayWaitVblankStart&#40;&#41;;
		for&#40;y = 0; y<141; y++&#41;
		&#123;
			for&#40;x = 0; x<150; x++&#41;
			&#123;
				*&#40;g_vram_base+&#40;x+250+&#40;&#40;y+100&#41;*512&#41;&#41;&#41; = mybuf&#91;x+&#40;y*150&#41;&#93;;

			&#125;
		&#125;		
		//sceKernelDcacheWritebackInvalidateAll&#40;&#41;;
		sceRtcGetCurrentTick&#40;&lasttick&#41;;
		
		if&#40;&#40;&#40;lasttick-starttick&#41;/sceRtcGetTickResolution&#40;&#41;&#41; > 20&#41;
	          break;
		

	&#125;	
	sceKernelFreePartitionMemory&#40;id&#41;;
	sceKernelExitDeleteThread&#40;0&#41;;
	return 0;

&#125;



int module_start &#40;SceSize args, void *argp&#41;
&#123;
	SceUID thid;

	thid = sceKernelCreateThread&#40;"ch_main", mainThread, 0x64, 0x1000, 0, NULL&#41;;
	if &#40;thid >= 0&#41; sceKernelStartThread&#40;thid, args, argp&#41;;

	return 0;
&#125;

int module_stop &#40;void&#41;
&#123;
	return 0;
&#125;
it has still some problems this function
1-it flikers, it seems to do one write every two vsyncs
2-it doesn't load the entire file or doesn't write it correctly
3-you need to use psptex with all options disabled and the option with 8888 to make a valid raw image
TheBuzzer
Posts: 49
Joined: Mon Feb 06, 2006 10:02 am

Post by TheBuzzer »

so it got to be a raw image?

wonder will someone make it using png format.

thx though. maybe this will help someone be able to figure out how to import a png and change it to vshex extendor type prx
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

that's not a problem a png image but prepare two buffer (and hope there is space in kernel ram :P)
in one you fill the png image and send it to the libpng. when it's decoded in the second buffer you have a raw image and you can drop the png data.

you can get an example which loads a png image from memory (i didn't try using fopen so if it doesn't work with the kernel libc you need to use sceIoOpen) from the lua graphic library (you can find it under the lua svn folder as graphics.cpp/graphics.h)
then because the vsh is in 8888 format you don't have to do anything more after having decompressed it :)
TheBuzzer
Posts: 49
Joined: Mon Feb 06, 2006 10:02 am

Post by TheBuzzer »

so how does this extectly work?


I been trying to figure out how stuff is getting displied in vshex extendor but I barely know how does displaying even work
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

you def do not want to be in kernel memory for this stuff
10011011 00101010 11010111 10001001 10111010
Post Reply