Looking for technical PSO information

Sylverant is a homebrew open source server for Phantasy Star Online. Dreamcast users still play PSO online with this server even today! This is the official forum for both the online game server as well as the open source project itself. Feel free to post and get a gathering started online! We can also show you how to get connected!

Moderators: BlueCrab, Aleron Ives

Post Reply
Triadic
DCEmu Newbie
DCEmu Newbie
Posts: 6
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Jan 10, 2014 11:41 am
Has thanked: 0
Been thanked: 0

Looking for technical PSO information

Post by Triadic »

Hi guys

I've started taking quite a bit of interest in PSO lately, and i want to get into understanding how PSO works from a client / server standpoint and the protocols that are involved. I come from a background of c++ , c#, and ruby. I have glanced over the sylverant source code and i get the gist of what is going on.

I want to be able to add custom content to the game via client & server modifications, along with nearly seamless cross platform gaming. I know that's saying a lot. I'm not really asking for all of the answers, but more of a place to start looking.

I would to find out how much of the game's logic is handled client side vs server side. As well as any map singing / encryption methods.

So yea, i know what I'm asking is a huge amount of information, like i said, i am just looking for place to start looking.
User avatar
Aleron Ives
DCEmu Nutter
DCEmu Nutter
Posts: 872
Joined: Wed Jan 05, 2011 2:15 pm
Location: California
Has thanked: 0
Been thanked: 25 times
Contact:

Re: Looking for technical PSO information

Post by Aleron Ives »

Aside from decompiling the game, the only other place to look is in the Sylverant source, which you've already browsed. Facilitating things like cross-platform play requires massive amounts of work on the server side, since altering the client isn't an option with disc-based games.
"Fear the HUnewearl."
Image
Triadic
DCEmu Newbie
DCEmu Newbie
Posts: 6
Joined: Fri Jan 10, 2014 11:41 am
Has thanked: 0
Been thanked: 0

Re: Looking for technical PSO information

Post by Triadic »

What makes the GC version of the game so different from the other versions? Maps / quests?
User avatar
Aleron Ives
DCEmu Nutter
DCEmu Nutter
Posts: 872
Joined: Wed Jan 05, 2011 2:15 pm
Location: California
Has thanked: 0
Been thanked: 25 times
Contact:

Re: Looking for technical PSO information

Post by Aleron Ives »

Aside from packet differences (which are relatively easy to adjust, as DC/PC has significant differences that are already accounted for), the main problem with GC is that Sega arbitrarily changed the maps. One of the ways PSO minimises network traffic is to refer to map objects by number, e.g. pressing a switch to open a door relays packets saying that player 1 pressed switch object 38 to unlock door object 87. If the GC map has that same switch as object 39 or the door as object 88, PSO freaks out when it thinks you used a switch to unlock a box (or any other invalid, mismatched object relationship).

Consequently, the only way to make DC/PC and GC not crash when playing together is to make an entire translation table of which object is which in every single freeplay map so that the server can forge packets to make the object numbers coincide with what the target client expects them to be. It isn't particularly difficult to do, but it's tedious and time consuming, which is why it hasn't been done yet (aside from the other gameplay differences that make cross-platform gaming problematic, even without such bugs).
"Fear the HUnewearl."
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

As Ives has said, cross-platform play (at least between all versions except Blue Burst) is extremely tedious and error-prone to do. Other than the mapping of objects and such, pretty much everything else should "just work" in Sylverant as it is, hence why DC/PC games can enable GC compatibility mode and GC users can join -- it just requires those extra steps to make sure people know the problems that can occur.

Blue Burst is a whole other can of worms, however. While it is possible to get it to work, it would probably require disassembling multiple versions of the game, and it would require the server to do a lot more work than it would otherwise have to. Not a fun task at all, and a whole lot more difficult than the GC/DC/PC compatibility.
Triadic
DCEmu Newbie
DCEmu Newbie
Posts: 6
Joined: Fri Jan 10, 2014 11:41 am
Has thanked: 0
Been thanked: 0

Re: Looking for technical PSO information

Post by Triadic »

I don't know really how far i will take it, but it has sparked my curiosity for now.

I guess i need to grab a copy of wireshark and start analyzing the protocol, hopefully there not any encryption involved.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

