Initial Commit
[Projects.git] / pkgbuilds / wiifuse / src / wiifuse-0.2.0 / server / source / main.c
blob7c2903a8299281f83710da8eb936432c23f9bbda
1 /*
2 * Copyright (C) 2008 dhewg, #wiidev efnet
4 * this file is part of wiifuse
5 * http://wiibrew.org/index.php?title=Wiifuse
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <malloc.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <unistd.h>
28 #include <gccore.h>
29 #include <ogcsys.h>
31 #include "../../shared.h"
32 #include "global.h"
33 #include "usb.h"
34 #include "server.h"
36 static void *xfb = NULL;
37 static GXRModeObj *rmode;
39 // TODO reset/power cb
40 void (*reload)() = (void (*) ()) 0x80001800;
42 int main() {
43 unsigned int geckoattached;
45 PAD_Init ();
46 VIDEO_Init ();
48 switch (VIDEO_GetCurrentTvMode())
50 case VI_NTSC:
51 rmode = &TVNtsc480IntDf;
52 break;
53 case VI_PAL:
54 rmode = &TVPal528IntDf;
55 break;
56 case VI_MPAL:
57 rmode = &TVMpal480IntDf;
58 break;
59 default:
60 rmode = &TVNtsc480IntDf;
61 break;
64 xfb = MEM_K0_TO_K1 (SYS_AllocateFramebuffer (rmode));
66 VIDEO_Configure (rmode);
67 VIDEO_SetNextFramebuffer (xfb);
68 VIDEO_SetBlack (FALSE);
69 VIDEO_Flush ();
70 VIDEO_WaitVSync ();
71 if (rmode->viTVMode&VI_NON_INTERLACE)
72 VIDEO_WaitVSync();
73 console_init(xfb, 20, 64, rmode->fbWidth, rmode->xfbHeight,
74 rmode->fbWidth * 2);
75 VIDEO_SetNextFramebuffer (xfb);
77 printf ("wiifuse server " WIIFUSE_VERSION "\n"
78 "coded by dhewg, #wiidev efnet/blitzed\n\n"
79 "running under ios version %d v%d.%d\n\n", IOS_GetVersion (),
80 IOS_GetRevisionMajor (), IOS_GetRevisionMinor ());
82 geckoattached = usb_checkgecko ();
83 if (!geckoattached) {
84 printf ("usb gecko not found\n");
85 } else {
86 usb_flush ();
87 server_run ();
90 printf ("reloading\n");
91 sleep (1);
92 reload ();
94 return 0;