home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Hack 1
/
GHM01.ZIP
/
GH1TITLE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-11-27
|
7KB
|
182 lines
Program GameNotes2Cover;
Uses CRT,DOS,XUnit;
Type
ColType=Array [0..239] of Byte;
TimeRec=Record
H,M,S,S100:Word;
End;
Var
CurrentRGB:RGB;
PaletteBuf,PaletteSave:PaletteRegType;
I,X,Y,NewINdex:Integer;
OneByte:Byte;
InFile:File of ColType;
ColBuf:ColType;
STime,CTime:TimeRec; {Start time, Current Time}
StartSecs,EndSecs,DisplayTime:LongInt;
StopNow:Boolean;
ErrCode,LastCount:Integer;
LastCountText:String;
MonthStr:String;
OneKey:Char;
Begin
Val(ParamStr(1),DisplayTime,ErrCode); {Get command line parameter, time}
If ErrCode<>0 then DisplayTime:=15; {If bad or no time entered, 15 secs}
If DisplayTime>999 then DisplayTime:=999; {>999 seconds not allowed}
StopNow:=False;
XRGB2Buf(PaletteBuf); {Read default palette set into PaletteBuf variable}
PaletteSave:=PaletteBuf; {Save palettes for restoring later}
{Do not put the following before RGB2Buf or it will not function
correctly on STB PowerGraph cards.}
MonthStr:=ParamStr(2);
MonthStr:=MonthStr+' 1994';
XSet320x240Mode; {Set screen to X-mode}
{This For loop sets up palettes. There's no magic here, I just fooled
around with the values I'm assigning 'til I thought it looked pretty.
Note that only palettes 32 to 255 are being assigned. This is because
palettes 0-31 will be used for colors which do not change, while palettes
32-255 will be altered to animate the display.}
For I:=32 to 255 do
Begin
PaletteBuf[I].Red:=I div 2;
PaletteBuf[I].Blu:=I div 4;
PaletteBuf[I].Grn:=I;
End;
XBuf2RGB(PaletteBuf); {Write the palettes to VGA}
Assign(InFile,'PLASPIC.DAT'); {Read the plasma bitmap}
{$I-}
Reset(InFile);
{$I+}
If IOResult<>0 then {couldn't find the file}
Begin
XSet80x25Mode; {go back to text mode before displaying message}
WriteLn('File PLASPIC.DAT must be in the same directory as GH1TITLE.EXE.');
WriteLn('Program halted. Hit <CR> to continue.');
ReadLn;
Halt(0); {Stop the program}
End;
For X:=0 to 319 do {For each screen column ...}
Begin
Read(InFile,ColBuf); { ... read in 1 column of data from file ... }
For Y:=0 to 239 do XPutPix(X,Y,0,ColBuf[Y]); { ... and draw it.}
End;
Close(InFile); {Close bitmap file, we're done with it.}
{ Now we're done with the plasma bitmap and we need to draw the text
and non-animated parts of the screen. }
XFillRect(9,9,146,81,0,0); {Black rect, 1 pixel bigger per edge than ...}
XFillRect(10,10,145,80,0,1); { ... this blue rectangle. "GAME HACK" will
be drawn in this blue area with a black border.}
XFillRect(19,199,301,236,0,0); {Black rect, 1 pix bigger per edge than ...}
XFillRect(20,200,300,235,0,1); { ... this blue rectangle. Text and prompt
will be drawn inside this blue area with a black border.}
{The next group of commands draws all the text on the screen}
XWriteDrop(4,15,40,'GAME',0,127,0); {Note scaling of 4}
XWriteDrop(4,15,75,'HACK',0,63,0);
XWriteDrop(1,234,25,'ISSUE # 1',0,15,0);
XWriteDrop(1,306-Length(MonthStr)*8,15,MonthStr,0,15,0);
XWriteCenterDrop(1,210,'AN ELECTRONIC MAGAZINE PUBLISHED',0,15,0);
XWriteCenterDrop(1,220,'BY VISUAL IMPACT SOFTWARE',0,15,0);
If DisplayTime=0 then
XWriteCenterDrop(1,230,'HIT A KEY TO CONTINUE',0,15,0) else
XWriteCenterDrop(1,230,'HIT A KEY TO CONTINUE OR WAIT 000',0,15,0);
{Now let's animate the display by messing with the palettes.}
With STime do
Begin
GetTime(H,M,S,S100); {Find the current time}
StartSecs:=H*3600+M*60+S; {Calc start time in seconds}
End;
NewIndex:=0; {Just a variable to increment}
Repeat {Continue the animation}
Inc(NewIndex);
For I:=32 to 255 do {Calculate a new set of palette colors}
Begin
PaletteBuf[I].Red:=(I+NewIndex) div 2;
PaletteBuf[I].Blu:=(I+NewIndex) div 4;
PaletteBuf[I].Grn:=(I+NewIndex);
End;
XBuf2RGB(PaletteBuf); {Write the new palette set to VGA}
If NewIndex=255 then NewIndex:=0;
With CTime do
Begin
GetTime(H,M,S,S100); {Get the current time}
EndSecs:=H*3600+M*60+S; {Calc current time in seconds}
End;
{The next statement adjusts for the rare midnight-crossing}
If EndSecs-StartSecs<0 then StartSecs:=StartSecs-86400;
If EndSecs-StartSecs>DisplayTime then StopNow:=True;
If LastCount<>DisplayTime-EndSecs+StartSecs then {Secs changed, redraw}
Begin {As a completely frivolous exercise, show the countdown}
XFillRect(262,224,292,232,0,1); {Blank countdown text}
LastCount:=DisplayTime-EndSecs+StartSecs; {Substitute new count}
Str(LastCount,LastCountText); {Convert to string for WriteDrop}
While Length(LastCountText)<3
do LastCountText:='0'+LastCountText; {Pad 0's}
If (LastCount<>-1) and (DisplayTime>0) then
XWriteDrop(1,268,230,LastCountText,0,15,0); {write it to the screen}
End;
If DisplayTime=0 then StopNow:=False; {If DisplayTime=0, no time limit}
Until KeyPressed or StopNow; {Until the user presses a key}
If not StopNow then Repeat OneKey:=ReadKey Until not KeyPressed;
{Flush keyboard buffer}
XBuf2RGB(PaletteSave); {Restore palettes to their entry values}
XSet80x25Mode; {Go back to text mode}
TextBackGround(Black);
{Write credits screen}
ClrScr;
TextBackGround(Green);
TextColor(White);
WriteLn(' About the cover art ... ');
TextColor(White);
TextBackGround(Black);
WriteLn;
WriteLn('GAME HACK Issue # 1 Mode-X animated cover by Fred Trafton.');
WriteLn;
WriteLn('640x480 plasma created by IMPROCES, read by Sean Wetzel''s GIFPAS Pascal');
WriteLn('unit, then translated to 320x240 X-mode bitmap by Fred Trafton.');
WriteLn;
WriteLn('Sean Wetzel''s GIFPAS unit can be downloaded from the CompuServe Borland Pascal');
WriteLn('Forum. Type GO BPASCAL from the CompuServe prompt. IMPROCES can be downloaded');
WriteLn('from the Graphics Support Forum, type GO GRAPHSUP from the CompuServe prompt.');
WriteLn('The Mode X assembly routines are heavily based upon Michael Abrash''s articles');
WriteLn('in Dr. Dobb''s Journal on the subject, and were modified by me for use with');
WriteLn('Borland Pascal rather than C.');
WriteLn;
WriteLn('Source code for this cover is included in this issue.');
WriteLn;
TextColor(Magenta);
WriteLn('Hit any key to read GAME HACK Issue # 1 ...');
With STime do
Begin
GetTime(H,M,S,S100); {Find the current time}
StartSecs:=H*3600+M*60+S; {Calc start time in seconds}
End;
StopNow:=False;
Repeat
With CTime do
Begin
GetTime(H,M,S,S100); {Get the current time}
EndSecs:=H*3600+M*60+S; {Calc current time in seconds}
End;
{The next statement adjusts for the rare midnight-crossing}
If EndSecs-StartSecs<0 then StartSecs:=StartSecs-86400;
If EndSecs-StartSecs>DisplayTime then StopNow:=True;
If DisplayTime=0 then StopNow:=False;
Until KeyPressed or StopNow;
If not StopNow then Repeat OneKey:=ReadKey Until not KeyPressed;
TextColor(LightGray);
TextBackground(Black);
ClrScr;
End.