Usermode/Build - Updates to build system for crtbegin/crtend
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / main.c
1 /*
2  * Acess2 GUI (AxWin) Version 3
3  * - By John Hodge (thePowersGang)
4  *
5  * main.c
6  * - Entrypoint
7  */
8 #include <common.h>
9 #include <acess/sys.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12
13 // === IMPORTS ===
14 extern void     Video_Setup(void);
15 extern void     WM_Initialise(void);
16 extern int      Renderer_Menu_Init(void);
17 extern int      Renderer_Widget_Init(void);
18 extern int      Renderer_Background_Init(void);
19 extern void     WM_Update(void);
20
21 // === PROTOTYPES ===
22 void    ParseCommandline(int argc, char **argv);
23
24 // === GLOBALS ===
25 const char      *gsTerminalDevice = NULL;
26 const char      *gsMouseDevice = NULL;
27
28  int    giScreenWidth = 640;
29  int    giScreenHeight = 480;
30
31  int    giTerminalFD = -1;
32  int    giMouseFD = -1;
33
34 #define __INSTALL_ROOT  "/Acess/Apps/AxWin/3.0"
35
36 const char      *gsInstallRoot = __INSTALL_ROOT;
37
38 // === CODE ===
39 /**
40  * \brief Program Entrypoint
41  */
42 int main(int argc, char *argv[])
43 {
44          int    server_tid = gettid();
45         
46         ParseCommandline(argc, argv);
47         
48         if( gsTerminalDevice == NULL ) {
49                 gsTerminalDevice = "/Devices/VTerm/6";
50         }
51         if( gsMouseDevice == NULL ) {
52                 gsMouseDevice = "/Devices/PS2Mouse";
53         }
54         
55         Video_Setup();
56 //      Interface_Init();
57         IPC_Init();
58         Input_Init();
59         
60         Renderer_Menu_Init();
61         Renderer_Widget_Init();
62         Renderer_Background_Init();
63         WM_Initialise();
64         
65         // Spawn interface root
66         if( clone(CLONE_VM, 0) == 0 )
67         {
68                 static char csInterfaceApp[] = __INSTALL_ROOT"/AxWinUI";
69                 char    server_info[] = "AXWIN3_SERVER=00000";
70                 char    *envp[] = {server_info, NULL};
71                 char    *argv[] = {csInterfaceApp, NULL};
72                 _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid);
73                 sprintf(server_info, "AXWIN3_SERVER=%i", server_tid);
74                 execve(csInterfaceApp, argv, envp);
75                 exit(1);
76         }
77
78         // Main Loop
79         for(;;)
80         {
81                 fd_set  fds;
82                  int    nfds = 0;
83                 FD_ZERO(&fds);
84         
85                 WM_Update();
86
87                 Input_FillSelect(&nfds, &fds);
88                 IPC_FillSelect(&nfds, &fds);
89                 
90                 nfds ++;
91                 if( select(nfds, &fds, NULL, NULL, NULL) == -1 ) {
92                         _SysDebug("ERROR: select() returned -1");
93                         return -1;
94                 }
95
96                 Input_HandleSelect(&fds);
97                 IPC_HandleSelect(&fds);
98         }
99         return 0;
100 }
101
102 void ParseCommandline(int argc, char **argv)
103 {
104         
105 }
106

UCC git Repository :: git.ucc.asn.au