Skip to content

Commit

Permalink
Allow autostarting of config file via command line argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Feb 14, 2024
1 parent 9a0f6ac commit 2770c1b
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -159,7 +159,7 @@ if(BUILD_PSP2)
SceSysmodule_stub SceDisplay_stub SceGxm_stub
SceCtrl_stub ScePgf_stub ScePower_stub SceCommonDialog_stub
SceAudio_stub SceShellSvc_stub SceHid_stub SceTouch_stub png jpeg z m c
SceAppUtil_stub
SceAppUtil_stub SceAppMgr_stub
)

if (BUILD_DEBUG)
Expand All @@ -178,7 +178,7 @@ if(BUILD_PSP2)

vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} ${UNSAFE_FLAG})
add_custom_target(${PROJECT_NAME}.vpk
DEPENDS ${PROJECT_NAME}.self
DEPENDS ${PROJECT_NAME}.self-self
COMMAND rm -rf vpk && mkdir -p vpk/sce_sys
COMMAND ${VITASDK}/bin/vita-mksfoex -s TITLE_ID=${TITLEID} "${PROJECT_NAME}" vpk/sce_sys/param.sfo
COMMAND cp ${PROJECT_NAME}.self vpk/eboot.bin
Expand Down
34 changes: 34 additions & 0 deletions psp2launcher/Makefile
@@ -0,0 +1,34 @@
TITLE_ID = UAE2XXXXX
TARGET = Launcher
OBJS = main.o

LIBS = -lSceAppMgr_stub

PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
CFLAGS = -Wl,-q -Wall
ASFLAGS = $(CFLAGS)

all: builder/eboot.bin

%.vpk: eboot.bin
vita-mksfoex -s TITLE_ID=$(TITLE_ID) "Launcher" param.sfo
vita-pack-vpk -s param.sfo -b eboot.bin $@ \
-a assets/icon0.png=sce_sys/icon0.png \
-a assets/bg.png=sce_sys/livearea/contents/bg.png \
-a assets/startup.png=sce_sys/livearea/contents/startup.png \
-a assets/template.xml=sce_sys/livearea/contents/template.xml \
-a assets/args.txt=args.txt

builder/eboot.bin: $(TARGET).velf
vita-make-fself -s $< $@

%.velf: %.elf
vita-elf-create $< $@

$(TARGET).elf: $(OBJS)
$(CC) $(CFLAGS) $^ $(LIBS) -o $@

clean:
@rm -rf $(TARGET).vpk $(TARGET).velf $(TARGET).elf $(OBJS) \
eboot.bin param.sfo
Binary file added psp2launcher/builder/assets/bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added psp2launcher/builder/assets/icon0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added psp2launcher/builder/assets/startup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions psp2launcher/builder/assets/template.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<livearea style="psmobile" format-ver="01.00" content-rev="1">
<livearea-background>
<image>bg.png</image>
</livearea-background>

<gate>
<startup-image>startup.png</startup-image>
</gate>
</livearea>
6 changes: 6 additions & 0 deletions psp2launcher/builder/build.bat
@@ -0,0 +1,6 @@
@set /p title="Insert bubble name: "
@set /p rom="Insert rom name: "
@set /p id="Insert bubble title ID (9 characters [NOTE: Only UPPERCASE letters or numbers]): "
@echo|set /p="%rom%"> "assets/args.txt"
vita-mksfoex -s TITLE_ID=%id% "%title%" param.sfo
vita-pack-vpk -s param.sfo -b eboot.bin "%title%.vpk" -a assets/icon0.png=sce_sys/icon0.png -a assets/bg.png=sce_sys/livearea/contents/bg.png -a assets/startup.png=sce_sys/livearea/contents/startup.png -a assets/template.xml=sce_sys/livearea/contents/template.xml -a assets/args.txt=args.txt
Binary file added psp2launcher/builder/vita-mksfoex.exe
Binary file not shown.
Binary file added psp2launcher/builder/vita-pack-vpk.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions psp2launcher/main.c
@@ -0,0 +1,23 @@
#include <vitasdk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, const char *argv[]) {
char buffer[256];
memset(buffer, 0, 256);
FILE *f = fopen("app0:args.txt", "rb");
if (f) {
fread(buffer, 1, 256, f);
fclose(f);
char uri[512];
sprintf(uri, "psgm:play?titleid=%s&param=%s", "UAE4ALL00", buffer);

sceAppMgrLaunchAppByUri(0xFFFFF, uri);
sceKernelDelayThread(1000);
}

sceKernelExitProcess(0);

return 0;
}
3 changes: 3 additions & 0 deletions src/filesys.cpp
Expand Up @@ -410,8 +410,11 @@ struct uaedev_mount_info *dup_mountinfo (struct uaedev_mount_info *mip)
uip->volname = my_strdup (uip->volname);
if (uip->rootdir)
uip->rootdir = my_strdup (uip->rootdir);
#if !(defined __PSP2__)
// Broken in latest VitaSDK 20240214 (fdopen returns 0), causing crashes with hdf
if (uip->hf.fd)
uip->hf.fd = fdopen ( dup (fileno (uip->hf.fd)), uip->readonly ? "rb" : "r+b");
#endif
}
return i2;
}
Expand Down
8 changes: 7 additions & 1 deletion src/gp2x/menu/menu_config.cpp
Expand Up @@ -1514,7 +1514,13 @@ void loadconfig(int general)
}

