Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2015-01-07 03:43:08

ShantyTown
Member
Registered: 2013-12-04
Post 169/344

Pokered/crystal Battle Server

Some emulators, like BGB, support connecting over the internet so you can battle and trade with friends.  Wouldn't it be cool if you could battle and trade with a random person?

The idea is to create a server that manages connections between emulators and routes messages between them.  I would imagine that it would work something like this:

1.  Set ip address in BGB (or whatever emulator) to the server's ip.
2.  Talk to the link cable lady in the Pokemon centers.
3.  The emulator (client) will then send out the game's serial messages to the server.
4.  While the lady says "Please wait...", the server will find another client who is in the "Please wait..." phase.
5.  Finally, the server will just relay the serial messages to each client as if they were communicating directly.

This seems feasible to me, but I don't have any experience building anything where connections are managed and there is message passing going on.  I'd love to hear people's thoughts on this.

One obvious downside is that if nobody is connecting to the server, then you're never going to be able to find a person to battle or trade with.

Offline

#2 2015-01-07 04:16:05

pokeglitch
Member
Registered: 2013-02-20
Post 80/95

Re: Pokered/crystal Battle Server

I think its a good idea, I just have a few comments/questions:

1) Would it be emulator specific?  Or do most emulators use the same protocol for this?
2) Could we directly modify an emulator source code, like the javascript emulators, to skip the need for your step 1 (the emulator would need to be hosted on the server as well)
3) How does the game actually receive data while linked?  I see the cable_club.asm on the repository, but didn't find the routine where the game stores the data from the linked gameboy (or sends data).
--Changing this will allow for more than battling/trading (I know someone mentioned a 2 player pokemon red hack somewhere on here).

Offline

#3 2015-01-07 04:26:20

ShantyTown
Member
Registered: 2013-12-04
Post 170/344

Re: Pokered/crystal Battle Server

pokeglitch wrote:

I think its a good idea, I just have a few comments/questions:

1) Would it be emulator specific?  Or do most emulators use the same protocol for this?
2) Could we directly modify an emulator source code, like the javascript emulators, to skip the need for your step 1 (the emulator would need to be hosted on the server as well)
3) How does the game actually receive data while linked?  I see the cable_club.asm on the repository, but didn't find the routine where the game stores the data from the linked gameboy (or sends data).
--Changing this will allow for more than battling/trading (I know someone mentioned a 2 player pokemon red hack somewhere on here).

1) That's a great question.  I don't know.  My guess would be that they're different.
2) Yes, I guess you could hardcode that into the emulator?  I'm not sure what you meant by the emulator needing to be hosted on the server.
3) I believe there is a register (or two?) that the data is written to.  To receive the data, that register is just polled a bunch of times to read it one byte at a time.  I haven't looked at that stuff in awhile, so I might be a little off.

Regarding the very last thing you said, it's already possible to directly connect to another emulator.  The server would just allow for random pairings of emulators.

Offline

#4 2015-01-07 06:17:08

comet
Member
Registered: 2012-04-09
Post 498/679

Re: Pokered/crystal Battle Server

The link cable transmits very small amounts of data very quickly.  TCP/IP does the inverse (larger packets less frequently). The link cable is so fast that sending and receiving a byte is simultaneous. Most games assume this and use the received byte to decide what to send next, rather than trading bigger chunks of data. As a result, two emulators on separate machines must send and receive each byte one at a time over TCP/IP, slowing execution to a crawl. Stag and I tried it once in bgb. It took an hour (really!) to trade one Pokemon.

The accepted solution to this problem is to emulate both sides on each client, and send/receive joypad input instead. This means trading packets once per frame, instead of dozens of times or more (a rough estimate being 50 times a frame, going by the earlier example).

pokecrystal of course does have code to connect to a server over http using the mobile adapter. Instead of playing it straight it could be useful to modify an emulator like gameboy-online to cheat and do regular server things and then drop the received data into sram at your convenience.

There was a multiplayer version of Pokemon Red that did something similar, but it was only up for a few hours before being taken down.

Offline

#5 2015-01-07 06:50:45

ShantyTown
Member
Registered: 2013-12-04
Post 171/344

Re: Pokered/crystal Battle Server

Darn, I was hoping latency wouldn't be a big issue.  I just assumed that because bgb had that functionality, it worked at normal speed.  It seems to work at normal speed when connecting to a localhost emulator, but of course there isn't much latency there since they're on the same machine...

I'm actually surprised that it took an hour.  It seems like you should be able to transmit around 5 bytes/second if you're dealing with a 100ms ping, and I would expect there to only be a couple hundred bytes that need to be sent.  (10? for a handshake and 100? for the pokemon data?)

Offline

#6 2015-01-08 07:45:58

stag019
Idea Killer
Registered: 2011-01-05
Post 613/630

Re: Pokered/crystal Battle Server

It sends/receives data whether there's data to be sent or not. It so that the two emulators can be kept in sync. It simply sends a 00 byte when there's no data to be sent. So it has to transmit that byte every frame, on top of some overall protocol bytes to help keep it in sync too. In an older version of BGB that was 4 bytes of overall data per 1 byte of link cable data, but I think the newer versions ups that to 6 or 8 or something.

It does transmit all those 6 or 8 bytes as one packet though.


You can try to hide yourself in this world of pretend; when the paper's crumpled up, it can't be perfect again.

Offline

#7 2016-08-04 12:36:23

wisejustin
Member
From: Kanto
Registered: 2015-01-04
Post 49/131

Re: Pokered/crystal Battle Server

i like this idea, is it still being though about? would love to set something up like this for my hack, allowing people to battle/trade wirelessly

Offline

#8 2016-10-05 20:56:18

FIQ
Member
Registered: 2016-09-17
Post 3/79

Re: Pokered/crystal Battle Server

Isn't the link cable more tolerant to latency in GB/GBC compared to GBA (where it's basically like you describe) meaning it works all right over the net?

Otherwise, I feel like the most straightforward way to make this would probably be a custom script to interface with emulators' link protocols and make the games aware of it (so a custom link protocol, kinda, and needing a patch to go with it).

Last edited by FIQ (2016-10-05 20:57:35)

Offline

#9 2016-10-05 22:47:19

MechanicalPen
Member
Registered: 2016-06-22
Post 22/29

Re: Pokered/crystal Battle Server

Pokemon Crystal already supports (or did) online battling / trading. The servers are obviously offline now, but with a boatload of work we could reverse engineer and/or re-implement the protocol and host our own server.

Offline

Board footer

Powered by FluxBB