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

#14140 - dagamer34 - Wed Dec 31, 2003 3:32 am

I cannot find any solid to really get me started in coding a multiplayer app. I have found only one demo that works, Multiplayer Pong, but it didn't come with source.

When looking at old posts, people kept talking about this site:
http://downtou.cjb.net/ but I can't seem to access it for its tutorials. Is it still up? If not, does anybody have the source so I can look at it?

And when trying to compile the mbclient from www.devrs.com/gba/mbclient.txt, I get these errors:


/cygdrive/c/DOCUME~1/Jeofrey/LOCALS~1/Temp/cclrTLrd.s: Assembler messages:
/cygdrive/c/DOCUME~1/Jeofrey/LOCALS~1/Temp/cclrTLrd.s:8631: Error: bad instruction `lsr r2,#24'
/cygdrive/c/DOCUME~1/Jeofrey/LOCALS~1/Temp/cclrTLrd.s:8649: Error: Bad arguments to instruction
NMAKE : fatal error U1077: 'C:\Consoles\GBA\DevKits\DevKitAdv\v4\bin\gcc' : return code '0x1'
Stop.
Error executing NMAKE.

Thaks for all your help!
_________________
Little kids and Playstation 2's don't mix. :(

#14143 - crossraleigh - Wed Dec 31, 2003 4:04 am

The SGADE has a nice multiplayer module as well an explanatory demo.

If you are wanting multiboot (i.e., multiplayer using only one cartridge), I don't know where else to send you besides Jeff's example. As far as the compilation problems, it looks like you don't have the -mthumb option enabled.

#14169 - dagamer34 - Wed Dec 31, 2003 3:31 pm

I'm pretty sure its enabled. But it still does not want to work. Where would I put it in a makefile? In the compile flags or linker flags?

My makefile:

PROJECT = GBALibTest

# -------------------------------------------
# Define some directories;
# -------------------------------------------

# -------------------------------------------
# Base Directory for gcc arm-agb-elf replace with
# wherever you put your gba devkitadv files.
# -------------------------------------------

DEVDIR = C:\Consoles\GBA\DevKits\DevKitAdv\v4

# -------------------------------------------
# Source directory (where your project's source files are located.)
# -------------------------------------------

SRCDIR = C:\Consoles\GBA\Projects\DevKitAdv\GBALibTest\

# -------------------------------------------
# Compiler Directories for binaries, includes and libs.
# -------------------------------------------

CMPDIR = $(DEVDIR)\bin
LIBDIR = $(DEVDIR)\lib\gcc-lib\arm-agb-elf\3.0.2\interwork
LIBDIR2 = $(DEVDIR)\arm-agb-elf\lib\interwork
INCDIR = $(DEVDIR)\lib\gcc-lib\arm-agb-elf\3.0.2\include
INCDIR2 = $(DEVDIR)\arm-agb-elf\include

# -------------------------------------------
# END of directory defines
# -------------------------------------------

# -------------------------------------------
# Define what extensions we use;
# -------------------------------------------
.SUFFIXES : .cpp .c .s

# -------------------------------------------
# Define the flags for the compilers;
# -------------------------------------------
CFLAGS = -I $(INCDIR2) -I $(INCDIR) -I $(SRCDIR) -mthumb -mthumb-interwork -c -g -O2 -Wall -fverbose-asm
SFLAGS = -I $(INCDIR2) -I $(INCDIR) -mthumb-interwork
LDFLAGS = -L $(LIBDIR) -L $(LIBDIR2) -T LinkScript

# -------------------------------------------
# Define the list of all O files;
# Just follow the syntax shown to add any
# other objects your project may need to
# compile properly. You will need to add
# files to this part to make it work with
# your project add a \ to the end of all o
# files except the last one. Like below.
# -------------------------------------------

O_FILES = \
crt0.o \
crtbegin.o \
crtend.o \
GBALibTest.o


# -------------------------------------------
# There should be no need to modify anything
# below here.
# -------------------------------------------

# -------------------------------------------
# Define the final dependecy;
# -------------------------------------------
all : $(PROJECT).gba

# -------------------------------------------
# Define the copy from .elf to .bin file
# -------------------------------------------
$(PROJECT).gba : $(PROJECT).elf
$(CMPDIR)\objcopy -v -O binary $(PROJECT).elf $(PROJECT).gba
-@echo ------------------------------------------
-@echo Done
-@echo ------------------------------------------

# -------------------------------------------
# Define the linker instruction;
# -------------------------------------------
$(PROJECT).elf : $(O_FILES)
$(CMPDIR)\ld $(LDFLAGS) -o $(PROJECT).elf $(O_FILES) -lstdc++ -lm -lgcc -lc -lgcc

-@echo ------------------------------------------
-@echo Linking Done
-@echo ------------------------------------------

# -------------------------------------------
# Define each compile;
# -------------------------------------------
{$(SRCDIR)}.cpp.o::
$(CMPDIR)\gcc $(CFLAGS) $<
-@echo ------------------------------------------
-@echo CPP-Sources Compiled
-@echo ------------------------------------------

{$(SRCDIR)}.c.o::
$(CMPDIR)\gcc $(CFLAGS) $<
-@echo ------------------------------------------
-@echo C-sources Compiled
-@echo ------------------------------------------

# -------------------------------------------
# Define each assemble;
# -------------------------------------------
{$(SRCDIR)}.s.o:
$(CMPDIR)\as $(SFLAGS) $(SRCDIR)\$*.s -o$@
-@echo ------------------------------------------
-@echo ASM-Sources Compiled
-@echo ------------------------------------------
_________________
Little kids and Playstation 2's don't mix. :(

#14172 - johnny_north - Wed Dec 31, 2003 5:27 pm

Try removing the -O2 from your compile options. I think it causes problems with Jeff's inline assembly.

#14173 - dagamer34 - Wed Dec 31, 2003 5:47 pm

Changing the option to -O makes no difference. The funny thing is that i just tried using a batch file and it worked! What's the diff?

path=C:\Consoles\GBA\DevKits\DevKitAdv\v4\bin

gcc -o GBALibTest.elf GBALibTest.cpp -lstdc++ -lm -lgcc -lc -mthumb -mthumb-interwork

objcopy -O binary GBALibTest.elf GBALibTest.gba

pause

This makefile stuff is just screwing me over.
_________________
Little kids and Playstation 2's don't mix. :(

#14175 - johnny_north - Wed Dec 31, 2003 6:52 pm

When I was new to makefiles, I was having similar problems. Figuring out a massive group of makefile wild cards is difficult. Search the forums for a recent makefile post by me. I gave an example of a functional mikefile for a c++ project using Jeff F's crt0 and linkscript. This file uses no wildcards.

#14179 - Miked0801 - Wed Dec 31, 2003 9:05 pm

<evil laugh> Welcome to the Hell that is GBA multiplayer. It took us months and months to get a 2 player game 100% solid while allowing HBlank interrupts to interrupt it w/o causing packet loss and then another month to get it extended to 4 player. GBA sucks nearly as bad as GBC at multiplayer. Unless you really, really, really, need multiplayer (or enjoy a whole bunch of pain), don't go there. It's a big pain in the ass with almost no good sources to get it working correctly. Oh and the Nintendo sample code for it is a big joke - as usual :)

Mike

#14186 - dagamer34 - Wed Dec 31, 2003 11:23 pm

So that's why there is little documentation for it. Those who can't get i give up, and those who do get it KEEP it to themselves by signing some kind of contract.

Why does it always happen this way....

So there is absolutely no hope for me? All i need is for it to send some little data, like the position of a sprite, between 2 GBAs and that would be good enough for me.

Thanks for your help anyway.
_________________
Little kids and Playstation 2's don't mix. :(

#15066 - ScottLininger - Fri Jan 16, 2004 8:28 pm

http://www.thingker.com/gba/MultiplayerV1.zip

I just got this thing working last night, and YES, multiplayer is a pain to make stable.

I'm sure once this code starts getting used in games with interrupts, it'll be back to the drawing board.

;)

Scott

#15100 - dagamer34 - Sat Jan 17, 2004 2:42 am

Hmm... thats a pretty good example!!! Though, why are you using variables in EWRAM? Does the program assume that there is some random value in EWRAM?? And is this meant to be flashed onto a cart or replicated like Jeff's multiboot replicating example?

This does show me what packets are and how they work, briefly. If possible, and I get the hell we like to call multiplayer to work, I think I'll work on a tutorial.

Does everybody use agbtty for printing letters to the screen?

And how would you do error and drop-checking?
_________________
Little kids and Playstation 2's don't mix. :(

#15136 - ScottLininger - Sat Jan 17, 2004 9:01 pm

The demo is indeed meant to be run as a MULTIBOOT (and replicated to the slave GBA like Jeff's demo--in fact, that part of the code is pretty much exactly from his program.) Any reference to EWRAM is just because of the multiboot.

However, the basic idea would work cart-to-cart as well (with no multiboot) I just haven't tried that yet. I'll give it a shot and post and update when I get a chance.

#15138 - ScottLininger - Sat Jan 17, 2004 9:21 pm

dagamer34 wrote:

Does everybody use agbtty for printing letters to the screen?

And how would you do error and drop-checking?


agbtty is just one of many options. I use it because I have it working and it's versatile.

"Error checking," i.e. making sure packets don't get corrupted in transfer, is sort-of built into the code, since the transfer will keep trying until each and every packet is transferred and sent back by the other players.

"Drop checking," i.e. figuring out when someone is disconnected, is a little more complex. I guess the simple thing would be to keep track of how many times you've tried to send a packet without any response, and if you've tried 1000 times without success you assume something's disconnected. I need to dig back into the IO registers and see if there's anything that gives you more useful information.

I know that when a gameboy is "not connected," its data register is set to 0xFFFF, but I'm pretty sure that this is also the default state for connected gameboys that are simply not sending anything. We'll just need to experiment.

#15148 - dagamer34 - Sun Jan 18, 2004 1:54 am

What about the error bit that is set in the REG_SIOCNT register? Doesn't that tell when an error has occured (other than lost packets)??

Once, I successfully send a MB ROM from a flash cart, however, I didn't know anything about multiplayer. I'll try to see if i can get it working again, maybe send you the code, whatever I have, so we can get this &$#@ thing to work.

I envy those who have the official GBA docs... how do they figure this stuff out anyway!?!?!?!?
_________________
Little kids and Playstation 2's don't mix. :(

#15201 - Miked0801 - Sun Jan 18, 2004 10:27 pm

We don't. We have (had) to guess like the rest of you and burn months of man hours to get it working. The Nintendo example code barely works (it might if it was the only thing running) and doesn't stay in sync. The code samples on the net are better sources than Nintendo stuff. Nintedo docs are not the holy grail.