Difference between revisions of "MGS"
From MSX Game Library
(→Decode) |
|||
Line 36: | Line 36: | ||
// Decode a string and if valid, output a data stream and return true | // Decode a string and if valid, output a data stream and return true | ||
// Parameters: | // Parameters: | ||
− | // code [in] Crypted code | + | // $code [in] Crypted code |
− | // key [in] Decoder key (game specific) | + | // $key [in] Decoder key (game specific) |
− | // data [out] Data stream (bytes array) | + | // $data [out] Data stream (bytes array) |
// Return: | // Return: | ||
// true if decode succeed | // true if decode succeed |
Revision as of 18:38, 26 May 2025
MSX Game Scores (MGS) is an online leaderboard platform for MSX games: https://aoineko.org/mgs.
It allows players to submit their high scores using codes generated by the games themselves. Developers can integrate score encoding into their games, and once submitted, the scores are verified server-side and displayed on public leaderboards. The goal is to bring a modern, competitive scoring system to new MSX games.
Note: The MGS site has the same author but is not directly linked to MSXgl, even though this library includes tools to help generate score code.
Contents
How do I add my game to MGS?
Generate a score code
The basic idea is that your MSX game must generate a code that encodes the relevant data:
- the score,
- the corresponding leaderboard (if there are several),
- and any other useful information for your game.
For example, in a racing game, besides the time to complete the race (the score) and the track (the leaderboard), you might also want to record the used car model, whether the player used a manual or automatic gearbox, etc.
You are free to use any technique you want to encrypt your data. Just make sure the encoding is strong enough to prevent someone from inputting random codes and getting a valid score. MSXgl provides a C module for encoding data than can be easily adapt to other development environment.
Add your game to MGS
After that, the game and its leaderboards have to be added to the MGS site. For now, this is a manual process that is handled directly by the site owner (MRC user Aoineko).
Finally, the interface for converting score code to leaderboard entry needs to be created. It consist of several PHP functions (the site owner can help you write them).
Decode
If you are not using MSXgl encryption feature in your MSX game, you will have to provide your own decrypt function in PHP (a language that looks a lot like C). This function have to check the validity of the submitted code and, if valid, generates the entry to be added to the leaderboard.
Function prototype:
// Decode a string and if valid, output a data stream and return true // Parameters: // $code [in] Crypted code // $key [in] Decoder key (game specific) // $data [out] Data stream (bytes array) // Return: // true if decode succeed function Decode(string $code, string $key, array &$data): bool {}
I have some example PHP functions available, but I can also write them for you if needed. To decode the score code, you’ll need to write in PHP the inverse function of the one used on MSX. If you use the MSXgl score encoding function, the corresponding PHP decoding function is already available.