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

create struct screenDisplayBuffer type (cellDisplayBuffer[COLS][ROWS] ---> screenDisplayBuffer) #625

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

Nathan-Fenner
Copy link
Contributor

Before this change, most of the time, a cellDisplayBuffer buf[COLS][ROWS] was created wherever needed. Now, you can spell this as screenDisplayBuffer buf;

There are a few ways that this is nicer:

  • The new type remembers the correct size for the buffer, so it doesn't have to be written down [COLS][ROWS] every time
  • The new type is a struct instead of an array, so it has more-consistent semantics: no pointer decay; taking references is explicit instead of implicit, etc.

This PR just swaps out all of the existing cellDisplayBuffer arrays to references to this new type. There's no other changes.


Eventually, I'd like to refactor a bit more, so that the screen is more "encapsulated" - references to .cells should be restricted to a handful of functions, so that the screen buffer can become a higher-level data structure (e.g. we could eventually store info about "layers" or "effects" to make the view prettier on platforms that support it). Having a consistent "screen" type is an important basic step to make that happen.

@Nathan-Fenner Nathan-Fenner changed the title create screenDisplayBuffer type (buffer of drawn characters for the whole screen) create struct screenDisplayBuffer type (cellDisplayBuffer[COLS][ROWS] ---> screenDisplayBuffer) Nov 19, 2023
@flend
Copy link
Collaborator

flend commented Nov 25, 2023

Makes sense to me.

@flend flend merged commit eee0dd4 into tmewett:release Dec 2, 2023
1 check passed
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