#66060 - Ultima2876 - Sat Jan 07, 2006 11:37 pm
I've got some normal mode multiplayer code, for sending game assets from the master to the slave (just one way communications):
There are two WaitForVsync calls in there - if they're commented, as they are above, the game crashes after sending 4 bytes (1 transfer). It only works if it waits for Vsync every frame -- surely this can't be due to speed limits? 4 bytes/frame? that's disgustingly slow o_O
The SI/SO bits should be taking care of sync here, shouldn't they? Or is there something I'm missing? I saw another topic with a very similar problem, but when the guy fixed the problem he didn't actually say what the solution was...
Are there any working examples of one-way normal mode transfers around?
Thanks for any help.
Last edited by Ultima2876 on Sun Jan 08, 2006 3:06 pm; edited 1 time in total
Code: |
void transfer_data(u8 master, u32 *data, u32 size) //master - 1 for master, 0 for slave, *data - pointer to data to send, size - size of data in bytes
{ u32 location = 0; REG_RCNT = 0; //init RCNT if(master) { //make sure size is correct if(size == 0) { return; } if(size & 3 != 0) { size += 4; } size = (size - (size & 3)) >> 2; REG_SIOCNT = 0x1001; //init SIOCNT for master while(location < size) //start sending { REG_SIODATA32 = ((u32*)data)[location]; //set the data to send while(REG_SIOCNT & 4) { } //while the SI is HIGH (slave NOT READY), wait REG_SIOCNT |= 0x80; //set the start bit to start the transfer while((REG_SIOCNT & 0x80) == 1) { } //wait for the start bit to clear (transfer done) errorcount += 1; location += 1; //WaitForVsync(); } } else { //make sure size is correct if(size == 0) { return; } if(size & 3 != 0) { size += 4; } size = (size - (size & 3)) >> 2; REG_SIOCNT = 0x1008; //init for slave (with SO HIGH, to indicate NOT READY) while(location < size) { REG_SIODATA32 = 0; //clear the data REG_SIOCNT |= 0x80; //set the start bit so that you can wait for the transfer to complete REG_SIOCNT &= 0xFFF7; //Set SO LOW - READY while(REG_SIOCNT & 0x80) { } //wait for the start bit to clear (transfer done) REG_SIOCNT |= 8; //Set SO HIGH - NOT READY ((u32*)data)[location] = REG_SIODATA32; //write the received data errorcount += 1; location += 1; //WaitForVsync(); } } } |
There are two WaitForVsync calls in there - if they're commented, as they are above, the game crashes after sending 4 bytes (1 transfer). It only works if it waits for Vsync every frame -- surely this can't be due to speed limits? 4 bytes/frame? that's disgustingly slow o_O
The SI/SO bits should be taking care of sync here, shouldn't they? Or is there something I'm missing? I saw another topic with a very similar problem, but when the guy fixed the problem he didn't actually say what the solution was...
Are there any working examples of one-way normal mode transfers around?
Thanks for any help.
Last edited by Ultima2876 on Sun Jan 08, 2006 3:06 pm; edited 1 time in total