From 22135b76963920dd813254bc126a526e88a078d2 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Mon, 2 Feb 2009 21:40:08 +0000 Subject: [PATCH] Added shuffle2's (unused for now) GBA Serial Interface device code. This calls for implementing a pad type chooser window, anyone in? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2071 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Core.vcproj | 8 ++ .../Core/Src/HW/SI_DeviceGBAController.cpp | 99 +++++++++++++++++++ .../Core/Core/Src/HW/SI_DeviceGBAController.h | 62 ++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 Source/Core/Core/Src/HW/SI_DeviceGBAController.cpp create mode 100644 Source/Core/Core/Src/HW/SI_DeviceGBAController.h diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 886e9e6c90..747e333b0f 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -626,6 +626,14 @@ RelativePath=".\Src\HW\SI_Device.h" > + + + + diff --git a/Source/Core/Core/Src/HW/SI_DeviceGBAController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGBAController.cpp new file mode 100644 index 0000000000..b3710497c6 --- /dev/null +++ b/Source/Core/Core/Src/HW/SI_DeviceGBAController.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2003-2009 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 "SI_Device.h" +#include "SI_DeviceGBAController.h" +#include "../PluginManager.h" + +#include "EXI_Device.h" + +CSIDevice_GBA::CSIDevice_GBA(int _iDeviceNumber) : + ISIDevice(_iDeviceNumber) +{ +} + +int CSIDevice_GBA::RunBuffer(u8* _pBuffer, int _iLength) +{ + // for debug logging only + ISIDevice::RunBuffer(_pBuffer, _iLength); + + int iPosition = 0; + while(iPosition < _iLength) + { + // read the command + EBufferCommands command = static_cast(_pBuffer[iPosition ^ 3]); + iPosition++; + + // handle it + switch(command) + { + case CMD_RESET: + { + *(u32*)&_pBuffer[0] = SI_GBA; + iPosition = _iLength; // break the while loop + LOG(SERIALINTERFACE, "SI-GBA CMD_RESET"); + } + break; + case CMD_STATUS: //Same behavior as CMD_RESET: send 0x0004, then lower 8 bits of SIOSTAT + { + *(u32*)&_pBuffer[0] = SI_GBA; + iPosition = _iLength; // break the while loop + LOG(SERIALINTERFACE, "SI-GBA CMD_STATUS"); + } + break; + case CMD_WRITE: + { + LOG(SERIALINTERFACE, "SI-GBA CMD_WRITE"); + } + break; + case CMD_READ: + { + LOG(SERIALINTERFACE, "SI-GBA CMD_READ"); + } + break; + default: + { + LOG(SERIALINTERFACE, "unknown SI-GBA command (0x%x)", command); + //PanicAlert("SI: Unknown command"); + iPosition = _iLength; + } + break; + } + } + + return iPosition; +} + +// __________________________________________________________________________________________________ +// GetData +// +bool +CSIDevice_GBA::GetData(u32& _Hi, u32& _Low) +{ + LOG(SERIALINTERFACE, "SI-GBA GetData Hi: (0x%x) Low: (0x%x)", _Hi, _Low); + + return true; +} + +// __________________________________________________________________________________________________ +// SendCommand +// +void +CSIDevice_GBA::SendCommand(u32 _Cmd) +{ + LOG(SERIALINTERFACE, "SI-GBA SendCommand: (0x%x)", _Cmd); +} diff --git a/Source/Core/Core/Src/HW/SI_DeviceGBAController.h b/Source/Core/Core/Src/HW/SI_DeviceGBAController.h new file mode 100644 index 0000000000..e41b630631 --- /dev/null +++ b/Source/Core/Core/Src/HW/SI_DeviceGBAController.h @@ -0,0 +1,62 @@ +// Copyright (C) 2003-2009 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/ + +// ===================================================================================================== +// GameBoy Advance +// ===================================================================================================== + +class CSIDevice_GBA : public ISIDevice +{ +private: + + // commands + enum EBufferCommands + { + CMD_RESET = 0xFF, + CMD_STATUS = 0x00, + CMD_WRITE = 0x15, + CMD_READ = 0x14 + }; + + //0x4000158 - JOYSTAT - Receive Status Register (R/W) (ON THE GBA) + //Bit Explanation + //0 Not used + //1 Receive Status Flag (0=Remote GBA is/was receiving) (Read Only?) + //2 Not used + //3 Send Status Flag (1=Remote GBA is/was sending) (Read Only?) + //4-5 General Purpose Flag (Not assigned, may be used for whatever purpose) + //6-15 Not used + //-------------------------------------- + //Bit 1 is automatically set when writing to local JOY_TRANS. + //Bit 3 is automatically reset when reading from local JOY_RECV. + + int DeviceNum; + +public: + + // constructor + CSIDevice_GBA(int _iDeviceNumber); + + // run the SI Buffer + virtual int RunBuffer(u8* _pBuffer, int _iLength); + + // return true on new data + virtual bool GetData(u32& _Hi, u32& _Low); + + // send a command directly + virtual void SendCommand(u32 _Cmd); +};