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

Every sound driver is always linked in #320

Open
joeyparrish opened this issue Mar 29, 2024 · 0 comments
Open

Every sound driver is always linked in #320

joeyparrish opened this issue Mar 29, 2024 · 0 comments

Comments

@joeyparrish
Copy link
Contributor

joeyparrish commented Mar 29, 2024

I have found that my ROMs always contain every sound driver. After analyzing the symbols and tracing their usage, I found this chain of calls is responsible:

_start_entry() => internal_reset() => Z80_init() => Z80_loadDriver().

And because Z80_loadDriver() and Z80_unloadDriver() reference all SGDK drivers, all drivers and their table data are always linked into every ROM, whether you use them or not.

I can't think of a reason I wouldn't know what driver I had loaded. Even if I might need more than one in different parts of my game, I would have enough state to keep track of what was loaded.

So I propose we deprecate and remove Z80_loadDriver(), Z80_unloadDriver(), and Z80_getLoadedDriver(). Games should call the load and unload methods of their drivers directly.

When I tried these changes locally, I found that I was able to strip 33552 bytes from "int main() { return 0; }". I eliminated 1380 more bytes by decoupling XGM2_doVBlankFadeProcess() from src/sys.c via a callback.

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

1 participant