diff options
-rw-r--r-- | sound/mods/module.cpp | 13 | ||||
-rw-r--r-- | sound/mods/module.h | 16 |
2 files changed, 6 insertions, 23 deletions
diff --git a/sound/mods/module.cpp b/sound/mods/module.cpp index d6f1d3eb4d..9a518f482a 100644 --- a/sound/mods/module.cpp +++ b/sound/mods/module.cpp @@ -33,12 +33,7 @@ bool Module::load(Common::ReadStream &st) { st.read(songname, 20); songname[20] = '\0'; - // FIXME: We define sample to have 32 entries, - // yet we only setup 31 of these -- is this on - // purpose, or an off-by-one error? This should - // be clarified by either adding a comment explaining - // this odditiy, or by fixing the off-by-one-bug. - for (int i = 0; i < 31; ++i) { + for (int i = 0; i < NUM_SAMPLES; ++i) { st.read(sample[i].name, 22); sample[i].name[22] = '\0'; sample[i].len = 2 * st.readUint16BE(); @@ -79,7 +74,7 @@ bool Module::load(Common::ReadStream &st) { } } - for (int i = 0; i < 31; ++i) { + for (int i = 0; i < NUM_SAMPLES; ++i) { if (!sample[i].len) sample[i].data = 0; else { @@ -96,14 +91,14 @@ bool Module::load(Common::ReadStream &st) { Module::Module() { pattern = 0; - for (int i = 0; i < 31; ++i) { + for (int i = 0; i < NUM_SAMPLES; ++i) { sample[i].data = 0; } } Module::~Module() { delete[] pattern; - for (int i = 0; i < 31; ++i) { + for (int i = 0; i < NUM_SAMPLES; ++i) { delete[] sample[i].data; } } diff --git a/sound/mods/module.h b/sound/mods/module.h index f56e42767b..b62a8f47cb 100644 --- a/sound/mods/module.h +++ b/sound/mods/module.h @@ -28,19 +28,6 @@ namespace Modules { -/* - * FIXME: Is the following comment still valid? If so, - * it should be marked accordingly, and maybe added to our - * TODO list on the Wiki (conserving memory is always a big - * boon for our smaller targets). - * - * Storing notes and patterns like this - * wastes insane amounts of memory. - * - * They should be stored in memory - * like they are in the file. - */ - #include "common/pack-start.h" // START STRUCT PACKING struct note_t { @@ -67,7 +54,8 @@ class Module { public: byte songname[21]; - sample_t sample[32]; + static const int NUM_SAMPLES = 31; + sample_t sample[NUM_SAMPLES]; byte songlen; byte undef; |