aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWon Star2006-06-29 09:17:04 +0000
committerWon Star2006-06-29 09:17:04 +0000
commit7169e90fadd2f6929cf6b599db3afe531175cf9b (patch)
tree0d00fbef1575787032294f9067ea2cb72111b49f
parent5e7d109e3cac8c46f3842df4988f082579de7ffa (diff)
downloadscummvm-rg350-7169e90fadd2f6929cf6b599db3afe531175cf9b.tar.gz
scummvm-rg350-7169e90fadd2f6929cf6b599db3afe531175cf9b.tar.bz2
scummvm-rg350-7169e90fadd2f6929cf6b599db3afe531175cf9b.zip
Properly init memory tables.
svn-id: r23342
-rw-r--r--backends/gp32/gp32_main.cpp7
-rw-r--r--backends/gp32/gp32std_memory.cpp19
2 files changed, 18 insertions, 8 deletions
diff --git a/backends/gp32/gp32_main.cpp b/backends/gp32/gp32_main.cpp
index 2175141f2e..50227308a6 100644
--- a/backends/gp32/gp32_main.cpp
+++ b/backends/gp32/gp32_main.cpp
@@ -38,9 +38,6 @@
GlobalVars g_vars;
void init() {
- extern void memChunkInit();
- memChunkInit();
-
gp_setCpuSpeed(40); // Default CPU Speed
GpGraphicModeSet(16, NULL);
@@ -58,6 +55,9 @@ void init() {
}
void GpMain(void *arg) {
+ extern void memChunkInit();
+ memChunkInit();
+
init();
readConfigVars();
@@ -84,6 +84,7 @@ void GpMain(void *arg) {
extern void memChunkDeinit();
memChunkDeinit();
+
g_system->quit(); // TODO: Consider removing / replacing this!
//return res;
diff --git a/backends/gp32/gp32std_memory.cpp b/backends/gp32/gp32std_memory.cpp
index d39d3b95a3..3d5a11b6cb 100644
--- a/backends/gp32/gp32std_memory.cpp
+++ b/backends/gp32/gp32std_memory.cpp
@@ -1,6 +1,8 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001-2006 The ScummVM project
- * Copyright (C) 2006 Won Star - GP32 Backend
+ * Copyright (C) 2002 Ph0x - GP32 Backend
+ * Copyright (C) 2003/2004 DJWillis - GP32 Backend
+ * Copyright (C) 2005/2006 Won Star - GP32 Backend
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -52,7 +54,7 @@ protected:
static int prevBlock;
// Linked list is slow for this task. :)
- static MemBlock block[NUM_BLOCK];
+ static MemBlock *block;
byte *block;
size_t size;
@@ -74,23 +76,30 @@ byte *MemBlock::userMem = NULL;
//size_t MemBlock::allocSize = 0;
int MemBlock::numBlock = 0;
int MemBlock::prevBlock = 0;
-MemBlock MemBlock::block[NUM_BLOCK];
+MemBlock *MemBlock::block = NULL;
void MemBlock::init()
{
userMem = (byte *)gm_malloc(USER_MEMORY_SIZE + USER_BLOCK_SIZE);
- if (!userMem) {
+ block = (MemBlock *)gm_malloc(NUM_BLOCK * sizeof(MemBlock));
+
+ if (!(userMem && block)) {
//error
}
+
+ memset(userMem, 0, USER_MEMORY_SIZE + USER_BLOCK_SIZE);
+ memset(block, 0, NUM_BLOCK * sizeof(MemBlock));
}
void MemBlock::deinit()
{
- if (!userMem) {
+ if (!(userMem && block)) {
//error
}
gm_free(userMem);
+ gm_free(block);
userMem = NULL;
+ block = NULL;
}
void *MemBlock::addBlock(size_t size)