Jump to content

Serum cross-platform library


zedrummer

Recommended Posts

  • Content Provider

Hello

 

I have coded a cross-platform open-source C library to use Serum files inside your own programs.

It is available here https://github.com/zesinger/libserum with all the explanations on how to use it.

 

Only tested on Windows x86 for now, but the release for Windows x64, Android Arm64, Linux x64, MacOS, MacOS x64 and MacOS Arm64 are available too.

If you test on any of these platform, please report here.

 

Many thanks to @mk47 for his help on the Github stuff

 

Thanks

David

Edited by zedrummer
Link to comment
Share on other sites

Looks good for the beginning. I plan to experiment a bit with this. However, some comments on improvements:
You're using a lot of untyped byte-buffers for data structures that are not bytes. E.g. palette and rotation are fixed-length buffers. Why not use an array of structs for these? This would make the code more readable and the compiler can do type-checking without any impact on performance.

If there is interest in this I can work on this and create a PR.

Link to comment
Share on other sites

  • Content Provider

Hello and thanks for your interest.

When you say "Looks good for the beginning", do you mean that you see many features that are missing? I think the format is complete. Certainly, there will be some additions, but as such, it can colorize any ROM, no?

The reason why I don't use such data structures is because, for me, the content of these buffers is always use as a block. I never specifically need to read the green component of the 13th colour, the rotations are transfered like that to the devices.

Moreover, the DLL is in C and is, for now, mainly used in DMD-extensions, in C#. I have been coding in Assembler and C. But C# and all this OO programming is a pain in my ..., so it was way easier for me to use simple byte buffers as parameters to communicate between them than structures.

Edited by zedrummer
Link to comment
Share on other sites

The problem with a 'block' is that the compiler cannot do any range checking at all. Using structs and arrays allows at least some minimal checks and would make the code easier readable. 

If there is no specific interest from your side I won't touch this code and probably just do a C++ wrapper around to implement a typed API.

Link to comment
Share on other sites

While theoretically C# can be used cross-platform, no one seriously uses it outside the Windows ecosystem. Therefore, I wouldn't even try as this would complicate things seriously.
I understand why it's used in Windows applications, but serious cross-platform libraries are either C or C++ (modern C++ has definitely a lot advantages to C, but you don't want to use this).

Link to comment
Share on other sites

  • Content Provider

C# is not my choice, but initially the Serum file format was aimed to be used with DMD-extensions.

And, object-oriented coding is too much for my messy brain! C is perfect for me and the easier to use with other languages I think.

Link to comment
Share on other sites

  • Content Provider

@usul27 Only WIPs, but you can easily run ColorizingDMD, colorize the 2 or 3 first frames shown at rom start and use it to check if it works. (put a colour rectangle in the middle of the frame and that's enough to be sure it works)

 

Edited by zedrummer
Link to comment
Share on other sites

  • Content Provider

Moving to C++ should be really easy (way easier than C<->C#). Do you intend to generate a C++ DLL?
Be careful not to mimic the behaviour of VNI and PAC files, the Serum file format relies on frames and not on animations. Each format has to go its own way. Why do you need this triggers?

Edited by zedrummer
Link to comment
Share on other sites

  • Content Provider

Hello @usul27 with the joined file, you should have this display when running Champion Pub when the ROM "cp_16" starts if Serum is working:

 

 

 

The color rotation is only working with compatible device (VirtualDMD with freezy's DmdDevice.dll and with ZeDMD, for the moment). As I suppose you will use your own code and if you don't use ZeDMD, you'll only have the blue gradient with no colour rotation. But that will be enough to be sure that Serum is working as expected.

 

I hope it will help :) !

 

cp_16.cRZ

Edited by zedrummer
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...