diff options
-rw-r--r-- | sword2/module.mk | 1 | ||||
-rw-r--r-- | sword2/startup.cpp | 55 | ||||
-rw-r--r-- | sword2/sword2.h | 2 | ||||
-rw-r--r-- | sword2/tony_gsdk.cpp | 55 |
4 files changed, 35 insertions, 78 deletions
diff --git a/sword2/module.mk b/sword2/module.mk index 167db14c5e..7061020a39 100644 --- a/sword2/module.mk +++ b/sword2/module.mk @@ -26,7 +26,6 @@ MODULE_OBJS := \ sword2/startup.o \ sword2/sword2.o \ sword2/sync.o \ - sword2/tony_gsdk.o \ sword2/walker.o \ sword2/driver/d_draw.o \ sword2/driver/d_sound.o \ diff --git a/sword2/startup.cpp b/sword2/startup.cpp index d8ccd12089..f4b19dbce8 100644 --- a/sword2/startup.cpp +++ b/sword2/startup.cpp @@ -18,6 +18,7 @@ */ #include "common/stdafx.h" +#include "common/file.h" #include "sword2/sword2.h" namespace Sword2 { @@ -30,10 +31,9 @@ uint32 Logic::initStartMenu(void) { // We query each in turn and setup an array of start structures. // If the file doesn't exist then we say so and return a 0. - uint32 end; - mem *temp; + File fp; + uint32 pos = 0; - uint32 j = 0; char *raw_script; uint32 null_pc; @@ -45,30 +45,45 @@ uint32 Logic::initStartMenu(void) { debug(5, "initialising start menu"); - if (!(end = _vm->readFile("startup.inf", &temp, UID_temp))) { - debug(5, "Init_start_menu cannot open startup.inf"); - return 0; // meaning no start menu available + if (!fp.open("startup.inf")) { + warning("initStartMenu: cannot open startup.inf - the debugger won't have a start menu"); + return 0; } - // Ok, we've loaded in the startup.inf file which contains a list of - // all the files now extract the filenames + // The startup.inf file which contains a list of all the files. Now + // extract the filenames + + while (1) { + bool done = false; + + while (1) { + byte b = fp.readByte(); - do { - while (temp->ad[j] != 13) { // item must have an #0d0a - ascii_start_ids[_totalScreenManagers][pos] = temp->ad[j]; - j++; + if (fp.ioFailed()) { + done = true; + break; + } + + // Each item ends with CRLF + if (b == 13) { + fp.readByte(); + break; + } + + if (pos < 7) + ascii_start_ids[_totalScreenManagers][pos] = b; pos++; } + if (done) + break; + // NULL terminate our extracted string ascii_start_ids[_totalScreenManagers][pos] = 0; // reset position in current slot between entries pos = 0; - // past the 0a - j += 2; - // done another _totalScreenManagers++; @@ -76,7 +91,9 @@ uint32 Logic::initStartMenu(void) { debug(5, "WARNING MAX_starts exceeded!"); break; } - } while (j <end); + } + + fp.close(); // using this method the Gode generated resource.inf must have #0d0a // on the last entry @@ -88,8 +105,8 @@ uint32 Logic::initStartMenu(void) { // instance a startup could be set for later in the game where // specific vars are set - for (j = 0; j < _totalScreenManagers; j++) { - _startRes = atoi(ascii_start_ids[j]); + for (uint i = 0; i < _totalScreenManagers; i++) { + _startRes = atoi(ascii_start_ids[i]); debug(5, "+querying screen manager %d", _startRes); @@ -111,8 +128,6 @@ uint32 Logic::initStartMenu(void) { debug(5, "- resource %d invalid", _startRes); } - _vm->_memory->freeMemory(temp); - return 1; } diff --git a/sword2/sword2.h b/sword2/sword2.h index df3ee91bd7..0839611c7d 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -361,8 +361,6 @@ public: void sleepUntil(uint32 time); - uint32 readFile(const char *name, mem **membloc, uint32 uid); - void errorString(const char *buf_input, char *buf_output); void initialiseFontResourceFlags(void); void initialiseFontResourceFlags(uint8 language); diff --git a/sword2/tony_gsdk.cpp b/sword2/tony_gsdk.cpp deleted file mode 100644 index 31c6dbf616..0000000000 --- a/sword2/tony_gsdk.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 1994-2003 Revolution Software Ltd - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Header$ - */ - -// general odds and ends - -#include "common/stdafx.h" -#include "common/file.h" -#include "sword2/sword2.h" - -namespace Sword2 { - -uint32 Sword2Engine::readFile(const char *name, mem **membloc, uint32 uid) { - // read the file in and place into an allocated MEM_float block - - File fh; - uint32 size; - - if (!fh.open(name)) { - debug(5, "Read_file cannot open %s", name); - return 0; - } - - size = fh.size(); - - // reserve enough floating memory for the file - *membloc = _memory->allocMemory(size, MEM_float, uid); - - if (fh.read((*membloc)->ad, size) != size) { - debug(5, "Read_file read fail %d", name); - return 0; - } - - fh.close(); - - // ok, done it - return bytes read - return size; -} - -} // End of namespace Sword2 |