tcploader addded
[svpe-wii.git] / tcploader / wii / preloader.c
blob093320a3ddae06b1aaf3fcfecfb3b59e141da17b
1 #include <gccore.h>
2 #include <gctypes.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include "dol.h"
6 #include "asm.h"
7 #include "processor.h"
9 extern const u8 loader_dol[];
10 extern const u32 loader_dol_size;
12 extern void __exception_closeall();
13 extern s32 __IOS_ShutdownSubsystems();
15 static u32 *xfb;
16 static GXRModeObj *rmode;
18 int main(int argc, char *argv[])
20 void (*ep)();
21 unsigned long level;
23 // doesn't work for some odd reason when this tuff is not done :/
24 VIDEO_Init();
25 PAD_Init();
27 switch(VIDEO_GetCurrentTvMode())
29 case VI_PAL:
30 rmode = &TVPal528IntDf;
31 break;
32 case VI_MPAL:
33 rmode = &TVMpal480IntDf;
34 default:
35 case VI_NTSC:
36 rmode = &TVNtsc480IntDf;
37 break;
40 xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
41 console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
43 VIDEO_Configure(rmode);
44 VIDEO_SetBlack(FALSE);
45 VIDEO_SetNextFramebuffer(xfb);
46 VIDEO_Flush();
47 VIDEO_WaitVSync();
48 if(rmode->viTVMode & VI_NON_INTERLACE)
49 VIDEO_WaitVSync();
51 printf("loading, please wait...\n");
52 memcpy((void *)0x90000020, loader_dol, loader_dol_size);
53 // memcpy((void *)0x80001800, stub_bin, stub_bin_size);
55 ep = (void(*)())load_dol_image((void *)loader_dol, 1);
56 __IOS_ShutdownSubsystems();
57 _CPU_ISR_Disable(level);
58 __exception_closeall();
59 ep();
60 return 0;