summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-10-21 09:56:09 -0700
committerPixel <pixel@nobis-crew.org>2009-10-21 09:56:09 -0700
commitceebadeefd68d37a680f1fa173d4a1f564538acc (patch)
tree110c484f97dfa5762e4ab0a69600924783c94b89 /lib
parent91e1b2a0b50088e3a5d556eabfd7c25b689edd07 (diff)
parentcfaf203f68cad99465ae3f93a007508ddf9c44dd (diff)
Merge branch 'master' of ssh+git://pixel@git.grumpycoder.net/pub/repo.git/PSX-Bundle
Diffstat (limited to 'lib')
-rw-r--r--lib/isobuilder.cpp16
-rw-r--r--lib/luacd.cpp113
-rw-r--r--lib/lzss.cpp5
3 files changed, 123 insertions, 11 deletions
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;
}