initial import

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@2 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2006-12-19 20:53:21 +00:00
parent 2cadbd5e56
commit cc68a136aa
341 changed files with 180839 additions and 0 deletions

View file

@ -0,0 +1,644 @@
/*******************************************************************
*
* File: App.cpp
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#include "app.h"
// #include "picodriven.mbg" // bitmap identifiers
#include "picodriven.rsg"
#include <eikenv.h>
#include <qbtselectdlg.h>
//#include <gulutil.h>
//#include <bautils.h>
#include <eikmenub.h> // CEikMenuBar
#include <apgtask.h> // TApaSystemEvent
#include "Dialogs.h"
CApaDocument* CPicolApplication::CreateDocumentL()
{
return new (ELeave) CPicolDocument(*this);
}
CPicolDocument::CPicolDocument(CEikApplication& aApp)
: CEikDocument(aApp)
{
}
CPicolDocument::~CPicolDocument()
{
}
CEikAppUi* CPicolDocument::CreateAppUiL()
{
return new(ELeave) CPicolAppUi;
}
////////////////////////////////////////////////////////////////
//
// class CPicolAppUi
//
////////////////////////////////////////////////////////////////
CPicolAppUi::CPicolAppUi()
: iCurrentLConfig(iCurrentConfig)
{
// set default config
Mem::FillZ(&iCurrentConfig, sizeof(iCurrentConfig));
iCurrentConfig.iFlags = 1; // use_sram
iCurrentConfig.iFrameskip = TPicoConfig::PFSkipAuto;
iCurrentConfig.iScreenRotation = TPicoConfig::PRot90;
}
CPicolAppUi::~CPicolAppUi()
{
delete iAppView;
DeregisterView(*iFOView);
delete iFOView;
DeregisterView(*iFCView);
delete iFCView;
}
void CPicolAppUi::ConstructL()
{
BaseConstructL();
// load config
iCurrentLConfig.Load();
iAppView=new(ELeave) CEPicolAppView;
iAppView->ConstructL(ClientRect());
iFOView=new(ELeave) CPicolFOView(*iAppView);
RegisterViewL(*iFOView);
iFCView=new(ELeave) CPicolFCView(*iAppView);
RegisterViewL(*iFCView);
}
void CPicolAppUi::HandleCommandL(TInt aCommand)
{
TInt oldFrameskip = iCurrentConfig.iFrameskip;
TInt res;
// give time for config dialog destruction
if(iAfterConfigDialog) {
iAfterConfigDialog = EFalse;
TTime now; now.UniversalTime();
if(now.MicroSecondsFrom(iConfigDialogClosed).Int64().Low() < 2500*1000)
User::After(2500*1000-now.MicroSecondsFrom(iConfigDialogClosed).Int64().Low());
}
switch (aCommand)
{
case EEikCmdPicoLoadState:
if(iGameRunner) {
CEikonEnv::Static()->BusyMsgL(_L("Loading State"));
res = ss.SendReceive(PicoMsgLoadState, 0);
CEikonEnv::Static()->BusyMsgCancel();
// emu doesn't start to run if load fails, so we can display this
if(res) CEikonEnv::Static()->InfoMsg(_L("Load Failed"));
}
break;
case EEikCmdPicoSaveState:
if(iGameRunner) {
CEikonEnv::Static()->BusyMsgL(_L("Saving State"));
res = ss.SendReceive(PicoMsgSaveState, 0);
CEikonEnv::Static()->BusyMsgCancel();
if(res) CEikonEnv::Static()->InfoMsg(_L("Save Failed"));
}
break;
case EEikCmdPicoLoadROM:
DisplayOpenROMDialogL();
break;
case EEikCmdPicoResume:
ss.Send(PicoMsgResume, 0);
iEmuRunning = ETrue;
break;
case EEikCmdPicoReset:
ss.Send(PicoMsgReset, 0);
iEmuRunning = ETrue;
break;
case EEikCmdPicoKeys:
if(!iGameRunner) RunGameL();
ss.Send(PicoMsgKeys, 0);
iEmuRunning = ETrue;
break;
case EEikCmdPicoSettings:
DisplayConfigDialogL();
break;
case EEikCmdHelpAbout: // EEikCmdPicoAbout:
DisplayAboutDialogL();
break;
// standard identifier must be used here, TApaTask::EndTask() and probably others send it
case EEikCmdExit: // EEikCmdPicoExit:
if(iGameRunner) {
iQuitting = ETrue;
iExitForcer = CExitForcer::NewL(*this, 2000);
ss.Send(PicoMsgQuit, 0);
} else {
iCurrentLConfig.Save();
DEBUGPRINT(_L("[app] Exit (menu)"));
Exit();
}
break;
// frameskips
case EEikCmdPicoFrameskipAuto:
iCurrentConfig.iFrameskip = TPicoConfig::PFSkipAuto;
break;
case EEikCmdPicoFrameskip0:
iCurrentConfig.iFrameskip = TPicoConfig::PFSkip0;
break;
case EEikCmdPicoFrameskip1:
iCurrentConfig.iFrameskip = 1;
break;
case EEikCmdPicoFrameskip2:
iCurrentConfig.iFrameskip = 2;
break;
case EEikCmdPicoFrameskip4:
iCurrentConfig.iFrameskip = 4;
break;
case EEikCmdPicoFrameskip8:
iCurrentConfig.iFrameskip = 8;
break;
case EEikCmdPicoDebugKillEmu:
if(iGameRunner) {
iExitForcer = CExitForcer::NewL(*this, 4000);
ss.Send(PicoMsgQuit, 0);
}
break;
case EEikCmdPicoDebugInfo:
if(iGameRunner)
DisplayDebugDialogL();
break;
}
// send config update if needed
if(iCurrentConfig.iFrameskip != oldFrameskip)
SendConfig();
}
void CPicolAppUi::HandleSystemEventL(const TWsEvent& aEvent)
{
TApaSystemEvent event;
event = *(TApaSystemEvent*)aEvent.EventData();
if(event == EApaSystemEventBroughtToForeground) // application brought to foreground
{
DEBUGPRINT(_L("[app] EApaSystemEventBroughtToForeground, iEmuRunning=%i"), iEmuRunning);
// we might have missed flip open event (when moved to background),
// so make sure we have correct view active
if(iCoeEnv->ScreenDevice()->CurrentScreenMode() == EScreenModeFlipOpen) {
ActivateViewL(TVwsViewId(KUidPicolApp, KUidPicolFOView));
return;
}
}
if(event == EApaSystemEventShutdown)
{
DEBUGPRINT(_L("[app] EApaSystemEventShutdown"));
}
CEikAppUi::HandleSystemEventL(aEvent);
}
// called just before the menu is shown
void CPicolAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
if(aResourceId == R_APP_EMU_MENU) {
TBool dimmed = !iGameRunner || !iROMLoaded;
aMenuPane->SetItemDimmed(EEikCmdPicoLoadState, dimmed);
aMenuPane->SetItemDimmed(EEikCmdPicoSaveState, dimmed);
aMenuPane->SetItemDimmed(EEikCmdPicoResume, dimmed);
aMenuPane->SetItemDimmed(EEikCmdPicoReset, dimmed);
} else if(aResourceId == R_APP_FRAMESKIP_MENU) {
TInt itemToCheck = EEikCmdPicoFrameskipAuto;
switch(iCurrentConfig.iFrameskip) {
case 0: itemToCheck = EEikCmdPicoFrameskip0; break;
case 1: itemToCheck = EEikCmdPicoFrameskip1; break;
case 2: itemToCheck = EEikCmdPicoFrameskip2; break;
case 4: itemToCheck = EEikCmdPicoFrameskip4; break;
case 8: itemToCheck = EEikCmdPicoFrameskip8; break;
}
aMenuPane->SetItemButtonState(itemToCheck, EEikMenuItemSymbolOn);
}
}
void CPicolAppUi::DisplayAboutDialogL()
{
CEikDialog* dialog = new(ELeave) CAboutDialog;
TInt iButtonRes = dialog->ExecuteLD(R_DIALOG_ABOUT);
if(iButtonRes == EEikBidYes) {
CCreditsDialog *creditsDialog = new (ELeave) CCreditsDialog();
creditsDialog->iMessageResourceID = R_TBUF_CREDITS;
creditsDialog->ExecuteLD(R_DIALOG_CREDITS);
}
}
void CPicolAppUi::DisplayOpenROMDialogL()
{
TFileName file(iCurrentLConfig.iLastROMFile);
CEikDialog* dialog = new(ELeave) CEikFileOpenDialog(&file);
//((CEikFileOpenDialog *)dialog)->SetRequiredExtension(&ext);
if(dialog->ExecuteLD(R_EIK_DIALOG_FILE_OPEN) == EEikBidOk) {
CEikonEnv::Static()->BusyMsgL(_L("Loading ROM"));
// start emu process if it is not running
if(!iGameRunner) RunGameL();
iROMLoaded = EFalse;
TBuf8<KMaxFileName> file8;
file8.Copy(file);
TAny *p[KMaxMessageArguments];
p[0]= (TAny*)(&file8);
TInt res = ss.SendReceive(PicoMsgLoadROM, &p[0]);
CEikonEnv::Static()->BusyMsgCancel();
if(res == 1)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to open file."));
else if(res == 2)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to allocate memory."));
else if(res == 3)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("The file you selected is not a game ROM."));
else if(res == 4)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("No game ROMs found in zipfile."));
else if(res == 5)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed while unzipping ROM."));
else if(res < 0)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to send request to emu process."));
else {
iROMLoaded = ETrue;
iEmuRunning = ETrue;
}
// sound errors which leave ROM loaded
if(res == 6)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to allocate sound buffer, disabled sound."));
else if(res == 7)
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to start soundsystem, disabled sound."));
if(res == 6 || res == 7) iCurrentConfig.iFlags &= ~4;
iCurrentLConfig.iLastROMFile.Copy(file);
}
}
void CPicolAppUi::DisplayConfigDialogL()
{
CPicoConfigDialog* configDialog = new(ELeave)CPicoConfigDialog(iCurrentConfig, iCurrentLConfig);
configDialog->ExecuteLD(R_PICO_CONFIG);
if(iGameRunner)
SendConfig();
iCurrentLConfig.Save();
// configDialog seems to be actually destroyed later after returning,
// and this usually happens just after resuming game and causes emu slowdowns :/
iAfterConfigDialog = ETrue;
iConfigDialogClosed.UniversalTime();
}
void CPicolAppUi::DisplayDebugDialogL()
{
// first get our debug info
char dtxt[1024];
TAny *p[KMaxMessageArguments];
TPtr8 descr((TUint8*) dtxt, sizeof(dtxt));
p[0]= (TAny*)(&descr);
ss.SendReceive(PicoMsgRetrieveDebugStr, &p[0]);
CEikDialog* dialog = new(ELeave) CDebugDialog(dtxt);
dialog->ExecuteLD(R_DIALOG_DEBUG);
}
void CPicolAppUi::SendConfig()
{
// send config
if(iGameRunner) {
TAny *p[KMaxMessageArguments];
TPtrC8 descr((TUint8*) &iCurrentConfig, sizeof(iCurrentConfig));
p[0]= (TAny*)(&descr);
ss.Send(PicoMsgConfigChange, &p[0]);
}
}
// get config from emu proc
void CPicolAppUi::RetrieveConfig()
{
// ask to configure keys and receive new config
TAny *p[KMaxMessageArguments];
TPtr8 descr((TUint8*) &iCurrentConfig, sizeof(iCurrentConfig));
p[0]= (TAny*)(&descr);
ss.SendReceive(PicoMsgRetrieveConfig, &p[0]);
iCurrentLConfig.Save();
}
void CPicolAppUi::NotifyEmuDeath()
{
StopGame();
if(iQuitting) {
DEBUGPRINT(_L("[app] Exit (NotifyEmuDeath)"));
iCurrentLConfig.Save();
RProcess me;
me.Terminate(0);
}
}
void CPicolAppUi::NotifyForcedExit()
{
DEBUGPRINT(_L("[app] Exit (NotifyForcedExit)"));
StopGame();
RProcess me;
me.Terminate(0);
}
TBool CPicolAppUi::EmuRunning() const
{
return iEmuRunning;
}
void CPicolAppUi::StopGame()
{
// in case we have busyMsg and process crashes
CEikonEnv::Static()->BusyMsgCancel();
ss.Close();
if(iGameRunner) delete iGameRunner;
iGameRunner = NULL;
if(iExitForcer) delete iExitForcer;
iExitForcer = NULL;
if(iThreadWatcher1) delete iThreadWatcher1;
iThreadWatcher1 = NULL;
iROMLoaded = EFalse;
iEmuRunning = EFalse;
}
void CPicolAppUi::RunGameL()
{
TInt res = KErrNone;
// do one connection attemt to emu and ask it to quit if we succeed
res = ss.Connect();
if(res == KErrNone) {
ss.Send(PicoMsgQuit, 0);
ss.Close();
}
iGameRunner = CGameRunner::NewL(*this);
// Connect to the server
// we don't want to do complex asynchronous stuff here, so we just
// wait and do several connection attempts
User::After(200000);
for(TInt attempt=0; attempt < 10; attempt++) {
res = ss.Connect();
if(res == KErrNone) break;
User::After(200000);
}
if(res != KErrNone) {
CEikonEnv::Static()->BusyMsgCancel();
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to communicate with the emulation process."));
StopGame();
RProcess me;
me.Terminate(2);
}
// now we are successfully connected, that means emu process' helper-communication thread is running.
// we have to keep an eye on it too, because if it crashes, symbian OS leaves it's process
// alive, but it becomes useless without it's communication thread so we have to detect it's death.
iThreadWatcher1 = CThreadWatcher::NewL(*this, KServerName);
// send initial config
SendConfig();
}
/*
void CPicolAppUi::HandleScreenDeviceChangedL()
{
// does not receive when emu is in foreground
if(iCoeEnv->ScreenDevice()->CurrentScreenMode() == 0) { // flip open
// regain focus
//iCoeEnv->BringOwnerToFront();
}
// ss.Send(PicoMsgFlipChange, 0);
}
*/
void CPicolAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent& aEvent)
{
DEBUGPRINT(_L("[app] event from server: %i"), aEvent.Type());
switch (aEvent.Type())
{
case EEventKeyCfgDone:
RetrieveConfig();
break;
case EEventGamePaused:
iEmuRunning = EFalse;
break;
}
}
////////////////////////////////////////////////////////////////
//
// class CEPicolAppView
//
////////////////////////////////////////////////////////////////
void CEPicolAppView::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect(aRect);
ActivateL();
/*
* Load background image
*/
/*
TBuf<1> name = _L("*");
TRAPD(err, iBgImage = CEikonEnv::Static()->CreateBitmapL(name, EMbmEdoomDoom));
if (iBgImage)
{
iImagePosition.iX = (aRect.Size().iWidth - iBgImage->SizeInPixels().iWidth) / 2;
iImagePosition.iY = (aRect.Size().iHeight - iBgImage->SizeInPixels().iHeight) / 2;
}
*/
}
CEPicolAppView::~CEPicolAppView()
{
//if (iBgImage) delete iBgImage;
}
void CEPicolAppView::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
//if (iBgImage)
//{
// gc.DrawBitmap(iImagePosition, iBgImage);
// DrawUtils::ClearBetweenRects(gc, Rect(), TRect(iImagePosition, iBgImage->SizeInPixels()));
//}
//else
gc.Clear();//aRect);
}
////////////////////////////////////////////////////////////////
//
// class CPicolViewBase
//
////////////////////////////////////////////////////////////////
void CPicolViewBase::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
{
TPixelsAndRotation sizeAndRotation;
CEikonEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(sizeAndRotation);
CEikonEnv::Static()->ScreenDevice()->SetScreenSizeAndRotation(sizeAndRotation);
//iAppViewCtl.MakeVisible(ETrue);
}
void CPicolViewBase::ViewDeactivated()
{
//iAppViewCtl.MakeVisible(EFalse);
}
////////////////////////////////////////////////////////////////
//
// class CPicolFOView
//
////////////////////////////////////////////////////////////////
TVwsViewId CPicolFOView::ViewId() const
{
return TVwsViewId(KUidPicolApp, KUidPicolFOView);
}
TVwsViewIdAndMessage CPicolFOView::ViewScreenDeviceChangedL()
{
// only handle change to FC mode when emu process is running
if(static_cast<CPicolAppUi*>(CEikonEnv::Static()->AppUi())->EmuRunning())
return TVwsViewIdAndMessage(TVwsViewId(KUidPicolApp, KUidPicolFCView));
else return MCoeView::ViewScreenDeviceChangedL();
}
TBool CPicolFOView::ViewScreenModeCompatible(TInt aScreenMode)
{
return (aScreenMode == EScreenModeFlipOpen);
}
void CPicolFOView::ViewActivatedL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage)
{
DEBUGPRINT(_L("[app] FO"));
CPicolViewBase::ViewActivatedL(aPrevViewId, aCustomMessageId, aCustomMessage);
CEikonEnv::Static()->AppUiFactory()->MenuBar()->MakeVisible(ETrue);
iAppViewCtl.SetRect(static_cast<CEikAppUi*>(CEikonEnv::Static()->AppUi())->ClientRect());
}
////////////////////////////////////////////////////////////////
//
// class CPicolFCView
//
////////////////////////////////////////////////////////////////
TVwsViewId CPicolFCView::ViewId() const
{
return TVwsViewId(KUidPicolApp, KUidPicolFCView);
}
TVwsViewIdAndMessage CPicolFCView::ViewScreenDeviceChangedL()
{
return TVwsViewIdAndMessage(TVwsViewId(KUidPicolApp, KUidPicolFOView));
}
TBool CPicolFCView::ViewScreenModeCompatible(TInt aScreenMode)
{
return (aScreenMode == EScreenModeFlipClosed);
}
void CPicolFCView::ViewActivatedL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage)
{
DEBUGPRINT(_L("[app] FC"));
CPicolViewBase::ViewActivatedL(aPrevViewId, aCustomMessageId, aCustomMessage);
CEikonEnv::Static()->AppUiFactory()->MenuBar()->MakeVisible(EFalse);
//iAppViewCtl.ChangeLayout(ETrue);
iAppViewCtl.SetRect(CEikonEnv::Static()->ScreenDevice()->SizeInPixels());
}
////////////////////////////////////////////////////////////////
//
// framework
//
////////////////////////////////////////////////////////////////
GLDEF_C TInt E32Dll(TDllReason)
{
return KErrNone;
}
EXPORT_C CApaApplication* NewApplication()
{
return new CPicolApplication;
}
TUid CPicolApplication::AppDllUid() const
{
return KUidPicolApp;
}

