home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / anivga12 / whatsnew.pas < prev   
Pascal/Delphi Source File  |  1993-07-11  |  9KB  |  281 lines

  1. {$A+,B-,D+,E+,F-,G-,I+,L+,N+,O-,R-,S-,V-,X+}
  2. {$M 16384,0,655360}
  3. PROGRAM WhatsNewInV12;
  4. USES ANIVGA,CRT;
  5. CONST FirstSpriteNumber=100;
  6.       FireFontData='FIRE.FNT';      {path & name of the font to load}
  7.       FireFontPal ='FIRE.PAL';      {corresponding palette}
  8.       Tiles='WHATSNEW.LIB';         {1 black + 4 maeander tiles}
  9.       tiles_per_row=2;              {These are the proportions of }
  10.       tiles_per_column=2;           {the above 4 tile file: 2x2!  }
  11.       ch:CHAR=#0; {sets ch to that value everytime the program starts}
  12. VAR i,j,x,y,nr,oldX1,oldY1,oldX2,oldY2:INTEGER;
  13.     tempPal,blackPal:Palette;
  14.  
  15. PROCEDURE CheckFileErr(name:STRING);
  16. { in: Error = error value}
  17. {     name  = file to deal with}
  18. {out: If there was an error with the file, the program stops in a clean way}
  19. BEGIN
  20.  IF Error<>Err_None
  21.   THEN BEGIN
  22.         CloseRoutines;
  23.         WRITELN('Couldn''t access file '+name+' : '+GetErrorMessage);
  24.         halt(1)
  25.        END;
  26. END;
  27.  
  28. PROCEDURE ErrBeep;
  29. BEGIN
  30.  Sound(200); Delay(50); NoSound
  31. END;
  32.  
  33.  
  34. BEGIN
  35.  ClrScr;
  36.  WRITELN('Please wait while I''m loading the font '+FireFontData+' ...');
  37.  SetBackgroundMode(scrolling);
  38.  SetBackgroundScrollRange(-100,-100,500,300);
  39.  MakeTileArea(1,2,2);
  40.  
  41.  {Load font and its palette}
  42.  LoadFont(FireFontData); CheckFileErr(FireFontData);
  43.  LoadPalette(FireFontPal,0,tempPal); CheckFileErr(FireFontPal);
  44.  
  45.  MakeTextSprite('What''s new in V1.2?',1);
  46.  MakeTextSprite('Let''s demonstrate it!',7);
  47.  
  48.  LoadFont(''); {switch back to internal font again}
  49.  
  50.  MakeTextSprite('There are some minor changes & enhancements,',2);
  51.  MakeTextSprite('which I won''t discuss here.',3);
  52.  MakeTextSprite('The most eye-catching new feature is the',4);
  53.  MakeTextSprite('possibility of an animation window, like this one.',5);
  54.  MakeTextSprite('You may resize it any time you want to:',6);
  55.  
  56.  
  57.  InitGraph;
  58.  
  59.  LoadTile(Tiles,0); {load the 5 tiles from the library file}
  60.  IF Error<>Err_None
  61.   THEN BEGIN
  62.         CloseRoutines;
  63.         WRITELN('Couldn''t access file '+Tiles+' : '+GetErrorMessage);
  64.         halt(1)
  65.        END;
  66.  SetCycleTime(40); {slow down animations}
  67.  SetPalette(tempPal,TRUE);
  68.  SetAnimateWindow(16,4,XMAX-4,YMAX-28);
  69.  Color:=66;
  70.  FillBackground(Color);
  71.  
  72.  GraphTextOrientation:=vertical;
  73.  BackgroundOutTextXY(2,2,'WHATSNEW.EXE');
  74.  GraphTextOrientation:=horizontal;
  75.  
  76.  {Place text sprites:}
  77.  nr:=FirstSpriteNumber; x:=WinXMIN+7; y:=WinYMIN+150;
  78.  SpriteN[nr]:=1; SpriteX[nr]:=x+10; SpriteY[nr]:=y;
  79.  INC(y,MaxFontHeight); INC(nr);
  80.  SpriteN[nr]:=2; SpriteX[nr]:=x; SpriteY[nr]:=y;
  81.  INC(y,FontHeight+2); INC(nr);
  82.  SpriteN[nr]:=3; SpriteX[nr]:=x; SpriteY[nr]:=y;
  83.  INC(y,FontHeight+2+6); INC(nr);
  84.  SpriteN[nr]:=4; SpriteX[nr]:=x; SpriteY[nr]:=y;
  85.  INC(y,FontHeight+2); INC(nr);
  86.  SpriteN[nr]:=5; SpriteX[nr]:=x; SpriteY[nr]:=y;
  87.  INC(y,FontHeight+2); INC(nr);
  88.  SpriteN[nr]:=6; SpriteX[nr]:=x; SpriteY[nr]:=y;
  89.  INC(y,FontHeight+2);
  90.  
  91.  Animate;
  92.  
  93.  {scroll in text block:}
  94.  FOR i:=1 TO 100 DO
  95.   BEGIN
  96.    FOR j:=FirstSpriteNumber TO nr DO DEC(SpriteY[j]);
  97.    Animate;
  98.   END;
  99.  
  100.  Delay(15000);
  101.  SpriteN[FirstSpriteNumber]:=7; Animate; {show "let's.."}
  102.  Delay(5000);
  103.  
  104.  {change size of animation window horizontally}
  105.  oldX1:=WinXMIN; oldY1:=WinYMIN; oldX2:=WinXMAX; oldY2:=WinYMAX;
  106.  FOR i:=1 TO 20 DO
  107.   BEGIN
  108.    SetAnimateWindow(oldX1+i*4,oldY1,oldX2-i*4,oldY2);
  109.    UpdateOuterArea:=2; {to show that update}
  110.    Delay(100);
  111.    Animate;
  112.   END;
  113.  
  114.  Delay(2000);
  115.  {move text around horizontally}
  116.  FOR i:=1 TO 100 DO
  117.   BEGIN
  118.    FOR j:=FirstSpriteNumber TO nr DO inc(SpriteX[j]);
  119.    Animate
  120.   END;
  121.  FOR i:=1 TO 100 DO
  122.   BEGIN
  123.    FOR j:=FirstSpriteNumber TO nr DO dec(SpriteX[j]);
  124.    Animate
  125.   END;
  126.  
  127.  FOR i:=19 DOWNTO 0 DO
  128.   BEGIN
  129.    SetAnimateWindow(oldX1+i*4,oldY1,oldX2-i*4,oldY2);
  130.    UpdateOuterArea:=2;
  131.    Delay(100);
  132.    Animate;
  133.   END;
  134.  SetAnimateWindow(oldX1,oldY1,oldX2,oldY2); UpdateOuterArea:=2;
  135.  
  136.  
  137.  SpriteN[FirstSpriteNumber]:=1; Animate; {show "What's new"}
  138.  Delay(2000);
  139.  
  140.  GraphTextColor:=Yellow; GraphTextBackground:=GraphTextColor;
  141.  MakeTextSprite('- loadable fonts, monochrome or color',2); Animate;
  142.  Delay(2000);
  143.  MakeTextSprite('- convert textstrings to sprites (like now)',3); Animate;
  144.  Delay(2000);
  145.  MakeTextSprite('- optional data compression for all',4);
  146.  MakeTextSprite('  external data files',5); Animate;
  147.  Delay(2000);
  148.  MakeTextSprite('- optional clipping for each individual sprite',6); Animate;
  149.  Delay(2000);
  150.  FOR i:=1 TO 45 DO
  151.   BEGIN
  152.    INC(StartVirtualY); Animate
  153.   END;
  154.  
  155.  Delay(2000);
  156.  MakeTextSprite('- faster than ever! (This demo is slowed down)',7);
  157.  y:=SpriteY[nr]+FontHeight+2; INC(nr);
  158.  SpriteN[nr]:=7; SpriteX[nr]:=x; SpriteY[nr]:=y;
  159.  INC(y,FontHeight+2); INC(nr); Animate;
  160.  
  161.  Delay(2000);
  162.  MakeTextSprite('- use the debugger (internal or external one)',8);
  163.  MakeTextSprite('  to single-step your program in graphic mode',9);
  164.  SpriteN[nr]:=8; SpriteX[nr]:=x; SpriteY[nr]:=y;
  165.  INC(y,FontHeight+2); INC(nr);
  166.  SpriteN[nr]:=9; SpriteX[nr]:=x; SpriteY[nr]:=y;
  167.  INC(y,FontHeight+2); INC(nr); Animate;
  168.  
  169.  Delay(2000);
  170.  MakeTextSprite('- decide yourself which text/lines/pixels shall',10);
  171.  MakeTextSprite('  be clipped to the animation window',11);
  172.  SpriteN[nr]:=10; SpriteX[nr]:=x; SpriteY[nr]:=y;
  173.  INC(y,FontHeight+2); INC(nr);
  174.  SpriteN[nr]:=11; SpriteX[nr]:=x; SpriteY[nr]:=y;
  175.  INC(y,FontHeight+2+6); INC(nr); Animate;
  176.  
  177.  GraphTextColor:=White; GraphTextBackground:=GraphTextColor;
  178.  Delay(2000);
  179.  MakeTextSprite('Now try it out yourself!',12);
  180.  MakeTextSprite('Use E to scroll around, I   i to resize',13);
  181.  MakeTextSprite('   S D                 J K j k',14);
  182.  MakeTextSprite('    X                   M   m',15);
  183.  SpriteN[nr]:=12; SpriteX[nr]:=x; SpriteY[nr]:=y;
  184.  INC(y,FontHeight+2+3); INC(nr);
  185.  SpriteN[nr]:=13; SpriteX[nr]:=x; SpriteY[nr]:=y;
  186.  INC(y,FontHeight+2); INC(nr);
  187.  SpriteN[nr]:=14; SpriteX[nr]:=x; SpriteY[nr]:=y;
  188.  INC(y,FontHeight+2); INC(nr);
  189.  SpriteN[nr]:=15; SpriteX[nr]:=x; SpriteY[nr]:=y;
  190.  INC(y,FontHeight+2+3); INC(nr);
  191.  
  192.  MakeTextSprite('These two sprites are not identical -find out!',16);
  193.  SpriteN[nr]:=16; SpriteX[nr]:=x; SpriteY[nr]:=y;
  194.  INC(y,FontHeight+2); INC(nr);
  195.  SpriteN[0]:=16; SpriteX[0]:=x; SpriteY[0]:=y;
  196.  SetSplitIndex(FirstSpriteNumber-1);
  197.  
  198.  GraphTextColor:=LightBlue; GraphTextBackground:=GraphTextColor;
  199.  BackgroundOutTextXY(5,WinYMAX+50,
  200.   'Use E,S,D,X to scroll around, I,J,K,M/i,j,k,m');
  201.  BackgroundOutTextXY(5,WinYMAX+59,
  202.   'to resize, <ESC> to quit.');
  203.  UpdateOuterArea:=2;
  204.  
  205.  Animate;
  206.  REPEAT
  207.   if KeyPressed
  208.    THEN BEGIN
  209.          WHILE KeyPressed do ch:=ReadKey;
  210.          CASE ch OF
  211.           'e','E':dec(StartVirtualY,10);  {change position of whole scene with}
  212.           's','S':dec(StartVirtualX,10);  {E,S,D,X}
  213.           'd','D':inc(StartVirtualX,10);
  214.           'x','X':inc(StartVirtualY,10);
  215.           'i':IF (WinYMIN>0)
  216.                THEN SetAnimateWindow(WinXMIN,WinYMIN-1,WinXMAX,WinYMAX)
  217.                ELSE ErrBeep;
  218.           'j':IF (WinXMIN>=4)
  219.                THEN SetAnimateWindow(WinXMIN-4,WinYMIN,WinXMAX,WinYMAX)
  220.                ELSE ErrBeep;
  221.           'k':IF (WinXMAX-WinXMIN+1 > 32)
  222.                THEN SetAnimateWindow(WinXMIN+4,WinYMIN,WinXMAX,WinYMAX)
  223.                ELSE ErrBeep;
  224.           'm':IF (WinYMAX-WinYMIN+1 > 32)
  225.                THEN SetAnimateWindow(WinXMIN,WinYMIN+1,WinXMAX,WinYMAX)
  226.                ELSE ErrBeep;
  227.           'I':IF (WinYMAX-WinYMIN+1 > 32)
  228.                THEN SetAnimateWindow(WinXMIN,WinYMIN,WinXMAX,WinYMAX-1)
  229.                ELSE ErrBeep;
  230.           'J':IF (WinXMAX-WinXMIN+1 > 32)
  231.                THEN SetAnimateWindow(WinXMIN,WinYMIN,WinXMAX-4,WinYMAX)
  232.                ELSE ErrBeep;
  233.           'K':IF (WinXMAX+4<=XMAX)
  234.                THEN SetAnimateWindow(WinXMIN,WinYMIN,WinXMAX+4,WinYMAX)
  235.                ELSE ErrBeep;
  236.           'M':IF (WinYMAX<YMAX)
  237.                THEN SetAnimateWindow(WinXMIN,WinYMIN,WinXMAX,WinYMAX+1)
  238.                ELSE ErrBeep;
  239.          END;
  240.          UpdateOuterArea:=2; {be extremely lazy here...}
  241.          IF POS(ch,'IJKMijkmESDXesdx')>0 THEN Animate;
  242.         END;
  243.  
  244.  UNTIL (ch='Q') OR (ch='q') OR (ch=#27);
  245.  
  246.  FillChar(blackPal,SizeOf(blackPal),0);
  247.  FadeToPalette(blackPal,200);
  248.  FOR i:=FirstSpriteNumber TO nr DO SpriteN[i]:=0;
  249.  SpriteN[0]:=0; StartVirtualX:=0; StartVirtualY:=0;
  250.  FillBackground(Color);
  251.  SetBackgroundMode(STATIC);
  252.  UpdateOuterArea:=2; Animate;
  253.  LoadFont(FireFontData);
  254.  x:=8; y:=5;
  255.  BackgroundOutTextXY(x,y,'As said earlier, there are a lot of');
  256.  BackgroundOutTextXY(x,y+FontHeight+2,'other changes :');
  257.  BackgroundOutTextXY(x,y+2*(FontHeight+2),
  258.  'Some bug fixes, usage of EMS for');
  259.  BackgroundOutTextXY(x,y+3*(FontHeight+2),
  260.  'the frame buffer, palette fade');
  261.  BackgroundOutTextXY(x,y+4*(FontHeight+2),
  262.  'in/out, a few minor changes to');
  263.  BackgroundOutTextXY(x,y+5*(FontHeight+2),
  264.  'MAKES, simplified background');
  265.  BackgroundOutTextXY(x,y+6*(FontHeight+2),
  266.  'tiling, etc.');
  267.  BackgroundOutTextXY(x,y+7*(FontHeight+2),
  268.  'Read WHATSNEW.TXT for more');
  269.  BackgroundOutTextXY(x,y+8*(FontHeight+2),
  270.  'information!');
  271.  BackgroundOutTextXY(x,y+9*(FontHeight+2)+5,
  272.  'Press any key to quit');
  273.  
  274.  Animate;
  275.  
  276.  FadeToPalette(tempPal,200);
  277.  
  278.  ch:=ReadKey;
  279.  CloseRoutines;
  280. END.
  281.