From 82d4f89d5353184e35ff843cfb0b0b9bca619dac Mon Sep 17 00:00:00 2001 From: Ludvig Strigeus Date: Sat, 13 Apr 2002 21:06:48 +0000 Subject: added null graphics driver (USE_NULL_DRIVER) will make it nicer later. svn-id: r3931 --- simon/simon.cpp | 16 ++++++++++++++-- simon/simon.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'simon') diff --git a/simon/simon.cpp b/simon/simon.cpp index f995b8a7f1..0a1aeb2aba 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -131,7 +131,7 @@ FILE *fopen_maybe_lowercase(const char *filename) { byte *SimonState::allocateItem(uint size) { byte *org = _itemheap_ptr; - size = (size + 1) & ~1; + size = (size + 3) & ~3; _itemheap_ptr += size; _itemheap_curpos += size; @@ -142,8 +142,16 @@ byte *SimonState::allocateItem(uint size) { return org; } +void SimonState::alignTableMem() { + if ((uint32)_tablesheap_ptr & 3) { + _tablesheap_ptr += 2; + _tablesheap_curpos += 2; + } +} + byte *SimonState::allocateTable(uint size) { byte *org = _tablesheap_ptr; + size = (size + 1) & ~1; _tablesheap_ptr += size; @@ -527,7 +535,11 @@ void SimonState::readSubroutine(FILE *in, Subroutine *sub) { } Subroutine *SimonState::createSubroutine(uint id) { - Subroutine *sub = (Subroutine*)allocateTable(sizeof(Subroutine)); + Subroutine *sub; + + alignTableMem(); + + sub = (Subroutine*)allocateTable(sizeof(Subroutine)); sub->id = id; sub->first = 0; sub->next = _subroutine_list; diff --git a/simon/simon.h b/simon/simon.h index 6e98eee821..8fbcf4d346 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -592,6 +592,7 @@ public: byte *allocateItem(uint size); byte *allocateTable(uint size); + void alignTableMem(); Child *findChildOfType(Item *i, uint child); Child *allocateChildBlock(Item *i, uint type, uint size); -- cgit v1.2.3