rollback 1829. Seriously, WTF?
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1831 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
f705cfc49f
commit
4916bf54b6
|
@ -0,0 +1,58 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Common.h"
|
||||
#include "DriveUtil.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
#endif
|
||||
|
||||
void GetAllRemovableDrives(std::vector<std::string> *drives) {
|
||||
drives->clear();
|
||||
#ifdef _WIN32
|
||||
HANDLE hDisk;
|
||||
DISK_GEOMETRY diskGeometry;
|
||||
|
||||
for (int i = 'A'; i < 'Z'; i++)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "\\\\.\\%c:", i);
|
||||
hDisk = CreateFile(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hDisk != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwBytes;
|
||||
DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &diskGeometry, sizeof(DISK_GEOMETRY), &dwBytes, NULL);
|
||||
// Only proceed if disk is a removable media
|
||||
if (diskGeometry.MediaType == RemovableMedia)
|
||||
{
|
||||
if (diskGeometry.BytesPerSector == 2048) {
|
||||
// Probably CD/DVD drive.
|
||||
// "Remove" the "\\.\" part of the path and return it.
|
||||
drives->push_back(path + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(hDisk);
|
||||
}
|
||||
#else
|
||||
// TODO
|
||||
// stat("/media/cdrom") or whatever etc etc
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _DRIVEUTIL_H
|
||||
#define _DRIVEUTIL_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Tools to enumerate drives (HDD, DVD, CD) in a platform-independent manner.
|
||||
|
||||
void GetAllRemovableDrives(std::vector<std::string> *drives);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,437 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Written by Zoltan Csizmadia, zoltan_csizmadia@yahoo.com
|
||||
// For companies(Austin,TX): If you would like to get my resume, send an email.
|
||||
//
|
||||
// The source is free, but if you want to use it, mention my name and e-mail address
|
||||
//
|
||||
// History:
|
||||
// 1.0 Initial version Zoltan Csizmadia
|
||||
// 1.1 WhineCube version Masken
|
||||
// 1.2 Dolphin version Masken
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExtendedTrace.cpp
|
||||
//
|
||||
|
||||
// Include StdAfx.h, if you're using precompiled
|
||||
// header through StdAfx.h
|
||||
//#include "stdafx.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "ExtendedTrace.h"
|
||||
using namespace std;
|
||||
|
||||
#include <tchar.h>
|
||||
#include <ImageHlp.h>
|
||||
|
||||
#define BUFFERSIZE 0x200
|
||||
#pragma warning(disable:4996)
|
||||
|
||||
// Unicode safe char* -> TCHAR* conversion
|
||||
void PCSTR2LPTSTR( PCSTR lpszIn, LPTSTR lpszOut )
|
||||
{
|
||||
#if defined(UNICODE)||defined(_UNICODE)
|
||||
ULONG index = 0;
|
||||
PCSTR lpAct = lpszIn;
|
||||
|
||||
for( ; ; lpAct++ )
|
||||
{
|
||||
lpszOut[index++] = (TCHAR)(*lpAct);
|
||||
if ( *lpAct == 0 )
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// This is trivial :)
|
||||
strcpy( lpszOut, lpszIn );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Let's figure out the path for the symbol files
|
||||
// Search path= ".;%_NT_SYMBOL_PATH%;%_NT_ALTERNATE_SYMBOL_PATH%;%SYSTEMROOT%;%SYSTEMROOT%\System32;" + lpszIniPath
|
||||
// Note: There is no size check for lpszSymbolPath!
|
||||
static void InitSymbolPath( PSTR lpszSymbolPath, PCSTR lpszIniPath )
|
||||
{
|
||||
CHAR lpszPath[BUFFERSIZE];
|
||||
|
||||
// Creating the default path
|
||||
// ".;%_NT_SYMBOL_PATH%;%_NT_ALTERNATE_SYMBOL_PATH%;%SYSTEMROOT%;%SYSTEMROOT%\System32;"
|
||||
strcpy( lpszSymbolPath, "." );
|
||||
|
||||
// environment variable _NT_SYMBOL_PATH
|
||||
if ( GetEnvironmentVariableA( "_NT_SYMBOL_PATH", lpszPath, BUFFERSIZE ) )
|
||||
{
|
||||
strcat( lpszSymbolPath, ";" );
|
||||
strcat( lpszSymbolPath, lpszPath );
|
||||
}
|
||||
|
||||
// environment variable _NT_ALTERNATE_SYMBOL_PATH
|
||||
if ( GetEnvironmentVariableA( "_NT_ALTERNATE_SYMBOL_PATH", lpszPath, BUFFERSIZE ) )
|
||||
{
|
||||
strcat( lpszSymbolPath, ";" );
|
||||
strcat( lpszSymbolPath, lpszPath );
|
||||
}
|
||||
|
||||
// environment variable SYSTEMROOT
|
||||
if ( GetEnvironmentVariableA( "SYSTEMROOT", lpszPath, BUFFERSIZE ) )
|
||||
{
|
||||
strcat( lpszSymbolPath, ";" );
|
||||
strcat( lpszSymbolPath, lpszPath );
|
||||
strcat( lpszSymbolPath, ";" );
|
||||
|
||||
// SYSTEMROOT\System32
|
||||
strcat( lpszSymbolPath, lpszPath );
|
||||
strcat( lpszSymbolPath, "\\System32" );
|
||||
}
|
||||
|
||||
// Add user defined path
|
||||
if ( lpszIniPath != NULL )
|
||||
if ( lpszIniPath[0] != '\0' )
|
||||
{
|
||||
strcat( lpszSymbolPath, ";" );
|
||||
strcat( lpszSymbolPath, lpszIniPath );
|
||||
}
|
||||
}
|
||||
|
||||
// Uninitialize the loaded symbol files
|
||||
BOOL UninitSymInfo() {
|
||||
return SymCleanup( GetCurrentProcess() );
|
||||
}
|
||||
|
||||
// Initializes the symbol files
|
||||
BOOL InitSymInfo( PCSTR lpszInitialSymbolPath )
|
||||
{
|
||||
CHAR lpszSymbolPath[BUFFERSIZE];
|
||||
DWORD symOptions = SymGetOptions();
|
||||
|
||||
symOptions |= SYMOPT_LOAD_LINES;
|
||||
symOptions &= ~SYMOPT_UNDNAME;
|
||||
SymSetOptions( symOptions );
|
||||
InitSymbolPath( lpszSymbolPath, lpszInitialSymbolPath );
|
||||
|
||||
return SymInitialize( GetCurrentProcess(), lpszSymbolPath, TRUE);
|
||||
}
|
||||
|
||||
// Get the module name from a given address
|
||||
static BOOL GetModuleNameFromAddress( UINT address, LPTSTR lpszModule )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
IMAGEHLP_MODULE moduleInfo;
|
||||
|
||||
::ZeroMemory( &moduleInfo, sizeof(moduleInfo) );
|
||||
moduleInfo.SizeOfStruct = sizeof(moduleInfo);
|
||||
|
||||
if ( SymGetModuleInfo( GetCurrentProcess(), (DWORD)address, &moduleInfo ) )
|
||||
{
|
||||
// Got it!
|
||||
PCSTR2LPTSTR( moduleInfo.ModuleName, lpszModule );
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
// Not found :(
|
||||
_tcscpy( lpszModule, _T("?") );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get function prototype and parameter info from ip address and stack address
|
||||
static BOOL GetFunctionInfoFromAddresses( ULONG fnAddress, ULONG stackAddress, LPTSTR lpszSymbol )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
DWORD dwSymSize = 10000;
|
||||
TCHAR lpszUnDSymbol[BUFFERSIZE]=_T("?");
|
||||
CHAR lpszNonUnicodeUnDSymbol[BUFFERSIZE]="?";
|
||||
LPTSTR lpszParamSep = NULL;
|
||||
LPTSTR lpszParsed = lpszUnDSymbol;
|
||||
PIMAGEHLP_SYMBOL pSym = (PIMAGEHLP_SYMBOL)GlobalAlloc( GMEM_FIXED, dwSymSize );
|
||||
|
||||
::ZeroMemory( pSym, dwSymSize );
|
||||
pSym->SizeOfStruct = dwSymSize;
|
||||
pSym->MaxNameLength = dwSymSize - sizeof(IMAGEHLP_SYMBOL);
|
||||
|
||||
// Set the default to unknown
|
||||
_tcscpy( lpszSymbol, _T("?") );
|
||||
|
||||
// Get symbol info for IP
|
||||
#ifndef _M_X64
|
||||
if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, &dwDisp, pSym ) )
|
||||
#else
|
||||
//makes it compile but hell im not sure if this works...
|
||||
if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, (PDWORD64)&dwDisp, pSym ) )
|
||||
#endif
|
||||
{
|
||||
// Make the symbol readable for humans
|
||||
UnDecorateSymbolName( pSym->Name, lpszNonUnicodeUnDSymbol, BUFFERSIZE,
|
||||
UNDNAME_COMPLETE |
|
||||
UNDNAME_NO_THISTYPE |
|
||||
UNDNAME_NO_SPECIAL_SYMS |
|
||||
UNDNAME_NO_MEMBER_TYPE |
|
||||
UNDNAME_NO_MS_KEYWORDS |
|
||||
UNDNAME_NO_ACCESS_SPECIFIERS );
|
||||
|
||||
// Symbol information is ANSI string
|
||||
PCSTR2LPTSTR( lpszNonUnicodeUnDSymbol, lpszUnDSymbol );
|
||||
|
||||
// I am just smarter than the symbol file :)
|
||||
if ( _tcscmp(lpszUnDSymbol, _T("_WinMain@16")) == 0 )
|
||||
_tcscpy(lpszUnDSymbol, _T("WinMain(HINSTANCE,HINSTANCE,LPCTSTR,int)"));
|
||||
else
|
||||
if ( _tcscmp(lpszUnDSymbol, _T("_main")) == 0 )
|
||||
_tcscpy(lpszUnDSymbol, _T("main(int,TCHAR * *)"));
|
||||
else
|
||||
if ( _tcscmp(lpszUnDSymbol, _T("_mainCRTStartup")) == 0 )
|
||||
_tcscpy(lpszUnDSymbol, _T("mainCRTStartup()"));
|
||||
else
|
||||
if ( _tcscmp(lpszUnDSymbol, _T("_wmain")) == 0 )
|
||||
_tcscpy(lpszUnDSymbol, _T("wmain(int,TCHAR * *,TCHAR * *)"));
|
||||
else
|
||||
if ( _tcscmp(lpszUnDSymbol, _T("_wmainCRTStartup")) == 0 )
|
||||
_tcscpy(lpszUnDSymbol, _T("wmainCRTStartup()"));
|
||||
|
||||
lpszSymbol[0] = _T('\0');
|
||||
|
||||
// Let's go through the stack, and modify the function prototype, and insert the actual
|
||||
// parameter values from the stack
|
||||
if ( _tcsstr( lpszUnDSymbol, _T("(void)") ) == NULL && _tcsstr( lpszUnDSymbol, _T("()") ) == NULL)
|
||||
{
|
||||
ULONG index = 0;
|
||||
for( ; ; index++ )
|
||||
{
|
||||
lpszParamSep = _tcschr( lpszParsed, _T(',') );
|
||||
if ( lpszParamSep == NULL )
|
||||
break;
|
||||
|
||||
*lpszParamSep = _T('\0');
|
||||
|
||||
_tcscat( lpszSymbol, lpszParsed );
|
||||
_stprintf( lpszSymbol + _tcslen(lpszSymbol), _T("=0x%08X,"), *((ULONG*)(stackAddress) + 2 + index) );
|
||||
|
||||
lpszParsed = lpszParamSep + 1;
|
||||
}
|
||||
|
||||
lpszParamSep = _tcschr( lpszParsed, _T(')') );
|
||||
if ( lpszParamSep != NULL )
|
||||
{
|
||||
*lpszParamSep = _T('\0');
|
||||
|
||||
_tcscat( lpszSymbol, lpszParsed );
|
||||
_stprintf( lpszSymbol + _tcslen(lpszSymbol), _T("=0x%08X)"), *((ULONG*)(stackAddress) + 2 + index) );
|
||||
|
||||
lpszParsed = lpszParamSep + 1;
|
||||
}
|
||||
}
|
||||
|
||||
_tcscat( lpszSymbol, lpszParsed );
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
GlobalFree( pSym );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get source file name and line number from IP address
|
||||
// The output format is: "sourcefile(linenumber)" or
|
||||
// "modulename!address" or
|
||||
// "address"
|
||||
static BOOL GetSourceInfoFromAddress( UINT address, LPTSTR lpszSourceInfo )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
IMAGEHLP_LINE lineInfo;
|
||||
DWORD dwDisp;
|
||||
TCHAR lpszFileName[BUFFERSIZE] = _T("");
|
||||
TCHAR lpModuleInfo[BUFFERSIZE] = _T("");
|
||||
|
||||
_tcscpy( lpszSourceInfo, _T("?(?)") );
|
||||
|
||||
::ZeroMemory( &lineInfo, sizeof( lineInfo ) );
|
||||
lineInfo.SizeOfStruct = sizeof( lineInfo );
|
||||
|
||||
if ( SymGetLineFromAddr( GetCurrentProcess(), address, &dwDisp, &lineInfo ) )
|
||||
{
|
||||
// Got it. Let's use "sourcefile(linenumber)" format
|
||||
PCSTR2LPTSTR( lineInfo.FileName, lpszFileName );
|
||||
TCHAR fname[_MAX_FNAME];
|
||||
TCHAR ext[_MAX_EXT];
|
||||
_tsplitpath(lpszFileName, NULL, NULL, fname, ext);
|
||||
_stprintf( lpszSourceInfo, _T("%s%s(%d)"), fname, ext, lineInfo.LineNumber );
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is no source file information. :(
|
||||
// Let's use the "modulename!address" format
|
||||
GetModuleNameFromAddress( address, lpModuleInfo );
|
||||
|
||||
if ( lpModuleInfo[0] == _T('?') || lpModuleInfo[0] == _T('\0'))
|
||||
// There is no modulename information. :((
|
||||
// Let's use the "address" format
|
||||
_stprintf( lpszSourceInfo, _T("0x%08X"), address );
|
||||
else
|
||||
_stprintf( lpszSourceInfo, _T("%s!0x%08X"), lpModuleInfo, address );
|
||||
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file )
|
||||
{
|
||||
STACKFRAME callStack;
|
||||
BOOL bResult;
|
||||
CONTEXT context;
|
||||
TCHAR symInfo[BUFFERSIZE] = _T("?");
|
||||
TCHAR srcInfo[BUFFERSIZE] = _T("?");
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
// If it's not this thread, let's suspend it, and resume it at the end
|
||||
if ( hThread != GetCurrentThread() )
|
||||
if ( SuspendThread( hThread ) == -1 )
|
||||
{
|
||||
// whaaat ?!
|
||||
etfprint(file, "Call stack info failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
::ZeroMemory( &context, sizeof(context) );
|
||||
context.ContextFlags = CONTEXT_FULL;
|
||||
|
||||
if ( !GetThreadContext( hThread, &context ) )
|
||||
{
|
||||
etfprint(file, "Call stack info failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
::ZeroMemory( &callStack, sizeof(callStack) );
|
||||
#ifndef _M_X64
|
||||
callStack.AddrPC.Offset = context.Eip;
|
||||
callStack.AddrStack.Offset = context.Esp;
|
||||
callStack.AddrFrame.Offset = context.Ebp;
|
||||
#else
|
||||
callStack.AddrPC.Offset = context.Rip;
|
||||
callStack.AddrStack.Offset = context.Rsp;
|
||||
callStack.AddrFrame.Offset = context.Rbp;
|
||||
#endif
|
||||
callStack.AddrPC.Mode = AddrModeFlat;
|
||||
callStack.AddrStack.Mode = AddrModeFlat;
|
||||
callStack.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
etfprint(file, "Call stack info: \n");
|
||||
etfprint(file, lpszMessage);
|
||||
|
||||
GetFunctionInfoFromAddresses( callStack.AddrPC.Offset, callStack.AddrFrame.Offset, symInfo );
|
||||
GetSourceInfoFromAddress( callStack.AddrPC.Offset, srcInfo );
|
||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
||||
|
||||
for( ULONG index = 0; ; index++ )
|
||||
{
|
||||
bResult = StackWalk(
|
||||
IMAGE_FILE_MACHINE_I386,
|
||||
hProcess,
|
||||
hThread,
|
||||
&callStack,
|
||||
NULL,
|
||||
NULL,
|
||||
SymFunctionTableAccess,
|
||||
SymGetModuleBase,
|
||||
NULL);
|
||||
|
||||
if ( index == 0 )
|
||||
continue;
|
||||
|
||||
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
||||
break;
|
||||
|
||||
GetFunctionInfoFromAddresses( callStack.AddrPC.Offset, callStack.AddrFrame.Offset, symInfo );
|
||||
GetSourceInfoFromAddress( callStack.AddrPC.Offset, srcInfo );
|
||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
||||
|
||||
}
|
||||
|
||||
if ( hThread != GetCurrentThread() )
|
||||
ResumeThread( hThread );
|
||||
}
|
||||
|
||||
void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp )
|
||||
{
|
||||
STACKFRAME callStack;
|
||||
BOOL bResult;
|
||||
TCHAR symInfo[BUFFERSIZE] = _T("?");
|
||||
TCHAR srcInfo[BUFFERSIZE] = _T("?");
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
// If it's not this thread, let's suspend it, and resume it at the end
|
||||
if ( hThread != GetCurrentThread() )
|
||||
if ( SuspendThread( hThread ) == -1 )
|
||||
{
|
||||
// whaaat ?!
|
||||
etfprint(file, "Call stack info failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
::ZeroMemory( &callStack, sizeof(callStack) );
|
||||
callStack.AddrPC.Offset = eip;
|
||||
callStack.AddrStack.Offset = esp;
|
||||
callStack.AddrFrame.Offset = ebp;
|
||||
callStack.AddrPC.Mode = AddrModeFlat;
|
||||
callStack.AddrStack.Mode = AddrModeFlat;
|
||||
callStack.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
etfprint(file, "Call stack info: \n");
|
||||
etfprint(file, lpszMessage);
|
||||
|
||||
GetFunctionInfoFromAddresses( callStack.AddrPC.Offset, callStack.AddrFrame.Offset, symInfo );
|
||||
GetSourceInfoFromAddress( callStack.AddrPC.Offset, srcInfo );
|
||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
||||
|
||||
for( ULONG index = 0; ; index++ )
|
||||
{
|
||||
bResult = StackWalk(
|
||||
IMAGE_FILE_MACHINE_I386,
|
||||
hProcess,
|
||||
hThread,
|
||||
&callStack,
|
||||
NULL,
|
||||
NULL,
|
||||
SymFunctionTableAccess,
|
||||
SymGetModuleBase,
|
||||
NULL);
|
||||
|
||||
if ( index == 0 )
|
||||
continue;
|
||||
|
||||
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
||||
break;
|
||||
|
||||
GetFunctionInfoFromAddresses( callStack.AddrPC.Offset, callStack.AddrFrame.Offset, symInfo );
|
||||
GetSourceInfoFromAddress( callStack.AddrPC.Offset, srcInfo );
|
||||
etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n"));
|
||||
|
||||
}
|
||||
|
||||
if ( hThread != GetCurrentThread() )
|
||||
ResumeThread( hThread );
|
||||
}
|
||||
|
||||
char g_uefbuf[2048];
|
||||
|
||||
void etfprintf(FILE *file, const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int len = vsprintf(g_uefbuf, format, ap);
|
||||
fwrite(g_uefbuf, 1, len, file);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void etfprint(FILE *file, const std::string &text) {
|
||||
size_t len = text.length();
|
||||
fwrite(text.data(), 1, len, file);
|
||||
}
|
||||
|
||||
#endif //WIN32
|
|
@ -0,0 +1,56 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Written by Zoltan Csizmadia, zoltan_csizmadia@yahoo.com
|
||||
// For companies(Austin,TX): If you would like to get my resume, send an email.
|
||||
//
|
||||
// The source is free, but if you want to use it, mention my name and e-mail address
|
||||
//
|
||||
// History:
|
||||
// 1.0 Initial version Zoltan Csizmadia
|
||||
// 1.1 WhineCube version Masken
|
||||
// 1.2 Dolphin version Masken
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExtendedTrace.h
|
||||
//
|
||||
|
||||
#ifndef EXTENDEDTRACE_H_INCLUDED
|
||||
#define EXTENDEDTRACE_H_INCLUDED
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#pragma comment( lib, "imagehlp.lib" )
|
||||
|
||||
#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) InitSymInfo( IniSymbolPath )
|
||||
#define EXTENDEDTRACEUNINITIALIZE() UninitSymInfo()
|
||||
#define STACKTRACE(file) StackTrace( GetCurrentThread(), _T(""), file)
|
||||
#define STACKTRACE2(file, eip, esp, ebp) StackTrace(GetCurrentThread(), _T(""), file, eip, esp, ebp)
|
||||
//class File;
|
||||
|
||||
BOOL InitSymInfo( PCSTR );
|
||||
BOOL UninitSymInfo();
|
||||
void StackTrace( HANDLE, LPCTSTR, FILE *file);
|
||||
void StackTrace( HANDLE, LPCTSTR, FILE *file, DWORD eip, DWORD esp, DWORD ebp);
|
||||
|
||||
//functions by Masken
|
||||
void etfprintf(FILE *file, const char *format, ...);
|
||||
void etfprint(FILE *file, const std::string &text);
|
||||
#define UEFBUFSIZE 2048
|
||||
extern char g_uefbuf[UEFBUFSIZE];
|
||||
|
||||
#else //not WIN32
|
||||
|
||||
#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) ((void)0)
|
||||
#define EXTENDEDTRACEUNINITIALIZE() ((void)0)
|
||||
#define STACKTRACE(file) ((void)0)
|
||||
#define STACKTRACE2(file, eip, esp, ebp) ((void)0)
|
||||
|
||||
#endif //WIN32
|
||||
|
||||
#endif //EXTENDEDTRACE_H_INCLUDED
|
|
@ -0,0 +1,7 @@
|
|||
REV=`svnversion -n ./`
|
||||
echo $REV
|
||||
|
||||
cat > Src/svnrev.h <<EOF
|
||||
#define SVN_REV $REV
|
||||
#define SVN_REV_STR "$REV"
|
||||
EOF
|
|
@ -0,0 +1,120 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// M O D U L E B E G I N ///////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// C L A S S/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CDolLoader
|
||||
{
|
||||
public:
|
||||
|
||||
CDolLoader(const char* _szFilename) :
|
||||
m_bInit(false)
|
||||
{
|
||||
// try to open file
|
||||
FILE* pStream = NULL;
|
||||
fopen_s(&pStream, _szFilename, "rb");
|
||||
if (pStream)
|
||||
{
|
||||
fread(&m_dolheader, 1, sizeof(SDolHeader), pStream);
|
||||
|
||||
// swap memory
|
||||
u32* p = (u32*)&m_dolheader;
|
||||
for (int i=0; i<(sizeof(SDolHeader)>>2); i++)
|
||||
p[i] = Common::swap32(p[i]);
|
||||
|
||||
// load all text (code) sections
|
||||
for(int i=0; i<DOL_NUM_TEXT; i++)
|
||||
{
|
||||
if(m_dolheader.textOffset[i] != 0)
|
||||
{
|
||||
u8* pTemp = new u8[m_dolheader.textSize[i]];
|
||||
|
||||
fseek(pStream, m_dolheader.textOffset[i], SEEK_SET);
|
||||
fread(pTemp, 1, m_dolheader.textSize[i], pStream);
|
||||
|
||||
for (size_t num=0; num<m_dolheader.textSize[i]; num++)
|
||||
CMemory::Write_U8(pTemp[num], m_dolheader.textAddress[i] + num);
|
||||
|
||||
delete [] pTemp;
|
||||
}
|
||||
}
|
||||
|
||||
// load all data sections
|
||||
for(int i=0; i<DOL_NUM_DATA; i++)
|
||||
{
|
||||
if(m_dolheader.dataOffset[i] != 0)
|
||||
{
|
||||
u8* pTemp = new u8[m_dolheader.dataSize[i]];
|
||||
|
||||
fseek(pStream, m_dolheader.dataOffset[i], SEEK_SET);
|
||||
fread(pTemp, 1, m_dolheader.dataSize[i], pStream);
|
||||
|
||||
for (size_t num=0; num<m_dolheader.dataSize[i]; num++)
|
||||
CMemory::Write_U8(pTemp[num], m_dolheader.dataAddress[i] + num);
|
||||
|
||||
delete [] pTemp;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(pStream);
|
||||
m_bInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
_u32 GetEntryPoint(void)
|
||||
{
|
||||
return m_dolheader.entryPoint;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
DOL_NUM_TEXT = 7,
|
||||
DOL_NUM_DATA = 11
|
||||
};
|
||||
|
||||
struct SDolHeader
|
||||
{
|
||||
_u32 textOffset[DOL_NUM_TEXT];
|
||||
_u32 dataOffset[DOL_NUM_DATA];
|
||||
|
||||
_u32 textAddress[DOL_NUM_TEXT];
|
||||
_u32 dataAddress[DOL_NUM_DATA];
|
||||
|
||||
_u32 textSize[DOL_NUM_TEXT];
|
||||
_u32 dataSize[DOL_NUM_DATA];
|
||||
|
||||
_u32 bssAddress;
|
||||
_u32 bssSize;
|
||||
_u32 entryPoint;
|
||||
_u32 padd[7];
|
||||
};
|
||||
|
||||
SDolHeader m_dolheader;
|
||||
|
||||
bool m_bInit;
|
||||
};
|
|
@ -44,6 +44,7 @@
|
|||
#include "Config.h"
|
||||
#include "CodeWindow.h"
|
||||
#include "LogWindow.h"
|
||||
#include "ExtendedTrace.h"
|
||||
#include "BootManager.h"
|
||||
////////////////////////////////////
|
||||
|
||||
|
@ -69,11 +70,11 @@ LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
|
|||
FILE* file=NULL;
|
||||
fopen_s(&file, "exceptioninfo.txt", "a");
|
||||
fseek(file, 0, SEEK_END);
|
||||
fprint(file, "\n");
|
||||
//fprint(file, g_buildtime);
|
||||
//fprint(file, "\n");
|
||||
etfprint(file, "\n");
|
||||
//etfprint(file, g_buildtime);
|
||||
//etfprint(file, "\n");
|
||||
//dumpCurrentDate(file);
|
||||
fprintf(file, "Unhandled Exception\n Code: 0x%08X\n",
|
||||
etfprintf(file, "Unhandled Exception\n Code: 0x%08X\n",
|
||||
e->ExceptionRecord->ExceptionCode);
|
||||
#ifndef _M_X64
|
||||
STACKTRACE2(file, e->ContextRecord->Eip, e->ContextRecord->Esp, e->ContextRecord->Ebp);
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
// Windows Template Library - WTL version 8.0
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// This file is a part of the Windows Template Library.
|
||||
// The use and distribution terms for this software are covered by the
|
||||
// Common Public License 1.0 (http://opensource.org/osi3.0/licenses/cpl1.0.php)
|
||||
// which can be found in the file CPL.TXT at the root of this distribution.
|
||||
// By using this software in any fashion, you are agreeing to be bound by
|
||||
// the terms of this license. You must not remove this notice, or
|
||||
// any other, from this software.
|
||||
|
||||
#ifndef __ATLRES_H__
|
||||
#define __ATLRES_H__
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined (_WIN32_WCE) && !defined (__ATLRESCE_H__)
|
||||
#error Use atlresCE.h instead of atlres.h for Windows CE
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RC_INVOKED
|
||||
#ifndef _INC_WINDOWS
|
||||
|
||||
#define _INC_WINDOWS
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#define VS_VERSION_INFO 1
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#ifndef WINVER
|
||||
#define WINVER 0x0400 // default to Windows Version 4.0
|
||||
#endif // !WINVER
|
||||
|
||||
#include <winresrc.h>
|
||||
|
||||
// operation messages sent to DLGINIT
|
||||
#define LB_ADDSTRING (WM_USER + 1)
|
||||
#define CB_ADDSTRING (WM_USER + 3)
|
||||
#endif // !_WIN32_WCE
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#ifdef IDC_STATIC
|
||||
#undef IDC_STATIC
|
||||
#endif // IDC_STATIC
|
||||
#define IDC_STATIC (-1)
|
||||
|
||||
#endif // !_INC_WINDOWS
|
||||
#endif // RC_INVOKED
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ATL resource types
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
#define RT_DLGINIT MAKEINTRESOURCE(240)
|
||||
#define RT_TOOLBAR MAKEINTRESOURCE(241)
|
||||
#endif // RC_INVOKED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Standard window components
|
||||
|
||||
#define ID_SEPARATOR 0 // special separator value
|
||||
#define ID_DEFAULT_PANE 0 // default status bar pane
|
||||
|
||||
#ifndef RC_INVOKED // code only
|
||||
// standard control bars (IDW = window ID)
|
||||
#define ATL_IDW_TOOLBAR 0xE800 // main Toolbar for window
|
||||
#define ATL_IDW_STATUS_BAR 0xE801 // Status bar window
|
||||
#define ATL_IDW_COMMAND_BAR 0xE802 // Command bar window
|
||||
|
||||
// parts of a frame window
|
||||
#define ATL_IDW_CLIENT 0xE900
|
||||
#define ATL_IDW_PANE_FIRST 0xE900 // first pane (256 max)
|
||||
#define ATL_IDW_PANE_LAST 0xE9FF
|
||||
#define ATL_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max)
|
||||
#define ATL_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max)
|
||||
|
||||
#define ATL_IDW_SIZE_BOX 0xEA20 // size box for splitters
|
||||
#define ATL_IDW_PANE_SAVE 0xEA21 // to shift ATL_IDW_PANE_FIRST
|
||||
|
||||
// bands for a rebar
|
||||
#define ATL_IDW_BAND_FIRST 0xEB00
|
||||
#define ATL_IDW_BAND_LAST 0xEBFF
|
||||
#endif // !RC_INVOKED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Standard Commands
|
||||
|
||||
// File commands
|
||||
#define ID_FILE_NEW 0xE100
|
||||
#define ID_FILE_OPEN 0xE101
|
||||
#define ID_FILE_CLOSE 0xE102
|
||||
#define ID_FILE_SAVE 0xE103
|
||||
#define ID_FILE_SAVE_AS 0xE104
|
||||
#define ID_FILE_PAGE_SETUP 0xE105
|
||||
#define ID_FILE_PRINT_SETUP 0xE106
|
||||
#define ID_FILE_PRINT 0xE107
|
||||
#define ID_FILE_PRINT_DIRECT 0xE108
|
||||
#define ID_FILE_PRINT_PREVIEW 0xE109
|
||||
#define ID_FILE_UPDATE 0xE10A
|
||||
#define ID_FILE_SAVE_COPY_AS 0xE10B
|
||||
#define ID_FILE_SEND_MAIL 0xE10C
|
||||
|
||||
#define ID_FILE_MRU_FIRST 0xE110
|
||||
#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max
|
||||
#define ID_FILE_MRU_FILE2 0xE111
|
||||
#define ID_FILE_MRU_FILE3 0xE112
|
||||
#define ID_FILE_MRU_FILE4 0xE113
|
||||
#define ID_FILE_MRU_FILE5 0xE114
|
||||
#define ID_FILE_MRU_FILE6 0xE115
|
||||
#define ID_FILE_MRU_FILE7 0xE116
|
||||
#define ID_FILE_MRU_FILE8 0xE117
|
||||
#define ID_FILE_MRU_FILE9 0xE118
|
||||
#define ID_FILE_MRU_FILE10 0xE119
|
||||
#define ID_FILE_MRU_FILE11 0xE11A
|
||||
#define ID_FILE_MRU_FILE12 0xE11B
|
||||
#define ID_FILE_MRU_FILE13 0xE11C
|
||||
#define ID_FILE_MRU_FILE14 0xE11D
|
||||
#define ID_FILE_MRU_FILE15 0xE11E
|
||||
#define ID_FILE_MRU_FILE16 0xE11F
|
||||
#define ID_FILE_MRU_LAST 0xE11F
|
||||
|
||||
// Edit commands
|
||||
#define ID_EDIT_CLEAR 0xE120
|
||||
#define ID_EDIT_CLEAR_ALL 0xE121
|
||||
#define ID_EDIT_COPY 0xE122
|
||||
#define ID_EDIT_CUT 0xE123
|
||||
#define ID_EDIT_FIND 0xE124
|
||||
#define ID_EDIT_PASTE 0xE125
|
||||
#define ID_EDIT_PASTE_LINK 0xE126
|
||||
#define ID_EDIT_PASTE_SPECIAL 0xE127
|
||||
#define ID_EDIT_REPEAT 0xE128
|
||||
#define ID_EDIT_REPLACE 0xE129
|
||||
#define ID_EDIT_SELECT_ALL 0xE12A
|
||||
#define ID_EDIT_UNDO 0xE12B
|
||||
#define ID_EDIT_REDO 0xE12C
|
||||
|
||||
// Window commands
|
||||
#define ID_WINDOW_NEW 0xE130
|
||||
#define ID_WINDOW_ARRANGE 0xE131
|
||||
#define ID_WINDOW_CASCADE 0xE132
|
||||
#define ID_WINDOW_TILE_HORZ 0xE133
|
||||
#define ID_WINDOW_TILE_VERT 0xE134
|
||||
#define ID_WINDOW_SPLIT 0xE135
|
||||
#ifndef RC_INVOKED // code only
|
||||
#define ATL_IDM_WINDOW_FIRST 0xE130
|
||||
#define ATL_IDM_WINDOW_LAST 0xE13F
|
||||
#define ATL_IDM_FIRST_MDICHILD 0xFF00 // window list starts here
|
||||
#define ATL_IDM_LAST_MDICHILD 0xFFFD
|
||||
#endif // !RC_INVOKED
|
||||
// TabView
|
||||
#define ID_WINDOW_TABFIRST 0xFF00 // = ATL_IDM_FIRST_MDICHILD
|
||||
#define ID_WINDOW_TABLAST 0xFFFD
|
||||
#define ID_WINDOW_SHOWTABLIST 0xFFFE
|
||||
|
||||
// Help and App commands
|
||||
#define ID_APP_ABOUT 0xE140
|
||||
#define ID_APP_EXIT 0xE141
|
||||
#define ID_HELP_INDEX 0xE142
|
||||
#define ID_HELP_FINDER 0xE143
|
||||
#define ID_HELP_USING 0xE144
|
||||
#define ID_CONTEXT_HELP 0xE145 // shift-F1
|
||||
// special commands for processing help
|
||||
#define ID_HELP 0xE146 // first attempt for F1
|
||||
#define ID_DEFAULT_HELP 0xE147 // last attempt
|
||||
|
||||
// Misc
|
||||
#define ID_NEXT_PANE 0xE150
|
||||
#define ID_PREV_PANE 0xE151
|
||||
#define ID_PANE_CLOSE 0xE152
|
||||
|
||||
// Format
|
||||
#define ID_FORMAT_FONT 0xE160
|
||||
|
||||
// Scroll
|
||||
#define ID_SCROLL_UP 0xE170
|
||||
#define ID_SCROLL_DOWN 0xE171
|
||||
#define ID_SCROLL_PAGE_UP 0xE172
|
||||
#define ID_SCROLL_PAGE_DOWN 0xE173
|
||||
#define ID_SCROLL_TOP 0xE174
|
||||
#define ID_SCROLL_BOTTOM 0xE175
|
||||
#define ID_SCROLL_LEFT 0xE176
|
||||
#define ID_SCROLL_RIGHT 0xE177
|
||||
#define ID_SCROLL_PAGE_LEFT 0xE178
|
||||
#define ID_SCROLL_PAGE_RIGHT 0xE179
|
||||
#define ID_SCROLL_ALL_LEFT 0xE17A
|
||||
#define ID_SCROLL_ALL_RIGHT 0xE17B
|
||||
|
||||
// OLE commands
|
||||
#define ID_OLE_INSERT_NEW 0xE200
|
||||
#define ID_OLE_EDIT_LINKS 0xE201
|
||||
#define ID_OLE_EDIT_CONVERT 0xE202
|
||||
#define ID_OLE_EDIT_CHANGE_ICON 0xE203
|
||||
#define ID_OLE_EDIT_PROPERTIES 0xE204
|
||||
#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max
|
||||
#ifndef RC_INVOKED // code only
|
||||
#define ID_OLE_VERB_LAST 0xE21F
|
||||
#endif // !RC_INVOKED
|
||||
|
||||
// View commands (same number used as IDW used for toolbar and status bar)
|
||||
#define ID_VIEW_TOOLBAR 0xE800
|
||||
#define ID_VIEW_STATUS_BAR 0xE801
|
||||
#define ID_VIEW_REFRESH 0xE803
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Standard control IDs
|
||||
|
||||
#ifdef IDC_STATIC
|
||||
#undef IDC_STATIC
|
||||
#endif // IDC_STATIC
|
||||
#define IDC_STATIC (-1) // all static controls
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Standard string error/warnings
|
||||
|
||||
// idle status bar message
|
||||
#define ATL_IDS_IDLEMESSAGE 0xE001
|
||||
|
||||
#ifndef RC_INVOKED // code only
|
||||
#define ATL_IDS_SCFIRST 0xEF00
|
||||
#endif // !RC_INVOKED
|
||||
|
||||
#define ATL_IDS_SCSIZE 0xEF00
|
||||
#define ATL_IDS_SCMOVE 0xEF01
|
||||
#define ATL_IDS_SCMINIMIZE 0xEF02
|
||||
#define ATL_IDS_SCMAXIMIZE 0xEF03
|
||||
#define ATL_IDS_SCNEXTWINDOW 0xEF04
|
||||
#define ATL_IDS_SCPREVWINDOW 0xEF05
|
||||
#define ATL_IDS_SCCLOSE 0xEF06
|
||||
#define ATL_IDS_SCRESTORE 0xEF12
|
||||
#define ATL_IDS_SCTASKLIST 0xEF13
|
||||
|
||||
#define ATL_IDS_MDICHILD 0xEF1F
|
||||
#define ATL_IDS_MRU_FILE 0xEFDA
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Misc. control IDs
|
||||
|
||||
// Property Sheet control id's (determined with Spy++)
|
||||
#define ID_APPLY_NOW 0x3021
|
||||
#define ID_WIZBACK 0x3023
|
||||
#define ID_WIZNEXT 0x3024
|
||||
#define ID_WIZFINISH 0x3025
|
||||
#define ATL_IDC_TAB_CONTROL 0x3020
|
||||
|
||||
#endif // __ATLRES_H__
|
|
@ -0,0 +1,30 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by resources.rc
|
||||
//
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_MAINDLG 129
|
||||
#define IDD_DISASMDLG 129
|
||||
#define IDD_DISASMDLG1 130
|
||||
#define IDD_REGISTERDLG 130
|
||||
#define IDC_LIST1 1000
|
||||
#define IDC_DISASM_LIST 1000
|
||||
#define ID_STEP 1001
|
||||
#define ID_SHOW_REGISTER 1002
|
||||
#define IDC_ASSERT_INT 1003
|
||||
#define ID_GO 1004
|
||||
#define IDC_HALT 1005
|
||||
#define IDC_HALT2 1006
|
||||
#define IDC_INIT 1006
|
||||
#define IDC_GROUP 1007
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 202
|
||||
#define _APS_NEXT_COMMAND_VALUE 32772
|
||||
#define _APS_NEXT_CONTROL_VALUE 1008
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,323 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "atlres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Germany) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDR_MAINFRAME DIALOGEX 0, 0, 186, 94
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDR_MAINFRAME, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 87
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // German (Germany) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""atlres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_DISASMDLG DIALOGEX 0, 0, 513, 298
|
||||
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Debugger"
|
||||
FONT 8, "Tahoma", 400, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Step",ID_STEP,456,7,50,14
|
||||
CONTROL "",IDC_DISASM_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SORTDESCENDING | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,445,284
|
||||
PUSHBUTTON "&Show Regs",ID_SHOW_REGISTER,456,277,50,14
|
||||
DEFPUSHBUTTON "Go",ID_GO,456,23,50,14
|
||||
CONTROL "AssertInt",IDC_ASSERT_INT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,455,50,51,9
|
||||
CONTROL "Halt",IDC_HALT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,455,63,51,9
|
||||
CONTROL "Init",IDC_INIT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,455,75,51,9
|
||||
END
|
||||
|
||||
IDD_REGISTERDLG DIALOGEX 0, 0, 312, 170
|
||||
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Registers Dialog"
|
||||
FONT 8, "Tahoma", 400, 0, 0x0
|
||||
BEGIN
|
||||
CONTROL "",IDC_DISASM_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_ALIGNLEFT | LVS_NOSCROLL | WS_BORDER | WS_TABSTOP,7,7,298,156
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_DISASMDLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 506
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 291
|
||||
END
|
||||
|
||||
IDD_REGISTERDLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 305
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 163
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS
|
||||
BEGIN
|
||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL
|
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
|
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
|
||||
"P", ID_FILE_PRINT, VIRTKEY, CONTROL
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
|
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
|
||||
VK_F6, ID_NEXT_PANE, VIRTKEY
|
||||
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "test1 Module"
|
||||
VALUE "FileVersion", "1, 0, 0, 1"
|
||||
VALUE "InternalName", "TEST1"
|
||||
VALUE "LegalCopyright", "Copyright 2004"
|
||||
VALUE "OriginalFilename", "demoproject1.exe"
|
||||
VALUE "ProductName", "demoproject1 Module"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "demoproject1"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document\nNew"
|
||||
ID_FILE_OPEN "Open an existing document\nOpen"
|
||||
ID_FILE_CLOSE "Close the active document\nClose"
|
||||
ID_FILE_SAVE "Save the active document\nSave"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
|
||||
ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup"
|
||||
ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup"
|
||||
ID_FILE_PRINT "Print the active document\nPrint"
|
||||
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_WINDOW_NEW "Open another window for the active document\nNew Window"
|
||||
ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons"
|
||||
ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows"
|
||||
ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows"
|
||||
ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows"
|
||||
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_EDIT_CLEAR "Erase the selection\nErase"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
|
||||
ID_EDIT_FIND "Find the specified text\nFind"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
|
||||
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
|
||||
ID_EDIT_UNDO "Undo the last action\nUndo"
|
||||
ID_EDIT_REDO "Redo the previously undone action\nRedo"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ATL_IDS_SCSIZE "Change the window size"
|
||||
ATL_IDS_SCMOVE "Change the window position"
|
||||
ATL_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
ATL_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
ATL_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
ATL_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
ATL_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ATL_IDS_SCRESTORE "Restore the window to normal size"
|
||||
ATL_IDS_SCTASKLIST "Activate Task List"
|
||||
ATL_IDS_MDICHILD "Activate this window"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ATL_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ATL_IDS_MRU_FILE "Open this document"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -0,0 +1,280 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
|
||||
#include "DSoundStream.h"
|
||||
|
||||
namespace DSound
|
||||
{
|
||||
#define BUFSIZE 32768
|
||||
#define MAXWAIT 70 //ms
|
||||
|
||||
//THE ROCK SOLID SYNCED DSOUND ENGINE :)
|
||||
|
||||
|
||||
//våran kritiska sektion och vår syncevent-handle
|
||||
CRITICAL_SECTION soundCriticalSection;
|
||||
HANDLE soundSyncEvent;
|
||||
HANDLE hThread;
|
||||
|
||||
StreamCallback callback;
|
||||
|
||||
//lite mojs
|
||||
IDirectSound8* ds;
|
||||
IDirectSoundBuffer* dsBuffer;
|
||||
|
||||
//tja.. behövs
|
||||
int bufferSize; //i bytes
|
||||
int totalRenderedBytes;
|
||||
int sampleRate;
|
||||
|
||||
//med den här synkar vi stängning..
|
||||
//0=vi spelar oväsen, 1=stäng tråden NU! 2=japp,tråden är stängd så fortsätt
|
||||
volatile int threadData;
|
||||
|
||||
|
||||
//ser till så X kan delas med 32
|
||||
inline int FIX32(int x)
|
||||
{
|
||||
return(x & (~127));
|
||||
}
|
||||
|
||||
|
||||
int DSound_GetSampleRate()
|
||||
{
|
||||
return(sampleRate);
|
||||
}
|
||||
|
||||
|
||||
//Dags att skapa vår directsound buffert
|
||||
bool createBuffer()
|
||||
{
|
||||
PCMWAVEFORMAT pcmwf;
|
||||
DSBUFFERDESC dsbdesc;
|
||||
|
||||
//ljudformatet
|
||||
memset(&pcmwf, 0, sizeof(PCMWAVEFORMAT));
|
||||
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
|
||||
|
||||
pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM;
|
||||
pcmwf.wf.nChannels = 2;
|
||||
pcmwf.wf.nSamplesPerSec = sampleRate;
|
||||
pcmwf.wf.nBlockAlign = 4;
|
||||
pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
|
||||
pcmwf.wBitsPerSample = 16;
|
||||
|
||||
//buffer description
|
||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS; //VIKTIGT //DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
|
||||
dsbdesc.dwBufferBytes = bufferSize = BUFSIZE; //FIX32(pcmwf.wf.nAvgBytesPerSec); //ändra för att ställa in bufferstorlek
|
||||
dsbdesc.lpwfxFormat = (WAVEFORMATEX*)&pcmwf;
|
||||
// nu skapar vi bufferjäveln
|
||||
|
||||
if (SUCCEEDED(ds->CreateSoundBuffer(&dsbdesc, &dsBuffer, NULL)))
|
||||
{
|
||||
dsBuffer->SetCurrentPosition(0);
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed.
|
||||
dsBuffer = NULL;
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool writeDataToBuffer(DWORD dwOffset, // Our own write cursor.
|
||||
char* soundData, // Start of our data.
|
||||
DWORD dwSoundBytes) // Size of block to copy.
|
||||
{
|
||||
void* ptr1, * ptr2;
|
||||
DWORD numBytes1, numBytes2;
|
||||
// Obtain memory address of write block. This will be in two parts if the block wraps around.
|
||||
HRESULT hr = dsBuffer->Lock(dwOffset, dwSoundBytes, &ptr1, &numBytes1, &ptr2, &numBytes2, 0);
|
||||
|
||||
// If the buffer was lost, restore and retry lock.
|
||||
|
||||
if (DSERR_BUFFERLOST == hr)
|
||||
{
|
||||
dsBuffer->Restore();
|
||||
hr = dsBuffer->Lock(dwOffset, dwSoundBytes, &ptr1, &numBytes1, &ptr2, &numBytes2, 0);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
memcpy(ptr1, soundData, numBytes1);
|
||||
|
||||
if (ptr2 != 0)
|
||||
{
|
||||
memcpy(ptr2, soundData + numBytes1, numBytes2);
|
||||
}
|
||||
|
||||
// Release the data back to DirectSound.
|
||||
dsBuffer->Unlock(ptr1, numBytes1, ptr2, numBytes2);
|
||||
return(true);
|
||||
} /*
|
||||
else
|
||||
{
|
||||
char temp[8];
|
||||
sprintf(temp,"%i\n",hr);
|
||||
OutputDebugString(temp);
|
||||
}*/
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
inline int ModBufferSize(int x)
|
||||
{
|
||||
return((x + bufferSize) % bufferSize);
|
||||
}
|
||||
|
||||
|
||||
int currentPos;
|
||||
int lastPos;
|
||||
short realtimeBuffer[1024 * 1024];
|
||||
|
||||
|
||||
DWORD WINAPI soundThread(void*)
|
||||
{
|
||||
currentPos = 0;
|
||||
lastPos = 0;
|
||||
//writeDataToBuffer(0,realtimeBuffer,bufferSize);
|
||||
// dsBuffer->Lock(0, bufferSize, (void **)&p1, &num1, (void **)&p2, &num2, 0);
|
||||
|
||||
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
|
||||
|
||||
while (!threadData)
|
||||
{
|
||||
EnterCriticalSection(&soundCriticalSection);
|
||||
|
||||
dsBuffer->GetCurrentPosition((DWORD*)¤tPos, 0);
|
||||
int numBytesToRender = FIX32(ModBufferSize(currentPos - lastPos));
|
||||
|
||||
//renderStuff(numBytesToRender/2);
|
||||
//if (numBytesToRender>bufferSize/2) numBytesToRender=0;
|
||||
|
||||
if (numBytesToRender >= 256)
|
||||
{
|
||||
(*callback)(realtimeBuffer, numBytesToRender >> 2, 16, 44100, 2);
|
||||
|
||||
writeDataToBuffer(lastPos, (char*)realtimeBuffer, numBytesToRender);
|
||||
|
||||
currentPos = ModBufferSize(lastPos + numBytesToRender);
|
||||
totalRenderedBytes += numBytesToRender;
|
||||
|
||||
lastPos = currentPos;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&soundCriticalSection);
|
||||
WaitForSingleObject(soundSyncEvent, MAXWAIT);
|
||||
}
|
||||
|
||||
dsBuffer->Stop();
|
||||
|
||||
threadData = 2;
|
||||
return(0); //hurra!
|
||||
}
|
||||
|
||||
|
||||
bool DSound_StartSound(HWND window, int _sampleRate, StreamCallback _callback)
|
||||
{
|
||||
callback = _callback;
|
||||
threadData = 0;
|
||||
sampleRate = _sampleRate;
|
||||
|
||||
//no security attributes, automatic resetting, init state nonset, untitled
|
||||
soundSyncEvent = CreateEvent(0, false, false, 0);
|
||||
|
||||
//vi initierar den...........
|
||||
InitializeCriticalSection(&soundCriticalSection);
|
||||
|
||||
//vi vill ha access till DSOUND så...
|
||||
if (FAILED(DirectSoundCreate8(0, &ds, 0)))
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//samarbetsvillig? nää :)
|
||||
ds->SetCooperativeLevel(window, DSSCL_NORMAL); //DSSCL_PRIORITY?
|
||||
|
||||
//så.. skapa buffern
|
||||
if (!createBuffer())
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//rensa den.. ?
|
||||
DWORD num1;
|
||||
short* p1;
|
||||
|
||||
dsBuffer->Lock(0, bufferSize, (void* *)&p1, &num1, 0, 0, 0);
|
||||
|
||||
memset(p1, 0, num1);
|
||||
dsBuffer->Unlock(p1, num1, 0, 0);
|
||||
totalRenderedBytes = -bufferSize;
|
||||
DWORD h;
|
||||
hThread = CreateThread(0, 0, soundThread, 0, 0, &h);
|
||||
SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
void DSound_UpdateSound()
|
||||
{
|
||||
SetEvent(soundSyncEvent);
|
||||
}
|
||||
|
||||
|
||||
void DSound_StopSound()
|
||||
{
|
||||
EnterCriticalSection(&soundCriticalSection);
|
||||
threadData = 1;
|
||||
//kick the thread if it's waiting
|
||||
SetEvent(soundSyncEvent);
|
||||
LeaveCriticalSection(&soundCriticalSection);
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
CloseHandle(hThread);
|
||||
|
||||
dsBuffer->Release();
|
||||
ds->Release();
|
||||
|
||||
CloseHandle(soundSyncEvent);
|
||||
}
|
||||
|
||||
|
||||
int DSound_GetCurSample()
|
||||
{
|
||||
EnterCriticalSection(&soundCriticalSection);
|
||||
int playCursor;
|
||||
dsBuffer->GetCurrentPosition((DWORD*)&playCursor, 0);
|
||||
playCursor = ModBufferSize(playCursor - lastPos) + totalRenderedBytes;
|
||||
LeaveCriticalSection(&soundCriticalSection);
|
||||
return(playCursor);
|
||||
}
|
||||
|
||||
|
||||
float DSound_GetTimer()
|
||||
{
|
||||
return((float)DSound_GetCurSample() * (1.0f / (4.0f * 44100.0f)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef __SOUNDSTREAM_H__
|
||||
#define __SOUNDSTREAM_H__
|
||||
|
||||
namespace DSound
|
||||
{
|
||||
typedef void (*StreamCallback)(short* buffer, int numSamples, int bits, int rate, int channels);
|
||||
|
||||
bool DSound_StartSound(HWND window, int sampleRate, StreamCallback _callback);
|
||||
void DSound_UpdateSound();
|
||||
void DSound_StopSound();
|
||||
|
||||
float DSound_GetTimer();
|
||||
int DSound_GetCurSample();
|
||||
int DSound_GetSampleRate();
|
||||
}
|
||||
|
||||
|
||||
#endif //__SOUNDSTREAM_H__
|
|
@ -0,0 +1,667 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "../res/resource.h"
|
||||
#include "DisAsmDlg.h"
|
||||
|
||||
#include "gdsp_memory.h"
|
||||
#include "gdsp_interpreter.h"
|
||||
#include "disassemble.h"
|
||||
#include "RegSettings.h"
|
||||
|
||||
CDisAsmDlg::CDisAsmDlg()
|
||||
: m_CachedStepCounter(-1)
|
||||
, m_CachedCR(-1)
|
||||
, m_State(RUN)
|
||||
, m_CachedUCodeCRC(-1)
|
||||
{}
|
||||
|
||||
|
||||
BOOL CDisAsmDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
return(IsDialogMessage(pMsg));
|
||||
}
|
||||
|
||||
|
||||
BOOL CDisAsmDlg::OnIdle()
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CWindowSettings ws;
|
||||
|
||||
if (ws.Load("Software\\Dolphin\\DSP", "DisAsm"))
|
||||
{
|
||||
ws.ApplyTo(CWindow(m_hWnd), SW_SHOW);
|
||||
}
|
||||
|
||||
m_DisAsmListViewCtrl.m_hWnd = GetDlgItem(IDC_DISASM_LIST);
|
||||
|
||||
UIAddChildWindowContainer(m_hWnd);
|
||||
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("BP"), ColumnBP);
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("Function"), ColumnFunction);
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("Address"), ColumnAddress);
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("Mnenmomic"), ColumnMenmomic);
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("Opcode"), ColumnOpcode);
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("Ext"), ColumnExt);
|
||||
m_DisAsmListViewCtrl.AddColumn(_T("Parameter"), ColumnParameter);
|
||||
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnBP, 25);
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnFunction, 160);
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnAddress, 55);
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnMenmomic, 55);
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnOpcode, 60);
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnExt, 40);
|
||||
m_DisAsmListViewCtrl.SetColumnWidth(ColumnParameter, 500);
|
||||
|
||||
m_DisAsmListViewCtrl.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||
|
||||
m_RegisterDlg.Create(m_hWnd);
|
||||
|
||||
UpdateDialog();
|
||||
|
||||
DlgResize_Init(true, false, WS_THICKFRAME);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CWindowSettings ws;
|
||||
ws.GetFrom(CWindow(m_hWnd));
|
||||
ws.Save("Software\\Dolphin\\DSP", "DisAsm");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnStep(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
m_State = STEP;
|
||||
|
||||
UpdateButtonTexts();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnGo(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
if ((m_State == RUN) || (m_State == RUN_START))
|
||||
{
|
||||
m_State = PAUSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_State = RUN_START;
|
||||
}
|
||||
|
||||
UpdateButtonTexts();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnShowRegisters(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
if (m_RegisterDlg.IsWindowVisible())
|
||||
{
|
||||
m_RegisterDlg.ShowWindow(SW_HIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RegisterDlg.ShowWindow(SW_SHOW);
|
||||
}
|
||||
|
||||
UpdateButtonTexts();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnDblClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
|
||||
{
|
||||
int Index = m_DisAsmListViewCtrl.GetSelectedIndex();
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
uint16 SelectedPC = static_cast<uint16>(m_DisAsmListViewCtrl.GetItemData(Index));
|
||||
ToggleBreakPoint(SelectedPC);
|
||||
}
|
||||
|
||||
RedrawDisAsmListView();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnRClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
|
||||
{
|
||||
int Index = m_DisAsmListViewCtrl.GetSelectedIndex();
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
uint16 SelectedPC = static_cast<uint16>(m_DisAsmListViewCtrl.GetItemData(Index));
|
||||
g_dsp.pc = SelectedPC;
|
||||
}
|
||||
|
||||
RedrawDisAsmListView();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::CloseDialog(int nVal)
|
||||
{
|
||||
DestroyWindow();
|
||||
::PostQuitMessage(nVal);
|
||||
}
|
||||
|
||||
|
||||
int CALLBACK CDisAsmDlg::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
||||
{
|
||||
return(lParam1 > lParam2);
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::RebuildDisAsmListView()
|
||||
{
|
||||
if (!m_DisAsmListViewCtrl.IsWindow())
|
||||
return;
|
||||
|
||||
m_DisAsmListViewCtrl.ShowWindow(SW_HIDE);
|
||||
m_DisAsmListViewCtrl.DeleteAllItems();
|
||||
|
||||
char Buffer[256];
|
||||
gd_globals_t gdg;
|
||||
|
||||
if (g_dsp.pc & 0x8000)
|
||||
{
|
||||
gdg.binbuf = g_dsp.irom;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdg.binbuf = g_dsp.iram;
|
||||
}
|
||||
|
||||
gdg.buffer = Buffer;
|
||||
gdg.buffer_size = 256;
|
||||
gdg.ext_separator = (char)0xff;
|
||||
|
||||
gdg.show_pc = false;
|
||||
gdg.show_hex = false;
|
||||
gdg.print_tabs = true;
|
||||
gdg.decode_names = true;
|
||||
gdg.decode_registers = true;
|
||||
|
||||
for (gdg.pc = 0; gdg.pc < DSP_IROM_SIZE;)
|
||||
{
|
||||
uint16 CurrentPC = gdg.pc;
|
||||
|
||||
if (g_dsp.pc & 0x8000)
|
||||
{
|
||||
CurrentPC |= 0x8000;
|
||||
}
|
||||
|
||||
char Temp[256];
|
||||
sprintf_s(Temp, 256, "0x%04x", CurrentPC);
|
||||
|
||||
char Temp2[256];
|
||||
sprintf_s(Temp2, 256, "0x%04x", dsp_imem_read(CurrentPC));
|
||||
|
||||
char* pOpcode = gd_dis_opcode(&gdg);
|
||||
const char* pParameter = NULL;
|
||||
const char* pExtension = NULL;
|
||||
|
||||
size_t WholeString = strlen(pOpcode);
|
||||
|
||||
for (size_t i = 0; i < WholeString; i++)
|
||||
{
|
||||
if (pOpcode[i] == (char)0xff)
|
||||
{
|
||||
pOpcode[i] = 0x00;
|
||||
pExtension = &pOpcode[i + 1];
|
||||
}
|
||||
|
||||
if (pOpcode[i] == 0x09)
|
||||
{
|
||||
pOpcode[i] = 0x00;
|
||||
pParameter = &pOpcode[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char* pFunctionName = NULL;
|
||||
|
||||
if (m_SymbolMap.find(CurrentPC) != m_SymbolMap.end())
|
||||
{
|
||||
pFunctionName = m_SymbolMap[CurrentPC].Name.c_str();
|
||||
}
|
||||
|
||||
int Item = m_DisAsmListViewCtrl.AddItem(0, ColumnBP, _T(" "));
|
||||
m_DisAsmListViewCtrl.AddItem(Item, ColumnFunction, pFunctionName);
|
||||
m_DisAsmListViewCtrl.AddItem(Item, ColumnAddress, Temp);
|
||||
m_DisAsmListViewCtrl.AddItem(Item, ColumnMenmomic, Temp2);
|
||||
m_DisAsmListViewCtrl.AddItem(Item, ColumnOpcode, pOpcode);
|
||||
m_DisAsmListViewCtrl.AddItem(Item, ColumnExt, pExtension);
|
||||
|
||||
if (!_stricmp(pOpcode, "CALL"))
|
||||
{
|
||||
uint32 FunctionAddress = -1;
|
||||
sscanf(pParameter, "0x%04x", &FunctionAddress);
|
||||
|
||||
if (m_SymbolMap.find(FunctionAddress) != m_SymbolMap.end())
|
||||
{
|
||||
pParameter = m_SymbolMap[FunctionAddress].Name.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
m_DisAsmListViewCtrl.AddItem(Item, ColumnParameter, pParameter);
|
||||
|
||||
m_DisAsmListViewCtrl.SetItemData(Item, CurrentPC);
|
||||
}
|
||||
|
||||
m_DisAsmListViewCtrl.SortItems(CompareFunc, (LPARAM) this);
|
||||
|
||||
m_DisAsmListViewCtrl.ShowWindow(SW_SHOW);
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::UpdateDisAsmListView()
|
||||
{
|
||||
if (g_dsp.dram == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check if we have to rebuild the list view
|
||||
if (m_DisAsmListViewCtrl.GetItemCount() == 0)
|
||||
{
|
||||
RebuildDisAsmListView();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16 FirstPC = static_cast<uint16>(m_DisAsmListViewCtrl.GetItemData(0));
|
||||
|
||||
if ((FirstPC & 0x8000) != (g_dsp.pc & 0x8000))
|
||||
{
|
||||
RebuildDisAsmListView();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_CachedStepCounter == g_dsp.step_counter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// show PC
|
||||
for (int i = 0; i < m_DisAsmListViewCtrl.GetItemCount(); i++)
|
||||
{
|
||||
if (m_DisAsmListViewCtrl.GetItemData(i) == g_dsp.pc)
|
||||
{
|
||||
m_DisAsmListViewCtrl.EnsureVisible(i - 5, FALSE);
|
||||
m_DisAsmListViewCtrl.EnsureVisible(i + 14, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_CachedStepCounter = g_dsp.step_counter;
|
||||
|
||||
RedrawDisAsmListView();
|
||||
|
||||
m_RegisterDlg.UpdateRegisterListView();
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::UpdateSymbolMap()
|
||||
{
|
||||
if (g_dsp.dram == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_CachedUCodeCRC != g_dsp.iram_crc)
|
||||
{
|
||||
// load symbol map (if there is one)
|
||||
m_CachedUCodeCRC = g_dsp.iram_crc;
|
||||
char FileName[MAX_PATH];
|
||||
sprintf(FileName, "maps\\DSP_%08x.map", m_CachedUCodeCRC);
|
||||
LoadSymbolMap(FileName);
|
||||
|
||||
// rebuild the disasm
|
||||
RebuildDisAsmListView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::UpdateRegisterFlags()
|
||||
{
|
||||
if (m_CachedCR == g_dsp.cr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CButton ButtonAssertInt(GetDlgItem(IDC_ASSERT_INT));
|
||||
ButtonAssertInt.SetCheck(g_dsp.cr & 0x02 ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CButton ButtonReset(GetDlgItem(IDC_HALT));
|
||||
ButtonReset.SetCheck(g_dsp.cr & 0x04 ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
CButton ButtonInit(GetDlgItem(IDC_INIT));
|
||||
ButtonInit.SetCheck(g_dsp.cr & 0x800 ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
m_CachedCR = g_dsp.cr;
|
||||
}
|
||||
|
||||
|
||||
bool CDisAsmDlg::CanDoStep()
|
||||
{
|
||||
UpdateSymbolMap(); // update the symbols all the time because there a script cmds like bps
|
||||
|
||||
switch (m_State)
|
||||
{
|
||||
case RUN_START:
|
||||
m_State = RUN;
|
||||
return(true);
|
||||
|
||||
case RUN:
|
||||
|
||||
if (IsBreakPoint(g_dsp.pc))
|
||||
{
|
||||
UpdateDialog();
|
||||
m_State = PAUSE;
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
case PAUSE:
|
||||
UpdateDialog();
|
||||
return(false);
|
||||
|
||||
case STEP:
|
||||
UpdateDialog();
|
||||
m_State = PAUSE;
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::DebugBreak()
|
||||
{
|
||||
m_State = PAUSE;
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::UpdateButtonTexts()
|
||||
{
|
||||
// go button
|
||||
{
|
||||
CButton Button(GetDlgItem(ID_GO));
|
||||
|
||||
switch (m_State)
|
||||
{
|
||||
case RUN_START:
|
||||
case RUN:
|
||||
Button.SetWindowText("Pause");
|
||||
break;
|
||||
|
||||
case PAUSE:
|
||||
case STEP:
|
||||
Button.SetWindowText("Go");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// show register
|
||||
{
|
||||
CButton Button(GetDlgItem(ID_SHOW_REGISTER));
|
||||
|
||||
if (m_RegisterDlg.IsWindowVisible())
|
||||
{
|
||||
Button.SetWindowText("Hide Regs");
|
||||
}
|
||||
else
|
||||
{
|
||||
Button.SetWindowText("Show Regs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CDisAsmDlg::IsBreakPoint(uint16 _Address)
|
||||
{
|
||||
return(std::find(m_BreakPoints.begin(), m_BreakPoints.end(), _Address) != m_BreakPoints.end());
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::ToggleBreakPoint(uint16 _Address)
|
||||
{
|
||||
if (IsBreakPoint(_Address))
|
||||
{
|
||||
RemoveBreakPoint(_Address);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBreakPoint(_Address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::RemoveBreakPoint(uint16 _Address)
|
||||
{
|
||||
CBreakPointList::iterator itr = std::find(m_BreakPoints.begin(), m_BreakPoints.end(), _Address);
|
||||
|
||||
if (itr != m_BreakPoints.end())
|
||||
{
|
||||
m_BreakPoints.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::AddBreakPoint(uint16 _Address)
|
||||
{
|
||||
CBreakPointList::iterator itr = std::find(m_BreakPoints.begin(), m_BreakPoints.end(), _Address);
|
||||
|
||||
if (itr == m_BreakPoints.end())
|
||||
{
|
||||
m_BreakPoints.push_back(_Address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::ClearBreakPoints()
|
||||
{
|
||||
m_BreakPoints.clear();
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDisAsmDlg::OnCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& _bHandled)
|
||||
{
|
||||
int result = CDRF_DODEFAULT;
|
||||
|
||||
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pnmh);
|
||||
|
||||
switch (pLVCD->nmcd.dwDrawStage)
|
||||
{
|
||||
case CDDS_PREPAINT:
|
||||
result = CDRF_NOTIFYITEMDRAW;
|
||||
break;
|
||||
|
||||
case CDDS_ITEMPREPAINT:
|
||||
result = CDRF_NOTIFYSUBITEMDRAW;
|
||||
break;
|
||||
|
||||
case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
|
||||
{
|
||||
pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED | CDIS_FOCUS);
|
||||
|
||||
uint16 CurrentAddress = static_cast<uint16>(m_DisAsmListViewCtrl.GetItemData((int)pLVCD->nmcd.dwItemSpec));
|
||||
pLVCD->clrTextBk = FindColor(CurrentAddress);
|
||||
|
||||
if (CurrentAddress == g_dsp.pc)
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(96, 192, 128);
|
||||
}
|
||||
|
||||
switch (pLVCD->iSubItem)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
if (IsBreakPoint(CurrentAddress))
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(255, 64, 64);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::RedrawDisAsmListView()
|
||||
{
|
||||
::InvalidateRect(m_DisAsmListViewCtrl.m_hWnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
|
||||
bool CDisAsmDlg::LoadSymbolMap(const char* _pFileName)
|
||||
{
|
||||
m_SymbolMap.clear();
|
||||
|
||||
FILE* pFile = fopen(_pFileName, "r");
|
||||
|
||||
if (!pFile)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
char Name[1024];
|
||||
uint32 AddressStart, AddressEnd;
|
||||
|
||||
while (!feof(pFile))
|
||||
{
|
||||
char line[512];
|
||||
fgets(line, 511, pFile);
|
||||
|
||||
if (strlen(line) < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for comment
|
||||
if (line[0] == '.')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// clear all breakpoints
|
||||
if (line[0] == 'C')
|
||||
{
|
||||
ClearBreakPoints();
|
||||
continue;
|
||||
}
|
||||
|
||||
// add breakpoint
|
||||
if (line[0] == 'B')
|
||||
{
|
||||
sscanf(line, "B %04x", &AddressStart);
|
||||
AddBreakPoint(static_cast<uint16>(AddressStart));
|
||||
continue;
|
||||
}
|
||||
|
||||
// default add new symbol
|
||||
sscanf(line, "%04x %04x %s", &AddressStart, &AddressEnd, Name);
|
||||
|
||||
if (m_SymbolMap.find(AddressStart) == m_SymbolMap.end())
|
||||
{
|
||||
m_SymbolMap.insert(std::pair<uint16, SSymbol>(AddressStart, SSymbol(AddressStart, AddressEnd, Name)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SymbolMap[AddressStart] = SSymbol(AddressStart, AddressEnd, Name);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
DWORD CDisAsmDlg::FindColor(uint16 _Address)
|
||||
{
|
||||
size_t Color = 0;
|
||||
static int Colors[6] = {0xC0FFFF, 0xFFE0C0, 0xC0C0FF, 0xFFC0FF, 0xC0FFC0, 0xFFFFC0};
|
||||
|
||||
for (CSymbolMap::const_iterator itr = m_SymbolMap.begin(); itr != m_SymbolMap.end(); itr++)
|
||||
{
|
||||
const SSymbol& rSymbol = itr->second;
|
||||
|
||||
if ((rSymbol.AddressStart <= _Address) && (_Address <= rSymbol.AddressEnd))
|
||||
{
|
||||
return(Colors[Color % 6]);
|
||||
}
|
||||
|
||||
Color++;
|
||||
}
|
||||
|
||||
return(GetSysColor(COLOR_3DLIGHT));
|
||||
}
|
||||
|
||||
|
||||
void CDisAsmDlg::UpdateDialog()
|
||||
{
|
||||
UpdateSymbolMap();
|
||||
UpdateDisAsmListView();
|
||||
// UpdateButtonTexts();
|
||||
UpdateRegisterFlags();
|
||||
}
|
||||
|
||||
LRESULT CDisAsmDlg::OnLvnItemchangedDisasmList(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/)
|
||||
{
|
||||
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// TODO: make the members adjust with the dialog
|
||||
LRESULT CDisAsmDlg::OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
|
||||
{
|
||||
// we habe to make a group of the items I think
|
||||
/*
|
||||
CRect lpRect;
|
||||
|
||||
|
||||
int wid = lpRect.right - lpRect.left - 100;
|
||||
int hei = lpRect.bottom - lpRect.top - 20;
|
||||
m_DisAsmListViewCtrl.ResizeClient(wid, hei, true);
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../res/resource.h"
|
||||
#include "DisAsmListView.h"
|
||||
#include "RegisterDlg.h"
|
||||
|
||||
class CDisAsmDlg
|
||||
: public CDialogImpl<CDisAsmDlg>, public CUpdateUI<CDisAsmDlg>, public CDialogResize<CDisAsmDlg>
|
||||
{
|
||||
public:
|
||||
|
||||
CDisAsmDlg();
|
||||
|
||||
enum { IDD = IDD_DISASMDLG };
|
||||
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
virtual BOOL OnIdle();
|
||||
|
||||
|
||||
BEGIN_UPDATE_UI_MAP(CDisAsmDlg)
|
||||
END_UPDATE_UI_MAP()
|
||||
|
||||
BEGIN_DLGRESIZE_MAP(CDisAsmDlg)
|
||||
DLGRESIZE_CONTROL(IDR_MAINFRAME, DLSZ_SIZE_X | DLSZ_SIZE_Y)
|
||||
END_DLGRESIZE_MAP()
|
||||
|
||||
BEGIN_MSG_MAP(CDisAsmDlg)
|
||||
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
|
||||
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
||||
COMMAND_ID_HANDLER(ID_STEP, OnStep)
|
||||
COMMAND_ID_HANDLER(ID_GO, OnGo)
|
||||
COMMAND_ID_HANDLER(ID_SHOW_REGISTER, OnShowRegisters)
|
||||
NOTIFY_CODE_HANDLER(NM_CLICK, OnDblClick)
|
||||
NOTIFY_CODE_HANDLER(NM_RETURN, OnDblClick)
|
||||
NOTIFY_CODE_HANDLER(NM_RCLICK, OnRClick)
|
||||
NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw)
|
||||
NOTIFY_HANDLER(IDC_DISASM_LIST, LVN_ITEMCHANGED, OnLvnItemchangedDisasmList)
|
||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||
CHAIN_MSG_MAP(CDialogResize<CDisAsmDlg>)
|
||||
|
||||
END_MSG_MAP()
|
||||
|
||||
// Handler prototypes (uncomment arguments if needed):
|
||||
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
|
||||
|
||||
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
|
||||
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
|
||||
|
||||
LRESULT OnStep(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
|
||||
LRESULT OnGo(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
|
||||
LRESULT OnShowRegisters(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
|
||||
LRESULT OnCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& _bHandled);
|
||||
|
||||
LRESULT OnDblClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
|
||||
LRESULT OnRClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
|
||||
|
||||
void CloseDialog(int nVal);
|
||||
|
||||
bool CanDoStep();
|
||||
|
||||
void DebugBreak();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
enum EColumns
|
||||
{
|
||||
ColumnBP = 0,
|
||||
ColumnFunction = 1,
|
||||
ColumnAddress = 2,
|
||||
ColumnMenmomic = 3,
|
||||
ColumnOpcode = 4,
|
||||
ColumnExt = 5,
|
||||
ColumnParameter = 6
|
||||
};
|
||||
|
||||
enum EState
|
||||
{
|
||||
PAUSE,
|
||||
STEP,
|
||||
RUN,
|
||||
RUN_START // ignores breakpoints and switches after one step to RUN
|
||||
};
|
||||
EState m_State;
|
||||
|
||||
|
||||
CListViewCtrl m_DisAsmListViewCtrl;
|
||||
CRegisterDlg m_RegisterDlg;
|
||||
//CWindow GroupLeft
|
||||
CStatic GroupLeft;
|
||||
|
||||
uint64 m_CachedStepCounter;
|
||||
uint16 m_CachedCR;
|
||||
uint32 m_CachedUCodeCRC;
|
||||
|
||||
typedef std::list<uint16>CBreakPointList;
|
||||
CBreakPointList m_BreakPoints;
|
||||
|
||||
// break point handling
|
||||
bool IsBreakPoint(uint16 _Address);
|
||||
void ToggleBreakPoint(uint16 _Address);
|
||||
void RemoveBreakPoint(uint16 _Address);
|
||||
void AddBreakPoint(uint16 _Address);
|
||||
void ClearBreakPoints();
|
||||
|
||||
|
||||
// update dialog
|
||||
void UpdateDisAsmListView();
|
||||
void UpdateRegisterFlags();
|
||||
void UpdateSymbolMap();
|
||||
void UpdateButtonTexts();
|
||||
|
||||
void RedrawDisAsmListView();
|
||||
void RebuildDisAsmListView();
|
||||
|
||||
|
||||
struct SSymbol
|
||||
{
|
||||
uint32 AddressStart;
|
||||
uint32 AddressEnd;
|
||||
std::string Name;
|
||||
|
||||
SSymbol(uint32 _AddressStart = 0, uint32 _AddressEnd = 0, char* _Name = NULL)
|
||||
: AddressStart(_AddressStart)
|
||||
, AddressEnd(_AddressEnd)
|
||||
, Name(_Name)
|
||||
{}
|
||||
};
|
||||
typedef std::map<uint16, SSymbol>CSymbolMap;
|
||||
CSymbolMap m_SymbolMap;
|
||||
|
||||
void AddSymbol(uint16 _AddressStart, uint16 _AddressEnd, char* _Name);
|
||||
bool LoadSymbolMap(const char* _pFileName);
|
||||
DWORD FindColor(uint16 _Address);
|
||||
void UpdateDialog();
|
||||
|
||||
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
||||
public:
|
||||
LRESULT OnLvnItemchangedDisasmList(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);
|
||||
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
|
||||
};
|
|
@ -0,0 +1,274 @@
|
|||
// RegSettings.cpp
|
||||
//
|
||||
// Copyright (c) 2001 Magomed Abdurakhmanov
|
||||
// maq@hotbox.ru, http://mickels.iwt.ru/en
|
||||
//
|
||||
//
|
||||
//
|
||||
// No warranties are given. Use at your own risk.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "RegSettings.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CWindowSettings
|
||||
|
||||
#define S_WINDOW_PLACEMENT_VAL _T("WindowPlacement")
|
||||
|
||||
CWindowSettings::CWindowSettings()
|
||||
{
|
||||
m_WindowPlacement.length = sizeof(m_WindowPlacement);
|
||||
m_WindowPlacement.flags = 0;
|
||||
m_WindowPlacement.ptMinPosition.x = 0;
|
||||
m_WindowPlacement.ptMinPosition.y = 0;
|
||||
m_WindowPlacement.ptMaxPosition.x = 0;
|
||||
m_WindowPlacement.ptMaxPosition.y = 0;
|
||||
|
||||
CRect rc;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, rc, 0);
|
||||
rc.DeflateRect(100, 100);
|
||||
m_WindowPlacement.rcNormalPosition = rc;
|
||||
m_WindowPlacement.showCmd = SW_SHOWNORMAL;
|
||||
}
|
||||
|
||||
|
||||
bool CWindowSettings::Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* = HKEY_CURRENT_USER*/)
|
||||
{
|
||||
CRegKey reg;
|
||||
DWORD err = reg.Open(hkRootKey, szRegKey, KEY_READ);
|
||||
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwType = NULL;
|
||||
DWORD dwSize = sizeof(m_WindowPlacement);
|
||||
err = RegQueryValueEx(reg.m_hKey, CString(szPrefix) + S_WINDOW_PLACEMENT_VAL, NULL, &dwType,
|
||||
(LPBYTE)&m_WindowPlacement, &dwSize);
|
||||
}
|
||||
|
||||
return(err == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
bool CWindowSettings::Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* = HKEY_CURRENT_USER*/) const
|
||||
{
|
||||
CRegKey reg;
|
||||
DWORD err = reg.Create(hkRootKey, szRegKey);
|
||||
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
err = RegSetValueEx(reg.m_hKey, CString(szPrefix) + S_WINDOW_PLACEMENT_VAL, NULL, REG_BINARY,
|
||||
(LPBYTE)&m_WindowPlacement, sizeof(m_WindowPlacement));
|
||||
}
|
||||
|
||||
return(err == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
void CWindowSettings::GetFrom(CWindow& Wnd)
|
||||
{
|
||||
ATLASSERT(Wnd.IsWindow());
|
||||
Wnd.GetWindowPlacement(&m_WindowPlacement);
|
||||
}
|
||||
|
||||
|
||||
void CWindowSettings::ApplyTo(CWindow& Wnd, int nCmdShow /* = SW_SHOWNORMAL*/) const
|
||||
{
|
||||
ATLASSERT(Wnd.IsWindow());
|
||||
|
||||
Wnd.SetWindowPlacement(&m_WindowPlacement);
|
||||
|
||||
if (SW_SHOWNORMAL != nCmdShow)
|
||||
{
|
||||
Wnd.ShowWindow(nCmdShow);
|
||||
}
|
||||
else
|
||||
if (m_WindowPlacement.showCmd == SW_MINIMIZE || m_WindowPlacement.showCmd == SW_SHOWMINIMIZED)
|
||||
{
|
||||
Wnd.ShowWindow(SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CReBarSettings
|
||||
|
||||
#define S_BAR_BANDCOUNT _T("BandCount")
|
||||
#define S_BAR_ID_VAL _T("ID")
|
||||
#define S_BAR_CX_VAL _T("CX")
|
||||
#define S_BAR_BREAKLINE_VAL _T("BreakLine")
|
||||
|
||||
CReBarSettings::CReBarSettings()
|
||||
{
|
||||
m_pBands = NULL;
|
||||
m_cbBandCount = 0;
|
||||
}
|
||||
|
||||
|
||||
CReBarSettings::~CReBarSettings()
|
||||
{
|
||||
if (m_pBands != NULL)
|
||||
{
|
||||
delete[] m_pBands;
|
||||
m_pBands = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CReBarSettings::Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* = HKEY_CURRENT_USER*/)
|
||||
{
|
||||
if (m_pBands != NULL)
|
||||
{
|
||||
delete[] m_pBands;
|
||||
m_pBands = NULL;
|
||||
}
|
||||
|
||||
m_pBands = NULL;
|
||||
m_cbBandCount = 0;
|
||||
|
||||
CRegKey reg;
|
||||
DWORD err = reg.Open(hkRootKey, szRegKey, KEY_READ);
|
||||
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
reg.QueryDWORDValue(CString(szPrefix) + S_BAR_BANDCOUNT, m_cbBandCount);
|
||||
|
||||
if (m_cbBandCount > 0)
|
||||
{
|
||||
m_pBands = new BandInfo[m_cbBandCount];
|
||||
}
|
||||
|
||||
for (DWORD i = 0; i < m_cbBandCount; i++)
|
||||
{
|
||||
CString s;
|
||||
s.Format(_T("%s%i_"), szPrefix, i);
|
||||
reg.QueryDWORDValue(s + S_BAR_ID_VAL, m_pBands[i].ID);
|
||||
reg.QueryDWORDValue(s + S_BAR_CX_VAL, m_pBands[i].cx);
|
||||
|
||||
DWORD dw;
|
||||
reg.QueryDWORDValue(s + S_BAR_BREAKLINE_VAL, dw);
|
||||
m_pBands[i].BreakLine = dw != 0;
|
||||
}
|
||||
}
|
||||
|
||||
return(err == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
bool CReBarSettings::Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* = HKEY_CURRENT_USER*/) const
|
||||
{
|
||||
CRegKey reg;
|
||||
DWORD err = reg.Create(hkRootKey, szRegKey);
|
||||
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
reg.SetDWORDValue(CString(szPrefix) + S_BAR_BANDCOUNT, m_cbBandCount);
|
||||
|
||||
for (DWORD i = 0; i < m_cbBandCount; i++)
|
||||
{
|
||||
CString s;
|
||||
s.Format(_T("%s%i_"), szPrefix, i);
|
||||
reg.SetDWORDValue(s + S_BAR_ID_VAL, m_pBands[i].ID);
|
||||
reg.SetDWORDValue(s + S_BAR_CX_VAL, m_pBands[i].cx);
|
||||
|
||||
DWORD dw = m_pBands[i].BreakLine;
|
||||
reg.SetDWORDValue(s + S_BAR_BREAKLINE_VAL, dw);
|
||||
}
|
||||
}
|
||||
|
||||
return(err == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
void CReBarSettings::GetFrom(CReBarCtrl& ReBar)
|
||||
{
|
||||
ATLASSERT(ReBar.IsWindow());
|
||||
|
||||
if (m_pBands != NULL)
|
||||
{
|
||||
delete[] m_pBands;
|
||||
}
|
||||
|
||||
m_pBands = NULL;
|
||||
m_cbBandCount = ReBar.GetBandCount();
|
||||
|
||||
if (m_cbBandCount > 0)
|
||||
{
|
||||
m_pBands = new BandInfo[m_cbBandCount];
|
||||
}
|
||||
|
||||
for (UINT i = 0; i < m_cbBandCount; i++)
|
||||
{
|
||||
REBARBANDINFO rbi;
|
||||
rbi.cbSize = sizeof(rbi);
|
||||
rbi.fMask = RBBIM_ID | RBBIM_SIZE | RBBIM_STYLE;
|
||||
ReBar.GetBandInfo(i, &rbi);
|
||||
m_pBands[i].ID = rbi.wID;
|
||||
m_pBands[i].cx = rbi.cx;
|
||||
m_pBands[i].BreakLine = (rbi.fStyle & RBBS_BREAK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CReBarSettings::ApplyTo(CReBarCtrl& ReBar) const
|
||||
{
|
||||
ATLASSERT(ReBar.IsWindow());
|
||||
|
||||
for (UINT i = 0; i < m_cbBandCount; i++)
|
||||
{
|
||||
ReBar.MoveBand(ReBar.IdToIndex(m_pBands[i].ID), i);
|
||||
REBARBANDINFO rbi;
|
||||
rbi.cbSize = sizeof(rbi);
|
||||
rbi.fMask = RBBIM_ID | RBBIM_SIZE | RBBIM_STYLE;
|
||||
ReBar.GetBandInfo(i, &rbi);
|
||||
|
||||
rbi.cx = m_pBands[i].cx;
|
||||
|
||||
if (m_pBands[i].BreakLine)
|
||||
{
|
||||
rbi.fStyle |= RBBS_BREAK;
|
||||
}
|
||||
else
|
||||
{
|
||||
rbi.fStyle &= (~RBBS_BREAK);
|
||||
}
|
||||
|
||||
ReBar.SetBandInfo(i, &rbi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CSplitterSettings
|
||||
|
||||
#define S_SPLITTER_POS _T("SplitterPos")
|
||||
|
||||
bool CSplitterSettings::Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* = HKEY_CURRENT_USER*/)
|
||||
{
|
||||
CRegKey reg;
|
||||
DWORD err = reg.Open(hkRootKey, szRegKey, KEY_READ);
|
||||
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
reg.QueryDWORDValue(CString(szPrefix) + S_SPLITTER_POS, m_dwPos);
|
||||
}
|
||||
|
||||
return(err == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
bool CSplitterSettings::Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* = HKEY_CURRENT_USER*/) const
|
||||
{
|
||||
CRegKey reg;
|
||||
DWORD err = reg.Create(hkRootKey, szRegKey);
|
||||
|
||||
if (err == ERROR_SUCCESS)
|
||||
{
|
||||
reg.SetDWORDValue(CString(szPrefix) + S_SPLITTER_POS, m_dwPos);
|
||||
}
|
||||
|
||||
return(err == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
// RegSettings.h
|
||||
//
|
||||
// Copyright (c) 2001 Magomed Abdurakhmanov
|
||||
// maq@hotbox.ru, http://mickels.iwt.ru/en
|
||||
//
|
||||
//
|
||||
//
|
||||
// No warranties are given. Use at your own risk.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined (AFX_REGSETTINGS_H__91E69C67_8104_4819_969A_B5E71A9993D5__INCLUDED_)
|
||||
#define AFX_REGSETTINGS_H__91E69C67_8104_4819_969A_B5E71A9993D5__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <AtlMisc.h>
|
||||
#include <AtlCtrls.h>
|
||||
|
||||
class CWindowSettings
|
||||
{
|
||||
public:
|
||||
|
||||
WINDOWPLACEMENT m_WindowPlacement;
|
||||
|
||||
CWindowSettings();
|
||||
void GetFrom(CWindow& Wnd);
|
||||
void ApplyTo(CWindow& Wnd, int nCmdShow = SW_SHOWNORMAL) const;
|
||||
|
||||
bool Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER);
|
||||
bool Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER) const;
|
||||
};
|
||||
|
||||
class CReBarSettings
|
||||
{
|
||||
public:
|
||||
|
||||
struct BandInfo
|
||||
{
|
||||
DWORD ID;
|
||||
DWORD cx;
|
||||
bool BreakLine;
|
||||
}* m_pBands;
|
||||
|
||||
DWORD m_cbBandCount;
|
||||
|
||||
CReBarSettings();
|
||||
~CReBarSettings();
|
||||
|
||||
void GetFrom(CReBarCtrl& ReBar);
|
||||
void ApplyTo(CReBarCtrl& ReBar) const;
|
||||
|
||||
bool Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER);
|
||||
bool Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER) const;
|
||||
};
|
||||
|
||||
class CSplitterSettings
|
||||
{
|
||||
public:
|
||||
|
||||
DWORD m_dwPos;
|
||||
|
||||
template<class T>void GetFrom(const T& Splitter)
|
||||
{
|
||||
m_dwPos = Splitter.GetSplitterPos();
|
||||
}
|
||||
|
||||
|
||||
template<class T>void ApplyTo(T& Splitter) const
|
||||
{
|
||||
Splitter.SetSplitterPos(m_dwPos);
|
||||
}
|
||||
|
||||
|
||||
bool Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER);
|
||||
bool Save(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey = HKEY_CURRENT_USER) const;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_REGSETTINGS_H__91E69C67_8104_4819_969A_B5E71A9993D5__INCLUDED_)
|
|
@ -0,0 +1,207 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "../res/resource.h"
|
||||
#include "RegisterDlg.h"
|
||||
|
||||
#include "disassemble.h"
|
||||
#include "gdsp_interpreter.h"
|
||||
#include "RegSettings.h"
|
||||
|
||||
CRegisterDlg::CRegisterDlg()
|
||||
: m_CachedCounter(-1)
|
||||
{}
|
||||
|
||||
|
||||
BOOL CRegisterDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
return(IsDialogMessage(pMsg));
|
||||
}
|
||||
|
||||
|
||||
BOOL CRegisterDlg::OnIdle()
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CRegisterDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CWindowSettings ws;
|
||||
|
||||
if (ws.Load("Software\\Dolphin\\DSP", "Register"))
|
||||
{
|
||||
ws.ApplyTo(CWindow(m_hWnd), SW_SHOW);
|
||||
}
|
||||
|
||||
m_RegisterListViewCtrl.m_hWnd = GetDlgItem(IDC_DISASM_LIST);
|
||||
|
||||
UIAddChildWindowContainer(m_hWnd);
|
||||
|
||||
m_RegisterListViewCtrl.AddColumn(_T("General"), 0);
|
||||
m_RegisterListViewCtrl.AddColumn(_T(" "), 1);
|
||||
m_RegisterListViewCtrl.AddColumn(_T("Special"), 2);
|
||||
m_RegisterListViewCtrl.AddColumn(_T("0"), 3);
|
||||
|
||||
m_RegisterListViewCtrl.SetColumnWidth(0, 50);
|
||||
m_RegisterListViewCtrl.SetColumnWidth(1, 100);
|
||||
m_RegisterListViewCtrl.SetColumnWidth(2, 60);
|
||||
m_RegisterListViewCtrl.SetColumnWidth(3, 100);
|
||||
|
||||
m_RegisterListViewCtrl.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
||||
m_RegisterListViewCtrl.SetTextBkColor(GetSysColor(COLOR_3DLIGHT));
|
||||
|
||||
|
||||
for (uint16 i = 0; i < 16; i++)
|
||||
{
|
||||
// 0-15
|
||||
int Item = m_RegisterListViewCtrl.AddItem(0, 0, gd_dis_get_reg_name(i));
|
||||
|
||||
// 16-31
|
||||
m_RegisterListViewCtrl.AddItem(Item, 2, gd_dis_get_reg_name(16 + i));
|
||||
|
||||
// just for easy sort
|
||||
m_RegisterListViewCtrl.SetItemData(Item, i);
|
||||
}
|
||||
|
||||
m_RegisterListViewCtrl.SortItems(CompareFunc, (LPARAM) this);
|
||||
|
||||
UpdateRegisterListView();
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CRegisterDlg::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
CWindowSettings ws;
|
||||
ws.GetFrom(CWindow(m_hWnd));
|
||||
ws.Save("Software\\Dolphin\\DSP", "Register");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void CRegisterDlg::UpdateRegisterListView()
|
||||
{
|
||||
if (m_CachedCounter == g_dsp.step_counter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_CachedCounter = g_dsp.step_counter;
|
||||
|
||||
char Temp[256];
|
||||
|
||||
for (uint16 i = 0; i < 16; i++)
|
||||
{
|
||||
// 0-15
|
||||
if (m_CachedRegs[i] != g_dsp.r[i])
|
||||
{
|
||||
m_CachedRegHasChanged[i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CachedRegHasChanged[i] = false;
|
||||
}
|
||||
|
||||
m_CachedRegs[i] = g_dsp.r[i];
|
||||
|
||||
sprintf_s(Temp, 256, "0x%04x", g_dsp.r[i]);
|
||||
m_RegisterListViewCtrl.SetItemText(i, 1, Temp);
|
||||
|
||||
// 16-31
|
||||
if (m_CachedRegs[16 + i] != g_dsp.r[16 + i])
|
||||
{
|
||||
m_CachedRegHasChanged[16 + i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CachedRegHasChanged[16 + i] = false;
|
||||
}
|
||||
|
||||
m_CachedRegs[16 + i] = g_dsp.r[16 + i];
|
||||
|
||||
sprintf_s(Temp, 256, "0x%04x", g_dsp.r[16 + i]);
|
||||
m_RegisterListViewCtrl.SetItemText(i, 3, Temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CALLBACK CRegisterDlg::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
||||
{
|
||||
return(lParam1 > lParam2);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CRegisterDlg::OnCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& _bHandled)
|
||||
{
|
||||
int result = CDRF_DODEFAULT;
|
||||
|
||||
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pnmh);
|
||||
|
||||
switch (pLVCD->nmcd.dwDrawStage)
|
||||
{
|
||||
case CDDS_PREPAINT:
|
||||
result = CDRF_NOTIFYITEMDRAW;
|
||||
break;
|
||||
|
||||
case CDDS_ITEMPREPAINT:
|
||||
result = CDRF_NOTIFYSUBITEMDRAW;
|
||||
break;
|
||||
|
||||
case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
|
||||
{
|
||||
pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED | CDIS_FOCUS);
|
||||
|
||||
int Offset = static_cast<int>(m_RegisterListViewCtrl.GetItemData((int)pLVCD->nmcd.dwItemSpec));
|
||||
|
||||
size_t Register = -1;
|
||||
|
||||
if (pLVCD->iSubItem == 1)
|
||||
{
|
||||
Register = Offset;
|
||||
}
|
||||
else if (pLVCD->iSubItem == 3)
|
||||
{
|
||||
Register = Offset + 16;
|
||||
}
|
||||
|
||||
if (Register != -1)
|
||||
{
|
||||
if (m_CachedRegHasChanged[Register])
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(0xFF, 192, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(0xF0, 0xF0, 0xF0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(192, 224, 192);
|
||||
}
|
||||
|
||||
|
||||
// uint16 CurrentAddress = static_cast<uint16>(m_DisAsmListViewCtrl.GetItemData((int)pLVCD->nmcd.dwItemSpec));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
#include <map>
|
||||
#include "DisAsmListView.h"
|
||||
|
||||
class CRegisterDlg
|
||||
: public CDialogImpl<CRegisterDlg>, public CUpdateUI<CRegisterDlg>
|
||||
{
|
||||
public:
|
||||
|
||||
CRegisterDlg();
|
||||
|
||||
enum { IDD = IDD_REGISTERDLG };
|
||||
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
virtual BOOL OnIdle();
|
||||
|
||||
|
||||
BEGIN_UPDATE_UI_MAP(CRegisterDlg)
|
||||
END_UPDATE_UI_MAP()
|
||||
|
||||
BEGIN_MSG_MAP(CRegisterDlg)
|
||||
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
|
||||
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
||||
NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw)
|
||||
|
||||
// COMMAND_ID_HANDLER(ID_STEP, OnStep)
|
||||
// COMMAND_ID_HANDLER(ID_GO, OnGo)
|
||||
// COMMAND_ID_HANDLER(ID_SHOW_REGISTER, OnShowRegisters)
|
||||
END_MSG_MAP()
|
||||
|
||||
// Handler prototypes (uncomment arguments if needed):
|
||||
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
|
||||
|
||||
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
|
||||
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
|
||||
LRESULT OnCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& _bHandled);
|
||||
|
||||
|
||||
// LRESULT OnStep(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
|
||||
// LRESULT OnGo(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
|
||||
// LRESULT OnShowRegisters(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
|
||||
|
||||
void CloseDialog(int nVal);
|
||||
|
||||
void UpdateRegisterListView();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CListViewCtrl m_RegisterListViewCtrl;
|
||||
|
||||
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
||||
|
||||
|
||||
uint64 m_CachedCounter;
|
||||
uint16 m_CachedRegs[32];
|
||||
bool m_CachedRegHasChanged[32];
|
||||
};
|
|
@ -26,6 +26,8 @@
|
|||
#include "disassemble.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "DisAsmDlg.h"
|
||||
#include "DSoundStream.h"
|
||||
#include "Logging/Console.h" // For wprintf, ClearScreen
|
||||
#include "Logging/Logging.h" // For Logging
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// WTL
|
||||
#include <atlbase.h>
|
||||
#include <atlapp.h>
|
||||
|
||||
#include <atlwin.h>
|
||||
#include <atlframe.h>
|
||||
#include <atlctrls.h>
|
||||
#include <atldlgs.h>
|
||||
|
||||
#include "PluginSpecs_DSP.h"
|
||||
|
Loading…
Reference in New Issue