Main Page | Data Structures | Directories | File List | Data Fields | Globals

splash.c File Reference

#include "lcconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "lcstring.h"
#include "common.h"
#include "lctypes.h"
#include "lin-city.h"
#include "cliglobs.h"
#include "engglobs.h"
#include "screen.h"
#include "fileutil.h"

Go to the source code of this file.

Defines

#define SI_BLACK   252
#define SI_RED   253
#define SI_GREEN   254
#define SI_YELLOW   255

Functions

void load_start_image (void)
void start_image_text (void)
void si_scroll_text (void)
char si_next_char (FILE *inf)


Define Documentation

#define SI_BLACK   252
 

Definition at line 30 of file splash.c.

#define SI_GREEN   254
 

Definition at line 32 of file splash.c.

#define SI_RED   253
 

Definition at line 31 of file splash.c.

#define SI_YELLOW   255
 

Definition at line 33 of file splash.c.


Function Documentation

void load_start_image void   ) 
 

Definition at line 49 of file splash.c.

00050 {
00051 #ifdef LC_X11
00052   XColor pal[256];
00053   XEvent xev;
00054 #endif
00055   long x, y, l, r, g, b;
00056   FILE *fp;
00057 
00058   fp = fopen_read_gzipped (opening_pic);
00059   if (fp == NULL) {
00060       return;
00061   }
00062 
00063   for (x = 0; x < 7; x++)
00064     l = fgetc (fp);
00065   l &= 0xff;
00066   if (l == 0)
00067     l = 256;
00068   for (x = 0; x < l; x++)
00069     {
00070       r = fgetc (fp);
00071       g = fgetc (fp);
00072       b = fgetc (fp);
00073 #ifdef LC_X11
00074       pal[x].red = r;
00075       pal[x].green = g;
00076       pal[x].blue = b;
00077       pal[x].flags = DoRed | DoGreen | DoBlue;
00078 #else
00079       gl_setpalettecolor (x, r, g, b);
00080 #endif
00081     }
00082   /* use last 4 colours for text */
00083 #ifdef LC_X11
00084   pal[SI_BLACK].red = 0;
00085   pal[SI_BLACK].green = 0;
00086   pal[SI_BLACK].blue = 0;
00087   pal[SI_BLACK].flags = DoRed | DoGreen | DoBlue;
00088   pal[SI_RED].red = 60;
00089   pal[SI_RED].green = 0;
00090   pal[SI_RED].blue = 0;
00091   pal[SI_RED].flags = DoRed | DoGreen | DoBlue;
00092   pal[SI_GREEN].red = 0;
00093   pal[SI_GREEN].green = 60;
00094   pal[SI_GREEN].blue = 0;
00095   pal[SI_GREEN].flags = DoRed | DoGreen | DoBlue;
00096   pal[SI_YELLOW].red = 60;
00097   pal[SI_YELLOW].green = 60;
00098   pal[SI_YELLOW].blue = 0;
00099   pal[SI_YELLOW].flags = DoRed | DoGreen | DoBlue;
00100   open_setcustompalette (pal);
00101   suppress_next_expose = 1;
00102   do
00103     {
00104       while (XPending (display.dpy) == 0);
00105       XNextEvent (display.dpy, &xev);
00106       HandleEvent (&xev);
00107     }
00108   while (xev.type != MapNotify);
00109 
00110 #else
00111   gl_setpalettecolor (SI_BLACK, 0, 0, 0);
00112   gl_setpalettecolor (SI_RED, 60, 0, 0);
00113   gl_setpalettecolor (SI_GREEN, 0, 60, 0);
00114   gl_setpalettecolor (SI_YELLOW, 60, 60, 0);
00115 #endif
00116 #if defined (WIN32)
00117   UpdatePalette ();
00118 #endif
00119   for (y = 0; y < 480; y++)
00120     for (x = 0; x < 640; x++)
00121       {
00122         l = fgetc (fp);
00123         /*
00124            //      printf("l=%d x=%d y=%d ",l,x,y);
00125            // octree doesn't seem to want to generate images with 252 colours!
00126            // So the next best thing (well the easyest) is to just map the pixels
00127            // coloured as the last 4 colours to the 4 before that.
00128            // If it looks OK, leave it.
00129          */
00130         if (l == SI_BLACK)
00131           l = SI_BLACK - 4;
00132         if (l == SI_RED)
00133           l = SI_RED - 4;
00134         if (l == SI_GREEN)
00135           l = SI_GREEN - 4;
00136         if (l == SI_YELLOW)
00137           l = SI_YELLOW - 4;
00138         Fgl_setpixel (x, y, l);
00139       }
00140 
00141   fclose_read_gzipped (fp);
00142 
00143 #if defined (WIN32)
00144   RefreshScreen ();
00145 #endif
00146   start_image_text ();
00147 }

char si_next_char FILE *  inf  ) 
 

Definition at line 287 of file splash.c.

00288 {
00289   char c;
00290   if (feof (inf) != 0)
00291     fseek (inf, 0L, SEEK_SET);
00292   c = fgetc (inf);
00293   if (c == 0xa || c == 0xd)
00294     c = ' ';
00295   return (c);
00296 }

