From b56a0c0f711031a7c63ea4d68433debd56aa9249 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 29 Nov 2024 14:33:21 +0100 Subject: [PATCH] - [NEW] surfsize(surface) torna el tamany de la surface que se li pasa --- lua.cpp | 8 ++++++++ mini.cpp | 8 ++++++++ mini.h | 3 +++ version.h | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lua.cpp b/lua.cpp index 22728b3..f9d5260 100644 --- a/lua.cpp +++ b/lua.cpp @@ -26,6 +26,13 @@ extern "C" { return 0; } + static int cpp_surfsize(lua_State *L) { + uint8_t surface = luaL_checkinteger(L, 1); + lua_pushinteger(L, surfw(surface)); + lua_pushinteger(L, surfh(surface)); + return 2; + } + static int cpp_setdest(lua_State *L) { uint8_t surface = luaL_checkinteger(L, 1); setdest(surface); @@ -861,6 +868,7 @@ void push_lua_funcs() { lua_pushcfunction(L,cpp_newsurf); lua_setglobal(L, "newsurf"); lua_pushcfunction(L,cpp_loadsurf); lua_setglobal(L, "loadsurf"); lua_pushcfunction(L,cpp_freesurf); lua_setglobal(L, "freesurf"); + lua_pushcfunction(L,cpp_surfsize); lua_setglobal(L, "surfsize"); lua_pushcfunction(L,cpp_setdest); lua_setglobal(L, "setdest"); lua_pushcfunction(L,cpp_setsource); lua_setglobal(L, "setsource"); lua_pushcfunction(L,cpp_setmap); lua_setglobal(L, "setmap"); diff --git a/mini.cpp b/mini.cpp index 21a427d..f83ca65 100644 --- a/mini.cpp +++ b/mini.cpp @@ -221,6 +221,14 @@ void freesurf(uint8_t surface) { surfaces[surface].p = NULL; } +int surfw(uint8_t surface) { + return surfaces[surface].w; +} + +int surfh(uint8_t surface) { + return surfaces[surface].h; +} + void recalculate_clip() { ds::clip[0] = ds::clp[0]; ds::clip[1] = ds::clp[1]; ds::clip[2] = ds::clp[2]-ds::clp[0]-1; ds::clip[3] = ds::clp[3]-ds::clp[1]-1; diff --git a/mini.h b/mini.h index 21aafc6..d948802 100644 --- a/mini.h +++ b/mini.h @@ -120,6 +120,9 @@ int scrh(); uint8_t newsurf(int w, int h); uint8_t loadsurf(const char* filename); void freesurf(uint8_t surface); +int surfw(uint8_t surface); +int surfh(uint8_t surface); + void setdest(uint8_t surface); void setsource(uint8_t surface); void setmap(uint8_t surface); diff --git a/version.h b/version.h index 8a2fcea..54ea118 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "0.9.98a" +#define MINI_VERSION "0.9.98b"