static int lua_newT(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments."); #endif Timer* new_timer = (Timer*)malloc(sizeof(Timer)); // Calculating current frame new_timer->tick = osGetTime(); new_timer->magic = 0x4C544D52; new_timer->isPlaying = true; drawCommand("Timer.new: ","Timer created at offset 0x%lX.\n",(u32)new_timer); allocatedDatas = allocatedDatas + sizeof(Timer); size_t percent = (allocatedDatas * 100) / maxDatas; drawDebug("Debug: ","Allocated %lu bytes (Mem. usage: %u%%).\n",sizeof(Timer), percent); if (percent > 80) drawWarning("Warning: ", "High memory usage!"); if (percent > 100){ drawError("FATAL ERROR: ", "Out of memory!"); return luaL_error(L, "internal error."); } lua_pushinteger(L,(u32)new_timer); return 1; }
static int lua_openfile(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if ((argc != 2) && (argc != 3) && (argc != 4)) return luaL_error(L, "wrong number of arguments"); #endif char file_tbo[256]; const char *file_tmp = luaL_checkstring(L, 1); int type = luaL_checkinteger(L, 2); u32 archive_id; u32 filesize; if (argc >= 3){ char warn[256]; archive_id = luaL_checknumber(L,3); sprintf(warn,"Extdata is unavailable on PC, using %s.ext%lu as file.\n", file_tmp, archive_id); drawWarning("Warning: ", warn); if (argc == 4) filesize = luaL_checkinteger(L, 4); sprintf(file_tbo, "%s.ext%lu", file_tmp, archive_id); }else sprintf(file_tbo, "%s", file_tmp); FILE* handle; if (type == 0) handle = fopen(file_tbo, "r"); else if (type == 1) handle = fopen(file_tbo, "r+"); else handle = fopen(file_tbo, "w+"); #ifndef SKIP_ERROR_HANDLING if (handle == NULL) return luaL_error(L, "file doesn't exist."); #endif drawCommand("io.open: ","Opening file handle at offset 0x%lX.\n",(u32)handle); lua_pushinteger(L,(u32)handle); return 1; }
static int lua_installcia(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 2) return luaL_error(L, "wrong number of arguments"); #endif const char* path = luaL_checkstring(L, 1); u8 mediatype = luaL_checkinteger(L, 2); drawWarning("Warning: ", "Skipping System.installCia function.\n"); return 0; }
/* * Prepare the OpenGL scene for drawing (projection and frustrum settings) */ void ColorSpaceKeyerOverlay::prepareOpenGLScene(const OFX::DrawArgs& args) { //reset OpenGL scene (remove previous image) glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //change background color to gray glClearColor(0.5f, 0.5f, 0.5f, 1.0f); //get projection matrix GLdouble proj_matrix[16]; glGetDoublev(GL_PROJECTION_MATRIX, proj_matrix); //initialize model-view and projection matrixes to identity glMatrixMode( GL_PROJECTION ); // load standard mode glLoadIdentity(); // projection to identity glMatrixMode( GL_MODELVIEW ); // load standard mode glLoadIdentity(); // model-view to identity //get current viewport size GLint viewport[4] = { 0, 0, 0, 0 }; // define result array glGetIntegerv(GL_VIEWPORT,viewport); // get current viewport size const double ratio = (viewport[2]-viewport[0]) / (double)(viewport[3]-viewport[1]); // compute ratio //define new coordinates glOrtho( 0.0, 1.0, 0.0, 1.0, -1.0, 1.0 ); // set coordinates to 0-1 if(args.time != getData()._time || args.time != getData()._averageColor._time) // if current overlay has not been updated { //display warning sign on screen Ofx3DPointD warningPoint; // initialize warning drawing point warningPoint.x = 0.15; // x == viewport width/7; warningPoint.y = 0.2; // y == viewport height/5; drawWarning(warningPoint, ratio); // draw warning sign } //define openGL scene frustrum glMatrixMode( GL_PROJECTION ); // load standard mode glLoadMatrixd( proj_matrix ); // reload previous projection matrix const GLdouble vleft = - 0.5; //frustrum left const GLdouble vright = 1.5; //frustrum right const GLdouble vbottom = - 0.5; //frustrum bottom const GLdouble vtop = 1.5; //frustrum top const GLdouble vnear = 10.0; //frustrum near const GLdouble vfar = -10.0; //frustrum far glOrtho( vleft, vright, vbottom, vtop, vnear, vfar); //define new frustrum for overlay data glMatrixMode( GL_MODELVIEW ); //load standard mode //initialize double* modelViewMatrix double modelViewMatrix[16]; //initialize for(unsigned int i=0; i<16; ++i) modelViewMatrix[i] = _modelViewMatrix[i]; //recopy Matrix4 into double* glLoadMatrixd(modelViewMatrix);//load modelView matrix (first time is equal to identity) }
static int lua_createdir(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 1 && argc != 2) return luaL_error(L, "wrong number of arguments"); #endif const char *path = luaL_checkstring(L, 1); char file_tbo[256]; if (argc == 2){ u32 archive_id = luaL_checkinteger(L, 2); char warn[256]; sprintf(warn,"Extdata is unavailable on PC, using %s.ext%lu as file.\n", path, archive_id); drawWarning("Warning: ", warn); sprintf(file_tbo, "%s.ext%lu", path, archive_id); }else sprintf(file_tbo, "%s", path); mkdir(file_tbo); return 0; }