#23515 - ProblemBaby - Wed Jul 14, 2004 3:43 pm
Ive made working Multiplayer code.
But ive still some problems with the delay to send the data
It is very Important that the data is recieved in same Frame in borh GBAs
if I use a timer as ive seen many does the data often is recieved in Frame x+1
Now Ive put a little Delay in the MultiPlayerUpdate code
But maybe it exist a better way to do this or maybe not
well if not does it exist a formula to know how many cycles to wait
that depends on the baudrate, number of gbas connected and number of packets
#23522 - tepples - Wed Jul 14, 2004 5:13 pm
Multiple GBAs will often drift out of sync because every GBA's clock crystal vibrates at a slightly different rate. You have to send a sequential frame number (of about 4 bits) with the input reflection or world reflection packets so that the GBAs that fall behind can wait a frame to catch up.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#23526 - ProblemBaby - Wed Jul 14, 2004 5:34 pm
In my case it is input.
as I said its very important that it is recieved in same Frame or else the whole game will flip out..
Code: |
u8 n;
REG_SIOMLT_SEND = OutData;
if (g_MultiPlayerData.Identifier == 0)
REG_SIOCNT |= SIOCNT_ACTIVE;
DelayCycles(921000); // I dont like this
if (!(REG_SIOCNT & SIOCNT_ERROR))
{
for (n = 0; n < g_MultiPlayerData.PlayerCount; n++)
g_MultiPlayerData.Data[n] = REG_SIOMULTI[n];
}
else
{
for (n = 0; n < g_MultiPlayerData.PlayerCount; n++)
g_MultiPlayerData.Data[n] = 0;
return 0;
}
|
This is my function for updating data it works very good but I think
that the procedure to recieve doesnt take that much cycles.
Now this works fine because it isnt much else in the program, but later....
It will take a lot of time to find a good value. Because I ve to flash it to my FlashCart every time to see if it works.
I dont want to use interrupts because the data will be recieved to late
So maybe it exist a formula to find it out and then I can add some extra cycles because of the sunc problems you told me about
#23534 - col - Wed Jul 14, 2004 7:59 pm
tepples wrote: |
Multiple GBAs will often drift out of sync because every GBA's clock crystal vibrates at a slightly different rate. You have to send a sequential frame number (of about 4 bits) with the input reflection or world reflection packets so that the GBAs that fall behind can wait a frame to catch up. |
I am interested to know if you have implemented a successful version of this approach, and what the behaviour was at the 'boundary' point where the lag occurs.
ProblemBaby (and tepples),
Are you talking about a system where each unit sends its keypad info to the others.?
Or one where the slaves all sent their keypads and the master broadcasts game state information?
cheers
Col
#23552 - ProblemBaby - Thu Jul 15, 2004 1:59 am
Well iam talking about a system that sends the keystate
and then every thing is processed in each gameboy
#23553 - ProblemBaby - Thu Jul 15, 2004 2:30 am
And oh Ive downloaded no$gba and in the options it is possible to set MultiPlayer settings but nothing doesnt work isnt it implemented or am I doing something wrong do I need something extra or what is the problem..
my settings is:
Multiboot port: none/disabled
Multiboot Normal/burst delays: Medium/medium (stable)
Number of GBAs emulated: 2
Link Gamepaks: Master only (single gamepak)
Link cable type: Multiplayer (four players) // becuase it is what i got
#23599 - ProblemBaby - Fri Jul 16, 2004 12:42 am
It seems like that no$gba doesnt support MultiBoot
but if I skip the MultiBoot-code and choose 2gbas it works
but not like in hardware, no delays =/
Well about my question ive tried do a while to wait for the SIOCNT to be unactive and then run the Recieve code i got good frame rate
but I doesnt work perfect...
Maybe I cant do the same for both the Master and Slave
do anyone now something abot this what happens in the Master and Slaves when the transfer is done and ready to be recieved..
Thanks
#23618 - caitsith2 - Fri Jul 16, 2004 8:10 am
Actually, no$gba does handle multiboot without the bios, just the routine for that is not perfect, and seems to only work with games written with the official library at the moment. I have tried however, using multiboot, with the bios, and it seems to work fine, providing that you tell no$gba to use the nintendo logo as the entry point, and not the direct rom access.
#23626 - ProblemBaby - Fri Jul 16, 2004 12:27 pm
My screen is just white if I choose to start from the nintedo logo
#23634 - Miked0801 - Fri Jul 16, 2004 5:45 pm
All the more reason to try to setup an error reporting system on this forum :)
#23648 - ProblemBaby - Sat Jul 17, 2004 1:13 am
Iam also wondering what the swi 0x25 really does
do someone know a site where I can find information how do my own.
Because I dont want to have my game twice in the cartridge and I want to be able to send different data.
#23649 - mymateo - Sat Jul 17, 2004 1:50 am
I'm way in over my head when it comes to multiplayer or ASM programming and the like, but sometimes I can be creative so I might be able to help.
What if each frame, you generated a checksum, or counted each frame sequentially. Each GBA listens for comms from the other GBA(s). When a GBA is done everything it needs to for a frame, it sends a "finished" code (defined by you) accompanied with the frame's checksum/serial number. Then it waits until it has received a "finished" code with a matching number from all other GBA's. Then, each GBA shares it's key data, and proceeds to process the next frame. Since each GBA runs at almost the exact same speed, there should be extremely little delay, you could even save some overhead by reading the key data from other GBA's every 2 (or possibly 3) frames ('cause most people can't selectively push 20 to 30 buttons every second... by selectively I mean that pretty much everyone can wildly mash all the buttons and manage it, but they couldn't puch buttons that fast in a controlled manner to acheive a goal... heh).
So like I said, I'm in over my head in the technicl aspect, so I don't know if this is a theoretically sound solution, but maybe it'll help. I hope it will.
#23655 - tepples - Sat Jul 17, 2004 6:26 am
mymateo wrote: |
Since each GBA runs at almost the exact same speed, there should be extremely little delay, you could even save some overhead by reading the key data from other GBA's every 2 (or possibly 3) frames ('cause most people can't selectively push 20 to 30 buttons every second... by selectively I mean that pretty much everyone can wildly mash all the buttons and manage it, but they couldn't puch buttons that fast in a controlled manner to acheive a goal... heh). |
You'd be surprised at how fast a fighting game veteran can pull off a Street Fighter II fireball or dragon-punch move.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#23729 - ScottLininger - Mon Jul 19, 2004 7:51 pm
ProblemBaby,
You may be way past me already, but if you're interested I have some stable multiboot/multiplayer code on my site: http://www.thingker.com
The code works by exchanging arbitrary STRUCTs every frame between all of the connected GBAs, so you could exchange your keypress state pretty easily... Each of your slave STRUCTS would contain a single INT that you dump the keystate into before transfer, while the master's STRUCT would contain all of the other game state variables that the slaves would need to display the game correctly.
The only problem with the code is that it's slower than the SGADE implementation because it checks that every single byte was transferred successfully, rather than using a CHECKSUM to confirm whole blocks of data. However, it's been speedy enough to run a multiplayer pong game and to exchange long strings for a text-based murder mystery game I was working on.
I'd be happy to send you the Pong sourcecode if that would help.
Scott
#23824 - ProblemBaby - Thu Jul 22, 2004 11:25 am
Thanks for all replies!
Ive solved almost everything. Instead of the Delay I wait until the bus isnt active anymore and then also send a little counter and check that they are equal at both GBAs.
thanks everyone!
#23838 - col - Thu Jul 22, 2004 7:27 pm
ProblemBaby wrote: |
Thanks for all replies!
Ive solved almost everything. Instead of the Delay I wait until the bus isnt active anymore and then also send a little counter and check that they are equal at both GBAs.
thanks everyone! |
Checking if the units have the same frame tick value isn't the difficult part.
The real trick is what you do when they are out of sync - that's the part that causes the trouble.
What is your plan for that situation?
cheers
Col
#23842 - ProblemBaby - Thu Jul 22, 2004 10:04 pm
Well it doesnt happend... my GBAs seems to be very synchronized.
But if it happens The GBA that is out if vsync will keep send the counter
and then wait until the counter is equal again without handle the other stuff.