Mercurial > hg > forks > pwpunix
annotate pwplib/pwplib-unix.c @ 15:fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Quitting via ESC now works, as does signal handling (shouldn't segfault when sent SIGINT etc.) to some degree.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 22 May 2010 18:12:37 +0300 |
parents | acb5694e93d9 |
children | c60e531d19cd |
rev | line source |
---|---|
0 | 1 #define __PWPLIB_C |
2 | |
3 #include "config.h" | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
8 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
9 #include <SDL.h> |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
10 #endif |
0 | 11 #include <signal.h> |
12 #include <time.h> | |
13 #include <sys/time.h> | |
14 | |
15 #include "pwplib.h" | |
16 #include "tty.h" | |
17 | |
18 | |
19 /******************** random stuff *************************/ | |
20 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
21 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
22 static int sdl_init = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
23 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
24 |
0 | 25 extern void pwplib_dummy(); |
26 #define pwp_dummy pwplib_dummy | |
27 | |
28 void pwpwrite(char*z) | |
29 { | |
30 if(!pwplib.setup[SETUP_SHUTUP]) | |
31 { | |
32 fprintf(stderr,"%s",z); | |
33 usleep(1000*pwplib.set.infodelay); | |
34 } | |
35 } | |
36 | |
37 /********************* timer ******************************/ | |
38 | |
39 #define TIMERHZ 72 | |
40 int pwp_unix_tod() | |
41 { | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
42 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
43 if (sdl_init) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
44 int quit = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
45 SDL_Event event; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
46 if (SDL_PollEvent(&event) >= 0) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
47 switch (event.type) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 case SDL_KEYDOWN: |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 if (event.key.keysym.sym == SDLK_ESCAPE) |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
50 quit = 1; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
51 break; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
52 case SDL_QUIT: |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
53 quit = 1; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
54 break; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
55 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
56 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
57 if (quit) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
58 SDL_Quit(); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
59 pwplib_shutdown(); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
60 exit(1); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
61 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
62 return (SDL_GetTicks() * TIMERHZ) / 1000; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
63 } else |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
64 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
65 { |
0 | 66 struct timeval tod; |
67 gettimeofday(&tod,NULL); | |
68 return (tod.tv_sec*TIMERHZ)+(tod.tv_usec*TIMERHZ/1000000); | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
69 } |
0 | 70 } |
71 | |
72 /********************* destructors, signals etc **********/ | |
73 | |
74 void pwp_fatalsignal(int n) | |
75 { | |
76 char buf[40]; | |
77 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
78 pwpwrite("* pwplib shutting down\n"); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
79 |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
80 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
81 if (sdl_init) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 sdl_init = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
83 SDL_Quit(); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
84 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
85 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
86 |
0 | 87 pwplib_shutdown(); |
88 | |
89 sprintf(buf,"* died to signal %d\n",n); | |
90 pwpwrite(buf); | |
91 | |
92 exit(1); | |
93 } | |
94 | |
95 /******************** initialization *********************/ | |
96 | |
97 int pwplib_initcore() | |
98 { | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
99 int sdl_flags = 0; |
0 | 100 pwplib_init_common(); |
101 | |
102 /*** set signals ***/ | |
103 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
104 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
105 #ifdef DRIVE_VIDEO |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
106 sdl_flags |= SDL_INIT_VIDEO; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 #ifdef DRIVE_AUDIO |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 sdl_flags |= SDL_INIT_AUDIO; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
110 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
111 /* With SDL, we let it handle the signals */ |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
112 if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_EVENTTHREAD | /* SDL_INIT_NOPARACHUTE | */ sdl_flags) != 0) |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
113 { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
114 pwpwrite("* SDL could not be initialized.\n"); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
115 sdl_init = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 } else |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
117 sdl_init = 1; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
118 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
120 if (!sdl_init) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
121 signal(SIGTERM,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
122 signal(SIGINT,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 signal(SIGQUIT,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 signal(SIGKILL,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 signal(SIGSEGV,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 } |
0 | 127 |
128 /*** video ***/ | |
129 | |
130 # ifdef DRIVE_VIDEO | |
131 | |
132 # ifdef DRIVE_SDL | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
133 if(sdl_init && pwp_SDL_init()) |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
134 { |
0 | 135 } |
136 else | |
137 # endif | |
138 # ifdef DRIVE_PVP | |
139 if(pwplib.setup[SETUP_PVP]) | |
140 pvp_init(); | |
141 else | |
142 # endif | |
143 if(!pwplib.setup[SETUP_NOVIDEO]) | |
144 { | |
145 tty_init(); | |
146 } | |
147 # endif | |
148 | |
149 /*** audio ***/ | |
150 # ifdef DRIVE_AUDIO | |
151 if(!pwplib.setup[SETUP_NOSOUND]) | |
152 { | |
153 int snd=0; | |
154 #ifdef DRIVE_SDL | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
155 if(!snd) { if(sdl_init && pwp_sdlaudio_init())snd++; } |
0 | 156 #endif |
157 | |
158 #ifdef DRIVE_OSS | |
159 if(!snd) { if(oss_init())snd++; } | |
160 #endif | |
161 | |
162 #ifdef DRIVE_HPUX | |
163 if(!snd) { if(hpuxsnd_init())snd++; } | |
164 #endif | |
165 | |
166 if(!snd) | |
167 pwpwrite("* couldn't init sound. going silent.\n"); | |
168 | |
169 } | |
170 else | |
171 pwpwrite("* no sound, as requested\n"); | |
172 # endif | |
173 | |
174 /*** fallbacks - remove? ***/ | |
175 | |
176 if(pwplib.dump_rast==pwplib_dummy && pwplib.dump_attr!=pwplib_dummy) | |
177 pwplib.dump_rast=pwplib_dump_rast_plain; | |
178 | |
179 /*** timer ***/ | |
180 | |
181 if(pwplib.setup[SETUP_BPS]|pwplib.setup[SETUP_FPS]) | |
182 { | |
183 char tmp[100]; | |
184 sprintf(tmp,"non-realtime output (bps=%d fps=%d)\n", | |
185 pwplib.setup[SETUP_BPS],pwplib.setup[SETUP_FPS]); | |
186 pwpwrite(tmp); | |
187 | |
188 pwplib.timerfunc=pwp_timer_nrt; | |
189 pwplib.timer_counter=0; | |
190 } | |
191 else | |
192 pwplib.timerfunc=pwp_unix_tod; | |
193 | |
194 /*** hmmm ***/ | |
195 | |
196 if(pwplib.setup[SETUP_HALVE]) | |
197 pwplib.videobuf.height<<=1; | |
198 | |
199 /* only allow if smaller than original? */ | |
200 | |
201 if(pwplib.setup[SETUP_USERHEIGHT]) | |
202 pwplib.videobuf.height=pwplib.setup[SETUP_USERHEIGHT]; | |
203 if(pwplib.setup[SETUP_USERWIDTH]) | |
204 pwplib.videobuf.width=pwplib.setup[SETUP_USERWIDTH]; | |
205 | |
206 /*** done ***/ | |
207 | |
208 # ifdef DRIVE_VIDEO | |
209 if(!pwplib.setup[SETUP_NOVIDEO]) | |
210 {char tmp[100]; | |
211 sprintf(tmp,"* pwplib now controls a %d x %d framebuffer\n", | |
212 pwplib.videobuf.width,pwplib.videobuf.height); | |
213 pwpwrite(tmp); | |
214 } | |
215 # endif | |
216 | |
217 return 1; | |
218 } | |
219 | |
220 /************************************/ | |
221 | |
222 const char*pwplogo= | |
223 "\033[2J\033[H\n" | |
224 " \033[36;46mMMmmmmmmMM\033[0m\n" | |
225 " \033[36;46mMM\033[0m\n" | |
226 " \033[31;41mxxxxxxxxxxxx\033[0m\n" | |
227 " \033[31;41mxxxxxxxxxxxxxxxxxxx\033[0m\n" | |
228 " \033[31;41mxxxxxxxxx\033[0m\n" | |
229 " \033[33;43mZZZZZ\033[34;44m....\033[0m %%%%%%%%% %%% %%% %%%%%%%%%\n" | |
230 " \033[37;47m@@@@\033[34;44m......\033[0m %%%%%%%%%. %%%....... %%%. %%%%%%%%%....\n" | |
231 " \033[37;47m@@@@\033[34;44m....\033[37mo\033[34m.\033[0m .....%%% %%% %%% %%% %%% %%% %%%\n" | |
232 " \033[37;47m@@@@@@@\033[34;44m....\033[0m %%% %%% %%% %%% %%% %%% %%%\n" | |
233 " \033[37;47m@@@@@@@@@@@\033[0m %%%% %%% %%% %%% %%% %%%% %%%\n" | |
234 " \033[37;47m@@@@@@@@@@@@@\033[0m %%%% %%% %%% %%% %%% %%%% %%%\n" | |
235 " \033[37;47m@@@@@@@@@@@@@@@\033[0m %%%%%%%%% %%% %%% %%% %%%%%%%%%\n" | |
236 " \033[37;47m@@@@\033[0m %%%%%%%%% %%% %%% %%% %%%%%%%%%\n" | |
237 " \033[37;47m@@@@@@\033[0m %%% %%%%% %%% %%% %%%\n" | |
238 " \033[37;47m@@@@@@@@@@\033[0m \033[31;41mxx\033[0m %%% %%%%% %%% %%% %%%\n" | |
239 " \033[37;47m@@@@@@@@@@@@@@\033[0m %%% %%%%% %%%% %%% %%%\n" | |
240 " \033[37;47m@@@@@@@@@@@\033[0m %%% %%%%% %%%% %%% %%%\n" | |
241 " \033[37;47m@@@@@@@@@\033[0m .....%%%....... %%%%%%%%%%%%%%. %%%..........\n" | |
242 " \033[37;47m@@@@@\033[0m %%% %%%%%%%%%%%%%% %%%\n" | |
243 " \033[37;47m@@@@\033[0m\n\n"; | |
244 | |
245 | |
246 void pwplib_startup() | |
247 { | |
248 if(!pwplib.setup[SETUP_SHUTUP]) | |
249 { | |
250 pwpwrite("starting up.... 2sec delay for ^C"); | |
251 sleep(2); | |
252 } | |
253 | |
254 /* send initstuff? */ | |
255 } | |
256 | |
257 void pwplib_end() | |
258 { | |
259 if(pwplib.setup[SETUP_SHUTUP])return; | |
260 | |
261 pwplib_shutdown(); | |
262 sleep(2); | |
263 | |
264 fputs(pwplogo,stderr); | |
265 pwpwrite("shutting down multimedia subsystems\n" | |
266 "operation finished - support pwp\n\n\n"); | |
267 } | |
268 | |
269 /***************************************************************/ | |
270 | |
271 int pwplib_init(int argc,char**argv) | |
272 { | |
273 int i=0,quit=0; | |
274 | |
275 pwplib.argc=argc; | |
276 pwplib.argv=argv; | |
277 | |
278 pwplib_getopts(); | |
279 | |
280 if(pwplib.setup[SETUP_WANTHELP]) | |
281 { | |
282 printhelp(); | |
283 exit(0); | |
284 pwplib.setup[SETUP_SHUTUP]++; | |
285 } | |
286 | |
287 if(!pwplib.setup[SETUP_SHUTUP]) | |
288 { | |
289 fputs(pwplogo,stderr); | |
290 pwpwrite("pwplib " PWPLIB_VERSION " initializing..\n\nrun with --help for some options\n\n"); | |
291 } | |
292 | |
293 {char buf[40]; | |
294 sprintf(buf,"* using locale '%s'\n",pwplib.set.lang); | |
295 pwpwrite(buf); | |
296 } | |
297 | |
298 if(!pwplib_initcore()) | |
299 { | |
300 pwpwrite("initialization failed!\n"); | |
301 return 0; | |
302 } | |
303 | |
304 if(pwplib.setup[SETUP_WANTHELP]) | |
305 return 0; | |
306 | |
307 return 1; | |
308 } |