Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LSDj 9.2.0+ #19

Open
jkotlinski opened this issue Mar 5, 2021 · 4 comments
Open

Support LSDj 9.2.0+ #19

jkotlinski opened this issue Mar 5, 2021 · 4 comments

Comments

@jkotlinski
Copy link
Owner

jkotlinski commented Mar 5, 2021

Interrupts and sample playback changed. Basically nothing works anymore.

@jkotlinski jkotlinski changed the title Support LSDj 9.2.0+ sample+wave playback Support LSDj 9.2.0+ Apr 15, 2021
@binarycounter
Copy link

Heyo! Thanks for making LSDj and this tool!
I'd love to get 9.2.0+ support working to include music in a SGB demo.

I made a quick change to lsdpack.cpp and some libgambatte files to basically replace the LCD Interrupt handler with a Timer interrupt handler, changing otherwise nothing.

I've then recorded a 9.3.3 tune in DMG mode (because CGB has double speed timers, halving the song tempo in the player) and built the example boot.s.

Sample / wavetable playback is a bit scratchy (player.s probably needs to be updated with improved wave swap routine) but otherwise the song seems to play fine. If i can get the wave channel playing nicely, would you be interested in a pull request?

@jkotlinski
Copy link
Owner Author

jkotlinski commented Nov 5, 2023 via email

@binarycounter
Copy link

Awesome, thank you. I have forked the repository and pushed my changes of lsdpack. Will pull request later once i think it's finished.

The way I am currently handling compatibility with older versions is to check the version number in the GB header of the ROM and decide which interrupts to capture based on that, with optional command-line flags to override the auto-detection.
I have not tested v4 specifically, but compatibility should remain identical with previous lsdpack versions, unless someone edited the ROM header (then they would need to use the command-line flag to force <9.1.C mode).
Note: I moved setting the interrupt handler inside load_gb to be able to do it on a per-ROM basis, so you could mix old and new versions.

Sample playback is actually not that bad, I'm just noticing more crackling as the player swaps out the wave. Looking at recordings it seems like newer LSDj versions have a much more graceful way of swapping waves, which doesn't cause such a noticable audio spike. Definitely seeing some differences stepping through the code. It seems faster overall (putting the data on the stack and then pop-sliding it). I will investigate later. If you have any pointers of where I should be looking at, please let me know.

The test file i'm currently using ends up being 328k big, so I'd love to also look into compression like you mentioned. A few days ago I've experimented with implementing a LZ77/78 style compression scheme (for another playback routine) that works on a command basis rather than byte basis . Rather than needing to compress and decompress the data, it relies on the routine's loop and referencing commands to deduplicate data, so other than some pointer manipulation it's fairly light on the CPU. I got decent results there, and will look into getting it working for this too.

Sorry for the long read :)

@jkotlinski
Copy link
Owner Author

jkotlinski commented Nov 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants