initial import
[picodrive.git] / platform / uiq3 / Engine.h
CommitLineData
cc68a136 1/*******************************************************************\r
2 *\r
3 * File: Engine.h\r
4 *\r
5 * Author: Peter van Sebille (peter@yipton.net)\r
6 *\r
7 * Modified/adapted for picodriveN by notaz, 2006\r
8 *\r
9 * (c) Copyright 2006, notaz\r
10 * (c) Copyright 2002, Peter van Sebille\r
11 * All Rights Reserved\r
12 *\r
13 *******************************************************************/\r
14\r
15#ifndef __ENGINE_H\r
16#define __ENGINE_H\r
17\r
18#include <e32base.h>\r
19\r
20class RReadStream;\r
21class RWriteStream;\r
22\r
23\r
24// engine states\r
25enum TPicoGameState {\r
26 PGS_Running = 1,\r
27 PGS_Paused,\r
28 PGS_Quit,\r
29 PGS_KeyConfig,\r
30 PGS_DebugHeap,\r
31};\r
32\r
33enum TPicoServRqst {\r
34 PicoMsgLoadState,\r
35 PicoMsgSaveState,\r
36 PicoMsgLoadROM,\r
37 PicoMsgResume,\r
38 PicoMsgReset,\r
39 PicoMsgKeys,\r
40 PicoMsgPause,\r
41 PicoMsgQuit,\r
42 PicoMsgConfigChange,\r
43 PicoMsgSetAppView,\r
44 kDefaultMessageSlots // this is how many messages we need :)\r
45};\r
46\r
47enum TPicoGenErrors { // generic errors\r
48 PicoErrNoErr = 0, // OK\r
49 PicoErrRomOpenFailed,\r
50 PicoErrOutOfMem,\r
51 PicoErrNotRom,\r
52 PicoErrNoRomsInArchive,\r
53 PicoErrUncomp, // 5\r
54 PicoErrOutOfMemSnd,\r
55 PicoErrGenSnd, // 7 generic sound system error\r
56 PicoErrEmuThread\r
57};\r
58\r
59\r
60// needed for creating server thread.\r
61const TUint KPicoMaxHeapSize=0x00800000;\r
62\r
63// key config entry (touchpad areas)\r
64struct TPicoAreaConfigEntry {\r
65 TRect rect;\r
66 //unsigned long actions;\r
67};\r
68\r
69struct TPicoKeyConfigEntry\r
70{\r
71 unsigned short keyCode;\r
72 unsigned char scanCode;\r
73 unsigned char flags; // lsb->msb: key_down, pulse_only, ?, ?, ?, ?, not_configurable, disabled\r
74 TInt32 handle1; // for CancelCaptureKeyUpAndDowns()\r
75 TInt32 handle2; // for CancelCaptureKey()\r
76 char *name;\r
77};\r
78\r
79\r
80// configuration data\r
81class TPicoConfig\r
82{\r
83public:\r
84 void SetDefaults();\r
85 void InternalizeL(RReadStream &aStream);\r
86 void ExternalizeL(RWriteStream &aStream) const;\r
87\r
88 enum TPicoScreenRotation {\r
89 PRot0,\r
90 PRot90,\r
91 PRot180,\r
92 PRot270\r
93 };\r
94 enum TPicoScreenMode {\r
95 PMCenter,\r
96 PMFit,\r
97 PMFit2\r
98 };\r
99 enum TPicoFrameSkip {\r
100 PFSkipAuto = -1,\r
101 PFSkip0\r
102 };\r
103\r
104public:\r
105 TFileName iLastROMFile;\r
106\r
107 TInt32 iScreenRotation;\r
108 TInt32 iScreenMode;\r
109 TUint32 iFlags; // LSb->MSb: use_sram, show_fps, enable_sound, sound_rate(3bits), gzip_saves{=0x40}, dont_use_mot_vol\r
110 // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;\r
111 // alt_renderer, 6button_gamepad, accurate_timing\r
112 TInt32 iPicoOpt;\r
113 TInt32 iFrameskip;\r
114 TUint32 iKeyBinds[256]; // a binding for every keycode\r
115 TUint32 iAreaBinds[19];\r
116 TInt32 PicoRegion;\r
117};\r
118\r
119\r
120class CThreadWatcher : public CActive\r
121{\r
122public:\r
123 static CThreadWatcher* NewL(const TThreadId& aTid);\r
124 ~CThreadWatcher();\r
125\r
126 TThreadId iTid; // thread id\r
127\r
128protected:\r
129 CThreadWatcher(const TThreadId& aTid);\r
130 void ConstructL();\r
131\r
132 virtual void RunL();\r
133 virtual void DoCancel();\r
134};\r
135\r
136\r
137class CPicoGameSession\r
138{\r
139public:\r
140 static TInt Do(const TPicoServRqst what, TAny *param=0);\r
141 static void freeResources();\r
142\r
143 static TBool iEmuRunning;\r
144 static TBuf<0x30> iRomInternalName;\r
145\r
146private:\r
147 // services available\r
148 static TInt StartEmuThread();\r
149 static TInt ChangeRunState(TPicoGameState newstate, TPicoGameState newstate_next=(TPicoGameState)0);\r
150 static TInt loadROM(TPtrC16 *pptr);\r
151 static TInt changeConfig(TPicoConfig *aConfig);\r
152\r
153 static CThreadWatcher *iThreadWatcher;\r
154};\r
155\r
156// global\r
157int saveLoadGame(int load, int sram=0);\r
158\r
159#endif\r