Views: 230,427 Homepage | Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 07-15-18 11:09 PM
Guest:

0 users reading DeSmuME-Reloaded = Fork of DeSmuME with Wifi capacities | 1 bot

Main - General chatter - DeSmuME-Reloaded = Fork of DeSmuME with Wifi capacities New reply


Jackobo
Posted on 12-12-17 11:02 AM (rev. 6 of 12-12-17 11:10 AM) Link | #441
Hi everybody,

I did not know where to post this message. So in order to not put the mixed in the forum, I put it to you here.

I read a few days ago all the news about DeSmuME, the tensions that there was about the Wifi support and all the work that StapleButter had brought on it and which was destroyed by zeromus mainly.

I will not go back over it, but personally, it made me sad that:
- Wifi was no longer working while StapleButter had worked on it for everything to work
- the emulator still had good points on the other features.

I saw only tests on Windows. I thought to myself: why not test all this on a Linux distribution ^^ ? So I found a 0.9.7 version and a code that supported on Windows the Wifi for the connection with DWC servers of polaris- project ( Code : https://github.com/polaris-/dwc_network_server_emulator --- Wiki : https://github.com/polaris-/dwc_network_server_emulator/wiki )

I just finished successfully this support, available here for the interested ones: DeSmuME-Reloaded = https://github.com/JackoboLeChocobo/DeSmuME-Reloaded. And so I come to make a request: Would StapleButter mainly as well as the others members of the forum be interested to try to include the support of the local MelonDS Wifi on DeSmuME-Reloaded in the aim to honor the work that StapleButter had done on it and finally having the long-awaited emulator that all we wanted here ?

Thank you for taking the time to read my post.

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

StapleButter
Posted on 12-12-17 11:14 PM Link | #446
That's cool if people want to revive DeSmuME's wifi support, but I'm not touching the codebase with a 20m pole. Not that I have any hate towards DeSmuME or its developers, I just think it needs a rewrite badly, for a variety of reasons. If you want I can go in detail about this.

Oh and from what I have seen, they haven't changed their stance towards wifi (it doesn't exist!!), so I guess sticking to your own branch is a good thing.


The bit about wifi is one of the reasons why melonDS exists, after all. Getting altWFC working is matter of emulating an access point and using libpcap or whatever to redirect data frames to the network. I could even auto-patch WFC-enabled games to use altWFC.

Jackobo
Posted on 12-13-17 08:44 AM (rev. 4 of 12-13-17 12:32 PM) Link | #447
Hi StapleButter,

That's cool if people want to revive DeSmuME's wifi support, but I'm not touching the codebase with a 20m pole. Not that I have any hate towards DeSmuME or its developers, I just think it needs a rewrite badly, for a variety of reasons. If you want I can go in detail about this.