Everything is encrypted, with the exception of the initial encryption setup packet. You're better off reading the Sylverant source code for the communication protocols. :wink:
Triadic
DCEmu Newbie
DCEmu Newbie
Posts: 6
Joined: Fri Jan 10, 2014 11:41 am
Has thanked: 0
Been thanked: 0

Re: Looking for technical PSO information

Post by Triadic »

I see

I've been browsing the source and making notes. I have come across a few things i have some questions on. First, it looks like all of the ports are defined in login_server.c. Is the purpose of each port known? I originally thought it might have something to do with localization. As in american clients connect on one port and Japanese clients on another, but i am not really sure.

Second i see that a lot of strings are limited to 16 characters, is this because the game tries to fit the entire string in a single packet and nothing larger will fit?

Also what are the purpose of the web ports?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

Well, keep in mind that the login server only handles the initial part of the communications. Actual gameplay takes place on the ship server. That has a lot more code dealing with packets than does the login server (both share the packets.h file you're probably looking at, but the "master" version of that is in the ship server as well). :wink:

As you initially suspected, different region/version clients connect on different ports to the login server. That's all there is to it there. As for string length, it's not so much an issue of the packet length (since TCP packets can be up to 4GiB in length, in theory -- not that the Dreamcast would be able to accept such a large packet, especially considering some of the really braindead stuff that the TCP stack on the DC did), that's just how the game does things. There's no special magic to it, that's just the maximum length that the strings needed to be in Sega's opinion. That said, there are plenty of packets that don't have a 16-byte max length for strings, such as those for talking on the ship server.

As for the web ports, that's used by the website to check the status of the login server. That's completely specific to Sylverant itself and has nothing to do with the game. 8-)
Triadic
DCEmu Newbie
DCEmu Newbie
Posts: 6
Joined: Fri Jan 10, 2014 11:41 am
Has thanked: 0
Been thanked: 0

Re: Looking for technical PSO information

Post by Triadic »

BlueCrab wrote:Well, keep in mind that the login server only handles the initial part of the communications. Actual gameplay takes place on the ship server. That has a lot more code dealing with packets than does the login server (both share the packets.h file you're probably looking at, but the "master" version of that is in the ship server as well). :wink:

As you initially suspected, different region/version clients connect on different ports to the login server. That's all there is to it there. As for string length, it's not so much an issue of the packet length (since TCP packets can be up to 4GiB in length, in theory -- not that the Dreamcast would be able to accept such a large packet, especially considering some of the really braindead stuff that the TCP stack on the DC did), that's just how the game does things. There's no special magic to it, that's just the maximum length that the strings needed to be in Sega's opinion. That said, there are plenty of packets that don't have a 16-byte max length for strings, such as those for talking on the ship server.

As for the web ports, that's used by the website to check the status of the login server. That's completely specific to Sylverant itself and has nothing to do with the game. 8-)
Ah, thats makes quite a bit more sense. I was assuming the game was limiting all packets to a small size, possibly because of connection quality back in the DC era. Do you happen to know which ports are assigned to each localization? If not i can probably figure it out. Are the different clients in each region limited to a specific subset of languages?

So are NTST-J and NTSC-U/C combined into one port? Or is PAL and NTSC-U/C combined in one port?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

It depends on the version of the game you're talking about how the ports are combined.

For the Dreamcast versions, all regions for PSOv1 and PSOv2 used port 9200, except for the Eurpoean versions when running in 50hz mode, which used port 9201. Port 9000 was used by the Dreamcast Network Trial Edition, as is commented in the source code.

As for the Gamecube versions, I believe that the Japanese versions used ports 9000, 9001, 9002, and 9003; the US versions used ports 9100 and 9103; and the European versions used ports 9200, 9201, and 9203 (yes, two of these overlap with the Dreamcast version, hence the odd code for sorting out what version is connecting in the source code). I'm not entirely positive of those assignments, as it's been a while since I actually checked. :wink: The xxx3 ports are all for Episode III, by the way (and 9002 is the Trial Edition of Episode III).

Language-wise, all non-trial versions have all languages that are supported on a given release; although I believe the translations were updated between the Japanese and US/EU releases, at least with the Dreamcast version. The Trial versions are all Japanese-only.

