--- /dev/null
+#ifndef PicoDriveH\r
+#define PicoDriveH\r
+#include <e32base.h>\r
+#include <eikappui.h>\r
+#include <coecntrl.h>\r
+#include <aknapp.h>\r
+#include <akndoc.h>\r
+#include <MdaAudioOutputStream.h>\r
+#include <Mda\Common\Audio.h>\r
+\r
+#include <aknappUI.h>\r
+struct Target\r
+{\r
+ unsigned char *screen;\r
+ TPoint point; // Screen to client point\r
+ TRect view,update;\r
+ TInt scanline_length;\r
+ TInt screen_offset;\r
+ TBool stretch_line;\r
+\r
+};\r
+\r
+enum TPicoMainMenu\r
+{\r
+ ELoadRom,\r
+ ELoadState,\r
+ ESaveState,\r
+ ESetControls,\r
+ ESetScreen,\r
+ ESelectSound,\r
+ ESelectCheat,\r
+ EResetHw,\r
+ EAboutPico,\r
+ EExitPico,\r
+ ELastMenuItem\r
+};\r
+\r
+enum TPicoSoundMenu\r
+{\r
+ EEnableZ80,\r
+ EEnableYM2612,\r
+ EEnableSN76496,\r
+ ESoundVolume,\r
+ ESoundRate,\r
+ ELastSoundItem\r
+};\r
+\r
+enum TPicoCheatMenu\r
+{\r
+ EAddCheat,\r
+ EClearCheats,\r
+ ELastCheatItem\r
+};\r
+\r
+enum TPicoControllerMenu\r
+{\r
+ EControllerType,\r
+ EConfigControls\r
+};\r
+enum TPicoMenus\r
+{\r
+ EPicoMainMenu,\r
+ ESelectScrMenu,\r
+ EAboutPicoMenu,\r
+ ESelectSoundMenu,\r
+ ESelectControlsMenu,\r
+ ESelectCheatMenu\r
+};\r
+\r
+enum TPicoKeys\r
+{\r
+ EPicoUpKey,\r
+ EPicoDownKey,\r
+ EPicoLeftKey,\r
+ EPicoRightKey,\r
+ EPicoAKey,\r
+ EPicoBKey,\r
+ EPicoCKey,\r
+ EPicoXKey,\r
+ EPicoYKey,\r
+ EPicoZKey,\r
+ EPicoModeKey,\r
+ EPicoStartKey,\r
+ EPicoULKey,\r
+ EPicoURKey,\r
+ EPicoDRKey,\r
+ EPicoDLKey,\r
+ EPicoResetKey,\r
+ EPicoPanLKey,\r
+ EPicoPanRKey,\r
+ EPicoNoKeys\r
+};\r
+\r
+class CPicoAddCheatDlg:public CEikDialog\r
+{\r
+public:\r
+ CPicoAddCheatDlg(TDes8& aCheatCode):iCheatCode(aCheatCode){};\r
+ ~CPicoAddCheatDlg(){ iEikonEnv->EikAppUi()->RemoveFromStack(this);}\r
+ TBool OkToExitL(TInt /*aButtonId*/)\r
+ {\r
+ static_cast<CEikEdwin*>(ControlOrNull(0x2000))->GetText(iUniCheatCode);\r
+ iCheatCode.Copy(iUniCheatCode);\r
+ return ETrue;\r
+ }\r
+\r
+ void PreLayoutDynInitL()\r
+ {\r
+ iEikonEnv->EikAppUi()->AddToStackL(this);\r
+ }\r
+private:\r
+ TDes8& iCheatCode;\r
+ TBuf<16> iUniCheatCode;\r
+};\r
+\r
+#ifdef S60V3\r
+class CPicoDriveDoc:public CAknDocument\r
+{\r
+public:\r
+ CPicoDriveDoc(CEikApplication& aApp);\r
+ ~CPicoDriveDoc();\r
+ CEikAppUi* CreateAppUiL();\r
+};\r
+\r
+class CPicoDriveApp:public CAknApplication\r
+{\r
+public:\r
+ CPicoDriveApp();\r
+ ~CPicoDriveApp();\r
+ TUid AppDllUid()const;\r
+ CApaDocument* CreateDocumentL();\r
+\r
+ /**\r
+ * From @c CApaApplication. Opens the .ini file associated with the\r
+ * application. By default, ini files are not supported by SERIES60 \r
+ * applications. If you want to use an ini file, either override this\r
+ * function to base call @c CEikApplication::OpenIniFileLC, or call it\r
+ * directly.\r
+ * @param aFs File server session to use. Not used.\r
+ * @return Pointer to the dictionary store object representing the\r
+ * application's .ini file.\r
+ */\r
+ CDictionaryStore* OpenIniFileLC(RFs& aFs) const;\r
+};\r
+#endif\r
+\r
+class CQPicoDriveView:public CCoeControl,public MDirectScreenAccess\r
+ {\r
+public:\r
+ CQPicoDriveView() {};\r
+ ~CQPicoDriveView();\r
+ void Draw(const TRect& aRect) const;\r
+ void ConstructL();\r
+ void PutBitmap(CFbsBitmap* aBitmap,TPoint aPoint,TRect aRect);\r
+ void Restart(RDirectScreenAccess::TTerminationReasons aReason);\r
+ void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);\r
+ void DrawText(const TDesC& aText,TPoint aPoint,TBool aHighLight=EFalse,TRgb aTextColour = KRgbWhite);\r
+ TInt DrawTextInRect(const TDesC& aText,TRect aRect,TInt aStartPos);\r
+ void Clear();\r
+ CDirectScreenAccess* iDsa;\r
+ TBool iDrawingOn;\r
+ TBool iForeground;\r
+ };\r
+\r
+\r
+class CPicoDriveUi:public CAknAppUi,public MMdaAudioOutputStreamCallback\r
+{\r
+public:\r
+ CPicoDriveUi();\r
+ ~CPicoDriveUi();\r
+ void ConstructL();\r
+ void StartAsynchUpdate();\r
+protected:\r
+ static TInt AsyncUpdateL(TAny* aAppUi);\r
+ void StartEmulatorL();\r
+ virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);\r
+ void HandleForegroundEventL(TBool aForeground);\r
+ // Menu drawers\r
+ void PutMainMenu();\r
+ void PutScreenSelect();\r
+ void PutControllerSelect();\r
+ void PutConfigKeys();\r
+ void PutSoundSelect();\r
+ void PutCheatSelect();\r
+ void PutAbout(TBool iOnlyRedraw = EFalse);\r
+\r
+ // Asynch screen update callback\r
+ void UpdateScreen();\r
+\r
+ TInt SelectFile(TFileName& aFileName);\r
+ // Emulation functions\r
+ int EmulateInit();\r
+ void EmulateExit();\r
+ int EmulateFrame();\r
+ int InputFrame();\r
+ int TargetInit();\r
+ void CalulateLineStarts();\r
+\r
+ static TInt IdleCallBackStop(TAny* aAppUi);\r
+ static TInt StartEmulatorL(TAny* aAppUi);\r
+ // Settings storage\r
+ void SaveSettingsL();\r
+ void InternalizeL(const CDictionaryStore& aStore);\r
+ void ExternalizeL( CDictionaryStore& aStore);\r
+\r
+ // Save state handling\r
+ int saveLoadGame(int load, int sram);\r
+\r
+ /**\r
+ * Calculates the palette table 0-4096\r
+ */\r
+ void CalculatePaletteTable();\r
+ CAsyncCallBack iIdleCallBack;\r
+\r
+ // Variables\r
+ TUint16 iPad1;\r
+ TUint16 iPad2; \r
+ TFileName iRomName;\r
+ char RomName[260];\r
+ TInt iScanCodes[EPicoNoKeys];\r
+ TInt iCurrentScan;\r
+ CDesCArrayFlat* iKeyNames;\r
+ CDesCArrayFlat* iRegNames;\r
+ TBool iEmuRunning;\r
+ CQPicoDriveView* iView;\r
+ TInt iResourceFileId;\r
+ CAsyncCallBack iStartUp;\r
+ CFbsBitmap* iBackBuffer;\r
+ TFileName iAppPath;\r
+ TPoint iPutPoint;\r
+ TRect iPutRect; \r
+ TInt iSelection;\r
+ TInt iSndSelection;\r
+ TInt iCtrlSelection;\r
+ TInt iCheatSelection;\r
+ TInt iNoCheats;\r
+ TBool iCheatEnter;\r
+ CEikDialog* iCheatDlg;\r
+ TInt iListOffset;\r
+ TInt iScrMode;\r
+ TInt iLastScrMode;\r
+ TBool iRomLoaded;\r
+ TBool iInterpolate;\r
+ TBool iStretch;\r
+ TBool iEnableSixButtons;\r
+ TPicoMenus iPicoMenu;\r
+ CAsyncCallBack iAsyncUpdate;\r
+\r
+ // sound support\r
+ CMdaAudioOutputStream* iSndStream;\r
+ TMdaAudioDataSettings iAudioSettings;\r
+ TBuf8<442*2*6> iMonoSound;\r
+ TInt iCurrentSeg;\r
+ TBool iEnableSound;\r
+ TBool iSndRateChanged;\r
+ TInt iSoundVolume; // 0-10 in 10% percent\r
+ void MaoscOpenComplete(TInt aError);\r
+ void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer);\r
+ void MaoscPlayComplete(TInt aError);\r
+ // Update the sound output rate\r
+ TBool UpdatePSndRate();\r
+\r
+ // Rom pointers\r
+ unsigned char *RomData;\r
+ unsigned int RomSize;\r
+ \r
+ TInt64 LastSecond;\r
+ int FramesDone;\r
+ int FramesPerSecond;\r
+ TDisplayMode iDisplayMode;\r
+ TInt iLastAboutPos;\r
+ TBool iFirstStart;\r
+ TInt iFrameSkip;\r
+ TInt iFontHeight; \r
+ int (*myPicoScan)(unsigned int scan,unsigned short *pal);\r
+ TBuf<1024> iTempString;\r
+ // make save filename\r
+ char saveFname[KMaxFileName];\r
+\r
+};\r
+\r
+#endif\r