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 > Multiplayer

#23785 - Daniel Andersen - Wed Jul 21, 2004 3:28 pm

I am struggling to get some simple multiplayer code to work, but it seems only to work in no$gba, not on real hardware. On the real thing, it detects who are slave and master, though.

It seams that after initializing a send, the SIOCNT is always signalizing busy, no matter how long both master and slave waits.

Here is some code:


Code:
   ;; Setup multiplayer mode

   ; Address link
   MOV   R0, #0x04000000
   ADD   R0, R0, #0x120

   ; Initialize RCNT
   MOV   R1, #0
   STRH   R1, [R0, #0x14]

   ; Initialize SIOCNT
   MOV   R1, #0x2000
   ; ORR   R1, R1, #0x3
   STRH   R1, [R0, #0x8]

   ; Wait for all players to enter multiplayer mode
   ; <snap - works fine>

   ; Just keep looping
Loop

   ;; Wait for inactivity
SpaceDust_SendPacket_Wait1

   ; Get activity
   LDRH   R1, [R0, #0x8]
   ANDS   R10, R1, #0x80
   BNE   SpaceDust_SendPacket_Wait1

   ;; Start transfer

   ; Write outgoing data to SIODATA_SEND
   LDR   R1, [R12, -4]
   STRH   R1, [R0, #0xA]

   ; Get status
   LDRH   R1, [R0, #0x8]

   ; Check master
   ANDS   R10, R1, #0x4
   BNE   SpaceDust_SendPacket_Wait2

   ; Set start bit
   ORR   R1, R1, #0x80
   STRH   R1, [R0, #0x8]

   ;; Wait for transfer to start
SpaceDust_SendPacket_Wait2

   ; Get activity
   LDRH   R1, [R0, #0x8]
   ANDS   R1, R1, #0x80
   BEQ   SpaceDust_SendPacket_Wait2

   ;; Wait for transfer to finish
SpaceDust_SendPacket_Wait3

   ; Get activity
   LDRH   R1, [R0, #0x8]
   ANDS   R1, R1, #0x80
   BNE   SpaceDust_SendPacket_Wait3

   B   Loop


Actually, in my code it loops until indata of master is not equal to 0xFFFF. Master sends #0.

Hope someone can figure it out! :)
_________________
In a world without fences and walls you will never need gates and windows.

#23787 - Daniel Andersen - Wed Jul 21, 2004 3:31 pm

Ah, forgot to tell that in no$gba it doesn't work if selecting "normal (two players)" as link cable type. It only works if selecting "multiplayer (four players)." What's the difference?

On real hardware I got AGB-005 connected between two GBA's.
_________________
In a world without fences and walls you will never need gates and windows.

#23790 - tepples - Wed Jul 21, 2004 5:03 pm

"Normal" is the Game Boy Color link cable.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.