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.

Coding > SIO Normal Mode

#26859 - ProblemBaby - Mon Sep 27, 2004 9:09 pm

Hi

Ive some problems to get SIO Normal Mode to work.
My code works if I put 4 calls to VBlankIntrWait after the transmission code=) but not with one or any!

When I look at the flow slowly I see that data is transmitted faster then recieved from the the slave.
I check if SI is high before I send in the master code is it anything else I should do???

Here is the code:
Code:

void Transfer(u32 Data)
{
   REG_SIODATA32 = Data;
   if (g_MultiPlayer.Identifier) // Slave!
   {
      REG_SIOCNT |= SIOCNT_ACTIVE; // Activate
      REG_SIOCNT &= 0xFFF7; // Clear SO
      while (REG_SIOCNT & SIOCNT_ACTIVE);
      REG_SIOCNT |= BIT(3); // Set SO
   }
   else // Master
   {
      while (REG_SIOCNT & BIT(2)); // check for SI low
                                // I think something should be done here!
      REG_SIOCNT |= SIOCNT_ACTIVE;
      while (REG_SIOCNT & SIOCNT_ACTIVE);
   }

      // If I wait four times for VBlankIntr here it works!
}



Plz Help!

#26908 - ProblemBaby - Tue Sep 28, 2004 9:19 pm

Im one step closer to the problem.
The data is sent to the slave but never recieved.
But I dont know how to fix it Do someone see somthing wrong in the code?

#26939 - tepples - Wed Sep 29, 2004 9:23 pm

Normal mode with a GBA cable is one-way. You'll need to use a GBC cable for two-way normal mode comms.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#26940 - ProblemBaby - Wed Sep 29, 2004 9:38 pm

It works when I select another cable type in no$gba
actually I havent tried it yet on real hardware.
But do you mean that it wont work if Ive my normal 4 link cable?
even on hardware?

I also have to ask for now Iam putting a little delay after the master has sent the data in other case the slave sometimes take two packages.
is the SO automatically set after the transmission is finished on real hardware? The man who wrote the gbatek was unsure.

#26949 - tepples - Thu Sep 30, 2004 12:10 am

On your normal 4 link cable, Normal Mode is used for broadcasts such as loading assets at the beginning of a level, and Multiplayer Mode is used for actual gameplay.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#26962 - ProblemBaby - Thu Sep 30, 2004 11:55 am

I was so glad for a moment...
It was so easy to perfrom error checking in normal mode!
Well it is still easy when I just send stuff to my slaves
but when they should communicate I have to use MultiPlayer Mode, I read in the gbatek that slaves should temporarily switch into another mode which doesnt output SD High.

I dont understand what he means, do someone understand?

#26963 - Krakken - Thu Sep 30, 2004 12:54 pm

You don't _have_ to use Multiplayer mode unless you want more than 2 players in your game.

#26965 - tepples - Thu Sep 30, 2004 1:00 pm

To stop outputting SD High, try switching into general purpose mode with SO, SI, SC as input, and SD as output set to 0. This will pull SD low so that the master will pick it up.

Krakken: Players expect GBA multiplayer to work with a GBA cable. You have to use multiplayer mode for 2-way communication over a GBA cable, even in a 2-player game.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#26973 - ProblemBaby - Thu Sep 30, 2004 3:32 pm

some pseudo code:

StartSession

while (1)
{

RCNT = BIT(5) | BIT(15);

SetMultiPlayerMode
Transfer
if (SD & HIGH)
{
No problems do stuff
}
else
{
problems.
Transfer until SD is high
}

is it something like this?

}