Hi!
OT/This is my first post, excuse me for don't introduce in the forum and for my bad english!I'm italian xd..../OT
I have many problems whit this library...I wanted to make a nice sample that it made to see a menù (that of dc6)...I make a main.cpp and a makefile but not be done....
main.cpp:
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspsuspend.h>
#include <psppower.h>
#include <pspreg.h>
#include <psprtc.h>
#include <psputils.h>
#include <systemctrl.h>
#include <kubridge.h>
#include <stdio.h>
#include <stdarg.h>
#include <libpsardumper.h>
#include <pspdecrypt.h>
#include <pspipl_update.h>
#include <vlf.h>
#include <time.h>
#define RGB(r, g, b) ((b << 16) | (g << 8) | r)
#define GREEN (0, 255, 0)
#define BLUE RGB(0, 0, 255)
#define BLACK RGB(0, 0, 0)
#define WHITE RGB(255, 255, 255)
#define RED RGB(255, 0, 0)
#define YELLOW RGB(255, 255, 0)
PSP_MODULE_INFO("Test", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_KB(12*1024);
#define SMALL_BUFFER_SIZE 2100000
static int BIG_BUFFER_SIZE;
void *ReadFileAllocEx(char *file, int seek, int size, int *retSize);
int done = 0;
int exit_callback(int arg1, int arg2, void *common)
{
done = 1;
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
u8 *big_buffer;
u8 *sm_buffer1, *sm_buffer2;
#define N_FILES 12
int progress_text = -1, progress_bar = -1;
int status = -1;
void *ReadFileAllocEx(char *file, int seek, int size, int *retSize);
int ReadFile(char *file, int offset, void *buf, int size);
int WriteFile(char *file, void *buf, int size);
void *malloc64(int size);
int scePower_0442D852(int);
#define scePowerRequestColdReset scePower_0442D852
void MainMenu(int sel);
#define N_HI_ITEMS 10
int hi_texts[N_HI_ITEMS];
typedef struct U64
{
u32 low;
u32 high;
} U64;
int OnMainMenuSelect(int sel)
{
void *wi;
switch (sel)
{
case 0:
vlfGuiCancelBottomDialog();
sceKernelExitGame();
break;
case 1:
{
vlfGuiAddWaitIcon(&wi);
scePowerRequestStandby();
return VLF_EV_RET_REMOVE_HANDLERS;
}
break;
case 2:
{
vlfGuiAddWaitIcon(&wi);
scePowerRequestColdReset(0);
return VLF_EV_RET_REMOVE_HANDLERS;
}
break;
case 3:
{
vlfGuiAddWaitIcon(&wi);
sceKernelExitGame();
return VLF_EV_RET_REMOVE_HANDLERS;
}
break;
}
return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
}
void MainMenu(int sel)
{
char *items[] =
{
"By Stefyx7",
"Shotdown",
"Reboot",
"Exit"
};
vlfGuiCentralMenu(4, items, sel, OnMainMenuSelect, 0, 0);
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}
int app_main(int argc, char *argv[])
{
SetupCallbacks();
void *bi;
void *data = ReadFileAllocEx("flash0:/vsh/resource/01-12.bmp", 7*6176, 6176, NULL);
if (!data || vlfGuiSetBackgroundFileBuffer(data, 6176) < 0)
{
vlfGuiSetBackgroundPlane(0xFF000000);
}
if (data)
free(data);
vlfGuiCacheResource("system_plugin");
vlfGuiCacheResource("system_plugin_fg");
vlfGuiSetModelSystem();
vlfGuiAddBatteryIconSystem(&bi, 10*1000*1000);
vlfGuiAddClock();
while (!done)
{
vlfGuiDrawFrame();
}
sceKernelExitGame();
return 0;
}
makefile:
Code: Select all
TARGET = test
OBJS = crt0.o main.o graphics.o
INCDIR = ./include
CFLAGS = -O2 -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS) -c
LIBDIR = ./lib
LDFLAGS = -mno-crt0 -nostdlib -nodefaultlibs
LIBS = -lvlfgui -lvlfgu -lvlfutils -lpng -lz -lm -lvlflibc -lpspkubridge
PSP_FW_VERSION = 150
BUILD_PRX = 1
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test
#PSP_EBOOT_ICON="icon0.png"
PSPSDK=$(shell psp-config --pspsdk-path)
include ./build.mak
help meeeeeeeee!