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

The background refactor (completely rethink backgrounds) #827

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

gwilymk
Copy link
Member

@gwilymk gwilymk commented Jan 29, 2025

Massive change to how backgrounds work and a fundamental shift to how agb works in general. The main thing this is trying to achieve is to make it easier to manage multiple backgrounds or backgrounds where you only need to do something briefly.

See the code in the dungeon puzzler example for how hard it was previously to do backgrounds easily.

This makes as much of a difference as switching from the 'unmanaged' sprites to the 'managed' sprites. You can suddenly have dynamically allocated backgrounds, and don't have to set them all up at the beginning. You can switch background tile modes as needed with affine (although affine support is still lacking a little due to some changes needed in the tile allocation).

Main changes:

  1. Backgrounds are no longer created at the beginning, and instead created 'on the fly'
  2. The VRamManager is now global. So you no longer need to thread it through, and also removes lifetimes from the map code. This allowed removal of many, many lifetimes in the example games.
  3. The InfiniteScrolledMap API is much, much simpler. You now pass the tile selection function to the set_pos call which allows for easier dynamically generated items.
  4. The DynamicTile is now just a constructor call, and it automatically gets rid of itself when it gets dropped.
  5. You don't need to call .clear on backgrounds any more.

Removals:

  1. In order to support this, bitmap modes have been removed entirely. They were previously a fairly major soundness issue within agb, and with a global vram manager they would have to be entirely unsafe.

Still TODO:

  • Documentation
  • Changelog update
  • DynamicTile's .tileset return is incorrect. Ideally we want to be able to use it with InfiniteScrolledMap
  • The hat chooses the wizard example needs a few fixes

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

Successfully merging this pull request may close these issues.

2 participants