home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / acksrc.zip / ACKGOAL.C < prev    next >
Text File  |  1993-06-17  |  2KB  |  127 lines

  1. /*           ACK-3D ( Animation Construction Kit 3D )              */
  2. /* Goal routine          */
  3. /* Author: Lary Myers */
  4.  
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <dos.h>
  8. #include <mem.h>
  9. #include <alloc.h>
  10. #include <io.h>
  11. #include <fcntl.h>
  12. #include <time.h>
  13. #include <string.h>
  14. #include <sys\stat.h>
  15. #include "ack3d.h"
  16. #include "ackext.h"
  17.  
  18. extern unsigned char far  colordat[];
  19.  
  20. /****************************************************************************
  21. **                                       **
  22. ****************************************************************************/
  23. int ShowScreen(char *sName)
  24. {
  25.          int    handle;
  26.     unsigned char *sBuffer,*Video;
  27.     unsigned char *pBuffer;
  28.  
  29. pBuffer = malloc(768);
  30. if (pBuffer == NULL)
  31.     return(-1);
  32.  
  33. if (!stricmp(GetExtent(sName),"LBM"))
  34.     {
  35.     sBuffer = Readiff(sName);
  36.     memmove(sBuffer,&sBuffer[4],64000);
  37.     memmove(pBuffer,colordat,768);
  38.     }
  39. else
  40.     {
  41.     handle = open(sName,O_RDWR|O_BINARY);
  42.     if (handle < 1)
  43.     {
  44.     free(pBuffer);
  45.     return(-2);
  46.     }
  47.  
  48.     sBuffer = malloc(64000);
  49.     if (sBuffer)
  50.     {
  51.     read(handle,sBuffer,4);
  52.     read(handle,sBuffer,64000);
  53.     }
  54.  
  55.     close(handle);
  56.  
  57.     if (*GoalPalFile)
  58.     {
  59.     handle = open(GoalPalFile,O_RDWR|O_BINARY);
  60.     if (handle > 0)
  61.         {
  62.         read(handle,pBuffer,768);
  63.         close(handle);
  64.         }
  65.     else
  66.         {
  67.         free(pBuffer);
  68.         pBuffer = NULL;
  69.         }
  70.     }
  71.     else
  72.     {
  73.     free(pBuffer);
  74.     pBuffer = NULL;
  75.     }
  76.     }
  77.  
  78. if (sBuffer == NULL)
  79.     {
  80.     if (pBuffer)
  81.     free(pBuffer);
  82.     return(-3);
  83.     }
  84.  
  85. if (pBuffer)
  86.     {
  87.     SetPalette(pBuffer);
  88.     free(pBuffer);
  89.     }
  90.  
  91. Video = MK_FP(0xA000,0);
  92. memmove(Video,sBuffer,64000);
  93.  
  94. free(sBuffer);
  95.  
  96. return(0);
  97. }
  98.  
  99.  
  100.  
  101. /****************************************************************************
  102. ** Here is where everything finishes up. If a screen was specified in the  **
  103. ** master description file then it is displayed, otherwise a simple       **
  104. ** YOU WON! is shown.                               **
  105. ****************************************************************************/
  106. void DoGoalScreen(void)
  107. {
  108.     int        result;
  109.  
  110. SetVGAmode();
  111.  
  112. result = 1;
  113.  
  114. if (*GoalFile)
  115.     result = ShowScreen(GoalFile);
  116.  
  117. if (result)
  118.     {
  119.     printf("\tY O U  W O N ! !");
  120.     }
  121.  
  122. setvect(KEYBD,oldvec);
  123. getch();
  124. }
  125.  
  126.  
  127.