Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92b4e4472f | |||
| d362eef8bf | |||
| 57852bd3ae | |||
| 6fb31a3ae5 | |||
| 89496fb8fb | |||
| 4774a1a806 | |||
| 74cb8cb0f8 | |||
| d573c159fa | |||
| 446f588cfe |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -4,4 +4,6 @@ mini_debug.exe
|
|||||||
mini_debug
|
mini_debug
|
||||||
.vscode/*
|
.vscode/*
|
||||||
info.plist
|
info.plist
|
||||||
build/*
|
build/*
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
8
Makefile
8
Makefile
@@ -3,7 +3,7 @@ source = *.cpp ./lua/*.c
|
|||||||
|
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
g++ $(source) icon.res -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lmingw32 -lSDL3 -lopengl32 -mwindows -o "$(executable).exe"
|
g++ $(source) icon.res -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lmingw32 -lSDL3 -lopengl32 -static-libstdc++ -static-libgcc -lpthread -mwindows -o "$(executable).exe"
|
||||||
strip -s -R .comment -R .gnu.version --strip-unneeded "$(executable).exe"
|
strip -s -R .comment -R .gnu.version --strip-unneeded "$(executable).exe"
|
||||||
|
|
||||||
windows_debug:
|
windows_debug:
|
||||||
@@ -11,13 +11,13 @@ windows_debug:
|
|||||||
g++ $(source) -D DEBUG -g -Wall -Os -lmingw32 -lSDL3 -lopengl32 -o "$(executable)_debug.exe"
|
g++ $(source) -D DEBUG -g -Wall -Os -lmingw32 -lSDL3 -lopengl32 -o "$(executable)_debug.exe"
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
clang++ $(source) -Wall -Os -std=c++11 -ffunction-sections -fdata-sections -lSDL3 -o "$(executable)"
|
clang++ $(source) -Wall -Os -std=c++17 -Wno-deprecated -ffunction-sections -fdata-sections -lSDL3 -framework OpenGL -o "$(executable)"
|
||||||
|
|
||||||
macos_debug:
|
macos_debug:
|
||||||
clang++ $(source) -D DEBUG -g -Wall -Os -std=c++11 -ffunction-sections -fdata-sections -lSDL3 -o "$(executable)_debug"
|
clang++ $(source) -D DEBUG -g -Wall -Os -std=c++17 -Wno-deprecated -ffunction-sections -fdata-sections -lSDL3 -framework OpenGL -o "$(executable)_debug"
|
||||||
|
|
||||||
macos_bundle:
|
macos_bundle:
|
||||||
clang++ $(source) -D MACOS_BUNDLE -Wall -Os -std=c++11 -framework SDL3 -F /Library/Frameworks -ffunction-sections -fdata-sections -o mini_bundle -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
clang++ $(source) -D MACOS_BUNDLE -Wall -Os -std=c++17 -Wno-deprecated -framework SDL3 -framework OpenGL -F /Library/Frameworks -ffunction-sections -fdata-sections -o mini_bundle -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
g++ $(source) -D LUA_USE_LINUX -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lSDL3 -lGL -o "$(executable)"
|
g++ $(source) -D LUA_USE_LINUX -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lSDL3 -lGL -o "$(executable)"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
--require "ia.other"
|
--require "ia.other"
|
||||||
|
|
||||||
x=0
|
x=0
|
||||||
|
rot=0
|
||||||
|
|
||||||
function mini.init()
|
function mini.init()
|
||||||
s = surf.load("gfx/logo.gif")
|
s = surf.load("gfx/logo.gif")
|
||||||
@@ -21,7 +22,7 @@ end
|
|||||||
|
|
||||||
function mini.update()
|
function mini.update()
|
||||||
surf.cls(0)
|
surf.cls(0)
|
||||||
draw.surf(0, 0, 160, 144, 0, 0)
|
draw.surfrot(0, 0, 160, 144, 120, 78, rot)
|
||||||
|
|
||||||
draw.text("PRESS START", 60, 110, 28)
|
draw.text("PRESS START", 60, 110, 28)
|
||||||
if key.press(key.ESCAPE) then sys.quit() end
|
if key.press(key.ESCAPE) then sys.quit() end
|
||||||
@@ -48,4 +49,5 @@ function mini.update()
|
|||||||
font.spacing(0)
|
font.spacing(0)
|
||||||
draw.text("0146",100,50,28)
|
draw.text("0146",100,50,28)
|
||||||
font.current(font.DEFAULT)
|
font.current(font.DEFAULT)
|
||||||
|
rot=rot+1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,12 +16,18 @@ make windows_debug || exit /b 1
|
|||||||
|
|
||||||
echo Creando paquetes...
|
echo Creando paquetes...
|
||||||
|
|
||||||
|
copy bin\SDL3.dll .
|
||||||
|
copy bin\libwinpthread-1.dll .
|
||||||
|
|
||||||
REM Crear ZIP release con mini.exe + DLLs
|
REM Crear ZIP release con mini.exe + DLLs
|
||||||
tar -a -c -f mini_%PARAM%_windows_release.zip mini.exe bin\*.dll || exit /b 1
|
tar -a -c -f mini_%PARAM%_win32-x64_release.zip mini.exe *.dll || exit /b 1
|
||||||
|
|
||||||
REM Crear ZIP debug solo con mini_debug.exe
|
REM Crear ZIP debug solo con mini_debug.exe
|
||||||
tar -a -c -f mini_%PARAM%_windows_debug.zip mini_debug.exe || exit /b 1
|
tar -a -c -f mini_%PARAM%_win32-x64_debug.zip mini_debug.exe *.dll || exit /b 1
|
||||||
|
|
||||||
|
del SDL3.dll
|
||||||
|
del libwinpthread-1.dll
|
||||||
|
|
||||||
echo Paquetes generados:
|
echo Paquetes generados:
|
||||||
echo mini_%PARAM%_windows_release.zip
|
echo mini_%PARAM%_win32-x64_release.zip
|
||||||
echo mini_%PARAM%_windows_debug.zip
|
echo mini_%PARAM%_win32-x64_debug.zip
|
||||||
|
|||||||
37
do_release.sh
Normal file → Executable file
37
do_release.sh
Normal file → Executable file
@@ -1,36 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
#if [ -z "$1" ]; then
|
||||||
echo "Uso: $0 <PARAMETRO>"
|
# echo "Uso: $0 <PARAMETRO>"
|
||||||
exit 1
|
# exit 1
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
PARAM=$1
|
# Leer versión desde version.h
|
||||||
|
VERSION=$(grep '#define MINI_VERSION' version.h | sed 's/.*"\(.*\)".*/\1/')
|
||||||
|
echo "Versión detectada: $VERSION"
|
||||||
|
|
||||||
|
#PARAM=$1
|
||||||
|
|
||||||
# Datos Windows
|
# Datos Windows
|
||||||
WIN_USER="raimon"
|
WIN_USER="raimon"
|
||||||
WIN_HOST="192.168.1.51"
|
WIN_HOST="tonlab19"
|
||||||
WIN_PATH_SSH="/cygdrive/c/Users/raimon/dev/mini"
|
WIN_PATH_SSH="C:\Users\raimon\dev\mini"
|
||||||
|
WIN_PATH_SCP="C:/Users/Raimon/dev/mini"
|
||||||
|
|
||||||
echo "=== Compilando Linux ==="
|
echo "=== Compilando Linux ==="
|
||||||
make linux
|
make linux
|
||||||
make linux_debug
|
make linux_debug
|
||||||
|
|
||||||
echo "=== Empaquetando Linux ==="
|
echo "=== Empaquetando Linux ==="
|
||||||
tar -czf mini_${PARAM}_linux_release.tar.gz mini
|
tar -czf mini_v${VERSION}_linux_release.tar.gz mini
|
||||||
tar -czf mini_${PARAM}_linux_debug.tar.gz mini_debug
|
tar -czf mini_v${VERSION}_linux_debug.tar.gz mini_debug
|
||||||
|
|
||||||
echo "=== Ejecutando build remoto Windows ==="
|
echo "=== Ejecutando build remoto Windows ==="
|
||||||
ssh ${WIN_USER}@${WIN_HOST} "cd '${WIN_PATH_SSH}' && build_windows.bat ${PARAM}"
|
ssh ${WIN_USER}@${WIN_HOST} "cd ${WIN_PATH_SSH} && do_release.bat v${VERSION}"
|
||||||
|
|
||||||
echo "=== Copiando ZIPs desde Windows ==="
|
echo "=== Copiando ZIPs desde Windows ==="
|
||||||
scp ${WIN_USER}@${WIN_HOST}:"${WIN_PATH_SSH}/mini_${PARAM}_windows_release.zip" .
|
scp ${WIN_USER}@${WIN_HOST}:"${WIN_PATH_SCP}/mini_v${VERSION}_windows_release.zip" .
|
||||||
scp ${WIN_USER}@${WIN_HOST}:"${WIN_PATH_SSH}/mini_${PARAM}_windows_debug.zip" .
|
scp ${WIN_USER}@${WIN_HOST}:"${WIN_PATH_SCP}/mini_v${VERSION}_windows_debug.zip" .
|
||||||
|
|
||||||
echo "=== Build completado correctamente ==="
|
echo "=== Build completado correctamente ==="
|
||||||
echo "Generados:"
|
echo "Generados:"
|
||||||
echo " mini_${PARAM}_linux_release.tar.gz"
|
echo " mini_v${VERSION}_linux_release.tar.gz"
|
||||||
echo " mini_${PARAM}_linux_debug.tar.gz"
|
echo " mini_v${VERSION}_linux_debug.tar.gz"
|
||||||
echo " mini_${PARAM}_windows_release.zip"
|
echo " mini_v${VERSION}_windows_release.zip"
|
||||||
echo " mini_${PARAM}_windows_debug.zip"
|
echo " mini_v${VERSION}_windows_debug.zip"
|
||||||
|
|||||||
6
lua.cpp
6
lua.cpp
@@ -577,7 +577,11 @@ extern "C" {
|
|||||||
int dx = luaL_checknumber(L, 5);
|
int dx = luaL_checknumber(L, 5);
|
||||||
int dy = luaL_checknumber(L, 6);
|
int dy = luaL_checknumber(L, 6);
|
||||||
float a = luaL_checknumber(L, 7);
|
float a = luaL_checknumber(L, 7);
|
||||||
blit_r(sx, sy, sw, sh, dx, dy, a);
|
int dw = luaL_optnumber(L, 8, 0);
|
||||||
|
int dh = luaL_optnumber(L, 9, 0);
|
||||||
|
bool flip_x = lua_toboolean(L, 10);
|
||||||
|
bool flip_y = lua_toboolean(L, 11);
|
||||||
|
blit_r(sx, sy, sw, sh, dx, dy, dw, dh, flip_x, flip_y, a);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
196
mini.cpp
196
mini.cpp
@@ -15,6 +15,10 @@
|
|||||||
#define MAX_SURFACES 100
|
#define MAX_SURFACES 100
|
||||||
#define MAX_FONTS 5
|
#define MAX_FONTS 5
|
||||||
|
|
||||||
|
#define SURF_NOTHING 0
|
||||||
|
#define SURF_EXTERNAL 1
|
||||||
|
#define SURF_GENERATED 2
|
||||||
|
|
||||||
#ifdef MACOS_BUNDLE
|
#ifdef MACOS_BUNDLE
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -28,6 +32,7 @@ struct surface_t {
|
|||||||
uint8_t *p {nullptr};
|
uint8_t *p {nullptr};
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
uint8_t flags {SURF_NOTHING};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct char_t {
|
struct char_t {
|
||||||
@@ -282,6 +287,7 @@ uint8_t newsurf(int w, int h) {
|
|||||||
surfaces[i].h = h;
|
surfaces[i].h = h;
|
||||||
surfaces[i].size = w*h;
|
surfaces[i].size = w*h;
|
||||||
surfaces[i].p = (uint8_t*)calloc(surfaces[i].size,1);
|
surfaces[i].p = (uint8_t*)calloc(surfaces[i].size,1);
|
||||||
|
surfaces[i].flags = SURF_GENERATED;
|
||||||
log_msg(LOG_INFO, "Surface %i creada.\n", i);
|
log_msg(LOG_INFO, "Surface %i creada.\n", i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -315,11 +321,13 @@ uint8_t loadsurf(const char* filename, const bool external) {
|
|||||||
while (i<MAX_SURFACES && surfaces[i].p != NULL) ++i;
|
while (i<MAX_SURFACES && surfaces[i].p != NULL) ++i;
|
||||||
if (i==MAX_SURFACES) return 255;
|
if (i==MAX_SURFACES) return 255;
|
||||||
|
|
||||||
|
surfaces[i].flags = SURF_NOTHING;
|
||||||
// Carregar l'arxiu de disc
|
// Carregar l'arxiu de disc
|
||||||
int size;
|
int size;
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
if (external) {
|
if (external) {
|
||||||
buffer = (uint8_t*)file_getfilebufferex(filename, size);
|
buffer = (uint8_t*)file_getfilebufferex(filename, size);
|
||||||
|
surfaces[i].flags |= SURF_EXTERNAL;
|
||||||
} else {
|
} else {
|
||||||
buffer = (uint8_t*)file_getfilebuffer(filename, size);
|
buffer = (uint8_t*)file_getfilebuffer(filename, size);
|
||||||
}
|
}
|
||||||
@@ -341,6 +349,36 @@ uint8_t loadsurf(const char* filename, const bool external) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reloadsurfs() {
|
||||||
|
for (unsigned int i=0; i<MAX_SURFACES; ++i)
|
||||||
|
if (surfaces[i].name) {
|
||||||
|
if (surfaces[i].flags & SURF_GENERATED) {
|
||||||
|
log_msg(LOG_INFO, "Ignorant surface generada %i.\n", i);
|
||||||
|
} else {
|
||||||
|
log_msg(LOG_INFO, "Recarregant de disc surface %i:'%s'.\n", i, surfaces[i].name);
|
||||||
|
|
||||||
|
int size;
|
||||||
|
uint8_t *buffer;
|
||||||
|
if (surfaces[i].flags & SURF_EXTERNAL) {
|
||||||
|
buffer = (uint8_t*)file_getfilebufferex(surfaces[i].name, size);
|
||||||
|
} else {
|
||||||
|
buffer = (uint8_t*)file_getfilebuffer(surfaces[i].name, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si no s'ha pogut, petar
|
||||||
|
if (!buffer) {
|
||||||
|
log_msg(LOG_FAIL, "Error al intentar obrir l'arxiu '%s'\n", surfaces[i].name);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaces[i].p = LoadGif(buffer, &surfaces[i].w, &surfaces[i].h);
|
||||||
|
surfaces[i].size = surfaces[i].w*surfaces[i].h;
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void savesurf(uint8_t surface, const char* filename, uint8_t *pal, uint8_t colors)
|
void savesurf(uint8_t surface, const char* filename, uint8_t *pal, uint8_t colors)
|
||||||
{
|
{
|
||||||
gif::write_gif(filename, surfaces[surface].p, surfaces[surface].w, surfaces[surface].h, pal, colors);
|
gif::write_gif(filename, surfaces[surface].p, surfaces[surface].w, surfaces[surface].h, pal, colors);
|
||||||
@@ -354,6 +392,7 @@ void freesurf(uint8_t surface) {
|
|||||||
log_msg(LOG_INFO, "Surface %i alliberada.\n", surface);
|
log_msg(LOG_INFO, "Surface %i alliberada.\n", surface);
|
||||||
}
|
}
|
||||||
surfaces[surface].p = NULL;
|
surfaces[surface].p = NULL;
|
||||||
|
surfaces[surface].flags = SURF_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
int surfw(uint8_t surface) {
|
int surfw(uint8_t surface) {
|
||||||
@@ -435,6 +474,7 @@ uint8_t loadfont_from_buffer(const char* buffer, uint8_t index, const char* name
|
|||||||
memcpy(line, ptr, len);
|
memcpy(line, ptr, len);
|
||||||
line[len] = '\0';
|
line[len] = '\0';
|
||||||
ptr += (ptr[len] == '\n') ? len + 1 : len; // Advance pointer
|
ptr += (ptr[len] == '\n') ? len + 1 : len; // Advance pointer
|
||||||
|
if (len > 0 && line[len - 1] == '\r') line[len - 1] = '\0';
|
||||||
|
|
||||||
if (strncmp(line, "bitmap=", 7) != 0) return false; // Parse first line
|
if (strncmp(line, "bitmap=", 7) != 0) return false; // Parse first line
|
||||||
|
|
||||||
@@ -453,6 +493,7 @@ uint8_t loadfont_from_buffer(const char* buffer, uint8_t index, const char* name
|
|||||||
memcpy(line, ptr, len);
|
memcpy(line, ptr, len);
|
||||||
line[len] = '\0';
|
line[len] = '\0';
|
||||||
ptr += (ptr[len] == '\n') ? len + 1 : len; // Advance pointer
|
ptr += (ptr[len] == '\n') ? len + 1 : len; // Advance pointer
|
||||||
|
if (len > 0 && line[len - 1] == '\r') line[len - 1] = '\0';
|
||||||
|
|
||||||
// Remove comments
|
// Remove comments
|
||||||
char* hash = strchr(line, '#');
|
char* hash = strchr(line, '#');
|
||||||
@@ -664,7 +705,8 @@ int main(int argc,char*argv[]){
|
|||||||
reinit();
|
reinit();
|
||||||
initaudio();
|
initaudio();
|
||||||
|
|
||||||
loadsurf(default_font_gif, "default_font");
|
uint8_t font_surf = loadsurf(default_font_gif, "default_font");
|
||||||
|
surfaces[font_surf].flags |= SURF_GENERATED;
|
||||||
loadfont_from_buffer((const char*)default_font_fnt, 0, "default_font");
|
loadfont_from_buffer((const char*)default_font_fnt, 0, "default_font");
|
||||||
current_font = &fonts[0];
|
current_font = &fonts[0];
|
||||||
|
|
||||||
@@ -690,13 +732,14 @@ int main(int argc,char*argv[]){
|
|||||||
if (mini_eve.type == SDL_EVENT_KEY_DOWN) {
|
if (mini_eve.type == SDL_EVENT_KEY_DOWN) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (mini_eve.key.scancode == SDL_SCANCODE_F12) {
|
if (mini_eve.key.scancode == SDL_SCANCODE_F12) {
|
||||||
if (lua_is_playing()) {
|
reloadsurfs();
|
||||||
lua_quit();
|
//if (lua_is_playing()) {
|
||||||
quitaudio();
|
// lua_quit();
|
||||||
reinit();
|
// quitaudio();
|
||||||
} else {
|
// reinit();
|
||||||
should_exit=true;
|
//} else {
|
||||||
}
|
// should_exit=true;
|
||||||
|
//}
|
||||||
} else if (mini_eve.key.scancode == SDL_SCANCODE_F5) {
|
} else if (mini_eve.key.scancode == SDL_SCANCODE_F5) {
|
||||||
should_exit=true;
|
should_exit=true;
|
||||||
} else {
|
} else {
|
||||||
@@ -1351,6 +1394,7 @@ void blit(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, bool f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void blit_r(int sx, int sy, int sw, int sh, int x, int y, float a)
|
void blit_r(int sx, int sy, int sw, int sh, int x, int y, float a)
|
||||||
{
|
{
|
||||||
const int x0 = sw>>1;
|
const int x0 = sw>>1;
|
||||||
@@ -1373,6 +1417,142 @@ void blit_r(int sx, int sy, int sw, int sh, int x, int y, float a)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void blit_r(int sx, int sy, int sw, int sh,
|
||||||
|
int dx, int dy, int dw, int dh,
|
||||||
|
bool flip_x, bool flip_y,
|
||||||
|
float angle_deg)
|
||||||
|
{
|
||||||
|
if (dw == 0) dw = sw;
|
||||||
|
if (dh == 0) dh = sh;
|
||||||
|
|
||||||
|
// Centro del destino (rectángulo sin rotar)
|
||||||
|
float dcx = dx + dw * 0.5f;
|
||||||
|
float dcy = dy + dh * 0.5f;
|
||||||
|
|
||||||
|
// Centro del subrectángulo origen
|
||||||
|
float scx = sx + sw * 0.5f;
|
||||||
|
float scy = sy + sh * 0.5f;
|
||||||
|
|
||||||
|
// Escalado destino -> origen
|
||||||
|
float inv_scale_x = float(sw) / float(dw);
|
||||||
|
float inv_scale_y = float(sh) / float(dh);
|
||||||
|
|
||||||
|
// Flips integrados en la escala
|
||||||
|
if (flip_x) inv_scale_x = -inv_scale_x;
|
||||||
|
if (flip_y) inv_scale_y = -inv_scale_y;
|
||||||
|
|
||||||
|
// Ángulo en radianes
|
||||||
|
float a = angle_deg * 3.14159265f / 180.0f;
|
||||||
|
float ca = SDL_cosf(a);
|
||||||
|
float sa = SDL_sinf(a);
|
||||||
|
|
||||||
|
// --- 1. Bounding box rotado del rectángulo destino ---
|
||||||
|
|
||||||
|
float hx = dw * 0.5f;
|
||||||
|
float hy = dh * 0.5f;
|
||||||
|
|
||||||
|
float vx[4] = { -hx, hx, -hx, hx };
|
||||||
|
float vy[4] = { -hy, -hy, hy, hy };
|
||||||
|
|
||||||
|
float min_x = 1e9f, max_x = -1e9f;
|
||||||
|
float min_y = 1e9f, max_y = -1e9f;
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
float rr_x = vx[i] * ca - vy[i] * sa;
|
||||||
|
float rr_y = vx[i] * sa + vy[i] * ca;
|
||||||
|
|
||||||
|
float dxp = dcx + rr_x;
|
||||||
|
float dyp = dcy + rr_y;
|
||||||
|
|
||||||
|
if (dxp < min_x) min_x = dxp;
|
||||||
|
if (dxp > max_x) max_x = dxp;
|
||||||
|
if (dyp < min_y) min_y = dyp;
|
||||||
|
if (dyp > max_y) max_y = dyp;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bb_x0 = (int)SDL_floorf(min_x);
|
||||||
|
int bb_x1 = (int)SDL_ceilf (max_x);
|
||||||
|
int bb_y0 = (int)SDL_floorf(min_y);
|
||||||
|
int bb_y1 = (int)SDL_ceilf (max_y);
|
||||||
|
|
||||||
|
// --- 2. Rotación inversa + escalado + clipping estricto ---
|
||||||
|
|
||||||
|
for (int y = bb_y0; y <= bb_y1; ++y) {
|
||||||
|
for (int x = bb_x0; x <= bb_x1; ++x) {
|
||||||
|
|
||||||
|
// Coordenadas relativas al centro destino
|
||||||
|
float rx = x - dcx;
|
||||||
|
float ry = y - dcy;
|
||||||
|
|
||||||
|
// Rotación inversa
|
||||||
|
float ux = rx * ca + ry * sa;
|
||||||
|
float uy = -rx * sa + ry * ca;
|
||||||
|
|
||||||
|
// Escalado destino -> origen (con flips)
|
||||||
|
float sxp = scx + ux * inv_scale_x;
|
||||||
|
float syp = scy + uy * inv_scale_y;
|
||||||
|
|
||||||
|
// Clipping estricto al subrectángulo origen
|
||||||
|
if (sxp < sx || sxp >= sx + sw ||
|
||||||
|
syp < sy || syp >= sy + sh)
|
||||||
|
continue; // no pintamos nada
|
||||||
|
|
||||||
|
uint8_t color = sget((int)sxp, (int)syp);
|
||||||
|
pset(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void blit_r(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, bool flip_x, bool flip_y, float angle_deg)
|
||||||
|
{
|
||||||
|
if (dw == 0) dw = sw;
|
||||||
|
if (dh == 0) dh = sh;
|
||||||
|
|
||||||
|
// Escalado origen→destino
|
||||||
|
float sdx = float(sw) / float(dw);
|
||||||
|
float sdy = float(sh) / float(dh);
|
||||||
|
|
||||||
|
// Centro del destino
|
||||||
|
float dcx = dx + dw * 0.5f;
|
||||||
|
float dcy = dy + dh * 0.5f;
|
||||||
|
|
||||||
|
// Centro del origen
|
||||||
|
float scx = sx + sw * 0.5f;
|
||||||
|
float scy = sy + sh * 0.5f;
|
||||||
|
|
||||||
|
// Flips: invertir escala
|
||||||
|
if (flip_x) sdx = -sdx;
|
||||||
|
if (flip_y) sdy = -sdy;
|
||||||
|
|
||||||
|
// Ángulo en radianes
|
||||||
|
float a = angle_deg * 3.14159265f / 180.0f;
|
||||||
|
float ca = SDL_cosf(a);
|
||||||
|
float sa = SDL_sinf(a);
|
||||||
|
|
||||||
|
// Bucle principal
|
||||||
|
for (int y = dy; y < dy + dh; ++y) {
|
||||||
|
for (int x = dx; x < dx + dw; ++x) {
|
||||||
|
|
||||||
|
// Coordenadas destino relativas al centro
|
||||||
|
float rx = x - dcx;
|
||||||
|
float ry = y - dcy;
|
||||||
|
|
||||||
|
// Rotación inversa (para muestreo)
|
||||||
|
float orx = rx * ca + ry * sa;
|
||||||
|
float ory = -rx * sa + ry * ca;
|
||||||
|
|
||||||
|
// Convertir a coordenadas de la fuente
|
||||||
|
float sxp = scx + orx * sdx;
|
||||||
|
float syp = scy + ory * sdy;
|
||||||
|
|
||||||
|
// Muestreo nearest neighbor
|
||||||
|
uint8_t color = sget(int(sxp), int(syp));
|
||||||
|
pset(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
void tline(int x0, int y0, int x1, int y1, float mx, float my, float mdx, float mdy) {
|
void tline(int x0, int y0, int x1, int y1, float mx, float my, float mdx, float mdy) {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|||||||
3
mini.h
3
mini.h
@@ -217,7 +217,8 @@ void sset(int x, int y, uint8_t color);
|
|||||||
|
|
||||||
void spr(uint8_t n, int x, int y, float w = 1.0f, float h = 1.0f, bool flip_x = false, bool flip_y = false);
|
void spr(uint8_t n, int x, int y, float w = 1.0f, float h = 1.0f, bool flip_x = false, bool flip_y = false);
|
||||||
void blit(int sx, int sy, int sw, int sh, int dx, int dy, int dw=0, int dh=0, bool flip_x = false, bool flip_y = false, bool invert = false);
|
void blit(int sx, int sy, int sw, int sh, int dx, int dy, int dw=0, int dh=0, bool flip_x = false, bool flip_y = false, bool invert = false);
|
||||||
void blit_r(int sx, int sy, int sw, int sh, int x, int y, float a);
|
//void blit_r(int sx, int sy, int sw, int sh, int x, int y, float a);
|
||||||
|
void blit_r(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, bool flip_x, bool flip_y, float angle_deg);
|
||||||
|
|
||||||
void tline(int x0, int y0, int x1, int y1, float mx, float my, float mdx=0.125f, float mdy=0.0f);
|
void tline(int x0, int y0, int x1, int y1, float mx, float my, float mdx=0.125f, float mdy=0.0f);
|
||||||
void thline(int x0, int y, int x1, float mx, float my, float mdx=0.125f, float mdy=0.0f);
|
void thline(int x0, int y, int x1, float mx, float my, float mdx=0.125f, float mdy=0.0f);
|
||||||
|
|||||||
57
publish_gitea.sh
Executable file
57
publish_gitea.sh
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#if [ -z "$1" ]; then
|
||||||
|
# echo "Uso: $0 <PARAMETRO>"
|
||||||
|
# exit 1
|
||||||
|
#fi
|
||||||
|
|
||||||
|
GITEA_TOKEN="eb44d9c0142f5038c61c5afd17f5a41177bfaedc"
|
||||||
|
|
||||||
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
echo "ERROR: Debes exportar GITEA_TOKEN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Leer versión desde version.h
|
||||||
|
VERSION=$(grep '#define MINI_VERSION' version.h | sed 's/.*"\(.*\)".*/\1/')
|
||||||
|
echo "Versión detectada: $VERSION"
|
||||||
|
|
||||||
|
#PARAM=$1
|
||||||
|
API="https://gitea.sustancia.synology.me/api/v1"
|
||||||
|
REPO="JailDoctor/mini"
|
||||||
|
|
||||||
|
echo "=== Creando release ${VERSION} en Gitea ==="
|
||||||
|
|
||||||
|
RELEASE_ID=$(curl -s -X POST "${API}/repos/${REPO}/releases" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"tag_name\": \"${VERSION}\",
|
||||||
|
\"name\": \"Release ${VERSION}\",
|
||||||
|
\"draft\": false,
|
||||||
|
\"prerelease\": false
|
||||||
|
}" | jq -r '.id')
|
||||||
|
|
||||||
|
if [ "$RELEASE_ID" = "null" ]; then
|
||||||
|
echo "ERROR: No se pudo crear el release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release creado con ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
echo "=== Subiendo artefactos ==="
|
||||||
|
|
||||||
|
for f in mini_v${VERSION}_linux_release.tar.gz \
|
||||||
|
mini_v${VERSION}_linux_debug.tar.gz \
|
||||||
|
mini_v${VERSION}_win32-x64_release.zip \
|
||||||
|
mini_v${VERSION}_win32-x64_debug.zip
|
||||||
|
do
|
||||||
|
echo "Subiendo $f..."
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-F "attachment=@${f}" \
|
||||||
|
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets" > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "=== Publicación completada ==="
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MINI_VERSION "1.4.7"
|
#define MINI_VERSION "1.4.10"
|
||||||
|
|||||||
@@ -320,9 +320,15 @@ function draw.surf(sx, sy, sw, sh, dx, dy, dw, dh, flip_x, flip_y, invert) end
|
|||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param a number
|
---@param a number
|
||||||
|
---@optional dw number
|
||||||
|
---@optional dh number
|
||||||
|
---@optional boolean flip_x
|
||||||
|
---@optional boolean flip_y
|
||||||
|
---@optional boolean invert
|
||||||
---Blit the region starting at (sx,sy) and size (sw, sh) from the source surface
|
---Blit the region starting at (sx,sy) and size (sw, sh) from the source surface
|
||||||
---to the position (dx, dy) of the target surface, rotating it by a degrees
|
---to the position (dx, dy) of the target surface, rotating it by a degrees,
|
||||||
function draw.surfrot(sx, sy, sw, sh, x, y, a) end
|
---(and optionally of size (dw, dh)) optionally flipping it horizontally or vertically
|
||||||
|
function draw.surfrot(sx, sy, sw, sh, x, y, a, dw, dh, flip_x, flip_y) end
|
||||||
|
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param x number
|
---@param x number
|
||||||
|
|||||||
Reference in New Issue
Block a user