Graphics in vshex?
Graphics in vshex?
Is there a way to be able to import a png and let it display in vshex?
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).
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
Code: Select all
#include <pspkernel.h>
#include <stdio.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
#include <string.h>
#include <pspgu.h>
PSP_MODULE_INFO("GFX", 0x1000, 1, 0);
//PSP_MAIN_THREAD_ATTR(0);
int a = 0;
int mainThread(SceSize args, void *argp)
{
int fd = sceIoOpen("ms0:/boot.raw", PSP_O_RDONLY, 0777);
int lenght = sceIoLseek(fd, 0, SEEK_END);
int id = sceKernelAllocPartitionMemory(2, "imgbuff", 0, lenght, NULL);
u32 *mybuf=sceKernelGetBlockHeadAddr(id);
u64 starttick;
u64 lasttick;
sceIoLseek(fd,0,SEEK_SET);
sceIoRead(fd, mybuf, lenght);
sceIoClose(fd);
sceRtcGetCurrentTick(&starttick);
while(1)
{
static u32* g_vram_base = (u32 *) 0x44000000; //0x04000000;
int y = 0;
int x = 0;
sceDisplayWaitVblankStart();
for(y = 0; y<141; y++)
{
for(x = 0; x<150; x++)
{
*(g_vram_base+(x+250+((y+100)*512))) = mybuf[x+(y*150)];
}
}
//sceKernelDcacheWritebackInvalidateAll();
sceRtcGetCurrentTick(&lasttick);
if(((lasttick-starttick)/sceRtcGetTickResolution()) > 20)
break;
}
sceKernelFreePartitionMemory(id);
sceKernelExitDeleteThread(0);
return 0;
}
int module_start (SceSize args, void *argp)
{
SceUID thid;
thid = sceKernelCreateThread("ch_main", mainThread, 0x64, 0x1000, 0, NULL);
if (thid >= 0) sceKernelStartThread(thid, args, argp);
return 0;
}
int module_stop (void)
{
return 0;
}
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
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 :)
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 :)