Commit f93bd808 authored by Jack's avatar Jack
Browse files

fixes max compressed length for stegano data, added poke2 and peek2

parent 7f53689f
......@@ -8,6 +8,11 @@ using namespace io;
constexpr size_t RAW_DATA_LENGTH = 0x4300;
#if DEBUGGER
#include <fstream>
static std::string fileName;
#endif
uint8_t Stegano::assembleByte(const uint32_t v)
{
constexpr uint32_t MASK_ALPHA = 0xff000000;
......@@ -63,6 +68,8 @@ void Stegano::load(const PngData& data, Machine& m)
/* skip 2 null*/
o += 2;
compressedLength = std::min(32769ULL - RAW_DATA_LENGTH, compressedLength);
const std::string lookup = "\n 0123456789abcdefghijklmnopqrstuvwxyz!#%(){}[]<>+=/*:;.,~_";
std::string code;
......@@ -100,8 +107,13 @@ void Stegano::load(const PngData& data, Machine& m)
}
}
m.code().initFromSource(code);
#if DEBUGGER
std::ofstream output(fileName);
output << code;
output.close();
#endif
m.code().initFromSource(code);
}
//TODO: remove SDL_image and use lighter library
......@@ -109,6 +121,10 @@ void Stegano::load(const PngData& data, Machine& m)
void Stegano::load(const std::string& path, Machine& m)
{
#if DEBUGGER
fileName = path.substr(0, path.length() - 4) + ".p8";
#endif
SDL_Surface* surface = IMG_Load(path.c_str());
if (!surface)
......
......@@ -586,6 +586,16 @@ static int llex (LexState *ls, SemInfo *seminfo) {
} while (anyValid);
}
/*case 0x8B:
{
seminfo->i = 0;
return TK_INT;
}
case 0x91:
{
seminfo->i = 1;
return TK_INT;
}*/
case EOZ: {
return TK_EOS;
......
......@@ -240,7 +240,7 @@ namespace draw
uint8_t w = lua_tonumber(L, 3);
uint8_t h = lua_tonumber(L, 4);
machine.memory().clipRect()->set(x0, y0, x0 + w, y0 + h);
machine.memory().clipRect()->set(x0, y0, std::min(x0 + w, int32_t(gfx::SCREEN_WIDTH-1)), std::min(y0 + h, int32_t(gfx::SCREEN_HEIGHT-1)));
}
return 0;
......@@ -746,6 +746,18 @@ namespace platform
return 0;
}
int poke2(lua_State* L)
{
address_t addr = lua_tonumber(L, 1);
uint32_t value = lua_tonumber(L, 2);
machine.memory().base()[addr] = value & 0xFF;
machine.memory().base()[addr+1] = (value & 0xFF00) >> 8;
return 0;
}
int peek(lua_State* L)
{
address_t addr = lua_tonumber(L, 1);
......@@ -756,6 +768,17 @@ namespace platform
return 1;
}
int peek2(lua_State* L)
{
address_t addr = lua_tonumber(L, 1);
uint8_t low = machine.memory().base()[addr];
uint8_t high = machine.memory().base()[addr+1];
lua_pushnumber(L, (low | high << 8));
return 1;
}
int memset(lua_State* L)
{
address_t addr = lua_tonumber(L, 1);
......@@ -983,6 +1006,8 @@ void lua::registerFunctions(lua_State* L)
lua_register(L, "dget", platform::dget);
lua_register(L, "poke", platform::poke);
lua_register(L, "peek", platform::peek);
lua_register(L, "poke2", platform::poke);
lua_register(L, "peek2", platform::peek);
lua_register(L, "memset", platform::memset);
lua_register(L, "memcpy", platform::memcpy);
lua_register(L, "reload", platform::reload);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment