Each Maestro file is held in memory as nine blocks of bytes: one for 'Gate' data, and eight for Note information for each audio channel. Currently, Maestro reserves a very big WimpSlot of 720K, divides the space between the end of the program and the end of the Wimpslot by 9 to get equally spaced pointers for each byte block, and then writes data to them without any bounds checking. This is very wasteful (Maestro files are typically only 1-2K in size), and there's nothing to prevent writes from running off the end of the Wimpslot and trampling over something else.
This merge request:
- Adds a set of heap management procedures
- Removes the existing memory management system, and holds all data in resizable heap blocks instead, with checks on overruns
- Removes the EnsureRMA check, which was only present because of Maestro's outsized WimpSlot request on older machines with less RAM
Admin: Tested on a variety of Maestro files. There's still plenty of inefficiency in the way Maestro handles its data, but with the largest file I could find, with Sprites11 loaded, the Wimpslot goes down to 380K.