That said, I'd think that there's usually very little need to differentiate what regional variant of a game that a particular user is using, and there are other ways to do it than just the port number. Sylverant really doesn't make any differentiation of regions, as I've yet to find a reason to actually do so. :wink:
Triadic
DCEmu Newbie
DCEmu Newbie
Posts: 6
Joined: Fri Jan 10, 2014 11:41 am
Has thanked: 0
Been thanked: 0

Re: Looking for technical PSO information

Post by Triadic »

BlueCrab wrote:It depends on the version of the game you're talking about how the ports are combined.

For the Dreamcast versions, all regions for PSOv1 and PSOv2 used port 9200, except for the Eurpoean versions when running in 50hz mode, which used port 9201. Port 9000 was used by the Dreamcast Network Trial Edition, as is commented in the source code.

As for the Gamecube versions, I believe that the Japanese versions used ports 9000, 9001, 9002, and 9003; the US versions used ports 9100 and 9103; and the European versions used ports 9200, 9201, and 9203 (yes, two of these overlap with the Dreamcast version, hence the odd code for sorting out what version is connecting in the source code). I'm not entirely positive of those assignments, as it's been a while since I actually checked. :wink: The xxx3 ports are all for Episode III, by the way (and 9002 is the Trial Edition of Episode III).

Language-wise, all non-trial versions have all languages that are supported on a given release; although I believe the translations were updated between the Japanese and US/EU releases, at least with the Dreamcast version. The Trial versions are all Japanese-only.

That said, I'd think that there's usually very little need to differentiate what regional variant of a game that a particular user is using, and there are other ways to do it than just the port number. Sylverant really doesn't make any differentiation of regions, as I've yet to find a reason to actually do so. :wink:
I wonder why they would decide to host over so many ports if the servers essentially were the same. I could see if it was redirecting to different ports which had different servers behind them for load balancing. I'll probably never know that answer.

Sorry for all of the questions :mrgreen: lol. I just want to ensure i have my head properly wrapped around this :wink:

So i see a lot of code the only specifies DC and BB (especially in packets.h). Should i be assuming that the DC packets are identical to the GC and PC packets?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

For the most part, the DC and GC packets are identical -- where they are different there are different structures defined in the code. Packets for the PC version have a slightly different header, hence why there are a lot of structures with things that look like this at the top:

Code: Select all

    union {
        dc_pkt_hdr_t dc;
        pc_pkt_hdr_t pc;
    } hdr;
All versions prior to Blue Burst use a 4-byte long header. Blue Burst uses an 8-byte long header, hence why it's packets are separated out. Many of them are identical to the earlier versions with the exception of the header. However, because of how I cast pointers all over the place, I have to have different structure definitions for those packets (the union approach only works if all the types in the union are the same length).
User avatar
RyoDC
Mental DCEmu
Mental DCEmu
Posts: 366
Joined: Wed Mar 30, 2011 12:13 pm
Has thanked: 2 times
Been thanked: 0

Re: Looking for technical PSO information

Post by RyoDC »

Always wondered what this stuff for:

Code: Select all

uint32_t grave_coords_time[5];
            char grave_team[20];
            char grave_message[24];
in v2_player struct.
How do I try to build a Dreamcast toolchain:
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

RyoDC wrote:Always wondered what this stuff for:

Code: Select all

uint32_t grave_coords_time[5];
            char grave_team[20];
            char grave_message[24];
in v2_player struct.
For the player's grave in Challenge Mode (which marks the last place where the user died while playing that mode).
User avatar
Didi
DCEmu Freak
DCEmu Freak
Posts: 70
Joined: Mon Sep 30, 2013 9:44 am
Location: Brasil
Has thanked: 0
Been thanked: 1 time
Contact:

Re: Looking for technical PSO information

Post by Didi »

Leveraging the topic, anyone here knows and could tell how to enable Challenge mode and windows trade in private server of the PSOBB?
Passatempo favorito: Jogar os diversos PSOs
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5665
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Looking for technical PSO information

Post by BlueCrab »

Well, if we're talking about Sylverant it is unimplmented, so without additional code, you cannot. I believe the same goes for Tethealla, as I don't remember ever seeing any code to do so in that server either.

I haven't really studied PSOBB enough to comment on anything for sure with regard to either, but I'd suspect that the trade window could be done in a very similar fashion to how Sylverant handles it for PSOGC, except with the additional step of updating both sides' inventory on the server as well. Once again, that is pure conjecture, but it seems at least logical on its face.
Post Reply