summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/isobuilder.h2
-rw-r--r--includes/luacd.h20
-rw-r--r--includes/lzss.h2
-rw-r--r--lib/isobuilder.cpp16
-rw-r--r--lib/luacd.cpp113
-rw-r--r--lib/lzss.cpp5
6 files changed, 146 insertions, 12 deletions
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/includes/luacd.h b/includes/luacd.h
index 1f7768f..baa4929 100644
--- a/includes/luacd.h
+++ b/includes/luacd.h
@@ -27,6 +27,8 @@
#include <LuaHandle.h>
#include <cdutils.h>
#include <isobuilder.h>
+#include <cdabstract.h>
+#include <dvdabstract.h>
#define CD_PUSHSTATICS(L) { \
Luacdutils::pushstatics(L); \
@@ -34,6 +36,8 @@
LuaPVD::pushstatics(L); \
LuaDirTree::pushstatics(L); \
Luaisobuilder::pushstatics(L); \
+ Luacdabstract::pushconstruct(L); \
+ Luadvdabstract::pushconstruct(L); \
}
class Luacdutils : public LuaObject {
@@ -89,4 +93,20 @@ class Luaisobuilder : public LuaObject {
isobuilder * iso;
};
+class Luacdabstract : public LuaHandle {
+ public:
+ static void pushconstruct(Lua *);
+ Luacdabstract(Handle *);
+ protected:
+ virtual void pushmembers(Lua *);
+};
+
+class Luadvdabstract : public LuaHandle {
+ public:
+ static void pushconstruct(Lua *);
+ Luadvdabstract(dvdabstract *);
+ protected:
+ virtual void pushmembers(Lua *);
+};
+
#endif
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/isobuilder.cpp b/lib/isobuilder.cpp
index 9bec34c..11979ad 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
}
}
+void 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");
}
@@ -738,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);
}
diff --git a/lib/luacd.cpp b/lib/luacd.cpp
index b619905..9c4e55a 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 {
@@ -478,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());
@@ -1120,6 +1126,7 @@ enum DirTree_methods_t {
DIRTREE_FROMDIR,
DIRTREE_SETBASICSXA,
DIRTREE_FIND,
+ DIRTREE_SETDVDMODE,
};
enum DirTree_functions_t {
@@ -1130,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 }
};
@@ -1147,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:
@@ -1163,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) {
@@ -1198,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;
@@ -1713,3 +1726,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<String> probed = cdabstract::probe();
+ int j = 1;
+
+ for (std::vector<String>::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);
+}
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;
}