diff --git a/misc/psp/Makefile b/misc/psp/Makefile index be00410bd..8e310e5c6 100644 --- a/misc/psp/Makefile +++ b/misc/psp/Makefile @@ -7,59 +7,107 @@ $(warning export PSPSDK=$$(shell psp-config --pspsdk-path)) $(error Failed to find PSPSDK installation) endif + +#--------------------------------------------------------------------------------- +# Configurable options +#--------------------------------------------------------------------------------- # Name of the final output TARGET = ClassiCube-psp # List of directories containing source code -SOURCE_DIRS = src third_party/bearssl +SOURCE_DIRS = src src/psp third_party/bearssl # Directory where object files are placed BUILD_DIR = build/psp -PSP_EBOOT_TITLE = ClassiCube -PSP_EBOOT_ICON = misc/psp/ICON0.png +PSP_EBOOT_TITLE = ClassiCube +PSP_EBOOT_ICON = misc/psp/ICON0.png +PSP_EBOOT_SFO = PARAM.SFO +PSP_EBOOT_ICON1 = NULL +PSP_EBOOT_UNKPNG = NULL +PSP_EBOOT_PIC1 = NULL +PSP_EBOOT_SND0 = NULL +PSP_EBOOT_PSAR = NULL +PSP_EBOOT = EBOOT.PBP #--------------------------------------------------------------------------------- # Code generation #--------------------------------------------------------------------------------- +S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) -OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o))) +OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) -INCDIR = third_party/bearssl -CFLAGS = -g -O1 -fno-math-errno -ASFLAGS = $(CFLAGS) +INCDIR := $(PSPDEV)/psp/include $(PSPSDK)/include +LIBDIR := $(PSPDEV)/psp/lib $(PSPSDK)/lib -LIBDIR = -LDFLAGS = -LIBS = -lm -lpspgum -lpspgu -lpspge -lpspdisplay -lpspctrl +CFLAGS := $(addprefix -I,$(INCDIR)) -g -O1 -fno-math-errno -D_PSP_FW_VERSION=600 +ASFLAGS := $(addprefix -I,$(INCDIR)) -g + +LDFLAGS := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx -Wl,-zmax-page-size=128 +LIBS := -lm -lpspgum -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspdebug -lpspnet -lpspnet_apctl # Dependency tracking DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d DEPFILES := $(OBJS:%.o=%.d) -BUILD_PRX = 1 -EXTRA_TARGETS = $(BUILD_DIR) EBOOT.PBP -include $(PSPSDK)/lib/build.mak +#--------------------------------------------------------------------------------- +# Compiler tools +#--------------------------------------------------------------------------------- +CC = psp-gcc +AS = psp-gcc +LD = psp-gcc +MKSFO = mksfoex +PACK_PBP = pack-pbp +FIXUP = psp-fixup-imports #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- +all: $(BUILD_DIR) $(PSP_EBOOT) + $(BUILD_DIR): mkdir -p $(BUILD_DIR) +clean: + -rm -f $(TARGET).prx $(TARGET).elf $(OBJS) $(PSP_EBOOT_SFO) $(PSP_EBOOT) + + +#--------------------------------------------------------------------------------- +# executable generation +#--------------------------------------------------------------------------------- +$(TARGET).elf: $(OBJS) + $(LD) $^ $(LDFLAGS) $(LIBS) -o $@ + $(FIXUP) $@ + +$(TARGET).prx: $(TARGET).elf + psp-prxgen $< $@ + +$(PSP_EBOOT_SFO): + $(MKSFO) -d MEMSIZE=1 '$(PSP_EBOOT_TITLE)' $@ + +$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO) + $(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \ + $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \ + $(PSP_EBOOT_SND0) $(TARGET).prx $(PSP_EBOOT_PSAR) + #--------------------------------------------------------------------------------- # object generation #--------------------------------------------------------------------------------- $(BUILD_DIR)/%.o : src/%.c $(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ + +$(BUILD_DIR)/%.o : src/psp/%.c + $(VITA_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o : third_party/bearssl/%.c $(CC) $(CFLAGS) -c $< -o $@ +#--------------------------------------------------------------------------------- # Dependency tracking +#--------------------------------------------------------------------------------- $(DEPFILES): include $(wildcard $(DEPFILES)) diff --git a/misc/vita/Makefile b/misc/vita/Makefile index 98f7bdd94..2b8a363f2 100644 --- a/misc/vita/Makefile +++ b/misc/vita/Makefile @@ -9,14 +9,14 @@ endif # Configurable options #--------------------------------------------------------------------------------- # Name of the final output -TARGET := ClassiCube-vita +TARGET = ClassiCube-vita # List of directories containing source code -SOURCE_DIRS := src src/psvita third_party/bearssl +SOURCE_DIRS = src src/psvita third_party/bearssl # Directory where object files are placed -BUILD_DIR := build/vita +BUILD_DIR = build/vita -PROJECT_TITLE := ClassiCube -PROJECT_TITLEID := CUBE00200 +PROJECT_TITLE = ClassiCube +PROJECT_TITLEID = CUBE00200 #--------------------------------------------------------------------------------- diff --git a/src/Launcher.c b/src/Launcher.c index 454405db5..c96f3966a 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -274,16 +274,15 @@ void Launcher_Setup(void) { #endif } -void Launcher_Run(void) { - for (;;) { - Window_ProcessEvents(10 / 1000.0f); - Gamepad_Tick(10 / 1000.0f); - if (!Window_Main.Exists || Launcher_ShouldStop) break; +cc_bool Launcher_Tick(void) { + /* NOTE: Make sure to keep delay same as hardcoded delay in RunLauncher in main_impl.h */ + Window_ProcessEvents(10 / 1000.0f); + Gamepad_Tick(10 / 1000.0f); + if (!Window_Main.Exists || Launcher_ShouldStop) return false; - Launcher_Active->Tick(Launcher_Active); - LBackend_Tick(); - Thread_Sleep(10); - } + Launcher_Active->Tick(Launcher_Active); + LBackend_Tick(); + return true; } void Launcher_Finish(void) { diff --git a/src/Launcher.h b/src/Launcher.h index 0364cf57e..975c82006 100644 --- a/src/Launcher.h +++ b/src/Launcher.h @@ -82,7 +82,7 @@ void Launcher_DisplayHttpError(struct HttpRequest* req, const char* action, cc_s /* Sets up state and then creates the launcher window */ void Launcher_Setup(void); /* Ticks the launcher main loop */ -void Launcher_Run(void); +cc_bool Launcher_Tick(void); /* Cleans up state and then destroys the launcher window */ void Launcher_Finish(void); diff --git a/src/main_impl.h b/src/main_impl.h index 0ce426bd8..e1fae6896 100644 --- a/src/main_impl.h +++ b/src/main_impl.h @@ -86,7 +86,9 @@ static void RunGame(void) { static void RunLauncher(void) { #ifndef CC_BUILD_WEB Launcher_Setup(); - Launcher_Run(); + /* NOTE: Make sure to keep delay same as hardcoded delay in Launcher_Tick */ + while (Launcher_Tick()) { Thread_Sleep(10); } + Launcher_Finish(); Window_Destroy(); #endif diff --git a/src/Graphics_PSP.c b/src/psp/Graphics_PSP.c similarity index 100% rename from src/Graphics_PSP.c rename to src/psp/Graphics_PSP.c diff --git a/src/Platform_PSP.c b/src/psp/Platform_PSP.c similarity index 100% rename from src/Platform_PSP.c rename to src/psp/Platform_PSP.c diff --git a/src/Window_PSP.c b/src/psp/Window_PSP.c similarity index 100% rename from src/Window_PSP.c rename to src/psp/Window_PSP.c