diff --git a/Makefile b/Makefile index ff83fc62..4c3525f4 100644 --- a/Makefile +++ b/Makefile @@ -81,11 +81,9 @@ else export LD := $(CXX) endif -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ +export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(sFILES:.s=.o) $(SFILES:.S=.o) \ - $(PNGFILES:.png=.png.o) $(addsuffix .o,$(DOLFILES)) \ - $(addsuffix .o,$(ELFFILES)) + $(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES)) #--------------------------------------------------------------------------------- # build a list of include paths @@ -142,11 +140,7 @@ $(OUTPUT).elf: $(OFILES) @echo $(notdir $<) @bin2s -a 32 $< | $(AS) -o $(@) -%.dol.o : %.dol - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -%.elf.o : %.elf +%.bin.o : %.bin @echo $(notdir $<) @bin2s -a 32 $< | $(AS) -o $(@) diff --git a/data/app_booter.bin b/data/app_booter.bin new file mode 100644 index 00000000..08d18063 Binary files /dev/null and b/data/app_booter.bin differ diff --git a/data/app_booter.dol b/data/app_booter.dol deleted file mode 100644 index 62c156fe..00000000 Binary files a/data/app_booter.dol and /dev/null differ diff --git a/source/background_image.c b/source/background_image.c index 080c85ad..cca072ff 100644 --- a/source/background_image.c +++ b/source/background_image.c @@ -3,6 +3,8 @@ #include "video.h" #include "filelist.h" +extern int screenwidth; +extern int screenheight; static int imagewidth = 0; static int imageheight = 0; @@ -56,7 +58,7 @@ void fadein(u8 * imgdata) for(i = 0; i < 255; i = i+10) { if(i>255) i = 255; - Background_Show(0, 0, 0, imgdata, 0, 1, 1, i); + Background_Show(screenwidth/2-imagewidth/2, screenheight/2-imageheight/2, 0, imgdata, 0, (float)screenwidth/(float)imagewidth, 1, i); } } @@ -68,6 +70,6 @@ void fadeout(u8 * imgdata) for(i = 255; i > 1; i = i-7) { if(i < 0) i = 0; - Background_Show(0, 0, 0, imgdata, 0, 1, 1, i); + Background_Show(screenwidth/2-imagewidth/2, screenheight/2-imageheight/2, 0, imgdata, 0, (float)screenwidth/(float)imagewidth, 1, i); } } diff --git a/source/filelist.h b/source/filelist.h index 6bc5a69b..20948a52 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -8,8 +8,8 @@ #include -extern const u8 app_booter_dol[]; -extern const u32 app_booter_dol_size; +extern const u8 app_booter_bin[]; +extern const u32 app_booter_bin_size; extern const u8 background_png[]; extern const u32 background_png_size; diff --git a/source/main.c b/source/main.c index 1daff025..b95e033d 100644 --- a/source/main.c +++ b/source/main.c @@ -1,8 +1,6 @@ /**************************************************************************** * Copyright 2009 The Lemon Man and thanks to luccax, Wiipower, Aurelio and crediar - * Copyright 2010 Dimok - * - * Original forwarder source by + * Copyright 2010-2011 Dimok * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any @@ -32,12 +30,17 @@ #include "video.h" #include "background_image.h" -#include "dolloader.h" #include "filelist.h" #include "devicemounter.h" #include "cfg.h" -void __exception_setreload(int t); +#define EXECUTE_ADDR ((u8 *) 0x92000000) +#define BOOTER_ADDR ((u8 *) 0x93000000) +#define ARGS_ADDR ((u8 *) 0x93200000) + +typedef void (*entrypoint) (void); +extern void __exception_setreload(int t); +extern void __exception_closeall(); static int GetXMLArguments(const char *path, struct __argv *args) { @@ -96,11 +99,6 @@ static int GetXMLArguments(const char *path, struct __argv *args) entry[len] = '\0'; - char *tmp = (char *) realloc(args->commandLine, args->length + len + 1); - if(!tmp) - break; //out of memory, take what we got until now - - args->commandLine = tmp; strcpy(args->commandLine + args->length - 1, entry); args->length += len + 1; } @@ -154,10 +152,9 @@ int main(int argc, char **argv) { u32 cookie; FILE *exeFile = NULL; - void * exeBuffer = (void *)EXECUTABLE_MEM_ADDR; u32 exeSize = 0; - u32 exeEntryPointAddress = 0; - entrypoint exeEntryPoint; + void * exeBuffer = (void *)EXECUTE_ADDR; + entrypoint exeEntryPoint = (entrypoint) BOOTER_ADDR; __exception_setreload(0); /* int videomod */ @@ -223,53 +220,42 @@ int main(int argc, char **argv) } fclose (exeFile); - /* load entry point */ + //! Setup argument struct struct __argv args; bzero(&args, sizeof(args)); args.argvMagic = ARGV_MAGIC; args.length = strlen(filepath) + 2; - args.commandLine = (char*)malloc(args.length); - if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + //! Put the argument into mem2 too, to avoid overwriting it + args.commandLine = (char *) ARGS_ADDR + sizeof(args); + //! Add executable file path as first argument strcpy(args.commandLine, filepath); + //! Append the arguments from the meta.xml GetXMLArguments(filepath, &args); + //! Finishing sequence "\0\0" args.commandLine[args.length - 1] = '\0'; args.argc = 1; args.argv = &args.commandLine; args.endARGV = args.argv + 1; - u8 * appboot_buff = (u8 *) malloc(app_booter_dol_size); - if(!appboot_buff) - { - fadeout(imgdata); - SDCard_deInit(); - USBDevice_deInit(); - StopGX(); - free(imgdata); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } + //! Put the booter code to it's expected address + memcpy(BOOTER_ADDR, app_booter_bin, app_booter_bin_size); + DCFlushRange(BOOTER_ADDR, app_booter_bin_size); - memcpy(appboot_buff, app_booter_dol, app_booter_dol_size); + //! Put the argument struct to it's expected address + memcpy(ARGS_ADDR, &args, sizeof(args)); + DCFlushRange(ARGS_ADDR, sizeof(args) + args.length); - exeEntryPointAddress = load_dol_image(appboot_buff, &args); - - if(appboot_buff) - free(appboot_buff); + //! Reset HBC stub so we can leave correct from USB Loader GX to System Menu + memset((char *) 0x80001804, 0, 8); + DCFlushRange((char *) 0x80001804, 8); + /* cleaning up and load booter */ fadeout(imgdata); SDCard_deInit(); USBDevice_deInit(); StopGX(); free(imgdata); - //! Reset HBC stub so we can leave correct from USB Loader to System Menu - memset((char *) 0x80001804, 0, 8); - DCFlushRange((char *) 0x80001804, 8); - - if (exeEntryPointAddress == 0) - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - - exeEntryPoint = (entrypoint) exeEntryPointAddress; - /* cleaning up and load dol */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); _CPU_ISR_Disable (cookie); __exception_closeall (); diff --git a/source/video.c b/source/video.c index 80ae461e..9bd1e5ed 100644 --- a/source/video.c +++ b/source/video.c @@ -204,6 +204,9 @@ void StopGX() VIDEO_SetBlack(TRUE); VIDEO_Flush(); + VIDEO_WaitVSync(); + if (vmode->viTVMode & VI_NON_INTERLACE) + VIDEO_WaitVSync(); } /****************************************************************************