home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 25 / amigaformatcd25.iso / websites / amidoom / adoom_src-0.7.lha / ADoom_src / amiga_main.c < prev    next >
C/C++ Source or Header  |  1998-01-16  |  5KB  |  178 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //    Main program, simply calls D_DoomMain high level loop.
  21. //
  22. //-----------------------------------------------------------------------------
  23.  
  24. const char amigaversion[] = "$VER: ADoom 0.7 " __AMIGADATE__ ;
  25.  
  26. long __oslibversion = 39;    /* we require at least OS3.0 for LoadRGB32() */
  27. char __stdiowin[] = "CON:20/50/500/130/ADoom";
  28. char __stdiov37[] = "/AUTO/CLOSE/WAIT";
  29.  
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32.  
  33. #include <exec/exec.h>
  34. #include <workbench/startup.h>
  35. #include <workbench/workbench.h>
  36. #include <workbench/icon.h>
  37.  
  38. #include <proto/exec.h>
  39. #include <proto/icon.h>
  40.  
  41. #include "doomdef.h"
  42.  
  43. #include "m_argv.h"
  44. #include "d_main.h"
  45. #include "i_system.h"
  46. #include "m_fixed.h"
  47.  
  48. /**********************************************************************/
  49. extern struct ExecBase *SysBase;
  50.  
  51. int cpu_type;
  52.  
  53. /**********************************************************************/
  54. int main (int argc, char* argv[])
  55.   struct WBStartup *argmsg;
  56.   struct WBArg *wb_arg;
  57.   struct DiskObject *obj;
  58.   char **toolarray, *s;
  59.   int i;
  60.  
  61.   /* these command line arguments are flags */
  62.   static char *flags[] = {
  63.     "-forcedemo",
  64.     "-changepitch",
  65.     "-mouse",
  66.     "-joypad",
  67.     "-music",
  68.     "-nosfx",
  69.     "-maxdemo",
  70.     "-nodraw",
  71.     "-noblit",
  72.     "-debugfile",
  73.     "-shdev",
  74.     "-regdev",
  75.     "-comdev",
  76.     "-nomonsters",
  77.     "-respawn",
  78.     "-fast",
  79.     "-devparm",
  80.     "-altdeath",
  81.     "-deathmatch",
  82.     "-cdrom",
  83.     "-turbo",
  84.     "-playdemo",
  85.     "-avg"
  86.   };
  87.   /* these command line arguments each take a value */
  88.   static char *settings[] = {
  89.     "-screenmode",
  90.     "-taskpriority",
  91.     "-mmu",
  92.     "-file",
  93.     "-timedemo",
  94.     "-skill",
  95.     "-episode",
  96.     "-timer",
  97.     "-statcopy",
  98.     "-record",
  99.     "-playdemo",
  100.     "-timedemo",
  101.     "-loadgame",
  102.     "-config"
  103.   };
  104.  
  105.   printf ("%s\n", &amigaversion[6]);
  106.  
  107.   myargc = argc;
  108.   if ((myargv = malloc(sizeof(char *)*MAXARGVS)) == NULL)
  109.     I_Error ("malloc(%d) failed", sizeof(char *)*MAXARGVS);
  110.   memset (myargv, 0, sizeof(char *)*MAXARGVS);
  111.   memcpy (myargv, argv, sizeof(char *)*myargc);
  112.  
  113.   /* parse icon tooltypes and convert them to argc/argv format */
  114.   if (argc == 0) {
  115.     argmsg = (struct WBStartup *)argv;
  116.     wb_arg = argmsg->sm_ArgList;
  117.     if ((myargv[myargc] = malloc(strlen(wb_arg->wa_Name)+1)) == NULL)
  118.       I_Error ("malloc(%d) failed", strlen(wb_arg->wa_Name)+1);
  119.     strcpy (myargv[myargc++], wb_arg->wa_Name);
  120.   }
  121.   if ((obj = GetDiskObject (myargv[0])) != NULL) {
  122.     toolarray = obj->do_ToolTypes;
  123.     for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
  124.       if (FindToolType (toolarray, &flags[i][1]) != NULL) {
  125.         myargv[myargc++] = flags[i];
  126.       }
  127.     }
  128.     for (i = 0; i < sizeof(settings)/sizeof(settings[0]); i++) {
  129.       if ((s = FindToolType (toolarray, &settings[i][1])) != NULL) {
  130.         myargv[myargc++] = settings[i];
  131.         if ((myargv[myargc] = malloc(strlen(s)+1)) == NULL)
  132.           I_Error ("malloc(%d) failed", strlen(s)+1);
  133.         strcpy(myargv[myargc++], s);
  134.       }
  135.     }
  136.     FreeDiskObject (obj);
  137.   }
  138.  
  139.   if (argc != myargc) {
  140.     printf ("\nIcon tooltypes translated command line to:\n\n    ");
  141.     for (i = 0; i < myargc; i++)
  142.       printf (" %s", myargv[i]);
  143.     printf ("\n\n");
  144.   }
  145.  
  146.   if ((SysBase->AttnFlags & AFF_68060) != 0)
  147.     cpu_type = 68060;
  148.   else if ((SysBase->AttnFlags & AFF_68040) != 0)
  149.     cpu_type = 68040;
  150.   else if ((SysBase->AttnFlags & AFF_68030) != 0)
  151.     cpu_type = 68030;
  152.   else if ((SysBase->AttnFlags & AFF_68020) != 0)
  153.     cpu_type = 68020;
  154.   else if ((SysBase->AttnFlags & AFF_68010) != 0)
  155.     cpu_type = 68010;
  156.   else
  157.     cpu_type = 68000;
  158.  
  159.   if (cpu_type >= 68060) {
  160.     if ((SysBase->AttnFlags & AFB_68881) != 0) {
  161.       SetFPMode ();  /* set FPU rounding mode to "trunc towards -infinity" */
  162.       FixedMul = FixedMul_060fpu;
  163.       FixedDiv = FixedDiv_060fpu;
  164.     } else {
  165.       FixedMul = FixedMul_060;
  166.       FixedDiv = FixedDiv_040;
  167.     }
  168.   } else {
  169.     FixedMul = FixedMul_040;
  170.     FixedDiv = FixedDiv_040;
  171.   }
  172.  
  173.   D_DoomMain ();
  174.  
  175.   return 0;
  176. }
  177.