View file

@ -0,0 +1,178 @@
/*******************************************************************
*
* File: App.h
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2001, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#ifndef __APP_H
#define __APP_H
#include <coecntrl.h>
#include <coeccntx.h>
#include <coemain.h>
#include <eikappui.h>
#include <eikapp.h>
#include <eikdoc.h>
#include "Engine.h"
#include "../ClientServer.h"
#include "SimpleClient.h"
#include "picodriven.hrh"
const TUid KUidPicolApp = { 0x1000C193 };
const TUid KUidPicolFOView = { 0x1000C194 };
const TUid KUidPicolFCView = { 0x1000C195 };
enum
{
EScreenModeFlipOpen = 0,
EScreenModeFlipClosed
};
//class CWsBitmap;
class CPicolDocument : public CEikDocument
{
public:
~CPicolDocument();
CPicolDocument(CEikApplication& aApp);
void ConstructL();
private: // from CEikDocument
CEikAppUi* CreateAppUiL();
};
class CEPicolAppView : public CCoeControl // , public MCoeControlBrushContext
{
public:
~CEPicolAppView();
void ConstructL(const TRect& aRect);
private:
void Draw(const TRect& aRect) const;
//CWsBitmap* iBgImage;
//TPoint iImagePosition;
};
class CPicolViewBase : public CBase, public MCoeView
{
public:
CPicolViewBase(CEPicolAppView& aAppViewCtl) : iAppViewCtl(aAppViewCtl) {}
//~CPicolViewBase();
protected:
// implements MCoeView:
virtual void ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/);
virtual void ViewDeactivated();
//virtual void ViewConstructL();
CEPicolAppView& iAppViewCtl;
};
class CPicolFOView : public CPicolViewBase
{
public:
CPicolFOView(CEPicolAppView& aAppViewCtl) : CPicolViewBase(aAppViewCtl) {}
//~CPicolFOView();
virtual TVwsViewId ViewId() const;
virtual TVwsViewIdAndMessage ViewScreenDeviceChangedL();
virtual TBool ViewScreenModeCompatible(TInt aScreenMode);
virtual void ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/);
};
class CPicolFCView : public CPicolViewBase
{
public:
CPicolFCView(CEPicolAppView& aAppViewCtl) : CPicolViewBase(aAppViewCtl) {}
//~CPicolFCView();
virtual TVwsViewId ViewId() const;
virtual TVwsViewIdAndMessage ViewScreenDeviceChangedL();
virtual TBool ViewScreenModeCompatible(TInt aScreenMode);
virtual void ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/);
};
class CPicolAppUi : public CEikAppUi, public MGameWatcher
{
public:
CPicolAppUi();
void ConstructL();
~CPicolAppUi();
public: // implements MGameWatcher
void NotifyEmuDeath();
void NotifyForcedExit();
TBool EmuRunning() const;
protected: // from CEikAppUi
void HandleCommandL(TInt aCommand);
void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
void HandleSystemEventL(const TWsEvent& aEvent);
protected: // new stuf
void DisplayAboutDialogL();
void DisplayOpenROMDialogL();
void DisplayConfigDialogL();
void DisplayDebugDialogL();
void StopGame();
void RunGameL();
void SendConfig();
void RetrieveConfig();
CGameRunner* iGameRunner;
CExitForcer* iExitForcer; // makes sure emu process exits
CThreadWatcher* iThreadWatcher1; // emu process helper thread watcher
RServSession ss;
private:
//void HandleScreenDeviceChangedL();
//void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination);
virtual void HandleApplicationSpecificEventL(TInt aType, const TWsEvent& aEvent);
private:
TBool iQuitting;
TBool iROMLoaded;
TBool iEmuRunning;
TBool iAfterConfigDialog;
TTime iConfigDialogClosed;
TPicoConfig iCurrentConfig;
TPLauncherConfig iCurrentLConfig;
CEPicolAppView* iAppView;
CPicolFOView* iFOView;
CPicolFCView* iFCView;
};
class CPicolApplication : public CEikApplication
{
private: // from CApaApplication
CApaDocument* CreateDocumentL();
TUid AppDllUid() const;
};
#endif

View file

@ -0,0 +1,477 @@
/*******************************************************************
*
* File: CSimpleTextParser.cpp
*
* Author: Peter van Sebille (peter@yipton.net)
*
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#include "CSimpleTextParser.h"
enum
{
EBadTag,
EBadZeroLengthTag,
EBadIntegerParam,
EBadAlignmentParam,
EBadRgbColorParam
};
void Panic(TInt aPanic)
{
User::Panic(_L("STP"), aPanic);
}
CSimpleTextFormatParser* CSimpleTextFormatParser::NewLC()
{
CSimpleTextFormatParser* self = new(ELeave)CSimpleTextFormatParser;
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CSimpleTextFormatParser::~CSimpleTextFormatParser()
{
delete iParaFormat;
}
void CSimpleTextFormatParser::ConstructL()
{
iParaFormat = CParaFormat::NewL();
}
void CSimpleTextFormatParser::SetBold(TBool aEnable)
{
iCharFormat.iFontSpec.iFontStyle.SetStrokeWeight(aEnable ? EStrokeWeightBold : EStrokeWeightNormal);
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttFontStrokeWeight);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
void CSimpleTextFormatParser::SetItalic(TBool aEnable)
{
iCharFormat.iFontSpec.iFontStyle.SetPosture(aEnable ? EPostureItalic : EPostureUpright);
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttFontPosture);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
void CSimpleTextFormatParser::SetUnderLine(TBool aEnable)
{
iCharFormat.iFontPresentation.iUnderline = aEnable ? EUnderlineOn : EUnderlineOff;
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttFontUnderline);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
void CSimpleTextFormatParser::SetHiddenText(TBool aEnable)
{
iCharFormat.iFontPresentation.iHiddenText = aEnable;
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttFontHiddenText);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
TRgb CSimpleTextFormatParser::ForegroundColor()
{
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttColor);
iRichText->GetCharFormat(iCharFormat, iCharMask, TextPos(), 0);
return iCharFormat.iFontPresentation.iTextColor;
}
void CSimpleTextFormatParser::SetForegroundColor(const TRgb& aColor)
{
iCharFormat.iFontPresentation.iTextColor = aColor;
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttColor);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
void CSimpleTextFormatParser::SetBackgroundColor(const TRgb& aColor)
{
iParaFormat->iFillColor = aColor;
iParaMask.ClearAll();
iParaMask.SetAttrib(EAttFillColor);
iRichText->ApplyParaFormatL(iParaFormat, iParaMask, ParaPos(), 0);
}
void CSimpleTextFormatParser::NewParagraph()
{
iCurrentPara++;
iRichText->AppendParagraphL();
AppendTextL(_L(""));
}
void CSimpleTextFormatParser::SetAlignment(CParaFormat::TAlignment aAlignment)
{
iParaFormat->iHorizontalAlignment = aAlignment;
iParaMask.ClearAll();
iParaMask.SetAttrib(EAttAlignment);
iRichText->ApplyParaFormatL(iParaFormat, iParaMask, ParaPos(), 0);
}
void CSimpleTextFormatParser::SetFontHeight(TInt aHeight)
{
iCharFormat.iFontSpec.iHeight = (aHeight * KTwipsPerInch)/KPointsPerInch;
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttFontHeight);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
void CSimpleTextFormatParser::SetFontName(const TDesC& aName)
{
iCharFormat.iFontSpec.iTypeface.iName = aName;
iCharFormat.iFontSpec.iTypeface.SetAttributes(0);
iCharFormat.iFontSpec.iTypeface.SetIsProportional(ETrue);
iCharMask.ClearAll();
iCharMask.SetAttrib(EAttFontTypeface);
iRichText->ApplyCharFormatL(iCharFormat, iCharMask, TextPos(), 0);
}
/*
* Character formatting:
* <b> Bold on
* </b> Bold of
* <i> Italic on
* </i> Italic off
* <u> Underline on
* </u> Underline off
* <h> Hidden text on **doesn't work**
* </h> Hidden text off **doesn't work**
* <f=name> Fontname: name (type: string)
* <s=size> Fontsize: size (type: integer)
* <fg=color> Foreground color: color (type: color)
* </fg> Restore foreground color
*
* Paragraph formatting:
* <p> New paragraph - will reset both character & paragraph formatting to defaults
* <a=align> Alignment: aling (type: alignement)
* <bg=color> Background color: color (type: color) **doesn't work**
*
* Special characters:
* </<> The character: <
*
* Types:
* - string:
* - integer: Either decimal or hexidecimal value
* - color: Either integer specifing rgb value, or (r,g,b) in which r, g and b are of type integer
* - align: element of enumeration {center, left, right}
*
* Comments:
* The syntax/parser is fairly simplistic. The parser is not trying to match a tag like
* <tag> </tag> as XML/HTML do. Basically, when it encounters a tag (e.g., <b>) it will
* simply instruct the the editor to apply the formatting from the current position as
* specified by the tag (e.g., enable bold). For example, <b><b>Hello</b>World</b> results
* in Hello displayed in a Bold font and World in a normal font.
*
* The only case where state is maintained is when using <fg=color> and </fg>. The current
* fg color is stored when parsing <fg=color> and restored when doing </fg>. Again, <fg> and
* </fg> don't have the XML/HTML <tag> </tag> behavior. For example:
* <fg=red>Peter<fg=blue>was</fg></fg>here
* results in "Peter" displayed in red, "was" displayed in blue and "here" displayed in red.
* It literally goes like this:
* 1) <fg=red> --> apply editor text color red, previous color = whatever the editor's text color is now
* 2) <fg=blue> --> apply editor text color blue, previous color = whatever the editor's text color
* is now --> red
* 3) </fg> --> apply editor text to previous color --> red
* 4) </fg> --> apply editor text to previous color --> red
*
* What you probably wanted was:
* <fg=red>Peter</fg><fg=blue>was</fg>here
* Now "Peter" is displayed in red, "was" in blue and "here" in the default editor's color
*/
static TUint32 ParseInteger(const TDesC& aString)
{
TUint32 val = 0;
TBool parsed = EFalse;
if (aString.Length() > 2)
{
if ((aString[0] == '0') && ((aString[0] == 'x') || (aString[0] == 'X')))
{
TLex lex(aString.Right(aString.Length()-2));
if (lex.Val(val, EHex) != KErrNone)
{
__ASSERT_DEBUG(ETrue, Panic(EBadIntegerParam));
}
parsed = ETrue;
}
}
if (!parsed)
{
TLex lex(aString);
if (lex.Val(val, EDecimal) != KErrNone)
{
__ASSERT_DEBUG(ETrue, Panic(EBadIntegerParam));
}
}
return val;
}
static TRgb ParseColor(const TDesC& aString)
{
if (aString.Length() > 0)
{
if (aString[0] == 'R')
{
if (aString.Compare(_L("RgbBlack")) == 0)
return KRgbBlack;
else if (aString.Compare(_L("RgbDarkGray")) == 0)
return KRgbDarkGray;
else if (aString.Compare(_L("RgbDarkRed")) == 0)
return KRgbDarkRed;
else if (aString.Compare(_L("RgbDarkGreen")) == 0)
return KRgbDarkGreen;
else if (aString.Compare(_L("RgbDarkYellow")) == 0)
return KRgbDarkYellow;
else if (aString.Compare(_L("RgbDarkBlue")) == 0)
return KRgbDarkBlue;
else if (aString.Compare(_L("RgbDarkMagenta")) == 0)
return KRgbDarkMagenta;
else if (aString.Compare(_L("RgbDarkCyan")) == 0)
return KRgbDarkCyan;
else if (aString.Compare(_L("RgbRed")) == 0)
return KRgbRed;
else if (aString.Compare(_L("RgbGreen")) == 0)
return KRgbGreen;
else if (aString.Compare(_L("RgbYellow")) == 0)
return KRgbYellow;
else if (aString.Compare(_L("RgbBlue")) == 0)
return KRgbBlue;
else if (aString.Compare(_L("RgbMagenta")) == 0)
return KRgbMagenta;
else if (aString.Compare(_L("RgbCyan")) == 0)
return KRgbCyan;
else if (aString.Compare(_L("RgbGray")) == 0)
return KRgbGray;
else if (aString.Compare(_L("RgbWhite")) == 0)
return KRgbWhite;
else
{
__ASSERT_DEBUG(ETrue, Panic(EBadRgbColorParam));
}
}
return ParseInteger(aString);
}
__ASSERT_DEBUG(ETrue, Panic(EBadRgbColorParam));
return KRgbBlack;
}
static CParaFormat::TAlignment ParseAlignment(const TDesC& aString)
{
if (aString.Compare(_L("center")) == 0)
{
return CParaFormat::ECenterAlign;
}
else if (aString.Compare(_L("left")) == 0)
{
return CParaFormat::ELeftAlign;
}
else if (aString.Compare(_L("right")) == 0)
{
return CParaFormat::ERightAlign;
}
__ASSERT_DEBUG(ETrue, Panic(EBadAlignmentParam));
return CParaFormat::ECenterAlign;
}
void CSimpleTextFormatParser::ParseTagL(const TDesC& aTag)
{
TInt tagLength = aTag.Length();
if (tagLength == 0)
{
__ASSERT_DEBUG(ETrue, Panic(EBadZeroLengthTag));
return;
}
TPtrC param(_L(""));
TInt pos = aTag.Find(_L("="));
if (pos>0)
{
param.Set(aTag.Right(aTag.Length()-pos-1));
tagLength = pos;
}
TPtrC tag = aTag.Left(tagLength);
// RDebug::Print(_L("tag=%S, param=%S"), &tag, &param);
switch (tagLength)
{
case 1:
{
if (tag.Compare(_L("a")) == 0)
SetAlignment(ParseAlignment(param));
else if (tag.Compare(_L("b")) == 0)
SetBold();
else if (tag.Compare(_L("f")) == 0)
SetFontName(param);
else if (tag.Compare(_L("h")) == 0)
SetHiddenText();
else if (tag.Compare(_L("i")) == 0)
SetItalic();
else if (tag.Compare(_L("p")) == 0)
NewParagraph();
else if (tag.Compare(_L("s")) == 0)
SetFontHeight(ParseInteger(param));
else if (tag.Compare(_L("u")) == 0)
SetUnderLine();
else
{
__ASSERT_DEBUG(ETrue, Panic(EBadTag));
}
break;
}
case 2:
{
if (tag.Compare(_L("/b")) == 0)
SetBold(EFalse);
if (tag.Compare(_L("bg")) == 0)
SetBackgroundColor(ParseColor(param));
if (tag.Compare(_L("fg")) == 0)
{
iPrevFgColor = ForegroundColor();
SetForegroundColor(ParseColor(param));
}
else if (tag.Compare(_L("/h")) == 0)
SetHiddenText(EFalse);
else if (tag.Compare(_L("/i")) == 0)
SetItalic(EFalse);
else if (tag.Compare(_L("/u")) == 0)
SetUnderLine(EFalse);
else if (tag.Compare(_L("/<")) == 0)
AppendTextL(_L("<"));
break;
}
case 3:
{
if (tag.Compare(_L("/fg")) == 0)
SetForegroundColor(iPrevFgColor);
break;
}
default:
;
}
}
void CSimpleTextFormatParser::ParseL(const TDesC& aSimpleText, CRichText& aRichText)
{
iRichText = &aRichText;
iCurrentPara = 0;
TBool done = EFalse;
TPtrC simpleText(aSimpleText);
do
{
TInt pos = simpleText.Locate('<');
if (pos > 0)
{
AppendTextL(simpleText.Left(pos));
simpleText.Set(simpleText.Right(simpleText.Length() - pos));
}
else if (pos == 0)
{
pos = simpleText.Locate('>');
if (pos<=0)
User::Leave(KErrArgument);
ParseTagL(simpleText.Mid(1, pos-1));
simpleText.Set(simpleText.Right(simpleText.Length() - pos - 1));
}
else
{
AppendTextL(simpleText);
done = ETrue;
}
} while (!done);
}
TInt CSimpleTextFormatParser::TextPos()
{
return iRichText->DocumentLength();
#if 0
TInt pos, length;
pos = iRichText->CharPosOfParagraph(length, iCurrentPara);
return pos+length-1;
#endif
}
TInt CSimpleTextFormatParser::ParaPos()
{
return TextPos();
#if 0
TInt pos, length;
pos = iRichText->CharPosOfParagraph(length, iCurrentPara);
return pos+length-1;
#endif
}
void CSimpleTextFormatParser::AppendTextL(const TDesC& aText)
{
// RDebug::Print(_L("text=%S"), &aText);
iRichText->InsertL(TextPos(), aText);
}
#if 0
void CTestDialog::ShowTextL(CRichText& aRichText)
{
aRichText.Reset();
TCharFormat charFormat;
TCharFormatMask charMask;
aRichText.GetCharFormat(charFormat, charMask, 0, 0);
TInt para = 0;
AppendTextL(_L("http://www.yipton.net"), aRichText);
para++;
aRichText.AppendParagraphL();
CParaFormat* paraFormat = CParaFormat::NewLC();
TParaFormatMask paraMask;
aRichText.GetParaFormatL(paraFormat, paraMask, ParaPos(aRichText, para), 0);
paraFormat->iHorizontalAlignment = CParaFormat::ECenterAlign;
paraMask.ClearAll();
paraMask.SetAttrib(EAttAlignment);
aRichText.ApplyParaFormatL(paraFormat, paraMask, ParaPos(aRichText, para), 0);
charFormat.iFontPresentation.iUnderline = EUnderlineOn;
charFormat.iFontSpec.iFontStyle.SetPosture(EPostureItalic);
charMask.ClearAll();
charMask.SetAttrib(EAttFontPosture);
charMask.SetAttrib(EAttFontUnderline);
aRichText.ApplyCharFormatL(charFormat, charMask, TextPos(aRichText, para));
AppendTextL(_L("mailto:Peter is here"), aRichText, para);
para++;
aRichText.AppendParagraphL();
TFontSpec fontSpec(_L("edmunds"), 20 * KPointsPerInch);
// CFont* font = NULL;
// iCoeEnv->ScreenDevice()->GetNearestFontInTwips(font, fontSpec);
charFormat.iFontSpec = fontSpec;
charMask.ClearAll();
charMask.SetAttrib(EAttFontHeight);
charMask.SetAttrib(EAttFontTypeface);
aRichText.ApplyCharFormatL(charFormat, charMask, TextPos(aRichText, para));
AppendTextL(_L("mailto:Peter is here"), aRichText, para);
CleanupStack::PopAndDestroy();
}
#endif

