DEV9: adjusted logic for loading default MAC

Now a little less confusing
This commit is contained in:
TheLastRar 2021-01-05 23:26:57 +00:00 committed by refractionpcsx2
parent 5cdb6dcb12
commit 9468b04713
2 changed files with 9 additions and 5 deletions

View File

@ -86,16 +86,18 @@ void TermNet()
NetAdapter::NetAdapter() NetAdapter::NetAdapter()
{ {
//Ensure eeprom matches our default //Ensure eeprom matches our default
SetMACAddress(ps2MAC); SetMACAddress(nullptr);
} }
void NetAdapter::SetMACAddress(u8* mac) void NetAdapter::SetMACAddress(u8* mac)
{ {
if (ps2MAC != mac) if (mac == nullptr)
memcpy(ps2MAC, defaultMAC, 6);
else
memcpy(ps2MAC, mac, 6); memcpy(ps2MAC, mac, 6);
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
dev9.eeprom[i] = ((u16*)mac)[i]; dev9.eeprom[i] = ((u16*)ps2MAC)[i];
//The checksum seems to be all the values of the mac added up in 16bit chunks //The checksum seems to be all the values of the mac added up in 16bit chunks
dev9.eeprom[3] = (dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2]) & 0xffff; dev9.eeprom[3] = (dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2]) & 0xffff;

View File

@ -17,6 +17,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> //uh isnt memcpy @ stdlib ? #include <string.h> //uh isnt memcpy @ stdlib ?
// first three recognized by Xlink as Sony PS2
const u8 defaultMAC[6] = {0x00, 0x04, 0x1F, 0x82, 0x30, 0x31};
struct NetPacket struct NetPacket
{ {
NetPacket() { size = 0; } NetPacket() { size = 0; }
@ -37,8 +40,7 @@ extern mtfifo<NetPacket*> tx_fifo;
class NetAdapter class NetAdapter
{ {
protected: protected:
// first three recognized by Xlink as Sony PS2 u8 ps2MAC[6];
u8 ps2MAC[6] = {0x00, 0x04, 0x1F, 0x82, 0x30, 0x31};
public: public:
NetAdapter(); NetAdapter();