*** empty log message ***
authorMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 8 Jan 2007 03:36:30 +0000 (03:36 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Mon, 8 Jan 2007 03:36:30 +0000 (03:36 +0000)
13 files changed:
mmsoftware/paradise_adventure/mus/adventure1.ogg [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/adventure1.readme [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/aria_prima.ogg [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/aria_prima.readme [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/castle.ogg [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/castle.readme [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/cavern.ogg [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/cavern.readme [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/forest.ogg [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/forest.readme [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/store.ogg [new file with mode: 0644]
mmsoftware/paradise_adventure/mus/store.readme [new file with mode: 0644]
mmsoftware/paradise_adventure/src/main.c

diff --git a/mmsoftware/paradise_adventure/mus/adventure1.ogg b/mmsoftware/paradise_adventure/mus/adventure1.ogg
new file mode 100644 (file)
index 0000000..56d5a24
Binary files /dev/null and b/mmsoftware/paradise_adventure/mus/adventure1.ogg differ
diff --git a/mmsoftware/paradise_adventure/mus/adventure1.readme b/mmsoftware/paradise_adventure/mus/adventure1.readme
new file mode 100644 (file)
index 0000000..618cb43
--- /dev/null
@@ -0,0 +1 @@
+Copyright (c) 1989, 2007, Matthew Mondor
diff --git a/mmsoftware/paradise_adventure/mus/aria_prima.ogg b/mmsoftware/paradise_adventure/mus/aria_prima.ogg
new file mode 100644 (file)
index 0000000..6f18829
Binary files /dev/null and b/mmsoftware/paradise_adventure/mus/aria_prima.ogg differ
diff --git a/mmsoftware/paradise_adventure/mus/aria_prima.readme b/mmsoftware/paradise_adventure/mus/aria_prima.readme
new file mode 100644 (file)
index 0000000..b02c0cd
--- /dev/null
@@ -0,0 +1 @@
+Copyright (c) 2007, Christiane Locas
diff --git a/mmsoftware/paradise_adventure/mus/castle.ogg b/mmsoftware/paradise_adventure/mus/castle.ogg
new file mode 100644 (file)
index 0000000..cc02fc2
Binary files /dev/null and b/mmsoftware/paradise_adventure/mus/castle.ogg differ
diff --git a/mmsoftware/paradise_adventure/mus/castle.readme b/mmsoftware/paradise_adventure/mus/castle.readme
new file mode 100644 (file)
index 0000000..618cb43
--- /dev/null
@@ -0,0 +1 @@
+Copyright (c) 1989, 2007, Matthew Mondor
diff --git a/mmsoftware/paradise_adventure/mus/cavern.ogg b/mmsoftware/paradise_adventure/mus/cavern.ogg
new file mode 100644 (file)
index 0000000..ea522a7
Binary files /dev/null and b/mmsoftware/paradise_adventure/mus/cavern.ogg differ
diff --git a/mmsoftware/paradise_adventure/mus/cavern.readme b/mmsoftware/paradise_adventure/mus/cavern.readme
new file mode 100644 (file)
index 0000000..618cb43
--- /dev/null
@@ -0,0 +1 @@
+Copyright (c) 1989, 2007, Matthew Mondor
diff --git a/mmsoftware/paradise_adventure/mus/forest.ogg b/mmsoftware/paradise_adventure/mus/forest.ogg
new file mode 100644 (file)
index 0000000..7caeb27
Binary files /dev/null and b/mmsoftware/paradise_adventure/mus/forest.ogg differ
diff --git a/mmsoftware/paradise_adventure/mus/forest.readme b/mmsoftware/paradise_adventure/mus/forest.readme
new file mode 100644 (file)
index 0000000..edb5385
--- /dev/null
@@ -0,0 +1 @@
+Copyright (c) 2007, Martin Mondor
diff --git a/mmsoftware/paradise_adventure/mus/store.ogg b/mmsoftware/paradise_adventure/mus/store.ogg
new file mode 100644 (file)
index 0000000..40f6901
Binary files /dev/null and b/mmsoftware/paradise_adventure/mus/store.ogg differ
diff --git a/mmsoftware/paradise_adventure/mus/store.readme b/mmsoftware/paradise_adventure/mus/store.readme
new file mode 100644 (file)
index 0000000..f0cb77a
--- /dev/null
@@ -0,0 +1 @@
+Copyright (c) 2007, Matthew Mondor
index a690c31..79ab7cc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.3 2007/01/07 09:26:43 mmondor Exp $ */
+/* $Id: main.c,v 1.4 2007/01/08 03:36:30 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
 
 int                    main(int, char **);
 
+static int             painting_switch(const char *);
+static int             music_switch(const char *);
+static void            frame_draw(void);
+
 
 
 /* PUBLIC GLOBALS */
@@ -76,6 +80,20 @@ main(int argc, char **argv)
        (void) SDL_EventState(SDL_KEYUP, SDL_IGNORE);
 
        /*
+        * System images
+        */
+       if ((img_border = IMG_Load("img/screen_borders.png")) == NULL) {
+               (void) fprintf(stderr, "main() - IMG_Load(border) - %s\n",
+                   IMG_GetError());
+               exit(EXIT_FAILURE);
+       }
+       if ((img_textarea = IMG_Load("img/screen_textarea.png")) == NULL) {
+               (void) fprintf(stderr, "main() - IMG_Load(textarea) - %s\n",
+                   IMG_GetError());
+               exit(EXIT_FAILURE);
+       }
+
+       /*
         * Audio
         */
        if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) != 0) {
@@ -85,16 +103,10 @@ main(int argc, char **argv)
        }
        (void) Mix_AllocateChannels(4);
        (void) Mix_ReserveChannels(2);
-       if ((music = Mix_LoadMUS("mus/1.ogg")) == NULL) {
-               (void) fprintf(stderr, "main() - Mix_LoadMUS() - %s\n",
-                   Mix_GetError());
-               exit(EXIT_FAILURE);
-       }
-       if (Mix_PlayMusic(music, -1) != 0) {
-               (void) fprintf(stderr, "main() - Mix_PlayMusic() - %s\n",
-                   Mix_GetError());
-               exit(EXIT_FAILURE);
-       }
+
+       /* XXX */
+       music_switch("1");
+       painting_switch("gardens_smallbridge");
 
        /*
         * Main loop.
@@ -102,6 +114,7 @@ main(int argc, char **argv)
        while (!main_quit) {
                SDL_Event       ev;
 
+               frame_draw();
                (void) SDL_WaitEvent(NULL);
                while (SDL_PollEvent(&ev)) {
                        switch (ev.type) {
@@ -118,3 +131,95 @@ main(int argc, char **argv)
 
        exit(EXIT_SUCCESS);
 }
+
+static int
+painting_switch(const char *f)
+{
+       SDL_Surface     *s = NULL;
+       char            path[1024], *str = NULL;
+
+       ASSERT(f != NULL);
+
+       /* If image already current avoid reloading */
+       if (painting_file != NULL && strcasecmp(f, painting_file) == 0)
+               return 0;
+
+       (void) snprintf(path, 1023, "img/%s.png", f);
+       if ((s = IMG_Load(path)) != NULL && (str = strdup(f)) != NULL) {
+               if (img_painting != NULL)
+                       SDL_FreeSurface(img_painting);
+               img_painting = s;
+               if (painting_file != NULL)
+                       free(painting_file);
+               painting_file = str;
+
+               return 0;
+       }
+
+       if (s != NULL)
+               SDL_FreeSurface(s);
+       if (str != NULL)
+               free(str);
+
+       return -1;
+}
+
+static int
+music_switch(const char *f)
+{
+       Mix_Music       *m = NULL;
+       char            path[1024], *str = NULL;
+       int             ret = -1;
+
+       ASSERT(f != NULL);
+
+       /* If music already current avoid reloading */
+       if (music_file != NULL && strcasecmp(f, music_file) == 0)
+               return 0;
+
+       /* Fadeout and stop old music */
+       (void) Mix_FadeOutMusic(1000);
+       SDL_Delay(1000);
+       (void) Mix_HaltMusic();
+
+       (void) snprintf(path, 1023, "mus/%s.ogg", f);
+       if ((m = Mix_LoadMUS(path)) != NULL && (str = strdup(f)) != NULL) {
+               if (music != NULL)
+                       Mix_FreeMusic(music);
+               music = m;
+               if (music_file != NULL)
+                       free(music_file);
+               music_file = str;
+
+               m = NULL;
+               str = NULL;
+               ret = 0;
+       }
+
+       if (m != NULL)
+               Mix_FreeMusic(m);
+       if (str != NULL)
+               free(str);
+
+       if (Mix_PlayMusic(music, -1) != 0) {
+               (void) fprintf(stderr, "music_switch() - Mix_PlayMusic() - %s",
+                   Mix_GetError());
+               ret = -1;
+       }
+
+       return ret;
+}
+
+void
+frame_draw(void)
+{
+       SDL_Rect        r;
+
+       (void) SDL_BlitSurface(img_border, NULL, screen_surface, NULL);
+       r = (struct SDL_Rect){ 798, 16, 0, 0 };
+       (void) SDL_BlitSurface(img_textarea, NULL, screen_surface, &r);
+       r = (struct SDL_Rect){ 16, 16, 0, 0 };
+       (void) SDL_BlitSurface(img_painting, NULL, screen_surface, &r);
+
+       (void) SDL_Flip(screen_surface);
+}