View file

@ -0,0 +1,62 @@
/*******************************************************************
*
* File: CSimpleTextParser.h
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#ifndef __CSIMPLE_TEXT_PARSER_H
#define __CSIMPLE_TEXT_PARSER_H
#include <e32def.h>
#include <txtrich.h> // CRichText
#include <eikrted.h> // CEikRichTextEditor
class CSimpleTextFormatParser : public CBase
{
public:
static CSimpleTextFormatParser* NewLC();
void ParseL(const TDesC& aPSTText, CRichText& aRichText);
protected:
CSimpleTextFormatParser(){}
~CSimpleTextFormatParser();
void ConstructL();
void ParseTagL(const TDesC& aTag);
TRgb ForegroundColor();
void SetBold(TBool aEnable=ETrue);
void SetItalic(TBool aEnable=ETrue);
void SetUnderLine(TBool aEnable=ETrue);
void SetFontHeight(TInt aHeight);
void SetFontName(const TDesC& aName);
void SetHiddenText(TBool aEnable=ETrue);
void SetForegroundColor(const TRgb& aColor);
void NewParagraph();
void SetAlignment(CParaFormat::TAlignment aAlignment);
void SetBackgroundColor(const TRgb& aColor);
void AppendTextL(const TDesC& aText);
TInt TextPos();
TInt ParaPos();
CRichText* iRichText;
TCharFormat iCharFormat;
TCharFormatMask iCharMask;
CParaFormat* iParaFormat;
TParaFormatMask iParaMask;
TInt iCurrentPara;
TRgb iPrevFgColor;
};
#endif /* __CSIMPLE_TEXT_PARSER_H */