void si_scroll_text void   ) 
 

Definition at line 164 of file splash.c.

00165 {
00166   char s[LC_PATH_MAX], line1[100], line2[100], line3[100], c;
00167   int i, t, l1c = 0, l2c = 0, l3c = 0;
00168   FILE *inf1, *inf2, *inf3;
00169 #ifdef LC_X11
00170   XEvent xev;
00171 #endif
00172   Fgl_enableclipping ();
00173   sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "text1");
00174   if ((inf1 = fopen (s, "rb")) == NULL)
00175     do_error ("Can't open opening/text1");
00176   for (i = 0; i < 52; i++)
00177     line1[i] = si_next_char (inf1);
00178   line1[52] = 0;
00179   sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "text2");
00180   if ((inf2 = fopen (s, "rb")) == NULL)
00181     do_error ("Can't open opening/text2");
00182   for (i = 0; i < 52; i++)
00183     line2[i] = si_next_char (inf2);
00184   line2[52] = 0;
00185   sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "text3");
00186   if ((inf3 = fopen (s, "rb")) == NULL)
00187     do_error ("Can't open opening/text3");
00188   for (i = 0; i < 52; i++)
00189     line3[i] = si_next_char (inf3);
00190   line3[52] = 0;
00191   do
00192     {
00193       get_real_time ();
00194       t = real_time + SPLASH_SCROLL_DELAY;
00195 #ifdef LC_X11
00196       if (XPending (display.dpy))
00197 
00198         {
00199           XNextEvent (display.dpy, &xev);
00200           HandleEvent (&xev);
00201         }
00202 
00203       c = x_key_value;
00204 #elif defined (WIN32)
00205       c = GetKeystroke ();
00206 #else
00207       c = vga_getkey ();
00208 #endif
00209       if (l1c >= 8)
00210         {
00211           for (i = 0; i < 51; i++)
00212             line1[i] = line1[i + 1];
00213           line1[51] = si_next_char (inf1);
00214           l1c = 0;
00215         }
00216       Fgl_setfont (8, 8, start_font1);
00217       Fgl_setclippingwindow (120, 30, 520, 40);
00218       Fgl_setfontcolors (SI_BLACK, SI_RED);
00219 #if defined (LC_X11) || defined (WIN32)
00220       open_write (120 - l1c, 31, line1);
00221 #else
00222       Fgl_write (120 - l1c, 31, line1);
00223 #endif
00224       l1c++;
00225 
00226       if (l2c >= 8)
00227         {
00228           for (i = 0; i < 51; i++)
00229             line2[i] = line2[i + 1];
00230           line2[51] = si_next_char (inf2);
00231           l2c = 0;
00232         }
00233       Fgl_setfont (8, 16, start_font2);
00234       Fgl_setclippingwindow (120, 55, 520, 73);
00235       Fgl_setfontcolors (SI_BLACK, SI_GREEN);
00236 #if defined (LC_X11) || defined (WIN32)
00237       open_write (120 - l2c, 57, line2);
00238 #else
00239       Fgl_write (120 - l2c, 57, line2);
00240 #endif
00241       l2c += 2;
00242 
00243       if (l3c >= 8)
00244         {
00245           for (i = 0; i < 51; i++)
00246             line3[i] = line3[i + 1];
00247           line3[51] = si_next_char (inf3);
00248           l3c = 0;
00249         }
00250       Fgl_setfont (8, 16, start_font3);
00251       Fgl_setclippingwindow (120, 88, 520, 106);
00252       Fgl_setfontcolors (SI_BLACK, SI_YELLOW);
00253 #if defined (LC_X11) || defined (WIN32)
00254       open_write (120 - l3c, 90, line3);
00255 #else
00256       Fgl_write (120 - l3c, 90, line3);
00257 #endif
00258       l3c += 2;
00259 #if defined (WIN32)             /* Scroll a little faster for WIN32 */
00260       if (pix_double)
00261         {
00262           l1c += 10;
00263           l2c += 10;
00264           l3c += 10;
00265         }
00266       else
00267         {
00268           l1c += 2;
00269           l2c += 4;
00270           l3c += 4;
00271         }
00272 #endif
00273       while (real_time < t)
00274         {
00275           lc_usleep (1);
00276           get_real_time ();
00277         }
00278     }
00279   while (c == 0);
00280   fclose (inf1);
00281   fclose (inf2);
00282   fclose (inf3);
00283   Fgl_disableclipping ();
00284 }

void start_image_text void   ) 
 

Definition at line 150 of file splash.c.

00151 {
00152 #if defined (SVGALIB)
00153   gl_setwritemode (FONT_COMPRESSED);
00154 #endif
00155   Fgl_setfont (8, 8, start_font1);
00156 #if defined (SVGALIB)
00157   gl_setwritemode (FONT_COMPRESSED);
00158 #endif
00159   Fgl_setfontcolors (SI_BLACK, SI_RED);
00160   si_scroll_text ();
00161 }


Generated on Sun Dec 26 11:23:42 2004 for lincity by  doxygen 1.3.9.1