Indeed rewrite of this code (0.9.7 r3947) is necessary to have all bugs fixes and optimisations. I planned to see every diff since this version ( last diff version for the first part (on Sourceforge) is r5576 so 1629 diffs actions will be analysed by me ( and only diffs that doesn't affect Wifi in the r3947 will be appplied ). Need coffee or Coca-Cola ^ลต^ . I will be interested to know details about this when you will have the time of course.

EDIT - 13-Dec-17 : New update, finally I successfully add Wifi for connection on DWC project in 0.9.11 ^w^

Oh and from what I have seen, they haven't changed their stance towards wifi (it doesn't exist!!), so I guess sticking to your own branch is a good thing.


That's why after much research on forums I see successfull results on Wifi with r3947. And I want to start with r3947 as a base

The bit about wifi is one of the reasons why melonDS exists, after all. Getting altWFC working is matter of emulating an access point and using libpcap or whatever to redirect data frames to the network. I could even auto-patch WFC-enabled games to use altWFC


I see indeed on Desmume that SoftAP is just an emulated access point ( I will change the name (SoftAP) if possible ^^") . Libpcap is a good choice ( for Windows users i think they can use an open source variant of libpcap instead of use WinPCAP ? ).

I understand that melonDS exists for that, but if I can understand how use the Wifi local in Desmume with your work and try to apply libpcap for altWFC support for melonDS, i can try it ^^ . I try to find a open source solution to patch WFC-enabled games ( currently i see only a free solution , WFCPatcher )

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

Jackobo
Posted on 12-13-17 06:10 PM Link | #448
Hi everybody,

I have the pleasure to announce the Wifi support for connection on DWC project in 0.9.12.
You will find all informations in my github project : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Time to understand now the local Wifi multiplayer mode : any help on that will be very useful ^^

Tested on Lubuntu 16.04 64-bits mode.

Bug fixes and suggestions/ideas are welcome \o/

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

Jackobo
Posted on 12-16-17 08:54 AM Link | #450
Hi everybody,

Here is a special annoucement. After 16 hours of many tests and modifications of the Windows version of DeSmuME ( Oh my god the mess it was in the original code.... What a pain... ) , I have successfully the WiFi support for connecting to DWC server projects on Windows. Method to use it is the same than older versions of Desmume ( see on the web tutorials for Wifi on 0.9.7 and 0.9.9 versions ).

The updates of the code are available now ( https://github.com/JackoboLeChocobo/DeSmuME-Reloaded/ ). I will write a wiki for using the emulator correctly.

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

Jackobo
Posted on 12-17-17 04:48 PM Link | #451
Hi everybody,

Got a question : What is the function "WIFI_SoftAP_RecvPacketFromDS" on old versions of DeSmuME, function that will be unused by '#ifdef 0' ?

Sincerely,
Jackobo The Chocobo


____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

StapleButter
Posted on 12-17-17 04:55 PM Link | #452
probably some old leftover, seeing as it predates the wifi interface system

Jackobo
Posted on 12-17-17 08:03 PM Link | #453
Hi StapleButter,

Because when I see that in sourceforge.net, and functions that use it and others things, I suppose that you get something working with this release for local wifi on DeSmuME ?

[r2787] (55.1 kB) by luigi__
Wifi: more work on packet reception.
NSMB two-card multiplayer now half-works. Luigi sees Mario, but Mario doesn't see Luigi :(

See that on https://sourceforge.net/p/desmume/code/3000/log/?path=/trunk/desmume/src/wifi.cpp
Changelog r2787 : https://sourceforge.net/p/desmume/code/2787/
Source code of r2787 : https://sourceforge.net/p/desmume/code/2787/tree/

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

Jackobo
Posted on 12-18-17 05:28 PM (rev. 4 of 12-18-17 05:30 PM) Link | #457
Hi everybody,

Trying to use the r2787 Ahdoc code with small modifications. Get datas that are sent ( thanks to Wireshark ) . But no answer of the two DeSmuME. What could be the problem ? Could be an issue in the recv subprogram ?

Datas are sent to 255.255.255.255.


void Adhoc_usTrigger()
{
Adhoc.usecCounter++;

// Check every millisecond if we received a packet
if (!(Adhoc.usecCounter & 1023))
{
fd_set fd;
struct timeval tv;

FD_ZERO(&fd);
FD_SET(wifi_socket, &fd);
tv.tv_sec = 0;
tv.tv_usec = 0; //<-------------------------------Issue with detection ?

if (select(1, &fd, 0, 0, &tv)) //<-------------------Issue with detection ?
{
sockaddr_t fromAddr;
int fromLen = sizeof(sockaddr_t);
u8 buf[1536];
u8* ptr;
u16 packetLen;

int nbytes = recvfrom(wifi_socket, (char*)buf, 1536, 0, &fromAddr, (socklen_t*)&fromLen);

// No packet arrived (or there was an error)
if (nbytes <= 0)
return;

WIFI_LOG(3, "Ad-hoc: received a packet of %i bytes from %i.%i.%i.%i (port %i).\n",
nbytes,
(u8)fromAddr.sa_data[2], (u8)fromAddr.sa_data[3],
(u8)fromAddr.sa_data[4], (u8)fromAddr.sa_data[5],
ntohs(*(u16*)&fromAddr.sa_data[0]));

ptr = buf;
Adhoc_FrameHeader header = *(Adhoc_FrameHeader*)&ptr[0];

// Check the magic string in header
if (strncmp(header.magic, ADHOC_MAGIC, 8) != 0)
return;

// Check the ad-hoc protocol version
if (header.version != ADHOC_PROTOCOL_VERSION)
return;

packetLen = header.packetLen;
ptr += sizeof(Adhoc_FrameHeader);

// If the packet is for us, send it to the wifi core
if (memcmp(&ptr[10], &wifiMac.mac.bytes[0], 6))
{
if ((!memcmp(&ptr[16], &BroadcastMAC[0], 6)) ||
(!memcmp(&ptr[16], &wifiMac.bss.bytes[0], 6)) ||
(!memcmp(&wifiMac.bss.bytes[0], &BroadcastMAC[0], 6)))
{
WIFI_triggerIRQ(WIFI_IRQ_RXSTART);

u8* packet = new u8[12 + packetLen];

WIFI_MakeRXHeader(packet, WIFI_GetRXFlags(ptr), 20, packetLen, 255, 2);
memcpy(&packet[12], &ptr[0], packetLen);

// u32 crc32 = WIFI_calcCRC32(ptr, packetLen - 4);
// *(u32*)&ptr[packetLen - 4] = crc32;

for (int i = 0; i < (12 + packetLen); i += 2)
{
u16 word = *(u16*)&packet[i];
WIFI_RXPutWord(word);
}

wifiMac.RXWriteCursor = ((wifiMac.RXWriteCursor + 1) & (~1));
WIFI_IOREG(REG_WIFI_RXHWWRITECSR) = wifiMac.RXWriteCursor;
wifiMac.RXNum++;
WIFI_triggerIRQ(WIFI_IRQ_RXEND);
}
}
}
}
}


____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

StapleButter
Posted on 12-18-17 05:49 PM Link | #458
I knew what the issue was back then (the EXTRA/CMD TX slot, the implementation wasn't accurate enough). I wouldn't know now though, seems the wifi support has degraded over time.

Jackobo
Posted on 12-18-17 09:06 PM Link | #459
Hi StapleButter,

I tried to replace the contents Adhoc_usTrigger() with a function to just detect the datas sent by the application. No answer. So if even the datas are not detected with a simple function, there is already an issue with it. The datas are correctly sent in the first part.

I will check that.

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

Jackobo
Posted on 12-19-17 01:03 AM (rev. 3 of 12-19-17 01:18 AM) Link | #462
Hi StapleButter and everybody,

I got now the same result as the original StapleButter ticket on old DesMume project : https://sourceforge.net/p/desmume/code/2787/
I do modifications of the code ( I write a new system creation of the sockets and I disable the verification of the MAC Address because we do a check with ADHOC_MAGIC and ADHOC_PROTOCOL_VERSION )

Tested on NSMB : Luigi sees Mario, invites him but after Mario said "Nope !" xD
Same sort of thing for Sonic Rush.

So close of the solution >< Any ideas to solve it ? ^^
If you want the code, I can create a new branch.

Question : What's the difference between these two codes ? :

Original code on DesMuMe :
select(1, &readfds, NULL, NULL, &tv);

New code on DesMuMe Reloaded (based on melonDS works) :
select(wifi_socket+1, &readfds, NULL, NULL, &tv);

Sincerely,
Jackobo The Chocobo

____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink

Jackobo
Posted on 12-21-17 03:13 AM (rev. 3 of 12-21-17 10:00 PM) Link | #469
Hi everybody,

I get a tentative connection with games on MP Link on my DeSmuME version. I get deconnexion when I tried to connect to the channel.

I check currently this code :

// TODO: find out if this is correct at all
// this was mostly guessed, like most of the MP reply functionality
static void WIFI_DoAutoReply(u8* cmd)
{
cmd += 12;

u16 frameCtl = *(u16*)&cmd[0] & 0xE7FF;

printf("0x%04X\n",frameCtl);

if (frameCtl == 0x0228)
{
// if the packet we got is a multiplayer command (data+cf-poll),
// check if it was destined to us
u16 slaveflags = *(u16*)&cmd[24 + 2];
if (!(slaveflags & (1 << wifiMac.pid)))
return;

// if it was destined to us, (try to) send a reply
u16 regval = WIFI_IOREG(REG_WIFI_TXBUF_REPLY1);
wifiMac.TXSlots[WIFI_TXSLOT_MPREPLY].RegVal = regval;

regval &= 0x0FFF;
wifiMac.RAM[regval + 6 + 1] = *(u16*)&cmd[24];

WIFI_TXStart(WIFI_TXSLOT_MPREPLY);
}
else if (frameCtl == 0x0118)
{
// broadcast MP ACK
// this packet appears to be sent automatically
// PS: nope. Enabling this code causes NSMB to break the connection even quicker.
// Probably it should send the ACK itself whenever it wants to...
u8 ack[32];
*(u16*)&ack[0] = 0x0218;
*(u16*)&ack[2] = 0x0000;
*(u16*)&ack[4] = 0x0903;
*(u16*)&ack[6] = 0x00BF;
*(u16*)&ack[8] = 0x0300;
memcpy(&ack[10], &wifiMac.bss.bytes[0], 6); //It's bss not mac according to StapleButter works
memcpy(&ack[16], &wifiMac.mac.bytes[0], 6);
*(u16*)&ack[22] = wifiMac.TXSeqNo << 4; wifiMac.TXSeqNo++;
*(u16*)&ack[24] = 0x0033; //??
*(u16*)&ack[26] = 0x0000;
*(u32*)&ack[28] = 0x00000000;

wifiCom->SendPacket(ack, 32);
}
}

I got the following frameCtl :
=> 0x0228 ==> Send a MP Reply if it was destined to us and the packet is a multiplayer command
=> 0x0080 ==> ???
=> 0x00B0 ==> ???
=> 0x0000 ==> ???
=> 0x0118 ==> Send ACK Packet
=> 0x00C0 ==> ???

Did you know for the others values what are the type of packets we must send ?
Maybe the default MP packet that I see in MelonDS :
*(u16*)&reply[0xC + 0x00] = 0x0158;
*(u16*)&reply[0xC + 0x02] = 0x00F0;//0; // TODO??
*(u16*)&reply[0xC + 0x04] = IOPORT(W_BSSID0);
*(u16*)&reply[0xC + 0x06] = IOPORT(W_BSSID1);
*(u16*)&reply[0xC + 0x08] = IOPORT(W_BSSID2);
*(u16*)&reply[0xC + 0x0A] = IOPORT(W_MACAddr0);
*(u16*)&reply[0xC + 0x0C] = IOPORT(W_MACAddr1);
*(u16*)&reply[0xC + 0x0E] = IOPORT(W_MACAddr2);
*(u16*)&reply[0xC + 0x10] = 0x0903;
*(u16*)&reply[0xC + 0x12] = 0x00BF;
*(u16*)&reply[0xC + 0x14] = 0x1000;
*(u16*)&reply[0xC + 0x16] = IOPORT(W_TXSeqNo) << 4;
*(u32*)&reply[0xC + 0x18] = 0;

For people that want to understand the packet, here is a link that my twin brother found on the Web :
http://www.ricbit.com/mundobizarro/nds.html

Any answer will be helpfull.

Sincerely,
Jackobo The Chocobo


____________________
Github : https://github.com/JackoboLeChocobo
DeSmuME-Reloaded : https://github.com/JackoboLeChocobo/DeSmuME-Reloaded
Vbam-libretro-pack : https://github.com/JackoboLeChocobo/vbam-libretro-pack
VisualBoyAdvance Link : https://github.com/JackoboLeChocobo/VisualBoyAdvanceLink


Main - General chatter - DeSmuME-Reloaded = Fork of DeSmuME with Wifi capacities New reply

Page rendered in 0.018 seconds. (2048KB of memory used)
MySQL - queries: 27, rows: 98/98, time: 0.009 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2017-11-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.