View file

@ -0,0 +1,473 @@
/*******************************************************************
*
* File: Dialogs.cpp
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#include "Dialogs.h"
#include "Engine.h"
#include "picodriven.hrh"
#include "picodriven.rsg"
#include "../version.h"
#include "CSimpleTextParser.h"
#include <txtrich.h> // CRichText
#include <eikrted.h> // CEikRichTextEditor
#include <qikvertoptionbuttonlist.h> // CEikHorOptionButtonList
#include <eikopbut.h> // CEikOptionButton
#include <QuartzKeys.h> // EQuartzKeyTwoWayDown
/************************************************
*
* config Dialog
*
************************************************/
CPicoConfigDialog::CPicoConfigDialog(TPicoConfig &cfg, TPLauncherConfig &cfgl) : config(cfg), config_l(cfgl)
{
}
void CPicoConfigDialog::PostLayoutDynInitL()
{
CEikHorOptionButtonList *buttons_rot = (CEikHorOptionButtonList*) Control( ECtlOptRotation );
CEikHorOptionButtonList *buttons_disp = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );
CEikCheckBox *chkbox_altrend= (CEikCheckBox*) Control( ECtlOptUseAltRend );
CEikCheckBox *chkbox_acctmng= (CEikCheckBox*) Control( ECtlOptUseAccTiming );
CEikCheckBox *chkbox_sram = (CEikCheckBox*) Control( ECtlOptUseSRAM );
CEikCheckBox *chkbox_fps = (CEikCheckBox*) Control( ECtlOptShowFPS );
CEikCheckBox *chkbox_sound = (CEikCheckBox*) Control( ECtlOptEnableSound );
CEikCheckBox *chkbox_z80 = (CEikCheckBox*) Control( ECtlOptEmulateZ80 );
CEikCheckBox *chkbox_ym2612 = (CEikCheckBox*) Control( ECtlOptEmulateYM2612 );
CEikCheckBox *chkbox_sn76496= (CEikCheckBox*) Control( ECtlOptEmulateSN76496 );
CEikChoiceListBase *combo_sndq = (CEikChoiceListBase*) Control( ECtlOptSndQuality );
CEikCheckBox *chkbox_6bpad = (CEikCheckBox*) Control( ECtlOpt6ButtonPad );
CEikCheckBox *chkbox_gzipst = (CEikCheckBox*) Control( ECtlOptGzipStates );
CEikCheckBox *chkbox_motvol = (CEikCheckBox*) Control( ECtlOptMotDontUseVol );
CEikCheckBox *chkbox_accsprt= (CEikCheckBox*) Control( ECtlOptUseAccSprites );
CEikChoiceListBase *combo_region = (CEikChoiceListBase*) Control( ECtlOptRegion );
CEikOptionButton *opt_fit2 = (CEikOptionButton*) buttons_disp->ComponentControl( TPicoConfig::PMFit2 );
buttons_rot ->SetButtonById(ECtlOptRotation0 + config.iScreenRotation);
buttons_disp->SetButtonById(ECtlOptScreenModeCenter + config.iScreenMode);
chkbox_sram ->SetState(config.iFlags & 1 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_fps ->SetState(config.iFlags & 2 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_sound ->SetState(config.iFlags & 4 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_motvol ->SetState(config.iFlags & 0x40 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_gzipst ->SetState(config.iFlags & 0x80 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_z80 ->SetState(config.iPicoOpt & 4 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_ym2612 ->SetState(config.iPicoOpt & 1 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_sn76496->SetState(config.iPicoOpt & 2 ? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_altrend->SetState(config.iPicoOpt & 0x10? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_6bpad ->SetState(config.iPicoOpt & 0x20? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_acctmng->SetState(config.iPicoOpt & 0x40? CEikButtonBase::ESet : CEikButtonBase::EClear);
chkbox_accsprt->SetState(config.iPicoOpt & 0x80? CEikButtonBase::ESet : CEikButtonBase::EClear);
// hide "fit2" if we are not in 0 or 180 mode
if(config.iScreenRotation != TPicoConfig::PRot0 && config.iScreenRotation != TPicoConfig::PRot180) opt_fit2->MakeVisible(EFalse);
// dim some stuff for alternative renderer
if(config.iPicoOpt & 0x10) {
buttons_disp->SetDimmed(ETrue);
((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot0)))->SetDimmed(ETrue);
((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot180)))->SetDimmed(ETrue);
}
// dim accurate sprites
if(config.iPicoOpt & 0x10) {
chkbox_accsprt->SetState(CEikButtonBase::EClear);
chkbox_accsprt->SetDimmed(ETrue);
}
TInt sel = (config.iPicoOpt&8) ? 4 : 0;
sel+= (config.iFlags>>3)&3;
combo_sndq->SetCurrentItem(sel);
switch(config.PicoRegion) {
case 1: sel = 4; break;
case 2: sel = 3; break;
case 4: sel = 2; break;
case 8: sel = 1; break;
default:sel = 0; // auto
}
combo_region->SetCurrentItem(sel);
}
TBool CPicoConfigDialog::OkToExitL(TInt aButtonId)
{
if(aButtonId != EEikBidOk) return ETrue;
CEikHorOptionButtonList *buttons_rot = (CEikHorOptionButtonList*) Control( ECtlOptRotation );
CEikHorOptionButtonList *buttons_disp = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );
CEikCheckBox *chkbox_altrend= (CEikCheckBox*) Control( ECtlOptUseAltRend );
CEikCheckBox *chkbox_acctmng= (CEikCheckBox*) Control( ECtlOptUseAccTiming );
CEikCheckBox *chkbox_sram = (CEikCheckBox*) Control( ECtlOptUseSRAM );
CEikCheckBox *chkbox_fps = (CEikCheckBox*) Control( ECtlOptShowFPS );
CEikCheckBox *chkbox_sound = (CEikCheckBox*) Control( ECtlOptEnableSound );
CEikCheckBox *chkbox_z80 = (CEikCheckBox*) Control( ECtlOptEmulateZ80 );
CEikCheckBox *chkbox_ym2612 = (CEikCheckBox*) Control( ECtlOptEmulateYM2612 );
CEikCheckBox *chkbox_sn76496= (CEikCheckBox*) Control( ECtlOptEmulateSN76496 );
CEikChoiceListBase *combo_sndq = (CEikChoiceListBase*) Control( ECtlOptSndQuality );
CEikCheckBox *chkbox_6bpad = (CEikCheckBox*) Control( ECtlOpt6ButtonPad );
CEikCheckBox *chkbox_gzipst = (CEikCheckBox*) Control( ECtlOptGzipStates );
CEikCheckBox *chkbox_motvol = (CEikCheckBox*) Control( ECtlOptMotDontUseVol );
CEikCheckBox *chkbox_accsprt= (CEikCheckBox*) Control( ECtlOptUseAccSprites );
CEikChoiceListBase *combo_region = (CEikChoiceListBase*) Control( ECtlOptRegion );
config.iScreenRotation = (TPicoConfig::TPicoScreenRotation) (buttons_rot->LabeledButtonId() - ECtlOptRotation0);
config.iScreenMode = (TPicoConfig::TPicoScreenMode) (buttons_disp->LabeledButtonId() - ECtlOptScreenModeCenter);
if(chkbox_sram ->State() == CEikButtonBase::ESet) config.iFlags |= 1; else config.iFlags &= ~1;
if(chkbox_fps ->State() == CEikButtonBase::ESet) config.iFlags |= 2; else config.iFlags &= ~2;
if(chkbox_sound ->State() == CEikButtonBase::ESet) config.iFlags |= 4; else config.iFlags &= ~4;
if(chkbox_motvol ->State() == CEikButtonBase::ESet) config.iFlags |= 0x40; else config.iFlags &= ~0x40;
if(chkbox_gzipst ->State() == CEikButtonBase::ESet) config.iFlags |= 0x80; else config.iFlags &= ~0x80;
if(chkbox_z80 ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 4; else config.iPicoOpt &= ~4;
if(chkbox_ym2612 ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 1; else config.iPicoOpt &= ~1;
if(chkbox_sn76496->State() == CEikButtonBase::ESet) config.iPicoOpt |= 2; else config.iPicoOpt &= ~2;
if(chkbox_altrend->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x10;else config.iPicoOpt &= ~0x10;
if(chkbox_6bpad ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x20;else config.iPicoOpt &= ~0x20;
if(chkbox_acctmng->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x40;else config.iPicoOpt &= ~0x40;
if(chkbox_accsprt->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x80;else config.iPicoOpt &= ~0x80;
TInt sel = combo_sndq->CurrentItem();
if(sel > 3) { config.iPicoOpt |= 8; sel-=4; } else config.iPicoOpt &= ~8;
config.iFlags &= ~0x18;
config.iFlags |= (sel<<3)&0x18;
switch(combo_region->CurrentItem()) {
case 4: config.PicoRegion = 1; break;
case 3: config.PicoRegion = 2; break;
case 2: config.PicoRegion = 4; break;
case 1: config.PicoRegion = 8; break;
default:config.PicoRegion = 0; // auto
}
return ETrue;
}
// simple GUI stuff needs lots of code
void CPicoConfigDialog::HandleControlStateChangeL(TInt aControlId)
{
if(aControlId == ECtlOptEnableSound) {
CEikCheckBox *chkbox_sound = (CEikCheckBox*) Control( ECtlOptEnableSound );
CEikCheckBox *chkbox_z80 = (CEikCheckBox*) Control( ECtlOptEmulateZ80 );
CEikCheckBox *chkbox_ym2612 = (CEikCheckBox*) Control( ECtlOptEmulateYM2612 );
CEikCheckBox *chkbox_sn76496= (CEikCheckBox*) Control( ECtlOptEmulateSN76496 );
if(chkbox_sound->State() == CEikButtonBase::ESet) {
// check all sound chips too, but only if they all are not set
if((chkbox_z80->State() | chkbox_ym2612->State() | chkbox_sn76496->State()) == CEikButtonBase::EClear) { // (==0)
chkbox_z80 ->SetState(CEikButtonBase::ESet);
chkbox_ym2612 ->SetState(CEikButtonBase::ESet);
chkbox_sn76496->SetState(CEikButtonBase::ESet);
chkbox_z80 ->DrawDeferred();
chkbox_ym2612 ->DrawDeferred();
chkbox_sn76496->DrawDeferred();
}
} else {
// clear everything, but only if everything is set
if((chkbox_z80->State() & chkbox_ym2612->State() & chkbox_sn76496->State()) == CEikButtonBase::ESet) { // (==1)
chkbox_z80 ->SetState(CEikButtonBase::EClear);
chkbox_ym2612 ->SetState(CEikButtonBase::EClear);
chkbox_sn76496->SetState(CEikButtonBase::EClear);
chkbox_z80 ->DrawDeferred();
chkbox_ym2612 ->DrawDeferred();
chkbox_sn76496->DrawDeferred();
}
}
} else if(aControlId == ECtlOptUseAltRend) {
CEikCheckBox *chkbox_altrend= (CEikCheckBox*) Control( ECtlOptUseAltRend );
CEikCheckBox *chkbox_accsprt= (CEikCheckBox*) Control( ECtlOptUseAccSprites );
CEikHorOptionButtonList *buttons_rot = (CEikHorOptionButtonList*) Control( ECtlOptRotation );
CEikHorOptionButtonList *buttons_disp = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );
TBool dimmed = chkbox_altrend->State() == CEikButtonBase::ESet;
// show/hide more stuff for alternative renderer
buttons_disp->SetDimmed(dimmed);
chkbox_accsprt->SetDimmed(dimmed);
((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot0)))->SetDimmed(dimmed);
((CEikOptionButton*)(buttons_rot->ComponentControl(TPicoConfig::PRot180)))->SetDimmed(dimmed);
if(dimmed && buttons_rot->LabeledButtonId() != ECtlOptRotation90 && buttons_rot->LabeledButtonId() != ECtlOptRotation270) {
buttons_rot->SetButtonById(ECtlOptRotation90);
aControlId = ECtlOptRotation; // cause rotation update
}
buttons_disp->SetButtonById(ECtlOptScreenModeCenter);
chkbox_accsprt->DrawDeferred();
buttons_disp->DrawDeferred();
buttons_rot->DrawDeferred();
}
if(aControlId == ECtlOptRotation) {
CEikHorOptionButtonList *buttons_rot = (CEikHorOptionButtonList*) Control( ECtlOptRotation );
CEikHorOptionButtonList *buttons_disp = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );
CEikOptionButton *opt_fit2 = (CEikOptionButton*) buttons_disp->ComponentControl( TPicoConfig::PMFit2 );
if(buttons_rot->LabeledButtonId() == ECtlOptRotation0 || buttons_rot->LabeledButtonId() == ECtlOptRotation180) {
opt_fit2->MakeVisible(ETrue);
opt_fit2->DrawDeferred();
} else {
if(opt_fit2->State() == CEikButtonBase::ESet) {
buttons_disp->SetButtonById(ECtlOptScreenModeFit);
buttons_disp->DrawDeferred();
}
opt_fit2->MakeVisible(EFalse);
}
}
}
/*************************************************************
*
* Credits dialog
*
**************************************************************/
void CCreditsDialog::PreLayoutDynInitL()
{
CDesCArrayFlat* desArray = CEikonEnv::Static()->ReadDesCArrayResourceL(iMessageResourceID);
CleanupStack::PushL(desArray);
TInt iLength;
TInt count = desArray->Count();
for (TInt i=0 ;i < count; i++)
{
iLength = static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->TextLength();
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->Text()->InsertL(iLength, desArray->operator[](i));
iLength = static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->TextLength();
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->Text()->InsertL(iLength, CEditableText::ELineBreak);
}
CleanupStack::PopAndDestroy(desArray);
}
void CCreditsDialog::PostLayoutDynInitL()
{
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->CreateScrollBarFrameL();
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto);
}
TKeyResponse CCreditsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (aType == EEventKey)
{
if (aKeyEvent.iCode == EQuartzKeyTwoWayDown)
{
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->MoveDisplayL(TCursorPosition::EFLineDown);
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->UpdateScrollBarsL();
return EKeyWasConsumed;
}
else if (aKeyEvent.iCode == EQuartzKeyTwoWayUp)
{
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->MoveDisplayL(TCursorPosition::EFLineUp);
static_cast<CEikGlobalTextEditor*>(Control(ECtlCredits))->UpdateScrollBarsL();
return EKeyWasConsumed;
}
}
return CEikDialog::OfferKeyEventL(aKeyEvent, aType);
}
/*************************************************************
*
* Debug dialog
*
**************************************************************/
CDebugDialog::CDebugDialog(char *t)
{
Mem::Copy(iText, t, 1024);
iText[1023] = 0;
}
void CDebugDialog::PreLayoutDynInitL()
{
char *p = iText, *line = iText;
TBool end=0;
TBuf<128> tbuf;
CEikGlobalTextEditor *editor = static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit));
while(!end) {
while(*p && *p != '\r' && *p != '\n') p++;
if(!*p) end=1;
*p = 0;
TPtrC8 ptr((TUint8*) line);
tbuf.Copy(ptr);
editor->Text()->InsertL(editor->TextLength(), tbuf);
editor->Text()->InsertL(editor->TextLength(), CEditableText::ELineBreak);
line = ++p;
}
}
void CDebugDialog::PostLayoutDynInitL()
{
static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->CreateScrollBarFrameL();
static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto);
}
TKeyResponse CDebugDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (aType == EEventKey)
{
if (aKeyEvent.iCode == EQuartzKeyTwoWayDown)
{
static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->MoveDisplayL(TCursorPosition::EFLineDown);
static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->UpdateScrollBarsL();
return EKeyWasConsumed;
}
else if (aKeyEvent.iCode == EQuartzKeyTwoWayUp)
{
static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->MoveDisplayL(TCursorPosition::EFLineUp);
static_cast<CEikGlobalTextEditor*>(Control(ECtlDebugEdit))->UpdateScrollBarsL();
return EKeyWasConsumed;
}
}
return CEikDialog::OfferKeyEventL(aKeyEvent, aType);
}
/************************************************
*
* SimpleTextInfoDialog
*
************************************************/
CSimpleTextInfoDialog::CSimpleTextInfoDialog(TInt aTextIdOne, TInt aRichTextCtlIdOne, TInt aTextIdTwo, TInt aRichTextCtlIdTwo, TBool aSimpleTextResIdOneIsArray, TBool aSimpleTextResIdTwoIsArray)
: iSimpleTextResIdOne(aTextIdOne),
iSimpleTextResIdTwo(aTextIdTwo),
iRichTextCtlIdOne(aRichTextCtlIdOne),
iRichTextCtlIdTwo(aRichTextCtlIdTwo),
iSimpleTextResIdOneIsArray(aSimpleTextResIdOneIsArray),
iSimpleTextResIdTwoIsArray(aSimpleTextResIdTwoIsArray),
iSetDialogBackground(ETrue)
{
}
void CSimpleTextInfoDialog::PreLayoutDynInitL()
{
CEikRichTextEditor* richTextEditor;
if (iRichTextCtlIdOne != -1)
{
richTextEditor=STATIC_CAST(CEikRichTextEditor*, Control(iRichTextCtlIdOne));
PreLayoutDynInitRichTextL(*richTextEditor, iRichTextCtlIdOne, iSimpleTextResIdOne);
}
if (iRichTextCtlIdTwo != -1)
{
richTextEditor=STATIC_CAST(CEikRichTextEditor*, Control(iRichTextCtlIdTwo));
richTextEditor->Border().SetType(ENone);
PreLayoutDynInitRichTextL(*richTextEditor, iRichTextCtlIdTwo, iSimpleTextResIdTwo);
}
}
void CSimpleTextInfoDialog::PreLayoutDynInitRichTextL(CEikRichTextEditor& aRichTextEditor, TInt aRichTextCtlId, TInt aSimpleTextResId)
{
iEikonEnv->BusyMsgL(_L("Opening"));
aRichTextEditor.SetEdwinSizeObserver(this);
if (iSetDialogBackground)
aRichTextEditor.SetBackgroundColorL(iEikonEnv->Color(EColorDialogBackground));
aRichTextEditor.SetSize(aRichTextEditor.Size()); // Set the size of the edwin
// no scrollbars for us
aRichTextEditor.CreateScrollBarFrameL(); // Create the scrollbars
aRichTextEditor.ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, iWantVertScrollbar ? CEikScrollBarFrame::EAuto: CEikScrollBarFrame::EOff);
ShowTextL(*aRichTextEditor.RichText(), aRichTextCtlId, aSimpleTextResId);
aRichTextEditor.UpdateAllFieldsL(); // Updates all the fields in the document
aRichTextEditor.UpdateScrollBarsL();
}
void CSimpleTextInfoDialog::PostLayoutDynInitL()
{
Layout();
iEikonEnv->BusyMsgCancel();
}
TBool CSimpleTextInfoDialog::HandleEdwinSizeEventL(CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize)
{
if ((aEventType == EEventSizeChanging))
aEdwin->SetSize(aDesirableEdwinSize);
return EFalse;
}
void CSimpleTextInfoDialog::ShowTextL(CRichText& aRichText, TInt /*aRichTextCtlId*/, TInt aResId)
{
if (aResId != -1)
{
if ( ((aResId == iSimpleTextResIdOne) && (iSimpleTextResIdOneIsArray)) ||
((aResId == iSimpleTextResIdTwo) && (iSimpleTextResIdTwoIsArray))
)
{
CDesCArrayFlat* desArray = CEikonEnv::Static()->ReadDesCArrayResourceL(aResId);
CleanupStack::PushL(desArray);
CSimpleTextFormatParser* parser = CSimpleTextFormatParser::NewLC();
TInt count = desArray->Count();
for (TInt i=0 ;i<count ; i++)
parser->ParseL(desArray->operator[](i), aRichText);
CleanupStack::PopAndDestroy(parser);
CleanupStack::PopAndDestroy(desArray);
}
else
{
HBufC* text = CEikonEnv::Static()->AllocReadResourceLC(aResId);
ShowSimpleTextL(*text, aRichText);
CleanupStack::PopAndDestroy(text);
}
}
}
void CSimpleTextInfoDialog::ShowSimpleTextL(const TDesC& aSimpleText, CRichText& aRichText)
{
CSimpleTextFormatParser* parser = CSimpleTextFormatParser::NewLC();
parser->ParseL(aSimpleText, aRichText);
CleanupStack::PopAndDestroy(parser);
}
/************************************************
*
* About Dialog
*
************************************************/
CAboutDialog::CAboutDialog() : CSimpleTextInfoDialog(-1, ECtlAboutVersion, R_SIMPLE_TEXT_ABOUT_LINKS, ECtlAboutLinks)
{
}
void CAboutDialog::ShowTextL(CRichText& aRichText, TInt aRichTextCtlId, TInt aResId)
{
if (aRichTextCtlId == ECtlAboutLinks)
CSimpleTextInfoDialog::ShowTextL(aRichText, aRichTextCtlId, aResId);
else
{
TBuf<16> versionText;
TBuf<512> text;
#if (KPicoBuildNumber != 0)
versionText.Format(_L("%d.%d%d"), KPicoMajorVersionNumber, KPicoMinorVersionNumber, KPicoBuildNumber);
#else
versionText.Format(_L("%d.%d"), KPicoMajorVersionNumber, KPicoMinorVersionNumber);
#endif
HBufC* aboutFormat = CEikonEnv::Static()->AllocReadResourceLC(R_SIMPLE_TEXT_ABOUT);
text.Format(*aboutFormat, &versionText);
ShowSimpleTextL(text, aRichText);
CleanupStack::PopAndDestroy(aboutFormat);
}
}

View file

@ -0,0 +1,145 @@
/*******************************************************************
*
* File: Dialogs.h
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#ifndef __DIALOGS_H
#define __DIALOGS_H
#include <eikenv.h>
#include <eikdialg.h>
#include <eiktxlbx.h>
#include <eiktxlbm.h>
#include <eikdlgtb.h>
#include <eiklabel.h>
#include <eikchlst.h>
#include <eikchkbx.h>
#include <eikedwob.h>
#include "../ClientServer.h"
class CRichText;
class CEikRichTextEditor;
class TPLauncherConfig;
/************************************************
*
* CSimpleTextInfo Dialog
*
************************************************/
class CSimpleTextInfoDialog : public CEikDialog, public MEikEdwinSizeObserver
{
public:
CSimpleTextInfoDialog(TInt aTextIdOne = -1, TInt aRichTextCtlIdOne = -1,
TInt aTextIdTwo = -1, TInt aRichTextCtlIdTwo = -1,
TBool aSimpleTextResIdOneIsArray = EFalse, TBool aSimpleTextResIdTwoIsArray = EFalse
);
void SetDialogBackground(TBool aEnable){iSetDialogBackground=aEnable;}
void WantVertScrollbar(TBool aEnable){iWantVertScrollbar=aEnable;}
public: // implements MEikEdwinSizeObserver
virtual TBool HandleEdwinSizeEventL(CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize);
protected: // framework
void PreLayoutDynInitL();
void PostLayoutDynInitL();
protected: // new stuff
virtual void ShowTextL(CRichText& aRichText, TInt aRichTextCtlId, TInt aResId);
virtual void PreLayoutDynInitRichTextL(CEikRichTextEditor& aRichTextEditor, TInt aRichTextCtlId, TInt aResId);
void ShowSimpleTextL(const TDesC& aSimpleText, CRichText& aRichText);
TInt iSimpleTextResIdOne;
TInt iSimpleTextResIdTwo;
TInt iRichTextCtlIdOne;
TInt iRichTextCtlIdTwo;
TBool iSimpleTextResIdOneIsArray;
TBool iSimpleTextResIdTwoIsArray;
TBool iSetDialogBackground;
TBool iWantVertScrollbar;
};
/************************************************
*
* config Dialog
*
************************************************/
class CPicoConfigDialog : public CEikDialog
{
public:
CPicoConfigDialog(TPicoConfig &cfg, TPLauncherConfig &cfgl);
protected: // framework
void PostLayoutDynInitL();
void HandleControlStateChangeL(TInt aControlId);
TBool OkToExitL(TInt aButtonId);
TPicoConfig &config;
TPLauncherConfig &config_l;
};
/************************************************
*
* About Dialog
*
************************************************/
class CAboutDialog : public CSimpleTextInfoDialog
{
public:
CAboutDialog();
protected: // from CSimpleTextInfoDialog
virtual void ShowTextL(CRichText& aRichText, TInt aRichTextCtlId, TInt aResId);
};
/*************************************************************
*
* Credits dialog
*
**************************************************************/
class CCreditsDialog : public CEikDialog
{
public:
TInt iMessageResourceID;
protected:
void PreLayoutDynInitL();
void PostLayoutDynInitL();
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
};
/*************************************************************
*
* Debug dialog
*
**************************************************************/
class CDebugDialog : public CEikDialog
{
public:
CDebugDialog(char *t);
protected:
char iText[1024];
void PreLayoutDynInitL();
void PostLayoutDynInitL();
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
};
#endif // __DIALOGS_H

View file

@ -0,0 +1,256 @@
/*******************************************************************
*
* File: Engine.cpp
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#include "Engine.h"
#include <w32std.h>
#include <eikenv.h>
//#include <eikdll.h>
#include "../version.h"
CGameRunner::~CGameRunner()
{
Cancel();
RProcess process;
if(process.Open(iProcessId) == KErrNone) {
process.Terminate(1);
process.Close();
}
}
CGameRunner::CGameRunner(MGameWatcher& aGameWatcher)
: CActive(CActive::EPriorityStandard), iGameWatcher(aGameWatcher)
{
}
CGameRunner* CGameRunner::NewL(MGameWatcher& aGameWatcher)
{
CGameRunner* self = new(ELeave) CGameRunner(aGameWatcher);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(); // self
return self;
}
void CGameRunner::ConstructL()
{
RProcess newProcess, thisProcess;
// make path to picosmall
TBuf<KMaxFileName> exePath;
TBuf<KMaxFileName*3> tmpbuff; // hopefully large enough
thisProcess.CommandLine(tmpbuff);
TInt pos = tmpbuff.Find(_L(" "));
if(pos == KErrNotFound) pos = tmpbuff.Length();
for(pos--; pos > 2; pos--)
if(tmpbuff[pos] == '\\') break;
if(pos > 2) {
exePath.Copy(tmpbuff.Ptr(), pos+1);
exePath.Append(_L("PICOSMALL.EXE"));
}
DEBUGPRINT(_L("[app] starting EXE: %S"), &exePath);
if(newProcess.Create(exePath, _L(""))) {
CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to start emulation process."));
thisProcess.Terminate(1);
}
iProcessId = newProcess.Id();
DEBUGPRINT(_L("[app] newProcess.Id(): %d"), iProcessId);
CActiveScheduler::Add(this);
newProcess.SetOwner(thisProcess); // Warning: phone strangely reboots when attempting to get owner after thisProcess exits
newProcess.Logon(iStatus);
SetActive();
newProcess.Resume(); // start execution
newProcess.Close();
}
void CGameRunner::RunL()
{
iGameWatcher.NotifyEmuDeath();
}
void CGameRunner::DoCancel()
{
RProcess process;
if(process.Open(iProcessId) == KErrNone) {
process.LogonCancel(iStatus);
process.Close();
}
}
// CExitForcer
CExitForcer::~CExitForcer()
{
Cancel();
}
CExitForcer::CExitForcer(MGameWatcher& aGameWatcher) : CActive(CActive::EPriorityStandard), iGameWatcher(aGameWatcher)
{
}
CExitForcer* CExitForcer::NewL(MGameWatcher& aGameWatcher, TInt ms)
{
CExitForcer* self = new(ELeave) CExitForcer(aGameWatcher);
CleanupStack::PushL(self);
self->ConstructL(ms);
CleanupStack::Pop(); // self
return self;
}
void CExitForcer::ConstructL(TInt ms)
{
CActiveScheduler::Add(this);
iTimer.CreateLocal();
iTimer.After(iStatus, ms*1000);
SetActive();
}
void CExitForcer::RunL()
{
iGameWatcher.NotifyForcedExit();
}
void CExitForcer::DoCancel()
{
if(iTimer.Handle()) {
iTimer.Cancel();
iTimer.Close();
}
}
// CThreadWatcher
CThreadWatcher::~CThreadWatcher()
{
Cancel();
}
CThreadWatcher::CThreadWatcher(MGameWatcher& aGameWatcher, const TDesC& aName)
: CActive(CActive::EPriorityStandard), iGameWatcher(aGameWatcher), iName(aName)
{
}
CThreadWatcher* CThreadWatcher::NewL(MGameWatcher& aGameWatcher, const TDesC& aName)
{
CThreadWatcher* self = new(ELeave) CThreadWatcher(aGameWatcher, aName);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(); // self
return self;
}
void CThreadWatcher::ConstructL()
{
CActiveScheduler::Add(this);
RThread thread;
if(thread.Open(iName) == KErrNone) {
thread.Logon(iStatus);
thread.Close();
SetActive();
}
}
void CThreadWatcher::RunL()
{
iGameWatcher.NotifyEmuDeath();
}
void CThreadWatcher::DoCancel()
{
RThread thread;
if(thread.Open(iName) == KErrNone) {
thread.LogonCancel(iStatus);
thread.Close();
}
}
// config
TPLauncherConfig::TPLauncherConfig(TPicoConfig &cfg)
: iEmuConfig(cfg)
{
iLastROMFile.Copy(_L("C:\\"));
// ini
TBuf<KMaxFileName*3> tmpbuff; // hopefully large enough
RProcess me;
me.CommandLine(tmpbuff);
TInt pos = tmpbuff.Find(_L(" "));
if(pos == KErrNotFound) pos = tmpbuff.Length();
if(pos > 3) {
iIniFileName.Copy(tmpbuff.Ptr(), pos-3);
iIniFileName.Append(_L("ini"));
}
//DEBUGPRINT(_L("[app] made ini: %S"), &iIniFileName);
}
void TPLauncherConfig::Load()
{
RFile file;
if(!file.Open(CEikonEnv::Static()->FsSession(), iIniFileName, 0))
{
TInt version;
TPckg<TInt> pkg_version(version);
TPckg<TBool> pkg_Pad(iPad);
TBuf8<KMaxFileName> pad0; // reserved for future use (6 words)
TPtr8 picoCfg((TUint8*) &iEmuConfig, sizeof(iEmuConfig));
file.Read(pkg_version);
file.Read(pkg_Pad);
file.Read(pad0, 24);
file.Read(pad0, KMaxFileName);
file.Read(picoCfg);
TBuf8<KMaxFileName> file8(pad0.Ptr()); // take as zero terminated string
iLastROMFile.Copy(file8);
//DEBUGPRINT(_L("[app] iLastROMFile (%i): %S"), iLastROMFile.Length(), &iLastROMFile);
file.Close();
}
}
void TPLauncherConfig::Save()
{
RFile file;
if(!file.Replace(CEikonEnv::Static()->FsSession(), iIniFileName, EFileWrite)) {
TInt version = (KPicoMajorVersionNumber<<24)+(KPicoMinorVersionNumber<<16);
TPckgC<TInt> pkg_version(version);
TPckgC<TBool> pkg_Pad(iPad);
TBuf8<KMaxFileName> pad0; pad0.FillZ(KMaxFileName);
TBuf8<KMaxFileName> file8; file8.Copy(iLastROMFile);
TPtrC8 picoCfg((TUint8*) &iEmuConfig, sizeof(iEmuConfig));
file.Write(pkg_version);
file.Write(pkg_Pad); // 0x0004
file.Write(pad0, 24); // 0x0008, reserved for future use (6 words)
file.Write(file8); // 0x0020
file.Write(pad0, KMaxFileName-file8.Length());
file.Write(picoCfg); // 0x0120
file.Close();
}
}

View file

@ -0,0 +1,112 @@
/*******************************************************************
*
* File: Engine.h
*
* Author: Peter van Sebille (peter@yipton.net)
*
* Modified/adapted for picodriveN by notaz, 2006
*
* (c) Copyright 2006, notaz
* (c) Copyright 2002, Peter van Sebille
* All Rights Reserved
*
*******************************************************************/
#ifndef __ENGINE_H
#define __ENGINE_H
#include <e32base.h>
#include <etel.h>
#include "../ClientServer.h"
class RFs;
#ifdef __DEBUG_PRINT
#define DEBUGPRINT(x...) RDebug::Print(x)
#else
#define DEBUGPRINT(x...)
#endif
class MGameWatcher
{
public:
virtual void NotifyEmuDeath() = 0;
virtual void NotifyForcedExit() = 0;
};
class CGameRunner : public CActive
{
public:
static CGameRunner* NewL(MGameWatcher& aGameWatcher);
~CGameRunner();
void KillAfter(TInt ms);
protected:
CGameRunner(MGameWatcher& aGameWatcher);
void ConstructL();
virtual void RunL();
virtual void DoCancel();
MGameWatcher& iGameWatcher;
TProcessId iProcessId;
};
class CExitForcer : public CActive
{
public:
static CExitForcer* NewL(MGameWatcher& aGameWatcher, TInt ms);
~CExitForcer();
protected:
CExitForcer(MGameWatcher& aGameWatcher);
void ConstructL(TInt ms);
virtual void RunL();
virtual void DoCancel();
MGameWatcher& iGameWatcher;
RTimer iTimer;
};
class CThreadWatcher : public CActive
{
public:
static CThreadWatcher* NewL(MGameWatcher& aGameWatcher, const TDesC& aName);
~CThreadWatcher();
protected:
CThreadWatcher(MGameWatcher& aGameWatcher, const TDesC& aName);
void ConstructL();
virtual void RunL();
virtual void DoCancel();
MGameWatcher& iGameWatcher;
const TDesC& iName; // thread name
};
// configuration emu process doesn't care about
class TPLauncherConfig {
public:
TPLauncherConfig(TPicoConfig &cfg);
void Load();
void Save();
TBool iPad; // was iPauseOnCall
TFileName iLastROMFile;
TPicoConfig &iEmuConfig;
private:
TFileName iIniFileName;
};
#endif

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,016 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,70 @@
enum TAppMenuCommands
{
// Emu menu
EEikCmdPicoLoadState = 10000,
EEikCmdPicoSaveState,
EEikCmdPicoLoadROM,
EEikCmdPicoResume,
EEikCmdPicoReset,
EEikCmdPicoKeys,
EEikCmdPicoSettings,
// Frameskip menu
EEikCmdPicoFrameskipAuto,
EEikCmdPicoFrameskip0,
EEikCmdPicoFrameskip1,
EEikCmdPicoFrameskip2,
EEikCmdPicoFrameskip4,
EEikCmdPicoFrameskip8,
// Debug menu
EEikCmdPicoDebugKillEmu,
EEikCmdPicoDebugInfo,
// config Dialog
// pages
ECtlOptPageMain,
ECtlOptPageSound,
ECtlOptPageMisc,
// main page
ECtlOptRotationLabel,
ECtlOptRotation,
ECtlOptRotation0,
ECtlOptRotation90,
ECtlOptRotation180,
ECtlOptRotation270,
ECtlOptScreenModeLabel,
ECtlOptScreenMode,
ECtlOptScreenModeCenter,
ECtlOptScreenModeFit,
ECtlOptScreenModeFit2,
ECtlOptUseAltRend,
ECtlOptUseAccTiming,
ECtlOptUseAccSprites,
ECtlOptShowFPS,
// sound page
ECtlOptEnableSound,
ECtlOptChipSelLabel,
ECtlOptEmulateZ80,
ECtlOptEmulateYM2612,
ECtlOptEmulateSN76496,
ECtlOptSndQLabel,
ECtlOptSndQuality,
// misc page
ECtlOpt6ButtonPad,
ECtlOptGzipStates,
ECtlOptUseSRAM,
ECtlOptMotDontUseVol,
ECtlOptRegionLabel,
ECtlOptRegion,
// credits
ECtlCredits,
// debug
ECtlDebugEdit
};
#define ECtlAboutVersion 1
#define ECtlAboutLinks 2

View file

@ -0,0 +1,34 @@
TARGET PicodriveN.app
TARGETTYPE app
TARGETPATH \system\Apps\PicodriveN
UID 0x100039CE 0x1000C193
USERINCLUDE .
SYSTEMINCLUDE \epoc32\include
SOURCEPATH .
SOURCE App.cpp
SOURCE Engine.cpp
SOURCE Dialogs.cpp
SOURCE CSimpleTextParser.cpp
SOURCE SimpleClient.cpp
LIBRARY EUSER.LIB WS32.LIB EFSRV.LIB
LIBRARY APPARC.LIB CONE.LIB
LIBRARY EIKCOCTL.LIB EIKCORE.LIB EIKDLG.LIB EIKCTL.LIB
LIBRARY EIKFILE.LIB // CEikFileOpenDialog
LIBRARY EGUL.LIB // CColorList
LIBRARY ETEXT.LIB // TCharFormat
LIBRARY GDI.LIB // TTypeface
//LIBRARY ETEL.LIB
//LIBRARY APGRFX.LIB FBSCLI.LIB bafl.lib BITGDI.LIB
SOURCEPATH .
RESOURCE PicodriveN.rss
//MACRO __DEBUG_PRINT
AIF PicodriveN.aif . PicodriveNAif.rss c8 PicoN20x16.bmp PicoN20x16m.bmp PicoN32x32.bmp PicoN32x32m.bmp

View file

@ -0,0 +1,474 @@
NAME PDN
#include <eikon.rh>
#include <eikon.rsg>
#include "picodriven.hrh"
RESOURCE RSS_SIGNATURE { }
RESOURCE TBUF { buf=""; }
RESOURCE EIK_APP_INFO
{
menubar=r_app_menubar;
hotkeys=r_app_hotkeys;
}
RESOURCE HOTKEYS r_app_hotkeys
{
control=
{
HOTKEY { command=EEikCmdExit; key='e'; }
};
}
RESOURCE MENU_BAR r_app_menubar
{
titles=
{
MENU_TITLE { menu_pane=r_app_emu_menu; txt="Emu"; },
MENU_TITLE { menu_pane=r_app_frameskip_menu; txt="Frameskip"; }
#ifdef __DEBUG_PRINT
,MENU_TITLE { menu_pane=r_app_debug_menu; txt="Debug"; }
#endif
};
}
RESOURCE MENU_PANE r_app_emu_menu
{
items=
{
MENU_ITEM { command=EEikCmdPicoLoadState; txt="Load state"; flags=EEikMenuItemDimmed; },
MENU_ITEM { command=EEikCmdPicoSaveState; txt="Save state"; flags=EEikMenuItemDimmed; },
MENU_ITEM { command=EEikCmdPicoLoadROM; txt="Load new ROM"; },
MENU_ITEM { command=EEikCmdPicoResume; txt="Resume game"; flags=EEikMenuItemDimmed; },
MENU_ITEM { command=EEikCmdPicoReset; txt="Reset game"; flags=EEikMenuItemDimmed; },
MENU_ITEM { command=EEikCmdPicoKeys; txt="Configure keys"; },
MENU_ITEM { command=EEikCmdPicoSettings; txt="Settings"; },
MENU_ITEM { command=EEikCmdHelpAbout; txt="About"; flags=EEikMenuItemSeparatorAfter; },
MENU_ITEM { command=EEikCmdExit; txt="Exit"; }
};
}
RESOURCE MENU_PANE r_app_frameskip_menu
{
items=
{
MENU_ITEM { command=EEikCmdPicoFrameskipAuto; txt="Auto"; flags=EEikMenuItemRadioStart | EEikMenuItemSeparatorAfter; },
MENU_ITEM { command=EEikCmdPicoFrameskip0; txt="0"; flags=EEikMenuItemRadioMiddle; },
MENU_ITEM { command=EEikCmdPicoFrameskip1; txt="1"; flags=EEikMenuItemRadioMiddle; },
MENU_ITEM { command=EEikCmdPicoFrameskip2; txt="2"; flags=EEikMenuItemRadioMiddle; },
MENU_ITEM { command=EEikCmdPicoFrameskip4; txt="4"; flags=EEikMenuItemRadioMiddle; },
MENU_ITEM { command=EEikCmdPicoFrameskip8; txt="8"; flags=EEikMenuItemRadioEnd; }
};
}
RESOURCE MENU_PANE r_app_debug_menu
{
items=
{
MENU_ITEM { command=EEikCmdPicoDebugKillEmu; txt="Kill emu proc"; },
MENU_ITEM { command=EEikCmdPicoDebugInfo; txt="info"; }
};
}
/**************************************
*
* about dialog
*
**************************************/
RESOURCE DIALOG r_dialog_about
{
title = "About";
buttons = r_buttons_continue_credits;
flags = EEikDialogFlagWait;
items =
{
DLG_LINE
{
itemflags = EQikDlgItemUseFullWidth | EQikDlgItemDenselyPacked;
type = EEikCtRichTextEditor;
id = ECtlAboutVersion;
control = RTXTED
{
flags = EEikEdwinResizable | EEikEdwinNoAutoSelection | EEikEdwinReadOnly | EEikEdwinWidthInPixels;
numlines = 4;
};
},
DLG_LINE
{
itemflags = EQikDlgItemUseFullWidth | EQikDlgItemDenselyPacked;
type = EEikCtRichTextEditor;
id = ECtlAboutLinks;
control = RTXTED
{
flags = EEikEdwinResizable | EEikEdwinNoAutoSelection | EEikEdwinReadOnly | EEikEdwinWidthInPixels | 0x00200000;
numlines = 4;
};
}
};
}
RESOURCE DLG_BUTTONS r_buttons_continue_credits
{
buttons =
{
DLG_BUTTON { id = EEikBidYes; button = CMBUT { txt = "Credits"; }; },
DLG_BUTTON { id = EEikBidCancel; button = CMBUT { txt = "Continue"; }; flags=EEikLabeledButtonIsDefault; }
};
}
RESOURCE TBUF r_simple_text_about_links
{
buf=
"<f=Corinna><s=11><u>Email</u>: notasas@gmail.com"\
"<p><f=Corinna><s=11><u>Web</u>:<p>http://notaz.atspace.com"\
"<p><f=Corinna><s=11><u>Dave's Web</u>:<p>http://www.finalburn.com";
}
RESOURCE TBUF r_simple_text_about
{
buf=
"<f=Polo><s=26><a=center><fg=RgbDarkBlue>PicodriveN"\
"<p><f=Polo><s=10><a=center>for UIQ2"\
"<p> <p><f=Corinna><s=12>Version %S, by notaz."\
"<p><s=6> <p><s=10>Port based on PicoDrive 0.030 for Pocket PC by Dave";
}
RESOURCE DIALOG r_dialog_credits
{
title = "Credits and thanks";
buttons = R_EIK_BUTTONS_DONE;
flags = EEikDialogFlagWait;
items =
{
DLG_LINE
{
type = EEikCtGlobalTextEditor;
id = ECtlCredits;
control = GTXTED
{
width = 150; height = 200; numlines = 26; flags = EEikEdwinReadOnly | EEikEdwinNoAutoSelection | EEikEdwinDisplayOnly;
};
}
};
}
RESOURCE ARRAY r_tbuf_credits
{
items=
{
LBUF{txt="This emulator uses code from these people / projects:";},
LBUF{txt="";},
LBUF{txt="Dave";},
LBUF{txt="- Cyclone 68000 core, Pico emulation library";},
LBUF{txt="Homepage: http://www.finalburn.com/";},
LBUF{txt="E-mail: david(atsymbol)finalburn.com";},
LBUF{txt="";},
LBUF{txt="Reesy & FluBBa";},
LBUF{txt="- DrZ80, the Z80 emulator written in ARM assembly.";},
LBUF{txt="Homepage: http://reesy.gp32x.de/";},
LBUF{txt="E-mail: drsms_reesy(atsymbol)yahoo.co.uk";},
LBUF{txt="";},
LBUF{txt="Tatsuyuki Satoh, Jarek Burczynski, MultiArcadeMachineEmulator (MAME) development";},
LBUF{txt="- software implementation of Yamaha FM sound generator and";},
LBUF{txt="Texas Instruments SN76489 / SN76496 programmable tone / noise generator";},
LBUF{txt="Homepage: http://www.mame.net/";},
LBUF{txt="";},
LBUF{txt="Additional thanks:";},
LBUF{txt="- Peter van Sebille for ECompXL and his various open-source Symbian projects to learn from.";},
LBUF{txt="- Steve Fischer for his open-source Motorola projects.";},
LBUF{txt="- Charles MacDonald (http://cgfm2.emuviews.com/) for old but still very useful info about genesis hardware.";},
LBUF{txt="- Stéphane Dallongeville for creating Gens and making it open-source.";},
LBUF{txt="- Steve Snake for all that he has done for Genesis emulation scene.";},
LBUF{txt="- Bart Trzynadlowski for his SSFII and 68000 docs.";},
LBUF{txt="- Haze for his research (http://haze.mameworld.info).";},
LBUF{txt="- The development team behind \"Symbian GCC Improvement Project \" (http://www.inf.u-szeged.hu/symbian-gcc/) for their updated compile tools.";},
LBUF{txt="- Mark and Jean-loup for zlib library.";},
LBUF{txt="- Reesy for also finding some Cyclone bugs.";},
LBUF{txt="- Inder for the icons.";}
};
}
/**************************************
*
* debug dialog
*
**************************************/
RESOURCE DIALOG r_dialog_debug
{
title = "debug";
buttons = R_EIK_BUTTONS_DONE;
flags = EEikDialogFlagWait;
items =
{
DLG_LINE
{
type = EEikCtGlobalTextEditor;
id = ECtlDebugEdit;
control = GTXTED
{
width = 150; height = 200; numlines = 26; flags = EEikEdwinReadOnly | EEikEdwinNoAutoSelection | EEikEdwinDisplayOnly;
};
}
};
}
/**************************************
*
* config dialog
*
**************************************/
RESOURCE DIALOG r_pico_config
{
title = "Settings";
buttons = R_EIK_BUTTONS_CANCEL_OK;
flags = EEikDialogFlagWait;
pages = r_pico_config_pages;
}
RESOURCE ARRAY r_pico_config_pages
{
items = {
PAGE
{
id = ECtlOptPageMain;
text = "Main";
lines = r_pico_config_page_main;
},
PAGE
{
id = ECtlOptPageSound;
text = "Sound";
lines = r_pico_config_page_sound;
},
PAGE
{
id = ECtlOptPageMisc;
text = "Misc";
lines = r_pico_config_page_misc;
}
};
}
RESOURCE ARRAY r_pico_config_page_main
{
items = {
DLG_LINE
{
id = ECtlOptRotationLabel;
type = EEikCtLabel;
prompt = "Screen Rotation";
control = LABEL { horiz_align = EEikLabelAlignHLeft; };
},
DLG_LINE
{
id = ECtlOptRotation;
type = EEikCtHorOptionButList;
control = HOROPBUT
{
array_id = r_pico_config_rotation_buttons;
};
},
DLG_LINE
{
id = ECtlOptScreenModeLabel;
type = EEikCtLabel;
prompt = "Screen Mode";
control = LABEL { horiz_align = EEikLabelAlignHLeft; };
},
DLG_LINE
{
id = ECtlOptScreenMode;
type = EEikCtHorOptionButList;
control = HOROPBUT
{
array_id = r_pico_config_screenmode_buttons;
};
},
DLG_LINE
{
id = ECtlOptUseAltRend;
type = EEikCtCheckBox;
prompt = "Fast renderer (inaccurate)";
},
DLG_LINE
{
id = ECtlOptUseAccTiming;
type = EEikCtCheckBox;
prompt = "Accurate timing (slower)";
},
DLG_LINE
{
id = ECtlOptUseAccSprites;
type = EEikCtCheckBox;
prompt = "Accurate sprites (slower)";
},
DLG_LINE
{
id = ECtlOptShowFPS;
type = EEikCtCheckBox;
prompt = "Show FPS";
}
};
}
RESOURCE ARRAY r_pico_config_page_sound
{
items = {
DLG_LINE
{
id = ECtlOptEnableSound;
type = EEikCtCheckBox;
prompt = "Enable sound";
},
DLG_LINE
{
id = ECtlOptChipSelLabel;
type = EEikCtLabel;
prompt = "Emulate these sound chips:";
control = LABEL { horiz_align = EEikLabelAlignHLeft; };
},
DLG_LINE
{
id = ECtlOptEmulateZ80;
type = EEikCtCheckBox;
prompt = "Z80";
},
DLG_LINE
{
id = ECtlOptEmulateYM2612;
type = EEikCtCheckBox;
prompt = "YM2612";
},
DLG_LINE
{
id = ECtlOptEmulateSN76496;
type = EEikCtCheckBox;
prompt = "SN76496 (PSG)";
},
DLG_LINE
{
id = ECtlOptSndQLabel;
type = EEikCtLabel;
prompt = "Quality (lowest is fastest)";
control = LABEL { horiz_align = EEikLabelAlignHLeft; };
},
DLG_LINE
{
id = ECtlOptSndQuality;
type = EEikCtChoiceList;
prompt = "";
control = CHOICELIST { array_id = r_pico_config_snd_quality; };
itemflags = EEikDlgItemNonFocusing;
}
};
}
RESOURCE ARRAY r_pico_config_page_misc
{
items = {
DLG_LINE
{
id = ECtlOpt6ButtonPad;
type = EEikCtCheckBox;
prompt = "6 button pad";
},
DLG_LINE
{
id = ECtlOptGzipStates;
type = EEikCtCheckBox;
prompt = "gzip save states";
},
DLG_LINE
{
id = ECtlOptUseSRAM;
type = EEikCtCheckBox;
prompt = "Use SRAM saves (.srm)";
},
DLG_LINE
{
id = ECtlOptMotDontUseVol;
type = EEikCtCheckBox;
prompt = "Motorola: don't use volume keys for game controls";
},
DLG_LINE
{
id = ECtlOptRegionLabel;
type = EEikCtLabel;
prompt = "Region: ";
control = LABEL { horiz_align = EEikLabelAlignHLeft; };
},
DLG_LINE
{
id = ECtlOptRegion;
type = EEikCtChoiceList;
prompt = "";
control = CHOICELIST { array_id = r_pico_config_region; };
itemflags = EEikDlgItemNonFocusing;
}
};
}
RESOURCE ARRAY r_pico_config_rotation_buttons
{
items = {
OPBUT { id = ECtlOptRotation0; text = "0º"; },
OPBUT { id = ECtlOptRotation90; text = "90º"; },
OPBUT { id = ECtlOptRotation180; text = "180º"; },
OPBUT { id = ECtlOptRotation270; text = "270º"; }
};
}
RESOURCE ARRAY r_pico_config_screenmode_buttons
{
items = {
OPBUT { id = ECtlOptScreenModeCenter; text = "Center"; },
OPBUT { id = ECtlOptScreenModeFit; text = "Fit"; },
OPBUT { id = ECtlOptScreenModeFit2; text = "Fit2"; }
};
}
RESOURCE ARRAY r_pico_config_snd_quality
{
items = {
LBUF { txt = "8000Hz mono"; },
LBUF { txt = "11025Hz mono"; },
LBUF { txt = "16000Hz mono"; },
LBUF { txt = "22050Hz mono"; },
LBUF { txt = "8000Hz stereo"; },
LBUF { txt = "11025Hz stereo"; },
LBUF { txt = "16000Hz stereo"; },
LBUF { txt = "22050Hz stereo"; }
};
}
RESOURCE ARRAY r_pico_config_region
{
items = {
LBUF { txt = "Auto"; },
LBUF { txt = "Europe"; },
LBUF { txt = "USA"; },
LBUF { txt = "Japan PAL"; },
LBUF { txt = "Japan NTSC"; }
};
}

View file

@ -0,0 +1,14 @@
#include <aiftool.rh>
RESOURCE AIF_DATA
{
app_uid=0x1000C193;
caption_list=
{
CAPTION { code=ELangEnglish; caption="PicodriveN"; }
};
num_icons=2;
embeddability=KAppNotEmbeddable;
newfile=KAppDoesNotSupportNewFile;
}

View file

@ -0,0 +1,33 @@
// needed for client interface
#include "../version.h"
#include "../ClientServer.h"
#include "SimpleClient.h"
// Connect to the server - default number of message slots = 4
TInt RServSession::Connect()
{
TInt r=CreateSession(KServerName,Version(),kDefaultMessageSlots);
return(r);
}
// Return the client side version number.
TVersion RServSession::Version(void) const
{
return(TVersion(KPicoMajorVersionNumber,KPicoMinorVersionNumber,0));
}
TInt RServSession::SendReceive(TInt aFunction, TAny* aPtr) const
{
return RSessionBase::SendReceive(aFunction, aPtr);
}
TInt RServSession::Send(TInt aFunction, TAny* aPtr) const
{
return RSessionBase::Send(aFunction, aPtr);
}

View file

@ -0,0 +1,23 @@
#ifndef __SERVSESSION_H__
#define __SERVSESSION_H__
#include <e32base.h>
//**********************************
// RServSession
//**********************************
class RServSession : public RSessionBase
{
public:
RServSession() {}
TInt Connect();
TVersion Version() const;
TInt SendReceive(TInt aFunction,TAny* aPtr) const;
TInt Send(TInt aFunction,TAny* aPtr) const;
};
#endif

View file

@ -0,0 +1,101 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void targetname(char *dest, char *src)
{
char *p, *p1;
if(strlen(src) < 5 || src[0] == '\t') return;
// goto string end
for(p=src; *p && *p != ' ' && *p != '\r'; p++);
// goto start
for(p1=p; p1 > src && *p1 != '\\'; p1--); p1++;
if(p-p1 > 0) {
strncpy(dest, p1, p-p1);
dest[p-p1] = 0;
}
}
int main(int argc, char *argv[])
{
FILE *f = 0, *fo = 0;
unsigned char buff[512], buff2[128], outname[512];
buff2[0] = 0;
if(argc != 2) {
printf("usage: %s <makefile>\n\n", argv[0]);
return 1;
}
f = fopen(argv[1], "r");
if(!f) {
printf("%s: couldn't open %s\n", argv[0], argv[1]);
return 2;
}
strcpy(outname, argv[1]);
strcat(outname, ".out");
fo = fopen(outname, "w");
if(!fo) {
fclose(f);
printf("%s: couldn't open %s for writing\n", argv[0], outname);
return 3;
}
while(!feof(f)) {
fgets(buff, 512, f);
if(!strncmp(buff, "\t$(GCCUREL)", 11) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: gcc\n\t@$(GCCUREL)", buff2);
fputs(buff+11, fo);
} else if(!strncmp(buff, "\tperl -S ecopyfile.pl", 21) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: perl -S ecopyfile.pl\n\t@perl", buff2);
fputs(buff+5, fo);
} else if(!strncmp(buff, "\tperl -S epocrc.pl", 18) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: perl -S epocrc.pl\n\t@perl", buff2);
fputs(buff+5, fo);
} else if(!strncmp(buff, "\tperl -S epocaif.pl", 19) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: perl -S epocaif.pl\n\t@perl", buff2);
fputs(buff+5, fo);
} else if(!strncmp(buff, "\tperl -S emkdir.pl", 18) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: perl -S emkdir.pl\n\t@perl", buff2);
fputs(buff+5, fo);
} else if(!strncmp(buff, "\tperl -S makedef.pl", 18) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: perl -S makedef.pl\n\t@perl", buff2);
fputs(buff+5, fo);
} else if(!strncmp(buff, "\tld ", 4) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: ld\n\t@ld ", buff2);
fputs(buff+4, fo);
} else if(!strncmp(buff, "\tar ", 4) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: ar\n\t@ar ", buff2);
fputs(buff+4, fo);
} else if(!strncmp(buff, "\tif exist ", 10) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: if exist (del?)\n\t@if exist ", buff2);
fputs(buff+10, fo);
} else if(!strncmp(buff, "\tdlltool ", 9) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: dlltool\n\t@dlltool ", buff2);
fputs(buff+9, fo);
} else if(!strncmp(buff, "\tpetran ", 8) && !strchr(buff, '>')) {
fprintf(fo, "\t@echo %s: petran\n\t@petran ", buff2);
fputs(buff+8, fo);
} else {
// try to get new targetname
targetname(buff2, buff);
fputs(buff, fo);
}
}
// done!
fclose(f);
fclose(fo);
remove(argv[1]);
rename(outname, argv[1]);
return 0;
}

Binary file not shown.

View file

@ -0,0 +1 @@
@..\..\..\..\qconsole-1.60\qtty-1.60\release\qtty --qc-addr P800 --qc-channel 5 --user qconsole --pass server --cmds "put d:\system\apps\picodriven\PICODRIVEN.APP ..\..\..\..\..\epoc32\release\armi\urel\PICODRIVEN.APP" "put d:\system\apps\picodriven\PICODRIVEN.rsc ..\..\..\..\..\epoc32\data\z\system\apps\PicodriveN\PICODRIVEN.rsc" exit