MADE engine fixes
|Reported by:||agent-q||Owned by:||bluegr|
This patch includes the following fixes: - Call free() on bitmapped surfaces before deleting them. If this isn't done, the surface leaks it's graphics data - In RedReader.cpp, large objects were allocated on the stack. Changed these so they're allocated on the heap instead (The DS doesn't have a large enough stack to cope). - Missing 'virtual' on resource destructors meant that the destuctors were not called, and the game leaked all resources. Made resource destructors virtual to fix this. - In scriptfuncs.cpp, added missing freeResource() when a sound finishes playing. Without this, sound resources never had their reference count decremented and therefore would never be freed from the resource cache. - To speed up script execution, only check shouldQuit() every 500 script cycles rather than on every one. This makes a huge difference to performance on the DS. - The resource cache stored up to 100 cache items before purging. Because the size of the items varies so much, the memory usage of this cache was unpredictable. I changed the cache behaviour to purge when the cache reaches a certain data size instead. kMaxResourceCacheSize in resource.h is used to set the size at which a purge should take place.
With these fixes, Return to Zork is fully playable on the DS.
It would be great if these could be applied to both trunk and 1.0 branch.
Ticket imported from: #2872409. Ticket imported from: patches/1199.