From 2726a2acb973c8daf6f382f7039a8c32b83ed018 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Mon, 2 Mar 2009 05:55:39 +0000 Subject: [PATCH] just some more comments for SI :) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2515 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/SI.cpp | 28 +++++++++++-------- Source/Core/Core/Src/HW/SI_Device.cpp | 1 + .../Core/Src/HW/SI_DeviceGCController.cpp | 16 +++++++---- .../Core/Core/Src/HW/SI_DeviceGCController.h | 12 ++++---- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 8523c9751c..621f5b8446 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -90,8 +90,8 @@ union USIChannelIn_Hi unsigned INPUT2 : 8; unsigned INPUT1 : 8; unsigned INPUT0 : 6; - unsigned ERRLATCH : 1; // 0: no error 1: Error latched. Check SISR. - unsigned ERRSTAT : 1; // 0: no error 1: error on last transfer + unsigned ERRLATCH : 1; // 0: no error 1: Error latched. Check SISR. + unsigned ERRSTAT : 1; // 0: no error 1: error on last transfer }; }; @@ -123,16 +123,16 @@ union USIPoll u32 Hex; struct { - unsigned VBCPY3 : 1; + unsigned VBCPY3 : 1; // 1: write to output buffer only on vblank unsigned VBCPY2 : 1; unsigned VBCPY1 : 1; unsigned VBCPY0 : 1; - unsigned EN3 : 1; - unsigned EN2 : 1; + unsigned EN3 : 1; // Enable polling of channel + unsigned EN2 : 1; // does not affect communication RAM transfers unsigned EN1 : 1; unsigned EN0 : 1; - unsigned Y : 10; - unsigned X : 10; + unsigned Y : 10; // Polls per frame + unsigned X : 10; // Polls per X lines. begins at vsync, min 7, max depends on video mode unsigned : 6; }; }; @@ -143,13 +143,17 @@ union USIComCSR u32 Hex; struct { - unsigned TSTART : 1; - unsigned CHANNEL : 2; // determines which SI channel will be used the communication interface. - unsigned : 5; + unsigned TSTART : 1; // write: start transfer read: transfer status + unsigned CHANNEL : 2; // determines which SI channel will be used on the communication interface. + unsigned : 3; + unsigned CALLBEN : 1; // Callback enable + unsigned CMDEN : 1; // Command enable? unsigned INLNGTH : 7; unsigned : 1; unsigned OUTLNGTH : 7; // Communication Channel Output Length in bytes - unsigned : 4; + unsigned : 1; + unsigned CHANEN : 1; // Channel enable? + unsigned CHANNUM : 2; // Channel number? unsigned RDSTINTMSK : 1; // Read Status Interrupt Status Mask unsigned RDSTINT : 1; // Read Status Interrupt Status unsigned COMERR : 1; // Communication Error (set 0) @@ -206,7 +210,7 @@ union USIEXIClockCount u32 Hex; struct { - unsigned LOCK : 1; + unsigned LOCK : 1; // 1: prevents CPU from setting EXI clock to 32MHz unsigned : 30; }; }; diff --git a/Source/Core/Core/Src/HW/SI_Device.cpp b/Source/Core/Core/Src/HW/SI_Device.cpp index 8f7b4bc28b..22b69961f0 100644 --- a/Source/Core/Core/Src/HW/SI_Device.cpp +++ b/Source/Core/Core/Src/HW/SI_Device.cpp @@ -52,6 +52,7 @@ int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength) ////////////////////////////////////////////////////////////////////////// // Just a dummy that logs reads and writes // to be used for SI devices we haven't emulated +// and hopefully as an "emtpy" device class CSIDevice_Dummy : public ISIDevice { public: diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index 32173c0dac..b58e8bbda9 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -34,12 +34,16 @@ CSIDevice_GCController::CSIDevice_GCController(int _iDeviceNumber) : { memset(&m_origin, 0, sizeof(SOrigin)); - m_origin.uCommand = 0x41; - m_origin.uOriginStickX = 0x80; + // Resetting to origin is a function of the controller itself + // press X+Y+Start for three seconds to trigger a reset + // probably this is meant to read current pad status and use it as + // the origin, but we just use these: + m_origin.uCommand = CMD_ORIGIN; + m_origin.uOriginStickX = 0x80; // center m_origin.uOriginStickY = 0x80; m_origin.uSubStickStickX = 0x80; m_origin.uSubStickStickY = 0x80; - m_origin.uTrigger_L = 0x1F; + m_origin.uTrigger_L = 0x1F; // 0-30 is the lower deadzone m_origin.uTrigger_R = 0x1F; } @@ -60,7 +64,7 @@ int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength) { case CMD_RESET: { - *(u32*)&_pBuffer[0] = SI_GC_CONTROLLER; // | SI_GC_NOMOTOR; + *(u32*)&_pBuffer[0] = SI_GC_CONTROLLER; iPosition = _iLength; // Break the while loop } break; @@ -94,7 +98,7 @@ int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength) case 0xCE: WARN_LOG(SERIALINTERFACE, "Unknown Wii SI Command"); break; - + // DEFAULT default: { @@ -126,7 +130,7 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) _Hi = (u32)((u8)PadStatus.stickY); _Hi |= (u32)((u8)PadStatus.stickX << 8); - _Hi |= (u32)((u16)PadStatus.button << 16); // Dunno were/if we should set any of the top 3bits... + _Hi |= (u32)((u16)PadStatus.button << 16); _Hi |= 0x00800000; // F|RES: means that the pad must be "combined" with the origin to math the "final" OSPad-Struct //_Hi |= 0x20000000; // ? diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.h b/Source/Core/Core/Src/HW/SI_DeviceGCController.h index 39b66c3664..7f015fb476 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.h +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.h @@ -37,14 +37,14 @@ private: struct SOrigin { - u8 uCommand; - u8 unk_1; + u8 uCommand;// Maybe should be button bits? + u8 unk_1; // ..and this would be the other half u8 uOriginStickX; u8 uOriginStickY; - u8 uSubStickStickX; // ??? - u8 uSubStickStickY; // ??? - u8 uTrigger_L; // ??? - u8 uTrigger_R; // ??? + u8 uSubStickStickX; + u8 uSubStickStickY; + u8 uTrigger_L; + u8 uTrigger_R; u8 unk_4; u8 unk_5; u8 unk_6;