if (general == 1)
snprintf(path, 300, "%s/conf/uaeconfig.conf", launchDir);
if (config_load_filename[0] != 0) {
// custom config was specified as command line argument
snprintf(path, 300, "%s",config_load_filename);
}
else {
snprintf(path, 300, "%s/conf/uaeconfig.conf", launchDir);
}
else if (general == 3)
snprintf(path, 300, config_filename, launchDir);
else if(general == 0)
Expand Down
16 changes: 13 additions & 3 deletions src/gp2x/menu/menu_main.cpp
Expand Up @@ -78,6 +78,8 @@ extern char filename3[256];

extern char config_load_filename[300];

extern bool resetOnStartingApp;

#ifdef __PSP2__
static const char *text_str_title= "----- UAE4All Vita " VERSION_MAJOR "." VERSION_MINOR " -----";
#else
Expand Down Expand Up @@ -1019,10 +1021,18 @@ int run_mainMenu()
raise_mainMenu();
end=0;
draw_mainMenu(c);
while(!end)
if (!resetOnStartingApp)
{
while(!end)
{
draw_mainMenu(c);
end=key_mainMenu(&c);
}
}
else
{
draw_mainMenu(c);
end=key_mainMenu(&c);
mainMenu_case = MAIN_MENU_CASE_RESET;
resetOnStartingApp = false;
}
unraise_mainMenu();
switch(mainMenu_case)
Expand Down
10 changes: 7 additions & 3 deletions src/gui.cpp
Expand Up @@ -206,14 +206,18 @@ int no_limiter = 0;
#ifdef __SWITCH__
int singleJoycons = 0; // are single Joycons being used at the moment?
void update_joycon_mode() {
int handheld = hidGetHandheldMode();
int handheld;
if (appletGetOperationMode() == AppletOperationMode_Handheld)
handheld = 1;
else
handheld = 0;
if (!handheld) {
if (mainMenu_singleJoycons) {
if (!singleJoycons) {
singleJoycons = 1;
for (int id=0; id<8; id++) {
hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);
hidScanInput();
//hidScanInput();
hidSetNpadJoyAssignmentModeSingleByDefault((HidNpadIdType) id);
}
}
Expand Down Expand Up @@ -247,7 +251,7 @@ void update_joycon_mode() {
singleJoycons = 0;
for (int id=0; id<8; id++) {
hidSetNpadJoyHoldType(HidNpadJoyHoldType_Vertical);
hidScanInput();
//hidScanInput();
hidSetNpadJoyAssignmentModeDual((HidNpadIdType) id);
}
}
Expand Down
31 changes: 25 additions & 6 deletions src/main.cpp
Expand Up @@ -66,6 +66,8 @@ extern SDL_Surface *current_screenshot;
#include <psp2/shellutil.h>
//Touch input
#include "psp2_touch.h"
//Custom bubble
#include <psp2/appmgr.h>
#ifdef DEBUG_UAE4ALL
#include <psp2shell.h>
#endif
Expand All @@ -90,6 +92,9 @@ struct gui_info gui_data;

char warning_buffer[256];

bool resetOnStartingApp = false;
extern char config_load_filename[300];

/* If you want to pipe printer output to a file, put something like
* "cat >>printerfile.tmp" above.
* The printer support was only tested with the driver "PostScript" on
Expand Down Expand Up @@ -300,16 +305,30 @@ void real_main (int argc, char **argv)
#ifdef GP2X
gp2x_init(argc, argv);
#endif
// Set everthing to default and clear HD settings
SetDefaultMenuSettings(1);

loadconfig (1);
// Set everthing to default and clear HD settings
SetDefaultMenuSettings(1);
//Check if UAE4All2 was launched by a custom bubble
#if defined(__SWITCH__)
if (argc == 2) {
snprintf(config_load_filename, 300, argv[1]);
resetOnStartingApp = true;
}
#endif
#if defined(__PSP2__) // NOT __SWITCH__
char boot_params[1024];
sceAppMgrGetAppParam(boot_params);
if (strstr(boot_params,"psgm:play") && strstr(boot_params, "&param=")) {
snprintf(config_load_filename, 300, strstr(boot_params, "&param=") + 7);
resetOnStartingApp = true;
}
#endif
loadconfig (1);
if (! graphics_setup ()) {
exit (1);
exit (1);
}
rtarea_init ();

hardfile_install();
hardfile_install();

if (! setup_sound ()) {
write_log ("Sound driver unavailable: Sound output disabled\n");
Expand Down
4 changes: 2 additions & 2 deletions src/psp2/psp2-dirent.c
Expand Up @@ -33,7 +33,7 @@ DEALINGS IN THE SOFTWARE.

#define SCE_ERRNO_MASK 0xFF

int mkdir(const char *path, mode_t mode)
/*int mkdir(const char *path, mode_t mode)
{
return sceIoMkdir(path, 0777);
}
Expand All @@ -42,7 +42,7 @@ int rmdir(const char *path)
{
return sceIoRmdir(path);
}

*/
struct DIR_
{
SceUID uid;
Expand Down
Binary file modified src/psp2/vita2d_fbo/lib/libvita2d.a
Binary file not shown.

0 comments on commit 2770c1b

Please sign in to comment.