diff --git a/build/win32/Cxbx.vcxproj b/build/win32/Cxbx.vcxproj
index 4879e0685..7ba7c5b4a 100644
--- a/build/win32/Cxbx.vcxproj
+++ b/build/win32/Cxbx.vcxproj
@@ -260,6 +260,7 @@
+
@@ -637,6 +638,7 @@
%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+
diff --git a/build/win32/Cxbx.vcxproj.filters b/build/win32/Cxbx.vcxproj.filters
index dbd742b48..0a71f250a 100644
--- a/build/win32/Cxbx.vcxproj.filters
+++ b/build/win32/Cxbx.vcxproj.filters
@@ -266,6 +266,9 @@
Hardware\Video
+
+ Hardware
+
@@ -529,6 +532,9 @@
Hardware\Video
+
+ Hardware
+
diff --git a/src/devices/ADM1032Device.cpp b/src/devices/ADM1032Device.cpp
new file mode 100644
index 000000000..3b53ae0a4
--- /dev/null
+++ b/src/devices/ADM1032Device.cpp
@@ -0,0 +1,57 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check it.
+// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// ******************************************************************
+// *
+// * .,-::::: .,:: .::::::::. .,:: .:
+// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
+// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
+// * $$$ Y$$$P $$""""Y$$ Y$$$P
+// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
+// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
+// *
+// * src->devices->ADM1032Device.cpp
+// *
+// * This file is part of the Cxbx project.
+// *
+// * Cxbx and Cxbe are free software; you can redistribute them
+// * and/or modify them under the terms of the GNU General Public
+// * License as published by the Free Software Foundation; either
+// * version 2 of the license, or (at your option) any later version.
+// *
+// * 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 for more details.
+// *
+// * You should have recieved a copy of the GNU General Public License
+// * along with this program; see the file COPYING.
+// * If not, write to the Free Software Foundation, Inc.,
+// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
+// *
+// * (c) 2018 ergo720
+// *
+// * All rights reserved
+// *
+// ******************************************************************
+
+#include "ADM1032Device.h"
+#include "..\CxbxKrnl\Emu.h" // For EmuWarning
+
+
+void ADM1032Device::Init()
+{
+ // ergo720: these are the values reported by UnleashX on my modded Xbox after half an hour of playing (in celsius)
+
+ m_CPUTemperature = 45;
+ m_MBTemperature = 40;
+}
+
+uint8_t ADM1032Device::ReadByte(uint8_t command)
+{
+ if (command == 0x0) { return m_MBTemperature; }
+ else if(command == 0x1) { return m_CPUTemperature; }
+
+ EmuWarning("Unknown read command sent to the temperature sensor. The command was %d", command);
+
+ return 0;
+}
diff --git a/src/devices/ADM1032Device.h b/src/devices/ADM1032Device.h
new file mode 100644
index 000000000..9d2f074dc
--- /dev/null
+++ b/src/devices/ADM1032Device.h
@@ -0,0 +1,67 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check it.
+// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// ******************************************************************
+// *
+// * .,-::::: .,:: .::::::::. .,:: .:
+// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
+// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
+// * $$$ Y$$$P $$""""Y$$ Y$$$P
+// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
+// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
+// *
+// * src->devices->ADM1032Device.h
+// *
+// * This file is part of the Cxbx project.
+// *
+// * Cxbx and Cxbe are free software; you can redistribute them
+// * and/or modify them under the terms of the GNU General Public
+// * License as published by the Free Software Foundation; either
+// * version 2 of the license, or (at your option) any later version.
+// *
+// * 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 for more details.
+// *
+// * You should have recieved a copy of the GNU General Public License
+// * along with this program; see the file COPYING.
+// * If not, write to the Free Software Foundation, Inc.,
+// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
+// *
+// * (c) 2018 ergo720
+// *
+// * All rights reserved
+// *
+// ******************************************************************
+
+#pragma once
+
+#include "SMDevice.h"
+
+// ergo702: annoyingly, I must override all the pure functions defined in SMDevice even if don't need most of them. If I don't, then
+// the compiler will complain about that ADM1032Device is an abstract class since it has pure functions within. Also, ADM1032Device
+// must derive from SMDevice because ConnectDevice expects a pointer to an object of that class...
+
+class ADM1032Device : public SMDevice
+{
+ public:
+ void Init();
+ void Reset() {};
+
+ void QuickCommand(bool read) {};
+ uint8_t ReceiveByte() { return 0; };
+ uint8_t ReadByte(uint8_t command);
+ uint16_t ReadWord(uint8_t command) { return 0; };
+ int ReadBlock(uint8_t command, uint8_t *data) { return 0; };
+
+ void SendByte(uint8_t data) {};
+ void WriteByte(uint8_t command, uint8_t value) {};
+ void WriteWord(uint8_t command, uint16_t value) {};
+ void WriteBlock(uint8_t command, uint8_t* data, int length) {};
+
+ private:
+ uint8_t m_CPUTemperature;
+ uint8_t m_MBTemperature;
+};
+
+extern ADM1032Device* g_ADM1032;
diff --git a/src/devices/SMCDevice.cpp b/src/devices/SMCDevice.cpp
index 38380ec34..651469c4d 100644
--- a/src/devices/SMCDevice.cpp
+++ b/src/devices/SMCDevice.cpp
@@ -45,6 +45,7 @@ namespace xboxkrnl
#include "CxbxKrnl\EmuShared.h"
#include "SMCDevice.h" // For SMCDevice
+#include "ADM1032Device.h" // For ADM1032Device
#include "LED.h"
void SetLEDSequence(LED::Sequence aLEDSequence)
@@ -109,8 +110,10 @@ uint8_t SMCDevice::ReadByte(uint8_t command)
break;
//case 0x03: // tray state
//case SMC_COMMAND_AV_PACK: // 0x04 // A / V Pack state
- //case SMC_COMMAND_CPU_TEMP: // 0x09 // CPU temperature (°C)
- //case SMC_COMMAND_MOTHERBOARD_TEMP: // 0x0A // motherboard temperature (°C)
+ case SMC_COMMAND_CPU_TEMP: // 0x09 // CPU temperature (°C)
+ return g_ADM1032->ReadByte(0x1);
+ case SMC_COMMAND_MOTHERBOARD_TEMP: // 0x0A // motherboard temperature (°C)
+ return g_ADM1032->ReadByte(0x0);
case 0x0F: // reads scratch register written with 0x0E
return buffer[0x0E];
//case SMC_COMMAND_POWER_FAN_READBACK: // 0x10 // Current power fan speed (0-50)
diff --git a/src/devices/SMCDevice.h b/src/devices/SMCDevice.h
index 2bac0f277..d896bd3ef 100644
--- a/src/devices/SMCDevice.h
+++ b/src/devices/SMCDevice.h
@@ -45,7 +45,7 @@
// Datasheet : http://ww1.microchip.com/downloads/en/DeviceDoc/30605D.pdf
// NOTE : Instead of calling this device by it's real name ("PIC16LC63A-04/SO"),
-// we've decided to call this device "SMC", since we don't implementation
+// we've decided to call this device "SMC", since we don't implement
// the low-level functionality of this PIC, but only the minimum set of
// high-level commands that are sufficient for the Xbox.
diff --git a/src/devices/Xbox.cpp b/src/devices/Xbox.cpp
index 5c28d0d77..8f1688def 100644
--- a/src/devices/Xbox.cpp
+++ b/src/devices/Xbox.cpp
@@ -9,7 +9,7 @@
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
-// * src->CxbxKrnl->Xbox.cpp
+// * src->devices->Xbox.cpp
// *
// * This file is part of the Cxbx project.
// *
@@ -42,6 +42,7 @@ SMCDevice* g_SMC;
EEPROMDevice* g_EEPROM;
NVNetDevice* g_NVNet;
NV2ADevice* g_NV2A;
+ADM1032Device* g_ADM1032;
MCPXRevision MCPXRevisionFromHardwareModel(HardwareModel hardwareModel)
{
@@ -125,6 +126,7 @@ void InitXboxHardware(HardwareModel hardwareModel)
g_EEPROM = new EEPROMDevice();
g_NVNet = new NVNetDevice();
g_NV2A = new NV2ADevice();
+ g_ADM1032 = new ADM1032Device();
// Connect devices to SM bus
g_SMBus->ConnectDevice(SMBUS_ADDRESS_SYSTEM_MICRO_CONTROLLER, g_SMC); // W 0x20 R 0x21
@@ -132,7 +134,7 @@ void InitXboxHardware(HardwareModel hardwareModel)
// TODO : Other SMBus devices to connect
//g_SMBus->ConnectDevice(SMBUS_ADDRESS_MCPX, g_MCPX); // W 0x10 R 0x11 -- TODO : Is MCPX an SMBus and/or PCI device?
- //g_SMBus->ConnectDevice(SMBUS_ADDRESS_TEMPERATURE_MEASUREMENT, g_TemperatureMeasurement); // W 0x98 R 0x99
+ g_SMBus->ConnectDevice(SMBUS_ADDRESS_TEMPERATURE_MONITOR, g_ADM1032); // W 0x98 R 0x99
//g_SMBus->ConnectDevice(SMBUS_ADDRESS_TV_ENCODER, g_TVEncoder); // W 0x88 R 0x89
switch (tv_encoder) {
case TVEncoder::Conexant:
diff --git a/src/devices/Xbox.h b/src/devices/Xbox.h
index 00901d403..634f1ace9 100644
--- a/src/devices/Xbox.h
+++ b/src/devices/Xbox.h
@@ -9,7 +9,7 @@
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
-// * src->CxbxKrnl->Xbox.h
+// * src->devices->Xbox.h
// *
// * This file is part of the Cxbx project.
// *
@@ -32,7 +32,7 @@
// *
// * All rights reserved
// *
-// ******************************************************************#pragma once
+// ******************************************************************
#pragma once
#include "PCIBus.h" // For PCIBus
@@ -41,13 +41,14 @@
#include "SMCDevice.h" // For SMCDevice
#include "EEPROMDevice.h" // For EEPROMDevice
#include "EmuNVNet.h" // For NVNetDevice
+#include "ADM1032Device.h" // For ADM1032
#include "devices\video\nv2a.h" // For NV2ADevice
#define SMBUS_ADDRESS_MCPX 0x10 // = Write; Read = 0x11
#define SMBUS_ADDRESS_TV_ENCODER 0x88 // = Write; Read = 0x89
#define SMBUS_ADDRESS_SYSTEM_MICRO_CONTROLLER 0x20 // = Write; Read = 0x21
#define SMBUS_ADDRESS_TV_ENCODER_ID_CONEXANT 0x8A // = Write; Read = 0x8B
-#define SMBUS_ADDRESS_TEMPERATURE_MEASUREMENT 0x98 // = Write; Read = 0x99
+#define SMBUS_ADDRESS_TEMPERATURE_MONITOR 0x98 // = Write; Read = 0x99
#define SMBUS_ADDRESS_EEPROM 0xA8 // = Write; Read = 0xA9
#define SMBUS_ADDRESS_TV_ENCODER_ID_FOCUS 0xD4 // = Write; Read = 0xD5
#define SMBUS_ADDRESS_TV_ENCODER_ID_XCALIBUR 0xE0 // = Write; Read = 0xE1