home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / JAGUAR / JAG_SRC / SOURCE / MAIN.C < prev    next >
C/C++ Source or Header  |  2001-08-17  |  6KB  |  135 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. // Jagulator: Atari Jaguar Console Emulation Project (main.c)
  3. // -----------------------------------------------------------------------------
  4. // Jagulator is the Copyright (c) RealityMan 1998-2001 and is provided "as is" 
  5. // without any expressed or implied warranty. I have no Trademarks, Legal or 
  6. // otherwise. Atari, Jaguar and the Atari Logo are copyright Hasbro Inc. All 
  7. // other Copyrights and Trademarks are acknowledged. This project is in no way 
  8. // linked to Atari/Hasbro or other associated Atari companies.                
  9. //
  10. // 07-07-2001 GH: New Source, Rewritten for Release 1.5.0
  11. // 00-00-0000 GH: All Previous Source Considered as Development Code Only
  12.  
  13. #include "core.h"
  14.  
  15. ////////////////////////////////////////////////////////////////////////////////
  16. // Globals
  17.  
  18.    static HANDLE emuthreadhandle;      // Main Emulation Thread Handle
  19.    CFGDATA cfg;                        // Configuration Data
  20.    STATE st;                           // Main Emulator State
  21.  
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // Appends '\' to Path if it Doesn't Contain One
  24.  
  25.    void FixPath( char *path, int striplastname )
  26.    {
  27.       char *p;                         // String Pointer
  28.     
  29.       if( !*path ) return;             // Return if No Path Passed
  30.          
  31.       if( striplastname )              // Strip Executable Name from Path
  32.       {
  33.          p = path + strlen(path);      // Set String Pointer
  34.          while( p > path + 1 && *p != ':' && *p != '\\' ) p--;
  35.       }
  36.       else 
  37.          p = path + strlen(path) - 1;  // Set Pointer to End of Path
  38.     
  39.       if( p[0] != '\\' ) *++p = '\\';  // Append '\\' if Not at End
  40.  
  41.       p[1] = 0;                        // Null Terminate String
  42.    }
  43.  
  44. ////////////////////////////////////////////////////////////////////////////////
  45. // Load Configuration Data
  46.  
  47.    void LoadConfig( void )
  48.    {
  49.       static char buf[MAX_PATH];       // Temporary Buffer
  50.  
  51.       // Retrieve Path and Filename of Executable and
  52.       // Append '\' to Path if it Doesn't Have One
  53.       GetModuleFileName( NULL, cfg.rootpath, sizeof(cfg.rootpath) );
  54.       FixPath( cfg.rootpath, 1 );
  55.  
  56.       // Setup Path/Filename to Configuration File
  57.       strcpy( buf, cfg.rootpath );    
  58.       strcat( buf, "jagulator.ini" );  
  59.  
  60.       // Load [Default] Settings from Configuration File
  61.       GetPrivateProfileString( "default", "rompath", ".", 
  62.                                cfg.rompath, sizeof(cfg.rompath), buf );
  63.       FixPath( cfg.rompath, 0 );
  64.       GetPrivateProfileString( "default", "bootpath", ".",
  65.                                cfg.bootpath, sizeof(cfg.bootpath), buf );
  66.       FixPath( cfg.bootpath, 0 );
  67.  
  68.       // Load [Audio] Settings from Configuration File
  69.       cfg.sound = GetPrivateProfileInt( "audio", "sound", 1, buf );
  70.  
  71.       // Load [Video] Settings from Configuration File
  72.       cfg.graphics   = GetPrivateProfileInt( "video", "graphics",    1, buf );
  73.       cfg.hres       = GetPrivateProfileInt( "video", "hres",      512, buf );
  74.       cfg.vres       = GetPrivateProfileInt( "video", "vres",      384, buf );
  75.       cfg.fullscreen = GetPrivateProfileInt( "video", "fullscreen",  0, buf );
  76.       cfg.frameskip  = GetPrivateProfileInt( "video", "frameskip",   0, buf );
  77.    }
  78.  
  79. ////////////////////////////////////////////////////////////////////////////////
  80. // Display Copyright Information
  81.  
  82.    void printcopyright( void )
  83.    {
  84.       print( WHITE"--------------------------------------------------------" );
  85.       print( "------------------------\n" );
  86.       print( WHITE"%s v%i.%i.%i - %s (%s)",
  87.              APPNAME, MAJORREV, MINORREV, PATCHLVL, TITLE, PLATFORM );
  88.       print( "\n\x1\xf"COPYRIGHT );
  89.       print( "\n\n" );
  90.       print( GRAY"Atari, Jaguar and the Atari Logo are the copyright of " );
  91.       print( "Hasbro Inc.\n" );
  92.       print( GRAY"All other copyrights and Trademarks are " );
  93.       print( "acknowledged. This project \n" );
  94.       print( GRAY"is in no way " );
  95.       print( "linked to Atari/Hasbro. This software is provided \"as is\" \n");
  96.       print( GRAY"without any expressed or implied warranty.\n\n" );
  97.       print( GRAY"Starscream v0.26a 680x0 emulation library by Neill Corlett\n" );
  98.       print( GRAY"(corlett@elwha.nrrc.ncsu.edu)\n" );
  99.       print( WHITE"---------------------------------------------------------" );
  100.       print( "-----------------------\n\n" );
  101.    }
  102.  
  103. ////////////////////////////////////////////////////////////////////////////////
  104. // Main Emulation Thread - Started Before Main Win32 GUI is Activated
  105.  
  106.    void main_thread( void )
  107.    {
  108.       LoadConfig();                    // Load INI Settings
  109.  
  110.       // Get Thread Handle of this Thread
  111.       emuthreadhandle = GetCurrentThread();
  112.  
  113.       // Open Debug Console
  114.       view_open();                  
  115.       view_changed( VIEW_RESIZE );
  116.       flushdisplay();
  117.       Sleep(100);                      // Give Time for UI to Redraw Fully
  118.       printcopyright();
  119.       #ifndef RELEASE
  120.       print( "Root Path - %s\n", cfg.rootpath );
  121.       print( "Boot Path - %s\n", cfg.bootpath );
  122.       print( "Rom Path  - %s\n", cfg.rompath  );
  123.  
  124.       // Display Help Text
  125.       print( "\n\x1\x3""Type 'help' for help or press F5 to start.\n\n" );
  126.       #endif
  127.  
  128.       debugui();                       // Main Debug User Interface Loop
  129.  
  130.       view_close();                    // Close Debug Console
  131.    }
  132.  
  133.  
  134.  
  135.