gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Multiplayer emulation

#60192 - wiz - Mon Nov 07, 2005 11:35 pm

Hi all,

I am actually looking for a good way to test multiplayer functionality. Looking through example code, which I downloaded Scott Lininger's website, the player ID seem to be set up like so:

Code:
Player = EWRAM[0xc5]


Im guessing the link cable sets an ID for each cable somehow?? Am I guessing correctly?

but when in emulation mode, all players are "player 0" therefore the demo doesnt actually work..

Can it be tested this way through an emu? if not - I cant seem to understand how one can be a "master" when they are both running the same code?

Im not interested in all the multiboot stuff yet, just thought I should mention that..

Thanks for your time reading :) any suggestions I would love to hear

#60240 - wintermute - Tue Nov 08, 2005 10:20 am

No$gba emulates multiplayer quite well.

http://nocash.emubase.de/gba.htm

The debug version is well worth the registration fee although hobbyists will find it hard to justify the price of the full blown source debugger. The standard home version is more than adequate for most homebrew purposes.

http://nocash.emubase.de/gba-dev.htm

#60245 - wiz - Tue Nov 08, 2005 11:06 am

Hi wintermute,

thanks for the reply, no$gba is the emulator I am currently trying with mutiplayer testing it looks very promising and I am very tempted to register the cheaper home dev version but Im not really sure I would understand the features ;)

This is what is puzzling me at the moment,

Code:
Player = EWRAM[0xc5]

I am assuming this memory address is to return the "player id"? the emulators set both players id to "player 0" so I can not distinguish one player from the other. Which GBA is the 'master'?

I have tried this with NO$GBA and VBA-LINK. Perhaps Im looking at this all the wrong way?

#60268 - tepples - Tue Nov 08, 2005 3:09 pm

The byte in EWRAM is there only if you start player 1 from a cart and players 2-4 from the BIOS screen and then you use SWI 0x25 to start players 2-4. But there's still a hardware register that tells you what number your GBA is in the chain. Look for "Multiplayer ID" in SIOCNT.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#60401 - wiz - Thu Nov 10, 2005 12:51 am

ah right, that works.. or atleast it does in no$gba, my player id code doesnt work in vba-link.

seems I can transfer around 32 bits a frame in my game without noticable slowdown (as I can tell from the emulator) using scott's techniqes.

well thanks yet again.. here is my code if anyone else is in my learning phase :)

If anyone can see a problem why this wouldnt work or if I am doing anything wrong please let me know as there is no way for me to test it on hardware

Code:

int MultiplayerGetIDs()
{
   SIOCNT = 0;

   // enable multiplayer
   SIOCNT |= (1 << 13);

   // set mode multiplayer mode
   REG_RCNT = 0;
   REG_RCNT |= (1 << 14);

   int ready = 0;

   // find out if all GBA's are ready
   if (SIOCNT & (1<<3)) ready = 1;

   // keep calling this function until 'ready' is equal to 1
   if (ready == 0)
   {
      return -1;
   }

   // get *this* player id
   PID = (SIOCNT >> 4) & 3;

   char buf[255];
   sprintf(buf, "THIS IS GBA %d ", PID);
        printscreen(buf, 1, 1);

        // clean up
   REG_RCNT = 0;
   SIOCNT = 0;

   return 0;
}



thanks!