home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -screenplay- / otherstuff / adoomppc_src / amiga_main.c < prev    next >
C/C++ Source or Header  |  1998-04-23  |  5KB  |  241 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: ADoomPPC 1.2.6 " __AMIGADATE__ ;
  25.  
  26. long __oslibversion = 38;    /* we require at least OS3.0 for LoadRGB32() */
  27. char __stdiowin[] = "CON:0/20/640/140/ADoomPPC";
  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. #include <PowerUP/ppclib/ppc.h>
  38.  
  39. #include <proto/exec.h>
  40. #include <proto/icon.h>
  41.  
  42. #include "doomdef.h"
  43.  
  44. #include "m_argv.h"
  45. #include "d_main.h"
  46. #include "i_system.h"
  47. #include "m_fixed.h"
  48.  
  49. /**********************************************************************/
  50.  
  51. int VERSION = 110;
  52.  
  53. int cpu_type;
  54. int bus_clock;
  55. int bus_MHz;
  56. double tb_scale_lo;
  57. double tb_scale_hi;
  58.  
  59. /**********************************************************************/
  60. extern int _WBArgc;
  61. extern char **_WBArgv;
  62.  
  63. int main (int argc, char* argv[])
  64.   int i, p;
  65.   double pll;
  66.  
  67.   /* these command line arguments are flags */
  68.   static char *flags[] = {
  69.     "-forcedemo",
  70.     "-changepitch",
  71.     "-mouse",
  72.     "-joypad",
  73.     "-music",
  74.     "-nosfx",
  75.     "-mmu",
  76.     "-fps",
  77.     "-rotatemap",
  78.     "-maponhu",
  79. //    "-rtg",
  80. //    "-native",
  81. //    "-ehb",
  82.     "-mousepointer",
  83.     "-sega3",
  84.     "-sega6",
  85.     "-pcchecksum",
  86.     "-revrseipx",
  87.     "-directcgx",
  88. //    "-graffitilo",
  89. //    "-graffitihi",
  90.     "-rawkey",
  91.     "-maxdemo",
  92.     "-nodraw",
  93.     "-noblit",
  94.     "-debugfile",
  95.     "-shdev",
  96.     "-regdev",
  97.     "-comdev",
  98.     "-nomonsters",
  99.     "-respawn",
  100.     "-fast",
  101.     "-devparm",
  102.     "-altdeath",
  103.     "-deathmatch",
  104.     "-cdrom",
  105.     "-playdemo",
  106.     "-avg"
  107.   };
  108.   /* these command line arguments each take a value */
  109.   static char *settings[] = {
  110.     "-screenmode",
  111. //    "-taskpriority",
  112.     "-heapsize",
  113.     "-cpu",
  114.     "-bus",
  115.     "-forceversion",
  116.     "-width",
  117.     "-height",
  118.     "-waddir",
  119.     "-file",
  120.     "-deh",
  121.     "-timedemo",
  122.     "-skill",
  123.     "-episode",
  124.     "-timer",
  125.     "-statcopy",
  126.     "-record",
  127.     "-playdemo",
  128.     "-timedemo",
  129.     "-loadgame",
  130.     "-config",
  131.     "-turbo"
  132.   };
  133.  
  134.   printf ("%s\n", &amigaversion[6]);
  135.  
  136.   if (argc == 0)
  137.   {
  138.   /* run from WB, _WBArgv is name and TOOLTYPEs */
  139.     argc = _WBArgc;
  140.     argv = _WBArgv;
  141.   }
  142.   myargc = argc;
  143.   if ((myargv = malloc(sizeof(char *)*MAXARGVS)) == NULL)
  144.     I_Error ("malloc(%d) failed", sizeof(char *)*MAXARGVS);
  145.   memset (myargv, 0, sizeof(char *)*MAXARGVS);
  146.   memcpy (myargv, argv, sizeof(char *)*myargc);
  147.  
  148.   printf ("\nADoomPPC parameters are:\n\n    ");
  149.   for (i = 1; i < myargc; i++)
  150.     printf (" %s", myargv[i]);
  151.   printf ("\n\n");
  152.  
  153.   cpu_type = PPCGetAttr(PPCINFOTAG_CPU);
  154.   p = M_CheckParm ("-cpu");
  155.   if (p && p < myargc - 1) {
  156.     cpu_type = atoi (myargv[p+1]);
  157.   }
  158.   switch (cpu_type) {
  159.     case 3:
  160.       printf ("\nCPU is PPC603 ");
  161.       break;
  162.     case 4:
  163.       printf ("\nCPU is PPC604 ");
  164.       break;
  165.     case 5:
  166.       printf ("\nCPU is PPC602 ");
  167.       break;
  168.     case 6:
  169.       printf ("\nCPU is PPC603e ");
  170.       break;
  171.     case 7:
  172.       printf ("\nCPU is PPC603e+ ");
  173.       break;
  174.     case 8:
  175.       printf ("\nCPU is PPC604e ");
  176.       break;
  177.     default:
  178.       printf ("\nCPU is PPC ");
  179.       break;
  180.   }
  181.  
  182.   bus_clock = PPCGetAttr(PPCINFOTAG_CPUCLOCK);
  183.   printf ("running at %d MHz ", bus_clock);
  184.   if (!bus_clock)
  185.     bus_clock = 50000000;
  186.   else
  187.     bus_clock = bus_clock * 1000000;
  188.   i = PPCGetAttr(PPCINFOTAG_CPUPLL);
  189.   switch (i) {
  190.     case 0:
  191.     case 1:
  192.     case 2:
  193.     case 3:
  194.       pll = 1.0;            // PLL is 1:1 (or bypassed)
  195.       break;
  196.     case 4:
  197.     case 5:
  198.       pll = 2.0;            // PLL is 2:1
  199.       break;
  200.     case 8:
  201.     case 9:
  202.       pll = 3.0;            // PLL is 3:1
  203.       break;
  204.     case 12:
  205.       if ((cpu_type == 4) || (cpu_type == 8))
  206.         pll = 1.5;            // PLL is 1.5:1
  207.       else
  208.         pll = 4.0;            // PLL is 4:1
  209.       break;
  210.     case 13:
  211.       pll = 4.0;            // PLL is 4:1
  212.       break;
  213.     default:
  214.       pll = 3.0;
  215.       break;
  216.   }
  217.   printf ("using a PLL divisor of %3.1f.\n", pll);
  218.  
  219.   bus_clock = (int)((double)bus_clock / pll);
  220.   p = M_CheckParm ("-bus");
  221.   if (p && p < myargc - 1) {
  222.     bus_clock = atoi (myargv[p+1]);
  223.   }
  224.   bus_MHz = bus_clock / 1000000;
  225.   printf("Bus clock is %d MHz.\n\n", bus_MHz);
  226.  
  227.   tb_scale_lo = ((double)(bus_clock >> 2)) / 35.0;
  228.   tb_scale_hi = (4.294967296E9 / (double)(bus_clock >> 2)) * 35.0;
  229.  
  230.   SetFPMode ();  /* set FPU rounding mode to "trunc towards -infinity" */
  231.  
  232.   p = M_CheckParm ("-forceversion");
  233.   if (p && p < myargc - 1)
  234.     VERSION = atoi (myargv[p+1]);
  235.  
  236.   D_DoomMain ();
  237.  
  238.   return 0;
  239. }
  240.