+ if(demo_init1(argc, argv) == -1) {
+ return -1;
+ }
+ if(demo_init2() == -1) {
+ return -1;
+ }
+ return 0;
+}
+
+static struct screen *scr;
+
+int demo_init1(int argc, char **argv)
+{
+ char *env;
+
+ if(load_config("demo.cfg") == -1) {
+ return -1;
+ }
+ if((env = getenv("START_SCR"))) {
+ opt.start_scr = env;
+ }
+ if(parse_args(argc, argv) == -1) {
+ return -1;
+ }
+ return 0;
+}
+
+int demo_init2(void)
+{
+ con_init();
+ initFpsFonts();
+
+ if(g3d_init() == -1) {
+ return -1;
+ }
+ g3d_framebuffer(FB_WIDTH, FB_HEIGHT, fb_pixels);
+
+ if(opt.music) {
+ if(!(mod = au_load_module("data/test.mod"))) {
+ return -1;
+ }
+ }
+
+ if(scr_init() == -1) {
+ return -1;
+ }
+
+ if(opt.start_scr) {
+ scr = scr_lookup(opt.start_scr);
+ } else {
+ scr = scr_screen(0);
+ }
+
+ if(!scr || scr_change(scr, 4000) == -1) {
+ fprintf(stderr, "screen %s not found\n", opt.start_scr ? opt.start_scr : "0");
+ return -1;
+ }
+
+ /* clear the framebuffer at least once */
+ memset(fb_pixels, 0, FB_WIDTH * FB_HEIGHT * FB_BPP / CHAR_BIT);
+
+ if(opt.music) {
+ au_play_module(mod);
+ }