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

  1. ////////////////////////////////////////////////////////////////////////////////
  2. // Jagulator: Atari Jaguar Console Emulation Project (cpu.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. #include "core.h"
  11.  
  12. ////////////////////////////////////////////////////////////////////////////////
  13. // Macro Definitions
  14.  
  15. #define EXEC_STEP          5000        // Execution Cycle Burst
  16. #define VIDEO_REFRESH      217714      // Cycles Per Video Refresh
  17.  
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // Globals
  20.  
  21.    BOOL emulating;                     // Emulation Active Flag
  22.    dword count;                        // Cycle Counter
  23.  
  24. ////////////////////////////////////////////////////////////////////////////////
  25. // Execute Complete Console CPU Emulation
  26.  
  27.    dword cpu_exec( void )
  28.    {
  29.       // Check if Emulation can Proceed
  30.       if( !st.readytogo ) 
  31.       {
  32.          emulating = FALSE;
  33.          return( emulating );
  34.       }
  35.       else 
  36.       {
  37.          emulating = TRUE;
  38.          count = 0;
  39.       }
  40.  
  41.       // Main Emulation Loop
  42.       while( emulating )      
  43.       {  
  44.          s68000exec( EXEC_STEP );      // Execute 68K Step Cycle
  45.          count += EXEC_STEP;           // Increment Cycle Counter
  46.  
  47.          if( count >= VIDEO_REFRESH )  // Check for Video Refresh
  48.          {
  49.             // Check if Video Interrupt is Enabled
  50.             if( *(word *)(st.tom + 0xE0) & 0x0001 )
  51.             {
  52.                s68000releaseTimeslice();
  53.                s68000interrupt( 1, 64 );
  54.                //while( gst.olista ) ;
  55.                object_exec();          // Execute Display List
  56.                count = 0;
  57.                flushdisplay();
  58.             }
  59.          }
  60.  
  61.          // Check to See if Exit has been Requested
  62.          if( GetAsyncKeyState( VK_ESCAPE ) ) 
  63.          {
  64.             wsprintf( sbbuf, "Emulation Stopped..." );
  65.             SendMessage( hwndStatus, SB_SETTEXT, 0, (LPARAM)sbbuf );
  66.             emulating = FALSE;
  67.          }
  68.       }
  69.  
  70.       return( TRUE );
  71.    }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.