home *** CD-ROM | disk | FTP | other *** search
/ Game Hack 1 / GHM01.ZIP / GH1TITLE.PAS < prev    next >
Pascal/Delphi Source File  |  1994-11-27  |  7KB  |  182 lines

  1. Program GameNotes2Cover;
  2.  
  3. Uses CRT,DOS,XUnit;
  4.  
  5. Type
  6.   ColType=Array [0..239] of Byte;
  7.   TimeRec=Record
  8.     H,M,S,S100:Word;
  9.   End;
  10.  
  11. Var
  12.   CurrentRGB:RGB;
  13.   PaletteBuf,PaletteSave:PaletteRegType;
  14.   I,X,Y,NewINdex:Integer;
  15.   OneByte:Byte;
  16.   InFile:File of ColType;
  17.   ColBuf:ColType;
  18.   STime,CTime:TimeRec;      {Start time, Current Time}
  19.   StartSecs,EndSecs,DisplayTime:LongInt;
  20.   StopNow:Boolean;
  21.   ErrCode,LastCount:Integer;
  22.   LastCountText:String;
  23.   MonthStr:String;
  24.   OneKey:Char;
  25.  
  26. Begin
  27.   Val(ParamStr(1),DisplayTime,ErrCode); {Get command line parameter, time}
  28.   If ErrCode<>0 then DisplayTime:=15; {If bad or no time entered, 15 secs}
  29.   If DisplayTime>999 then DisplayTime:=999; {>999 seconds not allowed}
  30.   StopNow:=False;
  31.   XRGB2Buf(PaletteBuf); {Read default palette set into PaletteBuf variable}
  32.   PaletteSave:=PaletteBuf; {Save palettes for restoring later}
  33.   {Do not put the following before RGB2Buf or it will not function
  34.   correctly on STB PowerGraph cards.}
  35.   MonthStr:=ParamStr(2);
  36.   MonthStr:=MonthStr+' 1994';
  37.   XSet320x240Mode; {Set screen to X-mode}
  38.  
  39.   {This For loop sets up palettes. There's no magic here, I just fooled
  40.   around with the values I'm assigning 'til I thought it looked pretty.
  41.   Note that only palettes 32 to 255 are being assigned. This is because
  42.   palettes 0-31 will be used for colors which do not change, while palettes
  43.   32-255 will be altered to animate the display.}
  44.   For I:=32 to 255 do
  45.   Begin
  46.     PaletteBuf[I].Red:=I div 2;
  47.     PaletteBuf[I].Blu:=I div 4;
  48.     PaletteBuf[I].Grn:=I;
  49.   End;
  50.  
  51.   XBuf2RGB(PaletteBuf); {Write the palettes to VGA}
  52.   Assign(InFile,'PLASPIC.DAT'); {Read the plasma bitmap}
  53.   {$I-}
  54.   Reset(InFile);
  55.   {$I+}
  56.   If IOResult<>0 then {couldn't find the file}
  57.   Begin
  58.     XSet80x25Mode; {go back to text mode before displaying message}
  59.     WriteLn('File PLASPIC.DAT must be in the same directory as GH1TITLE.EXE.');
  60.     WriteLn('Program halted. Hit <CR> to continue.');
  61.     ReadLn;
  62.     Halt(0); {Stop the program}
  63.   End;
  64.   For X:=0 to 319 do {For each screen column ...}
  65.   Begin
  66.     Read(InFile,ColBuf); { ... read in 1 column of data from file ... }
  67.     For Y:=0 to 239 do XPutPix(X,Y,0,ColBuf[Y]); { ... and draw it.}
  68.   End;
  69.   Close(InFile); {Close bitmap file, we're done with it.}
  70.  
  71.   { Now we're done with the plasma bitmap and we need to draw the text
  72.   and non-animated parts of the screen. }
  73.   XFillRect(9,9,146,81,0,0); {Black rect, 1 pixel bigger per edge than ...}
  74.   XFillRect(10,10,145,80,0,1); { ... this blue rectangle. "GAME HACK" will
  75.                             be drawn in this blue area with a black border.}
  76.   XFillRect(19,199,301,236,0,0); {Black rect, 1 pix bigger per edge than ...}
  77.   XFillRect(20,200,300,235,0,1); { ... this blue rectangle. Text and prompt
  78.                    will be drawn inside this blue area with a black border.}
  79.  
  80.   {The next group of commands draws all the text on the screen}
  81.   XWriteDrop(4,15,40,'GAME',0,127,0); {Note scaling of 4}
  82.   XWriteDrop(4,15,75,'HACK',0,63,0);
  83.   XWriteDrop(1,234,25,'ISSUE # 1',0,15,0);
  84.   XWriteDrop(1,306-Length(MonthStr)*8,15,MonthStr,0,15,0);
  85.   XWriteCenterDrop(1,210,'AN ELECTRONIC MAGAZINE PUBLISHED',0,15,0);
  86.   XWriteCenterDrop(1,220,'BY VISUAL IMPACT SOFTWARE',0,15,0);
  87.   If DisplayTime=0 then
  88.     XWriteCenterDrop(1,230,'HIT A KEY TO CONTINUE',0,15,0) else
  89.     XWriteCenterDrop(1,230,'HIT A KEY TO CONTINUE OR WAIT 000',0,15,0);
  90.  
  91.   {Now let's animate the display by messing with the palettes.}
  92.  
  93.   With STime do
  94.   Begin
  95.     GetTime(H,M,S,S100); {Find the current time}
  96.     StartSecs:=H*3600+M*60+S; {Calc start time in seconds}
  97.   End;
  98.   NewIndex:=0; {Just a variable to increment}
  99.   Repeat {Continue the animation}
  100.     Inc(NewIndex);
  101.     For I:=32 to 255 do {Calculate a new set of palette colors}
  102.     Begin
  103.       PaletteBuf[I].Red:=(I+NewIndex) div 2;
  104.       PaletteBuf[I].Blu:=(I+NewIndex) div 4;
  105.       PaletteBuf[I].Grn:=(I+NewIndex);
  106.     End;
  107.     XBuf2RGB(PaletteBuf); {Write the new palette set to VGA}
  108.     If NewIndex=255 then NewIndex:=0;
  109.     With CTime do
  110.     Begin
  111.       GetTime(H,M,S,S100); {Get the current time}
  112.       EndSecs:=H*3600+M*60+S;   {Calc current time in seconds}
  113.     End;
  114.     {The next statement adjusts for the rare midnight-crossing}
  115.     If EndSecs-StartSecs<0 then StartSecs:=StartSecs-86400;
  116.     If EndSecs-StartSecs>DisplayTime then StopNow:=True;
  117.     If LastCount<>DisplayTime-EndSecs+StartSecs then {Secs changed, redraw}
  118.     Begin {As a completely frivolous exercise, show the countdown}
  119.       XFillRect(262,224,292,232,0,1); {Blank countdown text}
  120.       LastCount:=DisplayTime-EndSecs+StartSecs; {Substitute new count}
  121.       Str(LastCount,LastCountText); {Convert to string for WriteDrop}
  122.       While Length(LastCountText)<3
  123.         do LastCountText:='0'+LastCountText; {Pad 0's}
  124.       If (LastCount<>-1) and (DisplayTime>0) then
  125.         XWriteDrop(1,268,230,LastCountText,0,15,0); {write it to the screen}
  126.     End;
  127.     If DisplayTime=0 then StopNow:=False; {If DisplayTime=0, no time limit}
  128.   Until KeyPressed or StopNow; {Until the user presses a key}
  129.   If not StopNow then Repeat OneKey:=ReadKey Until not KeyPressed;
  130.     {Flush keyboard buffer}
  131.   XBuf2RGB(PaletteSave); {Restore palettes to their entry values}
  132.   XSet80x25Mode; {Go back to text mode}
  133.   TextBackGround(Black);
  134.   {Write credits screen}
  135.   ClrScr;
  136.   TextBackGround(Green);
  137.   TextColor(White);
  138.   WriteLn('                             About the cover art ...                           ');
  139.   TextColor(White);
  140.   TextBackGround(Black);
  141.   WriteLn;
  142.   WriteLn('GAME HACK Issue # 1 Mode-X animated cover by Fred Trafton.');
  143.   WriteLn;
  144.   WriteLn('640x480 plasma created by IMPROCES, read by Sean Wetzel''s GIFPAS Pascal');
  145.   WriteLn('unit, then translated to 320x240 X-mode bitmap by Fred Trafton.');
  146.   WriteLn;
  147.   WriteLn('Sean Wetzel''s GIFPAS unit can be downloaded from the CompuServe Borland Pascal');
  148.   WriteLn('Forum. Type GO BPASCAL from the CompuServe prompt. IMPROCES can be downloaded');
  149.   WriteLn('from the Graphics Support Forum, type GO GRAPHSUP from the CompuServe prompt.');
  150.   WriteLn('The Mode X assembly routines are heavily based upon Michael Abrash''s articles');
  151.   WriteLn('in Dr. Dobb''s Journal on the subject, and were modified by me for use with');
  152.   WriteLn('Borland Pascal rather than C.');
  153.   WriteLn;
  154.   WriteLn('Source code for this cover is included in this issue.');
  155.   WriteLn;
  156.   TextColor(Magenta);
  157.   WriteLn('Hit any key to read GAME HACK Issue # 1 ...');
  158.   With STime do
  159.   Begin
  160.     GetTime(H,M,S,S100); {Find the current time}
  161.     StartSecs:=H*3600+M*60+S; {Calc start time in seconds}
  162.   End;
  163.   StopNow:=False;
  164.   Repeat
  165.     With CTime do
  166.     Begin
  167.       GetTime(H,M,S,S100); {Get the current time}
  168.       EndSecs:=H*3600+M*60+S;   {Calc current time in seconds}
  169.     End;
  170.     {The next statement adjusts for the rare midnight-crossing}
  171.     If EndSecs-StartSecs<0 then StartSecs:=StartSecs-86400;
  172.     If EndSecs-StartSecs>DisplayTime then StopNow:=True;
  173.     If DisplayTime=0 then StopNow:=False;
  174.   Until KeyPressed or StopNow;
  175.   If not StopNow then Repeat OneKey:=ReadKey Until not KeyPressed;
  176.   TextColor(LightGray);
  177.   TextBackground(Black);
  178.   ClrScr;
  179. End.
  180.  
  181.  
  182.