Skip to content

Memory Lifetimes and Overlays (Unions) #22

@imjasonh

Description

@imjasonh

(from Gemini)

The NES has exactly 2KB of internal work RAM. In traditional assembly or C environments, developers heavily rely on memory overlays—sharing the same RAM addresses for different variables depending on the game state (e.g., the Title Screen variables occupy the same memory as the Level 1 Enemy Data).

What's missing: NEScript provides struct and fixed-size arrays, but there is no native construct for a union or automatic memory overlaying.

The fix: Since the compiler already has state machine constructs (state Title { ... }), the compiler could do static lifecycle analysis to automatically overlay local variables that belong to mutually exclusive states, drastically reducing the global RAM footprint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions