diff options
author | pixel <pixel> | 2004-05-03 12:55:04 +0000 |
---|---|---|
committer | pixel <pixel> | 2004-05-03 12:55:04 +0000 |
commit | 5b1e50428eab9ea1d141b84e4579d77ac7b8f2d9 (patch) | |
tree | d1b008ff2f7e02bcf849587842e0c9548347e530 /lib/luacd.cpp | |
parent | 2371bb1ad54636e4f3f8524af65f37b64ef96a2a (diff) |
Still, various fixes, changes, improvements, new bug added, etc...
Diffstat (limited to 'lib/luacd.cpp')
-rw-r--r-- | lib/luacd.cpp | 75 |
1 files changed, 64 insertions, 11 deletions
diff --git a/lib/luacd.cpp b/lib/luacd.cpp index 2c10b3f..97efe82 100644 --- a/lib/luacd.cpp +++ b/lib/luacd.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: luacd.cpp,v 1.12 2004-05-02 21:04:45 pixel Exp $ */ +/* $Id: luacd.cpp,v 1.13 2004-05-03 12:55:04 pixel Exp $ */ #include "luacd.h" @@ -48,6 +48,9 @@ enum cdutils_methods_t { CDUTILS_FINDPARENT, CDUTILS_FINDDIRENTRY, CDUTILS_NEWCDFILE, + CDUTILS_UPDATESIZE, + CDUTILS_UPDATESECTOR, + CDUTILS_CREATESECTOR, }; enum cdutils_functions_t { @@ -58,6 +61,7 @@ enum cdutils_functions_t { CDUTILS_TO_BCD, CDUTILS_IS_VALID_BCD, CDUTILS_FROM_MSF, + CDUTILS_TO_MSF, }; struct lua_functypes_t cdutils_methods[] = { @@ -76,6 +80,9 @@ struct lua_functypes_t cdutils_methods[] = { { CDUTILS_FINDPARENT, "findparent", 1, 1, {LUA_STRING} }, { CDUTILS_FINDDIRENTRY, "finddirentry", 2, 2, {LUA_OBJECT, LUA_STRING} }, { CDUTILS_NEWCDFILE, "cdfile", 1, 3, {LUA_ANY, LUA_NUMBER, LUA_NUMBER} }, + { CDUTILS_UPDATESIZE, "updatesize", 2, 2, {LUA_STRING, LUA_NUMBER} }, + { CDUTILS_UPDATESECTOR, "updatesector", 2, 2, {LUA_STRING, LUA_NUMBER} }, + { CDUTILS_CREATESECTOR, "createsector", 2, 3, {LUA_NUMBER, LUA_NUMBER, LUA_BOOLEAN} }, { -1, 0, 0, 0, 0 } }; @@ -87,6 +94,7 @@ struct lua_functypes_t cdutils_functions[] = { { CDUTILS_TO_BCD, "to_BCD", 1, 1, {LUA_NUMBER} }, { CDUTILS_IS_VALID_BCD, "is_valid_BCD", 1, 1, {LUA_NUMBER} }, { CDUTILS_FROM_MSF, "from_MSF", 1, 4, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} }, + { CDUTILS_TO_MSF, "to_MSF", 1, 2, {LUA_NUMBER, LUA_NUMBER} }, { -1, 0, 0, 0, 0 } }; @@ -107,6 +115,9 @@ class sLua_cdutils : public Base { DECLARE_METHOD(cdutils, CDUTILS_FINDPARENT); DECLARE_METHOD(cdutils, CDUTILS_FINDDIRENTRY); DECLARE_METHOD(cdutils, CDUTILS_NEWCDFILE); + DECLARE_METHOD(cdutils, CDUTILS_UPDATESIZE); + DECLARE_METHOD(cdutils, CDUTILS_UPDATESECTOR); + DECLARE_METHOD(cdutils, CDUTILS_CREATESECTOR); DECLARE_FUNCTION(cdutils, CDUTILS_NEWCDUTILS); DECLARE_FUNCTION(cdutils, CDUTILS_SWAPWORD); @@ -115,6 +126,7 @@ class sLua_cdutils : public Base { DECLARE_FUNCTION(cdutils, CDUTILS_TO_BCD); DECLARE_FUNCTION(cdutils, CDUTILS_IS_VALID_BCD); DECLARE_FUNCTION(cdutils, CDUTILS_FROM_MSF); + DECLARE_FUNCTION(cdutils, CDUTILS_TO_MSF); private: static int cdutils_proceed(Lua * L, int n, cdutils * obj, int caller); @@ -139,6 +151,9 @@ void Luacdutils::pushmembers(Lua * L) { PUSH_METHOD(cdutils, CDUTILS_FINDPARENT); PUSH_METHOD(cdutils, CDUTILS_FINDDIRENTRY); PUSH_METHOD(cdutils, CDUTILS_NEWCDFILE); + PUSH_METHOD(cdutils, CDUTILS_UPDATESIZE); + PUSH_METHOD(cdutils, CDUTILS_UPDATESECTOR); + PUSH_METHOD(cdutils, CDUTILS_CREATESECTOR); } void Luacdutils::pushstatics(Lua * L) throw (GeneralException) { @@ -152,6 +167,7 @@ void Luacdutils::pushstatics(Lua * L) throw (GeneralException) { PUSH_FUNCTION(cdutils, CDUTILS_TO_BCD); PUSH_FUNCTION(cdutils, CDUTILS_IS_VALID_BCD); PUSH_FUNCTION(cdutils, CDUTILS_FROM_MSF); + PUSH_FUNCTION(cdutils, CDUTILS_TO_MSF); L->push("MODE0"); L->push((lua_Number) MODE0); @@ -216,8 +232,8 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { Handle * h; Byte sdatas[2352], * datas; String path; - cdutils::DirEntry * dir, * bdir, * adir; - bool invalid = false; + cdutils::DirEntry * dir, * bdir, * adir, pdir; + bool invalid = false, eof = false; int sector; cdfile * cdf; @@ -228,13 +244,13 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { break; case CDUTILS_GUESSTYPE: if (n == 1) { - sect = L->tonumber(); + sect = L->tonumber(2); } L->push((lua_Number) cd->guess_type(sect)); r = 1; break; case CDUTILS_SECTORSEEK: - sect = L->tonumber(); + sect = L->tonumber(2); cd->sector_seek(sect); break; case CDUTILS_READSECTOR: @@ -382,20 +398,20 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { break; case CDUTILS_NEWCDFILE: if (L->istable(2)) { - if (n <= 3) { + if (n <= 2) { dir = (cdutils::DirEntry *) LuaObject::getme(L, 2); - if (n == 3) + if (n == 2) mode = L->tonumber(3); cdf = new cdfile(cd, dir, mode); } else { invalid = true; } } else if (L->isnumber(2)) { - if (n >= 2) { + if (n >= 1) { sector = L->tonumber(2); - if (n >= 3) + if (n >= 2) size = L->tonumber(3); - if (n == 4) + if (n == 3) mode = L->tonumber(4); cdf = new cdfile(cd, sector, size, mode); } else { @@ -412,6 +428,31 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { r = 1; } break; + case CDUTILS_UPDATESIZE: + case CDUTILS_UPDATESECTOR: + path = L->tostring(2); + pdir = cd->find_parent(path); + dir = cd->find_path(&datas, path); + switch (caller) { + case CDUTILS_UPDATESIZE: + dir->Size = tolittle((Uint32) L->tonumber(3)); + dir->BESize = tobig((Uint32) L->tonumber(3)); + break; + case CDUTILS_UPDATESECTOR: + dir->Sector = tolittle((Uint32) L->tonumber(3)); + dir->BESector = tobig((Uint32) L->tonumber(3)); + break; + } + cd->write_datas(datas, pdir.Size, GUESS, pdir.Sector); + free(datas); + break; + case CDUTILS_CREATESECTOR: + mode = L->tonumber(2); + sect = L->tonumber(3); + if (n == 3) + eof = L->toboolean(4); + cd->create_sector(mode, sect, eof); + break; } @@ -422,7 +463,7 @@ int sLua_cdutils::cdutils_proceed_statics(Lua * L, int n, int caller) { int r = 0; Uint32 x; Handle * isor = 0, * isow = 0; - Uint32 msf, start = 150; + Uint32 sector, msf, start = 150; Byte m, s, f; switch(caller) { @@ -476,6 +517,18 @@ int sLua_cdutils::cdutils_proceed_statics(Lua * L, int n, int caller) { } r = 1; break; + case CDUTILS_TO_MSF: + sector = L->tonumber(1); + if (n == 2) + start = L->tonumber(2); + cdutils::to_MSF(sector, m, s, f, start); + msf = cdutils::to_MSF(sector, start); + L->push((lua_Number) msf); + L->push((lua_Number) m); + L->push((lua_Number) s); + L->push((lua_Number) f); + r = 4; + break; } return r; |