diff --git a/.gitignore b/.gitignore index 0a694cf..c4a4948 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ xcuserdata/ ActiveGS_AsmJS/out contents.xcworkspacedata +.vs/ +~Build/ +*.vcxproj.user + diff --git a/ActiveGS.exe/ActiveGS.sln b/ActiveGS.exe/ActiveGS.sln new file mode 100644 index 0000000..7dc79e9 --- /dev/null +++ b/ActiveGS.exe/ActiveGS.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32819.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ActiveGS", "ActiveGS91.exe.vcxproj", "{49D558B6-A2BC-4F7F-9F20-8C722193DD76}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Debug|x64.ActiveCfg = Debug|x64 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Debug|x64.Build.0 = Debug|x64 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Debug|x86.ActiveCfg = Debug|Win32 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Debug|x86.Build.0 = Debug|Win32 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Release|x64.ActiveCfg = Release|x64 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Release|x64.Build.0 = Release|x64 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Release|x86.ActiveCfg = Release|Win32 + {49D558B6-A2BC-4F7F-9F20-8C722193DD76}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B0B0FDD8-92C9-4AF4-A72D-4DAFD4AAF4BF} + EndGlobalSection +EndGlobal diff --git a/ActiveGS.exe/ActiveGS91.exe.vcxproj b/ActiveGS.exe/ActiveGS91.exe.vcxproj new file mode 100644 index 0000000..9d127ec --- /dev/null +++ b/ActiveGS.exe/ActiveGS91.exe.vcxproj @@ -0,0 +1,412 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ActiveGS + {49D558B6-A2BC-4F7F-9F20-8C722193DD76} + ActiveGS91exe + Win32Proj + 10.0 + + + + Application + v143 + Static + MultiByte + true + + + Application + v143 + Static + MultiByte + true + + + Application + v143 + Static + MultiByte + true + + + Application + v143 + Static + MultiByte + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>16.0.30427.251 + + + $(SolutionDir)~Build\$(ProjectName)\$(Configuration)\$(PlatformShortName) + $(SolutionDir)~Build\Objs\$(ProjectName)\$(Configuration)\$(PlatformShortName) + true + A$(TargetExt) + + + true + $(SolutionDir)~Build\$(ProjectName)\$(Configuration)\$(PlatformShortName) + $(SolutionDir)~Build\Objs\$(ProjectName)\$(Configuration)\$(PlatformShortName) + $(ProjectName) + + + $(SolutionDir)~Build\$(ProjectName)\$(Configuration)\$(PlatformShortName) + $(SolutionDir)~Build\Objs\$(ProjectName)\$(Configuration)\$(PlatformShortName) + false + + + false + $(SolutionDir)~Build\$(ProjectName)\$(Configuration)\$(PlatformShortName) + $(SolutionDir)~Build\Objs\$(ProjectName)\$(Configuration)\$(PlatformShortName) + + + + Disabled + WIN32;_DEBUG;_WINDOWS;KEGS_LITTLE_ENDIAN;ACTIVEGS;KEGS91;KEGS_BETAVERSION;DRIVER_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + Level3 + ProgramDatabase + 4996;%(DisableSpecificWarnings) + + + winmm.lib;comctl32.lib;nafxcwd.lib;libcmtd.lib;%(AdditionalDependencies) + msvcrtd.lib nafxcwd.lib libcmtd.lib;%(IgnoreSpecificDefaultLibraries) + true + Windows + MachineX86 + $(OutDir)$(TargetName) + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;KEGS_LITTLE_ENDIAN;ACTIVEGS;KEGS91;KEGS_BETAVERSION;DRIVER_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + 4996;%(DisableSpecificWarnings) + + + winmm.lib;comctl32.lib;nafxcwd.lib;libcmtd.lib;%(AdditionalDependencies) + msvcrtd.lib nafxcwd.lib libcmtd.lib;%(IgnoreSpecificDefaultLibraries) + true + Windows + $(OutDir)$(ProjectName).exe + + + + + MaxSpeed + true + WIN32;NDEBUG;_WINDOWS;KEGS_LITTLE_ENDIAN;ACTIVEGS;KEGS91;KEGS_BETAVERSION;DRIVER_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + true + + ../Common.win32/StdAfx.h + Level3 + ProgramDatabase + 4996;%(DisableSpecificWarnings) + + + winmm.lib;comctl32.lib;nafxcw.lib;libcmt.lib;%(AdditionalDependencies) + $(SolutionDir)run\ActiveGS.exe + msvcrt.lib nafxcw.lib libcmt.lib;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + MachineX86 + + + + + MaxSpeed + true + WIN32;NDEBUG;_WINDOWS;KEGS_LITTLE_ENDIAN;ACTIVEGS;KEGS91;KEGS_BETAVERSION;DRIVER_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + true + + + ../Common.win32/StdAfx.h + Level3 + ProgramDatabase + 4996;%(DisableSpecificWarnings) + + + winmm.lib;comctl32.lib;nafxcw.lib;libcmt.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).exe + msvcrt.lib nafxcw.lib libcmt.lib;%(IgnoreSpecificDefaultLibraries) + true + Windows + true + true + + + + + + + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ActiveGS.exe/ActiveGS91.exe.vcxproj.filters b/ActiveGS.exe/ActiveGS91.exe.vcxproj.filters new file mode 100644 index 0000000..be54e44 --- /dev/null +++ b/ActiveGS.exe/ActiveGS91.exe.vcxproj.filters @@ -0,0 +1,615 @@ + + + + + {0876290e-5ea0-4529-80ca-3e33de8b9a40} + + + {6da1666e-cbb0-4abb-a97f-ac0478b844f8} + + + {b38e7a11-43e1-4c45-9e0a-298f7faa5b34} + + + {12d375d5-3df0-4a7e-9086-c545dbdf625d} + + + {51dc8c41-b398-47e4-b68a-61417da40967} + + + {3dfcff28-c626-4032-b6ff-b8dc129d187a} + + + {3f6df060-e239-4886-b77c-b474461ce911} + + + {411622c0-1a8d-4b39-9fee-49dcbb8dd4c6} + + + {a0ee4f56-59a4-46a1-aa53-a3effdb48cbc} + + + {e88f5577-5dd9-4f81-adc3-d2e0001f5661} + + + {4b8c0a8d-8a74-40fa-aa3c-be5fb3ec4e7e} + + + {b96f449f-29ea-4305-b074-52155c15c111} + + + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + activegs.exe + + + activegs.exe + + + activegs.exe + + + activegs.exe + + + win + + + win + + + win + + + win + + + win + + + win + + + Drivers + + + Src + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + libpng + + + zlib + + + zlib + + + zlib + + + unzip + + + zlib + + + zlib + + + zlib + + + unzip + + + unzip + + + zlib + + + zlib + + + unzip + + + unzip + + + zlib + + + + + Common + + + Common + + + Common + + + Common + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + common.win32 + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + Src\H + + + activegs.exe + + + activegs.exe\Header Files + + + activegs.exe\Header Files + + + activegs.exe\Header Files + + + activegs.exe\Header Files + + + win + + + win + + + + Src\H + + + libpng + + + libpng + + + zlib + + + unzip + + + unzip + + + zlib + + + zlib + + + zlib + + + zlib + + + unzip + + + unzip + + + zlib + + + unzip + + + zlib + + + zlib + + + unzip + + + zlib + + + zlib + + + + + common.win32 + + + common.win32 + + + common.win32 + + + activegs.exe\Header Files + + + + + Run + + + + + activegs.exe\Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ActiveGS.exe/ActiveGSApp.aps b/ActiveGS.exe/ActiveGSApp.aps new file mode 100644 index 0000000..482f847 Binary files /dev/null and b/ActiveGS.exe/ActiveGSApp.aps differ diff --git a/ActiveGS.exe/ActiveGSApp.cpp b/ActiveGS.exe/ActiveGSApp.cpp new file mode 100644 index 0000000..b22674f --- /dev/null +++ b/ActiveGS.exe/ActiveGSApp.cpp @@ -0,0 +1,80 @@ +// ActiveGSApp.cpp : Définit les comportements de classe pour l'application. +// + +#include "../Common.win32/stdafx.h" +#include "ActiveGSApp.h" +#include "MainFrm.h" + + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CActiveGSAppAp +BEGIN_MESSAGE_MAP(CActiveGSAppApp, CWinApp) +// ON_COMMAND(ID_APP_ABOUT, OnAppAbout) +END_MESSAGE_MAP() + + +// construction CActiveGSAppApp + +CActiveGSAppApp::CActiveGSAppApp() +{ + // TODO : ajoutez ici du code de construction, + // Placez toutes les initialisations significatives dans InitInstance +} + + +// Seul et unique objet CActiveGSAppApp + +CActiveGSAppApp theApp; + +// initialisation CActiveGSAppApp + +BOOL CActiveGSAppApp::InitInstance() +{ + // InitCommonControls() est requis sur Windows XP si le manifeste de l'application + // spécifie l'utilisation de ComCtl32.dll version 6 ou ultérieure pour activer + // les styles visuels. Dans le cas contraire, la création de fenêtres échouera. + InitCommonControls(); + + CWinApp::InitInstance(); + + // Initialiser les bibliothèques OLE + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + AfxEnableControlContainer(); + // Initialisation standard + // Si vous n'utilisez pas ces fonctionnalités et que vous souhaitez réduire la taille + // de votre exécutable final, vous devez supprimer ci-dessous + // les routines d'initialisation spécifiques dont vous n'avez pas besoin. + // Changez la clé de Registre sous laquelle nos paramètres sont enregistrés. + // TODO : Modifiez cette chaîne avec des informations appropriées, + // telles que le nom de votre société ou organisation + SetRegistryKey(_T("Applications locales générées par AppWizard")); + // Pour créer la fenêtre principale, ce code crée un nouvel objet fenêtre frame + // qu'il définit ensuite en tant qu'objet fenêtre principale de l'application + + int argc = __argc; + char** argv = __argv; + + + CMainFrame* pFrame = new CMainFrame(argc,argv); + if (!pFrame) + return FALSE; + m_pMainWnd = pFrame; + + // MEts à jour le nom de la fenetre + + // La seule fenêtre a été initialisée et peut donc être affichée et mise à jour + pFrame->ShowWindow(SW_SHOW); + pFrame->UpdateWindow(); + // appelle DragAcceptFiles uniquement s'il y a un suffixe + // Dans une application SDI, cet appel doit avoir lieu juste après ProcessShellCommand + return TRUE; +} + diff --git a/ActiveGS.exe/ActiveGSApp.h b/ActiveGS.exe/ActiveGSApp.h new file mode 100644 index 0000000..e5fb754 --- /dev/null +++ b/ActiveGS.exe/ActiveGSApp.h @@ -0,0 +1,32 @@ +// ActiveGSApp.h : fichier d'en-tête principal pour l'application ActiveGSApp +// +#pragma once + +#ifndef __AFXWIN_H__ + #error inclut 'stdafx.h' avant d'inclure ce fichier pour PCH +#endif + +#include "resource.h" // symboles principaux + +// CActiveGSAppApp : +// Consultez ActiveGSApp.cpp pour l'implémentation de cette classe +// + +class CActiveGSAppApp : public CWinApp +{ +public: + CActiveGSAppApp(); + + +// Substitutions +public: + virtual BOOL InitInstance(); + +// Implémentation + +public: +// afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern CActiveGSAppApp theApp; diff --git a/ActiveGS.exe/ActiveGSApp.rc b/ActiveGS.exe/ActiveGSApp.rc new file mode 100644 index 0000000..7694662 --- /dev/null +++ b/ActiveGS.exe/ActiveGSApp.rc @@ -0,0 +1,323 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n" + "LANGUAGE 12, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\ActiveGSApp.rc2"" // ressources non modifiées par Microsoft Visual C++ \r\n" + "#include ""afxres.rc"" // Composants standard\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\ActiveGSApp.ico" +IDR_2DSK ICON "res\\idr_2mg1.ico" +IDR_32MG ICON "res\\idr_22mg.ico" +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_APP_ABOUT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "&Fichier" + BEGIN + MENUITEM "&quitter", ID_APP_EXIT + END + POPUP "&Edition" + BEGIN + MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT + MENUITEM "C&opier\tCtrl+C", ID_EDIT_COPY + MENUITEM "Co&ller\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&Affichage" + BEGIN + MENUITEM "&barre d'outils", ID_VIEW_TOOLBAR + MENUITEM "&barre d'état", ID_VIEW_STATUS_BAR + END + POPUP "&Aide" + BEGIN + MENUITEM "&À propos de ActiveGSApp...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT + VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT + "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "À propos de ActiveGSApp" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "ActiveGSApp Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT "Copyright (C) 2003",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 3,7,1199,0 + PRODUCTVERSION 3,7,1199,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04e4" + BEGIN + VALUE "CompanyName", "Second Sight Software" + VALUE "FileDescription", "ActiveGS StandAlone Application" + VALUE "FileVersion", "3.7.1199" + VALUE "InternalName", "ActiveGS.exe" + VALUE "LegalCopyright", "(c) Second Sight Software 2009-2011" + VALUE "OriginalFilename", "ActiveGSApp.exe" + VALUE "ProductName", "ActiveGS Standalone Application" + VALUE "ProductVersion", "3.7.1199" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1252 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDR_MAINFRAME "ActiveGSApp" +END + +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "ActiveGSApp" + AFX_IDS_IDLEMESSAGE "Prêt" +END + +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "MAJ" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "DÉFIL" + ID_INDICATOR_OVR "RFP" + ID_INDICATOR_REC "ENR" +END + +STRINGTABLE +BEGIN + ID_APP_ABOUT "Affiche des informations concernant le programme, le numéro de version et le copyright\nÀ propos de" + ID_APP_EXIT "Quitte l'application et invite à enregistrer les documents\nQuitter" +END + +STRINGTABLE +BEGIN + ID_NEXT_PANE "Bascule vers le volet de fenêtre suivant\nVolet suivant" + ID_PREV_PANE "Bascule vers le volet de fenêtre précédent\nVolet précédent" +END + +STRINGTABLE +BEGIN + ID_WINDOW_SPLIT "Fractionne la fenêtre active en volets\nFractionner" +END + +STRINGTABLE +BEGIN + ID_EDIT_CLEAR "Efface la sélection\nEffacer" + ID_EDIT_CLEAR_ALL "Efface tout\nEffacer tout" + ID_EDIT_COPY "Copie la sélection et la place dans le Presse-papiers\nCopier" + ID_EDIT_CUT "Coupe la sélection et la place dans le Presse-papiers\nCouper" + ID_EDIT_FIND "Recherche le texte spécifié\nRechercher" + ID_EDIT_PASTE "Insère le contenu du presse-papiers\nColler" + ID_EDIT_REPEAT "Répète la dernière action\nRépéter" + ID_EDIT_REPLACE "Remplace un texte spécifié par un texte différent\nRemplacer" + ID_EDIT_SELECT_ALL "Sélectionne la totalité du document\nSélectionner tout" + ID_EDIT_UNDO "Annule la dernière action\nAnnuler" + ID_EDIT_REDO "Rétablit l'action précédemment annulée\nRétablir" +END + +STRINGTABLE +BEGIN + ID_VIEW_TOOLBAR "Affiche ou masque la barre d'outils\nActiver/Désactiver Barre d'outils" + ID_VIEW_STATUS_BAR "Affiche ou masque la barre d'état\nActiver/Désactiver Barre d'état" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "Modifie la taille de la fenêtre" + AFX_IDS_SCMOVE "Modifie la position de la fenêtre" + AFX_IDS_SCMINIMIZE "Affiche la fenêtre sous forme d'icône" + AFX_IDS_SCMAXIMIZE "Affiche la fenêtre en plein écran" + AFX_IDS_SCNEXTWINDOW "Bascule vers la fenêtre de document suivante" + AFX_IDS_SCPREVWINDOW "Bascule vers la fenêtre de document précédente" + AFX_IDS_SCCLOSE "Ferme la fenêtre active et propose l'enregistrement des documents" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCRESTORE "Restaure la fenêtre à sa taille normale" + AFX_IDS_SCTASKLIST "Active la liste des tâches" +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +LANGUAGE 12, 1 +#pragma code_page(1252) +#include "res\ActiveGSApp.rc2" // ressources non modifiées par Microsoft Visual C++ +#include "afxres.rc" // Composants standard +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ActiveGS.exe/ActiveGSApp.rc.ref b/ActiveGS.exe/ActiveGSApp.rc.ref new file mode 100644 index 0000000..2ca15cf --- /dev/null +++ b/ActiveGS.exe/ActiveGSApp.rc.ref @@ -0,0 +1,323 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n" + "LANGUAGE 12, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\ActiveGSApp.rc2"" // ressources non modifiées par Microsoft Visual C++ \r\n" + "#include ""afxres.rc"" // Composants standard\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\ActiveGSApp.ico" +IDR_2DSK ICON "res\\idr_2mg1.ico" +IDR_32MG ICON "res\\idr_22mg.ico" +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_APP_ABOUT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "&Fichier" + BEGIN + MENUITEM "&quitter", ID_APP_EXIT + END + POPUP "&Edition" + BEGIN + MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT + MENUITEM "C&opier\tCtrl+C", ID_EDIT_COPY + MENUITEM "Co&ller\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&Affichage" + BEGIN + MENUITEM "&barre d'outils", ID_VIEW_TOOLBAR + MENUITEM "&barre d'état", ID_VIEW_STATUS_BAR + END + POPUP "&Aide" + BEGIN + MENUITEM "&À propos de ActiveGSApp...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT + VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT + "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "À propos de ActiveGSApp" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "ActiveGSApp Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT "Copyright (C) 2003",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION $MAJORVER$,$MINORVER$,$WCREV$,0 + PRODUCTVERSION $MAJORVER$,$MINORVER$,$WCREV$,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04e4" + BEGIN + VALUE "CompanyName", "Second Sight Software" + VALUE "FileDescription", "ActiveGS StandAlone Application" + VALUE "FileVersion", "$MAJORVER$.$MINORVER$.$WCREV$" + VALUE "InternalName", "ActiveGS.exe" + VALUE "LegalCopyright", "(c) Second Sight Software 2009-2011" + VALUE "OriginalFilename", "ActiveGSApp.exe" + VALUE "ProductName", "ActiveGS Standalone Application" + VALUE "ProductVersion", "$MAJORVER$.$MINORVER$.$WCREV$" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1252 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDR_MAINFRAME "ActiveGSApp" +END + +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "ActiveGSApp" + AFX_IDS_IDLEMESSAGE "Prêt" +END + +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "MAJ" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "DÉFIL" + ID_INDICATOR_OVR "RFP" + ID_INDICATOR_REC "ENR" +END + +STRINGTABLE +BEGIN + ID_APP_ABOUT "Affiche des informations concernant le programme, le numéro de version et le copyright\nÀ propos de" + ID_APP_EXIT "Quitte l'application et invite à enregistrer les documents\nQuitter" +END + +STRINGTABLE +BEGIN + ID_NEXT_PANE "Bascule vers le volet de fenêtre suivant\nVolet suivant" + ID_PREV_PANE "Bascule vers le volet de fenêtre précédent\nVolet précédent" +END + +STRINGTABLE +BEGIN + ID_WINDOW_SPLIT "Fractionne la fenêtre active en volets\nFractionner" +END + +STRINGTABLE +BEGIN + ID_EDIT_CLEAR "Efface la sélection\nEffacer" + ID_EDIT_CLEAR_ALL "Efface tout\nEffacer tout" + ID_EDIT_COPY "Copie la sélection et la place dans le Presse-papiers\nCopier" + ID_EDIT_CUT "Coupe la sélection et la place dans le Presse-papiers\nCouper" + ID_EDIT_FIND "Recherche le texte spécifié\nRechercher" + ID_EDIT_PASTE "Insère le contenu du presse-papiers\nColler" + ID_EDIT_REPEAT "Répète la dernière action\nRépéter" + ID_EDIT_REPLACE "Remplace un texte spécifié par un texte différent\nRemplacer" + ID_EDIT_SELECT_ALL "Sélectionne la totalité du document\nSélectionner tout" + ID_EDIT_UNDO "Annule la dernière action\nAnnuler" + ID_EDIT_REDO "Rétablit l'action précédemment annulée\nRétablir" +END + +STRINGTABLE +BEGIN + ID_VIEW_TOOLBAR "Affiche ou masque la barre d'outils\nActiver/Désactiver Barre d'outils" + ID_VIEW_STATUS_BAR "Affiche ou masque la barre d'état\nActiver/Désactiver Barre d'état" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "Modifie la taille de la fenêtre" + AFX_IDS_SCMOVE "Modifie la position de la fenêtre" + AFX_IDS_SCMINIMIZE "Affiche la fenêtre sous forme d'icône" + AFX_IDS_SCMAXIMIZE "Affiche la fenêtre en plein écran" + AFX_IDS_SCNEXTWINDOW "Bascule vers la fenêtre de document suivante" + AFX_IDS_SCPREVWINDOW "Bascule vers la fenêtre de document précédente" + AFX_IDS_SCCLOSE "Ferme la fenêtre active et propose l'enregistrement des documents" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCRESTORE "Restaure la fenêtre à sa taille normale" + AFX_IDS_SCTASKLIST "Active la liste des tâches" +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +LANGUAGE 12, 1 +#pragma code_page(1252) +#include "res\ActiveGSApp.rc2" // ressources non modifiées par Microsoft Visual C++ +#include "afxres.rc" // Composants standard +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ActiveGS.exe/MainFrm.cpp b/ActiveGS.exe/MainFrm.cpp new file mode 100644 index 0000000..5c89205 --- /dev/null +++ b/ActiveGS.exe/MainFrm.cpp @@ -0,0 +1,281 @@ +// MainFrm.cpp : implémentation de la classe CMainFrame +// + +#include "../Common.win32/stdafx.h" +#include "ActiveGSApp.h" + +#include "../common.win32/activecommon.h" +#include "../common/CEmulatorCtrl.h" +#include "mainfrm.h" +#include "../common/ki.h" + +#include "../common/svnversion.h" +#include "../kegs/src/defcomm.h" +#include "../kegs/src/savestate.h" +#include "../kegs/src/driver.h" +#include "cgfiltyp.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) + ON_WM_CREATE() + ON_WM_SETFOCUS() + ON_WM_DESTROY() + ON_WM_SIZING() +END_MESSAGE_MAP() + +void associateActiceGSConfig(const char* _ext, const char* _desc, int _icon) +{ + + CGCFileTypeAccess TheFTA; + + // get full file path to program executable file + + TCHAR szProgPath[MAX_PATH * 2]; + ::GetModuleFileName(NULL, szProgPath, sizeof(szProgPath)/sizeof(TCHAR)); + + CString csTempText; + + TheFTA.SetExtension(_ext); + + // just pass file path in quotes on command line + + csTempText = szProgPath; + csTempText += " \"%1\""; + TheFTA.SetShellOpenCommand(csTempText); + TheFTA.SetDocumentShellOpenCommand(csTempText); + + CString classname("ActiveGS."); + classname += _ext; + TheFTA.SetDocumentClassName(classname); + + TheFTA.SetDocumentDescription(_desc); + + // use first icon in program + + csTempText = szProgPath; + csTempText += ","; + csTempText += (char)(_icon+'0'); + TheFTA.SetDocumentDefaultIcon(csTempText); + + // set the necessary registry entries + + TheFTA.RegSetAllInfo(); + +} +CMainFrame::CMainFrame(int _argc, char** _argv) +{ + outputInfo("CMainFrame() (inst:%0X)\n",this); + + // Répertoire par default = pour une appli, le répertoire courant + char windir[1024]; + GetCurrentDirectory(1024,windir); + +#ifndef ACTIVEGSKARATEKA + associateActiceGSConfig("activegsxml","ActiveGS Configuration file",0); + associateActiceGSConfig("nib","Apple II 5.25 Disk Image",1); + associateActiceGSConfig("dsk","Apple II 5.25 Disk Image",1); + associateActiceGSConfig("2mg","Apple II 3.5 Image",2); + associateActiceGSConfig("po","Apple II 3.5 Disk Image",2); + associateActiceGSConfig("do","Apple II 5.25 Disk Image",1); +#endif + + + void (*driver)() = NULL; +#ifdef VIRTUALAPPLE + extern void jniSetup(const char*); + jniSetup(NULL); +#else + #ifdef ACTIVEGSKARATEKA + extern void karateka_driver(); + driver = karateka_driver; + #else + extern void activegs_driver(); + driver = activegs_driver; + #endif + g_driver.init( driver ); +#endif + + CDownload::initPersistentPath(); + + option.initOptions(); + + + m_wndView.config.setBaseURL(windir); + +#ifdef VIRTUALAPPLE + m_wndView.config.xmlconfig =g_driver.activegsxml; +#else + #ifdef ACTIVEGSPOP + m_wndView.config.xmlconfig ="http://asset/pop.activegsxml"; + #elif ACTIVEGSKARATEKA + m_wndView.config.xmlconfig ="http://asset/karateka.activegsxml"; + #else + m_wndView.config.xmlconfig ="default.activegsxml"; + m_wndView.config.processCommandLine(_argc,_argv); + #endif +#endif + + RECT r; + r.left = 100; + r.top = 100; + r.right = r.left+X_A2_WINDOW_WIDTH; + +#ifdef VIDEO_SINGLEHLINE + float w = X_A2_WINDOW_WIDTH*2; +#else + float w = X_A2_WINDOW_WIDTH; +#endif + + r.right = r.left + w * 2; + + +#ifdef VIDEO_SINGLEVLINE + float h = X_A2_WINDOW_HEIGHT*2; +#else + float h = X_A2_WINDOW_HEIGHT; +#endif + + r.bottom = r.top + h * 2; + + const char* ver = ACTIVEGSVERSIONSTR; + + Create(NULL, ver, WS_THICKFRAME | WS_SYSMENU,r, NULL,NULL, 0, NULL ); + + + +} + +CMainFrame::~CMainFrame() +{ + +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + outputInfo("OnCreate (inst:%0X)\n",lpCreateStruct->hInstance); + + m_wndView.CreateEmulatorWindow(this); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWnd::PreCreateWindow(cs) ) + return FALSE; + return TRUE; +} + +// diagnostics pour CMainFrame + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +// gestionnaires de messages pour CMainFrame + +void CMainFrame::OnSetFocus(CWnd* /*pOldWnd*/) +{ + // passe le focus à la fenêtre d'affichage + m_wndView.SetFocus(); +} + +BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) +{ + /* + // laisser la priorité à la vue pour cette commande + if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) + return TRUE; + */ + // sinon, la gestion par défaut est utilisée + return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); +} +void CMainFrame::OnDestroy() +{ + outputInfo("OnDestroy() (inst:%0X)\n",this); + CFrameWnd::OnDestroy(); + +} + + +extern void window_needs_full_refresh(); + +LRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + + if (message==WM_SIZE) + { + m_wndView.resize(); + return 1; + } + else + if (message==WM_ERASEBKGND) + { + // prevent mainframe to refresh its background + return 1; + } + else + return CFrameWnd::DefWindowProc(message, wParam, lParam); +} + + + +void CMainFrame::OnSizing(UINT nSide,LPRECT lpRect) +{ + RECT rcClient, rcWindow; + GetClientRect( &rcClient); + GetWindowRect( &rcWindow); + int borderw = (rcWindow.right - rcClient.right) + (rcClient.left - rcWindow.left ); + int borderh = (rcWindow.bottom - rcClient.bottom) + (rcClient.top - rcWindow.top ); + + // détermine le sens du resize (en x ou en y) + + int deltax = (rcWindow.right-lpRect->right) + (rcWindow.left-lpRect->left); + if (deltax<0) deltax = -deltax; + int deltay = (rcWindow.bottom-lpRect->bottom) + (rcWindow.top-lpRect->top); + if (deltay<0) deltay = -deltay; + +#ifdef VIDEO_SINGLEVLINE + int bottom = X_A2_WINDOW_HEIGHT*2; +#else + int bottom = X_A2_WINDOW_HEIGHT; +#endif +#ifdef VIDEO_SINGLEHLINE + int right = X_A2_WINDOW_WIDTH*2; +#else + int right = X_A2_WINDOW_WIDTH; +#endif +const float ratio = (float)right/(float)bottom; + + int w = (lpRect->right - lpRect->left) - borderw ; + int h = (lpRect->bottom - lpRect->top) - borderh ; + + if (deltax || deltay) + { + if (nSide !=6) + lpRect->bottom = lpRect->top + (int)(w/ratio) + borderh; + else + lpRect->right = lpRect->left + (int)(h*ratio) + borderw; + } + return CFrameWnd::OnSizing(nSide,lpRect); +} diff --git a/ActiveGS.exe/MainFrm.h b/ActiveGS.exe/MainFrm.h new file mode 100644 index 0000000..2192c40 --- /dev/null +++ b/ActiveGS.exe/MainFrm.h @@ -0,0 +1,54 @@ +// MainFrm.h : interface de la classe CMainFrame +// + + +#pragma once + +#include "../Common.win32/ChildView.h" +//#include "../common32/activecommon.h" + +class CMainFrame : public CFrameWnd +{ + +public: + CMainFrame(int _argc, char ** _argv); +protected: + DECLARE_DYNAMIC(CMainFrame) + +// Attributs +public: + CChildView m_wndView; + +// Opérations +public: + +// Substitutions +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); + +// Implémentation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // membres incorporés de la barre de contrôle + /* + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + */ +// Fonctions générées de la table des messages +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSetFocus(CWnd *pOldWnd); + DECLARE_MESSAGE_MAP() + virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); + afx_msg void OnSizing(UINT nSide,LPRECT lpRect); +public: + afx_msg void OnDestroy(); +}; + + diff --git a/ActiveGS.exe/Resource.h b/ActiveGS.exe/Resource.h new file mode 100644 index 0000000..3070db3 --- /dev/null +++ b/ActiveGS.exe/Resource.h @@ -0,0 +1,24 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ActiveGSApp.rc +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_HTML_TABDISKURL 103 +#define IDR_MAINFRAME 128 +#define IDR_ActiveGSAppTYPE 129 +#define IDR_1APP 129 +#define IDR_3DSK 130 +#define IDR_2DSK 130 +#define IDR_32MG 131 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif diff --git a/ActiveGS.exe/cgfiltyp.cpp b/ActiveGS.exe/cgfiltyp.cpp new file mode 100644 index 0000000..1d689ba --- /dev/null +++ b/ActiveGS.exe/cgfiltyp.cpp @@ -0,0 +1,328 @@ +//- ----------------------------------------------------------------- +//- (C) Copyright 2000 Blake V. Miller +//- All Rights Reserved. +//- ----------------------------------------------------------------- +//- File : CGFILTYP.CPP +//- Author : Blake Miller +//- Version : June 16, 2000 +//- Purpose : File Type Access +//- ----------------------------------------------------------------- + +#include "../Common.win32/stdafx.h" +#include "winerror.h" + +#ifndef __CGFILTYP_H__ +#include "CGFILTYP.H" // CGCFileTypeAccess +#endif + +#undef THIS_FILE +static char THIS_FILE[] = "CGFILTYP.CPP"; + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +IMPLEMENT_DYNAMIC(CGCFileTypeAccess, CObject) + +CGCFileTypeAccess::CGCFileTypeAccess() +{ +} + +// virtual +CGCFileTypeAccess::~CGCFileTypeAccess() +{ +} + +//- ***************************************************************** +//- Functions Affecting Registry +//- ***************************************************************** + +// virtual +BOOL CGCFileTypeAccess::RegSetAllInfo(void) +{ + RegSetExtension(); + RegSetDocumentType(); + RegSetCLSID(); + RegSetShellInfo(); + + return TRUE; +} + +// HKEY_CLASSES_ROOT\. +// virtual +BOOL CGCFileTypeAccess::RegSetExtension(void) +{ + if( m_csExtension.IsEmpty() ){ + return TRUE; + } + + CString csKey = "." + m_csExtension; + + SetRegistryValue(HKEY_CLASSES_ROOT, csKey, "", m_csDocumentClassName); + + if( !m_csShellOpenCommand.IsEmpty() ){ + csKey += "\\shell\\open\\command"; + SetRegistryValue(HKEY_CLASSES_ROOT, csKey, "", m_csShellOpenCommand); + } + + return TRUE; +} + +// HKEY_CLASSES_ROOT\. +// virtual +BOOL CGCFileTypeAccess::RegSetDocumentType(void) +{ + if( m_csDocumentClassName.IsEmpty()){ + return TRUE; + } + + CString csKey = m_csDocumentClassName; + + SetRegistryValue(HKEY_CLASSES_ROOT, csKey, "", m_csDocumentDescription); + + // DefaultIcon + if( !m_csDocumentDefaultIcon.IsEmpty() ){ + csKey = m_csDocumentClassName; + csKey += "\\DefaultIcon"; + SetRegistryValue(HKEY_CLASSES_ROOT, csKey, "", m_csDocumentDefaultIcon); + } + + // shell\open\command + if( !m_csShellOpenCommand.IsEmpty() ){ + csKey = m_csDocumentClassName; + csKey += "\\shell\\open\\command"; + SetRegistryValue(HKEY_CLASSES_ROOT, csKey, "", m_csShellOpenCommand); + } + + return TRUE; +} + +// HKEY_CLASSES_ROOT\CLSID\ +// virtual +BOOL CGCFileTypeAccess::RegSetCLSID(void) +{ + return TRUE; +} + +// +// virtual +BOOL CGCFileTypeAccess::RegSetShellInfo(void) +{ + return TRUE; +} + +//- ***************************************************************** +//- Member Variable Get/Set Methods +//- ***************************************************************** + +void CGCFileTypeAccess::SetExtension( + LPCTSTR szExtension +){ + m_csExtension = szExtension; +} +void CGCFileTypeAccess::GetExtension( + CString& csExtension +) const { + csExtension = m_csExtension; +} + +void CGCFileTypeAccess::SetContentType( + LPCTSTR szContentType +){ + m_csContentType = szContentType; +} +void CGCFileTypeAccess::GetContentType( + CString& csContentType +) const { + csContentType = m_csContentType; +} + +void CGCFileTypeAccess::SetShellOpenCommand( + LPCTSTR szShellOpenCommand +){ + m_csShellOpenCommand = szShellOpenCommand; +} +void CGCFileTypeAccess::GetShellOpenCommand( + CString& csShellOpenCommand +) const { + csShellOpenCommand = m_csShellOpenCommand; +} + +void CGCFileTypeAccess::SetShellNewCommand( + LPCTSTR szShellNewCommand +){ + m_csShellNewCommand = szShellNewCommand; +} +void CGCFileTypeAccess::GetShellNewCommand( + CString& csShellNewCommand +) const { + csShellNewCommand = m_csShellNewCommand; +} + +void CGCFileTypeAccess::SetShellNewFileName( + LPCTSTR szShellNewFileName +){ + m_csShellNewFileName = szShellNewFileName; +} +void CGCFileTypeAccess::GetShellNewFileName( + CString& csShellNewFileName +) const { + csShellNewFileName = m_csShellNewFileName; +} + +void CGCFileTypeAccess::SetDocumentClassName( + LPCTSTR szDocumentClassName +){ + m_csDocumentClassName = szDocumentClassName; +} +void CGCFileTypeAccess::GetDocumentClassName( + CString& csDocumentClassName +) const { + csDocumentClassName = m_csDocumentClassName; +} + +void CGCFileTypeAccess::SetDocumentDescription( + LPCTSTR szDocumentDescription +){ + m_csDocumentDescription = szDocumentDescription; +} +void CGCFileTypeAccess::GetDocumentDescription( + CString& csDocumentDescription +) const { + csDocumentDescription = m_csDocumentDescription; +} + +void CGCFileTypeAccess::SetDocumentCLSID( + LPCTSTR szDocumentCLSID +){ + m_csDocumentCLSID = szDocumentCLSID; +} +void CGCFileTypeAccess::GetDocumentCLSID( + CString& csDocumentCLSID +) const { + csDocumentCLSID = m_csDocumentCLSID; +} + +void CGCFileTypeAccess::SetDocumentCurrentVersion( + LPCTSTR szDocumentCurrentVersion +){ + m_csDocumentCurrentVersion = szDocumentCurrentVersion; +} +void CGCFileTypeAccess::GetDocumentCurrentVersion( + CString& csDocumentCurrentVersion +) const { + csDocumentCurrentVersion = m_csDocumentCurrentVersion; +} + +void CGCFileTypeAccess::SetDocumentDefaultIcon( + LPCTSTR szDocumentDefaultIcon +){ + m_csDocumentDefaultIcon = szDocumentDefaultIcon; +} +void CGCFileTypeAccess::GetDocumentDefaultIcon( + CString& csDocumentDefaultIcon +) const { + csDocumentDefaultIcon = m_csDocumentDefaultIcon; +} + +void CGCFileTypeAccess::SetDocumentShellOpenCommand( + LPCTSTR szDocumentShellOpenCommand +){ + m_csDocumentShellOpenCommand = szDocumentShellOpenCommand; +} +void CGCFileTypeAccess::GetDocumentShellOpenCommand( + CString& csDocumentShellOpenCommand +) const { + csDocumentShellOpenCommand = m_csDocumentShellOpenCommand; +} + +// virtual +void CGCFileTypeAccess::ClearAllData(void) +{ + m_csExtension.Empty(); + m_csContentType.Empty(); + m_csShellOpenCommand.Empty(); + m_csShellNewCommand.Empty(); + m_csShellNewFileName.Empty(); + + m_csDocumentClassName.Empty(); + m_csDocumentDescription.Empty(); + m_csDocumentCLSID.Empty(); + m_csDocumentCurrentVersion.Empty(); + m_csDocumentDefaultIcon.Empty(); + m_csDocumentShellOpenCommand.Empty(); +} + +//- ----------------------------------------------------------------- +//- set string value into registry + +BOOL CGCFileTypeAccess::SetRegistryValue( + HKEY hOpenKey, + LPCTSTR szKey, + LPCTSTR szValue, + LPCTSTR szData +){ + + // OG HACK + // Write to the Current User instead of Class Root : bypass UAC !!! + + hOpenKey = HKEY_CURRENT_USER ; + CString newKey; + newKey.Format("Software\\Classes\\%s",szKey); + szKey = (const char*)newKey; + + // validate input + if( !hOpenKey || !szKey || !szKey[0] || + !szValue || !szData ){ + ::SetLastError(E_INVALIDARG); + return FALSE; + } + + BOOL bRetVal = FALSE; + DWORD dwDisposition; + DWORD dwReserved = 0; + HKEY hTempKey = (HKEY)0; + + // length specifier is in bytes, and some TCHAR + // are more than 1 byte each + DWORD dwBufferLength = lstrlen(szData) * sizeof(TCHAR); + + // Open key of interest + // Assume all access is okay and that all keys will be stored to file + // Utilize the default security attributes + + // OG Track error + LONG err = ::RegCreateKeyEx(hOpenKey, szKey, dwReserved, + (LPTSTR)0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, + &hTempKey, &dwDisposition); + + if( ERROR_SUCCESS ==err ) + { + + // dwBufferLength must include size of terminating nul + // character when using REG_SZ with RegSetValueEx function + dwBufferLength += sizeof(TCHAR); + + err = ::RegSetValueEx(hTempKey, (LPTSTR)szValue, + dwReserved, REG_SZ, (LPBYTE)szData, dwBufferLength) ; + if( ERROR_SUCCESS == err ) + bRetVal = TRUE; + } + + if (err != ERROR_SUCCESS) + { + char errstr[1024]; + sprintf(errstr,"RegSetValueEx: %Xn",err); + OutputDebugString(errstr); + } + // close opened key + if( hTempKey ){ + ::RegCloseKey(hTempKey); + } + + return bRetVal; +} + +//- ----------------------------------------------------------------- +//- END CGFILTYP.CPP Source File +//- ----------------------------------------------------------------- diff --git a/ActiveGS.exe/cgfiltyp.h b/ActiveGS.exe/cgfiltyp.h new file mode 100644 index 0000000..b510d95 --- /dev/null +++ b/ActiveGS.exe/cgfiltyp.h @@ -0,0 +1,100 @@ +//- ----------------------------------------------------------------- +//- (C) Copyright 2000 Blake V. Miller +//- All Rights Reserved. +//- ----------------------------------------------------------------- +//- File : CGFILTYP.H +//- Author : Blake Miller +//- Version : June 16, 2000 +//- Purpose : File Type Access +//- ----------------------------------------------------------------- + +#if _MSC_VER > 1000 +#pragma once +#endif + +#ifndef __CGFILTYP_H__ +#define __CGFILTYP_H__ +#ifdef __cplusplus + +class CGCFileTypeAccess : public CObject +{ + DECLARE_DYNAMIC(CGCFileTypeAccess) + +public: + + CGCFileTypeAccess(); + virtual ~CGCFileTypeAccess(); + + virtual void ClearAllData(void); + + //- ---------------------------------------- + //- Effect Registry + + virtual BOOL RegSetAllInfo (void); + + virtual BOOL RegSetExtension (void); + virtual BOOL RegSetDocumentType (void); + virtual BOOL RegSetCLSID (void); + virtual BOOL RegSetShellInfo (void); + + //- ---------------------------------------- + //- Modify Member Variables + + void SetExtension (LPCTSTR); + void GetExtension (CString&) const; + + void SetContentType (LPCTSTR); + void GetContentType (CString&) const; + + void SetShellOpenCommand (LPCTSTR); + void GetShellOpenCommand (CString&) const; + + void SetShellNewCommand (LPCTSTR); + void GetShellNewCommand (CString&) const; + + void SetShellNewFileName (LPCTSTR); + void GetShellNewFileName (CString&) const; + + void SetDocumentClassName (LPCTSTR); + void GetDocumentClassName (CString&) const; + + void SetDocumentDescription (LPCTSTR); + void GetDocumentDescription (CString&) const; + + void SetDocumentCLSID (LPCTSTR); + void GetDocumentCLSID (CString&) const; + + void SetDocumentCurrentVersion (LPCTSTR); + void GetDocumentCurrentVersion (CString&) const; + + void SetDocumentDefaultIcon (LPCTSTR); + void GetDocumentDefaultIcon (CString&) const; + + void SetDocumentShellOpenCommand (LPCTSTR); + void GetDocumentShellOpenCommand (CString&) const; + +protected: + + BOOL SetRegistryValue(HKEY, LPCTSTR, LPCTSTR, LPCTSTR); + + CString m_csExtension; + CString m_csContentType; + CString m_csShellOpenCommand; + CString m_csShellNewCommand; + CString m_csShellNewFileName; + + CString m_csDocumentClassName; + CString m_csDocumentDescription; + CString m_csDocumentCLSID; + CString m_csDocumentCurrentVersion; + CString m_csDocumentDefaultIcon; + CString m_csDocumentShellOpenCommand; + +}; + +#endif // __cplusplus +#endif // __CGFILTYP_H__ + +//- ----------------------------------------------------------------- +//- END CGFILTYP.H Header File +//- ----------------------------------------------------------------- diff --git a/ActiveGS.exe/res/ActiveGSApp.ico b/ActiveGS.exe/res/ActiveGSApp.ico new file mode 100644 index 0000000..d96e3b4 Binary files /dev/null and b/ActiveGS.exe/res/ActiveGSApp.ico differ diff --git a/ActiveGS.exe/res/ActiveGSApp.manifest b/ActiveGS.exe/res/ActiveGSApp.manifest new file mode 100644 index 0000000..110f622 --- /dev/null +++ b/ActiveGS.exe/res/ActiveGSApp.manifest @@ -0,0 +1,22 @@ + + + +Tapez ici une description de votre application + + + + + + diff --git a/ActiveGS.exe/res/ActiveGSApp.rc2 b/ActiveGS.exe/res/ActiveGSApp.rc2 new file mode 100644 index 0000000..2dfe134 --- /dev/null +++ b/ActiveGS.exe/res/ActiveGSApp.rc2 @@ -0,0 +1,13 @@ +// +// ActiveGSApp.RC2 - ressources que Microsoft Visual C++ ne modifie pas directement +// + +#ifdef APSTUDIO_INVOKED +#error "ce fichier n'est pas modifiable par Microsoft Visual C++" +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Ajouter ici les ressources modifiées manuellement... + +///////////////////////////////////////////////////////////////////////////// diff --git a/ActiveGS.exe/res/Toolbar.bmp b/ActiveGS.exe/res/Toolbar.bmp new file mode 100644 index 0000000..b8c8c8e Binary files /dev/null and b/ActiveGS.exe/res/Toolbar.bmp differ diff --git a/ActiveGS.exe/res/idr_22mg.ico b/ActiveGS.exe/res/idr_22mg.ico new file mode 100644 index 0000000..6222474 Binary files /dev/null and b/ActiveGS.exe/res/idr_22mg.ico differ diff --git a/ActiveGS.exe/res/idr_2mg1.ico b/ActiveGS.exe/res/idr_2mg1.ico new file mode 100644 index 0000000..d933dd1 Binary files /dev/null and b/ActiveGS.exe/res/idr_2mg1.ico differ diff --git a/ActiveGS.exe/res/idr_main.ico b/ActiveGS.exe/res/idr_main.ico new file mode 100644 index 0000000..d96e3b4 Binary files /dev/null and b/ActiveGS.exe/res/idr_main.ico differ diff --git a/Common.win32/ActiveCommon.aps b/Common.win32/ActiveCommon.aps new file mode 100644 index 0000000..901e895 Binary files /dev/null and b/Common.win32/ActiveCommon.aps differ diff --git a/Common.win32/ActiveCommon.cpp b/Common.win32/ActiveCommon.cpp new file mode 100644 index 0000000..edf7323 --- /dev/null +++ b/Common.win32/ActiveCommon.cpp @@ -0,0 +1,664 @@ +#include "../common.win32/stdafx.h" +#include +#include +#include "activecommon.h" +#include "../kegs/src/sim65816.h" +#include "../kegs/src/driver.h" +#include "../kegs/src/adb.h" +#include "../common.win32/activegs.rc.h" + + +extern const char* currentBuild; + +void x_display_alert(int _abord, const char* _title, const char* _msg) +{ + + CString strsys(_msg); + CString titlesys(_title); + + MessageBox(NULL,strsys,titlesys,MB_OK); +} + + +CEmulatorWin32::CEmulatorWin32(CEmulator** _parent) : CEmulator(_parent) +{ + + m_hWnd = NULL; + hThread = NULL; +#ifndef UNDER_CE + hAlphaCursor = NULL; + activeInfo = NULL; + wStatus=NULL; + wLoading=NULL; + theConsole=NULL; + hhkLowLevelKybd=NULL; +#endif + +} + +extern void my_exit(int); + +CEmulatorWin32::~CEmulatorWin32() +{ + outputInfo("~CEmulatorWin32 (%X)\n",this); + destroy(); +#ifndef UNDER_CE + disableSystemKeys(); +#endif + +} +extern void kegsshut(); + +DWORD WINAPI CEmulatorWin32::myThread(LPVOID lpParameter) +{ + CEmulatorWin32* emu = (CEmulatorWin32*)lpParameter; + kegsinit(emu->m_hWnd); + emu->theThread(); + kegsshut(); + CloseHandle(emu->hThread); + emu->hThread=NULL; + return 0; +} + + + + + + +int CEmulatorWin32::initWindow(HWND _hWnd, HINSTANCE _hInstance) +{ + + m_hWnd = _hWnd; + hInst = _hInstance; + +#ifndef UNDER_CE + theConsole=new CConsole(); + CWnd *pw =CWnd::FromHandle(m_hWnd); + wStatus = new CActiveStatus(pw); + wStatus->Create(CActiveStatus::IDD,pw); + wLoading = new CActiveStatus(pw); + wLoading->Create(IDD_LOADING,pw); + + wLoadingBitmap[0].LoadBitmap(IDB_DISK51); + wLoadingBitmap[1].LoadBitmap(IDB_DISK52); + wLoadingBitmap[2].LoadBitmap(IDB_DISK61); + wLoadingBitmap[3].LoadBitmap(IDB_DISK62); + + enableSystemKeys(); +#endif + + resetLocalIMG(); + return 1; + +} + +void async_snd_shutdown(); +void async_sound_init(); + +void CEmulatorWin32::x_WaitForEndThread() +{ + // enlËve le mode pause + //g_pause=0; + + DWORD r; + MSG msg; + while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE )||bInThread ) + { + // Sleep(20); + int bStillRunning = hThread && (r=WaitForSingleObject(hThread,0)==WAIT_TIMEOUT); + if (!bStillRunning) + { + outputInfo("exiting thread %X %X\n",hThread,r); + break; + } + } + +} +/* +void CEmulatorWin32::activateEmulator() +{ + if (theEmulator != this) + return ; + launchEmulator( this->hInst,this->m_hWnd ); +} +*/ + +void CEmulatorWin32::x_LaunchThread( ) +{ + if (theEmulator != this) return ; + + outputInfo("launching win32 thread\n"); + + DWORD threadID; + +#ifndef UNDER_CE + theConsole->initConsole(this->hInst,this->m_hWnd); + hAlphaCursor = CreateAlphaCursor(hInst); +#endif + + // initialize le son async + //async_sound_init(); + + hThread= CreateThread(NULL,0,myThread,this,0,&threadID ); + if (!hThread) + outputInfo("thread initialisation failed!\n"); +/* + else + bRun = true; +*/ +} + + + +LRESULT CEmulatorWin32::eventHandler(UINT umsg, WPARAM wParam, LPARAM lParam) +{ + return win_event_handler(m_hWnd,umsg,wParam,lParam); +} + +void win_event_key_async(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags); + +void CEmulatorWin32::keyHandler(UINT raw_vk,BOOL down, UINT flags) +{ + win_event_key_async(m_hWnd,raw_vk, down, 0/*repeat*/, flags); +} + +int CEmulatorWin32::hasFocus() +{ + HWND h = ::GetFocus(); + if (h == m_hWnd) return 1; + else return 0; +} + +#ifndef UNDER_CE +LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + + BOOL fEatKeystroke = FALSE; + CEmulatorWin32* emu = (CEmulatorWin32*)CEmulator::theEmulator; + + // Manage the key only if the emulator has the focus + if (emu && emu->hasFocus() && nCode == HC_ACTION) + { + PKBDLLHOOKSTRUCT p; + p = (PKBDLLHOOKSTRUCT) lParam; + + int down=0; + switch (wParam) + { + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + down=1; + case WM_SYSKEYUP: + case WM_KEYUP: + + int syskeys = ( p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN ) || + ( p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN ) || + ( p->vkCode == VK_ESCAPE && (GetKeyState(VK_CONTROL) & 0x8000)) || + p->vkCode == VK_LWIN || + p->vkCode == VK_RWIN || + p->vkCode==VK_CANCEL || + p->vkCode==VK_SCROLL || + p->vkCode==VK_TAB || + p->vkCode==VK_LMENU || + p->vkCode == VK_APPS; + + if (syskeys ) + { + fEatKeystroke = 1; + // outputInfo("LLSYKEY: %X\n",p->vkCode); + ASSERT(emu); + emu->keyHandler(p->vkCode,down,((p->flags&0x1)<<8)); + } + else + { + // outputInfo("LLKEY: %X\n",p->vkCode); + } + + break; + } + } + else + { + // outputInfo("NO LL: %X %X %X",GetActiveWindow(),::GetFocus(),emu?emu->m_hWnd:0 ); + } + + return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam, + lParam)); +} + +void CEmulatorWin32::enableSystemKeys() +{ + hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, AfxGetInstanceHandle(), 0); +} + +void CEmulatorWin32::disableSystemKeys() +{ + if (hhkLowLevelKybd) + UnhookWindowsHookEx(hhkLowLevelKybd); +} +#endif + + +extern const char * activegsdownloaddir ; + +extern int g_config_control_panel; + +LRESULT CEmulatorWin32::windowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + { + if (message==WM_USER) + { + if (wParam==LOADING_ON) + { + showLoading(TRUE,lParam); + return TRUE; + } + else + if (wParam==LOADING_OFF) + { + showLoading(FALSE,lParam); + return TRUE; + } + else + if (wParam==REFRESH_STATUS) + { + refreshStatus(this->statusMsg.c_str()); + return TRUE; + } + else + return eventHandler(message,wParam,lParam); + + } + else +#ifndef UNDER_CE + if (message==WM_SETCURSOR) + { + if (hasFocus() && !g_config_control_panel) + { + SetCursor(hAlphaCursor); + return TRUE; + } + else + { + //outputInfo("nofocus\n"); + return FALSE; + } + } + else +#endif + if (message==WM_RBUTTONDOWN) + { + ShowActiveInfo(); + } + else + return eventHandler(message,wParam,lParam); + } + + return DefWindowProc(m_hWnd,message, wParam, lParam); +} + +void CEmulatorWin32::destroy() +{ + + + outputInfo("onDestroy\n"); + +#ifndef UNDER_CE + if (hAlphaCursor) + { + DestroyIcon(hAlphaCursor); + hAlphaCursor = NULL; + } + if (activeInfo) + { + activeInfo->DestroyWindow(); + delete activeInfo; + activeInfo=NULL; + } + + if (wStatus ) + { + // if (IsWindow(wStatus->m_hWnd)) + wStatus->DestroyWindow(); + delete wStatus; + wStatus = NULL; + + } + + + if (wLoading ) + { + + // if (IsWindow(wLoading->m_hWnd)) + wLoading->DestroyWindow(); + delete wLoading; + wLoading=NULL; + } + + + for(int i=0;i<4;i++) + wLoadingBitmap[i].DeleteObject(); + + if (theConsole) + { + theConsole->shutConsole(this->m_hWnd); + delete theConsole; + theConsole=NULL; + } +#endif +} + + +void CEmulatorWin32::ShowActiveInfo() +{ + if(!bInThread) + { + MessageBox(m_hWnd,_T("Close other instances first & reload page"),_T("ActiveGS"),MB_OK); + return ; + } +#ifndef UNDER_CE + if (!activeInfo) + { + CWnd *pw =CWnd::FromHandle(m_hWnd); + activeInfo = new CActiveInfo(pw); // this? + activeInfo->Create(CActiveInfo::IDD,pw); // this ? + } + + g_adb.g_warp_pointer=WARP_NONE; + g_adb.g_hide_pointer = 0; + x_hide_pointer(false); + + activeInfo->ShowWindow(SW_SHOW); +#endif +} + +void CEmulatorWin32::refreshStatus(const char* _msg) +{ +#ifndef UNDER_CE + if (wStatus) + { + RECT my; + wStatus->GetWindowRect(&my); + wStatus->ScreenToClient(&my); + my.left += 8; + my.right += 8; + my.bottom += 8; + my.top +=8; + + wStatus->MoveWindow(&my); + wStatus->SendDlgItemMessage(IDC_STATUS,WM_SETTEXT,0,(LPARAM)(LPCSTR)_msg); + wStatus->ShowWindow(SW_SHOWNOACTIVATE); + OutputDebugString(_msg); + if (wStatus->TimerID) + wStatus->KillTimer(wStatus->TimerID); + wStatus->TimerID = wStatus->SetTimer(0,2000,NULL); + + } +#endif +} + + +void CEmulatorWin32::showLoading( int _loading,int _disk) +{ +#ifndef UNDER_CE + if (wLoading) + { + if (_loading) + { + RECT my; + wLoading->GetWindowRect(&my); + wLoading->ScreenToClient(&my); + + + CWnd* w = CWnd::FromHandle(this->m_hWnd); + RECT wrect; + w->GetClientRect(&wrect); + + + my.left += wrect.right-56; + my.right += wrect.right-56; + my.bottom += 8; + my.top +=8; + wLoading->MoveWindow(&my); + + CWnd * hWndViewer = wLoading->GetDlgItem(IDC_IMAGECTRLDISK); + hWndViewer->SendMessage( STM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) wLoadingBitmap[_disk].m_hObject ); + + wLoading->ShowWindow(SW_SHOWNOACTIVATE); + if (wLoading->TimerID) + { + wLoading->KillTimer(wLoading->TimerID); + wLoading->TimerID = NULL; + } + } + else + { + if (!wLoading->TimerID) + wLoading->TimerID = wLoading->SetTimer(2,2000,NULL); + } + + } +#endif +} + +#ifndef UNDER_CE +void DeleteCursor(HCURSOR theCursor) +{ + DestroyIcon(theCursor); +} + +typedef struct { + DWORD bV5Size; + LONG bV5Width; + LONG bV5Height; + WORD bV5Planes; + WORD bV5BitCount; + DWORD bV5Compression; + DWORD bV5SizeImage; + LONG bV5XPelsPerMeter; + LONG bV5YPelsPerMeter; + DWORD bV5ClrUsed; + DWORD bV5ClrImportant; + DWORD bV5RedMask; + DWORD bV5GreenMask; + DWORD bV5BlueMask; + DWORD bV5AlphaMask; + DWORD bV5CSType; + CIEXYZTRIPLE bV5Endpoints; + DWORD bV5GammaRed; + DWORD bV5GammaGreen; + DWORD bV5GammaBlue; + DWORD bV5Intent; + DWORD bV5ProfileData; + DWORD bV5ProfileSize; + DWORD bV5Reserved; +} MYBITMAPV5HEADER; + + + +HCURSOR CreateAlphaCursor(HINSTANCE hInst) +{ +HDC hMemDC; +DWORD dwWidth, dwHeight; +MYBITMAPV5HEADER bi; +HBITMAP hBitmap, hOldBitmap; +void *lpBits; +DWORD x,y; +HCURSOR hAlphaCursor = NULL; + +HDC hdc; +HDC src; +HBITMAP hMonoBitmap; +DWORD *lpdwPixel; +ICONINFO ii; +HGDIOBJ hOldSrc; + + HBITMAP hBm = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ALPHACURSOR)); + if (!hBm) + { + outputInfo("Load AlphaCursor failed (inst:%0X)\n",hInst); + return NULL; + } + + BITMAP bm; + GetObject(hBm, sizeof(bm), &bm); + /* + alpha.GetBitmap(&bm); + */ + + dwWidth = bm.bmWidth; // width of cursor + dwHeight = bm.bmHeight; // height of cursor + + ZeroMemory(&bi,sizeof(MYBITMAPV5HEADER)); + bi.bV5Size = sizeof(MYBITMAPV5HEADER); + bi.bV5Width = dwWidth; + bi.bV5Height = dwHeight; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_BITFIELDS; + // The following mask specification specifies a supported 32 BPP + // alpha format for Windows XP. + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; + + + hdc = GetDC(NULL); + + // Create the DIB section with an alpha channel. + hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, + (void **)&lpBits, NULL, (DWORD)0); + + hMemDC = CreateCompatibleDC(hdc); + src = CreateCompatibleDC(hdc); + ReleaseDC(NULL,hdc); + + hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); + hOldSrc = SelectObject( src, hBm ); + BitBlt(hMemDC,0,0,dwWidth,dwHeight,src,0,0,SRCCOPY); + SelectObject(src,hOldSrc); + DeleteDC(src); + SelectObject(hMemDC,hOldBitmap); + DeleteDC(hMemDC); + + // Create an empty mask bitmap + hMonoBitmap = CreateBitmap(dwWidth,dwHeight,1,1,NULL); + + lpdwPixel = (DWORD *)lpBits; + for (x=0;xdisableConsole(); +#endif +} + +int CEmulatorWin32::activeRead(char *buf) +{ +#ifndef UNDER_CE + CConsole* c = theConsole; + if (c) + return c->read(buf); +#endif + buf[0]=0; + return 0; + +} +void CEmulatorWin32::getEngineString(MyString& _engine) +{ + + _engine ="WIN32"; +#ifdef USE_RASTER + _engine+="(vbl)"; +#endif +}; + + +void x_refresh_panel(int _enum) +{ +#ifndef UNDER_CE + CEmulatorWin32* p = (CEmulatorWin32*)CEmulator::theEmulator; + if (!p) return; + if (!p->activeInfo) return ; + if (_enum & PANEL_PARAMS) + p->activeInfo->updateParams(); + if (_enum & (PANEL_DISK | PANEL_RUNTIME)) + p->activeInfo->refresh(); +#endif +} + + +const int soundWin32Ressources[]= +{ + NULL, + IDR_SPINUPSEARCH1, + IDR_SPINUPSEARCH2 +}; + +void x_play_sound(enum_sound hSound) +{ + HINSTANCE h = ((CEmulatorWin32*)CEmulator::theEmulator)->hInst; + BOOL err = PlaySound(MAKEINTRESOURCE(soundWin32Ressources[hSound]), h, SND_RESOURCE | SND_ASYNC); +} + +int x_is_sound_playing(enum_sound _hSound) +{ + return 0; +}; \ No newline at end of file diff --git a/Common.win32/ActiveCommon.rc b/Common.win32/ActiveCommon.rc new file mode 100644 index 0000000..80bc15f --- /dev/null +++ b/Common.win32/ActiveCommon.rc @@ -0,0 +1,334 @@ +// Microsoft Visual C++ generated resource script. +// +#include "activecommonres.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Français (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "activecommonres.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_DISK51 BITMAP "bitmap2.bmp" + +IDB_DISK52 BITMAP "disk52.bmp" + +IDB_DISK61 BITMAP "disk54.bmp" + +IDB_DISK62 BITMAP "disk55.bmp" + +IDB_ALPHACURSOR BITMAP "bmp00001.bmp" + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ACTIVEINFO DIALOGEX 0, 0, 247, 143 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "ActiveGS v2.3 (Build BETA 07/MAY/09)" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_ACTIVETAB,"SysTabControl32",0x0,7,7,233,129 +END + +IDD_TABGENERAL DIALOGEX 0, 0, 192, 105 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "ActiveGS v3.6",IDC_STATIC,6,18,72,8 + LTEXT "Olivier Goguel",IDC_URLOG,84,18,54,8 + LTEXT "Kegs v0.91",IDC_STATIC,6,30,72,8 + LTEXT "Kent Dickey",IDC_URLKD,84,30,54,8 + LTEXT "Active GS Home Page",IDC_STATIC,6,66,70,8 + LTEXT "http://activegs.freetoolsassociation.com",IDC_URLFTA,84,66,99,8 + LTEXT "Build :",IDC_BUILD,7,97,178,8 + LTEXT "Active GS Home Page",IDC_VERSION,7,90,178,8 + LTEXT "Disk Drive Sounds",IDC_STATIC,7,44,72,8 + LTEXT "Moose O'Malley",IDC_URLKD2,85,44,54,8 +END + +IDD_TABDISKCONF DIALOGEX 0, 0, 230, 117 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_SLOTLIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,6,6,209,68 + PUSHBUTTON "Mount",IDC_MOUNTBUTTON,174,96,41,12 + EDITTEXT IDC_EDITURL,48,96,96,12,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES + PUSHBUTTON "EJect",IDC_EJECT,48,78,30,12 + PUSHBUTTON "Reload",IDC_RELOAD,6,96,36,12 + PUSHBUTTON "5",IDC_REBOOT5,161,78,16,12 + PUSHBUTTON "6",IDC_REBOOT6,179,78,16,12 + PUSHBUTTON "7",IDC_REBOOT7,198,78,16,12 + LTEXT "Reboot",IDC_STATICSLOT2,136,80,23,9 + COMBOBOX IDC_COMBOSLOT,6,78,36,66,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "...",IDC_FILESELECT,146,96,16,12 + PUSHBUTTON "Swap",IDC_SWAP,81,78,30,12 +END + +IDD_TABPARAM DIALOGEX 0, 0, 198, 120 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_PARAMLIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,26,184,78 +END + +IDD_TABOPTION DIALOGEX 0, 0, 239, 113 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Use persistent storage",IDC_NOIECACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,18,108,10 + LTEXT "Persistent Directory",IDC_STATIC,12,30,64,12 + EDITTEXT IDC_PERSISTENT,78,30,138,14,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Persistent Storage",IDC_STATIC,6,6,216,40 + GROUPBOX "Debug Options (for advanced users only)",IDC_STATIC,6,48,216,40 + CONTROL "Halt on bad memory read",IDC_HALTBADREAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,60,96,10 + CONTROL "Halt on all events",IDC_HALTEVENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,120,60,84,10 + CONTROL "Halt on bad memory access",IDC_HALTBADACCESS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,72,102,10 + PUSHBUTTON "Default Options",IDC_DEFAULTOPTIONS,150,72,66,12 + PUSHBUTTON "Clear Cache",IDC_CLEARCACHE,150,12,66,12,WS_DISABLED + CONTROL "Enable Realtime capture (Rewind Mode)",IDC_ENABLEREWIND, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,90,162,10 +END + +IDD_TABHELP DIALOGEX 0, 0, 230, 110 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "F4",IDC_STATIC,12,84,9,8 + LTEXT "Toggle joystick mode",IDC_STATIC,66,84,68,8 + LTEXT "ALT or F1",IDC_STATIC,12,18,32,8 + LTEXT "Open-Apple",IDC_STATIC,66,18,39,8 + LTEXT "WIN or F2",IDC_STATIC,12,30,34,8 + LTEXT "Closed-Apple / Option",IDC_STATIC,66,30,82,8 + LTEXT "F8",IDC_STATIC,12,72,9,8 + LTEXT "Toggle mouse lock",IDC_STATIC,66,72,59,8 + GROUPBOX "Apple II GS",IDC_STATIC,6,6,216,48 + GROUPBOX "Emulator",IDC_STATIC,6,60,216,48 + LTEXT "PAUSE or F12",IDC_STATIC,12,42,45,8 + LTEXT "Reset",IDC_STATIC,66,42,20,8 + LTEXT "F5",IDC_STATIC,12,97,9,8 + LTEXT "Pause/Resume",IDC_STATIC,66,97,48,8 +END + +IDD_TABRUNTIME1 DIALOGEX 0, 0, 230, 117 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "?",IDC_SPEED,144,6,79,8 + COMBOBOX IDC_SPEEDMODE,60,6,66,53,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "",IDC_ZIPSLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_TOOLTIPS | WS_TABSTOP,60,18,66,24 + LTEXT "Joystick Mode",IDC_STATIC,6,42,46,12 + COMBOBOX IDC_JOYSTICK,60,42,66,66,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Pause",IDC_PAUSE,144,78,66,12 + PUSHBUTTON "Screenshot",IDC_CONSOLEBUTTON2,144,60,66,12 + PUSHBUTTON "Capture State",IDC_SAVESTATE,60,96,66,12 + PUSHBUTTON "Restore State",IDC_RESTORESTATE,144,96,66,12 + LTEXT "Speed Mode",IDC_STATIC,6,6,48,12 + LTEXT "Video Type",IDC_STATIC,6,60,46,12 + COMBOBOX IDC_VIDEOFX,60,60,66,66,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Color Mode",IDC_STATIC,6,78,46,12 + COMBOBOX IDC_COLORMODE,60,78,66,66,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Zip Speed",IDC_STATIC,6,24,48,12 + PUSHBUTTON "Display Console",IDC_CONSOLEBUTTON3,144,24,66,12 + COMBOBOX IDC_STATE,7,96,36,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP +END + +IDD_LOADING DIALOGEX 0, 0, 30, 24 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_IMAGECTRLDISK,"Static",SS_BITMAP | SS_CENTERIMAGE,0,0,30,24 +END + +IDD_STATUS DIALOGEX 0, 0, 252, 22 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "(...)",IDC_STATUS,7,7,238,8,0,WS_EX_TRANSPARENT +END + +IDD_TABXML DIALOGEX 0, 0, 230, 110 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Name",-1,12,18,32,8 + LTEXT "Open-Apple",IDC_MULTIPLENAME,66,18,138,8 + LTEXT "Publisher",-1,12,30,31,8 + LTEXT "Closed-Apple / Option",IDC_MULTIPLEPUBLISHER,66,30,145,8 + LTEXT "Current",-1,12,72,26,8 + LTEXT "...",IDC_MULTIPLECURRENT,66,72,59,8 + GROUPBOX "Running",-1,6,6,216,48 + GROUPBOX "Multiple Disk",-1,6,60,216,42 + LTEXT "Year",-1,12,42,45,8 + LTEXT "Reset",IDC_MULTIPLEYEAR,66,42,148,8 + PUSHBUTTON "Swap",IDC_MULTIPLESWAP,161,69,54,12 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ACTIVEINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 240 + TOPMARGIN, 7 + BOTTOMMARGIN, 136 + END + + IDD_TABGENERAL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 185 + TOPMARGIN, 7 + BOTTOMMARGIN, 90 + END + + IDD_TABDISKCONF, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 108 + END + + IDD_TABPARAM, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 191 + TOPMARGIN, 7 + BOTTOMMARGIN, 113 + END + + IDD_TABOPTION, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 232 + TOPMARGIN, 7 + BOTTOMMARGIN, 106 + END + + IDD_TABHELP, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 103 + END + + IDD_TABRUNTIME1, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 110 + END + + IDD_LOADING, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 23 + TOPMARGIN, 7 + BOTTOMMARGIN, 17 + END + + IDD_STATUS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 245 + TOPMARGIN, 7 + BOTTOMMARGIN, 15 + END + + IDD_TABXML, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 103 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Cursor +// + +IDC_CURSOR1 CURSOR "cursor1.cur" + + +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_TABGENERAL AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +#endif // Français (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Common.win32/ActiveDownloadWin32.cpp b/Common.win32/ActiveDownloadWin32.cpp new file mode 100644 index 0000000..44f9b70 --- /dev/null +++ b/Common.win32/ActiveDownloadWin32.cpp @@ -0,0 +1,256 @@ +#include "../common.win32/stdafx.h" +#include +#ifndef UNDER_CE +#include +#include +#endif +#include +#include "../common/cemulatorctrl.h" +#include "../Libraries/unzip101e/unzip.h" +#include "../kegs/src/sim65816.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +bool CDownload::GetFile( const char *url, const char *filename) +{ + #define HTTPBUFLEN 4096 // Size of HTTP Buffer... + char httpbuff[HTTPBUFLEN]; + +#if defined(ACTIVEGSKARATEKA) + if (!strncmp(url,"http://asset/",13)) + { + extern bool x_load_asset( const char *url, const char *filename); + return x_load_asset(url,filename); + + } +#endif + + CHttpConnection* pServer = NULL; + //CFile* remoteFile=NULL; + CHttpFile* remoteFile=NULL; + CFile* myfile = NULL; + int remotefileopen=0; + + TOSYSTEMCHAR(filename,filenamesys); + + if (filename) + { + outputInfo("*** Downloading %s to %s \n",url,filename); + showProgress(url,0); + } + + DWORD dwLength=0; + + TRY + { + + CString serverName; + CString serverFile; + DWORD dwServiceType; + INTERNET_PORT nPort; + DWORD dwRet; + + CInternetSession mysession(_T("ActiveGS")); + + TOSYSTEMCHAR(url,urlsys); + + if (!AfxParseURLEx(urlsys,dwServiceType,serverName,serverFile,nPort,CString(),CString(),ICU_NO_ENCODE)) + { + outputInfo("*** misformed url/filename : %s",url); + AfxThrowFileException(0,0,NULL); + return false; + } + + if (dwServiceType ==AFX_INET_SERVICE_FILE) + { + + outputInfo("*** not an http file : %s",url); + AfxThrowFileException(0,0,NULL); + return false; + } + + pServer = mysession.GetHttpConnection(serverName/*,INTERNET_FLAG_ASYNC*/, nPort); + + //outputInfo("*** GetHttpConnection %s\n",serverName); + + remoteFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, serverFile); + + //outputInfo("*** OpenRequest %s\n",serverFile); + + if (!remoteFile->SendRequest()) + { + outputInfo("*** cannot SendRequest : %s",serverName); + AfxThrowFileException(0,0,NULL); + return false; + } + remotefileopen=1; + + if (!remoteFile->QueryInfoStatusCode(dwRet)) + { + outputInfo("*** QueryInfoStatusCode failed (%d)\n",GetLastError()); + } + + if (dwRet != HTTP_STATUS_OK) + { + outputInfo("*** cannot query http serveur : %s (status=%d)\n",serverName,dwRet); + AfxThrowFileException(0,0,NULL); + return false; + } + + DWORD BufferLength=sizeof(dwLength); + + if (!remoteFile->QueryInfo( HTTP_QUERY_CONTENT_LENGTH|HTTP_QUERY_FLAG_NUMBER, &dwLength, &BufferLength, NULL)) + { + + // File does not exist ? + + if (GetLastError()!=ERROR_HTTP_HEADER_NOT_FOUND) + { + outputInfo("*** cannot query file size (%d) (%s || %s)\n",GetLastError(),serverName,serverFile); + AfxThrowFileException(0,0,NULL); + return false; + } + else + { + // ce message apparait dans le cas des stats : pas de header ? + if (filename) + outputInfo("*** cannot query file size ERROR_HTTP_HEADER_NOT_FOUND (%s || %s)\n",serverName,serverFile); + } + } + + if (filename) + myfile = new CFile(filenamesys, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary); + + int nbread=0; + int numbytes; + + + int pourcent=0; + + while (numbytes = remoteFile->Read(httpbuff, HTTPBUFLEN)) + { + nbread+=numbytes; + + if (myfile) + myfile->Write(httpbuff, numbytes); + + + if (dwLength) + pourcent = (nbread*100)/dwLength; + else + pourcent = (pourcent+5)%100; + + if (myfile) + { + showProgress(url,pourcent); //("downloading: %s (%3d%%)",getfile(url),pourcent); + + if (r_sim65816.should_emulator_terminate()) + { + outputInfo("Download aborted (%s)\n",url); + AfxThrowFileException(0,0,NULL); + } + } + } + + if (remoteFile) + { + remoteFile->Close(); + delete remoteFile; + remoteFile=NULL; + } + + if (pServer) + { + pServer->Close(); + delete pServer; + pServer=NULL; + } + + if (myfile) + { + myfile->Close(); + delete myfile; + myfile=NULL; + } + + } + + + CATCH_ALL(error) + { + int err = GetLastError(); + + showStatus("Cannot download %s\n",getfile(url)); + + if (myfile) { myfile->Close(); delete myfile; } + if (remoteFile && remotefileopen) { remoteFile->Close(); delete remoteFile; } + if (pServer) { pServer->Close(); delete pServer; } + + DeleteFile(filenamesys); + + return false; + } + END_CATCH_ALL; + + return true; +} + + + +bool CDownload::retrievePersistentZippedFile(const char* url,int _order,MyString& _path, MyString& _short) +{ + + MyString pdir = getPersistentDir(url); + CString dir(pdir); + + // enum + CString search; + search.Format(_T("%s\\%d_*.*"),dir.GetString(),_order); + + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + + hFind = FindFirstFile(search, &FindFileData); + + if (hFind == INVALID_HANDLE_VALUE) + return false; + + MyString found(FindFileData.cFileName); + _path.Format("%s\\%s",pdir,found.c_str()); + _short = found.Mid(2); + return true; + +} + + +void CDownload::createDirectory(const char *_dir) +{ + TOSYSTEMCHAR(_dir,dirsys); + CreateDirectory(dirsys,NULL); +} + +extern const char * activegsdownloaddir; +extern const char * activegspersistentdir; + +void CDownload::initPersistentSystemPath(MyString& path) +{ + + TCHAR pfraw[MAX_PATH]; + SHGetSpecialFolderPath(NULL,pfraw,CSIDL_PERSONAL,TRUE); + path = pfraw; +} + + +void CDownload::deleteFile(const char* _dir) +{ +#ifndef WINCE + remove(_dir); +#endif +} + +void CDownload::deleteDirectory(const char* _dir, int keepDir) +{ +} diff --git a/Common.win32/ActiveGS.aps b/Common.win32/ActiveGS.aps new file mode 100644 index 0000000..3307d4e Binary files /dev/null and b/Common.win32/ActiveGS.aps differ diff --git a/Common.win32/ActiveGS.rc b/Common.win32/ActiveGS.rc new file mode 100644 index 0000000..f653656 --- /dev/null +++ b/Common.win32/ActiveGS.rc @@ -0,0 +1,71 @@ +// Microsoft Visual C++ generated resource script. +// +#include "ActiveGS.rc.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "ActiveGS.rc.\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// WAVE +// + +IDR_SPINUPSEARCH1 WAVE "..\\Common\\sounds\\Spin Up Search 1.wav" +IDR_SPINUPSEARCH2 WAVE "..\\Common\\sounds\\Spin Up Search 2.wav" +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Common.win32/ActiveGS.rc.h b/Common.win32/ActiveGS.rc.h new file mode 100644 index 0000000..efb3f26 --- /dev/null +++ b/Common.win32/ActiveGS.rc.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ActiveGS.rc +// +#define IDR_SPINUPSEARCH1 101 +#define IDR_SPINUPSEARCH2 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Common.win32/ActiveHook.cpp b/Common.win32/ActiveHook.cpp new file mode 100644 index 0000000..eedcdcf --- /dev/null +++ b/Common.win32/ActiveHook.cpp @@ -0,0 +1,111 @@ +#include "stdafx.h" + +#include +#include "ZipArchive.h" +#include +#include "activetools.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +TCActiveBaseCollection CActiveBase::m_Collection; +HHOOK CActiveBase::m_hHook=NULL; + +LRESULT CALLBACK CActiveBase::GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + // If this is a keystrokes message, pass it to IsDialogMessage for tab + // and accelerator processing + LPMSG lpMsg = (LPMSG) lParam; + + if ( + (nCode >= 0) && + // PM_REMOVE == wParam && + ( + (lpMsg->message == WM_LBUTTONDOWN) || + (lpMsg->message == WM_MOUSEMOVE) || + (lpMsg->message == WM_LBUTTONUP) || + (lpMsg->message == WM_RBUTTONDOWN) || + (lpMsg->message == WM_MBUTTONDOWN) || + (lpMsg->message == WM_MBUTTONUP) || + (lpMsg->message == WM_RBUTTONUP) + ) + ) + + + { + CActiveBase* pObj; //, hActiveWindow = GetActiveWindow(); + TCActiveBaseCollection::iterator it =m_Collection.begin(); + + // check each window we manage to see if the message is meant for them + while (it != m_Collection.end()) + { + pObj = *it; + + // if (::IsWindow(hWnd)) + // ::IsDialogMessage(hWnd, lpMsg) + + { + pObj->m_ttip.RelayEvent(lpMsg); + /* + lpMsg->hwnd = NULL; + lpMsg->message = WM_NULL; + lpMsg->lParam = 0L; + lpMsg->wParam = 0; + */ + + // break; + } + + it++; + } + } + + // Passes the hook information to the next hook procedure in + // the current hook chain. + return ::CallNextHookEx(m_hHook, nCode, wParam, lParam); +} + +HRESULT CActiveBase::InstallHook() +{ + // make sure the hook is installed + if (m_hHook == NULL) + { + m_hHook = ::SetWindowsHookEx(WH_GETMESSAGE, + GetMessageProc, + AfxGetInstanceHandle(), + GetCurrentThreadId()); + + // is the hook set? + if (m_hHook == NULL) + { + return E_UNEXPECTED; + } + } + + // add the window to our list of managed windows + if (m_Collection.find(this) == m_Collection.end()) + m_Collection.insert(this); + + return S_OK; +} + +HRESULT CActiveBase::UninstallHook() +{ + HRESULT hr = S_OK; + + // was the window found? + if (m_Collection.erase(this) == 0) + return E_INVALIDARG; + + // is this the last window? if so, then uninstall the hook + if (m_Collection.size() == 0 && m_hHook) + { + if (!::UnhookWindowsHookEx(m_hHook)) + hr = HRESULT_FROM_WIN32(::GetLastError()); + + m_hHook = NULL; + } + + return hr; +} diff --git a/Common.win32/ActiveInfo.cpp b/Common.win32/ActiveInfo.cpp new file mode 100644 index 0000000..c9e5b54 --- /dev/null +++ b/Common.win32/ActiveInfo.cpp @@ -0,0 +1,440 @@ +// ActiveInfo.cpp : fichier d'implémentation +// + +#include "../common.win32/stdafx.h" +#include "activeinfo.h" +#include "tabgeneral.h" +#include "taboption.h" +#include "tabruntime.h" +#include "tabxml.h" +#include "diskediturl.h" +#include "activecommon.h" +#include "../common/svnversion.h" +#include "../kegs/src/moremem.h" +#include "../kegs/src/sim65816.h" + +// Boîte de dialogue CActiveInfo + +IMPLEMENT_DYNAMIC(CActiveInfo, CDialog) +CActiveInfo::CActiveInfo(CWnd* pParent /*=NULL*/) + : CDialog(CActiveInfo::IDD, pParent) +{ + pTabDialog = NULL; + uTimer=0; + +} + +CActiveInfo::~CActiveInfo() +{ + +} + +void CActiveInfo::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +// DDX_Control(pDX, IDC_ACTIVETAB, m_InfoTab); +// DDX_Control(pDX, IDC_URLOG, urlOG); +} + + +BEGIN_MESSAGE_MAP(CActiveInfo, CDialog) + ON_NOTIFY(TCN_SELCHANGE, IDC_ACTIVETAB, OnTcnSelchangeActivetab) + ON_WM_TIMER() + ON_WM_DESTROY() +END_MESSAGE_MAP() + +void CActiveInfo::freeTabDialog() +{ + if (pTabDialog) + { + if (uTimer) KillTimer(uTimer); + uTimer=0; + pTabDialog->DestroyWindow(); + delete pTabDialog; + pTabDialog=NULL; + + } +} + + +// Gestionnaires de messages CActiveInfo + +BOOL CActiveInfo::OnInitDialog() +{ + CDialog::OnInitDialog(); + + int i=0; + CTabCtrl* infoTab = (CTabCtrl*)GetDlgItem(IDC_ACTIVETAB); + if (infoTab) + { + //infoTab->InsertItem(i++,"Image") ; + infoTab->InsertItem(i++,"Disk Conf."); + infoTab->InsertItem(i++,"Runtime Info"); + infoTab->InsertItem(i++,"Options"); + infoTab->InsertItem(i++,"Variables"); + infoTab->InsertItem(i++,"Help"); + infoTab->InsertItem(i++,"Credits"); + OnTcnSelchangeActivetab(NULL,NULL); + } + else + outputInfo("getdlgitem failed: %d",GetLastError()); + /* + m_InfoTab.InsertItem(1,"Runtime Info"); + m_InfoTab.InsertItem(2,"Console"); + */ + + // change le titre + SetWindowText(ACTIVEGSVERSIONSTR); + //char s[1024]; + //GetWindowText(hWnd,s,1024); + CenterWindow(); + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION : les pages de propriétés OCX devraient retourner FALSE +} + +extern int g_zipgs_reg_c05a; + + +void CActiveInfo::OnTcnSelchangeActivetab(NMHDR *pNMHDR, LRESULT *pResult) +{ + CTabCtrl* infoTab = (CTabCtrl*)GetDlgItem(IDC_ACTIVETAB); + //static const int sel2id[]={ IDD_TABGENERAL,IDD_TABOPTION,IDD_TABRUNTIME1,IDD_TABDISKCONF,IDD_TABPARAM,IDD_TABHELP,0}; + static const int sel2id[]={ + // IDD_TABXML, + IDD_TABDISKCONF, + IDD_TABRUNTIME1, + IDD_TABOPTION, + IDD_TABPARAM, + IDD_TABHELP, + IDD_TABGENERAL, + 0}; + int sel = infoTab->GetCurSel(); + int id = sel2id[sel]; + + freeTabDialog(); + + + if (!id) return; + + CRect m_ClientRect,WindowRect; + + // Determine the size of the area for the contents + infoTab->GetClientRect(&m_ClientRect); + infoTab->AdjustRect(FALSE, &m_ClientRect); + + // Determine the offset within the view's client area + + infoTab->GetWindowRect(&WindowRect); + infoTab->ScreenToClient(WindowRect); + m_ClientRect.OffsetRect(WindowRect.left, WindowRect.top); + + + switch(id) + { + case IDD_TABGENERAL: + pTabDialog = new CTabGeneral(infoTab); + break; + case IDD_TABOPTION: + pTabDialog = new CTabOption(infoTab); + break; + case IDD_TABRUNTIME1: + pTabDialog = new CTabRuntime(infoTab); + break; + case IDD_TABDISKCONF: + pTabDialog = new CDiskEditURL(infoTab); + break; + case IDD_TABXML: + pTabDialog = new CTabXML(infoTab); + break; + default: + pTabDialog = new CTabActiveInfo(id,infoTab); + } + + pTabDialog->Create(id,infoTab); + + switch(id) + { + case IDD_TABDISKCONF: + { + + CComboBox *pCombo = (CComboBox*)pTabDialog->GetDlgItem(IDC_COMBOSLOT); + ASSERT(pCombo); + CDiskEditURL* pDialogDisk = (CDiskEditURL*)pTabDialog; + MyString s; + int id; + int err; + for(int slot=5;slot<=7;slot++) + { + int maxdrive=2; + if (slot==7) maxdrive=MAXSLOT7DRIVES; + for(int disk=1;disk<=maxdrive;disk++) + { + s.Format("S%dD%d",slot,disk); + id = slot*10+disk ; + err = pCombo->InsertString(-1,s.c_str()); + pCombo->SetItemData(err,id); + } + } + + int d = pDialogDisk->selectedItem ; + if (d==-1) d=0; + pCombo->SetCurSel(d); + pDialogDisk->OnCbnSelchangeComboslot(); + + CListCtrl *pList = (CListCtrl*)pTabDialog->GetDlgItem(IDC_SLOTLIST); + pList->InsertColumn(0,"Slot"); + pList->SetColumnWidth(0,40); + /* + pList->InsertColumn(1,"(E)"); + pList->SetColumnWidth(1,10); + */ + pList->InsertColumn(1,"Filename"); + pList->SetColumnWidth(1,100); + pList->InsertColumn(2,"Size"); + pList->SetColumnWidth(2,50); + pList->InsertColumn(3,"Prefix"); + pList->SetColumnWidth(3,120); + /* + pList->InsertColumn(5,"Path"); + pList->SetColumnWidth(5,1000); + */ + // updateRuntimeImages(); + } + break; + case IDD_TABRUNTIME1: + { + CSliderCtrl *pSlider = (CSliderCtrl*)pTabDialog->GetDlgItem(IDC_ZIPSLIDER); + pSlider->SetRange(0,15); + pSlider->SetPos(15-(g_moremem.g_zipgs_reg_c05a>>4)&0x0F); + updateRuntimeSpeed(); + uTimer = SetTimer(1, 1000, 0); + + break; + } + case IDD_TABPARAM: + { + CListCtrl *pList = (CListCtrl*)pTabDialog->GetDlgItem(IDC_PARAMLIST); + pList->InsertColumn(0,"Name"); + pList->SetColumnWidth(0,80); + pList->InsertColumn(1,"Value"); + pList->SetColumnWidth(1,160); + pList->InsertColumn(2,"Hex"); + pList->SetColumnWidth(2,80); + updateParams(); + break; + } + case IDD_TABOPTION: + { + + } + break; + case IDD_TABXML: + break; + + case IDD_TABGENERAL: + { + + CWnd *pText = (CWnd*)pTabDialog->GetDlgItem(IDC_BUILD); + if (pText) + { + const char * builddate = "Built on " ACTIVEGSDATE ; + pText->SetWindowText(builddate); + } + pText = (CWnd*)pTabDialog->GetDlgItem(IDC_VERSION); + if (pText) + { + const char * builddate = ACTIVEGSVERSIONSTRFULL; + pText->SetWindowText(builddate); + } + + + } + break; + default: + break; + } + + + refresh(); + pTabDialog->MoveWindow(m_ClientRect); + pTabDialog->ShowWindow(SW_SHOW); + + if (pResult) + *pResult = 0; + +} + +/* +void CActiveInfo::updateRuntimeImages() +{ + CListCtrl *pList = (CListCtrl*)pTabDialog->GetDlgItem(IDC_SLOTLIST); + if (!pList) return ; + + pList->DeleteAllItems(); + + int nbi=0; + for(int slot=5;slot<=7;slot++) + for(int disk=1;disk<=2;disk++) + for(int active=0;activegetLocalMultipleIMGInfo(slot,disk,info,active); + if (!ret) continue; + if (info.status==UNDEFINED || info.status ==NOTHING) continue; + + MyString str; + str.Format("S%dD%d",slot,disk); + if (ret==1) + str +="*"; + pList->InsertItem(nbi,str.c_str()); + // pList->SetItemData(nbi,(slot-5); + // pList->SetItemText(nbi,1,"e"); + + + MyString shortname (info.shortname.c_str()); + + MyString sizeStr; + if (info.size>1*1024*1024) + sizeStr.Format("%4dMb",info.size/(1024*1024)); + else + sizeStr.Format("%4dKo",info.size/1024); + + MyString prefix; + switch(info.status) + { + case MOUNTED: + prefix = info.prefix.c_str(); + break; + case EJECTED: + if (!info.filename.IsEmpty()) + prefix = "*EJECTED*"; + break; + case READY2MOUNT: + prefix = "*READY2MOUNT*"; + shortname = getfile(info.url); + break; + case DELAYEDMOUNT: + prefix = "*DELAYEDMOUNT*"; + shortname = getfile(info.url); + break; + case FAILED: + prefix ="*FAILED*"; + break; + } + pList->SetItemText(nbi,1,shortname.c_str()); + pList->SetItemText(nbi,2,sizeStr.c_str()); + pList->SetItemText(nbi,3,prefix.c_str()); + + // pList->SetItemText(nbi,5,info.name); + + nbi++; + + } + +} +*/ + + + +//extern char targetSpeed[256]; +extern char estimatedSpeed[256]; +//extern int g_speed_fast; + +void CActiveInfo::updateRuntimeSpeed() +{ + + CWnd* speedTab = (CWnd*)pTabDialog->GetDlgItem(IDC_SPEED); + if (!speedTab) return ; + + CString speed; // pour AppendFormat + speed.Format("%s MHz ",estimatedSpeed); + + if (g_sim65816.g_speed_fast) + { +// speed.AppendFormat("(%s MHz)",targetSpeed); + } + else + speed.Append("(1.0 MHz*)"); + + speedTab->SetWindowText(speed); + + CComboBox *pCombo = (CComboBox*)pTabDialog->GetDlgItem(IDC_SPEEDMODE); + if (pCombo && ( ((CTabRuntime*)pTabDialog)->enableSpeedChange)) + { + CEmulator* emu = CEmulator::theEmulator ; + int sel = pCombo->GetCurSel(); + int speed = pCombo->GetItemData(sel); + int sp = g_sim65816.get_limit_speed(); + if (sp != speed) + { + namevalue& nv = option.find(OPTION_SPEED); + int ispeed = nv.getOrder(g_sim65816.get_limit_speed()); + pCombo->SetCurSel(ispeed); + printf("resetting speed to %s (%d)\n",nv.getDescription(sp),sp); + } + } + + + CSliderCtrl *pSlider = (CSliderCtrl*)pTabDialog->GetDlgItem(IDC_ZIPSLIDER); + if (pSlider) + pSlider->SetPos(15-(g_moremem.g_zipgs_reg_c05a>>4)&0x0F); + +} + +void CActiveInfo::OnTimer(UINT_PTR nIDEvent) +{ + updateRuntimeSpeed(); + CDialog::OnTimer(nIDEvent); +} + +void CActiveInfo::updateParams() +{ + CListCtrl *pList = (CListCtrl*)pTabDialog->GetDlgItem(IDC_PARAMLIST); + if (!pList) return ; + pList->DeleteAllItems(); + CEmulator* emu=CEmulator::theEmulator; + int pos = 0; + for(int i=0;inbparams;i++) + { + pList->InsertItem(pos,emu->params[i].data.c_str()); + pList->SetItemText(pos,1,emu->params[i].value.c_str()); + MyString hex; + hex.Format("(%X)",emu->params[i].hex); + pList->SetItemText(pos,2,hex.c_str()); + pos++; + } + for(int i=0;iname; + pList->InsertItem(pos,name); + MyString desc; option.getStrValue(desc,(option_id)i); + pList->SetItemText(pos,1,desc.c_str()); + if (option.options[i].def->convertTableInt) + { + MyString hex; + hex.Format("(%d)",option.options[i].intvalue); + pList->SetItemText(pos,2,hex.c_str()); + + } + pos++; + } +} + +void CActiveInfo::OnDestroy() +{ + CDialog::OnDestroy(); + + // TODO : ajoutez ici le code de votre gestionnaire de messages + freeTabDialog(); +} + +void CActiveInfo::refresh() +{ + if (pTabDialog) + pTabDialog->refresh(); + +} + + + diff --git a/Common.win32/ActiveInfo.h b/Common.win32/ActiveInfo.h new file mode 100644 index 0000000..d2e70f1 --- /dev/null +++ b/Common.win32/ActiveInfo.h @@ -0,0 +1,47 @@ +#pragma once +#include "afxcmn.h" +#include "hyperlink.h" +#include "activecommonres.h" + +class CTabActiveInfo : public CDialog +{ +public: + CTabActiveInfo(UINT IDD, CWnd* pParent /*=NULL*/) + : CDialog(IDD, pParent) {} + + + virtual void refresh() {} ; +}; + +// Boîte de dialogue CActiveInfo + +class CActiveInfo : public CDialog +{ + DECLARE_DYNAMIC(CActiveInfo) + +public: + CActiveInfo(CWnd* pParent = NULL); // constructeur standard + virtual ~CActiveInfo(); + +// Données de boîte de dialogue + enum { IDD = IDD_ACTIVEINFO }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge DDX/DDV + + DECLARE_MESSAGE_MAP() +public: +// CActiveTab m_InfoTab; + CTabActiveInfo* pTabDialog; + UINT uTimer; + virtual BOOL OnInitDialog(); + afx_msg void OnTcnSelchangeActivetab(NMHDR *pNMHDR, LRESULT *pResult); + void updateRuntimeSpeed(); +// void updateRuntimeImages(); + void updateParams(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + void freeTabDialog(); + afx_msg void OnDestroy(); + + void refresh(); +}; diff --git a/Common.win32/ActiveStatus.cpp b/Common.win32/ActiveStatus.cpp new file mode 100644 index 0000000..782e853 --- /dev/null +++ b/Common.win32/ActiveStatus.cpp @@ -0,0 +1,49 @@ +// ActiveStatus.cpp : implementation file +// + +#include "../common.win32/stdafx.h" +//#include "ActiveGS.h" +#include "ActiveStatus.h" +//#include "ActiveGSCtrl.h" + +// CActiveStatus dialog + +IMPLEMENT_DYNAMIC(CActiveStatus, CDialog) +CActiveStatus::CActiveStatus(CWnd* pParent /*=NULL*/) + : CDialog(CActiveStatus::IDD, pParent) +{ + TimerID = NULL; +} + +CActiveStatus::~CActiveStatus() +{ + +} + +void CActiveStatus::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CActiveStatus, CDialog) + ON_WM_TIMER() + ON_WM_DESTROY() +END_MESSAGE_MAP() + + +// CActiveStatus message handlers + +void CActiveStatus::OnTimer(UINT_PTR nIDEvent) +{ + ShowWindow(SW_HIDE); + CDialog::OnTimer(nIDEvent); + TimerID = NULL; +} + +void CActiveStatus::OnDestroy() +{ + if (TimerID) + KillTimer(TimerID); + TimerID = NULL; +} diff --git a/Common.win32/ActiveStatus.h b/Common.win32/ActiveStatus.h new file mode 100644 index 0000000..40a83bc --- /dev/null +++ b/Common.win32/ActiveStatus.h @@ -0,0 +1,26 @@ +#pragma once + +//#include "activegsresrc.h" +#include "activecommonres.h" +// CActiveStatus dialog + +class CActiveStatus : public CDialog +{ + DECLARE_DYNAMIC(CActiveStatus) + +public: + CActiveStatus(CWnd* pParent = NULL); // standard constructor + virtual ~CActiveStatus(); + UINT_PTR TimerID; + +// Dialog Data + enum { IDD = IDD_STATUS }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnDestroy(); +}; diff --git a/Common.win32/ChildView.cpp b/Common.win32/ChildView.cpp new file mode 100644 index 0000000..315e5cf --- /dev/null +++ b/Common.win32/ChildView.cpp @@ -0,0 +1,298 @@ + +// ChildView.cpp : implementation of the CChildView class +// + +#include "../Common.win32/stdafx.h" +#include "ChildView.h" + + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CChildView + +CChildView::CChildView() +{ + pEmulatorCtrl = NULL; + parent = NULL; + //pConfig = NULL; +} + +CChildView::~CChildView() +{ +} + + +BEGIN_MESSAGE_MAP(CChildView, CWnd) + ON_WM_PAINT() + ON_WM_CREATE() + ON_WM_DESTROY() + ON_WM_SETFOCUS() + ON_WM_SETTINGCHANGE() +#ifndef UNDER_CE + ON_WM_MOUSEACTIVATE() +#endif + ON_WM_SIZE() +// ON_WM_ERASEBACKGND() +END_MESSAGE_MAP() + +// CChildView message handlers + +BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) +{ + OutputDebugString("PreCreateWindow"); + + if (!CWnd::PreCreateWindow(cs)) + return FALSE; +/* cs.dwExStyle |= WS_EX_CLIENTEDGE; + cs.style &= ~WS_BORDER; +*/ + cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, + ::LoadCursor(NULL, IDC_SIZEALL /*IDC_ARROW*/), NULL /*reinterpret_cast(COLOR_WINDOW+1)*/, NULL); + return TRUE; +} + +int CChildView::CreateEmulatorWindow(CWnd* _w) +{ + /* + strMyClass = AfxRegisterWndClass( + CS_VREDRAW | CS_HREDRAW, + ::LoadCursor(NULL, IDC_ARROW), + (HBRUSH) ::GetStockObject(WHITE_BRUSH), + ::LoadIcon(NULL, IDI_APPLICATION)); +*/ + + outputInfo("CreateEmulatorWindow w:%X this:%X pEmulator:%X theEmulator:%X\n",_w,this,pEmulatorCtrl,CEmulator::theEmulator); + CRect rect; + parent = _w; + _w->GetClientRect(&rect); + outputInfo("Rect width:%d, height:%d\n",rect.Width(),rect.Height()); + + BOOL (__thiscall CWnd::* p )(LPCTSTR,LPCTSTR,DWORD,const RECT &,CWnd *,UINT,CCreateContext *) = &CChildView::Create; + outputInfo("p=%X",p); + + int r = Create(NULL, _T("activegs"), WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN/*AFX_WS_DEFAULT_VIEW*/, + rect,_w + // CRect(rect0, 0, 704, 460), +// CRect(0, 0, 1000, 600), +, AFX_IDW_PANE_FIRST, NULL); + SetFocus(); + return r; +} + +extern int g_window_width; +extern int g_window_height; + +void CChildView::resize() +{ + + extern void window_needs_full_refresh(); + + if (!parent) return ; + RECT rcClient, rcWindow; + RECT localClient, localWindow; + POINT ptDiff; + parent->GetClientRect( &rcClient); + parent->GetWindowRect( &rcWindow); +GetClientRect( &localClient); +GetWindowRect( &localWindow); + +#ifdef VIDEO_SINGLEVLINE + localClient.bottom *=2; +#endif + ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right; + ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom; + int nWidth = rcClient.right - rcClient.left; + int nHeight = rcClient.bottom - rcClient.top; + MoveWindow(0/*rcWindow.left*/, 0/*rcWindow.top*/, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE); + + window_needs_full_refresh(); + +} + +int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + outputInfo("OnCreate CChildView:%X CurrentEmulator:%X\n",this,CEmulator::theEmulator); + + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + +#ifdef UNDER_CE + DEVMODE mode; + memset(&mode,0,sizeof(DEVMODE)); + mode.dmSize = sizeof(DEVMODE); + + mode.dmFields=DM_DISPLAYORIENTATION; + mode.dmDisplayOrientation = DMDO_90; + + LONG Err= ChangeDisplaySettingsEx(NULL,&mode,NULL,0,NULL); + if (Err!=DISP_CHANGE_SUCCESSFUL) + outputInfo("failed to change display\n"); + #endif + + if (CEmulator::theEmulator) + { + outputInfo("Emulator was running: kill it (%X)\n",CEmulator::theEmulator); + CEmulator::theEmulator->terminateEmulator(); + delete CEmulator::theEmulator; + } + resize(); + + pEmulatorCtrl = new CEmulatorWin32((CEmulator**)&this->pEmulatorCtrl); + //id = pEmulatorCtrl->id; + //outputInfo("new emulator (%X)(%X)(%d)\n",this,pEmulatorCtrl,CEmulator::theEmulator->id); + hInst = lpCreateStruct->hInstance; + CEmulatorConfig* pConfig = &config; + +// g_download.initPersistentPath(); + + pEmulatorCtrl->initWindow(m_hWnd,hInst); + pEmulatorCtrl->setConfig(pConfig); + pEmulatorCtrl->launchEmulator(); + + return 0; +} + +void CChildView::OnPaint() +{ + + if ( pEmulatorCtrl && pEmulatorCtrl == CEmulator::theEmulator ) + { + + CWnd::OnPaint(); + } + else + { + PAINTSTRUCT ps; + CDC* cdc = BeginPaint(&ps); + RECT r; + GetClientRect(&r); + CBrush brush; + brush.CreateSolidBrush(RGB(36,34,244)); + cdc->FillRect(&r,&brush); + +#ifdef UNDER_CE + cdc->DrawText( _T("PAUSED"), -1, &r, DT_CENTER|DT_SINGLELINE|DT_VCENTER); +#else + cdc->SetTextColor(RGB(255,255,255)); + cdc->SetBkColor(RGB(36,34,244)); + + int l = (r.bottom - r.top)/2 - 20; + + const char* line1="The emulator has been closed as another instance is running."; + cdc->TextOut(100 ,l, line1,strlen(line1)); + const char line2[]="Refresh this window to re-activate the emulator."; + cdc->TextOut(100 ,l+20, line2,strlen(line2)); +#endif + EndPaint(&ps); + } +} + +void CChildView::OnDestroy() +{ + outputInfo("OnDestroy CChildView:%X theEmulator:%X\n",this,pEmulatorCtrl); + + if (pEmulatorCtrl) + { + // ASSERT(CEmulator::theEmulator == pEmulatorCtrl); + if (CEmulator::theEmulator == pEmulatorCtrl) + { + pEmulatorCtrl->terminateEmulator(); + delete pEmulatorCtrl; + pEmulatorCtrl = NULL; + } + else + outputInfo("ERR:OnDestroy but pEMulatorCtrl not owned by us ... CChildView:%X theEmulator:%X\n",this,pEmulatorCtrl); + + } +} + +LRESULT CChildView::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + + +#if 0 + switch(message) + { + + case WM_KEYUP: + outputInfo("DefWindowProc: WM_KEYUP: %X\n",wParam); + break; + case WM_KEYDOWN: + outputInfo("DefWindowProc: WM_KEYDOWN: %X\n",wParam); + break; + default: + break; + } +#endif + if (CEmulator::theEmulator && pEmulatorCtrl == CEmulator::theEmulator) + return pEmulatorCtrl->windowProc(message,wParam,lParam); + else + return CWnd::DefWindowProc(message, wParam, lParam); + +} + + BOOL CChildView::PreTranslateMessage(MSG* pMsg) +{ + switch(pMsg->message) + { + case WM_KEYDOWN: + case WM_KEYUP: + case WM_SYSKEYUP: + case WM_SYSKEYDOWN: + + if (pEmulatorCtrl && pEmulatorCtrl == CEmulator::theEmulator) + pEmulatorCtrl->windowProc(pMsg->message,pMsg->wParam,pMsg->lParam); + return 1; + /* + case WM_LBUTTONDOWN: + outputInfo("WM_LBUTTONDOWN\n"); + break; + case WM_LBUTTONUP: + outputInfo("WM_LBUTTONUP\n"); + break; + */ + default: + break; + } + + return 0; // to dispatch messag +} + + void CChildView::OnSetFocus(CWnd* pOldWnd ) + { + // outputInfo("OnSetFocus\n"); + CWnd::OnSetFocus(pOldWnd); + } + + CWnd* CChildView::SetFocus() + { + // outputInfo("SetFocus\n"); + CWnd* w = CWnd::SetFocus(); + return w; + } + +#ifndef UNDER_CE + int CChildView::OnMouseActivate(CWnd* pDesktopWnd,UINT nHitTest,UINT message ) + { +// outputInfo("child OnMouseActivate\n"); + + // Was used in the .OCX version +// OnActivateInPlace(TRUE, NULL); // OnActivateInPlace() is an undocumented function + return CWnd::OnMouseActivate(pDesktopWnd,nHitTest, message); +// return MA_ACTIVATEANDEAT ; + } +#endif + +BOOL CChildView::OnEraseBkgnd(CDC* pDC) + { + return 1; + } + +void CChildView::OnSettingChange(UINT uFlags,LPCTSTR lpszSection) + { + outputInfo("OnSettingChange"); + } + diff --git a/Common.win32/ChildView.h b/Common.win32/ChildView.h new file mode 100644 index 0000000..09c3fa1 --- /dev/null +++ b/Common.win32/ChildView.h @@ -0,0 +1,53 @@ + +// ChildView.h : interface of the CChildView class +// + + +#pragma once +#include "../common.win32/activecommon.h" +#include "../common/ki.h" + + +// CChildView window + +class CChildView : public CWnd +{ +// Construction +public: + CChildView(); + +// Attributes +public: + CEmulatorWin32* pEmulatorCtrl; + int id; + HINSTANCE hInst; + CEmulatorConfig config; + CWnd* parent; +// Operations +public: + int CreateEmulatorWindow(CWnd* _w); +// Overrides +protected: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CChildView(); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSetFocus(CWnd* pOldWnd ); + afx_msg void OnDestroy(); + afx_msg int OnMouseActivate(CWnd* pDesktopWnd,UINT nHitTest,UINT message ); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnSettingChange(UINT uFlags,LPCTSTR lpszSection); + + virtual CWnd*SetFocus(); + virtual BOOL PreTranslateMessage(MSG* pMsg); + void resize(); + + // Generated message map functions +//protected: + afx_msg void OnPaint(); + DECLARE_MESSAGE_MAP() + virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); +}; + diff --git a/Common.win32/DiskEditURL.cpp b/Common.win32/DiskEditURL.cpp new file mode 100644 index 0000000..7059c4f --- /dev/null +++ b/Common.win32/DiskEditURL.cpp @@ -0,0 +1,324 @@ +// DiskEditURL.cpp : implementation file +// + +#include "../Common.win32/stdafx.h" +//#include "ActiveGSApp.h" +#include "activecommon.h" +#include "DiskEditURL.h" +#include + +// CDiskEditURL dialog + +IMPLEMENT_DYNAMIC(CDiskEditURL, CDialog) + +CDiskEditURL::CDiskEditURL(CWnd* pParent /*=NULL*/) + : CTabActiveInfo(CDiskEditURL::IDD, pParent) +{ + selectedItem=0; +} + +CDiskEditURL::~CDiskEditURL() +{ + +} + +BOOL CDiskEditURL::OnInitDialog() +{ + selectedItem = 0; + CDialog::OnInitDialog(); + /* + DragAcceptFiles(TRUE); + CDialog* edit = (CDialog*)GetDlgItem(IDC_EDITURL); + ASSERT(edit); + edit->DragAcceptFiles(TRUE); + */ + return TRUE; +} + +void CDiskEditURL::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} +void CDiskEditURL::OnDropFiles() +{ + /* + HDROP hDrop = (HDROP)wParam; + char filename[MAX_PATH]; + DragQueryFile(hDrop, // Struture Identifier + + 0, // -1 to Drop more than one file or ( integer 0 to max ) + + // to drop selected No of files + + filename,// Droped File Name + + MAX_PATH); // Max char + */ +} + + +BEGIN_MESSAGE_MAP(CDiskEditURL, CDialog) + // ON_MESSAGE(WM_DROPFILES,OnDropFiles)// Message Handler for Drang and Drop + ON_CONTROL(WM_DROPFILES,IDC_EDITURL,OnDropFiles) +// ON_CONTROL(EN_UPDATE,IDC_EDITURL,OnDropFiles) +ON_BN_CLICKED(IDC_MOUNTBUTTON, &CDiskEditURL::OnBnClickedMountbutton) +ON_BN_CLICKED(IDC_EJECT, &CDiskEditURL::OnBnClickedEject) +ON_BN_CLICKED(IDC_RELOAD, &CDiskEditURL::OnBnClickedReload) +ON_NOTIFY(LVN_ITEMACTIVATE, IDC_SLOTLIST, &CDiskEditURL::OnLvnItemActivateSlotlist) +ON_NOTIFY(HDN_ITEMCLICK, 0, &CDiskEditURL::OnHdnItemclickSlotlist) +ON_BN_CLICKED(IDC_REBOOT5, &CDiskEditURL::OnBnClickedReboot5) +ON_BN_CLICKED(IDC_REBOOT6, &CDiskEditURL::OnBnClickedReboot6) +ON_BN_CLICKED(IDC_REBOOT7, &CDiskEditURL::OnBnClickedReboot7) +ON_BN_CLICKED(IDC_MOUNTBUTTON, &CDiskEditURL::OnBnClickedMountbutton) +ON_CBN_SELCHANGE(IDC_COMBOSLOT, &CDiskEditURL::OnCbnSelchangeComboslot) +ON_BN_CLICKED(IDC_FILESELECT, &CDiskEditURL::OnBnClickedFileselect) +ON_BN_CLICKED(IDC_SWAP, &CDiskEditURL::OnBnClickedSwap) +END_MESSAGE_MAP() + + +// CDiskEditURL message handlers + +void CDiskEditURL::OnBnClickedMountbutton() +{ + // TODO: Add your control notification handler code here + CDialog* edit = (CDialog*)GetDlgItem(IDC_EDITURL); + char path[MAX_PATH]; + int l = Edit_GetLine(edit->m_hWnd,0,path,MAX_PATH); + path[l]=0; + + int slot,drive; + if (getCurrentSlotAndDrive(slot,drive)) + { + CEmulator::theEmulator->config->setSlot(slot,drive,path,REPLACECURRENT); + } +} +void CDiskEditURL::OnBnClickedEject() +{ + + int slot,drive; + if (!getCurrentSlotAndDrive(slot,drive)) return ; + CEmulator::theEmulator->ejectDisk(slot,drive); + +} + +void CDiskEditURL::OnBnClickedReload() +{ + int slot,drive; + if (!getCurrentSlotAndDrive(slot,drive)) return ; + CEmulator::theEmulator->reloadDisk(slot,drive); +} + +void CDiskEditURL::OnLvnItemActivateSlotlist(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMITEMACTIVATE pNMIA = reinterpret_cast(pNMHDR); + // TODO: Add your control notification handler code here + /* + CListCtrl *pList = (CListCtrl*)GetDlgItem(IDC_SLOTLIST); + ASSERT(pList); + POSITION p = pList->GetFirstSelectedItemPosition(); + if (!p) return ; + int i =pList->GetNextSelectedItem(p); + selectedItem = pList->GetItemData(i); + refreshItem(); + */ + *pResult = 0; +} + +int CDiskEditURL::getCurrentSlotAndDrive(int& slot, int &drive) +{ + if (selectedItem==-1) return 0; + CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBOSLOT); + int data = pCombo->GetItemData(selectedItem); + slot = data / 10; + drive = data %10; + return 1; +} + +void CDiskEditURL::refresh() +{ + + CListCtrl *pList = (CListCtrl*)GetDlgItem(IDC_SLOTLIST); + if (pList) + { + pList->DeleteAllItems(); + int nbi=0; + for(int slot=5;slot<=7;slot++) + { + int maxdrive=2; + if (slot==7) maxdrive=MAXSLOT7DRIVES; + for(int disk=1;disk<=maxdrive;disk++) + for(int active=0;activegetLocalMultipleIMGInfo(slot,disk,info,active); + if (!ret) continue; + if (info.status==UNDEFINED || info.status ==NOTHING) continue; + + MyString str; + str.Format("S%dD%d",slot,disk); + if (ret==1) + str +="*"; + pList->InsertItem(nbi,str.c_str()); + // pList->SetItemData(nbi,(slot-5); + // pList->SetItemText(nbi,1,"e"); + + + MyString shortname (info.shortname.c_str()); + + MyString sizeStr; + if (info.size>1*1024*1024) + sizeStr.Format(_T("%4dMb"),info.size/(1024*1024)); + else + sizeStr.Format(_T("%4dKo"),info.size/1024); + + MyString prefix; + switch(info.status) + { + case MOUNTED: + prefix = info.prefix.c_str(); + break; + case EJECTED: + if (!info.filename.IsEmpty()) + prefix = "*EJECTED*"; + break; + case READY2MOUNT: + prefix = "*READY2MOUNT*"; + shortname = getfile(info.url); + break; + case DELAYEDMOUNT: + prefix = "*DELAYEDMOUNT*"; + shortname = getfile(info.url); + break; + case FAILED: + prefix ="*FAILED*"; + break; + } + pList->SetItemText(nbi,1,shortname.c_str()); + pList->SetItemText(nbi,2,sizeStr.c_str()); + pList->SetItemText(nbi,3,prefix.c_str()); + + // pList->SetItemText(nbi,5,info.name); + + nbi++; + + } + } + } + +// int slot = selectedItem; + BOOL beject = TRUE; + BOOL breload = TRUE; + BOOL bmount = TRUE; + BOOL bSwap = FALSE; + + int slot,drive; + if (getCurrentSlotAndDrive(slot,drive)) + { + const CSlotInfo& info = CEmulator::theEmulator->getLocalIMGInfo(slot,drive); + SetDlgItemText(IDC_EDITURL,info.url); + switch(info.status) + { + case UNDEFINED: + beject=FALSE; + breload=FALSE; + break; + case FAILED: + beject=FALSE; + breload=TRUE; + break; + case EJECTED: + beject=FALSE; + breload=TRUE; + break; + case READY2MOUNT: + case DELAYEDMOUNT: + beject=TRUE; + breload=FALSE; + break; + case MOUNTED: + beject=TRUE; + breload=FALSE; + } + + int sw = CEmulator::theEmulator->getSmartSwap(); + if ( ((sw/10) == slot) && ( (sw%10) == drive ) ) // OG A UNIFIER!!!! + bSwap = TRUE; + } + else + { + beject=FALSE; + breload=FALSE; + } + + ::EnableWindow(GetDlgItem(IDC_EJECT)->m_hWnd,beject); + ::EnableWindow(GetDlgItem(IDC_RELOAD)->m_hWnd,breload); + ::EnableWindow(GetDlgItem(IDC_MOUNTBUTTON)->m_hWnd,bmount); + ::EnableWindow(GetDlgItem(IDC_SWAP)->m_hWnd,bSwap); +} + + +void CDiskEditURL::OnHdnItemclickSlotlist(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMHEADER phdr = reinterpret_cast(pNMHDR); + // TODO: Add your control notification handler code here + *pResult = 0; +} + +void CDiskEditURL::OnBnClickedReboot5() +{ + CEmulator::theEmulator->onBootSlotChanged(5); +} + +void CDiskEditURL::OnBnClickedReboot6() +{ + CEmulator::theEmulator->onBootSlotChanged(6); +} + +void CDiskEditURL::OnBnClickedReboot7() +{ + CEmulator::theEmulator->onBootSlotChanged(7);} + + + +void CDiskEditURL::OnCbnSelchangeComboslot() +{ + // TODO: Add your control notification handler code here + CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBOSLOT); + selectedItem = pCombo->GetCurSel(); + refresh(); +// SetDlgItemText(IDC_EDITURL,l_strFileName); +} + +void CDiskEditURL::OnBnClickedFileselect() +{ + +// CFileDialog l_SampleDlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"2MG Images (*.img)|*.2mg|II Images (*.dsk)|*.dsk|II Images (*.nib)|*.nib|Archives (*.zip)|*.zip||"); + CFileDialog l_SampleDlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"Disk Image (*.img;*.dsk;*.nib;*.bin;*.zip)||"); + + int iRet = l_SampleDlg.DoModal(); + CString l_strFileName; + l_strFileName = l_SampleDlg.GetPathName(); + + if(iRet == IDOK) + { + // CDialog* edit = (CDialog*)GetDlgItem(IDC_EDITURL); + SetDlgItemText(IDC_EDITURL,l_strFileName); + OnBnClickedMountbutton(); + // MessageBox(l_strFileName); + // MessageBox(l_strFileName); + + } + /* + else + MessageBox("No File Selected!"); + */ +} + +void CDiskEditURL::OnBnClickedSwap() +{ +// int slot = selectedItem; + int slot,drive; + if (!getCurrentSlotAndDrive(slot,drive)) return ; + CEmulator::theEmulator->swapDisk(slot,drive); +} diff --git a/Common.win32/DiskEditURL.h b/Common.win32/DiskEditURL.h new file mode 100644 index 0000000..a87e6d4 --- /dev/null +++ b/Common.win32/DiskEditURL.h @@ -0,0 +1,37 @@ +#pragma once + + +// CDiskEditURL dialog + +class CDiskEditURL : public CTabActiveInfo +{ + DECLARE_DYNAMIC(CDiskEditURL) + +public: + CDiskEditURL(CWnd* pParent = NULL); // standard constructor + virtual ~CDiskEditURL(); + int selectedItem; +// Dialog Data + enum { IDD = IDD_TABDISKCONF }; + virtual void refresh(); +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + void OnDropFiles(); + + BOOL OnInitDialog(); + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedMountbutton(); + afx_msg void OnBnClickedEject(); + afx_msg void OnBnClickedReload(); + afx_msg void OnLvnItemActivateSlotlist(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnHdnItemclickSlotlist(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnBnClickedReboot5(); + afx_msg void OnBnClickedReboot6(); + afx_msg void OnBnClickedReboot7(); +// afx_msg void OnBnClickedMountbutton(); + afx_msg void OnCbnSelchangeComboslot(); + afx_msg void OnBnClickedFileselect(); + afx_msg void OnBnClickedSwap(); + int getCurrentSlotAndDrive(int& slot, int &drive); +}; diff --git a/Common.win32/HyperLink.cpp b/Common.win32/HyperLink.cpp new file mode 100644 index 0000000..3b7be37 --- /dev/null +++ b/Common.win32/HyperLink.cpp @@ -0,0 +1,498 @@ +// HyperLink.cpp : implementation file +// +// HyperLink static control. Will open the default browser with the given URL +// when the user clicks on the link. +// +// Copyright (C) 1997 - 1999 Chris Maunder +// All rights reserved. May not be sold for profit. +// +// Thanks to Pål K. Tønder for auto-size and window caption changes. +// +// "GotoURL" function by Stuart Patterson +// As seen in the August, 1997 Windows Developer's Journal. +// Copyright 1997 by Miller Freeman, Inc. All rights reserved. +// Modified by Chris Maunder to use TCHARs instead of chars. +// +// "Default hand cursor" from Paul DiLascia's Jan 1998 MSJ article. +// +// 2/29/00 -- P. Shaffer standard font mod. + +#include "../Common.win32/stdafx.h" +#include "HyperLink.h" + +#include "atlconv.h" // for Unicode conversion - requires #include // MFC OLE automation classes + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define TOOLTIP_ID 1 + +///////////////////////////////////////////////////////////////////////////// +// CHyperLink + +CHyperLink::CHyperLink() +{ + m_hLinkCursor = NULL; // No cursor as yet + m_crLinkColour = RGB( 0, 0, 238); // Blue + // m_crVisitedColour = RGB( 85, 26, 139); // Purple + m_crVisitedColour = RGB( 0, 0, 238); // Purple + m_crHoverColour = RGB(255, 0, 0); // Red + m_bOverControl = FALSE; // Cursor not yet over control + m_bVisited = FALSE; // Hasn't been visited yet. + m_nUnderline = ulHover; // Underline the link? + m_bAdjustToFit = TRUE; // Resize the window to fit the text? + m_strURL.Empty(); + m_nTimerID = 100; +} + +CHyperLink::~CHyperLink() +{ + m_UnderlineFont.DeleteObject(); +} + +///////////////////////////////////////////////////////////////////////////// +// CHyperLink overrides + +BOOL CHyperLink::DestroyWindow() +{ + KillTimer(m_nTimerID); + + return CStatic::DestroyWindow(); +} + +BOOL CHyperLink::PreTranslateMessage(MSG* pMsg) +{ + m_ToolTip.RelayEvent(pMsg); + return CStatic::PreTranslateMessage(pMsg); +} + + +void CHyperLink::PreSubclassWindow() +{ + // We want to get mouse clicks via STN_CLICKED + DWORD dwStyle = GetStyle(); + ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY); + + // Set the URL as the window text + if (m_strURL.IsEmpty()) + GetWindowText(m_strURL); + + // Check that the window text isn't empty. If it is, set it as the URL. + CString strWndText; + GetWindowText(strWndText); + if (strWndText.IsEmpty()) + { + ASSERT(!m_strURL.IsEmpty()); // Window and URL both NULL. DUH! + SetWindowText(m_strURL); + } + + CFont* pFont = GetFont(); + if (!pFont) + { + HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + if (hFont == NULL) + hFont = (HFONT) GetStockObject(ANSI_VAR_FONT); + if (hFont) + pFont = CFont::FromHandle(hFont); + } + ASSERT(pFont->GetSafeHandle()); + + // Create the underline font + LOGFONT lf; + pFont->GetLogFont(&lf); + m_StdFont.CreateFontIndirect(&lf); + lf.lfUnderline = (BYTE) TRUE; + m_UnderlineFont.CreateFontIndirect(&lf); + + PositionWindow(); // Adjust size of window to fit URL if necessary + SetDefaultCursor(); // Try and load up a "hand" cursor + SetUnderline(ulAlways); + + // Create the tooltip + CRect rect; + GetClientRect(rect); + m_ToolTip.Create(this); + m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID); + + CStatic::PreSubclassWindow(); +} + +BEGIN_MESSAGE_MAP(CHyperLink, CStatic) + //{{AFX_MSG_MAP(CHyperLink) + ON_WM_CTLCOLOR_REFLECT() + ON_WM_SETCURSOR() + ON_WM_MOUSEMOVE() + ON_WM_TIMER() + ON_CONTROL_REFLECT(STN_CLICKED, OnClicked) + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CHyperLink message handlers + +void CHyperLink::OnClicked() +{ + m_bOverControl = FALSE; + int result = (int)GotoURL(m_strURL, SW_SHOW); + m_bVisited = (result > HINSTANCE_ERROR); + if (!m_bVisited) + { + MessageBeep(MB_ICONEXCLAMATION); // Unable to follow link + ReportError(result); + } + else + SetVisited(); // Repaint to show visited colour +} + +HBRUSH CHyperLink::CtlColor(CDC* pDC, UINT nCtlColor) +{ + ASSERT(nCtlColor == CTLCOLOR_STATIC); + + if (m_bOverControl) + pDC->SetTextColor(m_crHoverColour); + else if (m_bVisited) + pDC->SetTextColor(m_crVisitedColour); + else + pDC->SetTextColor(m_crLinkColour); + + // transparent text. + pDC->SetBkMode(TRANSPARENT); + return (HBRUSH)GetStockObject(NULL_BRUSH); +} + +void CHyperLink::OnMouseMove(UINT nFlags, CPoint point) +{ + if (!m_bOverControl) // Cursor has just moved over control + { + m_bOverControl = TRUE; + + if (m_nUnderline == ulHover) + SetFont(&m_UnderlineFont); + Invalidate(); + + SetTimer(m_nTimerID, 100, NULL); + } + CStatic::OnMouseMove(nFlags, point); +} + +void CHyperLink::OnTimer(UINT_PTR nIDEvent) +{ + CPoint p(GetMessagePos()); + ScreenToClient(&p); + + CRect rect; + GetClientRect(rect); + if (!rect.PtInRect(p)) + { + m_bOverControl = FALSE; + KillTimer(m_nTimerID); + + if (m_nUnderline != ulAlways) + SetFont(&m_StdFont); + rect.bottom+=10; + InvalidateRect(rect); + } + + CStatic::OnTimer(nIDEvent); +} + +BOOL CHyperLink::OnSetCursor(CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/) +{ + if (m_hLinkCursor) + { + ::SetCursor(m_hLinkCursor); + return TRUE; + } + return FALSE; +} + +BOOL CHyperLink::OnEraseBkgnd(CDC* pDC) +{ + CRect rect; + GetClientRect(rect); + pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE)); + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CHyperLink operations + +void CHyperLink::SetURL(CString strURL) +{ + m_strURL = strURL; + + if (::IsWindow(GetSafeHwnd())) { + PositionWindow(); + m_ToolTip.UpdateTipText(strURL, this, TOOLTIP_ID); + } +} + +CString CHyperLink::GetURL() const +{ + return m_strURL; +} + +void CHyperLink::SetColours(COLORREF crLinkColour, COLORREF crVisitedColour, + COLORREF crHoverColour /* = -1 */) +{ + m_crLinkColour = crLinkColour; + m_crVisitedColour = crVisitedColour; + + if (crHoverColour == -1) + m_crHoverColour = ::GetSysColor(COLOR_HIGHLIGHT); + else + m_crHoverColour = crHoverColour; + + if (::IsWindow(m_hWnd)) + Invalidate(); +} + +COLORREF CHyperLink::GetLinkColour() const +{ + return m_crLinkColour; +} + +COLORREF CHyperLink::GetVisitedColour() const +{ + return m_crVisitedColour; +} + +COLORREF CHyperLink::GetHoverColour() const +{ + return m_crHoverColour; +} + +void CHyperLink::SetVisited(BOOL bVisited /* = TRUE */) +{ + m_bVisited = bVisited; + + if (::IsWindow(GetSafeHwnd())) + Invalidate(); +} + +BOOL CHyperLink::GetVisited() const +{ + return m_bVisited; +} + +void CHyperLink::SetLinkCursor(HCURSOR hCursor) +{ + m_hLinkCursor = hCursor; + if (m_hLinkCursor == NULL) + SetDefaultCursor(); +} + +HCURSOR CHyperLink::GetLinkCursor() const +{ + return m_hLinkCursor; +} + +void CHyperLink::SetUnderline(int nUnderline /*=ulHover*/) +{ + if (m_nUnderline == nUnderline) + return; + + if (::IsWindow(GetSafeHwnd())) + { + if (nUnderline == ulAlways) + SetFont(&m_UnderlineFont); + else + SetFont(&m_StdFont); + + Invalidate(); + } + + m_nUnderline = nUnderline; +} + +int CHyperLink::GetUnderline() const +{ + return m_nUnderline; +} + +void CHyperLink::SetAutoSize(BOOL bAutoSize /* = TRUE */) +{ + m_bAdjustToFit = bAutoSize; + + if (::IsWindow(GetSafeHwnd())) + PositionWindow(); +} + +BOOL CHyperLink::GetAutoSize() const +{ + return m_bAdjustToFit; +} + + +// Move and resize the window so that the window is the same size +// as the hyperlink text. This stops the hyperlink cursor being active +// when it is not directly over the text. If the text is left justified +// then the window is merely shrunk, but if it is centred or right +// justified then the window will have to be moved as well. +// +// Suggested by Pål K. Tønder + +void CHyperLink::PositionWindow() +{ + if (!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit) + return; + + // Get the current window position + CRect WndRect, ClientRect; + GetWindowRect(WndRect); + GetClientRect(ClientRect); + + ClientToScreen(ClientRect); + + CWnd* pParent = GetParent(); + if (pParent) + { + pParent->ScreenToClient(WndRect); + pParent->ScreenToClient(ClientRect); + } + + // Get the size of the window text + CString strWndText; + GetWindowText(strWndText); + + CDC* pDC = GetDC(); + CFont* pOldFont = pDC->SelectObject(&m_UnderlineFont); + CSize Extent = pDC->GetTextExtent(strWndText); + pDC->SelectObject(pOldFont); + ReleaseDC(pDC); + + // Adjust for window borders + Extent.cx += WndRect.Width() - ClientRect.Width(); + Extent.cy += WndRect.Height() - ClientRect.Height(); + + // Get the text justification via the window style + DWORD dwStyle = GetStyle(); + + // Recalc the window size and position based on the text justification + if (dwStyle & SS_CENTERIMAGE) + WndRect.DeflateRect(0, (WndRect.Height() - Extent.cy)/2); + else + WndRect.bottom = WndRect.top + Extent.cy; + + if (dwStyle & SS_CENTER) + WndRect.DeflateRect((WndRect.Width() - Extent.cx)/2, 0); + else if (dwStyle & SS_RIGHT) + WndRect.left = WndRect.right - Extent.cx; + else // SS_LEFT = 0, so we can't test for it explicitly + WndRect.right = WndRect.left + Extent.cx; + + // Move the window + SetWindowPos(NULL, WndRect.left, WndRect.top, WndRect.Width(), WndRect.Height(), SWP_NOZORDER); +} + +///////////////////////////////////////////////////////////////////////////// +// CHyperLink implementation + +// The following appeared in Paul DiLascia's Jan 1998 MSJ articles. +// It loads a "hand" cursor from the winhlp32.exe module +void CHyperLink::SetDefaultCursor() +{ + if (m_hLinkCursor == NULL) // No cursor handle - load our own + { + /* + // Get the windows directory + CString strWndDir; + GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH); + strWndDir.ReleaseBuffer(); + + strWndDir += _T("\\winhlp32.exe"); + // This retrieves cursor #106 from winhlp32.exe, which is a hand pointer + HMODULE hModule = LoadLibrary(strWndDir); + if (hModule) { + HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106)); + if (hHandCursor) + m_hLinkCursor = CopyCursor(hHandCursor); + } + FreeLibrary(hModule); + */ + } + +} + +LONG CHyperLink::GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) +{ + HKEY hkey; + LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey); + + if (retval == ERROR_SUCCESS) { + long datasize = MAX_PATH; + TCHAR data[MAX_PATH]; + RegQueryValue(hkey, NULL, data, &datasize); + lstrcpy(retdata,data); + RegCloseKey(hkey); + } + + return retval; +} + +void CHyperLink::ReportError(int nError) +{ + CString str; + switch (nError) { + case 0: str = "The operating system is out\nof memory or resources."; break; + case SE_ERR_PNF: str = "The specified path was not found."; break; + case SE_ERR_FNF: str = "The specified file was not found."; break; + case ERROR_BAD_FORMAT: str = "The .EXE file is invalid\n(non-Win32 .EXE or error in .EXE image)."; break; + case SE_ERR_ACCESSDENIED: str = "The operating system denied\naccess to the specified file."; break; + case SE_ERR_ASSOCINCOMPLETE: str = "The filename association is\nincomplete or invalid."; break; + case SE_ERR_DDEBUSY: str = "The DDE transaction could not\nbe completed because other DDE transactions\nwere being processed."; break; + case SE_ERR_DDEFAIL: str = "The DDE transaction failed."; break; + case SE_ERR_DDETIMEOUT: str = "The DDE transaction could not\nbe completed because the request timed out."; break; + case SE_ERR_DLLNOTFOUND: str = "The specified dynamic-link library was not found."; break; + case SE_ERR_NOASSOC: str = "There is no application associated\nwith the given filename extension."; break; + case SE_ERR_OOM: str = "There was not enough memory to complete the operation."; break; + case SE_ERR_SHARE: str = "A sharing violation occurred. "; + default: str.Format(_T("Unknown Error (%d) occurred."), nError); break; + } + str = "Unable to open hyperlink:\n\n" + str; + AfxMessageBox(str, MB_ICONEXCLAMATION | MB_OK); +} + +HINSTANCE CHyperLink::GotoURL(LPCTSTR url, int showcmd) +{ + TCHAR key[MAX_PATH + MAX_PATH]; + + // First try ShellExecute() + HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd); + + // If it failed, get the .htm regkey and lookup the program + if ((UINT)result <= HINSTANCE_ERROR) { + + if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { + lstrcat(key, _T("\\shell\\open\\command")); + + if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { + TCHAR *pos; + pos = _tcsstr(key, _T("\"%1\"")); + if (pos == NULL) { // No quotes found + pos = _tcsstr(key, _T("%1")); // Check for %1, without quotes + if (pos == NULL) // No parameter at all... + pos = key+lstrlen(key)-1; + else + *pos = '\0'; // Remove the parameter + } + else + *pos = '\0'; // Remove the parameter + + lstrcat(pos, _T(" ")); + lstrcat(pos, url); + + USES_CONVERSION; + result = (HINSTANCE) WinExec(T2A(key),showcmd); + } + } + } + + return result; +} + diff --git a/Common.win32/HyperLink.h b/Common.win32/HyperLink.h new file mode 100644 index 0000000..482d096 --- /dev/null +++ b/Common.win32/HyperLink.h @@ -0,0 +1,106 @@ +// HyperLink.h : header file +// +// +// HyperLink static control. Will open the default browser with the given URL +// when the user clicks on the link. +// +// Copyright Chris Maunder, 1997-1999 (cmaunder@mail.com) +// Feel free to use and distribute. May not be sold for profit. + +// 2/29/00 -- P. Shaffer standard font mod. + +#if !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_) +#define AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +///////////////////////////////////////////////////////////////////////////// +// CHyperLink window + +class CHyperLink : public CStatic +{ +// Construction/destruction +public: + CHyperLink(); + virtual ~CHyperLink(); + +public: + enum UnderLineOptions { ulHover = -1, ulNone = 0, ulAlways = 1}; + +// Attributes +public: + void SetURL(CString strURL); + CString GetURL() const; + + void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour, + COLORREF crHoverColour = -1); + COLORREF GetLinkColour() const; + COLORREF GetVisitedColour() const; + COLORREF GetHoverColour() const; + + void SetVisited(BOOL bVisited = TRUE); + BOOL GetVisited() const; + + void SetLinkCursor(HCURSOR hCursor); + HCURSOR GetLinkCursor() const; + + void SetUnderline(int nUnderline = ulHover); + int GetUnderline() const; + + void SetAutoSize(BOOL bAutoSize = TRUE); + BOOL GetAutoSize() const; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CHyperLink) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + virtual BOOL DestroyWindow(); + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL + +// Implementation +protected: + HINSTANCE GotoURL(LPCTSTR url, int showcmd); + void ReportError(int nError); + LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); + void PositionWindow(); + void SetDefaultCursor(); + +// Protected attributes +protected: + COLORREF m_crLinkColour, m_crVisitedColour; // Hyperlink colours + COLORREF m_crHoverColour; // Hover colour + BOOL m_bOverControl; // cursor over control? + BOOL m_bVisited; // Has it been visited? + int m_nUnderline; // underline hyperlink? + BOOL m_bAdjustToFit; // Adjust window size to fit text? + CString m_strURL; // hyperlink URL + CFont m_UnderlineFont; // Font for underline display + CFont m_StdFont; // Standard font + HCURSOR m_hLinkCursor; // Cursor for hyperlink + CToolTipCtrl m_ToolTip; // The tooltip + UINT m_nTimerID; + + // Generated message map functions +protected: + //{{AFX_MSG(CHyperLink) + afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + afx_msg void OnClicked(); + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_) diff --git a/Common.win32/SliderZip.cpp b/Common.win32/SliderZip.cpp new file mode 100644 index 0000000..125c0a5 --- /dev/null +++ b/Common.win32/SliderZip.cpp @@ -0,0 +1,38 @@ +// SliderZip.cpp : fichier d'implémentation +// + +#include "../common.win32/stdafx.h" +#include "activecommon.h" +#include "SliderZip.h" +#include "../kegs/src/moremem.h" + +// Boîte de dialogue CSliderZip + +IMPLEMENT_DYNAMIC(CSliderZip, CSliderCtrl) +CSliderZip::CSliderZip(CWnd* pParent /*=NULL*/) + : CSliderCtrl() +{ +} + +CSliderZip::~CSliderZip() +{ +} + +void CSliderZip::DoDataExchange(CDataExchange* pDX) +{ + CSliderCtrl::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CSliderZip, CSliderCtrl) +ON_NOTIFY_REFLECT(NM_RELEASEDCAPTURE, OnNMReleasedcapture) +END_MESSAGE_MAP() + +// Gestionnaires de messages CSliderZip + +void CSliderZip::OnNMReleasedcapture(NMHDR *pNMHDR, LRESULT *pResult) +{ + g_moremem.g_zipgs_reg_c05a = ((15-(GetPos() & 0x0F))<< 4 )|(g_moremem.g_zipgs_reg_c05a&0x0F); + *pResult = 0; +} + diff --git a/Common.win32/SliderZip.h b/Common.win32/SliderZip.h new file mode 100644 index 0000000..f7d3120 --- /dev/null +++ b/Common.win32/SliderZip.h @@ -0,0 +1,27 @@ +#pragma once + + +// Boîte de dialogue CSliderZip + +class CSliderZip : public CSliderCtrl +{ + DECLARE_DYNAMIC(CSliderZip) + +public: + CSliderZip(CWnd* pParent = NULL); // constructeur standard + virtual ~CSliderZip(); + +// Données de boîte de dialogue + enum { IDD = IDD_TABRUNTIME }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge DDX/DDV + + DECLARE_MESSAGE_MAP() +public: + + afx_msg void OnNMReleasedcapture(NMHDR *pNMHDR, LRESULT *pResult); + +protected: + +}; diff --git a/Common.win32/TabGeneral.cpp b/Common.win32/TabGeneral.cpp new file mode 100644 index 0000000..d865ffa --- /dev/null +++ b/Common.win32/TabGeneral.cpp @@ -0,0 +1,67 @@ +// TabGeneral.cpp : fichier d'implémentation +// + +#include "../Common.win32/stdafx.h" +#include "activecommon.h" +#include "tabgeneral.h" + + +// Boîte de dialogue CTabGeneral + +IMPLEMENT_DYNAMIC(CTabGeneral, CDialog) +CTabGeneral::CTabGeneral(CWnd* pParent /*=NULL*/) + : CTabActiveInfo(CTabGeneral::IDD, pParent) +{ + HCURSOR hHand = NULL; +} + +CTabGeneral::~CTabGeneral() +{ + if (hHand) + DeleteObject(hHand); +} + +void CTabGeneral::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_URLOG, urlOG); + DDX_Control(pDX, IDC_URLKD, m_urlKD); +// DDX_Control(pDX, IDC_URLTD, urlTD); + DDX_Control(pDX, IDC_URLFTA, urlFTA); +} + + +BEGIN_MESSAGE_MAP(CTabGeneral, CDialog) + ON_STN_CLICKED(IDC_URLKD2, &CTabGeneral::OnStnClickedUrlkd2) +END_MESSAGE_MAP() + + +// Gestionnaires de messages CTabGeneral + +BOOL CTabGeneral::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CEmulatorWin32* pEmu = (CEmulatorWin32*)CEmulator::theEmulator; + if (pEmu) + hHand = LoadCursor(pEmu->hInst,MAKEINTRESOURCE(IDC_CURSOR1)); + + + m_urlKD.SetURL("mailto:kadickey@alumni.princeton.edu"); + m_urlKD.SetLinkCursor(hHand); + urlOG.SetURL("mailto:o@goguel.com"); + urlOG.SetLinkCursor(hHand); + + // urlTD.SetURL("mailto:tdracz@artpol.com.pl"); + urlFTA.SetURL("http://activegs.freetoolsassociation.com"); + urlFTA.SetLinkCursor(hHand); + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION : les pages de propriétés OCX devraient retourner FALSE +} + + + +void CTabGeneral::OnStnClickedUrlkd2() +{ + // TODO: ajoutez ici le code de votre gestionnaire de notification de contrôle +} diff --git a/Common.win32/TabGeneral.h b/Common.win32/TabGeneral.h new file mode 100644 index 0000000..fb35605 --- /dev/null +++ b/Common.win32/TabGeneral.h @@ -0,0 +1,29 @@ +#pragma once +#include "hyperlink.h" + + +// Boîte de dialogue CTabGeneral + +class CTabGeneral : public CTabActiveInfo +{ + DECLARE_DYNAMIC(CTabGeneral) + +public: + CTabGeneral(CWnd* pParent = NULL); // constructeur standard + virtual ~CTabGeneral(); + HCURSOR hHand; +// Données de boîte de dialogue + enum { IDD = IDD_TABGENERAL }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge DDX/DDV + + DECLARE_MESSAGE_MAP() +public: + CHyperLink urlOG; + virtual BOOL OnInitDialog(); + CHyperLink m_urlKD; + CHyperLink urlTD; + CHyperLink urlFTA; + afx_msg void OnStnClickedUrlkd2(); +}; diff --git a/Common.win32/TabOption.cpp b/Common.win32/TabOption.cpp new file mode 100644 index 0000000..d79fbfd --- /dev/null +++ b/Common.win32/TabOption.cpp @@ -0,0 +1,123 @@ +// TabOption.cpp : fichier d'implémentation +// + +#include "../Common.win32/stdafx.h" +#include "activecommon.h" +#include "taboption.h" + + + +// Boîte de dialogue CTabOption + +IMPLEMENT_DYNAMIC(CTabOption, CDialog) +CTabOption::CTabOption(CWnd* pParent /*=NULL*/) + : CTabActiveInfo(CTabOption::IDD, pParent) +{ +} + +CTabOption::~CTabOption() +{ +} + +void CTabOption::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CTabOption, CDialog) + ON_BN_CLICKED(IDC_NOIECACHE, OnBnClickedNoiecache) + ON_BN_CLICKED(IDC_HALTBADREAD, OnBnClickedHaltbadread) + ON_BN_CLICKED(IDC_HALTBADACCESS, OnBnClickedHaltbadaccess) + ON_BN_CLICKED(IDC_HALTEVENT, OnBnClickedHaltevent) + ON_BN_CLICKED(IDC_DEFAULTOPTIONS, OnBnClickedDefaultoptions) + ON_BN_CLICKED(IDC_DISABLEREWIND, &CTabOption::OnBnClickedDisablerewind) +END_MESSAGE_MAP() + + + +BOOL CTabOption::OnInitDialog() +{ + CDialog::OnInitDialog(); + initOptionDialog(); + return TRUE; +} + +void CTabOption::initOptionDialog() +{ + + CButton *pButton = (CButton*)GetDlgItem(IDC_NOIECACHE); + pButton->SetCheck(1); //pEmu->option.getIntValue(OPTION_PERSISTENTDIR)); + pButton->EnableWindow(0); + pButton = (CButton*)GetDlgItem(IDC_HALTBADREAD); + + pButton->SetCheck(option.getIntValue(OPTION_HALTONBADREAD)); + + pButton = (CButton*)GetDlgItem(IDC_HALTBADACCESS); + pButton->SetCheck(option.getIntValue(OPTION_HALTONBADACC)); + + pButton = (CButton*)GetDlgItem(IDC_HALTEVENT); + pButton->SetCheck(option.getIntValue(OPTION_HALTONHALTS)); + + pButton = (CButton*)GetDlgItem(IDC_ENABLEREWIND); + pButton->SetCheck(option.getIntValue(OPTION_ENABLEREWIND)); + + CWnd *pWnd = (CWnd*)GetDlgItem(IDC_PERSISTENT); + + pWnd->SetWindowText(CDownload::getPersistentPath()); +} + +void CTabOption::OnBnClickedNoiecache() +{ +} + + +void CTabOption::OnBnClickedHaltbadread() +{ + // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle + CButton *pButton = (CButton*)GetDlgItem(IDC_HALTBADREAD); + if (!pButton) return ; + int ck = pButton->GetCheck(); + option.setIntValue(OPTION_HALTONBADREAD,ck); + option.saveOptions(1); + +} + +void CTabOption::OnBnClickedHaltbadaccess() +{ + // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle + CButton *pButton = (CButton*)GetDlgItem(IDC_HALTBADACCESS); + if (!pButton) return ; + int ck = pButton->GetCheck(); + option.setIntValue(OPTION_HALTONBADACC,ck); + option.saveOptions(1); + +} + +void CTabOption::OnBnClickedHaltevent() +{ + // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle + CButton *pButton = (CButton*)GetDlgItem(IDC_HALTEVENT); + if (!pButton) return ; + int ck = pButton->GetCheck(); + option.setIntValue(OPTION_HALTONHALTS,ck); + option.saveOptions(1); + +} + +void CTabOption::OnBnClickedDefaultoptions() +{ + option.setDefaultOptions(); + option.saveOptions(1); + initOptionDialog(); +} + + +void CTabOption::OnBnClickedDisablerewind() +{ + CButton *pButton = (CButton*)GetDlgItem(IDC_ENABLEREWIND); + if (!pButton) return ; + int ck = pButton->GetCheck(); + option.setIntValue(OPTION_ENABLEREWIND,ck); + option.saveOptions(1); +} diff --git a/Common.win32/TabOption.h b/Common.win32/TabOption.h new file mode 100644 index 0000000..b4e39bd --- /dev/null +++ b/Common.win32/TabOption.h @@ -0,0 +1,30 @@ +#pragma once + + +// Boîte de dialogue CTabOption + +class CTabOption : public CTabActiveInfo +{ + DECLARE_DYNAMIC(CTabOption) + +public: + CTabOption(CWnd* pParent = NULL); // constructeur standard + virtual ~CTabOption(); + +// Données de boîte de dialogue + enum { IDD = IDD_TABOPTION }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge DDX/DDV + void initOptionDialog(); + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnBnClickedNoiecache(); + afx_msg void OnBnClickedHaltbadread(); + afx_msg void OnBnClickedHaltbadaccess(); + afx_msg void OnBnClickedHaltevent(); + afx_msg void OnBnClickedDefaultoptions(); + afx_msg void OnBnClickedHaltbadread2(); + afx_msg void OnBnClickedDisablerewind(); +}; diff --git a/Common.win32/TabRuntime.cpp b/Common.win32/TabRuntime.cpp new file mode 100644 index 0000000..e45d933 --- /dev/null +++ b/Common.win32/TabRuntime.cpp @@ -0,0 +1,298 @@ +// TabRuntime.cpp : fichier d'implémentation +// + +#include "../Common.win32/stdafx.h" +#include "activecommon.h" +#include "tabruntime.h" +#include "../common/ki.h" +#include "sliderzip.h" +#include "../kegs/src/defcomm.h" +#include "../kegs/src/moremem.h" +#include "../kegs/src/paddles.h" +#include "../kegs/src/sim65816.h" +#include "../kegs/src/saveState.h" +#include "../kegs/src/video.h" + +// Boîte de dialogue CTabRuntime + +IMPLEMENT_DYNAMIC(CTabRuntime, CDialog) + + +CTabRuntime::CTabRuntime(CWnd* pParent /*=NULL*/) + : CTabActiveInfo(CTabRuntime::IDD, pParent) +{ +} + +CTabRuntime::~CTabRuntime() +{ +} + +void CTabRuntime::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_ZIPSLIDER, m_SliderZip); +} + + +BEGIN_MESSAGE_MAP(CTabRuntime, CDialog) + ON_CBN_SELCHANGE(IDC_SPEEDMODE, OnCbnSelchangeSpeedmode) + ON_CBN_DROPDOWN(IDC_SPEEDMODE, OnCbnDropdownSpeedmode) + ON_CBN_CLOSEUP(IDC_SPEEDMODE, OnCbnCloseupSpeedmode) + ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnNeedText ) + ON_CBN_SELCHANGE(IDC_JOYSTICK, OnCbnSelchangeJoystick) + ON_BN_CLICKED(IDC_CONSOLEBUTTON3, OnBnClickedConsolebutton) + ON_BN_CLICKED(IDC_PAUSE, OnBnClickedButton1) + + ON_BN_CLICKED(IDC_CONSOLEBUTTON2, &CTabRuntime::OnBnClickedConsolebutton2) + ON_BN_CLICKED(IDC_SAVESTATE, &CTabRuntime::OnBnClickedSavestate) + ON_BN_CLICKED(IDC_RESTORESTATE, &CTabRuntime::OnBnClickedRestorestate) + ON_CBN_SELCHANGE(IDC_VIDEOFX, &CTabRuntime::OnCbnSelchangeVideofx) + ON_CBN_SELCHANGE(IDC_COLORMODE, &CTabRuntime::OnCbnSelchangeColormode) +END_MESSAGE_MAP() + +// Gestionnaires de messages CTabRuntime + + +void fillCombo(CComboBox *_combo,option_id _id,int _cur) +{ + int pos=0; + int i=0; + const char* s; + + namevalue& nv = option.find(_id); + while(s=nv.def->convertTableDesc[i]) + { + _combo->InsertString(pos,s); + _combo->SetItemData(pos,nv.def->convertTableInt[i]); + pos++; + i++; + } + int o = nv.getOrder(_cur); + _combo->SetCurSel(o); +} + + +BOOL CTabRuntime::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_SPEEDMODE); + fillCombo(pCombo,OPTION_SPEED,g_sim65816.get_limit_speed()); + + /*CComboBox * */pCombo = (CComboBox*)GetDlgItem(IDC_COLORMODE); + fillCombo(pCombo,OPTION_COLORMODE,r_sim65816.get_color_mode()); + +/*CComboBox * */pCombo = (CComboBox*)GetDlgItem(IDC_VIDEOFX); + fillCombo(pCombo,OPTION_VIDEOFX,r_sim65816.get_video_fx()); + + CSliderCtrl *pSlider = (CSliderCtrl*)GetDlgItem(IDC_ZIPSLIDER); + pSlider->SetRange(0,15); + pSlider->SetPos(g_moremem.g_zipgs_reg_c05a&0x0F); + + CComboBox *pComboJoy = (CComboBox*)GetDlgItem(IDC_JOYSTICK); + fillCombo(pComboJoy,OPTION_JOYSTICKMODE,g_joystick_type); + + CComboBox *pComboState = (CComboBox*)GetDlgItem(IDC_STATE); + for(int i=0;i<5;i++) + { + MyString str; + + int state_id = i; + if (state_id==0) + str = "Mem"; + else + str.Format("#%d",state_id); + pComboState->InsertString(i,str.c_str()); + pComboState->SetItemData(i,state_id); + } + pComboState->SetCurSel(0); + + enableSpeedChange=true; + OnCbnSelchangeSpeedmode(); + refresh(); + setPauseText(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION : les pages de propriétés OCX devraient retourner FALSE +} + +void CTabRuntime::OnCbnSelchangeSpeedmode() +{ + CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_SPEEDMODE); + int sel = pCombo->GetCurSel(); + int sp = pCombo->GetItemData(sel); + CEmulator* emu = CEmulator::theEmulator ; + emu->onSpeedChanged(sp); + + if (enableSpeedChange) + { + CWnd *pSlider = (CWnd*)GetDlgItem(IDC_ZIPSLIDER); + pSlider->EnableWindow(g_sim65816.get_limit_speed() == SPEED_ZIP?SW_SHOW:SW_HIDE); + } + +} + +void CTabRuntime::OnCbnDropdownSpeedmode() +{ + + enableSpeedChange=false; +} + +void CTabRuntime::OnCbnCloseupSpeedmode() +{ + enableSpeedChange=true; +} + +BOOL CTabRuntime::OnNeedText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) +{ +TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; + + CSliderCtrl *pSlider = (CSliderCtrl*)GetDlgItem(IDC_ZIPSLIDER); + if (pSlider) + { + CString string; + string.Format("%3d%%", (pSlider->GetPos()+1)*100/16); + ::lstrcpy(pTTT->szText, (LPCTSTR) string); + return TRUE; + } + return FALSE; + +} + +void CTabRuntime::refresh() +{ + CComboBox *pComboJoy = (CComboBox*)GetDlgItem(IDC_JOYSTICK); + namevalue& nv = option.find(OPTION_JOYSTICKMODE); + int sel = nv.getOrder(g_joystick_type); + pComboJoy->SetCurSel(sel); +} + + +int toggleJoystick(int _force); + +void CTabRuntime::OnCbnSelchangeJoystick() +{ + CComboBox *pComboJoy = (CComboBox*)GetDlgItem(IDC_JOYSTICK); + int sel = pComboJoy->GetCurSel(); + int joy = pComboJoy->GetItemData(sel); + + option.setIntValue(OPTION_JOYSTICKMODE,joy); + + outputInfo("switching to %s\n",option.getDescription(OPTION_JOYSTICKMODE,joy)); + + option.saveOptions(1); + refresh(); + + +} + + +void CTabRuntime::OnBnClickedConsolebutton() +{ + CConsole* c = ((CEmulatorWin32*)CEmulator::theEmulator)->theConsole; + if (c) + c->toggleConsole(); +} + + + +void CTabRuntime::setPauseText() +{ + CWnd *pWnd = (CWnd*)GetDlgItem(IDC_PAUSE); + if (pWnd) + {/* + if (r_sim65816.get_state() == IN_PAUSE ) + pWnd->SetWindowText("Resume"); + else + pWnd->SetWindowText("Pause"); + */ + pWnd->SetWindowText("Pause/Resume"); + } +} +void CTabRuntime::OnBnClickedButton1() +{ + if (r_sim65816.get_state()==IN_PAUSE) + r_sim65816.resume(); + else + if (r_sim65816.get_state()==RUNNING) + r_sim65816.pause(); + else + { + printf("emulator not running nor in pause...\n"); + return ; + } + setPauseText(); + +} + +void CTabRuntime::OnBnClickedConsolebutton2() +{ + CEmulator*pEmu = CEmulator::theEmulator; + if (!pEmu) + return ; + + MyString ret; + pEmu->processCommand("screenshot",ret); + ::MessageBox(NULL,ret.c_str(),"Screenshot saved",MB_OK); +} + + +void CTabRuntime::getStateFilename(MyString& filename) +{ + CComboBox *pComboState = (CComboBox*)GetDlgItem(IDC_STATE); + int s = pComboState->GetCurSel(); + int id = pComboState->GetItemData(s); + if (id==0) + return ; + + filename = CDownload::getPersistentPath(); + filename += ACTIVEGS_DIRECTORY_SEPARATOR; + + MyString f; + f.Format( "state_%d.state",id); + filename += f; + +} + +void CTabRuntime::OnBnClickedSavestate() +{ + MyString path; + + getStateFilename(path); + g_savestate.saveState(path.c_str()); + +} + +void CTabRuntime::OnBnClickedRestorestate() +{ + MyString path; + getStateFilename(path); + g_savestate.restoreState(path.c_str()); + +} + + + +void CTabRuntime::OnCbnSelchangeVideofx() +{ + CComboBox *pComboJoy = (CComboBox*)GetDlgItem(IDC_VIDEOFX); + int vfx = pComboJoy->GetCurSel(); + int vfxdata = pComboJoy->GetItemData(vfx); + option.setIntValue(OPTION_VIDEOFX,vfxdata); + option.saveOptions(1); + x_refresh_video(); +} + +void CTabRuntime::OnCbnSelchangeColormode() +{ + CComboBox *pComboJoy = (CComboBox*)GetDlgItem(IDC_COLORMODE); + int cm = pComboJoy->GetCurSel(); + int cmdata = pComboJoy->GetItemData(cm); + option.setIntValue(OPTION_COLORMODE,cmdata); + option.saveOptions(1); + x_refresh_video(); + + + +} + diff --git a/Common.win32/TabRuntime.h b/Common.win32/TabRuntime.h new file mode 100644 index 0000000..da5b2da --- /dev/null +++ b/Common.win32/TabRuntime.h @@ -0,0 +1,45 @@ +#pragma once +#include "sliderzip.h" +#include "../Kegs/Src/StdString.h" + + +// Boîte de dialogue CTabRuntime + +class CTabRuntime : public CTabActiveInfo +{ + DECLARE_DYNAMIC(CTabRuntime) + void getStateFilename(MyString& filename); +public: + CTabRuntime(CWnd* pParent = NULL); // constructeur standard + virtual ~CTabRuntime(); + bool enableSpeedChange; + +// Données de boîte de dialogue + enum { IDD = IDD_TABRUNTIME }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge DDX/DDV + + DECLARE_MESSAGE_MAP() +public: + virtual BOOL OnInitDialog(); + afx_msg void OnCbnSelchangeSpeedmode(); + CSliderZip m_SliderZip; + afx_msg void OnCbnDropdownSpeedmode(); + afx_msg void OnCbnCloseupSpeedmode(); + BOOL OnNeedText( UINT id, NMHDR * pTTTStruct, LRESULT * pResult ); + + virtual void refresh(); + void setPauseText(); + afx_msg void OnCbnSelchangeJoystick(); + afx_msg void OnBnClickedConsolebutton(); + + afx_msg void OnBnClickedButton1(); + + afx_msg void OnBnClickedConsolebutton2(); + afx_msg void OnBnClickedSavestate(); + afx_msg void OnBnClickedRestorestate(); + afx_msg void OnCbnSelchangeVideofx(); + afx_msg void OnCbnSelchangeColormode(); + afx_msg void OnBnClickedConsolebutton3(); +}; diff --git a/Common.win32/TabXml.cpp b/Common.win32/TabXml.cpp new file mode 100644 index 0000000..137e1ee --- /dev/null +++ b/Common.win32/TabXml.cpp @@ -0,0 +1,122 @@ +// TabOption.cpp : fichier d'implémentation +// + +#include "../Common.win32/stdafx.h" +#include "activecommon.h" +#include "tabxml.h" + + + +// Boîte de dialogue CTabOption + +IMPLEMENT_DYNAMIC(CTabXML, CDialog) +CTabXML::CTabXML(CWnd* pParent /*=NULL*/) + : CTabActiveInfo(CTabXML::IDD, pParent) +{ +} + +CTabXML::~CTabXML() +{ +} + +void CTabXML::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_MULTIPLENAME, urlName); + DDX_Control(pDX, IDC_MULTIPLEPUBLISHER, urlPublisher); + +} + + +BEGIN_MESSAGE_MAP(CTabXML, CDialog) + ON_BN_CLICKED(IDC_MULTIPLESWAP, OnBnClickedSwap) +END_MESSAGE_MAP() + + +/* +BOOL CTabOption::OnInitDialog() +{ + CDialog::OnInitDialog(); + initOptionDialog(); + return TRUE; +} +*/ + +void CTabXML::OnBnClickedSwap() +{ + CEmulator* emu = CEmulator::theEmulator ; + if (!emu) return ; + emu->smartSwap(); +} + + +void CTabXML::refresh() +{ + CEmulator* emu = CEmulator::theEmulator; + if (!emu) return ; + + /* + const char * name = "*Custom Config*"; + const char * publisher = ""; + const char * year = ""; + const char * nameurl = NULL; + const char * publisherurl = NULL; + MyString swapdisk = "*not available*"; + int swapdiskenable = 0; + + if (emu->config->pure) + { + name = emu->config->name.c_str(); + year = emu->config->year.c_str(); + publisher = emu->config->publisher.c_str(); + nameurl = emu->config->nameurl.c_str(); + publisherurl = emu->config->publisherurl.c_str(); + int smart = emu->getSmartSwap(); + if (smart) + { + CSlotInfo ref = emu->getLocalIMGInfo(smart/10,smart%10); + if (ref.status == DELAYEDMOUNT) + swapdisk.Format("*%s*",ref.shortname.c_str()); + else + swapdisk = ref.shortname.c_str(); + swapdiskenable=1; + } + } + CWnd* pText = GetDlgItem(IDC_MULTIPLENAME); + if (nameurl && nameurl[0]) + { + urlName.SetURL(nameurl); + urlName.SetWindowText(name); + if (pText) + pText->SetWindowText(NULL); + } + else + { + if (pText) + pText->SetWindowText(name); + } + + if( publisherurl && publisherurl[0]) + urlPublisher.SetURL(publisherurl); + urlPublisher.SetWindowText(publisher); + + + pText = GetDlgItem(IDC_MULTIPLEYEAR); + if (pText) + pText->SetWindowText(year); + + pText = GetDlgItem(IDC_MULTIPLEPUBLISHER); + if (pText) + pText->SetWindowText(publisher); + + + pText = GetDlgItem(IDC_MULTIPLECURRENT); + if (pText) + pText->SetWindowText(swapdisk.c_str()); + + CWnd *swapbutton = GetDlgItem(IDC_MULTIPLESWAP); + if (swapbutton) + ::EnableWindow(swapbutton->m_hWnd,swapdiskenable); + */ + +} \ No newline at end of file diff --git a/Common.win32/TabXml.h b/Common.win32/TabXml.h new file mode 100644 index 0000000..09342d1 --- /dev/null +++ b/Common.win32/TabXml.h @@ -0,0 +1,29 @@ +#pragma once + + +// Boîte de dialogue CTabXML + +class CTabXML : public CTabActiveInfo +{ + DECLARE_DYNAMIC(CTabXML) + +public: + CTabXML(CWnd* pParent = NULL); // constructeur standard + virtual ~CTabXML(); + +// Données de boîte de dialogue + enum { IDD = IDD_TABXML }; + + CHyperLink urlName; + CHyperLink urlPublisher; + + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge DDX/DDV + void initOptionDialog(); + DECLARE_MESSAGE_MAP() +public: +// virtual BOOL OnInitDialog(); + afx_msg void OnBnClickedSwap(); + virtual void refresh(); +}; diff --git a/Common.win32/activecommon.h b/Common.win32/activecommon.h new file mode 100644 index 0000000..4eb02cc --- /dev/null +++ b/Common.win32/activecommon.h @@ -0,0 +1,114 @@ +#pragma once + + +#include "stdafx.h" +#include "../Common/CEmulatorCtrl.h" + +#ifndef UNDER_CE +#include "activeinfo.h" +#include "activecommonres.h" // main symbols +#include "activestatus.h" +#endif + +//#define FTAURL "http://www.freetoolsassociation.com/stat/stat.php?ver=2,0,0,11" + + +bool retrieveProgramFilesPath(MyString& path); + + +#define HIST_DEFAULT_LIMIT 262144 + +HCURSOR CreateAlphaCursor(HINSTANCE hInst); + +struct CConsole +{ + CConsole* theConsole; + HMODULE mod; + + HWND hWnd; + HWND hWndParent; + int visible; + char ConsoleHistory[HIST_DEFAULT_LIMIT]; + int HistorySize; + int BufferSize; + int kNbVisibleLinesInEditCtrl; + int enable; + char inputBuffer[256]; + WNDPROC OldProc; + HFONT hFont; + + + CConsole(); + ~CConsole(); + + void showConsole(); + void hideConsole(); + void initConsole(HINSTANCE hInst,HWND hWnd); + void shutConsole(HWND); + void toggleConsole(); + void addLine(const char* buf); + void enableConsole(); + void disableConsole(); + int read(char* buf); + void refreshLine(); + +}; + +const int DEFAULTCONFIGPARAM = -1000; + + + +class CEmulatorWin32 : public CEmulator +{ +public: + +#ifndef UNDER_CE + CConsole* theConsole; + CActiveInfo* activeInfo; + CActiveStatus* wStatus; + CActiveStatus* wLoading; + CBitmap wLoadingBitmap[4]; + HCURSOR hAlphaCursor; +#endif + HANDLE hThread; + HWND m_hWnd; + + + HMODULE mod; + + HHOOK hhkLowLevelKybd; + void enableSystemKeys(); + void disableSystemKeys(); + int hasFocus(); + + static DWORD WINAPI myThread(LPVOID lpParameter); + + HINSTANCE hInst; + + CEmulatorWin32(CEmulator** _parent); + int initWindow(HWND _hWnd,HINSTANCE _hInst); + ~CEmulatorWin32(); + + LRESULT windowProc(UINT message, WPARAM wParam, LPARAM lParam); + void destroy(); + LRESULT eventHandler(UINT umsg, WPARAM wParam, LPARAM lParam); + void keyHandler(UINT raw_vk,BOOL down, UINT flags); + + void x_LaunchThread(); + void x_WaitForEndThread(); + + virtual void refreshStatus(const char* _msg); + virtual void showLoading( int _loading,int _disk); + void ShowActiveInfo(); + virtual void showStatus(const char* _msg); + virtual void loadingInProgress(int _motorOn,int _slot, int _drive); + virtual void disableConsole(); + virtual int activeRead(char *buf); + virtual void getEngineString(MyString& _engine); + + +}; + + + + diff --git a/Common.win32/activecommonres.h b/Common.win32/activecommonres.h new file mode 100644 index 0000000..6307ac2 --- /dev/null +++ b/Common.win32/activecommonres.h @@ -0,0 +1,90 @@ +//{{NO_DEPENDENCIES}} +// fichier Include Microsoft Visual C++. +// Utilisé par ActiveCommon.rc +// +#define IDB_ALPHACURSOR 102 +#define IDD_STATUS 202 +#define IDD_LOADING 203 +#define IDC_RICHEDIT22 205 +#define IDC_EDIT22 205 +#define IDB_DISK51 205 +#define IDB_DISK52 206 +#define IDC_STATUS 207 +#define IDD_ACTIVEINFO 208 +#define IDB_DISK61 209 +#define IDD_TABGENERAL 209 +#define IDB_DISK62 210 +#define IDD_TABRUNTIME 210 +#define IDD_TABDISKCONF 210 +#define IDD_TABPARAM 211 +#define IDC_IMAGECTRLDISK 211 +#define IDD_TABOPTION 212 +#define IDD_TABHELP 213 +#define IDD_TABRUNTIME1 214 +#define IDC_CURSOR1 214 +#define IDC_URLFTA 215 +#define IDD_TABXML 215 +#define IDC_URLOG 217 +#define IDC_URLKD 218 +#define IDC_SPEED 219 +#define IDC_URLKD2 219 +#define IDC_SLOTLIST 220 +#define IDC_ACTIVETAB 221 +#define IDC_PARAMLIST 222 +#define IDC_URLTD 223 +#define IDC_NOIECACHE 224 +#define IDC_PERSISTENT 225 +#define IDC_SPEEDMODE 226 +#define IDC_ZIPSLIDER 227 +#define IDC_JOYSTICK 228 +#define IDC_CONSOLEBUTTON 229 +#define IDC_PAUSE 230 +#define IDC_HALTBADREAD 231 +#define IDC_CONSOLEBUTTON2 231 +#define IDC_HALTEVENT 232 +#define IDC_SAVESTATE 232 +#define IDC_HALTBADACCESS 233 +#define IDC_CONSOLEBUTTON4 233 +#define IDC_RESTORESTATE 233 +#define IDC_DEFAULTOPTIONS 234 +#define IDC_RESTORESTATE2 234 +#define IDC_REWINDSTATE 234 +#define IDC_VIDEOFX 234 +#define IDC_COLORMODE 235 +#define IDC_EDITURL 236 +#define IDC_CLEARCACHE 236 +#define IDC_CONSOLEBUTTON3 236 +#define IDC_DISABLEREWIND 237 +#define IDC_ENABLEREWIND 237 +#define IDC_MOUNTSLOT 238 +#define IDC_MOUNTBUTTON 239 +#define IDC_EJECT 240 +#define IDC_RELOAD 241 +#define IDC_FILESELECT 242 +#define IDC_REBOOT5 243 +#define IDC_REBOOT6 244 +#define IDC_REBOOT7 245 +#define IDC_STATICSLOT2 246 +#define IDC_EJECT2 247 +#define IDC_SWAP 247 +#define IDC_COMBOSLOT 248 +#define IDC_BUILD 249 +#define IDC_VERSION 250 +#define IDC_MULTIPLECURRENT 251 +#define IDC_MULTIPLENAME 252 +#define IDC_MULTIPLEPUBLISHER 253 +#define IDC_MULTIPLEYEAR 254 +#define IDC_MULTIPLESWAP 255 +#define IDC_COMBO1 257 +#define IDC_STATE 257 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 216 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 258 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Common.win32/activeconfig.c b/Common.win32/activeconfig.c new file mode 100644 index 0000000..1ef2a84 --- /dev/null +++ b/Common.win32/activeconfig.c @@ -0,0 +1,239 @@ + +#include +#include +#include +#include "../src/defc.h" +#include "ki.h" + +extern Iwm iwm; + +void (*ki_loadingptr)(int,int,int) = NULL; + +void prepareDriveInfo(Disk* dsk,int slot, int drive) +{ + int l = dsk->image_size; + int s = dsk->image_start ; + int p = (dsk->image_type == DSK_TYPE_PRODOS); + readImageInfo(slot,drive+1,l,s,p); +} + +int toggleJoystick(int _force) + { + if (_force==-2) + { + // auto + joystick_init(); // ? Joy + } + else + if (_force==-1) + { + if (g_joystick_type == JOYSTICK_MOUSE) + g_joystick_type = JOYSTICK_NONE; + else + if (g_joystick_type == JOYSTICK_NONE) + { + joystick_init(); // ? Joy + // can be mouse if not detected + } + else + { + // joystick_win32 + g_joystick_type=JOYSTICK_MOUSE; + } + } + else + { + g_joystick_type = _force; + if (g_joystick_type == JOYSTICK_WIN32_1) + joystick_init(); + } + + if (g_joystick_type == JOYSTICK_MOUSE) + printf("joystick set to mouse emulation\n"); + else + if (g_joystick_type == JOYSTICK_NONE) + printf("joystick set to none\n"); + else + printf("joystick set to native\n"); + + refreshInfo(); + return 1; +} + + +#ifndef _CONSOLE + +/* +void ejectDisk(int slot,int disk) +{ + setLocalIMG(slot,disk,NULL); +} +*/ + + +void checkImages() +{ + extern int g_highest_smartport_unit ; + extern Iwm iwm; + + if (mountImages()) + { + printf("Mounting images...\n"); + + g_highest_smartport_unit = -1; + + insert_disk(5,0,getLocalIMG(5,1),0,0,0,0); + insert_disk(5,1,getLocalIMG(5,2),0,0,0,0); + insert_disk(6,0,getLocalIMG(6,1),0,0,0,0); + insert_disk(6,1,getLocalIMG(6,2),0,0,0,0); + + insert_disk(7,0,getLocalIMG(7,1),0,0,0,0); + insert_disk(7,1,getLocalIMG(7,2),0,0,0,0); + + refreshInfo(); + + } +} +/* +extern void ejectDiskCtrl(int _slot,int _drive); +void ejectDisk(int _slot,int _drive) +{ + if (!g_inMount) + ejectDiskCtrl(_slot,_drive); +} +*/ + +void config_init() +{ + /* +#ifndef _USRDLL + insert_disk(5,0,"nucleus.2mg",0,0,0,0); + insert_disk(6,0,"flobynoid (2002).dsk",0,0,0,0); +#endif + */ +} + +char bram_default[]={ +(char)0x00, (char)0x00, (char)0x00, (char)0x01, (char)0x00, (char)0x00, (char)0x0D, (char)0x06, (char)0x02, (char)0x01, (char)0x01, (char)0x00, (char)0x01, (char)0x00, (char)0x00, (char)0x00, +(char)0x00, (char)0x00, (char)0x07, (char)0x06, (char)0x02, (char)0x01, (char)0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x0F, (char)0x06, (char)0x06, (char)0x00, (char)0x05, (char)0x06, +(char)0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x01, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x03, (char)0x02, (char)0x02, (char)0x02, +(char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x01, (char)0x02, (char)0x03, (char)0x04, (char)0x05, (char)0x06, +(char)0x07, (char)0x00, (char)0x00, (char)0x01, (char)0x02, (char)0x03, (char)0x04, (char)0x05, (char)0x06, (char)0x07, (char)0x08, (char)0x09, (char)0x0A, (char)0x0B, (char)0x0C, (char)0x0D, +(char)0x0E, (char)0x0F, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, +(char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFF, (char)0xFD, (char)0x96, (char)0x57, (char)0x3C +}; + +void updateBramCheckSum(unsigned char* buf) // original code in FF/B61D +{ + register short int crc=0; // LDA #0 + int i; // CLC + for(i=255-4-1;i>=0;i--) // LDX #FA + { + crc = (crc << 1) | ((crc>>15) & 1); // ROL (1-bits) +#ifdef UNDER_CE + crc += buf[i]; + crc += buf[i+1]*256; +#else + crc += *(unsigned short*)(buf+i); // ADC bram,X +#endif + } // DEX + // CPX #FF + // BNE Loop + *(unsigned short*)(buf+252) = crc; // TAX + *(unsigned short*)(buf+254) = crc ^0xAAAA; // EOR #AAAA +} + + +void initializeBram(byte* g_bram_ptr) +{ + memcpy(g_bram_ptr,bram_default,256); + updateBramParameters(g_bram_ptr); + updateBramCheckSum(g_bram_ptr); + +} +#else + +void config_init() +{ +// insert_disk(7,0,"system6.2mg",0,0,0,0); +// insert_disk(7,0,"C:\\Work\\GS\\Images\\GSOS_6.2MG",0,0,0,0); +// insert_disk(7,0,"OOTW.2MG",0,0,0,0); + +// insert_disk(7,0,"C:\\Work\\GS\\Images\\NFCDemoDrive.2mg",0,0,0,0); + + insert_disk(5,0,"nucleus.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\ACS_Demo2.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\StarWizard(OK).2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\BeamDemo.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\Bestof2vol1.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\MODULAE.2MG",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\delta.2MG",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\TFORCE1.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\manoir.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\BOUNCIN_FERNO.2MG",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\Rastan with Intro Disk 1.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\Aaargh!.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\CaliforniaDemo.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\xmasdemo.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\nodrugs.2mg",0,0,0,0); +// insert_disk(5,0,"C:\\Work\\GS\\Images\\Star_Trek_Classic.2mg",0,0,0,0); + +// insert_disk(5,0,"C:\\Work\\GS\\Images\\shark.2mg",0,0,0,0); + +// insert_disk(6,0,"C:\\Work\\GS\\Images\\flobynoid (2002).dsk",0,0,0,0); +// insert_disk(6,0,"C:\\Work\\GS\\Images\\Ultima III - Exodus (Master) (Disk 1 of 2).zip_0_Ultima III - Exodus (Master) (Disk 1 of 2)[1].dsk",0,0,0,0); +// insert_disk(6,0,"C:\\Work\\GS\\Images\\karateka.dsk",0,0,0,0); + +} + +#endif + + + +void monitorStatus(int motorOn,int drive,int select) +{ + if (ki_loadingptr) + ki_loadingptr(motorOn,drive,select); + +} + +#ifndef UNDER_CE +char targetSpeed[256]; +char estimatedSpeed[256]; + +void updateInfo(const char* target,const char *speed) +{ + strcpy(targetSpeed,target); + strcpy(estimatedSpeed,speed); + +} +#endif + + +// SIM86516 + +void fatalExit(int ret) +{ + char str[255]; + unsigned short strw[1024]; + sprintf(str,"Critical Error : %d",ret); + +#ifndef UNDER_CE + MessageBox(NULL,str,"ActiveGS Halted!",MB_OK); +#else + + MultiByteToWideChar(CP_ACP, 0,str,strlen(str),strw,1024); + + MessageBox(NULL,strw,_T("ActiveGS Halted!"),MB_OK); +#endif + ExitThread(ret); +} \ No newline at end of file diff --git a/Common.win32/bitmap1.bmp b/Common.win32/bitmap1.bmp new file mode 100644 index 0000000..6e8e840 Binary files /dev/null and b/Common.win32/bitmap1.bmp differ diff --git a/Common.win32/bitmap2.bmp b/Common.win32/bitmap2.bmp new file mode 100644 index 0000000..3568145 Binary files /dev/null and b/Common.win32/bitmap2.bmp differ diff --git a/Common.win32/bmp00001.bmp b/Common.win32/bmp00001.bmp new file mode 100644 index 0000000..c656d88 Binary files /dev/null and b/Common.win32/bmp00001.bmp differ diff --git a/Common.win32/console.aps b/Common.win32/console.aps new file mode 100644 index 0000000..09157ef Binary files /dev/null and b/Common.win32/console.aps differ diff --git a/Common.win32/console.rc b/Common.win32/console.rc new file mode 100644 index 0000000..bf64627 --- /dev/null +++ b/Common.win32/console.rc @@ -0,0 +1,114 @@ +// Microsoft Visual C++ generated resource script. +// +#include "consoleresrc.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "consoleresrc.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CONSOLE DIALOGEX 0, 0, 418, 252 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "ActiveGS Console v1.1" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Command",IDC_STATIC,6,216,405,30 + PUSHBUTTON "Go!",IDC_GO,12,228,24,12 + PUSHBUTTON "Step",IDC_STEP,42,228,24,12 + PUSHBUTTON "Regs",IDC_REGS,72,228,24,12 + PUSHBUTTON "Brk!",IDC_BUTTONBRK,102,228,24,12 + CONTROL "",IDC_EDIT2,"RichEdit20A",ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,7,404,203 + EDITTEXT IDC_EDIT1,138,228,267,12,ES_AUTOHSCROLL | WS_DISABLED +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_CONSOLE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 411 + TOPMARGIN, 7 + BOTTOMMARGIN, 245 + END +END +#endif // APSTUDIO_INVOKED + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Common.win32/consoleresrc.h b/Common.win32/consoleresrc.h new file mode 100644 index 0000000..000ab4a --- /dev/null +++ b/Common.win32/consoleresrc.h @@ -0,0 +1,23 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by console.rc +// +#define IDD_CONSOLE 101 +#define IDC_EDIT2 103 +#define IDC_EDIT1 104 +#define IDC_GO 105 +#define IDC_STEP 106 +#define IDC_REGS 107 +#define IDC_BUTTONBRK 108 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 114 +#define _APS_NEXT_COMMAND_VALUE 40013 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 109 +#endif +#endif diff --git a/Common.win32/cursor1.cur b/Common.win32/cursor1.cur new file mode 100644 index 0000000..f6a3673 Binary files /dev/null and b/Common.win32/cursor1.cur differ diff --git a/Common.win32/disk52.bmp b/Common.win32/disk52.bmp new file mode 100644 index 0000000..ec1c8f1 Binary files /dev/null and b/Common.win32/disk52.bmp differ diff --git a/Common.win32/disk54.bmp b/Common.win32/disk54.bmp new file mode 100644 index 0000000..aa61f4b Binary files /dev/null and b/Common.win32/disk54.bmp differ diff --git a/Common.win32/disk55.bmp b/Common.win32/disk55.bmp new file mode 100644 index 0000000..b64554b Binary files /dev/null and b/Common.win32/disk55.bmp differ diff --git a/Common.win32/stdafx.cpp b/Common.win32/stdafx.cpp new file mode 100644 index 0000000..be57497 --- /dev/null +++ b/Common.win32/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : fichier source incluant simplement les fichiers Include standard +// ActiveGSApp.pch représente l'en-tête précompilé +// stdafx.obj contient les informations de type précompilées + +#include "../Common.Win32/stdafx.h" + + diff --git a/Common.win32/stdafx.h b/Common.win32/stdafx.h new file mode 100644 index 0000000..9b55cd7 --- /dev/null +++ b/Common.win32/stdafx.h @@ -0,0 +1,49 @@ +// stdafx.h : Fichier Include pour les fichiers Include système standard, +// ou les fichiers Include spécifiques aux projets qui sont utilisés fréquemment, +// et sont rarement modifiés + +#pragma once +#define WINVER 0x0600 +#define _WIN32_WINNT 0x0600 +/* + +// FOR VS2010 + + + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclure les en-têtes Windows rarement utilisés +#endif + +// Modifiez les définitions suivantes si vous devez cibler une plate-forme avant celles spécifiées ci-dessous. +// Reportez-vous à MSDN pour obtenir les dernières informations sur les valeurs correspondantes pour les différentes plates-formes. +#ifndef WINVER // Autorise l'utilisation des fonctionnalités spécifiques à Windows 95 et Windows NT 4 ou version ultérieure. +#define WINVER 0x0400 // Attribuez la valeur appropriée à cet élément pour cibler Windows 98 et Windows 2000 ou version ultérieure. +#endif + +#ifndef _WIN32_WINNT // Autorise l'utilisation des fonctionnalités spécifiques à Windows NT 4 ou version ultérieure. +#define _WIN32_WINNT 0x0400 // Attribuez la valeur appropriée à cet élément pour cibler Windows 98 et Windows 2000 ou version ultérieure. +#endif + +#ifndef _WIN32_WINDOWS // Autorise l'utilisation des fonctionnalités spécifiques à Windows 98 ou version ultérieure. +#define _WIN32_WINDOWS 0x0410 // Attribuez la valeur appropriée à cet élément pour cibler Windows Me ou version ultérieure. +#endif + +#ifndef _WIN32_IE // Autorise l'utilisation des fonctionnalités spécifiques à IE 4.0 ou version ultérieure. +#define _WIN32_IE 0x0400 // Attribuez la valeur appropriée à cet élément pour cibler IE 5.0 ou version ultérieure. +#endif + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // certains constructeurs CString seront explicites + +// désactive le masquage MFC de certains messages d'avertissement courants et par ailleurs souvent ignorés +#define _AFX_ALL_WARNINGS +*/ +#include // composants MFC principaux et standard +#include // extensions MFC +#include // Classes MFC Automation +#include // MFC support for ActiveX Controls +#include // Prise en charge des MFC pour les contrôles communs Internet Explorer 4 +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // Prise en charge des MFC pour les contrôles communs Windows +#endif // _AFX_NO_AFXCMN_SUPPORT + diff --git a/Common.win32/vs10fix/afxctrlcontainer.cpp b/Common.win32/vs10fix/afxctrlcontainer.cpp new file mode 100644 index 0000000..e917442 --- /dev/null +++ b/Common.win32/vs10fix/afxctrlcontainer.cpp @@ -0,0 +1,378 @@ +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and related +// electronic documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. +// +// CWnd support for MFC Control containment (Feature Pack controls) +// + +#include "..\stdafx.h" +#include "afxpriv.h" +#include "afxole.h" +#include "..\src\mfc\oleimpl2.h" +#include "..\src\mfc\afximpl.h" +#include "afxctrlcontainer.h" +// OG TO REDUCE EXE SIZE +/* +#include "afxtagmanager.h" +#include "afxbutton.h" +#include "afxcolorbutton.h" +#include "afxeditbrowsectrl.h" +#include "afxfontcombobox.h" +#include "afxlinkctrl.h" +#include "afxmaskededit.h" +#include "afxmenubutton.h" +#include "afxpropertygridctrl.h" +#include "afxshelllistctrl.h" +#include "afxshelltreectrl.h" +#include "afxvslistbox.h" +*/ + +//////////////////////////////////////////////////////////////////////////// + +static void DoRegisterWindowClass(LPCTSTR lpszClassName, LPCTSTR lpszBaseClassName) +{ + ASSERT(lpszClassName != NULL); + ASSERT(lpszBaseClassName != NULL); + + WNDCLASS wnd = {0}; + + HINSTANCE hInst = AfxGetInstanceHandle(); + if (!AfxCtxGetClassInfo(hInst, lpszBaseClassName, &wnd)) + { + wnd.style = CS_DBLCLKS; + wnd.hInstance = hInst; + wnd.lpfnWndProc = ::DefWindowProc; + } + + wnd.lpszClassName = lpszClassName; + AfxRegisterClass(&wnd); +} + +void AfxRegisterMFCCtrlClasses() +{ + DoRegisterWindowClass(_T("MFCButton"), WC_BUTTON); + DoRegisterWindowClass(_T("MFCColorButton"), WC_BUTTON); + DoRegisterWindowClass(_T("MFCEditBrowse"), WC_EDIT); + DoRegisterWindowClass(_T("MFCFontComboBox"), WC_COMBOBOX); + DoRegisterWindowClass(_T("MFCLink"), WC_BUTTON); + DoRegisterWindowClass(_T("MFCMaskedEdit"), WC_EDIT); + DoRegisterWindowClass(_T("MFCMenuButton"), WC_BUTTON); + DoRegisterWindowClass(_T("MFCPropertyGrid"), WC_STATIC); + DoRegisterWindowClass(_T("MFCShellList"), WC_LISTVIEW); + DoRegisterWindowClass(_T("MFCShellTree"), WC_TREEVIEW); + DoRegisterWindowClass(_T("MFCVSListBox"), WC_STATIC); +} + +//////////////////////////////////////////////////////////////////////////// +// CMFCControlContainer + +CMFCControlContainer::CMFCControlContainer(CWnd* pWnd) : m_pWnd(pWnd) +{ +} + +CMFCControlContainer::~CMFCControlContainer() +{ + FreeSubclassedControls(); + ClearControlData(); +} + +BOOL CMFCControlContainer::SubclassDlgControls() +{ + if (m_pWnd->GetSafeHwnd() != NULL) + { + // Subclass Feature Pack controls: + CWnd* pWndChild = m_pWnd->GetWindow(GW_CHILD); + while (pWndChild != NULL) + { + ASSERT_VALID(pWndChild); + + TCHAR lpszClassName [MAX_CLASS_NAME + 1]; + + ::GetClassName(pWndChild->GetSafeHwnd(), lpszClassName, MAX_CLASS_NAME); + CWnd* pWndSubclassedCtrl = CreateDlgControl(lpszClassName); + + if (pWndSubclassedCtrl != NULL) + { + m_arSubclassedCtrls.Add((CObject*)pWndSubclassedCtrl); + pWndSubclassedCtrl->SubclassWindow(pWndChild->GetSafeHwnd()); + } + + pWndChild = pWndChild->GetNextWindow(); + } + + return TRUE; + } + + return FALSE; +} + +void CMFCControlContainer::FreeSubclassedControls() +{ + // Free subclassed controls: + for (int i = 0; i < m_arSubclassedCtrls.GetCount(); i++) + { + if (m_arSubclassedCtrls [i] != NULL) + { + delete m_arSubclassedCtrls [i]; + } + } + m_arSubclassedCtrls.RemoveAll(); +} + +CWnd* CMFCControlContainer::CreateDlgControl(LPCTSTR lpszClassName) +{ + ASSERT(m_pWnd->GetSafeHwnd() != NULL); + + if (lpszClassName != NULL) + { + CString strClass = lpszClassName; + CWnd* pWndSubclassedCtrl = NULL; + /* + if (strClass == _T("MFCButton")) + { + pWndSubclassedCtrl = new CMFCButton; + } + else if (strClass == _T("MFCColorButton")) + { + pWndSubclassedCtrl = new CMFCColorButton; + } + else if (strClass == _T("MFCEditBrowse")) + { + pWndSubclassedCtrl = new CMFCEditBrowseCtrl; + } + else if (strClass == _T("MFCFontComboBox")) + { + pWndSubclassedCtrl = new CMFCFontComboBox; + } + else if (strClass == _T("MFCLink")) + { + pWndSubclassedCtrl = new CMFCLinkCtrl; + } + else if (strClass == _T("MFCMaskedEdit")) + { + pWndSubclassedCtrl = new CMFCMaskedEdit; + } + else if (strClass == _T("MFCMenuButton")) + { + pWndSubclassedCtrl = new CMFCMenuButton; + } + else if (strClass == _T("MFCPropertyGrid")) + { + pWndSubclassedCtrl = new CMFCPropertyGridCtrl; + } + else if (strClass == _T("MFCShellList")) + { + pWndSubclassedCtrl = new CMFCShellListCtrl; + } + else if (strClass == _T("MFCShellTree")) + { + pWndSubclassedCtrl = new CMFCShellTreeCtrl; + } + else if (strClass == _T("MFCVSListBox")) + { + pWndSubclassedCtrl = new CVSListBox; + } + */ + return pWndSubclassedCtrl; + } + + return NULL; +} + +BOOL CMFCControlContainer::IsSubclassedFeaturePackControl(HWND hWndCtrl) +{ + if (hWndCtrl == NULL) + { + return FALSE; + } + + for (int i = 0; i < m_arSubclassedCtrls.GetCount(); i++) + { + CWnd* pWnd = (CWnd*)m_arSubclassedCtrls[i]; + if (pWnd->GetSafeHwnd() == hWndCtrl) + { + return TRUE; + } + } + + return FALSE; +} + +void CMFCControlContainer::PreUnsubclassControl(CWnd* pControl) +{ + /* + CMFCShellListCtrl* pListCtrl = DYNAMIC_DOWNCAST(CMFCShellListCtrl, pControl); + if (pListCtrl != NULL && pListCtrl->GetHeaderCtrl().GetSafeHwnd() != NULL) + { + pListCtrl->GetHeaderCtrl().UnsubclassWindow(); + } + */ +} + +BOOL CMFCControlContainer::ReSubclassControl(HWND hWndCtrl, WORD nIDC, CWnd& control) +{ + if (hWndCtrl == NULL) + { + return FALSE; + } + + int nIndex = -1; + for (int i = 0; i < m_arSubclassedCtrls.GetCount(); i++) + { + CWnd* pWnd = (CWnd*)m_arSubclassedCtrls [i]; + if (pWnd->GetSafeHwnd() == hWndCtrl) + { + nIndex = i; + break; + } + } + + if (nIndex != -1) + { + CWnd* pWnd = DYNAMIC_DOWNCAST(CWnd, m_arSubclassedCtrls [nIndex]); + + if (pWnd->GetSafeHwnd() != NULL) + { + ASSERT_VALID(pWnd); + + // get init state + DWORD dwSize = 0; + BYTE* pbInitData = NULL; + GetControlData(nIDC, dwSize, pbInitData); + + // Free old subclassed control: + m_arSubclassedCtrls [nIndex] = NULL; + + // unsubclass + PreUnsubclassControl(pWnd); + VERIFY(pWnd->UnsubclassWindow() == hWndCtrl); + // destroy + delete pWnd; + + // subclass + if (!control.SubclassWindow(hWndCtrl)) + { + ASSERT(FALSE); // possibly trying to subclass twice? + AfxThrowNotSupportedException(); + } + + // set init state + if (dwSize > 0) + { + control.SendMessage(WM_MFC_INITCTRL, (WPARAM)dwSize, (LPARAM)pbInitData); + } + + return TRUE; + } + } + + return FALSE; +} + +void CMFCControlContainer::SetControlData(WORD nIDC, DWORD dwSize, BYTE* pbData) +{ + CByteArray* pArray = new CByteArray; + pArray->SetSize(dwSize); + + BYTE* pbBuffer = pArray->GetData(); + if (memcpy_s(pbBuffer, dwSize, pbData, dwSize) != 0) + { + delete pArray; + ASSERT(FALSE); + return; + } + + m_mapControlData.SetAt(nIDC, pArray); +} + +BOOL CMFCControlContainer::GetControlData(WORD nIDC, DWORD& dwSize, BYTE*& pbData) +{ + CObject* pData = NULL; + if (m_mapControlData.Lookup(nIDC, pData) && pData != NULL) + { + CByteArray* pArray = (CByteArray*)pData; + dwSize = (DWORD)pArray->GetSize(); + pbData = pArray->GetData(); + return TRUE; + } + + return FALSE; +} + +void CMFCControlContainer::ClearControlData() +{ + WORD nIDC; + CObject* pData = NULL; + POSITION pos = m_mapControlData.GetStartPosition(); + while (pos != NULL) + { + m_mapControlData.GetNextAssoc(pos, nIDC, pData); + CByteArray* pArray = (CByteArray*)pData; + delete pArray; + } + + m_mapControlData.RemoveAll(); +} + +//////////////////////////////////////////////////////////////////////////// +// Accessing dialog DLGINIT helpers + +int __stdcall CMFCControlContainer::UTF8ToString(LPCSTR lpSrc, CString& strDst, int nLength) +{ + LPTSTR lpDst = NULL; + int count = ::MultiByteToWideChar(CP_UTF8, 0, lpSrc, nLength, NULL, 0); + if (count <= 0) + { + return 0; + } + + LPWSTR lpWide = new WCHAR[count + 1]; + memset(lpWide, 0, (count + 1) * sizeof(WCHAR)); + + ::MultiByteToWideChar(CP_UTF8, 0, lpSrc, nLength, lpWide, count); + +#ifdef _UNICODE + lpDst = lpWide; +#else + count = ::WideCharToMultiByte(::GetACP(), 0, lpWide, -1, NULL, 0, NULL, 0); + + if (count > 0) + { + lpDst = new char[count + 1]; + memset(lpDst, 0, count + 1); + + ::WideCharToMultiByte(::GetACP(), 0, lpWide, -1, lpDst, count, NULL, 0); + } + + delete [] lpWide; +#endif + + strDst = lpDst; + delete[] lpDst; + return count; +} + +BOOL __stdcall CMFCControlContainer::ReadBoolProp(CTagManager& tagManager, LPCTSTR lpszTag, BOOL& bMember) +{ + if (lpszTag == NULL) + { + return FALSE; + } + + CString str; +// tagManager.ExcludeTag(lpszTag, str); + + if (str.IsEmpty()) + { + return FALSE; + } + + bMember = (str.CompareNoCase(PS_True) == 0); + return TRUE; +} diff --git a/Common.win32/vs10fix/afxglobals.cpp b/Common.win32/vs10fix/afxglobals.cpp new file mode 100644 index 0000000..7016d57 --- /dev/null +++ b/Common.win32/vs10fix/afxglobals.cpp @@ -0,0 +1,1409 @@ +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and related +// electronic documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. + +#include "..\stdafx.h" +#include "afxpriv.h" +#include "afxole.h" +#include "..\src\mfc\oleimpl2.h" +#include "..\src\mfc\afximpl.h" +#include "comdef.h" + +//#include "afxcontrolbarutil.h" +#include "afxglobals.h" +/* +#include "afxvisualmanager.h" +#include "afxkeyboardmanager.h" +#include "afxmenuhash.h" +#include "afxtoolbar.h" +#include "afxmenuimages.h" +#include "afxpaneframewnd.h" +#include "afxdockingmanager.h" +#include "afxvisualmanageroffice2007.h" +#include "afxribbonres.h" + +#include "afxframewndex.h" +#include "afxmdiframewndex.h" +#include "afxoleipframewndex.h" +#include "afxoledocipframewndex.h" +#include "afxmdichildwndex.h" +*/ +extern CObList afxAllToolBars; + +BOOL CMemDC::m_bUseMemoryDC = TRUE; + +static const CString strOfficeFontName = _T("Tahoma"); +static const CString strOffice2007FontName = _T("Segoe UI"); +static const CString strDefaultFontName = _T("MS Sans Serif"); +static const CString strVertFontName = _T("Arial"); +static const CString strMarlettFontName = _T("Marlett"); + +CMemDC::CMemDC(CDC& dc, CWnd* pWnd) : + m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL) +{ + ASSERT_VALID(pWnd); + + pWnd->GetClientRect(m_rect); + + m_rect.right += pWnd->GetScrollPos(SB_HORZ); + m_rect.bottom += pWnd->GetScrollPos(SB_VERT); + + if (afxGlobalData.m_pfBeginBufferedPaint != NULL && afxGlobalData.m_pfEndBufferedPaint != NULL) + { + HDC hdcPaint = NULL; + + if (!afxGlobalData.m_bBufferedPaintInited && afxGlobalData.m_pfBufferedPaintInit != NULL && afxGlobalData.m_pfBufferedPaintUnInit != NULL) + { + afxGlobalData.m_pfBufferedPaintInit(); + afxGlobalData.m_bBufferedPaintInited = TRUE; + } + + m_hBufferedPaint = (*afxGlobalData.m_pfBeginBufferedPaint)(dc.GetSafeHdc(), m_rect, AFX_BPBF_TOPDOWNDIB, NULL, &hdcPaint); + + if (m_hBufferedPaint != NULL && hdcPaint != NULL) + { + m_bMemDC = TRUE; + m_dcMem.Attach(hdcPaint); + } + } + else + { + if (m_bUseMemoryDC && m_dcMem.CreateCompatibleDC(&m_dc) && m_bmp.CreateCompatibleBitmap(&m_dc, m_rect.Width(), m_rect.Height())) + { + //------------------------------------------------------------- + // Off-screen DC successfully created. Better paint to it then! + //------------------------------------------------------------- + m_bMemDC = TRUE; + m_pOldBmp = m_dcMem.SelectObject(&m_bmp); + } + } +} + +CMemDC::CMemDC(CDC& dc, const CRect& rect) : + m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL), m_rect(rect) +{ + ASSERT(!m_rect.IsRectEmpty()); + + if (afxGlobalData.m_pfBeginBufferedPaint != NULL && afxGlobalData.m_pfEndBufferedPaint != NULL) + { + HDC hdcPaint = NULL; + + if (!afxGlobalData.m_bBufferedPaintInited && afxGlobalData.m_pfBufferedPaintInit != NULL && afxGlobalData.m_pfBufferedPaintUnInit != NULL) + { + afxGlobalData.m_pfBufferedPaintInit(); + afxGlobalData.m_bBufferedPaintInited = TRUE; + } + + m_hBufferedPaint = (*afxGlobalData.m_pfBeginBufferedPaint)(dc.GetSafeHdc(), m_rect, AFX_BPBF_TOPDOWNDIB, NULL, &hdcPaint); + + if (m_hBufferedPaint != NULL && hdcPaint != NULL) + { + m_bMemDC = TRUE; + m_dcMem.Attach(hdcPaint); + } + } + else + { + if (m_bUseMemoryDC && m_dcMem.CreateCompatibleDC(&m_dc) && m_bmp.CreateCompatibleBitmap(&m_dc, m_rect.Width(), m_rect.Height())) + { + //------------------------------------------------------------- + // Off-screen DC successfully created. Better paint to it then! + //------------------------------------------------------------- + m_bMemDC = TRUE; + m_pOldBmp = m_dcMem.SelectObject(&m_bmp); + } + } +} + +CMemDC::~CMemDC() +{ + if (m_hBufferedPaint != NULL) + { + m_dcMem.Detach(); + (*afxGlobalData.m_pfEndBufferedPaint)(m_hBufferedPaint, TRUE); + } + else if (m_bMemDC) + { + //-------------------------------------- + // Copy the results to the on-screen DC: + //-------------------------------------- + CRect rectClip; + int nClipType = m_dc.GetClipBox(rectClip); + + if (nClipType != NULLREGION) + { + if (nClipType != SIMPLEREGION) + { + rectClip = m_rect; + } + + m_dc.BitBlt(rectClip.left, rectClip.top, rectClip.Width(), rectClip.Height(), &m_dcMem, rectClip.left, rectClip.top, SRCCOPY); + } + + m_dcMem.SelectObject(m_pOldBmp); + } +} + +static int CALLBACK FontFamalyProcFonts(const LOGFONT FAR* lplf, const TEXTMETRIC FAR* /*lptm*/, ULONG /*ulFontType*/, LPARAM lParam) +{ + ENSURE(lplf != NULL); + ENSURE(lParam != NULL); + + CString strFont = lplf->lfFaceName; + return strFont.CollateNoCase((LPCTSTR) lParam) == 0 ? 0 : 1; +} + +///////////////////////////////////////////////////////////////////////////// +// Cached system metrics, etc +AFX_GLOBAL_DATA afxGlobalData; + +// Initialization code +AFX_GLOBAL_DATA::AFX_GLOBAL_DATA() +{ + // Detect the kind of OS: + OSVERSIONINFO osvi; + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + ::GetVersionEx(&osvi); + + bIsRemoteSession = GetSystemMetrics(SM_REMOTESESSION); + + bIsWindowsVista = (osvi.dwMajorVersion >= 6); + bIsWindows7 = (osvi.dwMajorVersion == 6) && (osvi.dwMinorVersion >= 1) || (osvi.dwMajorVersion > 6) ; + bDisableAero = FALSE; + + m_bIsRibbonImageScale = TRUE; + + // Cached system values(updated in CWnd::OnSysColorChange) + hbrBtnShadow = NULL; + hbrBtnHilite = NULL; + hbrWindow = NULL; + + UpdateSysColors(); + + m_hinstUXThemeDLL = ::AfxCtxLoadLibraryW(L"UxTheme.dll"); + if (m_hinstUXThemeDLL != NULL) + { + m_pfDrawThemeBackground = (DRAWTHEMEPARENTBACKGROUND)::GetProcAddress(m_hinstUXThemeDLL, "DrawThemeParentBackground"); + m_pfDrawThemeTextEx = (DRAWTHEMETEXTEX)::GetProcAddress(m_hinstUXThemeDLL, "DrawThemeTextEx"); + + m_pfBufferedPaintInit = (BUFFEREDPAINTINIT)::GetProcAddress(m_hinstUXThemeDLL, "BufferedPaintInit"); + m_pfBufferedPaintUnInit = (BUFFEREDPAINTUNINIT)::GetProcAddress(m_hinstUXThemeDLL, "BufferedPaintUnInit"); + + m_pfBeginBufferedPaint = (BEGINBUFFEREDPAINT)::GetProcAddress(m_hinstUXThemeDLL, "BeginBufferedPaint"); + m_pfEndBufferedPaint = (ENDBUFFEREDPAINT)::GetProcAddress(m_hinstUXThemeDLL, "EndBufferedPaint"); + } + else + { + m_pfDrawThemeBackground = NULL; + m_pfDrawThemeTextEx = NULL; + + m_pfBufferedPaintInit = NULL; + m_pfBufferedPaintUnInit = NULL; + + m_pfBeginBufferedPaint = NULL; + m_pfEndBufferedPaint = NULL; + } + + m_hinstDwmapiDLL = ::AfxCtxLoadLibraryW(L"dwmapi.dll"); + if (m_hinstDwmapiDLL != NULL) + { + m_pfDwmExtendFrameIntoClientArea = (DWMEXTENDFRAMEINTOCLIENTAREA)::GetProcAddress(m_hinstDwmapiDLL, "DwmExtendFrameIntoClientArea"); + m_pfDwmDefWindowProc = (DWMDEFWINDOWPROC) ::GetProcAddress(m_hinstDwmapiDLL, "DwmDefWindowProc"); + m_pfDwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED)::GetProcAddress(m_hinstDwmapiDLL, "DwmIsCompositionEnabled"); + } + else + { + m_pfDwmExtendFrameIntoClientArea = NULL; + m_pfDwmDefWindowProc = NULL; + m_pfDwmIsCompositionEnabled = NULL; + } + + m_hcurStretch = NULL; + m_hcurStretchVert = NULL; + m_hcurHand = NULL; + m_hcurSizeAll = NULL; + m_hiconTool = NULL; + m_hiconLink = NULL; + m_hiconColors = NULL; + m_hcurMoveTab = NULL; + m_hcurNoMoveTab = NULL; + + m_bUseSystemFont = FALSE; + m_bInSettingChange = FALSE; + + UpdateFonts(); + OnSettingChange(); + + m_bIsRTL = FALSE; + m_bBufferedPaintInited = FALSE; + + m_nDragFrameThicknessFloat = 4; // pixels + m_nDragFrameThicknessDock = 3; // pixels + + m_nAutoHideToolBarSpacing = 14; // pixels + m_nAutoHideToolBarMargin = 4; // pixels + + m_nCoveredMainWndClientAreaPercent = 50; // percents + + m_nMaxToolTipWidth = -1; + m_bIsBlackHighContrast = FALSE; + m_bIsWhiteHighContrast = FALSE; + + m_bUseBuiltIn32BitIcons = TRUE; +/* + m_bComInitialized = FALSE; + + m_pTaskbarList = NULL; + m_pTaskbarList3 = NULL; + m_bTaskBarInterfacesAvailable = TRUE; + */ + EnableAccessibilitySupport(); +} + +AFX_GLOBAL_DATA::~AFX_GLOBAL_DATA() +{ + CleanUp(); +} + +void AFX_GLOBAL_DATA::UpdateFonts() +{ + CWindowDC dc(NULL); + m_dblRibbonImageScale = dc.GetDeviceCaps(LOGPIXELSX) / 96.0f; + + if (m_dblRibbonImageScale > 1. && m_dblRibbonImageScale < 1.1) + { + m_dblRibbonImageScale = 1.; + } + + if (fontRegular.GetSafeHandle() != NULL) + { + ::DeleteObject(fontRegular.Detach()); + } + + if (fontTooltip.GetSafeHandle() != NULL) + { + ::DeleteObject(fontTooltip.Detach()); + } + + if (fontBold.GetSafeHandle() != NULL) + { + ::DeleteObject(fontBold.Detach()); + } + + if (fontDefaultGUIBold.GetSafeHandle() != NULL) + { + ::DeleteObject(fontDefaultGUIBold.Detach()); + } + + if (fontUnderline.GetSafeHandle() != NULL) + { + ::DeleteObject(fontUnderline.Detach()); + } + + if (fontDefaultGUIUnderline.GetSafeHandle() != NULL) + { + ::DeleteObject(fontDefaultGUIUnderline.Detach()); + } + + if (fontVert.GetSafeHandle() != NULL) + { + ::DeleteObject(fontVert.Detach()); + } + + if (fontVertCaption.GetSafeHandle() != NULL) + { + ::DeleteObject(fontVertCaption.Detach()); + } + + if (fontMarlett.GetSafeHandle() != NULL) + { + ::DeleteObject(fontMarlett.Detach()); + } + + if (fontSmall.GetSafeHandle() != NULL) + { + ::DeleteObject(fontSmall.Detach()); + } + + // Initialize fonts: + + NONCLIENTMETRICS info; + GetNonClientMetrics (info); + + LOGFONT lf; + memset(&lf, 0, sizeof(LOGFONT)); + + lf.lfCharSet = (BYTE) GetTextCharsetInfo(dc.GetSafeHdc(), NULL, 0); + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + //------------------ + // Adjust font size: + //------------------ + int nFontHeight = lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight; + if (nFontHeight <= 12) + { + nFontHeight = 11; + } + else + { + nFontHeight--; + } + + lf.lfHeight = (lf.lfHeight < 0) ? -nFontHeight : nFontHeight; + + // Check if we should use system font + lstrcpy(lf.lfFaceName, info.lfMenuFont.lfFaceName); + + BOOL fUseSystemFont = m_bUseSystemFont || (info.lfMenuFont.lfCharSet > SYMBOL_CHARSET); + if (!fUseSystemFont) + { + // Check for "Segoe UI" or "Tahoma" font existance: + if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamalyProcFonts, (LPARAM)(LPCTSTR) strOffice2007FontName) == 0) + { + // Found! Use MS Office 2007 font! + lstrcpy(lf.lfFaceName, strOffice2007FontName); + lf.lfQuality = 5 /*CLEARTYPE_QUALITY*/; + } + else if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamalyProcFonts, (LPARAM)(LPCTSTR) strOfficeFontName) == 0) + { + // Found! Use MS Office font! + lstrcpy(lf.lfFaceName, strOfficeFontName); + } + else + { + // Not found. Use default font: + lstrcpy(lf.lfFaceName, strDefaultFontName); + } + } + + fontRegular.CreateFontIndirect(&lf); + + // Create small font: + LONG lfHeightSaved = lf.lfHeight; + + lf.lfHeight = (long)((1. + abs(lf.lfHeight)) * 2 / 3); + if (lfHeightSaved < 0) + { + lf.lfHeight = -lf.lfHeight; + } + + fontSmall.CreateFontIndirect(&lf); + lf.lfHeight = lfHeightSaved; + + // Create tooltip font: + NONCLIENTMETRICS ncm; + GetNonClientMetrics (ncm); + + lf.lfItalic = ncm.lfStatusFont.lfItalic; + lf.lfWeight = ncm.lfStatusFont.lfWeight; + fontTooltip.CreateFontIndirect(&lf); + + lf.lfItalic = info.lfMenuFont.lfItalic; + lf.lfWeight = info.lfMenuFont.lfWeight; + + // Create "underline" font: + lf.lfUnderline = TRUE; + fontUnderline.CreateFontIndirect(&lf); + lf.lfUnderline = FALSE; + + // Create bold font: + lf.lfWeight = FW_BOLD; + fontBold.CreateFontIndirect(&lf); + + // Create Marlett font: + BYTE bCharSet = lf.lfCharSet; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfCharSet = SYMBOL_CHARSET; + lf.lfWeight = 0; + lf.lfHeight = ::GetSystemMetrics(SM_CYMENUCHECK) - 1; + lstrcpy(lf.lfFaceName, strMarlettFontName); + + fontMarlett.CreateFontIndirect(&lf); + lf.lfCharSet = bCharSet; // Restore charset + + // Create vertical font: + CFont font; + if (font.CreateStockObject(DEFAULT_GUI_FONT)) + { + if (font.GetLogFont(&lf) != 0) + { + lf.lfOrientation = 900; + lf.lfEscapement = 2700; + + lf.lfHeight = info.lfMenuFont.lfHeight; + lf.lfWeight = info.lfMenuFont.lfWeight; + lf.lfItalic = info.lfMenuFont.lfItalic; + + { + lstrcpy(lf.lfFaceName, strVertFontName); + } + + fontVert.CreateFontIndirect(&lf); + + lf.lfEscapement = 900; + fontVertCaption.CreateFontIndirect(&lf); + } + } + + // Create dialog underline and bold fonts: + CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); + ASSERT_VALID(pDefaultGUIFont); + pDefaultGUIFont->GetLogFont(&lf); + + lf.lfUnderline = TRUE; + fontDefaultGUIUnderline.CreateFontIndirect(&lf); + lf.lfUnderline = FALSE; + + lf.lfWeight = FW_BOLD; + fontDefaultGUIBold.CreateFontIndirect(&lf); + + UpdateTextMetrics(); + + /* + // Notify toolbars about font changing: + for (POSITION posTlb = afxAllToolBars.GetHeadPosition(); posTlb != NULL;) + { + CMFCToolBar* pToolBar = (CMFCToolBar*) afxAllToolBars.GetNext(posTlb); + ENSURE(pToolBar != NULL); + + if (CWnd::FromHandlePermanent(pToolBar->m_hWnd) != NULL) + { + ASSERT_VALID(pToolBar); + pToolBar->OnGlobalFontsChanged(); + } + } + */ +} + +static BOOL CALLBACK InfoEnumProc( HMONITOR hMonitor, HDC /*hdcMonitor*/, LPRECT /*lprcMonitor*/, LPARAM dwData) +{ + CRect* pRect = (CRect*) dwData; + + MONITORINFO mi; + mi.cbSize = sizeof(MONITORINFO); + + if (GetMonitorInfo(hMonitor, &mi)) + { + CRect rectMon = mi.rcWork; + + pRect->left = min(pRect->left, rectMon.left); + pRect->right = max(pRect->right, rectMon.right); + pRect->top = min(pRect->top, rectMon.top); + pRect->bottom = max(pRect->bottom, rectMon.bottom); + } + + return TRUE; +} + +void AFX_GLOBAL_DATA::OnSettingChange() +{ + m_bInSettingChange = TRUE; + + m_sizeSmallIcon.cx = ::GetSystemMetrics(SM_CXSMICON); + m_sizeSmallIcon.cy = ::GetSystemMetrics(SM_CYSMICON); + + m_rectVirtual.SetRectEmpty(); + + if (!EnumDisplayMonitors(NULL, NULL, InfoEnumProc, (LPARAM) &m_rectVirtual)) + { + ::SystemParametersInfo(SPI_GETWORKAREA, 0, &m_rectVirtual, 0); + } + + // Get system menu animation type: + m_bMenuAnimation = FALSE; + m_bMenuFadeEffect = FALSE; + + if (!bIsRemoteSession) + { + ::SystemParametersInfo(SPI_GETMENUANIMATION, 0, &m_bMenuAnimation, 0); + + if (m_bMenuAnimation) + { + ::SystemParametersInfo(SPI_GETMENUFADE, 0, &m_bMenuFadeEffect, 0); + } + } + + m_nShellAutohideBars = 0; + m_bRefreshAutohideBars = TRUE; + + ::SystemParametersInfo(SPI_GETMENUUNDERLINES, 0, &m_bSysUnderlineKeyboardShortcuts, 0); + m_bUnderlineKeyboardShortcuts = m_bSysUnderlineKeyboardShortcuts; + + m_bInSettingChange = FALSE; +} + +void AFX_GLOBAL_DATA::UpdateSysColors() +{ + m_bIsBlackHighContrast = ::GetSysColor(COLOR_3DLIGHT) == RGB(255, 255, 255) && ::GetSysColor(COLOR_3DFACE) == RGB(0, 0, 0); + m_bIsWhiteHighContrast = ::GetSysColor(COLOR_3DDKSHADOW) == RGB(0, 0, 0) && ::GetSysColor(COLOR_3DFACE) == RGB(255, 255, 255); + + CWindowDC dc(NULL); + m_nBitsPerPixel = dc.GetDeviceCaps(BITSPIXEL); + + clrBarFace = clrBtnFace = ::GetSysColor(COLOR_BTNFACE); + clrBarShadow = clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW); + clrBarDkShadow = clrBtnDkShadow = ::GetSysColor(COLOR_3DDKSHADOW); + clrBarLight = clrBtnLight = ::GetSysColor(COLOR_3DLIGHT); + clrBarHilite = clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT); + clrBarText = clrBtnText = ::GetSysColor(COLOR_BTNTEXT); + clrGrayedText = ::GetSysColor(COLOR_GRAYTEXT); + clrWindowFrame = ::GetSysColor(COLOR_WINDOWFRAME); + + clrHilite = ::GetSysColor(COLOR_HIGHLIGHT); + clrTextHilite = ::GetSysColor(COLOR_HIGHLIGHTTEXT); + + clrBarWindow = clrWindow = ::GetSysColor(COLOR_WINDOW); + clrWindowText = ::GetSysColor(COLOR_WINDOWTEXT); + + clrCaptionText = ::GetSysColor(COLOR_CAPTIONTEXT); + clrMenuText = ::GetSysColor(COLOR_MENUTEXT); + + clrActiveCaption = ::GetSysColor(COLOR_ACTIVECAPTION); + clrInactiveCaption = ::GetSysColor(COLOR_INACTIVECAPTION); + + clrActiveCaptionGradient = ::GetSysColor(COLOR_GRADIENTACTIVECAPTION); + clrInactiveCaptionGradient = ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION); + + clrActiveBorder = ::GetSysColor(COLOR_ACTIVEBORDER); + clrInactiveBorder = ::GetSysColor(COLOR_INACTIVEBORDER); + + clrInactiveCaptionText = ::GetSysColor(COLOR_INACTIVECAPTIONTEXT); + + if (m_bIsBlackHighContrast) + { + clrHotLinkNormalText = clrWindowText; + clrHotLinkHoveredText = clrWindowText; + clrHotLinkVisitedText = clrWindowText; + } + else + { + clrHotLinkNormalText = ::GetSysColor(COLOR_HOTLIGHT); + clrHotLinkHoveredText = RGB(0, 0, 255); // Bright blue + clrHotLinkVisitedText = RGB(128, 0, 128); // Violet + } + + hbrBtnShadow = ::GetSysColorBrush(COLOR_BTNSHADOW); + ENSURE(hbrBtnShadow != NULL); + + hbrBtnHilite = ::GetSysColorBrush(COLOR_BTNHIGHLIGHT); + ENSURE(hbrBtnHilite != NULL); + + hbrWindow = ::GetSysColorBrush(COLOR_WINDOW); + ENSURE(hbrWindow != NULL); + + brBtnFace.DeleteObject(); + brBtnFace.CreateSolidBrush(clrBtnFace); + + brBarFace.DeleteObject(); + brBarFace.CreateSolidBrush(clrBarFace); + + brActiveCaption.DeleteObject(); + brActiveCaption.CreateSolidBrush(clrActiveCaption); + + brInactiveCaption.DeleteObject(); + brInactiveCaption.CreateSolidBrush(clrInactiveCaption); + + brHilite.DeleteObject(); + brHilite.CreateSolidBrush(clrHilite); + + brBlack.DeleteObject(); + brBlack.CreateSolidBrush(clrBtnDkShadow); + + brWindow.DeleteObject(); + brWindow.CreateSolidBrush(clrWindow); + + penHilite.DeleteObject(); + penHilite.CreatePen(PS_SOLID, 1, afxGlobalData.clrHilite); + + penBarFace.DeleteObject(); + penBarFace.CreatePen(PS_SOLID, 1, afxGlobalData.clrBarFace); + + penBarShadow.DeleteObject(); + penBarShadow.CreatePen(PS_SOLID, 1, afxGlobalData.clrBarShadow); + + if (brLight.GetSafeHandle()) + { + brLight.DeleteObject(); + } + + if (m_nBitsPerPixel > 8) + { + COLORREF clrLight = RGB(GetRValue(clrBtnFace) +((GetRValue(clrBtnHilite) - GetRValue(clrBtnFace)) / 2 ), + GetGValue(clrBtnFace) +((GetGValue(clrBtnHilite) - GetGValue(clrBtnFace)) / 2), + GetBValue(clrBtnFace) +((GetBValue(clrBtnHilite) - GetBValue(clrBtnFace)) / 2)); + + brLight.CreateSolidBrush(clrLight); + } + else + { + HBITMAP hbmGray = CreateDitherBitmap(dc.GetSafeHdc()); + ENSURE(hbmGray != NULL); + + CBitmap bmp; + bmp.Attach(hbmGray); + + brLight.CreatePatternBrush(&bmp); + } + +// CMenuImages::CleanUp(); +// CDockingManager::m_bSDParamsModified = TRUE; +} + +BOOL AFX_GLOBAL_DATA::SetMenuFont(LPLOGFONT lpLogFont, BOOL bHorz) +{ + ENSURE(lpLogFont != NULL); + + if (bHorz) + { + // Create regular font: + fontRegular.DeleteObject(); + if (!fontRegular.CreateFontIndirect(lpLogFont)) + { + ASSERT(FALSE); + return FALSE; + } + + // Create underline font: + lpLogFont->lfUnderline = TRUE; + fontUnderline.DeleteObject(); + fontUnderline.CreateFontIndirect(lpLogFont); + lpLogFont->lfUnderline = FALSE; + + // Create bold font(used in the default menu items): + long lSavedWeight = lpLogFont->lfWeight; + lpLogFont->lfWeight = 700; + + fontBold.DeleteObject(); + BOOL bResult = fontBold.CreateFontIndirect(lpLogFont); + + lpLogFont->lfWeight = lSavedWeight; // Restore weight + + if (!bResult) + { + ASSERT(FALSE); + return FALSE; + } + } + else // Vertical font + { + fontVert.DeleteObject(); + if (!fontVert.CreateFontIndirect(lpLogFont)) + { + ASSERT(FALSE); + return FALSE; + } + } + + UpdateTextMetrics(); + return TRUE; +} + +void AFX_GLOBAL_DATA::UpdateTextMetrics() +{ + CWindowDC dc(NULL); + + CFont* pOldFont = dc.SelectObject(&fontRegular); + ENSURE(pOldFont != NULL); + + TEXTMETRIC tm; + dc.GetTextMetrics(&tm); + + int nExtra = tm.tmHeight < 15 ? 2 : 5; + + m_nTextHeightHorz = tm.tmHeight + nExtra; + m_nTextWidthHorz = tm.tmMaxCharWidth + nExtra; + + dc.SelectObject(&fontVert); + dc.GetTextMetrics(&tm); + + nExtra = tm.tmHeight < 15 ? 2 : 5; + + m_nTextHeightVert = tm.tmHeight + nExtra; + m_nTextWidthVert = tm.tmMaxCharWidth + nExtra; + + dc.SelectObject(pOldFont); +} + +HBITMAP AFX_GLOBAL_DATA::CreateDitherBitmap(HDC hDC) +{ + struct // BITMAPINFO with 16 colors + { + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[16]; + } + bmi; + memset(&bmi, 0, sizeof(bmi)); + + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = 8; + bmi.bmiHeader.biHeight = 8; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 1; + bmi.bmiHeader.biCompression = BI_RGB; + + COLORREF clr = afxGlobalData.clrBtnFace; + + bmi.bmiColors[0].rgbBlue = GetBValue(clr); + bmi.bmiColors[0].rgbGreen = GetGValue(clr); + bmi.bmiColors[0].rgbRed = GetRValue(clr); + + clr = ::GetSysColor(COLOR_BTNHIGHLIGHT); + bmi.bmiColors[1].rgbBlue = GetBValue(clr); + bmi.bmiColors[1].rgbGreen = GetGValue(clr); + bmi.bmiColors[1].rgbRed = GetRValue(clr); + + // initialize the brushes + long patGray[8]; + for (int i = 0; i < 8; i++) + patGray[i] = (i & 1) ? 0xAAAA5555L : 0x5555AAAAL; + + HBITMAP hbm = CreateDIBitmap(hDC, &bmi.bmiHeader, CBM_INIT, (LPBYTE)patGray, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS); + return hbm; +} + +#if (WINVER >= 0x0601) +ITaskbarList* AFX_GLOBAL_DATA::GetITaskbarList() +{ + HRESULT hr = S_OK; + + if (!bIsWindows7 || !m_bTaskBarInterfacesAvailable) + { + return NULL; + } + + if (m_pTaskbarList != NULL) + { + return m_pTaskbarList; + } + + if (!m_bComInitialized) + { + hr = CoInitialize(NULL); + if (SUCCEEDED(hr)) + { + m_bComInitialized = TRUE; + } + } + + if (SUCCEEDED(hr)) + { + hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList)); + } + + ASSERT(SUCCEEDED(hr)); + return m_pTaskbarList; +} + +ITaskbarList3* AFX_GLOBAL_DATA::GetITaskbarList3() +{ + HRESULT hr = S_OK; + + if (!bIsWindows7 || !m_bTaskBarInterfacesAvailable) + { + return NULL; + } + + if (m_pTaskbarList3 != NULL) + { + return m_pTaskbarList3; + } + + if (!m_bComInitialized) + { + hr = CoInitialize(NULL); + if (SUCCEEDED(hr)) + { + m_bComInitialized = TRUE; + } + } + + if (SUCCEEDED(hr)) + { + hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList3)); + } + + ASSERT(SUCCEEDED(hr)); + return m_pTaskbarList3; +} + +void AFX_GLOBAL_DATA::ReleaseTaskBarRefs() +{ + m_bTaskBarInterfacesAvailable = FALSE; + + if (m_pTaskbarList != NULL) + { + RELEASE(m_pTaskbarList); + m_pTaskbarList = NULL; + } + + if (m_pTaskbarList3 != NULL) + { + RELEASE(m_pTaskbarList3); + m_pTaskbarList3 = NULL; + } + + if (m_bComInitialized) + { + CoUninitialize(); + m_bComInitialized = FALSE; + } +} +#endif + +void AFX_GLOBAL_DATA::CleanUp() +{ + if (brLight.GetSafeHandle()) + { + brLight.DeleteObject(); + } + + // cleanup fonts: + fontRegular.DeleteObject(); + fontBold.DeleteObject(); + fontUnderline.DeleteObject(); + fontVert.DeleteObject(); + fontVertCaption.DeleteObject(); + fontTooltip.DeleteObject(); + +// ReleaseTaskBarRefs(); + + if (m_bBufferedPaintInited && m_pfBufferedPaintUnInit != NULL) + { + m_pfBufferedPaintUnInit(); + m_bBufferedPaintInited = FALSE; + } + + if (m_hinstUXThemeDLL != NULL) + { + ::FreeLibrary(m_hinstUXThemeDLL); + m_hinstUXThemeDLL = NULL; + } + + if (m_hinstDwmapiDLL != NULL) + { + ::FreeLibrary(m_hinstDwmapiDLL); + m_hinstDwmapiDLL = NULL; + } + + m_bEnableAccessibility = FALSE; +} + +void ControlBarCleanUp() +{ + afxGlobalData.CleanUp(); + + /* + afxMenuHash.CleanUp(); + + CMFCToolBar::CleanUpImages(); + CMenuImages::CleanUp(); + + if (GetCmdMgr() != NULL) + { + GetCmdMgr()->CleanUp(); + } + + CKeyboardManager::CleanUp(); + + // Destroy visualization manager: + CMFCVisualManager::DestroyInstance(TRUE ); // bAutoDestroyOnly + CMFCVisualManagerOffice2007::CleanStyle(); + */ +} + +BOOL AFX_GLOBAL_DATA::DrawParentBackground(CWnd* pWnd, CDC* pDC, LPRECT rectClip) +{ + ASSERT_VALID(pDC); + ASSERT_VALID(pWnd); + + BOOL bRes = FALSE; + + CRgn rgn; + if (rectClip != NULL) + { + rgn.CreateRectRgnIndirect(rectClip); + pDC->SelectClipRgn(&rgn); + } + + CWnd* pParent = pWnd->GetParent(); + ASSERT_VALID(pParent); + + // In Windows XP, we need to call DrawThemeParentBackground function to implement + // transparent controls + if (m_pfDrawThemeBackground != NULL) + { + bRes = (*m_pfDrawThemeBackground)(pWnd->GetSafeHwnd(), pDC->GetSafeHdc(), rectClip) == S_OK; + } + + if (!bRes) + { + CPoint pt(0, 0); + pWnd->MapWindowPoints(pParent, &pt, 1); + pt = pDC->OffsetWindowOrg(pt.x, pt.y); + + bRes = (BOOL) pParent->SendMessage(WM_ERASEBKGND, (WPARAM)pDC->m_hDC); + + pDC->SetWindowOrg(pt.x, pt.y); + } + + pDC->SelectClipRgn(NULL); + + return bRes; +} + +CFrameWnd* AFXGetParentFrame(const CWnd* pWnd) +{ + if (pWnd->GetSafeHwnd() == NULL) + { + return NULL; + } + ASSERT_VALID(pWnd); + + const CWnd* pParentWnd = pWnd; + + while (pParentWnd != NULL) + { + /* + if (pParentWnd->IsKindOf(RUNTIME_CLASS(CPaneFrameWnd))) + { + CPaneFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST(CPaneFrameWnd, pParentWnd); + pParentWnd = pMiniFrame->GetParent(); + } + else + */ + { + pParentWnd = pParentWnd->GetParent(); + } + + if (pParentWnd == NULL) + { + return NULL; + } + + if (pParentWnd->IsFrameWnd()) + { + return(CFrameWnd*)pParentWnd; + } + } + + return NULL; +} + +COLORREF AFX_GLOBAL_DATA::GetColor(int nColor) +{ + switch(nColor) + { + case COLOR_BTNFACE: return clrBtnFace; + case COLOR_BTNSHADOW: return clrBtnShadow; + case COLOR_3DDKSHADOW: return clrBtnDkShadow; + case COLOR_3DLIGHT: return clrBtnLight; + case COLOR_BTNHIGHLIGHT: return clrBtnHilite; + case COLOR_BTNTEXT: return clrBtnText; + case COLOR_GRAYTEXT: return clrGrayedText; + case COLOR_WINDOWFRAME: return clrWindowFrame; + + case COLOR_HIGHLIGHT: return clrHilite; + case COLOR_HIGHLIGHTTEXT: return clrTextHilite; + + case COLOR_WINDOW: return clrWindow; + case COLOR_WINDOWTEXT: return clrWindowText; + + case COLOR_CAPTIONTEXT: return clrCaptionText; + case COLOR_MENUTEXT: return clrMenuText; + + case COLOR_ACTIVECAPTION: return clrActiveCaption; + case COLOR_INACTIVECAPTION: return clrInactiveCaption; + + case COLOR_ACTIVEBORDER: return clrActiveBorder; + case COLOR_INACTIVEBORDER: return clrInactiveBorder; + + case COLOR_INACTIVECAPTIONTEXT: return clrInactiveCaptionText; + } + + return ::GetSysColor(nColor); +} + +BOOL AFX_GLOBAL_DATA::SetLayeredAttrib(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags) +{ + return(::SetLayeredWindowAttributes(hwnd, crKey, bAlpha, dwFlags)); +} + +void AFX_GLOBAL_DATA::EnableAccessibilitySupport(BOOL bEnable/* = TRUE*/) +{ + m_bEnableAccessibility = bEnable; +} + +CString AFX_GLOBAL_DATA::RegisterWindowClass(LPCTSTR lpszClassNamePrefix) +{ + ENSURE(lpszClassNamePrefix != NULL); + + // Register a new window class: + HINSTANCE hInst = AfxGetInstanceHandle(); + UINT uiClassStyle = CS_DBLCLKS; + HCURSOR hCursor = ::LoadCursor(NULL, IDC_ARROW); + HBRUSH hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + + CString strClassName; + strClassName.Format(_T("%s:%x:%x:%x:%x"), lpszClassNamePrefix, (UINT_PTR)hInst, uiClassStyle, (UINT_PTR)hCursor, (UINT_PTR)hbrBackground); + + // See if the class already exists: + WNDCLASS wndcls; + if (::GetClassInfo(hInst, strClassName, &wndcls)) + { + // Already registered, assert everything is good: + ASSERT(wndcls.style == uiClassStyle); + } + else + { + // Otherwise we need to register a new class: + wndcls.style = uiClassStyle; + wndcls.lpfnWndProc = ::DefWindowProc; + wndcls.cbClsExtra = wndcls.cbWndExtra = 0; + wndcls.hInstance = hInst; + wndcls.hIcon = NULL; + wndcls.hCursor = hCursor; + wndcls.hbrBackground = hbrBackground; + wndcls.lpszMenuName = NULL; + wndcls.lpszClassName = strClassName; + + if (!AfxRegisterClass(&wndcls)) + { + AfxThrowResourceException(); + } + } + + return strClassName; +} + +BOOL AFX_GLOBAL_DATA::ExcludeTag(CString& strBuffer, LPCTSTR lpszTag, CString& strTag, BOOL bIsCharsList /* = FALSE*/) +{ + const int iBufLen = strBuffer.GetLength(); + + CString strTagStart = _T("<"); + strTagStart += lpszTag; + strTagStart += _T(">"); + + const int iTagStartLen = strTagStart.GetLength(); + + int iStart = -1; + + int iIndexStart = strBuffer.Find(strTagStart); + if (iIndexStart < 0) + { + return FALSE; + } + + iStart = iIndexStart + iTagStartLen; + + CString strTagEnd = _T("'); + + const int iTagEndLen = strTagEnd.GetLength(); + + int iIndexEnd = -1; + int nBalanse = 1; + for (int i = iStart; i < iBufLen - iTagEndLen + 1; i ++) + { + if (strBuffer [i] != '<') + { + continue; + } + + if (i < iBufLen - iTagStartLen && _tcsncmp(strBuffer.Mid(i), strTagStart, iTagStartLen) == 0) + { + i += iTagStartLen - 1; + nBalanse ++; + continue; + } + + if (_tcsncmp(strBuffer.Mid(i), strTagEnd, iTagEndLen) == 0) + { + nBalanse --; + if (nBalanse == 0) + { + iIndexEnd = i; + break; + } + + i += iTagEndLen - 1; + } + } + + if (iIndexEnd == -1 || iStart > iIndexEnd) + { + return FALSE; + } + + strTag = strBuffer.Mid(iStart, iIndexEnd - iStart); + strTag.TrimLeft(); + strTag.TrimRight(); + + strBuffer.Delete(iIndexStart, iIndexEnd + iTagEndLen - iIndexStart); + + if (bIsCharsList) + { + if (strTag.GetLength() > 1 && strTag [0] == _T('\"')) + { + strTag = strTag.Mid(1, strTag.GetLength() - 2); + } + + strTag.Replace(_T("\\t"), _T("\t")); + strTag.Replace(_T("\\n"), _T("\n")); + strTag.Replace(_T("\\r"), _T("\r")); + strTag.Replace(_T("\\b"), _T("\b")); + strTag.Replace(_T("LT"), _T("<")); + strTag.Replace(_T("GT"), _T(">")); + strTag.Replace(_T("AMP"), _T("&")); + } + + return TRUE; +} + +BOOL AFX_GLOBAL_DATA::DwmExtendFrameIntoClientArea(HWND hWnd, AFX_MARGINS* pMargins) +{ + if (m_pfDwmExtendFrameIntoClientArea == NULL) + { + return FALSE; + } + + HRESULT hres = (*m_pfDwmExtendFrameIntoClientArea)(hWnd, pMargins); + return hres == S_OK; +} + +LRESULT AFX_GLOBAL_DATA::DwmDefWindowProc(HWND hWnd, UINT message, WPARAM wp, LPARAM lp) +{ + if (m_pfDwmDefWindowProc == NULL) + { + return(LRESULT)-1; + } + + LRESULT lres = 0; + (*m_pfDwmDefWindowProc)(hWnd, message, wp, lp, &lres); + + return lres; +} + +BOOL AFX_GLOBAL_DATA::DwmIsCompositionEnabled() +{ + if (m_pfDwmIsCompositionEnabled == NULL || bDisableAero) + { + return FALSE; + } + + BOOL bEnabled = FALSE; + + (*m_pfDwmIsCompositionEnabled)(&bEnabled); + return bEnabled; +} + +BOOL AFX_GLOBAL_DATA::DrawTextOnGlass(HTHEME hTheme, CDC* pDC, int iPartId, int iStateId, CString strText, CRect rect, DWORD dwFlags, int nGlowSize, COLORREF clrText) +{ + //---- bits used in dwFlags of DTTOPTS ---- +#define AFX_DTT_TEXTCOLOR (1UL << 0) // crText has been specified +#define AFX_DTT_BORDERCOLOR (1UL << 1) // crBorder has been specified +#define AFX_DTT_SHADOWCOLOR (1UL << 2) // crShadow has been specified +#define AFX_DTT_SHADOWTYPE (1UL << 3) // iTextShadowType has been specified +#define AFX_DTT_SHADOWOFFSET (1UL << 4) // ptShadowOffset has been specified +#define AFX_DTT_BORDERSIZE (1UL << 5) // nBorderSize has been specified +#define AFX_DTT_FONTPROP (1UL << 6) // iFontPropId has been specified +#define AFX_DTT_COLORPROP (1UL << 7) // iColorPropId has been specified +#define AFX_DTT_STATEID (1UL << 8) // IStateId has been specified +#define AFX_DTT_CALCRECT (1UL << 9) // Use pRect as and in/out parameter +#define AFX_DTT_APPLYOVERLAY (1UL << 10) // fApplyOverlay has been specified +#define AFX_DTT_GLOWSIZE (1UL << 11) // iGlowSize has been specified +#define AFX_DTT_CALLBACK (1UL << 12) // pfnDrawTextCallback has been specified +#define AFX_DTT_COMPOSITED (1UL << 13) // Draws text with antialiased alpha(needs a DIB section) + + if (hTheme == NULL || m_pfDrawThemeTextEx == NULL || !DwmIsCompositionEnabled()) + { + pDC->DrawText(strText, rect, dwFlags); + return FALSE; + } + + CComBSTR bstmp = (LPCTSTR)strText; + + wchar_t* wbuf = new wchar_t[bstmp.Length() + 1]; + wcscpy_s(wbuf, bstmp.Length() + 1, bstmp); + + AFX_DTTOPTS dto; + memset(&dto, 0, sizeof(AFX_DTTOPTS)); + dto.dwSize = sizeof(AFX_DTTOPTS); + dto.dwFlags = AFX_DTT_COMPOSITED; + + if (nGlowSize > 0) + { + dto.dwFlags |= AFX_DTT_GLOWSIZE; + dto.iGlowSize = nGlowSize; + } + + if (clrText != (COLORREF)-1) + { + dto.dwFlags |= AFX_DTT_TEXTCOLOR; + dto.crText = clrText; + } + + (*m_pfDrawThemeTextEx)(hTheme, pDC->GetSafeHdc(), iPartId, iStateId, wbuf, -1, dwFlags, rect, &dto); + + delete [] wbuf; + + return TRUE; +} + +HCURSOR AFX_GLOBAL_DATA::GetHandCursor() +{ + if (m_hcurHand == NULL) + { + m_hcurHand = ::LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_HAND)); + } + + return m_hcurHand; +} + +BOOL AFX_GLOBAL_DATA::Resume() +{ + m_hinstUXThemeDLL = ::AfxCtxLoadLibraryW(L"UxTheme.dll"); + + if (m_hinstUXThemeDLL != NULL) + { + m_pfDrawThemeBackground = (DRAWTHEMEPARENTBACKGROUND)::GetProcAddress (m_hinstUXThemeDLL, "DrawThemeParentBackground"); + m_pfDrawThemeTextEx = (DRAWTHEMETEXTEX)::GetProcAddress (m_hinstUXThemeDLL, "DrawThemeTextEx"); + m_pfBeginBufferedPaint = (BEGINBUFFEREDPAINT)::GetProcAddress (m_hinstUXThemeDLL, "BeginBufferedPaint"); + m_pfEndBufferedPaint = (ENDBUFFEREDPAINT)::GetProcAddress (m_hinstUXThemeDLL, "EndBufferedPaint"); + } + else + { + m_pfDrawThemeBackground = NULL; + m_pfDrawThemeTextEx = NULL; + m_pfBeginBufferedPaint = NULL; + m_pfEndBufferedPaint = NULL; + } + + if (m_hinstDwmapiDLL != NULL) + { + m_hinstDwmapiDLL = ::AfxCtxLoadLibraryW(L"dwmapi.dll"); + ENSURE(m_hinstDwmapiDLL != NULL); + + m_pfDwmExtendFrameIntoClientArea = (DWMEXTENDFRAMEINTOCLIENTAREA)::GetProcAddress (m_hinstDwmapiDLL, "DwmExtendFrameIntoClientArea"); + m_pfDwmDefWindowProc = (DWMDEFWINDOWPROC) ::GetProcAddress (m_hinstDwmapiDLL, "DwmDefWindowProc"); + m_pfDwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED)::GetProcAddress (m_hinstDwmapiDLL, "DwmIsCompositionEnabled"); + } + + if (m_bEnableAccessibility) + { + EnableAccessibilitySupport(); + } + /* + CMFCVisualManagerOffice2007::CleanStyle (); + + if (CMFCVisualManager::m_pRTIDefault != NULL) + { + CMFCVisualManager::SetDefaultManager (CMFCVisualManager::m_pRTIDefault); + } + */ + return TRUE; +} + +BOOL AFX_GLOBAL_DATA::GetNonClientMetrics (NONCLIENTMETRICS& info) +{ + struct AFX_OLDNONCLIENTMETRICS + { + UINT cbSize; + int iBorderWidth; + int iScrollWidth; + int iScrollHeight; + int iCaptionWidth; + int iCaptionHeight; + LOGFONT lfCaptionFont; + int iSmCaptionWidth; + int iSmCaptionHeight; + LOGFONT lfSmCaptionFont; + int iMenuWidth; + int iMenuHeight; + LOGFONT lfMenuFont; + LOGFONT lfStatusFont; + LOGFONT lfMessageFont; + }; + + const UINT cbProperSize = (_AfxGetComCtlVersion() < MAKELONG(1, 6)) + ? sizeof(AFX_OLDNONCLIENTMETRICS) : sizeof(NONCLIENTMETRICS); + + info.cbSize = cbProperSize; + + return ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, cbProperSize, &info, 0); +} + + +BOOL AFXAPI AfxIsExtendedFrameClass(CWnd* pWnd) +{ + /* + ENSURE( pWnd ); + if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWndEx))) + { + return TRUE; + } + if (pWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx))) + { + return TRUE; + } + if (pWnd->IsKindOf(RUNTIME_CLASS(COleIPFrameWndEx))) + { + return TRUE; + } + if (pWnd->IsKindOf(RUNTIME_CLASS(COleDocIPFrameWndEx))) + { + return TRUE; + } + if (pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWndEx))) + { + return TRUE; + } + */ + return FALSE; +} + + +BOOL AFXAPI AfxIsMFCToolBar(CWnd* pWnd) +{ + ENSURE( pWnd ); + /* + if (pWnd->IsKindOf(RUNTIME_CLASS(CMFCToolBar))) + { + return TRUE; + } + */ + return FALSE; +} +/* +HRESULT AFX_GLOBAL_DATA::ShellCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv) +{ + static HMODULE hShellDll = AfxCtxLoadLibrary(_T("Shell32.dll")); + ENSURE(hShellDll != NULL); + + typedef HRESULT (__stdcall *PFNSHCREATEITEMFROMPARSINGNAME)( + PCWSTR, + IBindCtx*, + REFIID, + void** + ); + + PFNSHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName = + (PFNSHCREATEITEMFROMPARSINGNAME)GetProcAddress(hShellDll, "SHCreateItemFromParsingName"); + if (pSHCreateItemFromParsingName == NULL) + { + return E_FAIL; + } + + return (*pSHCreateItemFromParsingName)(pszPath, pbc, riid, ppv); +} +*/ \ No newline at end of file diff --git a/Common.win32/vs10fix/winmdi.cpp b/Common.win32/vs10fix/winmdi.cpp new file mode 100644 index 0000000..5ee9545 --- /dev/null +++ b/Common.win32/vs10fix/winmdi.cpp @@ -0,0 +1,1177 @@ +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and related +// electronic documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. + +#include "..\stdafx.h" +#include "afxpriv.h" +#include "afxole.h" +#include "..\src\mfc\oleimpl2.h" +//#include "..\src\mfc\afximpl.h" +/* +#include "afxmdichildwndex.h" +#include "afxmdiframewndex.h" +*/ +///////////////////////////////////////////////////////////////////////////// +// CMDIFrameWnd + +BEGIN_MESSAGE_MAP(CMDIFrameWnd, CFrameWnd) + //{{AFX_MSG_MAP(CMDIFrameWnd) + ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI, CMDIFrameWnd::OnIdleUpdateCmdUI) + ON_UPDATE_COMMAND_UI(ID_WINDOW_ARRANGE, &CMDIFrameWnd::OnUpdateMDIWindowCmd) + ON_UPDATE_COMMAND_UI(ID_WINDOW_CASCADE, &CMDIFrameWnd::OnUpdateMDIWindowCmd) + ON_UPDATE_COMMAND_UI(ID_WINDOW_TILE_HORZ, &CMDIFrameWnd::OnUpdateMDIWindowCmd) + ON_UPDATE_COMMAND_UI(ID_WINDOW_TILE_VERT, &CMDIFrameWnd::OnUpdateMDIWindowCmd) + ON_WM_SIZE() + ON_COMMAND_EX(ID_WINDOW_ARRANGE, &CMDIFrameWnd::OnMDIWindowCmd) + ON_COMMAND_EX(ID_WINDOW_CASCADE, &CMDIFrameWnd::OnMDIWindowCmd) + ON_COMMAND_EX(ID_WINDOW_TILE_HORZ, &CMDIFrameWnd::OnMDIWindowCmd) + ON_COMMAND_EX(ID_WINDOW_TILE_VERT, &CMDIFrameWnd::OnMDIWindowCmd) + ON_UPDATE_COMMAND_UI(ID_WINDOW_NEW, &CMDIFrameWnd::OnUpdateMDIWindowCmd) + ON_COMMAND(ID_WINDOW_NEW, &CMDIFrameWnd::OnWindowNew) + ON_WM_DESTROY() + ON_MESSAGE(WM_COMMANDHELP, &CMDIFrameWnd::OnCommandHelp) + ON_WM_MENUCHAR() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +CMDIFrameWnd::CMDIFrameWnd() +{ + m_hWndMDIClient = NULL; +} + +BOOL CMDIFrameWnd::OnCommand(WPARAM wParam, LPARAM lParam) +{ + // send to MDI child first - will be re-sent through OnCmdMsg later + CMDIChildWnd* pActiveChild = MDIGetActive(); + if (pActiveChild != NULL && AfxCallWndProc(pActiveChild, + pActiveChild->m_hWnd, WM_COMMAND, wParam, lParam) != 0) + return TRUE; // handled by child + + if (CFrameWnd::OnCommand(wParam, lParam)) + return TRUE; // handled through normal mechanism (MDI child or frame) + + HWND hWndCtrl = (HWND)lParam; + + ASSERT(AFX_IDM_FIRST_MDICHILD == 0xFF00); + if (hWndCtrl == NULL && (LOWORD(wParam) & 0xf000) == 0xf000) + { + // menu or accelerator within range of MDI children + // default frame proc will handle it + DefWindowProc(WM_COMMAND, wParam, lParam); + return TRUE; + } + + return FALSE; // not handled +} + +BOOL CMDIFrameWnd::OnCmdMsg(UINT nID, int nCode, void* pExtra, + AFX_CMDHANDLERINFO* pHandlerInfo) +{ + CMDIChildWnd* pActiveChild = MDIGetActive(); + // pump through active child FIRST + if (pActiveChild != NULL) + { + CPushRoutingFrame push(this); + if (pActiveChild->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) + return TRUE; + } + + // then pump through normal frame + return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); +} + +LRESULT CMDIFrameWnd::OnCommandHelp(WPARAM wParam, LPARAM lParam) +{ + if (lParam == 0 && IsTracking()) + lParam = HID_BASE_COMMAND+m_nIDTracking; + + CMDIChildWnd* pActiveChild = MDIGetActive(); + if (pActiveChild != NULL && AfxCallWndProc(pActiveChild, + pActiveChild->m_hWnd, WM_COMMANDHELP, wParam, lParam) != 0) + { + // handled by child + return TRUE; + } + + if (CFrameWnd::OnCommandHelp(wParam, lParam)) + { + // handled by our base + return TRUE; + } + + if (lParam != 0) + { + CWinApp* pApp = AfxGetApp(); + if (pApp != NULL) + { + AfxGetApp()->WinHelpInternal(lParam); + return TRUE; + } + } + return FALSE; +} + +BOOL CMDIFrameWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*) +{ + CMenu* pMenu = NULL; + if (m_hMenuDefault == NULL) + { + // default implementation for MFC V1 backward compatibility + pMenu = GetMenu(); + ASSERT(pMenu != NULL); + // This is attempting to guess which sub-menu is the Window menu. + // The Windows user interface guidelines say that the right-most + // menu on the menu bar should be Help and Window should be one + // to the left of that. + int iMenu = pMenu->GetMenuItemCount() - 2; + + // If this assertion fails, your menu bar does not follow the guidelines + // so you will have to override this function and call CreateClient + // appropriately or use the MFC V2 MDI functionality. + ASSERT(iMenu >= 0); + pMenu = pMenu->GetSubMenu(iMenu); + ASSERT(pMenu != NULL); + } + + return CreateClient(lpcs, pMenu); +} + +BOOL CMDIFrameWnd::CreateClient(LPCREATESTRUCT lpCreateStruct, + CMenu* pWindowMenu) +{ + ASSERT(m_hWnd != NULL); + ASSERT(m_hWndMDIClient == NULL); + DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_BORDER | + WS_CLIPCHILDREN | WS_CLIPSIBLINGS | + MDIS_ALLCHILDSTYLES; // allow children to be created invisible + DWORD dwExStyle = 0; + // will be inset by the frame + + // special styles for 3d effect on Win4 + dwStyle &= ~WS_BORDER; + dwExStyle = WS_EX_CLIENTEDGE; + + CLIENTCREATESTRUCT ccs; + ccs.hWindowMenu = pWindowMenu->GetSafeHmenu(); + // set hWindowMenu for MFC V1 backward compatibility + // for MFC V2, window menu will be set in OnMDIActivate + ccs.idFirstChild = AFX_IDM_FIRST_MDICHILD; + + if (lpCreateStruct->style & (WS_HSCROLL|WS_VSCROLL)) + { + // parent MDIFrame's scroll styles move to the MDICLIENT + dwStyle |= (lpCreateStruct->style & (WS_HSCROLL|WS_VSCROLL)); + + // fast way to turn off the scrollbar bits (without a resize) + ModifyStyle(WS_HSCROLL|WS_VSCROLL, 0, SWP_NOREDRAW|SWP_FRAMECHANGED); + } + + // Create MDICLIENT control with special IDC + if ((m_hWndMDIClient = ::AfxCtxCreateWindowEx(dwExStyle, _T("mdiclient"), NULL, + dwStyle, 0, 0, 0, 0, m_hWnd, (HMENU)AFX_IDW_PANE_FIRST, + AfxGetInstanceHandle(), (LPVOID)&ccs)) == NULL) + { + TRACE(traceAppMsg, 0, _T("Warning: CMDIFrameWnd::OnCreateClient: failed to create MDICLIENT.") + _T(" GetLastError returns 0x%8.8X\n"), ::GetLastError()); + return FALSE; + } + // Move it to the top of z-order + ::BringWindowToTop(m_hWndMDIClient); + + return TRUE; +} + +LRESULT CMDIFrameWnd::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam) +{ + return ::DefFrameProc(m_hWnd, m_hWndMDIClient, nMsg, wParam, lParam); +} + +BOOL CMDIFrameWnd::PreTranslateMessage(MSG* pMsg) +{ + // check for special cancel modes for ComboBoxes + if (pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_NCLBUTTONDOWN) + AfxCancelModes(pMsg->hwnd); // filter clicks + + // allow tooltip messages to be filtered + if (CWnd::PreTranslateMessage(pMsg)) + return TRUE; + +#ifndef _AFX_NO_OLE_SUPPORT + // allow hook to consume message + if (m_pNotifyHook != NULL && m_pNotifyHook->OnPreTranslateMessage(pMsg)) + return TRUE; +#endif + + CMDIChildWnd* pActiveChild = MDIGetActive(); + + // current active child gets first crack at it + if (pActiveChild != NULL && pActiveChild->PreTranslateMessage(pMsg)) + return TRUE; + + if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) + { + // translate accelerators for frame and any children + if (m_hAccelTable != NULL && + ::TranslateAccelerator(m_hWnd, m_hAccelTable, pMsg)) + { + return TRUE; + } + + // special processing for MDI accelerators last + // and only if it is not in SDI mode (print preview) + if (GetActiveView() == NULL) + { + if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) + { + // the MDICLIENT window may translate it + if (::TranslateMDISysAccel(m_hWndMDIClient, pMsg)) + return TRUE; + } + } + } + + return FALSE; +} + +void CMDIFrameWnd::DelayUpdateFrameMenu(HMENU hMenuAlt) +{ + OnUpdateFrameMenu(hMenuAlt); + + m_nIdleFlags |= idleMenu; +} + +void CMDIFrameWnd::OnIdleUpdateCmdUI() +{ + if (m_nIdleFlags & idleMenu) + { + DrawMenuBar(); + m_nIdleFlags &= ~idleMenu; + } + CFrameWnd::OnIdleUpdateCmdUI(); +} + +CFrameWnd* CMDIFrameWnd::GetActiveFrame() +{ + CMDIChildWnd* pActiveChild = MDIGetActive(); + if (pActiveChild == NULL) + return this; + return pActiveChild; +} + +BOOL CMDIFrameWnd::PreCreateWindow(CREATESTRUCT& cs) +{ + if (cs.lpszClass == NULL) + { + VERIFY(AfxDeferRegisterClass(AFX_WNDMDIFRAME_REG)); + cs.lpszClass = _afxWndMDIFrame; + } + return TRUE; +} + +BOOL CMDIFrameWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, + CWnd* pParentWnd, CCreateContext* pContext) +{ + if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, + pParentWnd, pContext)) + return FALSE; + + // save menu to use when no active MDI child window is present + ASSERT(m_hWnd != NULL); + m_hMenuDefault = ::GetMenu(m_hWnd); + return TRUE; +} + +void CMDIFrameWnd::OnDestroy() +{ + CFrameWnd::OnDestroy(); // exit and misc cleanup + + // owned menu stored in shared slot for MDIFRAME + if (m_hMenuDefault != NULL && ::GetMenu(m_hWnd) != m_hMenuDefault) + { + // must go through MDI client to get rid of MDI menu additions + ::SendMessage(m_hWndMDIClient, WM_MDISETMENU, + (WPARAM)m_hMenuDefault, NULL); + ASSERT(::GetMenu(m_hWnd) == m_hMenuDefault); + } +} + +void CMDIFrameWnd::OnSize(UINT nType, int, int) +{ + // do not call default - it will reposition the MDICLIENT + if (nType != SIZE_MINIMIZED) + RecalcLayout(); +} + +LRESULT CMDIFrameWnd::OnMenuChar(UINT nChar, UINT, CMenu*) +{ + // do not call Default() for Alt+(-) when in print preview mode + if (m_lpfnCloseProc != NULL && nChar == (UINT)'-') + return 0; + else + return Default(); +} + +CMDIChildWnd* CMDIFrameWnd::MDIGetActive(BOOL* pbMaximized) const +{ + // check first for MDI client window not created + if (m_hWndMDIClient == NULL) + { + if (pbMaximized != NULL) + *pbMaximized = FALSE; + return NULL; + } + + // MDI client has been created, get active MDI child + HWND hWnd = (HWND)::SendMessage(m_hWndMDIClient, WM_MDIGETACTIVE, 0, + (LPARAM)pbMaximized); + CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandlePermanent(hWnd); + ASSERT(pWnd == NULL || pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd))); + + // check for special pseudo-inactive state + if (pWnd != NULL && pWnd->m_bPseudoInactive && + (pWnd->GetStyle() & WS_VISIBLE) == 0) + { + // Window is hidden, active, but m_bPseudoInactive -- return NULL + pWnd = NULL; + // Ignore maximized flag if pseudo-inactive and maximized + if (pbMaximized != NULL) + *pbMaximized = FALSE; + } + return pWnd; +} + + +CMDIChildWnd* CMDIFrameWnd::CreateNewChild(CRuntimeClass* pClass, + UINT nResources, HMENU hMenu /* = NULL */, HACCEL hAccel /* = NULL */) +{ + ASSERT(pClass != NULL); + CMDIChildWnd* pFrame = (CMDIChildWnd*) pClass->CreateObject(); + ASSERT_KINDOF(CMDIChildWnd, pFrame); + + // load the frame + CCreateContext context; + context.m_pCurrentFrame = this; + + pFrame->SetHandles(hMenu, hAccel); + if (!pFrame->LoadFrame(nResources, + WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context)) + { + TRACE(traceAppMsg, 0, "Couldn't load frame window.\n"); + return NULL; + } + + CString strFullString, strTitle; + if (strFullString.LoadString(nResources)) + AfxExtractSubString(strTitle, strFullString, CDocTemplate::docName); + + // redraw the frame and parent + pFrame->SetTitle(strTitle); + pFrame->InitialUpdateFrame(NULL, TRUE); + + return pFrame; +} + +///////////////////////////////////////////////////////////////////////////// +// CMDIFrameWnd Diagnostics + +#ifdef _DEBUG +void CMDIFrameWnd::AssertValid() const +{ + CFrameWnd::AssertValid(); + ASSERT(m_hWndMDIClient == NULL || ::IsWindow(m_hWndMDIClient)); + ASSERT(m_hMenuDefault == NULL || ::IsMenu(m_hMenuDefault)); +} + +void CMDIFrameWnd::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); + + dc << "m_hWndMDIClient = " << (void*)m_hWndMDIClient; + dc << "\nm_hMenuDefault = " << (void*)m_hMenuDefault; + + dc << "\n"; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMDIChildWnd + +BEGIN_MESSAGE_MAP(CMDIChildWnd, CFrameWnd) + //{{AFX_MSG_MAP(CMDIChildWnd) + ON_WM_MOUSEACTIVATE() + ON_WM_NCACTIVATE() + ON_WM_MDIACTIVATE() + ON_WM_SIZE() + ON_WM_WINDOWPOSCHANGING() + ON_WM_NCCREATE() + ON_WM_CREATE() + ON_WM_DESTROY() + ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, &CMDIChildWnd::OnToolTipText) + ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, &CMDIChildWnd::OnToolTipText) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +CMDIChildWnd::CMDIChildWnd() +{ + m_hMenuShared = NULL; + m_bPseudoInactive = FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMDIChildWnd special processing + +LRESULT CMDIChildWnd::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam) +{ + return ::DefMDIChildProc(m_hWnd, nMsg, wParam, lParam); +} + +BOOL CMDIChildWnd::DestroyWindow() +{ + if (m_hWnd == NULL) + return FALSE; + + // avoid changing the caption during the destroy message(s) + CMDIFrameWnd* pFrameWnd = GetMDIFrame(); + HWND hWndFrame = pFrameWnd->m_hWnd; + ASSERT(::IsWindow(hWndFrame)); + DWORD dwStyle = SetWindowLong(hWndFrame, GWL_STYLE, + GetWindowLong(hWndFrame, GWL_STYLE) & ~FWS_ADDTOTITLE); + + MDIDestroy(); + + if (::IsWindow(hWndFrame)) + { + ASSERT(hWndFrame == pFrameWnd->m_hWnd); + SetWindowLong(hWndFrame, GWL_STYLE, dwStyle); + pFrameWnd->OnUpdateFrameTitle(TRUE); + } + + return TRUE; +} + +BOOL CMDIChildWnd::PreTranslateMessage(MSG* pMsg) +{ + // check for special cancel modes for combo boxes + if (pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_NCLBUTTONDOWN) + AfxCancelModes(pMsg->hwnd); // filter clicks + + // allow tooltip messages to be filtered + if (CWnd::PreTranslateMessage(pMsg)) + return TRUE; + + // we can't call 'CFrameWnd::PreTranslate' since it will translate + // accelerators in the context of the MDI Child - but since MDI Child + // windows don't have menus this doesn't work properly. MDI Child + // accelerators must be translated in context of their MDI Frame. + + if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) + { + // use document specific accelerator table over m_hAccelTable + HACCEL hAccel = GetDefaultAccelerator(); + return hAccel != NULL && + ::TranslateAccelerator(GetMDIFrame()->m_hWnd, hAccel, pMsg); + } + return FALSE; +} + +BOOL CMDIChildWnd::PreCreateWindow(CREATESTRUCT& cs) +{ + ASSERT(cs.style & WS_CHILD); + // MFC V2 requires that MDI Children are created with proper styles, + // usually: WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW. + // See Technical note TN019 for more details on MFC V1->V2 migration. + + return CFrameWnd::PreCreateWindow(cs); +} + +BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName, + LPCTSTR lpszWindowName, DWORD dwStyle, + const RECT& rect, CMDIFrameWnd* pParentWnd, + CCreateContext* pContext) +{ + if (pParentWnd == NULL) + { + CWinThread *pThread = AfxGetThread(); + ENSURE_VALID(pThread); + CWnd* pMainWnd = pThread->m_pMainWnd; + ENSURE_VALID(pMainWnd); + ASSERT_KINDOF(CMDIFrameWnd, pMainWnd); + pParentWnd = (CMDIFrameWnd*)pMainWnd; + } + ASSERT(::IsWindow(pParentWnd->m_hWndMDIClient)); + + // insure correct window positioning + pParentWnd->RecalcLayout(); + + // first copy into a CREATESTRUCT for PreCreate + CREATESTRUCT cs; + cs.dwExStyle = 0L; + cs.lpszClass = lpszClassName; + cs.lpszName = lpszWindowName; + cs.style = dwStyle; + cs.x = rect.left; + cs.y = rect.top; + cs.cx = rect.right - rect.left; + cs.cy = rect.bottom - rect.top; + cs.hwndParent = pParentWnd->m_hWnd; + cs.hMenu = NULL; + cs.hInstance = AfxGetInstanceHandle(); + cs.lpCreateParams = (LPVOID)pContext; + + if (!PreCreateWindow(cs)) + { + PostNcDestroy(); + return FALSE; + } + // extended style must be zero for MDI Children (except under Win4) + ASSERT(cs.hwndParent == pParentWnd->m_hWnd); // must not change + + // now copy into a MDICREATESTRUCT for real create + MDICREATESTRUCT mcs; + mcs.szClass = cs.lpszClass; + mcs.szTitle = cs.lpszName; + mcs.hOwner = cs.hInstance; + mcs.x = cs.x; + mcs.y = cs.y; + mcs.cx = cs.cx; + mcs.cy = cs.cy; + mcs.style = cs.style & ~(WS_MAXIMIZE | WS_VISIBLE); + mcs.lParam = (LPARAM)cs.lpCreateParams; + + // create the window through the MDICLIENT window + AfxHookWindowCreate(this); + HWND hWnd = (HWND)::SendMessage(pParentWnd->m_hWndMDIClient, + WM_MDICREATE, 0, (LPARAM)&mcs); + if (!AfxUnhookWindowCreate()) + PostNcDestroy(); // cleanup if MDICREATE fails too soon + + if (hWnd == NULL) + return FALSE; + + // special handling of visibility (always created invisible) + if (cs.style & WS_VISIBLE) + { + // place the window on top in z-order before showing it + ::BringWindowToTop(hWnd); + + // show it as specified + if (cs.style & WS_MINIMIZE) + ShowWindow(SW_SHOWMINIMIZED); + else if (cs.style & WS_MAXIMIZE) + ShowWindow(SW_SHOWMAXIMIZED); + else + ShowWindow(SW_SHOWNORMAL); + + // make sure it is active (visibility == activation) + pParentWnd->MDIActivate(this); + + // refresh MDI Window menu + ::SendMessage(pParentWnd->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0); + } + + ASSERT(hWnd == m_hWnd); + return TRUE; +} + +BOOL CMDIChildWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, + CWnd* pParentWnd, CCreateContext* pContext) +{ + // only do this once + ASSERT_VALID_IDR(nIDResource); + ASSERT(m_nIDHelp == 0 || m_nIDHelp == nIDResource); + + m_nIDHelp = nIDResource; // ID for help context (+HID_BASE_RESOURCE) + + // parent must be MDI Frame (or NULL for default) + ASSERT(pParentWnd == NULL || pParentWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd))); + // will be a child of MDIClient + ASSERT(!(dwDefaultStyle & WS_POPUP)); + dwDefaultStyle |= WS_CHILD; + + // if available - get MDI child menus from doc template + CMultiDocTemplate* pTemplate; + if (pContext != NULL && + (pTemplate = (CMultiDocTemplate*)pContext->m_pNewDocTemplate) != NULL) + { + ASSERT_KINDOF(CMultiDocTemplate, pTemplate); + // get shared menu from doc template + m_hMenuShared = pTemplate->m_hMenuShared; + m_hAccelTable = pTemplate->m_hAccelTable; + } + else + { + TRACE(traceAppMsg, 0, "Warning: no shared menu/acceltable for MDI Child window.\n"); + // if this happens, programmer must load these manually + } + + CString strFullString, strTitle; + if (strFullString.LoadString(nIDResource)) + AfxExtractSubString(strTitle, strFullString, 0); // first sub-string + + ASSERT(m_hWnd == NULL); + if (!Create(GetIconWndClass(dwDefaultStyle, nIDResource), + strTitle, dwDefaultStyle, rectDefault, + (CMDIFrameWnd*)pParentWnd, pContext)) + { + return FALSE; // will self destruct on failure normally + } + + // it worked ! + return TRUE; +} + +void CMDIChildWnd::OnSize(UINT nType, int cx, int cy) +{ + CFrameWnd::OnSize(nType, cx, cy); + + // update our parent frame - in case we are now maximized or not + GetMDIFrame()->OnUpdateFrameTitle(TRUE); +} + + +BOOL CMDIChildWnd::UpdateClientEdge(LPRECT lpRect) +{ + // only adjust for active MDI child window + CMDIFrameWnd* pFrameWnd = GetMDIFrame(); + CMDIChildWnd* pChild = pFrameWnd->MDIGetActive(); + + // Only adjust for regular MDI child windows, not tabbed windows. Attempting to set WS_EX_CLIENTEDGE on the tabbed + // MDI client area window is subverted by CMDIClientAreaWnd::OnStyleChanging, so we always try to reset the style and + // always repaint, none of which is necessary since the tabbed MDI children never change from maximized to restored. + /* + CMDIChildWndEx* pChildEx = (pChild == NULL) ? NULL : DYNAMIC_DOWNCAST(CMDIChildWndEx, pChild); + BOOL bIsTabbedMDIChild = (pChildEx == NULL) ? FALSE : pChildEx->GetMDIFrameWndEx() != NULL && pChildEx->GetMDIFrameWndEx()->AreMDITabs(); + if ((pChild == NULL || pChild == this) && !bIsTabbedMDIChild) + { + // need to adjust the client edge style as max/restore happens + DWORD dwStyle = ::GetWindowLong(pFrameWnd->m_hWndMDIClient, GWL_EXSTYLE); + DWORD dwNewStyle = dwStyle; + if (pChild != NULL && !(GetExStyle() & WS_EX_CLIENTEDGE) && (GetStyle() & WS_MAXIMIZE)) + { + dwNewStyle &= ~(WS_EX_CLIENTEDGE); + } + else + { + dwNewStyle |= WS_EX_CLIENTEDGE; + } + + if (dwStyle != dwNewStyle) + { + // SetWindowPos will not move invalid bits + ::RedrawWindow(pFrameWnd->m_hWndMDIClient, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); + + // remove/add WS_EX_CLIENTEDGE to MDI client area + ::SetWindowLong(pFrameWnd->m_hWndMDIClient, GWL_EXSTYLE, dwNewStyle); + ::SetWindowPos(pFrameWnd->m_hWndMDIClient, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOCOPYBITS); + + // return new client area + if (lpRect != NULL) + { + ::GetClientRect(pFrameWnd->m_hWndMDIClient, lpRect); + } + + return TRUE; + } + } + */ + + return FALSE; +} + +void CMDIChildWnd::OnWindowPosChanging(LPWINDOWPOS lpWndPos) +{ + if (!(lpWndPos->flags & SWP_NOSIZE)) + { + CRect rectClient; + if (UpdateClientEdge(rectClient) && (GetStyle() & WS_MAXIMIZE)) + { + // adjust maximized window size and position based on new + // size/position of the MDI client area. + ::AdjustWindowRectEx(rectClient, GetStyle(), FALSE, GetExStyle()); + lpWndPos->x = rectClient.left; + lpWndPos->y = rectClient.top; + lpWndPos->cx = rectClient.Width(); + lpWndPos->cy = rectClient.Height(); + } + } + + CFrameWnd::OnWindowPosChanging(lpWndPos); +} + +void CMDIChildWnd::OnDestroy() +{ + UpdateClientEdge(); + + CFrameWnd::OnDestroy(); +} + +BOOL CMDIChildWnd::OnNcActivate(BOOL bActive) +{ + // bypass CFrameWnd::OnNcActivate() + return CWnd::OnNcActivate(bActive); +} + +int CMDIChildWnd::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) +{ + int nResult = CFrameWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); + if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT) + return nResult; // frame does not want to activate + + // activate this window if necessary + CMDIFrameWnd* pFrameWnd = GetMDIFrame(); + ENSURE_VALID(pFrameWnd); + CMDIChildWnd* pActive = pFrameWnd->MDIGetActive(); + if (pActive != this) + MDIActivate(); + + return nResult; +} + +BOOL CMDIChildWnd::OnToolTipText(UINT msg, NMHDR* pNMHDR, LRESULT* pResult) +{ + ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); + UNUSED(pNMHDR); + + // check to see if the message is going directly to this window or not + const MSG* pMsg = GetCurrentMessage(); + if (pMsg->hwnd != m_hWnd) + { + // let top level frame handle this for us + return FALSE; + } + + // otherwise, handle it ourselves + return CFrameWnd::OnToolTipText(msg, pNMHDR, pResult); +} + +void CMDIChildWnd::ActivateFrame(int nCmdShow) +{ + BOOL bVisibleThen = (GetStyle() & WS_VISIBLE) != 0; + CMDIFrameWnd* pFrameWnd = GetMDIFrame(); + ASSERT_VALID(pFrameWnd); + + // determine default show command + if (nCmdShow == -1) + { + // get maximized state of frame window (previously active child) + BOOL bMaximized; + pFrameWnd->MDIGetActive(&bMaximized); + + // convert show command based on current style + DWORD dwStyle = GetStyle(); + if (bMaximized || (dwStyle & WS_MAXIMIZE)) + nCmdShow = SW_SHOWMAXIMIZED; + else if (dwStyle & WS_MINIMIZE) + nCmdShow = SW_SHOWMINIMIZED; + } + + // finally, show the window + CFrameWnd::ActivateFrame(nCmdShow); + + // update the Window menu to reflect new child window + CMDIFrameWnd* pFrame = GetMDIFrame(); + ::SendMessage(pFrame->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0); + + // Note: Update the m_bPseudoInactive flag. This is used to handle the + // last MDI child getting hidden. Windows provides no way to deactivate + // an MDI child window. + + BOOL bVisibleNow = (GetStyle() & WS_VISIBLE) != 0; + if (bVisibleNow == bVisibleThen) + return; + + if (!bVisibleNow) + { + // get current active window according to Windows MDI + HWND hWnd = (HWND)::SendMessage(pFrameWnd->m_hWndMDIClient, + WM_MDIGETACTIVE, 0, 0); + if (hWnd != m_hWnd) + { + // not active any more -- window must have been deactivated + ASSERT(!m_bPseudoInactive); + return; + } + + // check next window + ASSERT(hWnd != NULL); + pFrameWnd->MDINext(); + + // see if it has been deactivated now... + hWnd = (HWND)::SendMessage(pFrameWnd->m_hWndMDIClient, + WM_MDIGETACTIVE, 0, 0); + if (hWnd == m_hWnd) + { + // still active -- fake deactivate it + ASSERT(hWnd != NULL); + ::SendMessage(pFrameWnd->m_hWndMDIClient, WM_MDIACTIVATE, (WPARAM)m_hWnd, NULL); + m_bPseudoInactive = TRUE; // so MDIGetActive returns NULL + } + } + else if (m_bPseudoInactive) + { + // if state transitioned from not visible to visible, but + // was pseudo deactivated -- send activate notify now + ::SendMessage(pFrameWnd->m_hWndMDIClient, WM_MDIACTIVATE, NULL, (LPARAM)m_hWnd); + ASSERT(!m_bPseudoInactive); // should get set in OnMDIActivate! + } +} + +void CMDIChildWnd::SetHandles(HMENU hMenu, HACCEL hAccel) +{ + m_hMenuShared = hMenu; + m_hAccelTable = hAccel; +} + +///////////////////////////////////////////////////////////////////////////// +// CMDIChildWnd Diagnostics + +#ifdef _DEBUG +void CMDIChildWnd::AssertValid() const +{ + CFrameWnd::AssertValid(); + ASSERT(m_hMenuShared == NULL || ::IsMenu(m_hMenuShared)); +} + +void CMDIChildWnd::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); + + dc << "m_hMenuShared = " << (void*)m_hMenuShared; + dc << "\n"; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// Smarts for the "Window" menu + +HMENU CMDIFrameWnd::GetWindowMenuPopup(HMENU hMenuBar) + // find which popup is the "Window" menu +{ + if (hMenuBar == NULL) + return NULL; + + ASSERT(::IsMenu(hMenuBar)); + + int iItem = ::GetMenuItemCount(hMenuBar); + while (iItem--) + { + HMENU hMenuPop = ::GetSubMenu(hMenuBar, iItem); + if (hMenuPop != NULL) + { + int iItemMax = ::GetMenuItemCount(hMenuPop); + for (int iItemPop = 0; iItemPop < iItemMax; iItemPop++) + { + UINT nID = GetMenuItemID(hMenuPop, iItemPop); + if (nID >= AFX_IDM_WINDOW_FIRST && nID <= AFX_IDM_WINDOW_LAST) + return hMenuPop; + } + } + } + + // no default menu found + TRACE(traceAppMsg, 0, "Warning: GetWindowMenuPopup failed!\n"); + return NULL; +} + +///////////////////////////////////////////////////////////////////////////// +// Smarts for updating the window menu based on the current child + +void CMDIFrameWnd::OnUpdateFrameMenu(HMENU hMenuAlt) +{ + CMDIChildWnd* pActiveWnd = MDIGetActive(); + if (pActiveWnd != NULL) + { + // let child update the menu bar + pActiveWnd->OnUpdateFrameMenu(TRUE, pActiveWnd, hMenuAlt); + } + else + { + // no child active, so have to update it ourselves + // (we can't send it to a child window, since pActiveWnd is NULL) + if (hMenuAlt == NULL) + hMenuAlt = m_hMenuDefault; // use default + ::SendMessage(m_hWndMDIClient, WM_MDISETMENU, (WPARAM)hMenuAlt, NULL); + } +} + +///////////////////////////////////////////////////////////////////////////// +// MDI Child Extensions + +// walk up two parents for MDIFrame that owns MDIChild (skip MDIClient) +CMDIFrameWnd* CMDIChildWnd::GetMDIFrame() +{ + ASSERT_KINDOF(CMDIChildWnd, this); + ASSERT(m_hWnd != NULL); + HWND hWndMDIClient = ::GetParent(m_hWnd); + ASSERT(hWndMDIClient != NULL); + + CMDIFrameWnd* pMDIFrame; + pMDIFrame = (CMDIFrameWnd*)CWnd::FromHandle(::GetParent(hWndMDIClient)); + ASSERT(pMDIFrame != NULL); + ASSERT_KINDOF(CMDIFrameWnd, pMDIFrame); + ASSERT(pMDIFrame->m_hWndMDIClient == hWndMDIClient); + ASSERT_VALID(pMDIFrame); + return pMDIFrame; +} + +CWnd* CMDIChildWnd::GetMessageBar() +{ + // status bar/message bar owned by parent MDI frame + return GetMDIFrame()->GetMessageBar(); +} + +void CMDIChildWnd::OnUpdateFrameTitle(BOOL bAddToTitle) +{ + // update our parent window first + GetMDIFrame()->OnUpdateFrameTitle(bAddToTitle); + + if ((GetStyle() & FWS_ADDTOTITLE) == 0) + return; // leave child window alone! + + CDocument* pDocument = GetActiveDocument(); + if (bAddToTitle) + { + TCHAR szText[256+_MAX_PATH]; + if (pDocument == NULL) + Checked::tcsncpy_s(szText, _countof(szText), m_strTitle, _TRUNCATE); + else + Checked::tcsncpy_s(szText, _countof(szText), pDocument->GetTitle(), _TRUNCATE); + if (m_nWindow > 0) + { + TCHAR szWinNumber[16+1]; + _stprintf_s(szWinNumber, _countof(szWinNumber), _T(":%d"), m_nWindow); + + if( lstrlen(szText) + lstrlen(szWinNumber) < _countof(szText) ) + { + Checked::tcscat_s( szText, _countof(szText), szWinNumber ); + } + } + + // set title if changed, but don't remove completely + AfxSetWindowText(m_hWnd, szText); + } +} + +void CMDIChildWnd::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd*) +{ + m_bPseudoInactive = FALSE; // must be happening for real + + // make sure MDI client window has correct client edge + UpdateClientEdge(); + + // send deactivate notification to active view + CView* pActiveView = GetActiveView(); + if (!bActivate && pActiveView != NULL) + pActiveView->OnActivateView(FALSE, pActiveView, pActiveView); + + // allow hook to short circuit normal activation + BOOL bHooked = FALSE; +#ifndef _AFX_NO_OLE_SUPPORT + if (m_pNotifyHook != NULL && m_pNotifyHook->OnDocActivate(bActivate)) + bHooked = TRUE; +#endif + + // update titles (don't AddToTitle if deactivate last) + if (!bHooked) + OnUpdateFrameTitle(bActivate || (pActivateWnd != NULL)); + + // re-activate the appropriate view + if (bActivate) + { + if (pActiveView != NULL && GetMDIFrame() == GetActiveWindow()) + pActiveView->OnActivateView(TRUE, pActiveView, pActiveView); + } + + // update menus + if (!bHooked) + { + OnUpdateFrameMenu(bActivate, pActivateWnd, NULL); + GetMDIFrame()->DrawMenuBar(); + } +} + +void CMDIChildWnd::OnUpdateFrameMenu(BOOL bActivate, CWnd* pActivateWnd, + HMENU hMenuAlt) +{ + CMDIFrameWnd* pFrame = GetMDIFrame(); + + if (hMenuAlt == NULL && bActivate) + { + // attempt to get default menu from document + CDocument* pDoc = GetActiveDocument(); + if (pDoc != NULL) + hMenuAlt = pDoc->GetDefaultMenu(); + } + + // use default menu stored in frame if none from document + if (hMenuAlt == NULL) + hMenuAlt = m_hMenuShared; + + if (hMenuAlt != NULL && bActivate) + { + ASSERT(pActivateWnd == this); + + // activating child, set parent menu + ::SendMessage(pFrame->m_hWndMDIClient, WM_MDISETMENU, + (WPARAM)hMenuAlt, (LPARAM)pFrame->GetWindowMenuPopup(hMenuAlt)); + } + else if (hMenuAlt != NULL && !bActivate && pActivateWnd == NULL) + { + // destroying last child + HMENU hMenuLast = NULL; + ::SendMessage(pFrame->m_hWndMDIClient, WM_MDISETMENU, + (WPARAM)pFrame->m_hMenuDefault, (LPARAM)hMenuLast); + } + else + { + // refresh MDI Window menu (even if non-shared menu) + ::SendMessage(pFrame->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0); + } +} + +BOOL CMDIChildWnd::OnNcCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (!CFrameWnd::OnNcCreate(lpCreateStruct)) + return FALSE; + + // handle extended styles under Win4 + // call PreCreateWindow again just to get dwExStyle + VERIFY(PreCreateWindow(*lpCreateStruct)); + SetWindowLong(m_hWnd, GWL_EXSTYLE, lpCreateStruct->dwExStyle); + + return TRUE; +} + +int CMDIChildWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + // call base class with lParam context (not MDI one) + MDICREATESTRUCT* lpmcs; + lpmcs = (MDICREATESTRUCT*)lpCreateStruct->lpCreateParams; + CCreateContext* pContext = (CCreateContext*)lpmcs->lParam; + + return OnCreateHelper(lpCreateStruct, pContext); +} + +///////////////////////////////////////////////////////////////////////////// +// Special UI processing depending on current active child + +void CMDIFrameWnd::OnUpdateFrameTitle(BOOL bAddToTitle) +{ + if ((GetStyle() & FWS_ADDTOTITLE) == 0) + return; // leave it alone! + +#ifndef _AFX_NO_OLE_SUPPORT + // allow hook to set the title (used for OLE support) + if (m_pNotifyHook != NULL && m_pNotifyHook->OnUpdateFrameTitle()) + return; +#endif + + CMDIChildWnd* pActiveChild = NULL; + CDocument* pDocument = GetActiveDocument(); + if (bAddToTitle && + (pActiveChild = MDIGetActive()) != NULL && + (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0 && + (pDocument != NULL || + (pDocument = pActiveChild->GetActiveDocument()) != NULL)) + UpdateFrameTitleForDocument(pDocument->GetTitle()); + else + { + LPCTSTR lpstrTitle = NULL; + CString strTitle; + + if (pActiveChild != NULL && + (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0) + { + strTitle = pActiveChild->GetTitle(); + if (!strTitle.IsEmpty()) + lpstrTitle = strTitle; + } + UpdateFrameTitleForDocument(lpstrTitle); + } +} + +///////////////////////////////////////////////////////////////////////////// +// Standard MDI Commands + +// Two function for all standard MDI "Window" commands +void CMDIFrameWnd::OnUpdateMDIWindowCmd(CCmdUI* pCmdUI) +{ + ASSERT(m_hWndMDIClient != NULL); + pCmdUI->Enable(MDIGetActive() != NULL); +} + +BOOL CMDIFrameWnd::OnMDIWindowCmd(UINT nID) +{ + ASSERT(m_hWndMDIClient != NULL); + + UINT msg; + UINT wParam = 0; + switch (nID) + { + default: + return FALSE; // not for us + case ID_WINDOW_ARRANGE: + msg = WM_MDIICONARRANGE; + break; + case ID_WINDOW_CASCADE: + msg = WM_MDICASCADE; + break; + case ID_WINDOW_TILE_HORZ: + wParam = MDITILE_HORIZONTAL; + // fall through + case ID_WINDOW_TILE_VERT: + ASSERT(MDITILE_VERTICAL == 0); + msg = WM_MDITILE; + break; + } + + ::SendMessage(m_hWndMDIClient, msg, wParam, 0); + return TRUE; +} + +void CMDIFrameWnd::OnWindowNew() +{ + CMDIChildWnd* pActiveChild = MDIGetActive(); + CDocument* pDocument; + if (pActiveChild == NULL || + (pDocument = pActiveChild->GetActiveDocument()) == NULL) + { + TRACE(traceAppMsg, 0, "Warning: No active document for WindowNew command.\n"); + AfxMessageBox(AFX_IDP_COMMAND_FAILURE); + return; // command failed + } + + // otherwise we have a new frame ! + CDocTemplate* pTemplate = pDocument->GetDocTemplate(); + ASSERT_VALID(pTemplate); + CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pActiveChild); + if (pFrame == NULL) + { + TRACE(traceAppMsg, 0, "Warning: failed to create new frame.\n"); + return; // command failed + } + + pTemplate->InitialUpdateFrame(pFrame, pDocument); +} + +void CMDIFrameWnd::SetMenuBarVisibility(DWORD dwStyle) +{ + ENSURE_ARG(dwStyle == AFX_MBV_KEEPVISIBLE); + ASSERT(m_dwMenuBarVisibility == AFX_MBV_KEEPVISIBLE); +} + +BOOL CMDIFrameWnd::SetMenuBarState(DWORD dwState) +{ + return m_dwMenuBarState == AFX_MBS_HIDDEN ? FALSE : CFrameWnd::SetMenuBarState(dwState); +} + +IMPLEMENT_DYNCREATE(CMDIFrameWnd, CFrameWnd) +IMPLEMENT_DYNCREATE(CMDIChildWnd, CFrameWnd) + +//////////////////////////////////////////////////////////////////////////// diff --git a/Common.win32/winconsole.cpp b/Common.win32/winconsole.cpp new file mode 100644 index 0000000..16ff28e --- /dev/null +++ b/Common.win32/winconsole.cpp @@ -0,0 +1,389 @@ +#include "../common.win32/stdafx.h" +#include +#include "consoleresrc.h" +#include "activecommon.h" +#include "../common/ki.h" +#include "../common/svnversion.h" +#include "../kegs/src/sim65816.h" + +int outputInfoInternal(const char* _str) +{ + CEmulatorWin32* p = (CEmulatorWin32*)CEmulator::theEmulator; + if (p) + { + CConsole* c = p->theConsole; + if (c && IsWindow(c->hWnd)) + c->addLine(_str); + } + + OutputDebugString(_str); + return 0; +} + +int outputInfo(const MYCHAR* format,...) +{ + + va_list argptr; + va_start( argptr, format ); + CString st; + st.FormatV(format,argptr); + va_end(argptr); + + outputInfoInternal(st); + return 0; +} + +int fOutputInfo(FILE* _file,const char* format,...) +{ + va_list argptr; + va_start( argptr, format ); + CString st; + st.FormatV(format,argptr); + va_end(argptr); + + if ((_file!=stdout) && (_file!=stderr)) + fprintf(_file,st); + else + outputInfoInternal(st); + return 0; + +} + +void CConsole::showConsole() +{ + if (!IsWindow(hWnd)) return ; + ShowWindow(hWnd,SW_SHOW); + visible++; +} + +void CConsole::hideConsole() +{ + if (!IsWindow(hWnd)) return ; + ShowWindow(hWnd,SW_HIDE); + visible--; + /* + if (enable) + // run the emulator + strcpy(inputBuffer,"g"); + */ +} + + + +BOOL CALLBACK EditProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) +{ +HWND parent = GetParent(hwnd); + CConsole* theConsole = (CConsole*)GetWindowLongPtr(parent,GWLP_USERDATA); + + switch(Message) + { + case WM_CHAR: + if (wParam==VK_RETURN) + { + SendMessage( hwnd, WM_GETTEXT, (WPARAM)255, (LPARAM)(LPCSTR)(theConsole->inputBuffer)); + outputInfo(">%s\n",theConsole->inputBuffer); + SendMessage( hwnd, WM_SETTEXT, (WPARAM)NULL, (LPARAM)(LPCSTR)NULL); + UpdateWindow(hwnd); + return 0; + } + break; + } + return CallWindowProc(theConsole->OldProc,hwnd,Message,wParam,lParam); +} + +INT_PTR CALLBACK ConsoleProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) +{ + + CConsole* theConsole = (CConsole*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + + switch(Message) + { + case WM_USER: + if (theConsole) + theConsole->refreshLine(); + break; + case WM_DESTROY: + OutputDebugString("WM_DESTROY Console\n"); + + // détruit la font + if (theConsole) + { + if ( theConsole->hFont) + { + DeleteObject(theConsole->hFont); + theConsole->hFont=NULL; + } + theConsole->hWnd=NULL; + } + break; + case WM_CLOSE: + outputInfo("WM_CLOSE\n"); + theConsole->hideConsole(); + break; + case WM_COMMAND: + if (theConsole) + switch (LOWORD(wParam)) + { + case IDC_GO: + theConsole->inputBuffer[0]='g'; + theConsole->inputBuffer[1]=0; + break; + case IDC_REGS: + theConsole->inputBuffer[0]=0x05; + theConsole->inputBuffer[1]=0; + break; + case IDC_STEP: + theConsole->inputBuffer[0]='s'; + theConsole->inputBuffer[1]=0; + break; + case IDC_BUTTONBRK: + { + extern int g_config_control_panel; + if (!g_config_control_panel) + set_halt_act(HALT_WANTTOBRK); + else + outputInfo("Emulator not ready (likely in pause)...\n"); + } + break; + } + break; + case WM_CREATE: + outputInfo("WM_CREATE\n"); + break; + case WM_INITDIALOG: + { + // récupère le bon ptr + theConsole = (CConsole*)lParam; + // associe la classe à la fenetre + SetLastError(0); + if (! SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG_PTR)theConsole) && GetLastError()) + { + LONG err = GetLastError(); + char str[255]; + sprintf(str,"SetWindowLong(initdialog) Failed (%X %d)\n",hwnd,err); + OutputDebugString(str); + } + LOGFONT lf; + + // Creates a non proportionnal font for both EDIT1 & EDIT2 + + memset( &lf, 0, sizeof(LOGFONT) ); // zero out structure + lf.lfHeight = 14; // request a 12-pixel-height font + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = ANSI_CHARSET; + lf.lfPitchAndFamily = FIXED_PITCH & FF_DONTCARE; + strcpy( lf.lfFaceName, "Courier New" ); // request a face name "Arial" + + if (!(theConsole->hFont = CreateFontIndirect( &lf )) ) + OutputDebugString("font failed\n"); + + // Hook a new windw procedure for EDIT1 + + HWND edit2 = GetDlgItem(hwnd,IDC_EDIT1); + ASSERT(edit2!=NULL); + if (!SetWindowLongPtr(edit2,GWLP_USERDATA,(LONG_PTR)theConsole)) + { + LONG err = GetLastError(); + char str[255]; + sprintf(str,"SetWindowLongPtr(edit2) Failed (%X %d)\n",edit2,err); + OutputDebugString(str); + } + + theConsole->OldProc = (WNDPROC)GetWindowLongPtr(edit2,GWLP_WNDPROC); + if (!SetWindowLongPtr(edit2,GWLP_WNDPROC,(LONG_PTR)EditProc)) + { + LONG err = GetLastError(); + char str[255]; + sprintf(str,"SetWindowLong(proc) Failed (%X %d)\n",edit2,err); + OutputDebugString(str); + } + SendDlgItemMessage(hwnd,IDC_EDIT2,WM_SETFONT,(WPARAM)theConsole->hFont,TRUE); + SendDlgItemMessage(hwnd,IDC_EDIT1,WM_SETFONT,(WPARAM)theConsole->hFont,TRUE); + + + + break; + } + + default: + return FALSE; + } + return TRUE; +} + + + + + +void CConsole::addLine(const char* buf) +{ + int lb,i; + + lb = (int)strlen(buf); + + // ignore un message qui ne tient pas dans le buffer + if (lb+16>HIST_DEFAULT_LIMIT) + return ; + + + if (HistorySize+lb > (BufferSize-8) ) + HistorySize = 0; + + strcpy(ConsoleHistory+HistorySize, buf); + HistorySize += lb; + + for(i=0;i 1 ) + { + CurLine = (int)SendDlgItemMessage(hWnd,IDC_EDIT2, EM_GETFIRSTVISIBLELINE, 0, 0 ); + if( CurLine > lcount ) + CurLine = lcount; + NbLinesToScroll = lcount - CurLine - kNbVisibleLinesInEditCtrl; + + if( NbLinesToScroll < 0 ) + NbLinesToScroll = 0; + + SendDlgItemMessage(hWnd,IDC_EDIT2, EM_LINESCROLL, 0, NbLinesToScroll ); + } +} + +void CConsole::shutConsole(HWND _hWndParent) +{ + +// if (_hWndParent!=hWndParent) return ; + + OutputDebugString("shutConsole\n"); + + if (IsWindow(hWnd)) + { + DestroyWindow(hWnd); + hWnd=NULL; + } + + +} + + +CConsole::CConsole() +{ + + mod = LoadLibrary("riched20.dll"); +// CEmulator::theEmulator->theConsole=this; + hWnd = NULL; + enable = 0; +} + +CConsole::~CConsole() +{ + FreeLibrary(mod); +// CEmulator::theEmulator->theConsole=NULL; + +} + +void CConsole::initConsole(HINSTANCE _hInst,HWND _hWndParent) +{ + + if (hWnd) + { + outputInfo("Console already running\n"); + return ; // Already running + } + + hWndParent = _hWndParent; + + //theConsole=this; + HistorySize = 0; + visible=0; + kNbVisibleLinesInEditCtrl = 23; + BufferSize = HIST_DEFAULT_LIMIT; + inputBuffer[0]=0; + + + // console +// __asm int 3; + OutputDebugString("createConsole\n"); + + hWnd = CreateDialogParam(_hInst, MAKEINTRESOURCE(IDD_CONSOLE), _hWndParent, ConsoleProc,(LPARAM)this); + if (!hWnd) + { + outputInfo("createConsole failed... %d (%X)\n",GetLastError(),_hInst); + // theConsole=NULL; + return ; + } + + SendDlgItemMessage(hWnd,IDC_EDIT2, EM_EXLIMITTEXT, (WPARAM)HIST_DEFAULT_LIMIT, 0); + + + return ; +} + + +void CConsole::toggleConsole() +{ + outputInfo("toggleConsole\n"); + + if (!visible) + showConsole(); + else + hideConsole(); + +} + + + +int CConsole::read(char* buf) +{ + int l; + + if (!enable) enableConsole(); + + while(!inputBuffer[0] && IsWindow(hWnd)) + { + Sleep(100); + if (r_sim65816.should_emulator_terminate()) + break; + } + + strcpy(buf,inputBuffer); + l = strlen(buf); + if (l) + buf[l++]=0x0A; + buf[l]=0; + inputBuffer[0]=0; + return l; +} + +void CConsole::enableConsole() +{ + EnableWindow(GetDlgItem(hWnd,IDC_EDIT1),TRUE); + enable=1; + inputBuffer[0]=0; // clear previous commands + if (!visible) + showConsole(); +} + +void CConsole::disableConsole() +{ + + EnableWindow(GetDlgItem(hWnd,IDC_EDIT1),FALSE); + enable=0; +} + + diff --git a/Common/sounds/Apple Panic Start.wav b/Common/sounds/Apple Panic Start.wav new file mode 100644 index 0000000..fa2f92b Binary files /dev/null and b/Common/sounds/Apple Panic Start.wav differ diff --git a/Common/sounds/Apple_2_Disk_Drive_Sounds.txt b/Common/sounds/Apple_2_Disk_Drive_Sounds.txt new file mode 100644 index 0000000..17d6f31 --- /dev/null +++ b/Common/sounds/Apple_2_Disk_Drive_Sounds.txt @@ -0,0 +1,130 @@ + +Apple 2 Disk Drive Sounds Copyright (C) Moose O'Malley, +-------------------------- January 2011. + + +===========================================================+ + | T A B L E O F C O N T E N T S | + +===========================================================+ + | * Introduction | + | * Other Projects Using These Sounds | + | * License / Limitations / Restrictions | + | * Amendment History | + | * Contacting the Program's Author | + +===========================================================+ + +Introduction : +-------------- + +This ZIP file contains the Apple 2 disk drive sounds that I recorded for +use with my "Apple 2 Disk Drive Sound Simulator" program (Windows 95 / 98 / +ME / NT / 2000 / XP, Vista, etc). + + + +About the Disk Drive Sounds: (from my "Apple 2 Disk Drive Sound Simulator" program's readme). +----------------------------- + +As people may know from the Apple 2 Emulation section of my WEB pages : + + At the best of times, the Apple 2 disk drive used to make horrible + grunting and scrapping sounds as it loaded programs. When I used to go + to the local Burleigh Heads library and used the Apple 2 there, everyone + in the library would stop and stare (and sometimes glare !) at us + whenever the Apple 2 was reading floppy disks - the grunts and groans + from the drive were *that* loud !! + + N.B. These terrible sounds were perfectly normal for Apple 2 drives, + and they were quite loud as well, even when using brand new floppy + disks and brand new floppy drives. + +However, people today didn't believe me about the sounds or how loud they +really were. + +So now, a short MP3 of some Apple 2 disk drive sounds is available from my +WEB page. + +And, in addition, I have written this program to simulate some Apple 2 +disk drive sounds. + +All of the Apple 2 disk drive sounds were recorded by me on April 10 and 11, +2000. To record the sounds, I used a cheap microphone hooked up to my +Windows 98 PC, which was running Goldwave a good sound editing program. +I placed the microphone at the entrance to the Apple 2 floppy drive, and +then proceeded to record the loading sounds the drive made for a bunch +of games and programs. (I own an Apple ][c with both internal and +external drives). + +Finally, in December 2001, I again listened carefully to the sounds I recorded +18 months ago, and edited out some of the more common sound bytes. + +Then, I wrote a Delphi program to play them back, and compiled all of the +sounds into a single resource file, which was later compiled and compressed +into the Executable program. That is why there are no WAV files accompanying +this program - they are all contained inside the EXE file !! (See my +"Apple 2 Disk Drive Sound Simulator" program). + +The "squeak" was a sound that the disk drive makes very occassionally +when (I think) it is swinging its read head backwards and forwards +very quickly and the rubber belt slips - not sure about how it happens +but it does happen. It is definitely a sound the drive makes - not +the door on the drive. I rember it happening on all of the Apple ]['s I +used in the early 1980's and it still happens on my Apple ][c - but it is +very occasional. + +The "Ghostbusters" digitised speech sound is not a disk drive sound, +but I thought it would be fun to add this sound in as well to show +what digitised speech on the Apple ][ sounded like. Back in the +early 80's, this speech was state of the art and I remember +times when people used to crowd around my Apple ][ just to +hear it say "Ghostbusters" !! + + +Other Projects Using These Sounds : +------------------------------------ + +See the readme file that accompanies my "Apple 2 Disk Drive Sound Simulator" +program. + + +License / Limitations / Restrictions : +--------------------------------------- + +These sounds are freeware - which means they are copyrighted, but +any person and any company is welcome to use them in your own programs / +projects, subject to one condition. + +I am a friendly guy and I like supporting / helping other software +developers. If you want to use these sounds in your own programs / +projects, then that is fine: all I ask is that you add a credit to me +on your projects's web page, the credits screen, the help file, +or similar. A credit something like this would be perfect: + + Apple ][ disk drive sounds courtesy of + Moose's Software Valley: http://move.to/moose + +Please don't just rip off my work / take my work without giving me +any credit. + +Hope this is OK. + +Long Live the Apple ][ !!! + + +Amendment History : +-------------------- + +Vers Date Description + +1.0 25-Jan-2011 First Public Release of these sounds on their own. + + +If this ZIP file was not downloaded from my Home Page, then +it is possibly an old version. The latest version of this +ZIP file is available from my WEB page - see below. + + Mike "Moose" O'Malley +____________________________________________________ + Moose's Software Valley - Established July, 1996. + WEB: http://move.to/moose +____________________________________________________ + \ No newline at end of file diff --git a/Common/sounds/Beep Beep.wav b/Common/sounds/Beep Beep.wav new file mode 100644 index 0000000..fae960d Binary files /dev/null and b/Common/sounds/Beep Beep.wav differ diff --git a/Common/sounds/Beep.wav b/Common/sounds/Beep.wav new file mode 100644 index 0000000..99c6bc2 Binary files /dev/null and b/Common/sounds/Beep.wav differ diff --git a/Common/sounds/Ghostbusters.wav b/Common/sounds/Ghostbusters.wav new file mode 100644 index 0000000..f5a4265 Binary files /dev/null and b/Common/sounds/Ghostbusters.wav differ diff --git a/Common/sounds/Grunt Grind 1.wav b/Common/sounds/Grunt Grind 1.wav new file mode 100644 index 0000000..aabee1c Binary files /dev/null and b/Common/sounds/Grunt Grind 1.wav differ diff --git a/Common/sounds/Grunt Grind 2.wav b/Common/sounds/Grunt Grind 2.wav new file mode 100644 index 0000000..6a7eef8 Binary files /dev/null and b/Common/sounds/Grunt Grind 2.wav differ diff --git a/Common/sounds/Read 1.wav b/Common/sounds/Read 1.wav new file mode 100644 index 0000000..9b26974 Binary files /dev/null and b/Common/sounds/Read 1.wav differ diff --git a/Common/sounds/Read 2.wav b/Common/sounds/Read 2.wav new file mode 100644 index 0000000..b7f77b0 Binary files /dev/null and b/Common/sounds/Read 2.wav differ diff --git a/Common/sounds/Read 3.wav b/Common/sounds/Read 3.wav new file mode 100644 index 0000000..c206939 Binary files /dev/null and b/Common/sounds/Read 3.wav differ diff --git a/Common/sounds/Read 4.wav b/Common/sounds/Read 4.wav new file mode 100644 index 0000000..b333f5d Binary files /dev/null and b/Common/sounds/Read 4.wav differ diff --git a/Common/sounds/Read 5.wav b/Common/sounds/Read 5.wav new file mode 100644 index 0000000..dc1a628 Binary files /dev/null and b/Common/sounds/Read 5.wav differ diff --git a/Common/sounds/Read 6.wav b/Common/sounds/Read 6.wav new file mode 100644 index 0000000..8f623c0 Binary files /dev/null and b/Common/sounds/Read 6.wav differ diff --git a/Common/sounds/Read 7.wav b/Common/sounds/Read 7.wav new file mode 100644 index 0000000..a1f3105 Binary files /dev/null and b/Common/sounds/Read 7.wav differ diff --git a/Common/sounds/Search Skip Search 1.wav b/Common/sounds/Search Skip Search 1.wav new file mode 100644 index 0000000..ca203f6 Binary files /dev/null and b/Common/sounds/Search Skip Search 1.wav differ diff --git a/Common/sounds/Search Skip Search 2.wav b/Common/sounds/Search Skip Search 2.wav new file mode 100644 index 0000000..0d87532 Binary files /dev/null and b/Common/sounds/Search Skip Search 2.wav differ diff --git a/Common/sounds/Search Skip Search 3.wav b/Common/sounds/Search Skip Search 3.wav new file mode 100644 index 0000000..fbab1d3 Binary files /dev/null and b/Common/sounds/Search Skip Search 3.wav differ diff --git a/Common/sounds/Search Skip Search 4.wav b/Common/sounds/Search Skip Search 4.wav new file mode 100644 index 0000000..a4240a7 Binary files /dev/null and b/Common/sounds/Search Skip Search 4.wav differ diff --git a/Common/sounds/Search Skip Search 5.wav b/Common/sounds/Search Skip Search 5.wav new file mode 100644 index 0000000..e111207 Binary files /dev/null and b/Common/sounds/Search Skip Search 5.wav differ diff --git a/Common/sounds/Spin Up Search 1.wav b/Common/sounds/Spin Up Search 1.wav new file mode 100644 index 0000000..468f6f7 Binary files /dev/null and b/Common/sounds/Spin Up Search 1.wav differ diff --git a/Common/sounds/Spin Up Search 2.wav b/Common/sounds/Spin Up Search 2.wav new file mode 100644 index 0000000..a822ac0 Binary files /dev/null and b/Common/sounds/Spin Up Search 2.wav differ diff --git a/Common/sounds/Spin.wav b/Common/sounds/Spin.wav new file mode 100644 index 0000000..1168ae8 Binary files /dev/null and b/Common/sounds/Spin.wav differ diff --git a/Common/sounds/Sqweak.wav b/Common/sounds/Sqweak.wav new file mode 100644 index 0000000..b9b59bd Binary files /dev/null and b/Common/sounds/Sqweak.wav differ diff --git a/Common/sounds/eject.aiff b/Common/sounds/eject.aiff new file mode 100644 index 0000000..23ada3f Binary files /dev/null and b/Common/sounds/eject.aiff differ diff --git a/kegs/Src/StdString.h b/kegs/Src/StdString.h index ce2940d..7d681a9 100644 --- a/kegs/Src/StdString.h +++ b/kegs/Src/StdString.h @@ -447,7 +447,9 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2) #elif defined(_MSC_VER ) - #define SS_USE_FACET(loc, fac) std::_USE(loc, fac) + // #define SS_USE_FACET(loc, fac) std::_USE(loc, fac) + #define SS_USE_FACET(loc, fac) std::use_facet(loc) + // ...and #elif defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE) diff --git a/kegs/Src/bigfile.cpp b/kegs/Src/bigfile.cpp new file mode 100644 index 0000000..3a19dd1 --- /dev/null +++ b/kegs/Src/bigfile.cpp @@ -0,0 +1,184 @@ +// +// bigfile.cpp +// ActiveGS_Karateka +// +// Created by Olivier Goguel on 14/12/2017. +// + + +#include "bigfile.h" + + +#if KARATEKA_BIGFILE +#define ONLY_BIG +#endif + +#define BIG 0x8000 + +struct CBigFile +{ + const char* filename; + off_t seek_pos; + const char* buffer; + int size; + bool opened; + int code; +}; + + +#if KARATEKA_BIGFILE +extern "C" const char karateka_bin[]; +extern "C" const char karateka_activegsxml[]; + + +CBigFile files[] ={ + "karateka.bin", 0, karateka_bin,143360,false,0xEA, + "karateka.activegsxml", 0, karateka_activegsxml,5260,false,0XEA, + + NULL,0,NULL,0,false +}; +#else +CBigFile files[] ={ + NULL,0,NULL,0,false +}; + +#endif + + +/* +off_t seek_pos = -1; +const char* buffer = NULL; +int file_size = -1; +*/ + +static const char* getfile(const char* p) +{ + int l = strlen(p); + while(l>=0) + { + if (p[l]=='/') + return p+l+1; + l--; + } + return p; +} + + +int big_open(const char *_pathname, int _flags, mode_t _mode) +{ + const char* file = getfile(_pathname); + if (file[0]=='*') + { +#if KARATEKA_BIGFILE + int l = 0; + while(files[l].filename != NULL) + { + if (!strcmp(file+1,files[l].filename)) + { + if (files[l].opened) + { + printf("already opened %s",_pathname); + // return -1; + } + files[l].opened = true; + files[l].seek_pos = 0; + return BIG+l; + } + l++; + } + return -1; +#else + return open(_pathname+1,_flags,_mode); +#endif + } + else + { +#ifdef ONLY_BIG + printf("missing file %s\n",_pathname); + return -1; +#else + return open(_pathname,_flags,_mode); +#endif + } +} + + + +off_t big_lseek(int _fd, off_t _offset, int _whence) +{ + if ( ( _fd & BIG ) == 0 ) + { +#ifdef ONLY_BIG + return 0; +#else + return lseek(_fd, _offset, _whence); +#endif + } + else + { + CBigFile& file = files[_fd &~BIG]; + if (_whence == SEEK_SET) + file.seek_pos = _offset; + else + if (_whence == SEEK_END) + file.seek_pos = file.size-1; + + return file.seek_pos; + } +} + +ssize_t big_read(int _fd, void *_buf, size_t _count) +{ + if ( ( _fd & BIG ) == 0 ) + { +#ifdef ONLY_BIG + return 0; +#else + return read(_fd, _buf, _count); +#endif + } + else + { + CBigFile& file = files[_fd &~BIG]; + + if (_count + file.seek_pos > file.size) + _count = file.size - file.seek_pos; + + memcpy(_buf,file.buffer+file.seek_pos,_count); + char *decode = (char*)_buf; + for(int i=0;i<_count;i++) + decode[i] ^= file.code; + file.seek_pos += _count; + return _count; + } +} + +ssize_t big_write(int _fd, void* _buf, size_t _count) +{ + if ( ( _fd & BIG ) == 0 ) + { + return _count; + } + else { + return write(_fd, _buf, _count); + } +} + + +int big_close(int _fd) +{ + if ( ( _fd & BIG ) == 0 ) + { + CBigFile& file = files[_fd &~BIG]; + if (!file.opened) + { + printf("nothing to close"); + return -1; + } + file.opened=false; + } + else + close(_fd); + return 0; +} + diff --git a/kegs/Src/bigfile.h b/kegs/Src/bigfile.h new file mode 100644 index 0000000..1af917b --- /dev/null +++ b/kegs/Src/bigfile.h @@ -0,0 +1,27 @@ +// +// bigfile.hpp +// ActiveGS_Karateka +// +// Created by Olivier Goguel on 14/12/2017. +// + + +#ifndef bigfile_hpp +#define bigfile_hpp + +#include "defc.h" + +#if _MSC_VER +#define mode_t int +#define ssize_t int +#endif + +int big_open(const char *_pathname, int _flags, mode_t _mode); +off_t big_lseek(int _fd, off_t _offset, int _whence); +ssize_t big_read(int _fd, void *_buf, size_t _count); +ssize_t big_write(int _fd, void *_buf, size_t _count); +int big_close(int _fd); +ssize_t big_write(int _fd, const void* _buf, size_t _count); + +#endif /* bigfile_hpp */ + diff --git a/kegs/Src/sim65816.h b/kegs/Src/sim65816.h index 46dc32d..c2964a8 100644 --- a/kegs/Src/sim65816.h +++ b/kegs/Src/sim65816.h @@ -1,9 +1,9 @@ -/* - ActiveGS, Copyright 2004-2016 Olivier Goguel, https://github.com/ogoguel/ActiveGS - Based on Kegs, Copyright 2004 Kent Dickey, https://kegs.sourceforge.net - This code is covered by the GNU GPL licence -*/ - +/* + ActiveGS, Copyright 2004-2016 Olivier Goguel, https://github.com/ogoguel/ActiveGS + Based on Kegs, Copyright 2004 Kent Dickey, https://kegs.sourceforge.net + This code is covered by the GNU GPL licence +*/ + #pragma once #define START_DCYCS (0.0) diff --git a/kegs/Win/dirent-win32.h b/kegs/Win/dirent-win32.h new file mode 100644 index 0000000..6425174 --- /dev/null +++ b/kegs/Win/dirent-win32.h @@ -0,0 +1,230 @@ +/***************************************************************************** + * dirent.h - dirent API for Microsoft Visual Studio + * + * Copyright (C) 2006 Toni Ronkko + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * ``Software''), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Dec 15, 2009, John Cunningham + * Added rewinddir member function + * + * Jan 18, 2008, Toni Ronkko + * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string + * between multi-byte and unicode representations. This makes the + * code simpler and also allows the code to be compiled under MingW. Thanks + * to Azriel Fasten for the suggestion. + * + * Mar 4, 2007, Toni Ronkko + * Bug fix: due to the strncpy_s() function this file only compiled in + * Visual Studio 2005. Using the new string functions only when the + * compiler version allows. + * + * Nov 2, 2006, Toni Ronkko + * Major update: removed support for Watcom C, MS-DOS and Turbo C to + * simplify the file, updated the code to compile cleanly on Visual + * Studio 2005 with both unicode and multi-byte character strings, + * removed rewinddir() as it had a bug. + * + * Aug 20, 2006, Toni Ronkko + * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified + * comments by removing SGML tags. + * + * May 14 2002, Toni Ronkko + * Embedded the function definitions directly to the header so that no + * source modules need to be included in the Visual Studio project. Removed + * all the dependencies to other projects so that this very header can be + * used independently. + * + * May 28 1998, Toni Ronkko + * First version. + *****************************************************************************/ +#ifndef DIRENT_H +#define DIRENT_H + +#include +#include +#include + + +typedef struct dirent +{ + char d_name[MAX_PATH + 1]; /* current dir entry (multi-byte char string) */ + WIN32_FIND_DATAA data; /* file attributes */ +} dirent; + + +typedef struct DIR +{ + dirent current; /* Current directory entry */ + int cached; /* Indicates un-processed entry in memory */ + HANDLE search_handle; /* File search handle */ + char patt[MAX_PATH + 3]; /* search pattern (3 = pattern + "\\*\0") */ +} DIR; + + +/* Forward declarations */ +static DIR *opendir (const char *dirname); +static struct dirent *readdir (DIR *dirp); +static int closedir (DIR *dirp); +static void rewinddir(DIR* dirp); + + +/* Use the new safe string functions introduced in Visual Studio 2005 */ +#if defined(_MSC_VER) && _MSC_VER >= 1400 +# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE) +#else +# define STRNCPY(dest,src,size) strncpy((dest),(src),(size)) +#endif + + +/***************************************************************************** + * Open directory stream DIRNAME for read and return a pointer to the + * internal working area that is used to retrieve individual directory + * entries. + */ +static DIR *opendir(const char *dirname) +{ + DIR *dirp; + assert (dirname != NULL); + assert (strlen (dirname) < MAX_PATH); + + /* construct new DIR structure */ + dirp = (DIR*) malloc (sizeof (struct DIR)); + if (dirp != NULL) { + char *p; + + /* take directory name... */ + STRNCPY (dirp->patt, dirname, sizeof(dirp->patt)); + dirp->patt[MAX_PATH] = '\0'; + + /* ... and append search pattern to it */ + p = strchr (dirp->patt, '\0'); + if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') { + *p++ = '\\'; + } + *p++ = '*'; + *p = '\0'; + + /* open stream and retrieve first file */ + dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); + if (dirp->search_handle == INVALID_HANDLE_VALUE) { + /* invalid search pattern? */ + free (dirp); + return NULL; + } + + /* there is an un-processed directory entry in memory now */ + dirp->cached = 1; + } + + return dirp; +} + + +/***************************************************************************** + * Read a directory entry, and return a pointer to a dirent structure + * containing the name of the entry in d_name field. Individual directory + * entries returned by this very function include regular files, + * sub-directories, pseudo-directories "." and "..", but also volume labels, + * hidden files and system files may be returned. + */ +static struct dirent *readdir(DIR *dirp) +{ + assert (dirp != NULL); + + if (dirp->search_handle == INVALID_HANDLE_VALUE) { + /* directory stream was opened/rewound incorrectly or ended normally */ + return NULL; + } + + /* get next directory entry */ + if (dirp->cached != 0) { + /* a valid directory entry already in memory */ + dirp->cached = 0; + } else { + /* read next directory entry from disk */ + if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) { + /* the very last file has been processed or an error occured */ + FindClose (dirp->search_handle); + dirp->search_handle = INVALID_HANDLE_VALUE; + return NULL; + } + } + + /* copy as a multibyte character string */ + STRNCPY ( dirp->current.d_name, + dirp->current.data.cFileName, + sizeof(dirp->current.d_name) ); + dirp->current.d_name[MAX_PATH] = '\0'; + + return &dirp->current; +} + + +/***************************************************************************** + * Close directory stream opened by opendir() function. Close of the + * directory stream invalidates the DIR structure as well as any previously + * read directory entry. + */ +static int closedir(DIR *dirp) +{ + assert (dirp != NULL); + + /* release search handle */ + if (dirp->search_handle != INVALID_HANDLE_VALUE) { + FindClose (dirp->search_handle); + dirp->search_handle = INVALID_HANDLE_VALUE; + } + + /* release directory handle */ + free (dirp); + return 0; +} + + +/***************************************************************************** + * Resets the position of the directory stream to which dirp refers to the + * beginning of the directory. It also causes the directory stream to refer + * to the current state of the corresponding directory, as a call to opendir() + * would have done. If dirp does not refer to a directory stream, the effect + * is undefined. + */ +static void rewinddir(DIR* dirp) +{ + /* release search handle */ + if (dirp->search_handle != INVALID_HANDLE_VALUE) { + FindClose (dirp->search_handle); + dirp->search_handle = INVALID_HANDLE_VALUE; + } + + /* open new search handle and retrieve first file */ + dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); + if (dirp->search_handle == INVALID_HANDLE_VALUE) { + /* invalid search pattern? */ + free (dirp); + return; + } + + /* there is an un-processed directory entry in memory now */ + dirp->cached = 1; +} + + +#endif /*DIRENT_H*/ diff --git a/kegs/Win/joystick_win.cpp b/kegs/Win/joystick_win.cpp new file mode 100644 index 0000000..ed8c148 --- /dev/null +++ b/kegs/Win/joystick_win.cpp @@ -0,0 +1,123 @@ +/************************************************************************/ +/* KEGS: Apple //gs Emulator */ +/* Copyright 2002 by Kent Dickey */ +/* */ +/* This code is covered by the GNU GPL */ +/* */ +/* The KEGS web page is kegs.sourceforge.net */ +/* You may contact the author at: kadickey@alumni.princeton.edu */ +/************************************************************************/ + +const char rcsid_joystick_driver_c[] = "@(#)$KmKId: joystick_driver.c,v 1.12 2004-10-17 21:28:48-04 kentd Exp $"; + +#include "../src/defc.h" +#include "../src/moremem.h" +#include "../src/paddles.h" + +# include +# include + + +void joystick_init() +{ + JOYINFO info; + JOYCAPS joycap; + MMRESULT ret1, ret2; + int i; + + // Check that there is a joystick device + if(joyGetNumDevs() <= 0) { + printf("No joystick hardware detected\n"); + g_joystick_native_type1 = -1; + g_joystick_native_type2 = -1; + return; + } + + g_joystick_native_type1 = -1; + g_joystick_native_type2 = -1; + + // Check that at least joystick 1 or joystick 2 is available + ret1 = joyGetPos(JOYSTICKID1, &info); + ret2 = joyGetDevCaps(JOYSTICKID1, &joycap, sizeof(joycap)); + if(ret1 == JOYERR_NOERROR && ret2 == JOYERR_NOERROR) { + g_joystick_native_type1 = JOYSTICKID1; + printf("Joystick #1 = %s\n", joycap.szPname); + g_joystick_native_type = JOYSTICKID1; + } + ret1 = joyGetPos(JOYSTICKID2, &info); + ret2 = joyGetDevCaps(JOYSTICKID2, &joycap, sizeof(joycap)); + if(ret1 == JOYERR_NOERROR && ret2 == JOYERR_NOERROR) { + g_joystick_native_type2 = JOYSTICKID2; + printf("Joystick #2 = %s\n", joycap.szPname); + if(g_joystick_native_type < 0) { + g_joystick_native_type = JOYSTICKID2; + } + } + + for(i = 0; i < 4; i++) { + g_paddles.g_paddle_val[i] = 32767; + } + g_moremem.g_paddle_buttons = 0xc; + + joystick_update(0.0); +} + +void +joystick_update(double dcycs) +{ + JOYCAPS joycap; + JOYINFO info; + UINT id; + MMRESULT ret1, ret2; + + id = g_joystick_native_type; + + ret1 = joyGetDevCaps(id, &joycap, sizeof(joycap)); + ret2 = joyGetPos(id, &info); + if(ret1 == JOYERR_NOERROR && ret2 == JOYERR_NOERROR) { + // OG Convert to -32767/32767 + g_paddles.g_paddle_val[0] = (info.wXpos - joycap.wXmin) * 65535 / (joycap.wXmax - joycap.wXmin) - 32768; + g_paddles.g_paddle_val[1] = (info.wYpos - joycap.wYmin) * 65535 / (joycap.wYmax - joycap.wYmin) - 32768; + + if(info.wButtons & JOY_BUTTON1) { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons | 1; + } else { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons & (~1); + } + if(info.wButtons & JOY_BUTTON2) { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons | 2; + } else { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons & (~2); + } + paddle_update_trigger_dcycs(dcycs); + } +} + +void +joystick_update_buttons() +{ + JOYINFOEX info; + UINT id; + + id = g_joystick_native_type; + + info.dwSize = sizeof(JOYINFOEX); + info.dwFlags = JOY_RETURNBUTTONS; + if(joyGetPosEx(id, &info) == JOYERR_NOERROR) { + if(info.dwButtons & JOY_BUTTON1) { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons | 1; + } else { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons & (~1); + } + if(info.dwButtons & JOY_BUTTON2) { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons | 2; + } else { + g_moremem.g_paddle_buttons = g_moremem.g_paddle_buttons & (~2); + } + } +} + +// OG +void joystick_shut() +{ +} diff --git a/kegs/Win/scc_windriver.cpp b/kegs/Win/scc_windriver.cpp new file mode 100644 index 0000000..90359c0 --- /dev/null +++ b/kegs/Win/scc_windriver.cpp @@ -0,0 +1,260 @@ +/************************************************************************/ +/* KEGS: Apple //gs Emulator */ +/* Copyright 2002 by Kent Dickey */ +/* */ +/* This code is covered by the GNU GPL */ +/* */ +/* The KEGS web page is kegs.sourceforge.net */ +/* You may contact the author at: kadickey@alumni.princeton.edu */ +/************************************************************************/ + +const char rcsid_scc_windriver_c[] = "@(#)$KmKId: scc_windriver.c,v 1.4 2004-11-19 02:00:46-05 kentd Exp $"; + +/* This file contains the Win32 COM1/COM2 calls */ + +#include "../src/defc.h" +#include "../src/scc.h" + +#ifdef UNDER_CE +#define vsnprintf _vsnprintf +#endif + + +extern word32 g_c025_val; + +#ifdef _WIN32 +int +scc_serial_win_init(int port) +{ + COMMTIMEOUTS commtimeouts; + TCHAR str_buf[8]; + Scc *scc_ptr; + HANDLE host_handle; + int state; + int ret; + + scc_ptr = &(g_scc.scc_stat[port]); + + scc_ptr->state = 0; /* mark as failed */ + +#ifdef UNICODE + wsprintf(&str_buf[0], _T("COM%d"), port+1); +#else + sprintf(&str_buf[0], "COM%d", port+1); +#endif + host_handle = CreateFile(&str_buf[0], GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + + scc_ptr->host_handle = host_handle; + scc_ptr->host_handle2 = malloc(sizeof(DCB)); + + printf("scc_socket_init %d called, host_handle: %p\n", port, + host_handle); + + if(host_handle == INVALID_HANDLE_VALUE) { + scc_ptr->host_handle = 0; + return 0; + } + + scc_serial_win_change_params(port); + + + commtimeouts.ReadIntervalTimeout = MAXDWORD; + commtimeouts.ReadTotalTimeoutMultiplier = 0; + commtimeouts.ReadTotalTimeoutConstant = 0; + commtimeouts.WriteTotalTimeoutMultiplier = 0; + commtimeouts.WriteTotalTimeoutConstant = 10; + ret = SetCommTimeouts(host_handle, &commtimeouts); + if(ret == 0) { + printf("setcommtimeout ret: %d\n", ret); + } + + state = 2; /* raw serial */ + scc_ptr->state = state; + + return state; +} + +void +scc_serial_win_change_params(int port) +{ + DCB *dcbptr; + HANDLE host_handle; + Scc *scc_ptr; + int ret; + + scc_ptr = &(g_scc.scc_stat[port]); + + host_handle = scc_ptr->host_handle; + dcbptr = (DCB*)scc_ptr->host_handle2; // OG Added cast + if(host_handle == 0) { + return; + } + + ret = GetCommState(host_handle, dcbptr); + if(ret == 0) { + printf("getcomm port%d ret: %d\n", port, ret); + } + +#if 1 + printf("dcb.baudrate: %d, bytesize:%d, stops:%d, parity:%d\n", + (int)dcbptr->BaudRate, (int)dcbptr->ByteSize, + (int)dcbptr->StopBits, (int)dcbptr->Parity); + printf("dcb.binary: %d, ctsflow: %d, dsrflow: %d, dtr: %d, dsr: %d\n", + (int)dcbptr->fBinary, + (int)dcbptr->fOutxCtsFlow, + (int)dcbptr->fOutxDsrFlow, + (int)dcbptr->fDtrControl, + (int)dcbptr->fDsrSensitivity); + printf("dcb.txonxoff:%d, outx:%d, inx: %d, null: %d, rts: %d\n", + (int)dcbptr->fTXContinueOnXoff, + (int)dcbptr->fOutX, + (int)dcbptr->fInX, + (int)dcbptr->fNull, + (int)dcbptr->fRtsControl); + printf("dcb.fAbortOnErr:%d, fParity:%d\n", (int)dcbptr->fAbortOnError, + (int)dcbptr->fParity); +#endif + + dcbptr->fAbortOnError = 0; + + dcbptr->BaudRate = scc_ptr->baud_rate; + dcbptr->ByteSize = scc_ptr->char_size; + dcbptr->StopBits = ONESTOPBIT; + switch((scc_ptr->reg[4] >> 2) & 0x3) { + case 2: // 1.5 stop bits + dcbptr->StopBits = ONE5STOPBITS; + break; + case 3: // 2 stop bits + dcbptr->StopBits = TWOSTOPBITS; + break; + } + + dcbptr->Parity = NOPARITY; + switch((scc_ptr->reg[4]) & 0x3) { + case 1: // Odd parity + dcbptr->Parity = ODDPARITY; + break; + case 3: // Even parity + dcbptr->Parity = EVENPARITY; + break; + } + + dcbptr->fNull = 0; + dcbptr->fDtrControl = DTR_CONTROL_ENABLE; + dcbptr->fDsrSensitivity = 0; + dcbptr->fOutxCtsFlow = 0; + dcbptr->fOutxDsrFlow = 0; + dcbptr->fParity = 0; + dcbptr->fInX = 0; + dcbptr->fOutX = 0; + dcbptr->fRtsControl = RTS_CONTROL_ENABLE; + + ret = SetCommState(host_handle, dcbptr); + if(ret == 0) { + printf("SetCommState ret: %d, new baud: %d\n", ret, + (int)dcbptr->BaudRate); + } +} + +void +scc_serial_win_fill_readbuf(int port, int space_left, double dcycs) +{ + byte tmp_buf[256]; + Scc *scc_ptr; + HANDLE host_handle; + DWORD bytes_read; + DWORD i; + int ret; + + scc_ptr = &(g_scc.scc_stat[port]); + + host_handle = scc_ptr->host_handle; + if(host_handle == 0) { + return; + } + + /* Try reading some bytes */ + space_left = MIN(256, space_left); + ret = ReadFile(host_handle, tmp_buf, space_left, &bytes_read, NULL); + + if(ret == 0) { + printf("ReadFile ret 0\n"); + } + + if(ret && (bytes_read > 0)) { + for(i = 0; i < bytes_read; i++) { + scc_add_to_readbuf(port, tmp_buf[i], dcycs); + } + } + +} + +void +scc_serial_win_empty_writebuf(int port) +{ + Scc *scc_ptr; + HANDLE host_handle; + int rdptr; + int wrptr; + int done; + word32 err_code; + DWORD bytes_written; + int ret; + int len; + + scc_ptr = &(g_scc.scc_stat[port]); + + //printf("win_empty_writebuf, host_handle: %d\n", scc_ptr->host_handle); + host_handle = scc_ptr->host_handle; + if(host_handle == 0) { + return; + } + + /* Try writing some bytes */ + done = 0; + while(!done) { + rdptr = scc_ptr->out_rdptr; + wrptr = scc_ptr->out_wrptr; + if(rdptr == wrptr) { + //printf("...rdptr == wrptr\n"); + done = 1; + break; + } + len = wrptr - rdptr; + if(len < 0) { + len = SCC_OUTBUF_SIZE - rdptr; + } + if(len > 32) { + len = 32; + } + if(len <= 0) { + done = 1; + break; + } + bytes_written = 1; + ret = WriteFile(host_handle, &(scc_ptr->out_buf[rdptr]), len, + &bytes_written, NULL); + printf("WriteFile ret: %d, bytes_written:%d, len:%d\n", ret, + (int)bytes_written, len); + + err_code = (word32)-1; + if(ret == 0) { + err_code = (word32)GetLastError(); + printf("WriteFile ret:0, err_code: %08x\n", err_code); + } + + if(ret == 0 || (bytes_written == 0)) { + done = 1; + break; + } else { + rdptr = rdptr + bytes_written; + if(rdptr >= SCC_OUTBUF_SIZE) { + rdptr = rdptr - SCC_OUTBUF_SIZE; + } + scc_ptr->out_rdptr = rdptr; + } + } +} + +#endif diff --git a/kegs/Win/win32snd_driver.cpp b/kegs/Win/win32snd_driver.cpp new file mode 100644 index 0000000..425f46b --- /dev/null +++ b/kegs/Win/win32snd_driver.cpp @@ -0,0 +1,261 @@ +/************************************************************************/ +/* KEGS: Apple //gs Emulator */ +/* Copyright 2002 by Kent Dickey */ +/* */ +/* This code is covered by the GNU GPL */ +/* */ +/* The KEGS web page is kegs.sourceforge.net */ +/* You may contact the author at: kadickey@alumni.princeton.edu */ +/************************************************************************/ + +const char rcsid_win32snd_driver_c[] = "@(#)$KmKId: win32snd_driver.c,v 1.5 2002-11-19 03:09:59-05 kadickey Exp $"; + +#include "../src/defc.h" +#include "../src/sound.h" + +# include +# include + +//extern int Verbose; + +//extern int g_audio_rate; + +unsigned int __stdcall child_sound_loop_win32(void *param); +void check_wave_error(int res, char *str); + +#define NUM_WAVE_HEADERS 8 + +#ifndef __CYGWIN__ +HWAVEOUT g_wave_handle = NULL; // OG Default value must be set +WAVEHDR g_wavehdr[NUM_WAVE_HEADERS]; +#endif + +//extern int g_audio_enable; +extern word32 *g_sound_shm_addr; +// extern int g_preferred_rate; + +int g_win32snd_buflen = 0x1000; + +void +x_snd_init(word32 *shmaddr) +{ +// printf("win32snd_init\n"); +// child_sound_loop(-1, -1, shmaddr); + + return; +} + + +// OG Added global to free the dedicated win32 sound memory +byte *bptr = NULL; + +// OG shut win32 sound resources +void +x_snd_shutdown() +{ + + if (g_wave_handle) + { + MMRESULT res = waveOutReset(g_wave_handle); + if (res!=MMSYSERR_NOERROR ) + printf("waveOutReset Failed"); + + res = waveOutClose(g_wave_handle); + if (res!=MMSYSERR_NOERROR ) + printf("waveOutClose Failed"); + g_wave_handle=NULL; + } + // OG Free dedicated sound memory + if (bptr) + { + free(bptr); + bptr = NULL; + } + +} + + +void CALLBACK handle_wav_snd(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) +{ + LPWAVEHDR lpwavehdr; + + /* Only service "buffer done playing messages */ + if(uMsg == WOM_DONE) { + lpwavehdr = (LPWAVEHDR)dwParam1; + if(lpwavehdr->dwFlags == (WHDR_DONE | WHDR_PREPARED)) { + lpwavehdr->dwUser = FALSE; + } + } + + return; +} +void +check_wave_error(int res, char *str) +{ + TCHAR buf[256]; + + if(res == MMSYSERR_NOERROR) { + return; + } + + waveOutGetErrorText(res, &buf[0], sizeof(buf)); + printf("%s: %s\n", str, buf); + x_exit(1); +} + +void +x_snd_child_init() +{ + WAVEFORMATEX wavefmt; + WAVEOUTCAPS caps; + +// OG Moved as global variable (to rename) +// byte *bptr; + int bits_per_sample, channels, block_align; + int blen; + int res; + int i; + + memset(&wavefmt, 0, sizeof(WAVEFORMATEX)); + + wavefmt.wFormatTag = WAVE_FORMAT_PCM; +#ifndef UNDER_CE + bits_per_sample = 16; + wavefmt.nSamplesPerSec = g_sound.g_audio_rate; +#else + bits_per_sample = 16; + wavefmt.nSamplesPerSec = 12000; +#endif + + channels = 2; + wavefmt.wBitsPerSample = bits_per_sample; + wavefmt.nChannels = channels; + block_align = channels * (bits_per_sample / 8); + wavefmt.nBlockAlign = block_align; + wavefmt.nAvgBytesPerSec = block_align * g_sound.g_audio_rate; + + res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt, 0, 0, + WAVE_FORMAT_QUERY); + + if(res != MMSYSERR_NOERROR) { + printf("Cannot open audio device\n"); + g_sound.g_audio_enable = 0; + return; + } + + res = waveOutOpen(&g_wave_handle, WAVE_MAPPER, &wavefmt, + (DWORD_PTR)handle_wav_snd, 0, CALLBACK_FUNCTION | WAVE_ALLOWSYNC); + + if(res != MMSYSERR_NOERROR) { + printf("Cannot register audio\n"); + g_sound.g_audio_enable = 0; + return; + } + + g_sound.g_audio_rate = wavefmt.nSamplesPerSec; + + blen = (SOUND_SHM_SAMP_SIZE * 4 * 2) / NUM_WAVE_HEADERS; + g_win32snd_buflen = blen; + bptr = (byte*)malloc(blen * NUM_WAVE_HEADERS); // OG Added cast + if(bptr == NULL) { + printf("Unabled to allocate sound buffer\n"); + x_exit(1); + } + + for(i = 0; i < NUM_WAVE_HEADERS; i++) { + memset(&g_wavehdr[i], 0, sizeof(WAVEHDR)); + g_wavehdr[i].dwUser = FALSE; + g_wavehdr[i].lpData = (LPSTR)&(bptr[i*blen]); // OG Added cast + g_wavehdr[i].dwBufferLength = blen; + g_wavehdr[i].dwFlags = 0; + g_wavehdr[i].dwLoops = 0; + res = waveOutPrepareHeader(g_wave_handle, &g_wavehdr[i], + sizeof(WAVEHDR)); + check_wave_error(res, "waveOutPrepareHeader"); + } + + res = waveOutGetDevCaps((UINT_PTR)g_wave_handle, &caps, sizeof(caps)); + check_wave_error(res, "waveOutGetDevCaps"); + printf("Using %s\n", caps.szPname); + printf(" Bits per Sample = %d. Channels = %d\n", + wavefmt.wBitsPerSample, wavefmt.nChannels); + printf(" Sampling rate = %d, avg_bytes_per_sec = %d\n", + (int)wavefmt.nSamplesPerSec, (int)wavefmt.nAvgBytesPerSec); + + set_audio_rate(g_sound.g_audio_rate); + +} + +void +win32_send_audio2(byte *ptr, int size) +{ + int found; + int res; + int i; + + found = 0; + for(i = 0; i < NUM_WAVE_HEADERS; i++) { + if(g_wavehdr[i].dwUser == FALSE) { + found = 1; + break; + } + } + + if(!found) { + /* all audio buffers busy, just get out */ + return; + } + + memcpy(g_wavehdr[i].lpData, ptr, size); + g_wavehdr[i].dwBufferLength = size; + g_wavehdr[i].dwUser = TRUE; + + res = waveOutWrite(g_wave_handle, &g_wavehdr[i], sizeof(g_wavehdr)); + check_wave_error(res, "waveOutWrite"); + + return; +} + +int +x_snd_send_audio(byte *ptr, int in_size) +{ + int size; + int tmpsize; + + size = in_size; + while(size > 0) { + tmpsize = size; + if(size > g_win32snd_buflen) { + tmpsize = g_win32snd_buflen; + } + win32_send_audio2(ptr, tmpsize); + ptr += tmpsize; + size = size - tmpsize; + } + + return in_size; +} + +word32* x_sound_allocate(int size) +{ +word32 *shmaddr; + shmaddr = (word32*)malloc(size); + memset(shmaddr, 0, size); + return shmaddr; +} + + +void x_sound_free(word32* _mem) +{ + if (_mem) + free(_mem); + +} + +void x_async_sound_init() +{ +} + +void x_async_snd_shutdown() +{ +} \ No newline at end of file diff --git a/kegs/Win/win_activegs.cpp b/kegs/Win/win_activegs.cpp new file mode 100644 index 0000000..1c96c21 --- /dev/null +++ b/kegs/Win/win_activegs.cpp @@ -0,0 +1,69 @@ +#include "../../common/cemulatorctrl.h" +#include "../src/sim65816.h" +#include "../src/video.h" + +extern int g_config_control_panel; +extern HWND g_hwnd_main; + + + +int +win_nonblock_read_stdin(int fd, char *bufptr, int len) +{ + extern int activeRead(char* buf); + return activeRead(bufptr); +} + + +int +x_show_alert(int is_fatal, const char *str) +{ + return 0; +} + + + +void +x_redraw_status_lines() +{ +} + +// OG Added Stretchable window + +int x_calc_ratio(float& ratiox,float& ratioy) +{ + +#ifdef UNDER_CE + return 0; +#else + RECT rect; + ::GetClientRect(g_hwnd_main,&rect); + ratiox = (float)(rect.right - rect.left)/(float)X_A2_WINDOW_WIDTH; + ratioy = (float)(rect.bottom - rect.top)/(float)X_A2_WINDOW_HEIGHT; + if ( (ratiox == 1.0 ) && (ratioy == 1.0) ) + return 0; // not stretched + else + return 1; +#endif +} + +//extern void addFrameRate(int _id); + +//extern Kimage g_win32_offscreen ; +extern HDC g_main_cdc; + + +void x_check_system_input_events() +{ +#ifndef ACTIVEGS + if (r_sim65816.get_state()==IN_PAUSE) + { + int oldpanel = g_config_control_panel; + extern int halt_sim; + g_config_control_panel = 1; + while (!r_sim65816.should_emulator_terminate()) + Sleep(100); + g_config_control_panel = oldpanel; + } +#endif +} diff --git a/kegs/Win/win_console.cpp b/kegs/Win/win_console.cpp new file mode 100644 index 0000000..a23c245 --- /dev/null +++ b/kegs/Win/win_console.cpp @@ -0,0 +1,172 @@ +#include +#include +#include +//#include +//#include + +#include "../src/defc.h" +#include "../src/protos_windriver.h" +#include "../src/driver.h" + +extern void kegsinit(HWND _hwnd); +extern void kegsshut(); +extern HWND g_hwnd_main; + +extern char *g_status_ptrs[MAX_STATUS_LINES]; + + +int +win_nonblock_read_stdin(int fd, char *bufptr, int len) +{ + + + HANDLE oshandle; + DWORD dwret; + int ret; + + errno = EAGAIN; + oshandle = (HANDLE)_get_osfhandle(fd); // get stdin handle + dwret = WaitForSingleObject(oshandle, 1); // wait 1msec for data + ret = -1; + if(dwret == WAIT_OBJECT_0) { + ret = read(fd, bufptr, len); + } + return ret; + +} + + + +void +x_fatal_exit(const char *str) +{ + +} +int +x_show_alert(int is_fatal, const char *str) +{ + return 0; +} + +int WINAPI WinMain ( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nShowCmd) +{ + return main(0,0); +} + +int +main(int argc, char **argv) +{ +// InitCommonControls(); + + WNDCLASS wndclass; + RECT rect; + int height; + + + wndclass.style = 0; + wndclass.lpfnWndProc = (WNDPROC)win_event_handler; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = GetModuleHandle(NULL); + wndclass.hIcon = LoadIcon((HINSTANCE)NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // OG Added cast + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = "kegswin"; + + // Register the window + if(!RegisterClass(&wndclass)) { + printf("Registering window failed\n"); + exit(1); + } + + height = X_A2_WINDOW_HEIGHT + (MAX_STATUS_LINES * 16) + 32; +// g_main_height = height; + +#include "../Src/kegsversion.h" + + char windowstr[255]; + sprintf(windowstr, "KEGS v%-6s BUILD v%s - Apple //gs Emulator", + g_kegs_version_str, g_kegs_version_build); + + HWND hwnd = CreateWindow("kegswin", windowstr, + WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, + CW_USEDEFAULT, CW_USEDEFAULT, + X_A2_WINDOW_WIDTH, height, + NULL, NULL, GetModuleHandle(NULL), NULL); + + printf("g_hwnd_main = %p, height = %d\n", hwnd, height); + GetWindowRect(hwnd, &rect); + printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top, + rect.right, rect.bottom); + + extern void kegs_driver(); + g_driver.init(kegs_driver); + + kegsinit(hwnd); + int ret = kegsmain(argc, argv); + + UnregisterClass(wndclass.lpszClassName,GetModuleHandle(NULL)); + + kegsshut(); + return ret; +} + +void +x_check_system_input_events() +{ + + MSG msg; + + while(PeekMessage(&msg, g_hwnd_main, 0, 0, PM_NOREMOVE)) { + if(GetMessage(&msg, g_hwnd_main, 0, 0) > 0) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + printf("GetMessage returned <= 0\n"); + my_exit(2); + } + } +} + + + +void +x_redraw_status_lines() +{ + COLORREF oldtextcolor, oldbkcolor; + char *buf; + int line; + int len; + int height; + int margin; + + height = 16; + margin = 0; + + HDC localdc = GetDC(g_hwnd_main); // OG Use on the fly DC + oldtextcolor = SetTextColor(localdc, 0); + oldbkcolor = SetBkColor(localdc, 0xffffff); + for(line = 0; line < MAX_STATUS_LINES; line++) { + buf = g_status_ptrs[line]; + if(buf != 0) { + len = strlen(buf); + TextOut(localdc, 10, X_A2_WINDOW_HEIGHT + + height*line + margin, buf, len); + } + } + SetTextColor(localdc, oldtextcolor); + SetBkColor(localdc, oldbkcolor); + ReleaseDC(g_hwnd_main,localdc); +} + +int x_calc_ratio(float& ratiox,float& ratioy) +{ + return 0; // not stretched +} + + diff --git a/kegs/Win/win_generic.cpp b/kegs/Win/win_generic.cpp new file mode 100644 index 0000000..a8485ec --- /dev/null +++ b/kegs/Win/win_generic.cpp @@ -0,0 +1,1022 @@ +/************************************************************************/ +/* KEGS: Apple //gs Emulator */ +/* Copyright 2002 by Kent Dickey */ +/* */ +/* This code is covered by the GNU GPL */ +/* */ +/* The KEGS web page is kegs.sourceforge.net */ +/* You may contact the author at: kadickey@alumni.princeton.edu */ +/************************************************************************/ + +#pragma once +const char rcsid_windriver_c[] = "@(#)$KmKId: windriver.c,v 1.11 2004-11-24 16:43:46-05 kentd Exp $"; + +/* Based on code from Chea Chee Keong from KEGS32, which is available at */ +/* http://www.geocities.com/akilgard/kegs32 */ + +#define WIN32_LEAN_AND_MEAN /* Tell windows we want less header gunk */ +#define STRICT /* Tell Windows we want compile type checks */ + +#include +#include +#include +//#include + +#ifdef ACTIVEGS +#include "../src/raster.h" +#endif + +#ifdef ACTIVEGSKARATEKA +#include "../../drivers/karateka.h" +#include "../../drivers/karateka_interface.h" +#endif + +//#define USE_GDIPLUS + +#ifdef USE_GDIPLUS +#include +#include +using namespace Gdiplus; +#pragma comment (lib,"Gdiplus.lib") +#endif + +#include "../src/defc.h" +#include "../src/protos_windriver.h" +#include "../src/adb.h" +#include "../src/sim65816.h" +#include "../src/video.h" +#include "../src/graphcounter.h" +#include "../src/driver.h" + +//extern int g_screen_mdepth; +//extern int g_screen_depth; + +// OG replaced g_quit_sim_now by quitEmulator +// extern int g_quit_sim_now; + + +int g_use_shmem = 1; +int g_has_focus = 0; +int g_auto_repeat_on = -1; + +//extern Kimage g_mainwin_kimage; + +//HDC g_main_dc; // OG dc cannot be a global +HDC g_main_cdc; +//int g_main_height = 0; + +int g_win_capslock_down = 0; + +extern void x_async_paint(); + +extern word32 g_palette_8to1624[256]; +extern word32 g_a2palette_8to1624[256]; + +extern word32 g_full_refresh_needed; + +extern int g_border_sides_refresh_needed; +extern int g_border_special_refresh_needed; +//extern int g_status_refresh_needed; + +extern int g_lores_colors[]; +extern int g_cur_a2_stat; + +extern int g_a2vid_palette; + +//extern int g_installed_full_superhires_colormap; + +extern int g_screen_redraw_skip_amt; + +extern word32 g_a2_screen_buffer_changed; + +HWND g_hwnd_main; +BITMAPINFO *g_bmapinfo_ptr = 0; +volatile BITMAPINFOHEADER *g_bmaphdr_ptr = 0; + +int g_num_a2_keycodes = 0; + + +int g_win_button_states = 0; + +// OG Added calc_ratio +int x_calc_ratio(float& ratiox,float& ratioy); + +/* +// FROM THE IPHONE VERSION + +struct kbdDefinition kbdDefinitions[]= +{ +{ KBDWIDTH,"esc",0x35,0,0 }, +{ KBDWIDTH,"1",0x12,"!",0 }, +{ KBDWIDTH,"2",0x13,"@",0 }, +{ KBDWIDTH,"3",0x14,"#",0 }, +{ KBDWIDTH,"4",0x15,"$",0 }, +{ KBDWIDTH,"5",0x17,"%",0 }, +{ KBDWIDTH,"6",0x16,"^",0 }, +{ KBDWIDTH,"7",0x1A,"&",0 }, +{ KBDWIDTH,"8",0x1C,"*",0 }, +{ KBDWIDTH,"9",0x19,"(",0 }, +{ KBDWIDTH,"0",0x1D,")",0 }, +{ KBDWIDTH,"-",0x1B,"_",0 }, +{ KBDWIDTH,"=",0x18,"+",0 }, +{ KBDWIDTHTAB,"delete",0x33,0,0 }, +{ -1,0,0,0,0 }, +{ KBDWIDTHTAB,"tab",0x30,0,0 }, +{ KBDWIDTH,"q",0x0C,"Q",0 }, +{ KBDWIDTH,"w",0x0D,"W",0 }, +{ KBDWIDTH,"e",0x0E,"E",0 }, +{ KBDWIDTH,"r",0x0F,"R",0 }, +{ KBDWIDTH,"t",0x11,"T",0 }, +{ KBDWIDTH,"y",0x10,"Y",0 }, +{ KBDWIDTH,"u",0x20,"U",0 }, +{ KBDWIDTH,"i",0x22,"I",0 }, +{ KBDWIDTH,"o",0x1F,"O",0 }, +{ KBDWIDTH,"p",0x23,"P",0 }, +{ KBDWIDTH,"[",0x21,"{",0 }, +{ KBDWIDTH,"]",0x1E,"}",0 }, + { KBDWIDTHTAB,"menu",-1,0,0 }, +{ -1,0,0,0,0 }, +{ KBDWIDTHCTRL,"control",0x36,0,0 }, +{ KBDWIDTH,"a",0x00,"A",0 }, +{ KBDWIDTH,"s",0x01,"S",0 }, +{ KBDWIDTH,"d",0x02,"D",0 }, +{ KBDWIDTH,"f",0x03,"F",0 }, +{ KBDWIDTH,"g",0x05,"G",0 }, +{ KBDWIDTH,"h",0x04,"H",0 }, +{ KBDWIDTH,"j",0x26,"J",0 }, +{ KBDWIDTH,"k",0x28,"K",0 }, +{ KBDWIDTH,"l",0x25,"L",0 }, +{ KBDWIDTH,";",0x29,":",0 }, +{ KBDWIDTH,"'",0x27,"\"",0 }, +{ KBDWIDTHRET,"return",0x24,0,0 }, +{ -1,0,0,0,0 }, + { KBDWIDTHSHIFT,"shift",0x38,0,0 }, + { KBDWIDTH,"z",0x06,"Z",0 }, + { KBDWIDTH,"x",0x07,"X",0 }, + { KBDWIDTH,"c",0x08,"C",0 }, + { KBDWIDTH,"v",0x09,"V",0 }, + { KBDWIDTH,"b",0x0B,"B",0 }, + { KBDWIDTH,"n",0x2D,"N",0 }, + { KBDWIDTH,"m",0x2E,"M",0 }, + { KBDWIDTH,",",0x2B,"<",0 }, + { KBDWIDTH,".",0x2F,">",0 }, + { KBDWIDTH,"/",0x2C,"?",0 }, + { KBDWIDTHSHIFT,"shift",0x38,0,0 }, + { -1,0,0,0,0 }, + { KBDWIDTH,"caps",0x39,0,0 }, + { KBDWIDTH,"option",0x37,0,0 }, + { KBDWIDTHAPPLE,"",0x3A,0,0 }, + { KBDWIDTH,"`",0x12,0,0 }, + { KBDWIDTHSPACE," ",0x31,0,0 }, + { KBDWIDTH,"x",0x13,0,0 }, + { KBDWIDTH,"->",0x3C,0,0 }, + { KBDWIDTH,"<-",0x3B,0,0 }, + { KBDWIDTH,"^",0x5B,0,0 }, + { KBDWIDTH,"v",0x13,0,0 }, + + { 0,0,0,0,0 } + +}; +*/ + +/* this table is used to search for the Windows VK_* in col 1 or 2 */ +/* flags bit 8 is or'ed into the VK, so we can distinguish keypad keys */ +/* regardless of numlock */ +int g_a2_key_to_wsym[][3] = +{ + { 0x35, VK_ESCAPE, 0 }, + { 0x7a, VK_F1, 0 }, + { 0x78, VK_F2, 0 }, // OG Was 7B but F2 is defined has 0x78 in a2_key_to_ascii + { 0x63, VK_F3, 0 }, + { 0x76, VK_F4, 0 }, + { 0x60, VK_F5, 0 }, + { 0x61, VK_F6, 0 }, + { 0x62, VK_F7, 0 }, + { 0x64, VK_F8, 0 }, + { 0x65, VK_F9, 0 }, + { 0x6d, VK_F10, 0 }, + { 0x67, VK_F11, 0 }, + { 0x6f, VK_F12, 0 }, + { 0x69, VK_F13, 0 }, + { 0x6b, VK_F14, 0 }, + { 0x71, VK_F15, 0 }, + { 0x7f, VK_PAUSE, VK_CANCEL+0x100 }, + + { 0x32, 0xc0, 0 }, /* '`' */ + { 0x12, '1', 0 }, + { 0x13, '2', 0 }, + { 0x14, '3', 0 }, + { 0x15, '4', 0 }, + { 0x17, '5', 0 }, + { 0x16, '6', 0 }, + { 0x1a, '7', 0 }, + { 0x1c, '8', 0 }, + { 0x19, '9', 0 }, + { 0x1d, '0', 0 }, + { 0x1b, 0xbd, 0 }, /* '-' */ + { 0x18, 0xbb, 0 }, /* '=' */ + { 0x33, VK_BACK, 0 }, /* backspace */ + { 0x72, VK_INSERT+0x100, 0 }, /* Insert key */ + /* { 0x73, XK_Home, 0 }, alias VK_HOME to be KP_Equal! */ + { 0x74, VK_PRIOR+0x100, 0 }, /* pageup */ + { 0x47, VK_NUMLOCK, VK_NUMLOCK+0x100 }, /* clear */ + { 0x51, VK_HOME+0x100, 0 }, /* KP_equal is HOME key */ + { 0x4b, VK_DIVIDE, VK_DIVIDE+0x100 }, + { 0x43, VK_MULTIPLY, VK_MULTIPLY+0x100 }, + + { 0x30, VK_TAB, 0 }, + { 0x0c, 'Q', 0 }, + { 0x0d, 'W', 0 }, + { 0x0e, 'E', 0 }, + { 0x0f, 'R', 0 }, + { 0x11, 'T', 0 }, + { 0x10, 'Y', 0 }, + { 0x20, 'U', 0 }, + { 0x22, 'I', 0 }, + { 0x1f, 'O', 0 }, + { 0x23, 'P', 0 }, + { 0x21, 0xdb, 0 }, /* [ */ + { 0x1e, 0xdd, 0 }, /* ] */ + { 0x2a, 0xdc, 0 }, /* backslash, bar */ + { 0x75, VK_DELETE+0x100, 0 }, + { 0x77, VK_END+0x100, VK_END }, + { 0x79, VK_NEXT+0x100, 0 }, + { 0x59, VK_NUMPAD7, VK_HOME }, + { 0x5b, VK_NUMPAD8, VK_UP }, + { 0x5c, VK_NUMPAD9, VK_PRIOR }, + { 0x4e, VK_SUBTRACT, VK_SUBTRACT+0x100 }, + + // { 0x39, VK_CAPITAL, 0 }, // Handled specially! + { 0x00, 'A', 0 }, + { 0x01, 'S', 0 }, + { 0x02, 'D', 0 }, + { 0x03, 'F', 0 }, + { 0x05, 'G', 0 }, + { 0x04, 'H', 0 }, + { 0x26, 'J', 0 }, + { 0x28, 'K', 0 }, + { 0x25, 'L', 0 }, + { 0x29, 0xba, 0 }, /* ; */ + { 0x27, 0xde, 0 }, /* single quote */ + { 0x24, VK_RETURN, 0 }, + { 0x56, VK_NUMPAD4, VK_LEFT }, + { 0x57, VK_NUMPAD5, VK_CLEAR }, + { 0x58, VK_NUMPAD6, VK_RIGHT }, + { 0x45, VK_ADD, 0 }, + + { 0x38, VK_SHIFT, 0 }, + { 0x06, 'Z', 0 }, + { 0x07, 'X', 0 }, + { 0x08, 'C', 0 }, + { 0x09, 'V', 0 }, + { 0x0b, 'B', 0 }, + { 0x2d, 'N', 0 }, + { 0x2e, 'M', 0 }, + { 0x2b, 0xbc, 0 }, /* , */ + { 0x2f, 0xbe, 0 }, /* . */ + { 0x2c, 0xbf, 0 }, /* / */ + { 0x3e, VK_UP+0x100, 0 }, + { 0x53, VK_NUMPAD1, VK_END }, + { 0x54, VK_NUMPAD2, VK_DOWN }, + { 0x55, VK_NUMPAD3, VK_NEXT }, + + { 0x36, VK_CONTROL, VK_CONTROL+0x100 }, + { 0x3a, VK_SNAPSHOT+0x100, VK_MENU+0x100 },/* Opt=prntscrn or alt-r */ + +// OG ActiveGS map OA-CA to Win & AltKey +#ifndef ACTIVEGS + { 0x37, VK_SCROLL, VK_MENU }, /* Command=scr_lock or alt-l */ +#else + { 0x7f, VK_CANCEL, 0 }, + { 0x3A, VK_LWIN+0x100, VK_LWIN }, + { 0x37, VK_MENU, 0 }, /* Command=alt-l */ + { 0x37, VK_LMENU, 0 }, /* Command=alt-l */ + { 0x7F, VK_SCROLL,0 }, /* RESET */ + { 0x36, VK_LCONTROL, 0 }, // CTRL +#endif + + { 0x31, ' ', 0 }, + { 0x3b, VK_LEFT+0x100, 0 }, + { 0x3d, VK_DOWN+0x100, 0 }, + { 0x3c, VK_RIGHT+0x100, 0 }, + { 0x52, VK_NUMPAD0, VK_INSERT }, + { 0x41, VK_DECIMAL, VK_DECIMAL }, + { 0x4c, VK_RETURN+0x100, 0 }, + { -1, -1, -1 } +}; + +extern int g_config_control_panel; +extern int g_config_control_panel; // OG Expose g_config_control_panel + +void x_update_modifiers(word32) +{ +} + + +extern void add_event_mouse(int,int,int,int); +extern void add_event_key(int,int); + +extern void simulate_space_event(); + +void x_recenter_hw_mouse() +{ + /* move mouse to center of screen */ + POINT pt; + pt.x = X_A2_WINDOW_WIDTH/2; + pt.y = X_A2_WINDOW_HEIGHT/2; + ClientToScreen(g_hwnd_main, &pt); + SetCursorPos(pt.x, pt.y); +} + +void win_event_mouse_async(int umsg,WPARAM wParam, LPARAM lParam) +{ + + word32 flags; + int buttons; + int x, y; + + x = LOWORD(lParam); + y = HIWORD(lParam); + + flags = wParam; + buttons = (flags & 1); // + (((flags >> 1) & 1) << 2) + (((flags >> 4) & 1) << 1); + + if (umsg == WM_LBUTTONDBLCLK) + simulate_space_event(); + + + if(g_adb.g_warp_pointer==WARP_POINTER) + { + + int buttons_changed = (g_win_button_states != buttons); + g_win_button_states = buttons; //(g_win_button_states & ~buttons_valid) | (button_states & buttons_valid); + if ( (x == X_A2_WINDOW_WIDTH/2) && (y == X_A2_WINDOW_HEIGHT/2) && (!buttons_changed) ) + { + // tell adb routs to recenter but ignore this motion + add_event_mouse(x, y, 0, -1); + // win_recenter_hw_mouse(); + return ; + } + + } + else + { + // OG Reformat the mouse coordinates + float ratiox,ratioy; + if (x_calc_ratio(ratiox,ratioy)) + { + x = (int)((float)(x)/ratiox); + y = (int)((float)(y)/ratioy); + } + x -= BASE_MARGIN_LEFT; + y -= BASE_MARGIN_TOP; + } + + +#if 0 + if (umsg!=WM_MOUSEMOVE) + printf("Mouse at %d, %d fl: %08x, but: %d\n", x, y, flags, buttons); +#endif + + // ajoute l'event +#ifdef ACTIVEGSKARATEKA +// extern void jniTouch(int mode,float x, float y, int nbtap); + if (umsg==WM_LBUTTONDOWN) + jniTouch(0,EVT_TOUCHBEGAN,(float)x,(float)y,1); + else + if (umsg==WM_LBUTTONUP) + jniTouch(0,EVT_TOUCHENDED,(float)x,(float)y,1); +#else + add_event_mouse(x, y, buttons, 7); +#endif + + if(g_adb.g_warp_pointer == WARP_POINTER) + x_recenter_hw_mouse(); + +} + +void win_event_key_async(HWND hwnd, UINT raw_vk, BOOL down, int repeat, UINT flags) +{ + word32 vk; + int a2code; + int is_up; + int capslock_down; + int i; + if((flags & 0x4000) && down) + { + /* auto-repeating, just ignore it */ + return; + } + vk = raw_vk + (flags & 0x100); +#if 0 + printf("Key event, vk=%04x, down:%d, repeat: %d, flags: %08x\n", + vk, down, repeat, flags); +#endif + /* remap a few keys here.. sigh */ + if((vk & 0xff) == VK_APPS) + { + /* remap to command */ + vk = VK_MENU; + } + if((vk & 0xff) == VK_CAPITAL) + { + // Windows gives us up-and-down events of the actual key + // Use GetKeyState to get the true toggle state, and pass + // that on to the adb interface + capslock_down = GetKeyState(VK_CAPITAL) & 0x01; + if(capslock_down != g_win_capslock_down) + { + g_win_capslock_down = capslock_down; + //adb_physical_key_update(0x39, !capslock_down); + add_event_key(0x39, !capslock_down); + } + return; // Do no more processing! + } + // cherche déjà en ascii + a2code = -1; + int a2shift = -1; + is_up = !down; + /* + extern const int a2_key_to_ascii[][4]; + + int nbascii =128; + for(int i=0;i= 0; i--) + { + a2code = g_a2_key_to_wsym[i][0]; + if((vk == g_a2_key_to_wsym[i][1]) || + (vk == g_a2_key_to_wsym[i][2])) + { + vid_printf("Found vk:%04x = %02x\n", vk, a2code); + // adb_physical_key_update(a2code, is_up); + add_event_key(a2code,is_up); + return; + } + } + printf("VK: %04x unknown\n", vk); +} + +void +win_event_quit(HWND hwnd) +{ + r_sim65816.quit_emulator(); +} + +//extern int g_needfullrefreshfornextframe ; + +extern void ui_process_message( WPARAM wParam, LPARAM lParam); + +void window_needs_full_refresh() +{ + // Nothing to do : the whole offscreen is always refreshed +} + +LRESULT CALLBACK +win_event_handler(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) +{ +#if 0 + extern word32 g_vbl_count; + if (umsg==WM_LBUTTONDOWN) + outputInfo("WM_LBUTTONDOWN (%d)\n",g_vbl_count); + if (umsg==WM_LBUTTONUP) + outputInfo("WM_LBUTTONUP (%d)\n",g_vbl_count); + if (umsg==WM_LBUTTONDBLCLK) + outputInfo("WM_LBUTTONDBLCLK (%d)\n",g_vbl_count); +#endif + switch(umsg) + { + case WM_USER: + ui_process_message(wParam,lParam); + return 0; + case WM_MOUSEMOVE: + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_MBUTTONDOWN: + case WM_MBUTTONUP: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + case WM_LBUTTONDBLCLK: // OG Added dblclk as WM_LBUTTONDOWN + win_event_mouse_async(umsg,wParam, lParam); + return 0; + case WM_ERASEBKGND: + window_needs_full_refresh(); + return 1; + break; + case WM_PAINT: + x_async_paint(); + break; + HANDLE_MSG(hwnd, WM_KEYUP, win_event_key_async); + HANDLE_MSG(hwnd, WM_KEYDOWN, win_event_key_async); + HANDLE_MSG(hwnd, WM_SYSKEYUP, win_event_key_async); + HANDLE_MSG(hwnd, WM_SYSKEYDOWN, win_event_key_async); + HANDLE_MSG(hwnd, WM_DESTROY, win_event_quit); + } +#if 0 + switch(umsg) + { + case WM_NCACTIVATE: + case WM_NCHITTEST: + case WM_NCMOUSEMOVE: + case WM_SETCURSOR: + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_RBUTTONDOWN: + case WM_CONTEXTMENU: + case WM_RBUTTONUP: + case WM_MBUTTONDOWN: + case WM_MBUTTONUP: + case WM_PAINT: + break; + default: + printf("Got umsg2: %d\n", umsg); + } +#endif + return DefWindowProc(hwnd, umsg, wParam, lParam); +} + +// OG Added Generic kegsinit/kegsshut functions + +void kegsinit(HWND _hwnd) +{ + g_hwnd_main = _hwnd; + HDC localdc = GetDC(g_hwnd_main); + SetTextColor(localdc, 0); + SetBkColor(localdc, 0xFFFFFF); + g_main_cdc = CreateCompatibleDC(localdc); + ReleaseDC(g_hwnd_main,localdc); +} +void kegsshut() +{ + if (g_main_cdc) + { + DeleteDC(g_main_cdc); + g_main_cdc = NULL; + } + g_hwnd_main = NULL; +} + + +void +x_update_color(int col_num, int red, int green, int blue, word32 rgb) +{ +} + +void +x_update_physical_colormap() +{ +} + +void +x_show_color_array() +{ + int i; + for(i = 0; i < 256; i++) + { + printf("%02x: %08x\n", i, g_palette_8to1624[i]); + } +} + + +// OG Add function to clear all get_images loaded (dev dependent) +void x_release_kimage(Kimage *kimage_ptr) +{ + if ((int)kimage_ptr->dev_handle != -1) + { + DeleteObject(kimage_ptr->dev_handle); + kimage_ptr->dev_handle = (void*)-1; + } + else if (kimage_ptr->data_ptr) + { + free(kimage_ptr->data_ptr); + kimage_ptr->data_ptr = NULL; + } +} + + +void x_video_shut() // Should be renamed to dev_video_shut() ??? +{ +//#ifdef ACTIVEGS + x_release_kimage(&g_kimage_offscreen); +//#endif + x_release_kimage(&s_video.g_mainwin_kimage); + GlobalFree(g_bmapinfo_ptr); // allocated in x_dev_video_init + g_bmapinfo_ptr = 0; + printf("win32 video driver end\n"); +} + + +void x_get_kimage(Kimage *kimage_ptr) +{ + + int width; + int height; + int depth, mdepth; + int size; + width = kimage_ptr->width_req; + height = kimage_ptr->height; + depth = kimage_ptr->depth; + mdepth = kimage_ptr->mdepth; + size = 0; + + /* Use g_bmapinfo_ptr, adjusting width, height */ +#ifdef USE_GDIPLUS + Bitmap* bmp = new Bitmap(width,height,PixelFormat32bppARGB); + kimage_ptr->dev_handle = bmp; + + BitmapData* bdata = new BitmapData; + bdata->Width = width, + bdata->Height = height; + bdata->Stride = 4*width; + bdata->PixelFormat = PixelFormat32bppRGB; + bdata->Scan0 = (VOID*)malloc(height*width*4); + bdata->Reserved = NULL; + kimage_ptr->dev_handle2 = bdata; + + kimage_ptr->data_ptr = (byte*)bdata->Scan0; + +#else + g_bmaphdr_ptr->biWidth = width; + g_bmaphdr_ptr->biHeight = -height; + HDC localdc = GetDC(g_hwnd_main); // OG Use on the fly DC + kimage_ptr->dev_handle = CreateDIBSection(localdc, + g_bmapinfo_ptr, DIB_RGB_COLORS, + (VOID **)&(kimage_ptr->data_ptr), NULL, 0); + ReleaseDC(g_hwnd_main,localdc); +#endif + printf("kim: %p, dev:%p data: %p, size: %08x\n", kimage_ptr, + kimage_ptr->dev_handle, kimage_ptr->data_ptr, size); + return; +} + + +void x_video_init() +{ + int extra_size; + + printf("Preparing graphics system\n"); + + +#ifdef USE_GDIPLUS + GdiplusStartupInput gdiplusStartupInput; + ULONG_PTR gdiplusToken; + + // Initialize GDI+. + GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); +#endif + + // OG fix g_num_a2_keycodes identification + g_num_a2_keycodes = sizeof(g_a2_key_to_wsym)/3/sizeof(int); + g_num_a2_keycodes--; // last entry=-1 + + +#ifndef UNDER_CE + s_video.g_screen_depth = 24; + s_video.g_screen_mdepth = 32; +#else + // OG Forcing 16bits depth for WiNCE + s_video.g_screen_depth = 16; + s_video.g_screen_mdepth = 16; + s_video.g_red_mask = 0xff; + s_video.g_green_mask = 0xff; + s_video.g_blue_mask = 0xff; + s_video.g_red_left_shift = 10; + s_video.g_green_left_shift = 5; + s_video.g_blue_left_shift = 0; + s_video.g_red_right_shift = 3; + s_video.g_green_right_shift = 3; + s_video.g_blue_right_shift = 3; +#endif + extra_size = sizeof(RGBQUAD); + if(s_video.g_screen_depth == 8) + { + extra_size = 256 * sizeof(RGBQUAD); + } + g_bmapinfo_ptr = (BITMAPINFO *)GlobalAlloc(GPTR, + sizeof(BITMAPINFOHEADER) + extra_size); + g_bmaphdr_ptr = (BITMAPINFOHEADER *)g_bmapinfo_ptr; + g_bmaphdr_ptr->biSize = sizeof(BITMAPINFOHEADER); + g_bmaphdr_ptr->biWidth = A2_WINDOW_WIDTH; + g_bmaphdr_ptr->biHeight = -A2_WINDOW_HEIGHT; + g_bmaphdr_ptr->biPlanes = 1; + g_bmaphdr_ptr->biBitCount = s_video.g_screen_mdepth; + g_bmaphdr_ptr->biCompression = BI_RGB; + g_bmaphdr_ptr->biClrUsed = 0; + video_get_kimages(); + if(s_video.g_screen_depth != 8) + { + // Allocate g_mainwin_kimage + video_get_kimage(&s_video.g_mainwin_kimage, 0, s_video.g_screen_depth,s_video.g_screen_mdepth); + } + s_video.g_installed_full_superhires_colormap = 1; + + init_kimage(&g_kimage_offscreen,0,s_video.g_screen_depth, s_video.g_screen_mdepth); + g_kimage_offscreen.width_req = X_A2_WINDOW_WIDTH; + g_kimage_offscreen.width_act = X_A2_WINDOW_WIDTH; + g_kimage_offscreen.height = X_A2_WINDOW_HEIGHT; + x_get_kimage(&g_kimage_offscreen); + +#ifndef UNDER_CE + ShowWindow(g_hwnd_main, SW_SHOWDEFAULT); +#else + ShowWindow(g_hwnd_main, SW_SHOW); +#endif + UpdateWindow(g_hwnd_main); + +#ifdef USE_RASTER + x_init_raster((void*)g_hwnd_main); +#endif + + printf("Done with dev_video_init\n"); + fflush(stdout); +} + + + +void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy, + int width, int height) +{ + + int pixsize = kimage_ptr->mdepth>>3 ; + int srcrow = kimage_ptr->width_act * pixsize; + int dstrow = g_kimage_offscreen.width_act * pixsize; + int byte2copy = width * pixsize ; + char* ptrdest = (char*)g_kimage_offscreen.data_ptr +dstrow*desty + destx*pixsize; + char* srcdest = (char*)kimage_ptr->data_ptr + srcrow*srcy + srcx*pixsize; + int dbl = 1; +#if !defined(VIDEO_SINGLEVLINE) + int crt = (r_sim65816.get_video_fx()==VIDEOFX_CRT); +#else + int crt = 0; +#endif + for(int i=0; i>=1; + pixel &=0x7F7F7F7F, + ((word32*)ptrdest)[j]=pixel; + } + // memset(ptrdest,0,byte2copy); + } + else + memcpy(ptrdest,srcdest,byte2copy); + ptrdest += dstrow; + srcdest += srcrow; + } + g_video_offscreen_has_been_modified = 1; +} + + +void +x_push_done() +{ +} + +void +x_auto_repeat_on(int must) +{ +} + +void +x_auto_repeat_off(int must) +{ +} + + +void +x_hide_pointer(int do_hide) +{ + static int previous_hide = 0; // visible by default + if (previous_hide == do_hide) + return ; + if (do_hide==1 && g_adb.g_warp_pointer != WARP_POINTER) + return ; + + previous_hide = do_hide; + ::PostMessage(g_hwnd_main,WM_USER,SHOW_CURSOR,do_hide); +} + + + +void ui_hide_pointer(LONG do_hide) +{ + int count; + if(do_hide) + { + count= ShowCursor(0); + } + else + { + count = ShowCursor(1); + } +// printf("hide pointer %d (count:%d)\n",do_hide,count); +} + +void ui_process_message(WPARAM wParam, LPARAM lParam) +{ + if (wParam==SHOW_CURSOR) + return ui_hide_pointer(lParam); +} + +void +x_full_screen(int do_full) +{ + return; +} + +//int x_screen_dirty = 0; + +void x_refresh_video() +{ +#ifdef USE_RASTER + extern void x_async_paint(); + x_async_paint(); +#else + InvalidateRect(g_hwnd_main,NULL,0); + UpdateWindow(g_hwnd_main); +#endif + +} + +extern BOOL StretchBltPlus( + HDC hdcDest, + int nXOriginDest, + int nYOriginDest, + int nWidthDest, + int nHeightDest, + HDC hdcSrc, + int nXOriginSrc, + int nYOriginSrc, + int nWidthSrc, + int nHeightSrc, + DWORD dwRop +) ; + +void x_async_paint() +{ + + + extern void addConsoleWindow(Kimage*); +#ifndef USE_RASTER + RECT r; + BOOL b = GetUpdateRect( g_hwnd_main,&r,FALSE); + if (!b) + { + // System Paint : ignore + return ; + } +#endif + if (!r_sim65816.is_emulator_offscreen_available()) + { + printf("skip frame\n"); + PAINTSTRUCT ps; + RECT r; + GetClientRect(g_hwnd_main,&r); + HDC hdc = BeginPaint(g_hwnd_main,&ps); + HBRUSH brush = CreateSolidBrush(RGB(36,34,244)); + FillRect(hdc, &r, brush); + DeleteObject(brush); + + EndPaint(g_hwnd_main,&ps); + + return ; + } + +// DRAW_BORDER(); + + CHANGE_BORDER(1,0xFF); + CHANGE_BORDER(2,0xFF); + + addFrameRate(0); + +#if defined(ACTIVEGS) + addConsoleWindow(&g_kimage_offscreen); +#ifdef ENABLE_GRAPH + + static double lastframe = 0; + double curframe = get_dtime(); + double delay = curframe - lastframe; + double frame = 1/delay; + g_graph.add_graph(1,(float)frame,g_sim65816.g_vbl_count); + lastframe = curframe; + g_graph.draw_graph(&g_kimage_offscreen,g_sim65816.g_vbl_count); +#endif +#endif + +#ifdef USE_GDIPLUS + PAINTSTRUCT ps; + HDC localdc = BeginPaint(g_hwnd_main,&ps); // Faster than GetDC in WM_PAINT response + Graphics dest(localdc); + + int srcx =0; + int srcy =0; + int destx = 0; + + int desty = 0; + int width = g_kimage_offscreen.width_act; + int height = g_kimage_offscreen.height; + + Bitmap* bmp = (Bitmap*)g_kimage_offscreen.dev_handle; + Graphics src(bmp); + + BitmapData* data = (BitmapData*)g_kimage_offscreen.dev_handle2; + Rect rdata(0,0,width,height); + Status s= bmp->LockBits( + &rdata, + ImageLockModeWrite|ImageLockModeUserInputBuf, + PixelFormat32bppRGB, + data); + + // Commit the changes and unlock the 50x30 portion of the bitmap. + s = bmp->UnlockBits(data); + + float ratiox,ratioy; + int isStretched = x_calc_ratio(ratiox,ratioy); + float xdest = (destx)*ratiox; + float ydest = (desty)*ratioy; + float wdest = (width)*ratiox; + float hdest = (height)*ratioy; + + RectF rdest(xdest,ydest,wdest,hdest); + /* + SolidBrush br(Color::AliceBlue); + dest.FillRectangle(&br,rdest); +*/ + //dest.SetInterpolationMode(InterpolationModeHighQuality); + dest.SetInterpolationMode(InterpolationModeDefault); + s = dest.DrawImage(bmp, rdest, 0, 0, width, height, UnitPixel); + + EndPaint(g_hwnd_main,&ps); + + +#else + void *bitm_old; + POINT point; + point.x = 0; + point.y = 0; + ClientToScreen(g_hwnd_main, &point); + +// PAINTSTRUCT ps; +// HDC localdc = BeginPaint(g_hwnd_main,&ps); // Faster than GetDC in WM_PAINT response + HDC localdc = GetDC(g_hwnd_main); // Faster than GetDC in WM_PAINT response + + HDC localcdc = g_main_cdc; + bitm_old = SelectObject(localcdc, g_kimage_offscreen.dev_handle); + HRGN hrgn=NULL; + + int srcx =0; + + int srcy =0; + int destx = 0; + int desty = 0; + int width = g_kimage_offscreen.width_act; + int height = g_kimage_offscreen.height; + float ratiox,ratioy; + int isStretched = x_calc_ratio(ratiox,ratioy); + if (!isStretched) + BitBlt(localdc, destx, desty, width, height, localcdc, srcx, srcy, SRCCOPY); + else + { + float xdest = (destx)*ratiox; + float ydest = (desty)*ratioy; + float wdest = (width)*ratiox; + float hdest = (height)*ratioy; + BOOL err= StretchBlt(localdc,(int)xdest,(int)ydest,(int)wdest,(int)hdest, localcdc, srcx, srcy,width,height, SRCCOPY); + } + SelectObject(localcdc, bitm_old); + ReleaseDC(g_hwnd_main,localdc); +// EndPaint(g_hwnd_main,&ps); +#endif + CHANGE_BORDER(1,0); + CHANGE_BORDER(2,0); + + if (g_driver.x_handle_state_on_paint!=NULL) + g_driver.x_handle_state_on_paint((float)g_kimage_offscreen.width_act,(float)g_kimage_offscreen.height); +} diff --git a/kegs/Win/win_raster.cpp b/kegs/Win/win_raster.cpp new file mode 100644 index 0000000..d138e54 --- /dev/null +++ b/kegs/Win/win_raster.cpp @@ -0,0 +1,157 @@ +// TestRaster.cpp : Defines the entry point for the console application. +// + + +#include "../../common.win32/stdafx.h" +#include "../../Common/CemulatorCtrl.h" +#include "../src/raster.h" +#include "../src/graphcounter.h" + +#ifdef USE_RASTER +#include +#pragma comment(lib,"d3d9.lib") + +LPDIRECT3DDEVICE9 p_dx_Device = NULL; +LPDIRECT3D9 p_dx_Object = NULL; +int screenHeight; + +int x_init_raster(void* _data) +{ + HWND hwnd = (HWND)_data; + + p_dx_Object = Direct3DCreate9(D3D_SDK_VERSION); + if (p_dx_Object == NULL) + { + printf("DirectX Runtime library not installed!\n"); +return 0; + } + +// IDirect3DDevice9 * device; + +D3DPRESENT_PARAMETERS dx_PresParams; + + ZeroMemory( &dx_PresParams, sizeof(dx_PresParams) ); + dx_PresParams.Windowed = TRUE; + dx_PresParams.SwapEffect = D3DSWAPEFFECT_DISCARD; + dx_PresParams.BackBufferFormat = D3DFMT_UNKNOWN; + + +// HWND hWND=NULL; + + HRESULT err =p_dx_Object->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &dx_PresParams, &p_dx_Device); +//HRESULT err = IDirect3D9::CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,NULL,0,NULL,&device); + +if (err!=D3D_OK) +{ + printf("failed device"); + return 0; +} + + D3DRASTER_STATUS status; + err = p_dx_Device->GetRasterStatus(0,&status); +if (err!=D3D_OK) +{ + printf("failed getraster"); + return 0; +} + + screenHeight = GetSystemMetrics(SM_CYSCREEN) ; + + printf("screenHeight:%d\n",screenHeight); + + + return 1; +} + +int getScanLine() +{ + if (!p_dx_Device) return -1; + + D3DRASTER_STATUS status; + HRESULT err = p_dx_Device->GetRasterStatus(0,&status); + if (err!=D3D_OK) + { + printf("failed getraster"); + return 0; + } + + static int mins = 100000; + static int maxs = 0; + + if (mins>status.ScanLine) mins=status.ScanLine; + if (maxsGetRasterStatus(0,&status); + if (err!=D3D_OK) + { + printf("failed getraster"); + return 0; + } + return status.InVBlank; + +} + +int x_wait_for_last_refresh(double _w) +{ +#ifndef WIN32 + +#ifdef ENABLE_GRAPH + double s = get_dtime(); +#endif +CHANGE_BORDER(0,0xFFFFFF); +CHANGE_BORDER(2,0xFFFFFF); + // attends la prochaine vbl + //... x_wait_for_vbl(); +CHANGE_BORDER(0,0x000000); +CHANGE_BORDER(2,0); +#ifdef ENABLE_GRAPH + double d = get_dtime() - s; + g_graph.add_graph(2,(float)d,g_sim65816.g_vbl_count); +#endif + +#else + while(1) + { + int l =getScanLine(); + if (lscreenHeight-20) + break; + } +CHANGE_BORDER(0,0x000000); +CHANGE_BORDER(2,0); +#ifdef ENABLE_GRAPH + double d = get_dtime() - s; + g_graph.add_graph(2,(float)d,g_sim65816.g_vbl_count); +#endif // graph + + return 1; +} + +#endif diff --git a/kegs/Win/winresource.h b/kegs/Win/winresource.h new file mode 100644 index 0000000..27ef394 --- /dev/null +++ b/kegs/Win/winresource.h @@ -0,0 +1,42 @@ +//{{NO_DEPENDENCIES}} +// $Id: $ +// Microsoft Developer Studio generated include file. +// Used by win32.rc +// +#define IDD_ABOUT_DIALOG 101 +#define IDC_KEGS32 102 +#define IDR_TOOLBAR 103 +#define IDD_DLG_DISKCONF 104 +#define IDR_ACCEL 105 +#define ID_TOOLBAR 5000 +#define ID_STATUSBAR 5001 +#define IDC_EDIT_S5D1 10051 +#define IDC_EDIT_S5D2 10052 +#define IDC_EDIT_S6D1 10061 +#define IDC_EDIT_S6D2 10062 +#define IDC_EDIT_S7D1 10071 +#define IDC_EDIT_S7D2 10072 +#define IDC_BTN_S5D1 11051 +#define IDC_BTN_S5D2 11052 +#define IDC_BTN_S6D1 11061 +#define IDC_BTN_S6D2 11062 +#define IDC_BTN_S7D1 11071 +#define IDC_BTN_S7D2 11072 +#define ID_HELP_ABOUT 40001 +#define ID_FILE_EXIT 40002 +#define ID_FILE_DISK 40003 +#define ID_FILE_SENDRESET 40004 +#define ID_FILE_JOYSTICK 40005 +#define ID_FILE_DEBUGSTAT 40006 +#define ID_FILE_FULLSCREEN 40012 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 111 +#define _APS_NEXT_COMMAND_VALUE 40013 +#define _APS_NEXT_CONTROL_VALUE 1003 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif