Content Provider zedrummer Posted December 24, 2022 Content Provider Share Posted December 24, 2022 (edited) 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 December 24, 2022 by zedrummer Link to comment Share on other sites More sharing options...
usul27 Posted December 30, 2022 Share Posted December 30, 2022 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 More sharing options...
Content Provider zedrummer Posted December 30, 2022 Author Content Provider Share Posted December 30, 2022 (edited) 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 December 30, 2022 by zedrummer Link to comment Share on other sites More sharing options...
usul27 Posted December 30, 2022 Share Posted December 30, 2022 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 More sharing options...
Content Provider zedrummer Posted December 30, 2022 Author Content Provider Share Posted December 30, 2022 OK I'm gonna do these changes. My main concern remains the C# use, I'm gonna look at it! Link to comment Share on other sites More sharing options...
usul27 Posted December 30, 2022 Share Posted December 30, 2022 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 More sharing options...
Content Provider zedrummer Posted December 30, 2022 Author Content Provider Share Posted December 30, 2022 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 More sharing options...
usul27 Posted December 31, 2022 Share Posted December 31, 2022 Are there any colorisations (even WIP) available already? Without one, it's doesn't make sense to start yet. Link to comment Share on other sites More sharing options...
Content Provider zedrummer Posted December 31, 2022 Author Content Provider Share Posted December 31, 2022 (edited) @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 December 31, 2022 by zedrummer Link to comment Share on other sites More sharing options...
Content Provider zedrummer Posted December 31, 2022 Author Content Provider Share Posted December 31, 2022 @usul27 In the end, I prefer a wrapper in C++ than changing the code, it makes things much more complicated. Do you want me to (try to) write it? Link to comment Share on other sites More sharing options...
usul27 Posted January 1, 2023 Share Posted January 1, 2023 Ok, I'll wait until some colorisations are available. I'll probably reimplement the algorithm directly in C++. One thing that's missing in the API today is some kind of trigger on specific frames or sprites. Link to comment Share on other sites More sharing options...
Content Provider zedrummer Posted January 1, 2023 Author Content Provider Share Posted January 1, 2023 (edited) 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 January 1, 2023 by zedrummer Link to comment Share on other sites More sharing options...
Content Provider zedrummer Posted January 1, 2023 Author Content Provider Share Posted January 1, 2023 (edited) 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 January 5, 2023 by zedrummer Link to comment Share on other sites More sharing options...
usul27 Posted January 5, 2023 Share Posted January 5, 2023 Thanks, that helps a bit. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now