Adhoc wifi notes

From DeSmuME
(Difference between revisions)
Jump to: navigation, search
(Some disassembling)
Line 25: Line 25:
 
while (flags = IF & IE)<br>
 
while (flags = IF & IE)<br>
 
{<br>
 
{<br>
if (flags & 0x0080) call 0x037FA528;<br>
+
if (flags & 0x0080 /* TXSTART */) call 0x037FA528;<br>
if (flags & 0x0040) call 0x037FA5E4;<br>
+
if (flags & 0x0040 /* RXSTART */) call 0x037FA5E4;<br>
if (flags & 0x8000) call 0x037F95E8;<br>
+
if (flags & 0x8000 /* PREBEACON */) call 0x037F95E8;<br>
if (flags & 0x4000) call 0x037F9674;<br>
+
if (flags & 0x4000 /* BEACON */) call 0x037F9674;<br>
if (flags & 0x2000) call 0x037F9970;<br>
+
if (flags & 0x2000 /* POSTBEACON */) call 0x037F9970;<br>
if (flags & 0x0800) call 0x027EBC08;<br>
+
if (flags & 0x0800 /* RFWAKEUP */) call 0x027EBC08;<br>
if (flags & 0x0008) call 0x037F9A28;<br>
+
if (flags & 0x0008 /* TXERR INC */) call 0x037F9A28;<br>
if (flags & 0x0004) call 0x037F9B54;<br>
+
if (flags & 0x0004 /* RXEVT INC */) call 0x037F9B54;<br>
if (flags & 0x0001) call 0x037F9F88;<br>
+
if (flags & 0x0001 /* RXEND */) call 0x037F9F88;<br>
if (flags & 0x0030) call 0x037F99EC;<br>
+
if (flags & 0x0030 /* TXERR/RXEVT HOVF */) call 0x037F99EC;<br>
if (flags & 0x0002) call 0x037F9D18;<br>
+
if (flags & 0x0002 /* TXEND */) call 0x037F9D18;<br>
if (flags & 0x1000) call 0x037FA418;<br>
+
if (flags & 0x1000 /* IRQ12 */) call 0x037FA418;<br>
 
}<br>
 
}<br>
 
done:<br>
 
done:<br>

Revision as of 17:39, 25 September 2010

The Ultimate Goal

- Getting adhoc wifi working. AKA NSMB multiplayer, pictochat, and many others.

The Issue

NSMB goes through the following sequence to connect two players together:
- Mario configures the wifi hardware as to send beacons every ~200ms. The beacons are 802.11 standard with extra data (tag DDh as GBATek puts it)
- Luigi receives the beacons and asks "Mario found - want to play?", let's assume the player says Yes
- Luigi associates with Mario, they exchange a few 802.11 standard authentication/association packets
- Mario sends a data frame every 1660µs. 478µs are given Luigi to reply.
- Luigi never replies for some reason. Connection fails.


Luigi does processing on the received data frame before it is fully received (aka between IRQ6 and IRQ0). Once it is fully received it's too late.
That's what we can call tight timing. :P

Some disassembling

NSMB's wifi IRQ handler (pseudocode)
(located at 0x037F9504)

start:
u16 flags;
while (flags = IF & IE)
{
if (flags & 0x0080 /* TXSTART */) call 0x037FA528;
if (flags & 0x0040 /* RXSTART */) call 0x037FA5E4;
if (flags & 0x8000 /* PREBEACON */) call 0x037F95E8;
if (flags & 0x4000 /* BEACON */) call 0x037F9674;
if (flags & 0x2000 /* POSTBEACON */) call 0x037F9970;
if (flags & 0x0800 /* RFWAKEUP */) call 0x027EBC08;
if (flags & 0x0008 /* TXERR INC */) call 0x037F9A28;
if (flags & 0x0004 /* RXEVT INC */) call 0x037F9B54;
if (flags & 0x0001 /* RXEND */) call 0x037F9F88;
if (flags & 0x0030 /* TXERR/RXEVT HOVF */) call 0x037F99EC;
if (flags & 0x0002 /* TXEND */) call 0x037F9D18;
if (flags & 0x1000 /* IRQ12 */) call 0x037FA418;
}
done:
/* clear wifi IRQ flag in main IF */
return;

(edit: fucking mediawiki and its terrible way to handle linebreaks)

Personal tools