PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/avkon-gui/src/gamecontroller.cpp

http://psx4m.googlecode.com/
C++ | 823 lines | 563 code | 117 blank | 143 comment | 61 complexity | 4d98c7ad1ca18152f64fef7c0f464fe9 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * ==============================================================================
  3. * Name : gamecontroller.cpp
  4. * Part of : OpenC / OpenCOpenglEx
  5. * Interface :
  6. * Description : Contains the implementations of CGameController
  7. * & CWsEventReceiver.
  8. * Version :
  9. *
  10. * Copyright (c) 2007 Nokia Corporation.
  11. * This material, including documentation and any related
  12. * computer programs, is protected by copyright controlled by
  13. * Nokia Corporation.
  14. * ==============================================================================
  15. */
  16. #include "game.h"
  17. #include "gamecontroller.h"
  18. #include <coemain.h> // for CCoeEnv
  19. #include "symbian_memoryhandler.h"
  20. #include "string.h"
  21. #include "gpuPrim.h"
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include "psxCommon.h"
  25. #include "gpuPlugin.h"
  26. #include "spu.h"
  27. #include "system.h"
  28. #include "misc.h"
  29. #include "R3000a.h"
  30. //extern R3000Acpu* psxCpu;
  31. // -----------------------------------------------------------------------------
  32. // CGameController::NewLC
  33. // The Factory Function for a CGameController object.
  34. // -----------------------------------------------------------------------------
  35. //
  36. extern CGameController* gameController;
  37. extern short int toggle_button_map[16];
  38. TBool iIsPause = EFalse;
  39. extern int iFilter;
  40. extern char IsoFile[1024];
  41. //PsxConfig Config;
  42. PcsxConfig Config;
  43. R3000Acpu *psxCpu;
  44. psxRegisters* psxRegs;
  45. u32 *psxMemWLUT;
  46. u32 *psxMemRLUT;
  47. cdrStruct cdr;
  48. long LoadCdBios;
  49. s8 *psxH;
  50. s8 *psxR;
  51. s8 *psxP;
  52. s8 *psxM;
  53. psxCounter psxCounters[5];
  54. unsigned long psxNextCounter, psxNextsCounter;
  55. char packfile[256];
  56. char gamepath[256] = "E:\\data\\pcsx\\";
  57. char gamedir[256] = "E:\\data\\pcsx\\games\\";
  58. char pathfile[256] = "E:\\data\\pcsx\\game.path";
  59. char configfile[256] = "E:\\data\\pcsx\\default.cfg";
  60. //prototypes
  61. s32 InitComponents(void);
  62. void SysPrintf(char *fmt, ...);
  63. CGameController* CGameController::NewLC( EGLDisplay aEglDisplay )
  64. {
  65. CGameController* self = new (ELeave) CGameController( aEglDisplay );
  66. CleanupStack::PushL( self );
  67. self->ConstructL();
  68. return self;
  69. }
  70. // -----------------------------------------------------------------------------
  71. // CGameController::CGameController
  72. // Constructor.
  73. // -----------------------------------------------------------------------------
  74. //
  75. CGameController::CGameController( EGLDisplay aEglDisplay )
  76. :iEglDisplay( aEglDisplay ),
  77. iEglSurface( NULL ),
  78. iEglContext( NULL ),
  79. iWindow( NULL ),
  80. iWsEventReceiver( NULL ),
  81. iGame( NULL ),
  82. iWsScreenDevice( NULL ),
  83. iIsAppInFocus( EFalse ),
  84. iIsVisible( ETrue )
  85. {
  86. }
  87. // -----------------------------------------------------------------------------
  88. // CGameController::~CGameController
  89. // Destructor.
  90. // -----------------------------------------------------------------------------
  91. //
  92. CGameController::~CGameController()
  93. {
  94. // EGL related cleanup.
  95. eglMakeCurrent( iEglDisplay, EGL_NO_SURFACE,
  96. EGL_NO_SURFACE, EGL_NO_CONTEXT
  97. );
  98. eglDestroySurface( iEglDisplay, iEglSurface );
  99. eglDestroyContext( iEglDisplay, iEglContext );
  100. // Destroy the RWindow.
  101. if( iWindow != NULL )
  102. {
  103. iWindow->SetOrdinalPosition( KOrdinalPositionSwitchToOwningWindow );
  104. iWindow->Close();
  105. delete iWindow;
  106. iWindow = NULL;
  107. }
  108. delete iWsEventReceiver;
  109. }
  110. // -----------------------------------------------------------------------------
  111. // CGameController::ConstructL
  112. // Second phase constructor.
  113. // Initializes EGL.
  114. // -----------------------------------------------------------------------------
  115. //
  116. void CGameController::ConstructL()
  117. {
  118. CCoeEnv* env = CCoeEnv::Static();
  119. if( !env )
  120. {
  121. User::Leave( KErrCoeEnvNotInitialized );
  122. }
  123. // Get the Windows Server Session, screen device and window group.
  124. iWsSession = env->WsSession();
  125. iWsScreenDevice = env->ScreenDevice();
  126. iWindowGroup = env->RootWin();
  127. if( !iWsScreenDevice )
  128. {
  129. User::Leave( KErrCoeEnvNotInitialized );
  130. }
  131. // Intializes iWindow to a full screen window.
  132. CreateNativeWindowL();
  133. // Choose the buffer size based on the Window's display mode.
  134. TDisplayMode displayMode = iWindow->DisplayMode();
  135. TInt bufferSize = 0;
  136. switch( displayMode )
  137. {
  138. case(EColor4K):
  139. bufferSize = 12;
  140. break;
  141. case(EColor64K):
  142. bufferSize = 16;
  143. break;
  144. case(EColor16M):
  145. bufferSize = 24;
  146. break;
  147. case(EColor16MU):
  148. case(EColor16MA):
  149. bufferSize = 32;
  150. break;
  151. default:
  152. break;
  153. }
  154. // Set the desired properties for the EGLSurface
  155. const EGLint attributeList[] = {
  156. EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
  157. EGL_BUFFER_SIZE, bufferSize,
  158. EGL_NONE
  159. };
  160. EGLConfig bestConfig;
  161. EGLint numConfigs = 0;
  162. // Choose the best EGLConfig that matches the desired properties.
  163. if( eglChooseConfig( iEglDisplay, attributeList, &bestConfig,
  164. 1, &numConfigs
  165. ) == EGL_FALSE
  166. )
  167. {
  168. User::Leave( KErrConfigFailed );
  169. }
  170. if( numConfigs == 0 )
  171. {
  172. User::Leave( KErrConfigFailed );
  173. }
  174. // Create a window surface where the graphics are blitted.
  175. // Pass the Native Window handle to egl.
  176. iEglSurface = eglCreateWindowSurface( iEglDisplay, bestConfig,
  177. (void*)iWindow, NULL
  178. );
  179. if( iEglSurface == NULL )
  180. {
  181. User::Leave( KErrCreateWindowSurfaceFailed );
  182. }
  183. // Create a rendering context
  184. iEglContext = eglCreateContext( iEglDisplay, bestConfig,
  185. EGL_NO_CONTEXT, NULL
  186. );
  187. if( iEglContext == NULL )
  188. {
  189. User::Leave( KErrCreateContextFailed );
  190. }
  191. // Make it the current context.
  192. if( eglMakeCurrent( iEglDisplay, iEglSurface,
  193. iEglSurface, iEglContext
  194. ) == EGL_FALSE
  195. )
  196. {
  197. User::Leave( KErrSetContextFailed );
  198. }
  199. // Creates the Active Object that waits for Windows Server events.
  200. iWsEventReceiver = CWsEventReceiver::NewL( *this );
  201. }
  202. void CGameController::Load()
  203. {
  204. }
  205. void CGameController::Save()
  206. {
  207. }
  208. #define writeln(x) printf(x);printf("\n")
  209. int LoadGameName()
  210. {
  211. FILE *file = fopen(pathfile,"r");
  212. if (file == NULL)
  213. return -1;
  214. fgets(packfile,256,file);
  215. fclose(file);
  216. if (packfile=="")
  217. return -1;
  218. return 0;
  219. }
  220. void LoadConfig(char* configName)
  221. {
  222. char fileName[256];
  223. if (configName == NULL)
  224. sprintf(fileName,"%s%s",gamepath,"default.cfg");
  225. else
  226. sprintf(fileName,"%s%s%s",gamedir,configName,".cfg");
  227. FILE *file = fopen(fileName,"r");
  228. if (file == NULL)
  229. {
  230. printf("Config not found: ",fileName,"\n");
  231. return;
  232. }
  233. int c;
  234. for (int tmpi = 0; tmpi<16; tmpi++)
  235. {
  236. c = fgetc(file);
  237. if (c=='1')
  238. toggle_button_map[tmpi]=1;
  239. else
  240. toggle_button_map[tmpi]=0;
  241. }
  242. if (fgetc(file) == '1')
  243. iFilter = GL_LINEAR;
  244. else
  245. iFilter = GL_NEAREST;
  246. if (fgetc(file) == '1')
  247. Config.HLE = 0;
  248. else
  249. Config.HLE = 1;
  250. fclose(file);
  251. }
  252. // -----------------------------------------------------------------------------
  253. // CGameController::StartGameL
  254. // Intializes the Game and Starts the game loop.
  255. // -----------------------------------------------------------------------------
  256. //
  257. void CGameController::StartGameL( CGame& aGame )
  258. {
  259. User::SetFloatingPointMode(EFpModeRunFast);
  260. iGame = &aGame;
  261. // Allow the game to initialize itself.
  262. // The opengl es state intialization is done here.
  263. iGame->Initialize( iWindow->Size().iWidth, iWindow->Size().iHeight );
  264. surface = iEglSurface;
  265. display = iEglDisplay;
  266. writeln("EQ PCSX");
  267. writeln("-------");
  268. writeln("Initialization...");
  269. create_all_translation_caches();
  270. #if defined(__SYMBIAN32__)
  271. sprintf(gamepath, "E:\\data\\PCSX\\");
  272. #endif
  273. LoadGameName();
  274. sprintf((char*)IsoFile,"%s%s",gamedir,packfile);
  275. // memset(&Config, 0, sizeof(PsxConfig));
  276. Config.PsxAuto = 1;
  277. Config.Cdda = 1;
  278. Config.Xa = 1;
  279. #ifdef DYNAREC
  280. Config.Cpu = 0;
  281. #else
  282. Config.Cpu = 1;
  283. #endif
  284. #ifdef WITH_HLE
  285. // Testing HLE?
  286. Config.HLE = 0;
  287. #else
  288. // HLE OFF
  289. Config.HLE = 0;
  290. #endif
  291. Config.Mdec = 0;
  292. Config.PsxOut = 0;
  293. Config.PsxType = 0;
  294. Config.QKeys = 0;
  295. Config.RCntFix = 0;
  296. Config.Sio = 0;
  297. Config.SpuIrq = 0;
  298. Config.VSyncWA = 0;
  299. LoadConfig(NULL);
  300. LoadConfig(packfile);
  301. if (Config.HLE == 1)
  302. {
  303. sprintf((char*)Config.Bios,"%s","nobios");
  304. }
  305. sprintf((char*)Config.BiosDir, "%sbios\\", gamepath);
  306. sprintf((char*)Config.Bios, "scph1001.bin");
  307. sprintf((char*)Config.Mcd1, "%s\\memcards\\mcd001.mcr", gamepath);
  308. sprintf((char*)Config.Mcd2, "%s\\memcards\\mcd002.mcr", gamepath);
  309. LoadCdBios = 0;
  310. writeln("SysInit...");
  311. if (SysInit() == -1)
  312. {
  313. writeln("ERROR INIT!\nPress any key to exit.");
  314. getchar();
  315. return;
  316. }
  317. writeln("InitComponents...");
  318. if (InitComponents() == -1)
  319. {
  320. writeln("ERROR COMPONENTS!\nPress any key to exit.");
  321. getchar();
  322. return;
  323. }
  324. writeln("SysReset...");
  325. SysReset();
  326. writeln("CheckCDRom...");
  327. //CheckCdrom();
  328. writeln("LoadCDRom...");
  329. if (LoadCdrom() == -1)
  330. {
  331. writeln("ERROR LOAD CDROM!\nPress any key to exit.");
  332. getchar();
  333. return;
  334. }
  335. iWindow->SetOrdinalPosition(0);
  336. iWindowGroup.SetOrdinalPosition(0);
  337. writeln("EXECUTE!");
  338. // iIsPause = EFalse;
  339. psxCpu->Execute();
  340. aGame.Cleanup();
  341. }
  342. // -----------------------------------------------------------------------------
  343. // CGameController::ProcessBackgroundTasks
  344. // Calls the RunL on all Active Objects which have
  345. // pending requests.
  346. // If aIsBlocking is ETrue, this API will block till an event occurs.
  347. // -----------------------------------------------------------------------------
  348. //
  349. void CGameController::ProcessBackgroundTasks( TBool aIsBlocking )
  350. {
  351. RThread thread;
  352. TInt error = KErrNone;
  353. if ( aIsBlocking && !thread.RequestCount() )
  354. {
  355. // Block for a event.
  356. User::WaitForAnyRequest();
  357. // Run the Active Object corresponding to the event
  358. CActiveScheduler::RunIfReady( error, CActive::EPriorityIdle );
  359. }
  360. // Processes all outstanding requests
  361. while( thread.RequestCount() )
  362. {
  363. // Processes an event.
  364. CActiveScheduler::RunIfReady( error, CActive::EPriorityIdle );
  365. // Decreases thread.RequestCount
  366. User::WaitForAnyRequest();
  367. }
  368. }
  369. // -----------------------------------------------------------------------------
  370. // CGameController::CreateNativeWindowL
  371. // Create a full screen RWindow and enables screen size
  372. // change events.
  373. // -----------------------------------------------------------------------------
  374. //
  375. void CGameController::CreateNativeWindowL()
  376. {
  377. iWindow = new (ELeave) RWindow( iWsSession );
  378. // Construct the window.
  379. TInt err = iWindow->Construct( iWindowGroup,
  380. reinterpret_cast<TUint32>( this )
  381. );
  382. User::LeaveIfError( err );
  383. // Enable the EEventScreenDeviceChanged event.
  384. iWindowGroup.EnableScreenChangeEvents();
  385. TPixelsTwipsAndRotation pixnrot;
  386. iWsScreenDevice->GetScreenModeSizeAndRotation(
  387. iWsScreenDevice->CurrentScreenMode(),
  388. pixnrot );
  389. // Set size of the window (cover the entire screen)
  390. iWindow->SetExtent( TPoint( 0, 0 ),
  391. pixnrot.iPixelSize
  392. );
  393. iWindow->SetRequiredDisplayMode( iWsScreenDevice->DisplayMode() );
  394. // Activate window and bring it to the foreground
  395. iWindow->Activate();
  396. iWindow->SetVisible( ETrue );
  397. iWindow->SetNonFading( ETrue );
  398. iWindow->SetShadowDisabled( ETrue );
  399. iWindow->EnableRedrawStore( EFalse );
  400. iWindow->EnableVisibilityChangeEvents();
  401. iWindow->SetNonTransparent();
  402. iWindow->SetBackgroundColor();
  403. iWindow->SetOrdinalPosition( 0 );
  404. }
  405. // -----------------------------------------------------------------------------
  406. // CGameController::HandleWsEvent
  407. // This function is called by the CWsEventReceiver
  408. // Active Object, whenever it receives a Windows Server
  409. // event.
  410. // -----------------------------------------------------------------------------
  411. //
  412. void CGameController::HandleWsEvent( const TWsEvent& aWsEvent )
  413. {
  414. TInt eventType = aWsEvent.Type();
  415. // Handle Key and Screen Size change Events.
  416. switch( eventType )
  417. {
  418. case EEventKeyDown:
  419. {
  420. if (aWsEvent.Key()->iModifiers & EModifierShift)
  421. {
  422. if (aWsEvent.Key()->iScanCode == '4')
  423. {
  424. if (PsxCycleMult>2)
  425. {
  426. PsxCycleMult = PsxCycleMult - 1;
  427. }
  428. }
  429. else
  430. if (aWsEvent.Key()->iScanCode == '6')
  431. {
  432. PsxCycleMult = PsxCycleMult + 1;
  433. }
  434. else
  435. if (aWsEvent.Key()->iScanCode==EStdKeyDevice1)
  436. {
  437. psxShutdown();
  438. break;
  439. }
  440. }
  441. else
  442. if( iGame )
  443. iGame->HandleKeyEvent( aWsEvent.Key()->iScanCode, EFalse );
  444. break;
  445. }
  446. case EEventKeyUp:
  447. {
  448. if( iGame )
  449. iGame->HandleKeyEvent( aWsEvent.Key()->iScanCode, ETrue );
  450. break;
  451. }
  452. case( EEventScreenDeviceChanged ): // The screen size has changed.
  453. {
  454. TPixelsTwipsAndRotation pixnrot;
  455. iWsScreenDevice->GetScreenModeSizeAndRotation(
  456. iWsScreenDevice->CurrentScreenMode(),
  457. pixnrot
  458. );
  459. if( pixnrot.iPixelSize != iWindow->Size() )
  460. {
  461. // Update the window.
  462. iWindow->SetExtent( TPoint( 0, 0 ),
  463. pixnrot.iPixelSize
  464. );
  465. // If a game is running, notify it about the change.
  466. if( iGame )
  467. {
  468. iGame->SetScreenSize( pixnrot.iPixelSize.iWidth,
  469. pixnrot.iPixelSize.iHeight
  470. );
  471. // Call eglSwapBuffers after the window size has changed.
  472. // This updates the window size used by egl.
  473. eglSwapBuffers( iEglDisplay, iEglSurface );
  474. }
  475. }
  476. break;
  477. }
  478. case EEventFocusLost:
  479. {
  480. iIsAppInFocus = EFalse;
  481. // iIsPause = ETrue;
  482. break;
  483. }
  484. case EEventFocusGained:
  485. {
  486. iIsAppInFocus = ETrue;
  487. break;
  488. }
  489. case EEventWindowVisibilityChanged:
  490. {
  491. // Check if the event is for the iWindow
  492. if( aWsEvent.Handle() ==
  493. reinterpret_cast<TUint32>( this )
  494. )
  495. {
  496. if( aWsEvent.VisibilityChanged()->iFlags &
  497. TWsVisibilityChangedEvent::ECanBeSeen
  498. )
  499. {
  500. iIsVisible = ETrue;
  501. }
  502. else
  503. {
  504. iIsVisible = EFalse;
  505. // iIsPause = ETrue;
  506. }
  507. }
  508. break;
  509. }
  510. case EEventNull:
  511. case EEventKey:
  512. case EEventUser:
  513. case EEventWindowGroupListChanged:
  514. case EEventModifiersChanged:
  515. case EEventSwitchOn:
  516. case EEventPassword:
  517. case EEventWindowGroupsChanged:
  518. case EEventErrorMessage:
  519. case EEventPointer:
  520. case EEventPointerEnter:
  521. case EEventPointerExit:
  522. case EEventPointerBufferReady:
  523. case EEventDragDrop:
  524. break;
  525. default:
  526. break;
  527. }
  528. }
  529. ////////////////////////////////////////////////////////////////////////////////
  530. // Windows Server Event Receiver Implementation //
  531. ////////////////////////////////////////////////////////////////////////////////
  532. // -----------------------------------------------------------------------------
  533. // CWsEventReceiver::CWsEventReceiver
  534. // Constructor.
  535. // -----------------------------------------------------------------------------
  536. //
  537. CWsEventReceiver::CWsEventReceiver()
  538. :CActive( CActive::EPriorityStandard ),
  539. iParent( NULL )
  540. {
  541. }
  542. // -----------------------------------------------------------------------------
  543. // CWsEventReceiver::~CWsEventReceiver
  544. // Destructor.
  545. // -----------------------------------------------------------------------------
  546. //
  547. CWsEventReceiver::~CWsEventReceiver()
  548. {
  549. Cancel();
  550. }
  551. // -----------------------------------------------------------------------------
  552. // CWsEventReceiver::NewL
  553. // Factory Function.
  554. // -----------------------------------------------------------------------------
  555. //
  556. CWsEventReceiver* CWsEventReceiver::NewL( CGameController& aParent )
  557. {
  558. CWsEventReceiver* self = new (ELeave) CWsEventReceiver;
  559. CleanupStack::PushL( self );
  560. self->ConstructL( aParent );
  561. CleanupStack::Pop( self );
  562. return self;
  563. }
  564. // -----------------------------------------------------------------------------
  565. // CWsEventReceiver::ConstructL
  566. // Second phase constructor.
  567. // Add itself to the Active Scheduler.
  568. // -----------------------------------------------------------------------------
  569. //
  570. void CWsEventReceiver::ConstructL( CGameController& aParent )
  571. {
  572. if( !CCoeEnv::Static() )
  573. User::Leave( KErrCoeEnvNotCreated );
  574. iParent = &aParent;
  575. // Register with the Windows Server for events.
  576. iWsSession = CCoeEnv::Static()->WsSession();
  577. iWsSession.EventReady( &iStatus );
  578. CActiveScheduler::Add( this );
  579. SetActive();
  580. }
  581. // -----------------------------------------------------------------------------
  582. // CWsEventReceiver::RunL
  583. // Is called by the Active Scheduler when a Windows
  584. // Server event is pending.
  585. // NOTE: This API does not leave, so RunError is not
  586. // implemented.
  587. // -----------------------------------------------------------------------------
  588. //
  589. void CWsEventReceiver::RunL()
  590. {
  591. TWsEvent wsEvent;
  592. iWsSession.GetEvent( wsEvent );
  593. // Pass the event on to the Game Controller.
  594. iParent->HandleWsEvent( wsEvent );
  595. // Request for more events.
  596. iWsSession.EventReady( &iStatus );
  597. SetActive();
  598. }
  599. // -----------------------------------------------------------------------------
  600. // CWsEventReceiver::DoCancel
  601. // Cancels any pending Windows Server event requests.
  602. // -----------------------------------------------------------------------------
  603. //
  604. void CWsEventReceiver::DoCancel()
  605. {
  606. iWsSession.EventReadyCancel();
  607. }
  608. extern "C" void ProcessEvents()
  609. {
  610. while(EFalse != iIsPause)
  611. gameController->ProcessBackgroundTasks( ETrue );
  612. gameController->ProcessBackgroundTasks(EFalse);
  613. }
  614. //from old components.cpp
  615. s32 InitComponents(void)
  616. {
  617. s32 ret;
  618. #if defined(PSP) && defined(PSP_GPU)
  619. GPU_SelectPluggin(2);
  620. #elif defined(IPHONE)
  621. GPU_SelectPluggin(0); // 3
  622. #else
  623. // GPU_SelectPluggin(0);
  624. #endif
  625. printf("CDR\n");
  626. ret = CDR_init();
  627. if (ret < 0) { SysPrintf("CDRinit error : %d", ret); return -1; }
  628. printf("GPU\n");
  629. ret = GPU_init();
  630. if (ret < 0) { SysPrintf("GPUinit error: %d", ret); return -1; }
  631. printf("SPU\n");
  632. ret = SPU_init();
  633. if (ret < 0) { SysPrintf("SPUinit error: %d", ret); return -1; }
  634. printf("PAD1\n");
  635. ret = PAD1_init(1);
  636. if (ret < 0) { SysPrintf("PAD1init error: %d", ret); return -1; }
  637. printf("PAD2\n");
  638. ret = PAD2_init(2);
  639. if (ret < 0) { SysPrintf("PAD2init error: %d", ret); return -1; }
  640. printf("CDR OPEN\n");
  641. ret = CDR_open();
  642. if (ret < 0) { SysPrintf("Error Opening CDR Component"); return -1; }
  643. printf("SPU OPEN\n");
  644. ret = SPU_open();
  645. if (ret < 0) { SysPrintf("Error Opening SPU Component"); return -1; }
  646. // EDIT SPU_registerCallback(SPUirq);
  647. printf("GPU OPEN\n");
  648. ret = GPU_open(0);
  649. //if (ret < 0) { SysPrintf("Error Opening GPU Component"); return -1; }
  650. printf("PAD1 OPEN\n");
  651. ret = PAD1_open();
  652. if (ret < 0) { SysPrintf("Error Opening PAD1 Component"); return -1; }
  653. printf("PAD2 OPEN\n");
  654. ret = PAD2_open();
  655. if (ret < 0) { SysPrintf("Error Opening PAD2 Component"); return -1; }
  656. return 0;
  657. }
  658. int SysInit() {
  659. #ifdef GTE_DUMP
  660. gteLog = fopen("gteLog.txt","wb");
  661. setvbuf(gteLog, NULL, _IONBF, 0);
  662. #endif
  663. #ifdef EMU_LOG
  664. #ifndef LOG_STDOUT
  665. emuLog = fopen("emuLog.txt","wb");
  666. #else
  667. emuLog = stdout;
  668. #endif
  669. setvbuf(emuLog, NULL, _IONBF, 0);
  670. SysMessage("\n--- SysInit ---\n");
  671. fflush(emuLog);
  672. #endif
  673. psxInit();
  674. LoadMcds(Config.Mcd1, Config.Mcd2);
  675. return 0;
  676. }
  677. void SysReset() {
  678. psxReset();
  679. }
  680. void SysMessage(char *fmt, ...) {
  681. va_list list;
  682. char tmp[512];
  683. va_start(list,fmt);
  684. vsprintf(tmp,fmt,list);
  685. va_end(list);
  686. printf(tmp);
  687. printf("\n");
  688. // MessageBox(0, tmp, _("Pcsx Msg"), 0);
  689. }
  690. void SysPrintf(char *fmt, ...) {
  691. va_list list;
  692. char tmp[512];
  693. va_start(list,fmt);
  694. vsprintf(tmp,fmt,list);
  695. va_end(list);
  696. printf(tmp);
  697. printf("\n");
  698. }
  699. // eof