Sonic CD shows Sega logo
[picodrive.git] / platform / s60 / PicoDriveExe.h
... / ...
CommitLineData
1#ifndef PicoDriveH\r
2#define PicoDriveH\r
3#include <e32base.h>\r
4#include <eikappui.h>\r
5#include <coecntrl.h>\r
6#include <aknapp.h>\r
7#include <akndoc.h>\r
8#include <MdaAudioOutputStream.h>\r
9#include <Mda\Common\Audio.h>\r
10\r
11#include <aknappUI.h>\r
12struct Target\r
13{\r
14 unsigned char *screen;\r
15 TPoint point; // Screen to client point\r
16 TRect view,update;\r
17 TInt scanline_length;\r
18 TInt screen_offset;\r
19 TBool stretch_line;\r
20\r
21};\r
22\r
23enum TPicoMainMenu\r
24{\r
25 ELoadRom,\r
26 ELoadState,\r
27 ESaveState,\r
28 ESetControls,\r
29 ESetScreen,\r
30 ESelectSound,\r
31 ESelectCheat,\r
32 EResetHw,\r
33 EAboutPico,\r
34 EExitPico,\r
35 ELastMenuItem\r
36};\r
37\r
38enum TPicoSoundMenu\r
39{\r
40 EEnableZ80,\r
41 EEnableYM2612,\r
42 EEnableSN76496,\r
43 ESoundVolume,\r
44 ESoundRate,\r
45 ELastSoundItem\r
46};\r
47\r
48enum TPicoCheatMenu\r
49{\r
50 EAddCheat,\r
51 EClearCheats,\r
52 ELastCheatItem\r
53};\r
54\r
55enum TPicoControllerMenu\r
56{\r
57 EControllerType,\r
58 EConfigControls\r
59};\r
60enum TPicoMenus\r
61{\r
62 EPicoMainMenu,\r
63 ESelectScrMenu,\r
64 EAboutPicoMenu,\r
65 ESelectSoundMenu,\r
66 ESelectControlsMenu,\r
67 ESelectCheatMenu\r
68};\r
69\r
70enum TPicoKeys\r
71{\r
72 EPicoUpKey,\r
73 EPicoDownKey,\r
74 EPicoLeftKey,\r
75 EPicoRightKey,\r
76 EPicoAKey,\r
77 EPicoBKey,\r
78 EPicoCKey,\r
79 EPicoXKey,\r
80 EPicoYKey,\r
81 EPicoZKey,\r
82 EPicoModeKey,\r
83 EPicoStartKey,\r
84 EPicoULKey,\r
85 EPicoURKey,\r
86 EPicoDRKey,\r
87 EPicoDLKey,\r
88 EPicoResetKey,\r
89 EPicoPanLKey,\r
90 EPicoPanRKey,\r
91 EPicoNoKeys\r
92};\r
93\r
94class CPicoAddCheatDlg:public CEikDialog\r
95{\r
96public:\r
97 CPicoAddCheatDlg(TDes8& aCheatCode):iCheatCode(aCheatCode){};\r
98 ~CPicoAddCheatDlg(){ iEikonEnv->EikAppUi()->RemoveFromStack(this);}\r
99 TBool OkToExitL(TInt /*aButtonId*/)\r
100 {\r
101 static_cast<CEikEdwin*>(ControlOrNull(0x2000))->GetText(iUniCheatCode);\r
102 iCheatCode.Copy(iUniCheatCode);\r
103 return ETrue;\r
104 }\r
105\r
106 void PreLayoutDynInitL()\r
107 {\r
108 iEikonEnv->EikAppUi()->AddToStackL(this);\r
109 }\r
110private:\r
111 TDes8& iCheatCode;\r
112 TBuf<16> iUniCheatCode;\r
113};\r
114\r
115#ifdef S60V3\r
116class CPicoDriveDoc:public CAknDocument\r
117{\r
118public:\r
119 CPicoDriveDoc(CEikApplication& aApp);\r
120 ~CPicoDriveDoc();\r
121 CEikAppUi* CreateAppUiL();\r
122};\r
123\r
124class CPicoDriveApp:public CAknApplication\r
125{\r
126public:\r
127 CPicoDriveApp();\r
128 ~CPicoDriveApp();\r
129 TUid AppDllUid()const;\r
130 CApaDocument* CreateDocumentL();\r
131\r
132 /**\r
133 * From @c CApaApplication. Opens the .ini file associated with the\r
134 * application. By default, ini files are not supported by SERIES60 \r
135 * applications. If you want to use an ini file, either override this\r
136 * function to base call @c CEikApplication::OpenIniFileLC, or call it\r
137 * directly.\r
138 * @param aFs File server session to use. Not used.\r
139 * @return Pointer to the dictionary store object representing the\r
140 * application's .ini file.\r
141 */\r
142 CDictionaryStore* OpenIniFileLC(RFs& aFs) const;\r
143};\r
144#endif\r
145\r
146class CQPicoDriveView:public CCoeControl,public MDirectScreenAccess\r
147 {\r
148public:\r
149 CQPicoDriveView() {};\r
150 ~CQPicoDriveView();\r
151 void Draw(const TRect& aRect) const;\r
152 void ConstructL();\r
153 void PutBitmap(CFbsBitmap* aBitmap,TPoint aPoint,TRect aRect);\r
154 void Restart(RDirectScreenAccess::TTerminationReasons aReason);\r
155 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);\r
156 void DrawText(const TDesC& aText,TPoint aPoint,TBool aHighLight=EFalse,TRgb aTextColour = KRgbWhite);\r
157 TInt DrawTextInRect(const TDesC& aText,TRect aRect,TInt aStartPos);\r
158 void Clear();\r
159 CDirectScreenAccess* iDsa;\r
160 TBool iDrawingOn;\r
161 TBool iForeground;\r
162 };\r
163\r
164\r
165class CPicoDriveUi:public CAknAppUi,public MMdaAudioOutputStreamCallback\r
166{\r
167public:\r
168 CPicoDriveUi();\r
169 ~CPicoDriveUi();\r
170 void ConstructL();\r
171 void StartAsynchUpdate();\r
172protected:\r
173 static TInt AsyncUpdateL(TAny* aAppUi);\r
174 void StartEmulatorL();\r
175 virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);\r
176 void HandleForegroundEventL(TBool aForeground);\r
177 // Menu drawers\r
178 void PutMainMenu();\r
179 void PutScreenSelect();\r
180 void PutControllerSelect();\r
181 void PutConfigKeys();\r
182 void PutSoundSelect();\r
183 void PutCheatSelect();\r
184 void PutAbout(TBool iOnlyRedraw = EFalse);\r
185\r
186 // Asynch screen update callback\r
187 void UpdateScreen();\r
188\r
189 TInt SelectFile(TFileName& aFileName);\r
190 // Emulation functions\r
191 int EmulateInit();\r
192 void EmulateExit();\r
193 int EmulateFrame();\r
194 int InputFrame();\r
195 int TargetInit();\r
196 void CalulateLineStarts();\r
197\r
198 static TInt IdleCallBackStop(TAny* aAppUi);\r
199 static TInt StartEmulatorL(TAny* aAppUi);\r
200 // Settings storage\r
201 void SaveSettingsL();\r
202 void InternalizeL(const CDictionaryStore& aStore);\r
203 void ExternalizeL( CDictionaryStore& aStore);\r
204\r
205 // Save state handling\r
206 int saveLoadGame(int load, int sram);\r
207\r
208 /**\r
209 * Calculates the palette table 0-4096\r
210 */\r
211 void CalculatePaletteTable();\r
212 CAsyncCallBack iIdleCallBack;\r
213\r
214 // Variables\r
215 TUint16 iPad1;\r
216 TUint16 iPad2; \r
217 TFileName iRomName;\r
218 char RomName[260];\r
219 TInt iScanCodes[EPicoNoKeys];\r
220 TInt iCurrentScan;\r
221 CDesCArrayFlat* iKeyNames;\r
222 CDesCArrayFlat* iRegNames;\r
223 TBool iEmuRunning;\r
224 CQPicoDriveView* iView;\r
225 TInt iResourceFileId;\r
226 CAsyncCallBack iStartUp;\r
227 CFbsBitmap* iBackBuffer;\r
228 TFileName iAppPath;\r
229 TPoint iPutPoint;\r
230 TRect iPutRect; \r
231 TInt iSelection;\r
232 TInt iSndSelection;\r
233 TInt iCtrlSelection;\r
234 TInt iCheatSelection;\r
235 TInt iNoCheats;\r
236 TBool iCheatEnter;\r
237 CEikDialog* iCheatDlg;\r
238 TInt iListOffset;\r
239 TInt iScrMode;\r
240 TInt iLastScrMode;\r
241 TBool iRomLoaded;\r
242 TBool iInterpolate;\r
243 TBool iStretch;\r
244 TBool iEnableSixButtons;\r
245 TPicoMenus iPicoMenu;\r
246 CAsyncCallBack iAsyncUpdate;\r
247\r
248 // sound support\r
249 CMdaAudioOutputStream* iSndStream;\r
250 TMdaAudioDataSettings iAudioSettings;\r
251 TBuf8<442*2*6> iMonoSound;\r
252 TInt iCurrentSeg;\r
253 TBool iEnableSound;\r
254 TBool iSndRateChanged;\r
255 TInt iSoundVolume; // 0-10 in 10% percent\r
256 void MaoscOpenComplete(TInt aError);\r
257 void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer);\r
258 void MaoscPlayComplete(TInt aError);\r
259 // Update the sound output rate\r
260 TBool UpdatePSndRate();\r
261\r
262 // Rom pointers\r
263 unsigned char *RomData;\r
264 unsigned int RomSize;\r
265 \r
266 TInt64 LastSecond;\r
267 int FramesDone;\r
268 int FramesPerSecond;\r
269 TDisplayMode iDisplayMode;\r
270 TInt iLastAboutPos;\r
271 TBool iFirstStart;\r
272 TInt iFrameSkip;\r
273 TInt iFontHeight; \r
274 int (*myPicoScan)(unsigned int scan,unsigned short *pal);\r
275 TBuf<1024> iTempString;\r
276 // make save filename\r
277 char saveFname[KMaxFileName];\r
278\r
279};\r
280\r
281#endif\r