Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
experimental GBA stuff for XK :)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2578 8ced0084-cf51-0410-be5f-012b33b47a6e
- Loading branch information
Showing
6 changed files
with
343 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| // 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/ | ||
| #ifdef _WIN32 | ||
| #include <windows.h> | ||
| #endif | ||
|
|
||
| #include "Common.h" | ||
| #include "../Core.h" | ||
|
|
||
| #include "GBAPipe.h" | ||
| #include "../PowerPC/PowerPC.h" | ||
| #include "CommandProcessor.h" | ||
|
|
||
|
|
||
| #include "../Host.h" | ||
|
|
||
| #ifdef _WIN32 | ||
|
|
||
| namespace GBAPipe | ||
| { | ||
|
|
||
| HANDLE m_hPipe; | ||
| bool m_bIsServer; | ||
| bool m_bEnabled; | ||
| u32 m_BlockStart; | ||
|
|
||
| #define PIPENAME "\\\\.\\pipe\\gbapipe" | ||
|
|
||
|
|
||
| void SetBlockStart(u32 addr) | ||
| { | ||
| m_BlockStart = addr; | ||
| } | ||
|
|
||
| void StartServer() | ||
| { | ||
| if (m_bEnabled) | ||
| return; | ||
|
|
||
| //TODO: error checking | ||
| m_hPipe = CreateNamedPipe( | ||
| PIPENAME, | ||
| PIPE_ACCESS_DUPLEX, // client and server can both r+w | ||
| PIPE_WAIT |/* PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,*/ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, | ||
| 1, //maxinst | ||
| 0x1000, //outbufsize | ||
| 0x1000, //inbufsize | ||
| INFINITE, //timeout | ||
| 0); | ||
|
|
||
| if (m_hPipe == INVALID_HANDLE_VALUE) | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "Failed to create pipe."); | ||
| } | ||
| else | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "Pipe %s created.", PIPENAME); | ||
| } | ||
|
|
||
| m_bIsServer = true; | ||
| m_bEnabled = true; | ||
| } | ||
|
|
||
| void ConnectAsClient() | ||
| { | ||
| if (m_bEnabled) | ||
| return; | ||
|
|
||
| //TODO: error checking | ||
| m_hPipe = CreateFile( | ||
| PIPENAME, | ||
| GENERIC_READ|GENERIC_WRITE, | ||
| 0, //share | ||
| NULL, | ||
| OPEN_EXISTING, | ||
| 0, | ||
| NULL); | ||
|
|
||
| if (m_hPipe == INVALID_HANDLE_VALUE) | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "Failed to connect to pipe. %08x (2 = file not found)", GetLastError()); | ||
| } | ||
|
|
||
| m_bEnabled = true; | ||
| m_bIsServer = false; | ||
| } | ||
|
|
||
| void Stop() | ||
| { | ||
| if (m_bEnabled) | ||
| { | ||
| if (m_bIsServer) | ||
| DisconnectNamedPipe(m_hPipe); | ||
|
|
||
| CloseHandle(m_hPipe); | ||
| m_bEnabled = false; | ||
| } | ||
| } | ||
|
|
||
| void Read(u8& data) | ||
| { | ||
| if (!m_bEnabled) | ||
| return; | ||
|
|
||
| u32 read; | ||
| memset(&data, 0x00, sizeof(data)); // pad with zeros for now | ||
| HRESULT result = ReadFile(m_hPipe, &data, sizeof(data), (LPDWORD)&read, FALSE); | ||
| if (FAILED(result)/* || read != sizeof(data)*/) | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "Failed to read pipe %s", PIPENAME); | ||
| Stop(); | ||
| } | ||
| else | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "read %x bytes: 0x%02x", read, data); | ||
| } | ||
| } | ||
|
|
||
| void Write(u8 data) | ||
| { | ||
| if (!m_bEnabled) | ||
| return; | ||
|
|
||
| u32 written; | ||
| HRESULT result = WriteFile(m_hPipe, &data, sizeof(data), (LPDWORD)&written,FALSE); | ||
| if (FAILED(result)) | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "Failed to write to pipe %s", PIPENAME); | ||
| Stop(); | ||
| } | ||
| else | ||
| { | ||
| INFO_LOG(SERIALINTERFACE, "Wrote %x bytes: 0x%02x", written, data); | ||
| } | ||
| } | ||
|
|
||
| bool IsEnabled() | ||
| { | ||
| return m_bEnabled; | ||
| } | ||
|
|
||
| bool IsServer() | ||
| { | ||
| return m_bIsServer; | ||
| } | ||
|
|
||
|
|
||
| } | ||
| #else | ||
|
|
||
| namespace GBAPipe | ||
| { | ||
| void StartServer() { } | ||
| void ConnectAsClient() { } | ||
| void Stop() { } | ||
| void Read(u32& data){} | ||
| void Write(u32 data){} | ||
| bool IsEnabled() { return false; } | ||
| bool IsServer() { return false; } | ||
| } | ||
| // #error Provide a GBAPipe implementation or dummy it out, please | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // 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/ | ||
| // Sets up and maintains interprocess communication to make it possible | ||
| // to easily compare any two cpu cores by running two instances of DolphinHLE and | ||
| // comparing them to each other. | ||
| // | ||
|
|
||
| #ifndef _CPUCOMPARE_H | ||
| #define _CPUCOMPARE_H | ||
|
|
||
| #include "Common.h" | ||
|
|
||
| namespace GBAPipe | ||
| { | ||
| // start the server | ||
| void StartServer(); | ||
|
|
||
| // connect as client | ||
| void ConnectAsClient(); | ||
|
|
||
| // stop | ||
| void Stop(); | ||
|
|
||
| // Transfer funcs | ||
| void Read(u8& data); | ||
| void Write(u8 data); | ||
|
|
||
| // IsEnabled | ||
| bool IsEnabled(); | ||
|
|
||
| // IsServer | ||
| bool IsServer(); | ||
|
|
||
| void SetBlockStart(u32 addr); | ||
| } | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.