Skip to content

Commit

Permalink
improve load times and add fade animations
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Jul 20, 2023
1 parent 9f0d930 commit 32240d7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
3 changes: 3 additions & 0 deletions extras/menus/xMenu/include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class Menu{
void loadGame();

void rebootMenu();

void fadeIn();
void fadeOut();

public:

Expand Down
39 changes: 22 additions & 17 deletions extras/menus/xMenu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,35 @@ PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);

using namespace std;

int main(int argc, char** argv){

common::setArgs(argc, argv);

initGraphics();

common::loadData();

int startup_thread(int argc, void* argp){
int i;
std::string startup_txt = "starting menu";
std::string startup_txt_upper = "STARTING MENU";

std::stringstream startup_holder;

int i;
for(i=0;i<startup_txt.length();i++) {
if((i%2)==0)
startup_holder << startup_txt_upper[i];
else
startup_holder << startup_txt[i];
if((i%2)==0)
startup_holder << startup_txt_upper[i];
else
startup_holder << startup_txt[i];

debugScreen(startup_holder.str().c_str(), 180, 130);
sceKernelDelayThread(100000);
sceKernelDelayThread(50000);
}

return 0;
}

int main(int argc, char** argv){

common::setArgs(argc, argv);

int thid = sceKernelCreateThread("xmenu bootup", (SceKernelThreadEntry)startup_thread, 10, 2048, PSP_THREAD_ATTR_VFPU, NULL);
sceKernelStartThread(thid, 0, NULL);

initGraphics();
common::loadData();

sceKernelWaitThreadEnd(thid, NULL);
sceKernelDeleteThread(thid);

Menu* menu = new Menu();
menu->run();
Expand Down
32 changes: 29 additions & 3 deletions extras/menus/xMenu/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ void Menu::moveUp(){

void Menu::control(){

fadeIn();

Controller control;
bool working = true;
while(working){
Expand Down Expand Up @@ -320,6 +322,7 @@ void Menu::control(){
}

}
fadeOut();
}

void Menu::loadGame(){
Expand All @@ -335,7 +338,7 @@ void Menu::loadGame(){
param.args = strlen(path) + 1;
param.argp = path;
param.key = "pops";
debugScreen(path, NULL, NULL);
fadeOut();
sctrlKernelLoadExecVSHWithApitype(runlevel, path, &param);
}

Expand All @@ -346,15 +349,14 @@ void Menu::rebootMenu(){

char path[256];
strcpy(path, ark_config->arkpath);
//strcat(path, ark_config->launcher);
strcat(path, ARK_XMENU);

int runlevel = 0x141;

param.args = strlen(path) + 1;
param.argp = path;
param.key = "game";
debugScreen(path, NULL, NULL);
fadeOut();
sctrlKernelLoadExecVSHWithApitype(runlevel, path, &param);
}

Expand Down Expand Up @@ -389,6 +391,30 @@ void Menu::run(){
control();
}

void Menu::fadeOut(){
int alpha = 255;
while (alpha>0){
u32 color = alpha << 24;
clearScreen(CLEAR_COLOR);
blitAlphaImageToScreen(0, 0, 480, 272, common::getBG(), 0, 0);
fillScreenRect(color, 0, 0, 480, 272);
common::flip();
alpha -= 15;
}
}

void Menu::fadeIn(){
int alpha = 0;
while (alpha<255){
u32 color = alpha << 24;
clearScreen(CLEAR_COLOR);
blitAlphaImageToScreen(0, 0, 480, 272, common::getBG(), 0, 0);
fillScreenRect(color, 0, 0, 480, 272);
common::flip();
alpha += 15;
}
}

Menu::~Menu(){
delete this->txt;
this->eboots.clear();
Expand Down

0 comments on commit 32240d7

Please sign in to comment.