From 4984ff4a7cdc181aa8d4ff913ddc4323e77f4bca Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 16 May 2009 21:43:21 +0000 Subject: Adding cd/dvdabstract classes to the lua exports. --- lib/luacd.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'lib') diff --git a/lib/luacd.cpp b/lib/luacd.cpp index b619905..881f5ae 100644 --- a/lib/luacd.cpp +++ b/lib/luacd.cpp @@ -30,6 +30,12 @@ Luacdutils::Luacdutils(cdutils * _cd) : cd(_cd) { } class Luacdfile : public LuaHandle { public: Luacdfile(cdfile * h) : LuaHandle(h) {} + void pushmembers(Lua * L) { + LuaHandle::pushmembers(L); + L->push("__handletype"); + L->push("cdfile"); + L->settable(-3, true); + } }; enum cdutils_methods_t { @@ -1713,3 +1719,99 @@ int sLua_isobuilder::isobuilder_proceed_statics(Lua * L, int n, int caller) { return r; } + + + /********************************\ +|** the various abstract classes **| + \********************************/ + +class sLuacdabstract : public Base { + public: + static int cdprobe(lua_State * L); + static int new_cdabstract(lua_State * L); +}; + +int sLuacdabstract::cdprobe(lua_State * __L) { + Lua * L = Lua::find(__L); + + if (!cdabstract::canprobe()) + return 0; + + L->newtable(); + std::vector probed = cdabstract::probe(); + int j = 1; + + for (std::vector::iterator i = probed.begin(); i != probed.end(); i++, j++) { + L->push((lua_Number) j); + L->push(*i); + L->settable(); + } + + return 1; +} + +int sLuacdabstract::new_cdabstract(lua_State * __L) { + Lua * L = Lua::find(__L); + int n = L->gettop(); + + if ((n != 1) || !L->isstring()) { + L->error("Incorrect arguments to constructor `cdabstract'"); + } + + Luacdabstract m(cdabstract::open_cd(L->tostring())); + m.pushdestruct(L); + + return 1; +} + +Luacdabstract::Luacdabstract(Handle * h) : LuaHandle(h) { } + +void Luacdabstract::pushconstruct(Lua * L) { + L->declarefunc("cdprobe", sLuacdabstract::cdprobe); + L->declarefunc("cdabstract", sLuacdabstract::new_cdabstract); +} + +void Luacdabstract::pushmembers(Lua * L) { + LuaHandle::pushmembers(L); + L->push("__handletype"); + L->push("cdabstract"); + L->settable(-3, true); +} + +class sLuadvdabstract : public Base { + public: + static int new_dvdabstract(lua_State * L); +}; + +int sLuadvdabstract::new_dvdabstract(lua_State * __L) { + Lua * L = Lua::find(__L); + int n = L->gettop(); + bool forwrite = false; + String fname; + + if ((n > 2) || (n < 1) || !L->isstring(1)) { + L->error("Incorrect arguments to constructor `dvdabstract'"); + } + + if (n == 2) + forwrite = L->toboolean(2); + fname = L->tostring(1); + + Luadvdabstract m(new dvdabstract(forwrite ? (Handle *) new Output(fname, 0, 0) : (Handle *) new Input(fname))); + m.pushdestruct(L); + + return 1; +} + +Luadvdabstract::Luadvdabstract(dvdabstract * h) : LuaHandle(h) { } + +void Luadvdabstract::pushconstruct(Lua * L) { + L->declarefunc("dvdabstract", sLuadvdabstract::new_dvdabstract); +} + +void Luadvdabstract::pushmembers(Lua * L) { + LuaHandle::pushmembers(L); + L->push("__handletype"); + L->push("dvdabstract"); + L->settable(-3, true); +} -- cgit v1.2.3 From 2f6b22ede60a89cced23d499cd77413b9301a16d Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 25 May 2009 04:15:43 +0000 Subject: Adding the option to read or not the size in the lzss_decomp routine. --- includes/lzss.h | 2 +- lib/lzss.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/includes/lzss.h b/includes/lzss.h index 14aa345..8ba3fb5 100644 --- a/includes/lzss.h +++ b/includes/lzss.h @@ -59,7 +59,7 @@ class lzss : public Base { int tolerate, blockb; int blk, bitmap_count; - unsigned int lzss_decomp(Handle * f_source, Handle * f_cible, int true_length = -1); + unsigned int lzss_decomp(Handle * f_source, Handle * f_cible, int true_length = -1, bool read_length = true); void lzss_comp(Handle * f_source, Handle * f_cible, int * delta = NULL); Byte swap_bits(Byte); diff --git a/lib/lzss.cpp b/lib/lzss.cpp index 1d7ecfb..7d86a32 100644 --- a/lib/lzss.cpp +++ b/lib/lzss.cpp @@ -105,7 +105,7 @@ void lzss::compute_limits(void) { printm(M_INFO, "Computed values: maxsize = %i, maxptr = 0x%06x\n", lzss_maxsize, lzss_maxptr); } -unsigned int lzss::lzss_decomp(Handle * f_source, Handle * f_cible, int true_length) +unsigned int lzss::lzss_decomp(Handle * f_source, Handle * f_cible, int true_length, bool read_length) { unsigned char bitmap, fbitmap; unsigned char valeur; @@ -125,7 +125,8 @@ unsigned int lzss::lzss_decomp(Handle * f_source, Handle * f_cible, int true_len compute_limits(); - f_source->read(&length, 4); + if (read_length) + f_source->read(&length, 4); if (true_length >= 0) { length = true_length; } -- cgit v1.2.3 From 07c79ea1a1b015c8c8f5ea4bb4b8b5c2aaf6f4b9 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 9 Jun 2009 18:42:24 -0700 Subject: Adding dvdmode to the dirtree object. --- includes/isobuilder.h | 2 ++ lib/isobuilder.cpp | 12 +++++++----- lib/luacd.cpp | 9 ++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/includes/isobuilder.h b/includes/isobuilder.h index 16a3a4d..88ab91a 100644 --- a/includes/isobuilder.h +++ b/includes/isobuilder.h @@ -63,12 +63,14 @@ class isobuilder : public Base { DirTree * Child(); DirTree * Brother(); DirTree * Find(const String &); + void setdvdmode(); private: int buildpath_r(int * n, Byte * data, int size, int current_level, int level_to_dump, bool bigendian) throw (GeneralException); int maxlevel(int current_level = 1); DirTree * father, * child, * brother; bool dir; int node; + bool dvdmode; }; isobuilder(Handle * w, int mode = MODE2_FORM1); ~isobuilder(); diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp index 9bec34c..d3d9e1b 100644 --- a/lib/isobuilder.cpp +++ b/lib/isobuilder.cpp @@ -88,6 +88,8 @@ isobuilder::DirTree::DirTree(isobuilder::DirTree * _father, bool _dir) : mode(-1 if (!father) return; + + dvdmode = father->dvdmode; creation = father->creation; @@ -99,6 +101,10 @@ isobuilder::DirTree::DirTree(isobuilder::DirTree * _father, bool _dir) : mode(-1 } } +isobuilder::DirTree::setdvdmode() { + dvdmode = true; +} + isobuilder::DirTree::~DirTree() { while (child) { delete child; @@ -266,10 +272,6 @@ int isobuilder::DirTree::buildentry(Byte * buffer, int spaceleft, bool put_xa) { memset(pbuf, 0, 256); - if (name == "BM2.ELF") { - printm(M_INFO, "GRON"); - } - if (name == ".") { N = 1; pbuf[0] = 0; @@ -279,7 +281,7 @@ int isobuilder::DirTree::buildentry(Byte * buffer, int spaceleft, bool put_xa) { } else { strcpy(pbuf, name.to_charp()); N = name.strlen(); - if (!dir) { + if ((!dir) && !dvdmode) { N += 2; strcat(pbuf, ";1"); } diff --git a/lib/luacd.cpp b/lib/luacd.cpp index 881f5ae..6855b9a 100644 --- a/lib/luacd.cpp +++ b/lib/luacd.cpp @@ -1126,6 +1126,7 @@ enum DirTree_methods_t { DIRTREE_FROMDIR, DIRTREE_SETBASICSXA, DIRTREE_FIND, + DIRTREE_SETDVDMODE, }; enum DirTree_functions_t { @@ -1136,8 +1137,9 @@ struct lua_functypes_t DirTree_methods[] = { { DIRTREE_INDEX, "index", 1, 1, { BLUA_STRING } }, { DIRTREE_NEWINDEX, "newindex", 2, 2, { BLUA_STRING, BLUA_ANY } }, { DIRTREE_FROMDIR, "fromdir", 1, 1, { BLUA_OBJECT } }, - { DIRTREE_SETBASICSXA, "setbasicsxa", 0, 0, 0 }, + { DIRTREE_SETBASICSXA, "setbasicsxa", 0, 0, { } }, { DIRTREE_FIND, "find", 1, 1, { BLUA_STRING } }, + { DIRTREE_SETDVDMODE, "setdvdmode", 0, 0, { } }, { -1, 0, 0, 0, 0 } }; @@ -1153,6 +1155,7 @@ class sLua_DirTree : public Base { DECLARE_METHOD(DirTree, DIRTREE_FROMDIR); DECLARE_METHOD(DirTree, DIRTREE_SETBASICSXA); DECLARE_METHOD(DirTree, DIRTREE_FIND); + DECLARE_METHOD(DirTree, DIRTREE_SETDVDMODE); DECLARE_FUNCTION(DirTree, DIRTREE_NEWDIRTREE); private: @@ -1169,6 +1172,7 @@ void LuaDirTree::pushmembers(Lua * L) { PUSH_METHOD(DirTree, DIRTREE_FROMDIR); PUSH_METHOD(DirTree, DIRTREE_SETBASICSXA); PUSH_METHOD(DirTree, DIRTREE_FIND); + PUSH_METHOD(DirTree, DIRTREE_SETDVDMODE); } void LuaDirTree::pushstatics(Lua * L) throw (GeneralException) { @@ -1204,6 +1208,9 @@ int sLua_DirTree::DirTree_proceed(Lua * L, int n, DirTree * dir, int caller) { L->push(); } break; + case DIRTREE_SETDVDMODE: + dir->setdvdmode(); + break; case DIRTREE_INDEX: key = L->tostring(2); r = 1; -- cgit v1.2.3 From e0940305791e86f442cd761de486deb344b8e939 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 9 Jun 2009 20:31:47 -0700 Subject: Fixing printdir. --- lib/luacd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/luacd.cpp b/lib/luacd.cpp index 6855b9a..9c4e55a 100644 --- a/lib/luacd.cpp +++ b/lib/luacd.cpp @@ -484,7 +484,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) { L->error("Cdutils object void"); break; case CDUTILS_PRINTDIR: - path = L->tostring(1); + path = L->tostring(2); if (cd) { char * f; cdutils::DirEntry dir = cd->find_path(f = path.strdup()); -- cgit v1.2.3 From 4a015a9287f60cfb528da3c637d46a8d4b5ec104 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 10 Jun 2009 03:33:35 +0000 Subject: Typo... --- lib/isobuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp index d3d9e1b..54d9368 100644 --- a/lib/isobuilder.cpp +++ b/lib/isobuilder.cpp @@ -101,7 +101,7 @@ isobuilder::DirTree::DirTree(isobuilder::DirTree * _father, bool _dir) : mode(-1 } } -isobuilder::DirTree::setdvdmode() { +void isobuilder::DirTree::setdvdmode() { dvdmode = true; } -- cgit v1.2.3 From cfaf203f68cad99465ae3f93a007508ddf9c44dd Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 20 Oct 2009 17:55:34 -0700 Subject: Fixing an utterly stupid typo... --- lib/isobuilder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp index 54d9368..11979ad 100644 --- a/lib/isobuilder.cpp +++ b/lib/isobuilder.cpp @@ -740,11 +740,11 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr } } } - p->Size = cdutils::to_BE32(fsize); + p->Size = cdutils::to_LE32(fsize); cdfile * tmp = new cdfile(cd, p, fmode); createfile(r, tmp, "", p, fmode)->size = osize; delete tmp; - p->Size = cdutils::to_BE32(osize); + p->Size = cdutils::to_LE32(osize); } p = (cdutils::DirEntry *) (((Byte *) p) + p->R); } -- cgit v1.2.3