Engine.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*******************************************************************
  2. *
  3. * File: Engine.h
  4. *
  5. * Author: Peter van Sebille (peter@yipton.net)
  6. *
  7. * Modified/adapted for picodriveN by notaz, 2006
  8. *
  9. * (c) Copyright 2006, notaz
  10. * (c) Copyright 2002, Peter van Sebille
  11. * All Rights Reserved
  12. *
  13. *******************************************************************/
  14. #ifndef __ENGINE_H
  15. #define __ENGINE_H
  16. #include <e32base.h>
  17. class RReadStream;
  18. class RWriteStream;
  19. // engine states
  20. enum TPicoGameState {
  21. PGS_Running = 1,
  22. PGS_Paused,
  23. PGS_Quit,
  24. PGS_KeyConfig,
  25. PGS_DebugHeap,
  26. PGS_ReloadRom,
  27. };
  28. enum TPicoServRqst {
  29. PicoMsgLoadState,
  30. PicoMsgSaveState,
  31. PicoMsgLoadROM,
  32. PicoMsgResume,
  33. PicoMsgReset,
  34. PicoMsgKeys,
  35. PicoMsgPause,
  36. PicoMsgQuit,
  37. PicoMsgConfigChange,
  38. PicoMsgSetAppView,
  39. kDefaultMessageSlots // this is how many messages we need :)
  40. };
  41. enum TPicoGenErrors { // generic errors
  42. PicoErrNoErr = 0, // OK
  43. PicoErrRomOpenFailed,
  44. PicoErrOutOfMem,
  45. PicoErrNotRom,
  46. PicoErrNoRomsInArchive,
  47. PicoErrUncomp, // 5
  48. PicoErrOutOfMemSnd,
  49. PicoErrGenSnd, // 7 generic sound system error
  50. PicoErrEmuThread
  51. };
  52. // needed for creating server thread.
  53. const TUint KPicoMaxHeapSize=0x00800000;
  54. // key config entry (touchpad areas)
  55. struct TPicoAreaConfigEntry {
  56. TRect rect;
  57. //unsigned long actions;
  58. };
  59. struct TPicoKeyConfigEntry
  60. {
  61. unsigned short keyCode;
  62. unsigned char scanCode;
  63. unsigned char flags; // lsb->msb: key_down, pulse_only, ?, ?, ?, ?, not_configurable, disabled
  64. TInt32 handle1; // for CancelCaptureKeyUpAndDowns()
  65. TInt32 handle2; // for CancelCaptureKey()
  66. char *name;
  67. };
  68. // configuration data
  69. class TPicoConfig
  70. {
  71. public:
  72. // void SetDefaults();
  73. // void InternalizeL(RReadStream &aStream);
  74. // void ExternalizeL(RWriteStream &aStream) const;
  75. enum TPicoScreenRotation {
  76. PRot0,
  77. PRot90,
  78. PRot180,
  79. PRot270
  80. };
  81. enum TPicoScreenMode {
  82. PMCenter,
  83. PMFit,
  84. PMFit2
  85. };
  86. enum TPicoFrameSkip {
  87. PFSkipAuto = -1,
  88. PFSkip0
  89. };
  90. public:
  91. TFileName iLastROMFile; // used as tmp only
  92. };
  93. class CThreadWatcher : public CActive
  94. {
  95. public:
  96. static CThreadWatcher* NewL(const TThreadId& aTid);
  97. ~CThreadWatcher();
  98. TThreadId iTid; // thread id
  99. protected:
  100. CThreadWatcher(const TThreadId& aTid);
  101. void ConstructL();
  102. virtual void RunL();
  103. virtual void DoCancel();
  104. };
  105. class CPicoGameSession
  106. {
  107. public:
  108. static TInt Do(const TPicoServRqst what, TAny *param=0);
  109. static void freeResources();
  110. static TBool iEmuRunning;
  111. static TBuf<150> iRomInternalName;
  112. private:
  113. // services available
  114. static TInt StartEmuThread();
  115. static TInt ChangeRunState(TPicoGameState newstate, TPicoGameState newstate_next=(TPicoGameState)0);
  116. static TInt loadROM(TPtrC16 *pptr);
  117. static TInt changeConfig(TPicoConfig *aConfig);
  118. static CThreadWatcher *iThreadWatcher;
  119. };
  120. #endif