Added SDL2_mixer, SDL2_image, SDL2_ttf2 and SMPEG2 wrapped libs, plus a few more libc wrapped functions

This commit is contained in:
ptitSeb 2021-03-13 10:06:12 +01:00
parent 066410a31d
commit ca345d7f55
16 changed files with 911 additions and 23 deletions

View File

@ -177,6 +177,10 @@ set(WRAPPEDS
"${BOX64_ROOT}/src/wrapped/wrappedsdl1ttf.c"
"${BOX64_ROOT}/src/wrapped/wrappedsmpeg.c"
"${BOX64_ROOT}/src/wrapped/wrappedsdl2.c"
"${BOX64_ROOT}/src/wrapped/wrappedsdl2image.c"
"${BOX64_ROOT}/src/wrapped/wrappedsdl2mixer.c"
"${BOX64_ROOT}/src/wrapped/wrappedsdl2ttf.c"
"${BOX64_ROOT}/src/wrapped/wrappedsmpeg2.c"
"${BOX64_ROOT}/src/wrapped/wrappedxinerama.c"
)

View File

@ -96,7 +96,7 @@ void x64Int3(x64emu_t* emu)
s = GetNativeName((void*)addr);
if(addr==(uintptr_t)PltResolver) {
snprintf(buff, 256, "%s", " ... ");
} else if(strstr(s, "__open")==s || strcmp(s, "open ")==0) {
} else if(strstr(s, "__open")==s || !strcmp(s, "open") || !strcmp(s, "open ")) {
tmp = (char*)(R_RDI);
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %d (,%d))", tid, *(void**)(R_RSP), s, (tmp)?tmp:"(nil)", (int)(R_ESI), (int)(R_EDX));
perr = 1;

View File

@ -16,15 +16,15 @@ GO("libSDL2-2.0.so.0", sdl2)
GO("libSDL2-2.0.so.1", sdl2)
GO("libSDL2.so", sdl2)
GO("libsdl2-2.0.so.0", sdl2)
//GO("libSDL2_mixer-2.0.so.0", sdl2mixer)
//GO("libSDL2_image-2.0.so.0", sdl2image)
//GO("libSDL2_ttf-2.0.so.0", sdl2ttf)
GO("libSDL2_mixer-2.0.so.0", sdl2mixer)
GO("libSDL2_image-2.0.so.0", sdl2image)
GO("libSDL2_ttf-2.0.so.0", sdl2ttf)
GO("libSDL-1.2.so.0", sdl1)
GO("libSDL_mixer-1.2.so.0", sdl1mixer)
GO("libSDL_image-1.2.so.0", sdl1image)
GO("libSDL_ttf-2.0.so.0", sdl1ttf)
GO("libsmpeg-0.4.so.0", smpeg)
//GO("libsmpeg2-2.0.so.0", smpeg2)
GO("libsmpeg2-2.0.so.0", smpeg2)
//GO("libvorbisfile.so.3", vorbisfile)
//GO("libvorbis.so.0", libvorbis)
//GO("libogg.so.0", libogg)

View File

@ -194,6 +194,7 @@
#() vFppi
#() vFppu
#() vFppp
#() iFEiw
#() iFEip
#() iFEWW
#() iFEup
@ -202,6 +203,7 @@
#() iFEpp
#() iFEpV
#() iFESp
#() iFiwC
#() iFiii
#() iFiiu
#() iFiip
@ -439,7 +441,7 @@
#() pFuiii
#() pFpiii
#() pFpiip
#() pFpiuu
#() pFpiLL
#() pFpipi
#() pFpipp
#() pFpCWp
@ -577,6 +579,8 @@
#() pFEpipL
#() pFEpipp
#() pFEpupp
#() pFEppii
#() pFEppip
#() pFEpppp
#() pFuiiiu
#() pFuiipp
@ -656,6 +660,7 @@
#() iFEppppp
#() iFiiiiii
#() iFiiiiip
#() iFiuiipi
#() iFuppipp
#() iFuppppp
#() iFpiiiii

View File

@ -227,6 +227,7 @@ typedef void (*vFpup_t)(void*, uint32_t, void*);
typedef void (*vFppi_t)(void*, void*, int32_t);
typedef void (*vFppu_t)(void*, void*, uint32_t);
typedef void (*vFppp_t)(void*, void*, void*);
typedef int32_t (*iFEiw_t)(x64emu_t*, int32_t, int16_t);
typedef int32_t (*iFEip_t)(x64emu_t*, int32_t, void*);
typedef int32_t (*iFEWW_t)(x64emu_t*, uint16_t, uint16_t);
typedef int32_t (*iFEup_t)(x64emu_t*, uint32_t, void*);
@ -235,6 +236,7 @@ typedef int32_t (*iFEpL_t)(x64emu_t*, void*, uintptr_t);
typedef int32_t (*iFEpp_t)(x64emu_t*, void*, void*);
typedef int32_t (*iFEpV_t)(x64emu_t*, void*, void*);
typedef int32_t (*iFESp_t)(x64emu_t*, void*, void*);
typedef int32_t (*iFiwC_t)(int32_t, int16_t, uint8_t);
typedef int32_t (*iFiii_t)(int32_t, int32_t, int32_t);
typedef int32_t (*iFiiu_t)(int32_t, int32_t, uint32_t);
typedef int32_t (*iFiip_t)(int32_t, int32_t, void*);
@ -472,7 +474,7 @@ typedef void* (*pFippL_t)(int32_t, void*, void*, uintptr_t);
typedef void* (*pFuiii_t)(uint32_t, int32_t, int32_t, int32_t);
typedef void* (*pFpiii_t)(void*, int32_t, int32_t, int32_t);
typedef void* (*pFpiip_t)(void*, int32_t, int32_t, void*);
typedef void* (*pFpiuu_t)(void*, int32_t, uint32_t, uint32_t);
typedef void* (*pFpiLL_t)(void*, int32_t, uintptr_t, uintptr_t);
typedef void* (*pFpipi_t)(void*, int32_t, void*, int32_t);
typedef void* (*pFpipp_t)(void*, int32_t, void*, void*);
typedef void* (*pFpCWp_t)(void*, uint8_t, uint16_t, void*);
@ -610,6 +612,8 @@ typedef void* (*pFEpiii_t)(x64emu_t*, void*, int32_t, int32_t, int32_t);
typedef void* (*pFEpipL_t)(x64emu_t*, void*, int32_t, void*, uintptr_t);
typedef void* (*pFEpipp_t)(x64emu_t*, void*, int32_t, void*, void*);
typedef void* (*pFEpupp_t)(x64emu_t*, void*, uint32_t, void*, void*);
typedef void* (*pFEppii_t)(x64emu_t*, void*, void*, int32_t, int32_t);
typedef void* (*pFEppip_t)(x64emu_t*, void*, void*, int32_t, void*);
typedef void* (*pFEpppp_t)(x64emu_t*, void*, void*, void*, void*);
typedef void* (*pFuiiiu_t)(uint32_t, int32_t, int32_t, int32_t, uint32_t);
typedef void* (*pFuiipp_t)(uint32_t, int32_t, int32_t, void*, void*);
@ -689,6 +693,7 @@ typedef int32_t (*iFEpuppp_t)(x64emu_t*, void*, uint32_t, void*, void*, void*);
typedef int32_t (*iFEppppp_t)(x64emu_t*, void*, void*, void*, void*, void*);
typedef int32_t (*iFiiiiii_t)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
typedef int32_t (*iFiiiiip_t)(int32_t, int32_t, int32_t, int32_t, int32_t, void*);
typedef int32_t (*iFiuiipi_t)(int32_t, uint32_t, int32_t, int32_t, void*, int32_t);
typedef int32_t (*iFuppipp_t)(uint32_t, void*, void*, int32_t, void*, void*);
typedef int32_t (*iFuppppp_t)(uint32_t, void*, void*, void*, void*, void*);
typedef int32_t (*iFpiiiii_t)(void*, int32_t, int32_t, int32_t, int32_t, int32_t);
@ -1155,6 +1160,7 @@ void vFpup(x64emu_t *emu, uintptr_t fcn) { vFpup_t fn = (vFpup_t)fcn; fn((void*)
void vFppi(x64emu_t *emu, uintptr_t fcn) { vFppi_t fn = (vFppi_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX); }
void vFppu(x64emu_t *emu, uintptr_t fcn) { vFppu_t fn = (vFppu_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX); }
void vFppp(x64emu_t *emu, uintptr_t fcn) { vFppp_t fn = (vFppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX); }
void iFEiw(x64emu_t *emu, uintptr_t fcn) { iFEiw_t fn = (iFEiw_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (int16_t)R_RSI); }
void iFEip(x64emu_t *emu, uintptr_t fcn) { iFEip_t fn = (iFEip_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (void*)R_RSI); }
void iFEWW(x64emu_t *emu, uintptr_t fcn) { iFEWW_t fn = (iFEWW_t)fcn; R_RAX=fn(emu, (uint16_t)R_RDI, (uint16_t)R_RSI); }
void iFEup(x64emu_t *emu, uintptr_t fcn) { iFEup_t fn = (iFEup_t)fcn; R_RAX=fn(emu, (uint32_t)R_RDI, (void*)R_RSI); }
@ -1163,6 +1169,7 @@ void iFEpL(x64emu_t *emu, uintptr_t fcn) { iFEpL_t fn = (iFEpL_t)fcn; R_RAX=fn(e
void iFEpp(x64emu_t *emu, uintptr_t fcn) { iFEpp_t fn = (iFEpp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI); }
void iFEpV(x64emu_t *emu, uintptr_t fcn) { iFEpV_t fn = (iFEpV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)(R_RSP + 8)); }
void iFESp(x64emu_t *emu, uintptr_t fcn) { iFESp_t fn = (iFESp_t)fcn; R_RAX=fn(emu, io_convert((void*)R_RDI), (void*)R_RSI); }
void iFiwC(x64emu_t *emu, uintptr_t fcn) { iFiwC_t fn = (iFiwC_t)fcn; R_RAX=fn((int32_t)R_RDI, (int16_t)R_RSI, (uint8_t)R_RDX); }
void iFiii(x64emu_t *emu, uintptr_t fcn) { iFiii_t fn = (iFiii_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX); }
void iFiiu(x64emu_t *emu, uintptr_t fcn) { iFiiu_t fn = (iFiiu_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX); }
void iFiip(x64emu_t *emu, uintptr_t fcn) { iFiip_t fn = (iFiip_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); }
@ -1400,7 +1407,7 @@ void pFippL(x64emu_t *emu, uintptr_t fcn) { pFippL_t fn = (pFippL_t)fcn; R_RAX=(
void pFuiii(x64emu_t *emu, uintptr_t fcn) { pFuiii_t fn = (pFuiii_t)fcn; R_RAX=(uintptr_t)fn((uint32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); }
void pFpiii(x64emu_t *emu, uintptr_t fcn) { pFpiii_t fn = (pFpiii_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); }
void pFpiip(x64emu_t *emu, uintptr_t fcn) { pFpiip_t fn = (pFpiip_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX); }
void pFpiuu(x64emu_t *emu, uintptr_t fcn) { pFpiuu_t fn = (pFpiuu_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX); }
void pFpiLL(x64emu_t *emu, uintptr_t fcn) { pFpiLL_t fn = (pFpiLL_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (uintptr_t)R_RDX, (uintptr_t)R_RCX); }
void pFpipi(x64emu_t *emu, uintptr_t fcn) { pFpipi_t fn = (pFpipi_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (int32_t)R_RCX); }
void pFpipp(x64emu_t *emu, uintptr_t fcn) { pFpipp_t fn = (pFpipp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
void pFpCWp(x64emu_t *emu, uintptr_t fcn) { pFpCWp_t fn = (pFpCWp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint8_t)R_RSI, (uint16_t)R_RDX, (void*)R_RCX); }
@ -1538,6 +1545,8 @@ void pFEpiii(x64emu_t *emu, uintptr_t fcn) { pFEpiii_t fn = (pFEpiii_t)fcn; R_RA
void pFEpipL(x64emu_t *emu, uintptr_t fcn) { pFEpipL_t fn = (pFEpipL_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX); }
void pFEpipp(x64emu_t *emu, uintptr_t fcn) { pFEpipp_t fn = (pFEpipp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
void pFEpupp(x64emu_t *emu, uintptr_t fcn) { pFEpupp_t fn = (pFEpupp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
void pFEppii(x64emu_t *emu, uintptr_t fcn) { pFEppii_t fn = (pFEppii_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); }
void pFEppip(x64emu_t *emu, uintptr_t fcn) { pFEppip_t fn = (pFEppip_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX); }
void pFEpppp(x64emu_t *emu, uintptr_t fcn) { pFEpppp_t fn = (pFEpppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); }
void pFuiiiu(x64emu_t *emu, uintptr_t fcn) { pFuiiiu_t fn = (pFuiiiu_t)fcn; R_RAX=(uintptr_t)fn((uint32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (uint32_t)R_R8); }
void pFuiipp(x64emu_t *emu, uintptr_t fcn) { pFuiipp_t fn = (pFuiipp_t)fcn; R_RAX=(uintptr_t)fn((uint32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8); }
@ -1617,6 +1626,7 @@ void iFEpuppp(x64emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn; R
void iFEppppp(x64emu_t *emu, uintptr_t fcn) { iFEppppp_t fn = (iFEppppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); }
void iFiiiiii(x64emu_t *emu, uintptr_t fcn) { iFiiiiii_t fn = (iFiiiiii_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9); }
void iFiiiiip(x64emu_t *emu, uintptr_t fcn) { iFiiiiip_t fn = (iFiiiiip_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9); }
void iFiuiipi(x64emu_t *emu, uintptr_t fcn) { iFiuiipi_t fn = (iFiuiipi_t)fcn; R_RAX=fn((int32_t)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (void*)R_R8, (int32_t)R_R9); }
void iFuppipp(x64emu_t *emu, uintptr_t fcn) { iFuppipp_t fn = (iFuppipp_t)fcn; R_RAX=fn((uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (void*)R_R8, (void*)R_R9); }
void iFuppppp(x64emu_t *emu, uintptr_t fcn) { iFuppppp_t fn = (iFuppppp_t)fcn; R_RAX=fn((uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); }
void iFpiiiii(x64emu_t *emu, uintptr_t fcn) { iFpiiiii_t fn = (iFpiiiii_t)fcn; R_RAX=fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9); }

View File

@ -224,6 +224,7 @@ void vFpup(x64emu_t *emu, uintptr_t fnc);
void vFppi(x64emu_t *emu, uintptr_t fnc);
void vFppu(x64emu_t *emu, uintptr_t fnc);
void vFppp(x64emu_t *emu, uintptr_t fnc);
void iFEiw(x64emu_t *emu, uintptr_t fnc);
void iFEip(x64emu_t *emu, uintptr_t fnc);
void iFEWW(x64emu_t *emu, uintptr_t fnc);
void iFEup(x64emu_t *emu, uintptr_t fnc);
@ -232,6 +233,7 @@ void iFEpL(x64emu_t *emu, uintptr_t fnc);
void iFEpp(x64emu_t *emu, uintptr_t fnc);
void iFEpV(x64emu_t *emu, uintptr_t fnc);
void iFESp(x64emu_t *emu, uintptr_t fnc);
void iFiwC(x64emu_t *emu, uintptr_t fnc);
void iFiii(x64emu_t *emu, uintptr_t fnc);
void iFiiu(x64emu_t *emu, uintptr_t fnc);
void iFiip(x64emu_t *emu, uintptr_t fnc);
@ -469,7 +471,7 @@ void pFippL(x64emu_t *emu, uintptr_t fnc);
void pFuiii(x64emu_t *emu, uintptr_t fnc);
void pFpiii(x64emu_t *emu, uintptr_t fnc);
void pFpiip(x64emu_t *emu, uintptr_t fnc);
void pFpiuu(x64emu_t *emu, uintptr_t fnc);
void pFpiLL(x64emu_t *emu, uintptr_t fnc);
void pFpipi(x64emu_t *emu, uintptr_t fnc);
void pFpipp(x64emu_t *emu, uintptr_t fnc);
void pFpCWp(x64emu_t *emu, uintptr_t fnc);
@ -607,6 +609,8 @@ void pFEpiii(x64emu_t *emu, uintptr_t fnc);
void pFEpipL(x64emu_t *emu, uintptr_t fnc);
void pFEpipp(x64emu_t *emu, uintptr_t fnc);
void pFEpupp(x64emu_t *emu, uintptr_t fnc);
void pFEppii(x64emu_t *emu, uintptr_t fnc);
void pFEppip(x64emu_t *emu, uintptr_t fnc);
void pFEpppp(x64emu_t *emu, uintptr_t fnc);
void pFuiiiu(x64emu_t *emu, uintptr_t fnc);
void pFuiipp(x64emu_t *emu, uintptr_t fnc);
@ -686,6 +690,7 @@ void iFEpuppp(x64emu_t *emu, uintptr_t fnc);
void iFEppppp(x64emu_t *emu, uintptr_t fnc);
void iFiiiiii(x64emu_t *emu, uintptr_t fnc);
void iFiiiiip(x64emu_t *emu, uintptr_t fnc);
void iFiuiipi(x64emu_t *emu, uintptr_t fnc);
void iFuppipp(x64emu_t *emu, uintptr_t fnc);
void iFuppppp(x64emu_t *emu, uintptr_t fnc);
void iFpiiiii(x64emu_t *emu, uintptr_t fnc);

View File

@ -1281,6 +1281,7 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo
return tmp;
}
#endif
if(!strcmp(pathname, "data.zip")) trace_end=0;
int ret = open(pathname, flags, mode);
return ret;
}

View File

@ -1086,8 +1086,8 @@ GOW(lseek, IFiIi)
GOW(lseek64, IFiIi)
//GO(lsetxattr,
//GO(lutimes,
//GO(__lxstat, iFipp)
//GO(__lxstat64, iFipp)
GOM(__lxstat, iFEipp)
GOM(__lxstat64, iFEipp)
//GO(__madvise,
//GOW(madvise,
GOM(makecontext, iFEppiV) //weak
@ -1136,31 +1136,31 @@ GO(__memmove_chk, pFppLL)
//GOI(__mempcpy,
//GOI(mempcpy,
//GOI(__mempcpy_chk,
GOW(memrchr, pFpiu)
GOW(memrchr, pFpiL)
GO(memset, pFpiL)
GO(__memset_chk, pFpiuu)
GO(__memset_chk, pFpiLL)
//GO(__mempcpy_small,
//GO(__merge_grp,
//GO(mincore,
GO(mincore, iFpLp)
GOW(mkdir, iFpu)
GO(mkdirat, iFipu)
GO(mkdtemp, pFp)
GO(mkfifo, iFpu)
GO(mkfifoat, iFipu)
//GO(mkostemp,
//GOW(mkostemp64,
GO(mkostemp, iFpi)
GOW(mkostemp64, iFpi)
//GO(mkostemps,
//GOW(mkostemps64,
//GO(mkstemp,
//GOW(mkstemp64,
GO(mkstemp, iFp)
GOW(mkstemp64, iFp)
//GO(mkstemps,
//GOW(mkstemps64,
//GO(__mktemp,
//GOW(mktemp,
//GO(mktime,
//GO(mlock,
GO(__mktemp, pFp)
GOW(mktemp, pFp)
GO(mktime, uFp)
GO(mlock, iFpL)
//GO(mlock2,
//GO(mlockall,
GO(mlockall, iFi)
//GO(__mmap,
//GOW(mmap,
//GOW(mmap64,

164
src/wrapped/wrappedsdl2image.c Executable file
View File

@ -0,0 +1,164 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "box64context.h"
#include "sdl2rwops.h"
typedef void* (*pFpi_t)(void*, int32_t);
typedef void* (*pFp_t)(void*);
typedef void* (*pFpip_t)(void*, int32_t, void*);
typedef void* (*pFppi_t)(void*, void*, int32_t);
typedef int32_t (*iFppi_t)(void*, void*, int32_t);
typedef void* (*pFppip_t)(void*, void*, int32_t, void*);
typedef struct sdl2image_my_s {
pFp_t IMG_LoadBMP_RW;
pFp_t IMG_LoadCUR_RW;
pFp_t IMG_LoadGIF_RW;
pFp_t IMG_LoadICO_RW;
pFp_t IMG_LoadJPG_RW;
pFp_t IMG_LoadLBM_RW;
pFp_t IMG_LoadPCX_RW;
pFp_t IMG_LoadPNG_RW;
pFp_t IMG_LoadPNM_RW;
pFp_t IMG_LoadTGA_RW;
pFp_t IMG_LoadTIF_RW;
pFpip_t IMG_LoadTyped_RW;
pFp_t IMG_LoadWEBP_RW;
pFp_t IMG_LoadXCF_RW;
pFp_t IMG_LoadXPM_RW;
pFp_t IMG_LoadXV_RW;
pFpi_t IMG_Load_RW;
iFppi_t IMG_SavePNG_RW;
pFppi_t IMG_LoadTexture_RW;
pFppip_t IMG_LoadTextureTyped_RW;
} sdl2image_my_t;
static library_t* my_lib = NULL;
static void* getSDL2ImageMy(library_t* lib)
{
sdl2image_my_t* my = (sdl2image_my_t*)calloc(1, sizeof(sdl2image_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
GO(IMG_LoadBMP_RW,pFp_t)
GO(IMG_LoadCUR_RW,pFp_t)
GO(IMG_LoadGIF_RW,pFp_t)
GO(IMG_LoadICO_RW,pFp_t)
GO(IMG_LoadJPG_RW,pFp_t)
GO(IMG_LoadLBM_RW,pFp_t)
GO(IMG_LoadPCX_RW,pFp_t)
GO(IMG_LoadPNG_RW,pFp_t)
GO(IMG_LoadPNM_RW,pFp_t)
GO(IMG_LoadTGA_RW,pFp_t)
GO(IMG_LoadTIF_RW,pFp_t)
GO(IMG_LoadTyped_RW,pFpip_t)
GO(IMG_LoadWEBP_RW,pFp_t)
GO(IMG_LoadXCF_RW,pFp_t)
GO(IMG_LoadXPM_RW,pFp_t)
GO(IMG_LoadXV_RW,pFp_t)
GO(IMG_Load_RW,pFpi_t)
GO(IMG_SavePNG_RW, iFppi_t)
GO(IMG_LoadTexture_RW, pFppi_t)
GO(IMG_LoadTextureTyped_RW, pFppip_t)
#undef GO
return my;
}
#define GO(A) \
EXPORT void *my2_##A(x64emu_t* emu, void* a) \
{ \
sdl2image_my_t *my = (sdl2image_my_t *)my_lib->priv.w.p2; \
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a); \
void* r = my->A(rw); \
RWNativeEnd2(rw); \
return r; \
}
GO(IMG_LoadBMP_RW)
GO(IMG_LoadCUR_RW)
GO(IMG_LoadGIF_RW)
GO(IMG_LoadICO_RW)
GO(IMG_LoadJPG_RW)
GO(IMG_LoadLBM_RW)
GO(IMG_LoadPCX_RW)
GO(IMG_LoadPNG_RW)
GO(IMG_LoadPNM_RW)
GO(IMG_LoadTGA_RW)
GO(IMG_LoadTIF_RW)
GO(IMG_LoadWEBP_RW)
GO(IMG_LoadXCF_RW)
GO(IMG_LoadXPM_RW)
GO(IMG_LoadXV_RW)
#undef GO
EXPORT void *my2_IMG_LoadTyped_RW(x64emu_t* emu, void* a, int32_t b, void* c)
{
sdl2image_my_t *my = (sdl2image_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->IMG_LoadTyped_RW(rw, b, c);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT void *my2_IMG_Load_RW(x64emu_t* emu, void* a, int32_t b)
{
sdl2image_my_t *my = (sdl2image_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->IMG_Load_RW(rw, b);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT int32_t my2_IMG_SavePNG_RW(x64emu_t* emu, void* a, void* surf, int32_t compression)
{
sdl2image_my_t *my = (sdl2image_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
int32_t r = my->IMG_SavePNG_RW(rw, surf, compression);
RWNativeEnd2(rw);
return r;
}
EXPORT void* my2_IMG_LoadTexture_RW(x64emu_t* emu, void* rend, void* a, int32_t b)
{
sdl2image_my_t *my = (sdl2image_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->IMG_LoadTexture_RW(rend, rw, b);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT void* my2_IMG_LoadTextureTyped_RW(x64emu_t* emu, void* rend, void* a, int32_t b, void* type)
{
sdl2image_my_t *my = (sdl2image_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->IMG_LoadTextureTyped_RW(rend, rw, b, type);
if(b==0)
RWNativeEnd2(rw);
return r;
}
const char* sdl2imageName = "libSDL2_image-2.0.so.0";
#define LIBNAME sdl2image
#define CUSTOM_INIT \
my_lib = lib; \
lib->priv.w.p2 = getSDL2ImageMy(lib); \
lib->altmy = strdup("my2_");
#define CUSTOM_FINI \
free(lib->priv.w.p2); \
my_lib = NULL;
#include "wrappedlib_init.h"

View File

@ -0,0 +1,69 @@
#if defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)
DATA(__data_start, 4)
DATA(_edata, 4)
// _fini
GO(IMG_Init,iFi)
GO(IMG_InvertAlpha,iFi)
GO(IMG_Linked_Version,pFv)
GO(IMG_Load,pFp)
GOM(IMG_LoadBMP_RW,pFEp)
GOM(IMG_LoadCUR_RW,pFEp)
GOM(IMG_LoadGIF_RW,pFEp)
GOM(IMG_LoadICO_RW,pFEp)
GOM(IMG_LoadJPG_RW,pFEp)
GOM(IMG_LoadLBM_RW,pFEp)
GOM(IMG_LoadPCX_RW,pFEp)
GOM(IMG_LoadPNG_RW,pFEp)
GOM(IMG_LoadPNM_RW,pFEp)
GOM(IMG_LoadTGA_RW,pFEp)
GOM(IMG_LoadTIF_RW,pFEp)
GOM(IMG_LoadTyped_RW,pFEpip)
GOM(IMG_LoadWEBP_RW,pFEp)
GOM(IMG_LoadXCF_RW,pFEp)
GOM(IMG_LoadXPM_RW,pFEp)
GOM(IMG_LoadXV_RW,pFEp)
GOM(IMG_Load_RW,pFEpi)
GO(IMG_Quit,vFv)
GO(IMG_ReadXPMFromArray,pFp)
GO(IMG_isBMP,iFp)
GO(IMG_isCUR,iFp)
GO(IMG_isGIF,iFp)
GO(IMG_isICO,iFp)
GO(IMG_isJPG,iFp)
GO(IMG_isLBM,iFp)
GO(IMG_isPCX,iFp)
GO(IMG_isPNG,iFp)
GO(IMG_isPNM,iFp)
GO(IMG_isTIF,iFp)
GO(IMG_isWEBP,iFp)
GO(IMG_isXCF,iFp)
GO(IMG_isXPM,iFp)
GO(IMG_isXV,iFp)
// IMG_InitJPG
// IMG_InitPNG
// IMG_InitTIF
// IMG_InitWEBP
// IMG_isSVG
// IMG_LoadSVG_RW
GO(IMG_LoadTexture, pFpp)
GOM(IMG_LoadTexture_RW, pFEppi)
GOM(IMG_LoadTextureTyped_RW, pFEppip)
// IMG_QuitJPG
// IMG_QuitPNG
// IMG_QuitTIF
// IMG_QuitWEBP
// IMG_SaveJPG
// IMG_SaveJPG_RW
GO(IMG_SavePNG, iFppi)
GOM(IMG_SavePNG_RW, iFEppi)
// _init
DATA(nsvg__colors, 4)
// nsvgCreateRasterizer
// nsvgDelete
// nsvgDeleteRasterizer
// nsvgParse
// nsvg__parseXML
// nsvgRasterize
#endif

284
src/wrapped/wrappedsdl2mixer.c Executable file
View File

@ -0,0 +1,284 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "box64context.h"
#include "sdl2rwops.h"
#include "callback.h"
typedef void* (*pFpi_t)(void*, int32_t);
typedef int32_t(*iFip_t)(int32_t, void*);
typedef void* (*pFpii_t)(void*, int32_t, int32_t);
typedef void (*vFpp_t)(void*, void*);
typedef void (*vFp_t)(void*);
typedef int32_t (*iFippp_t)(int32_t, void*, void*, void*);
typedef int (*iFiwC_t)(int, int16_t, uint8_t);
#define SUPER() \
GO(Mix_LoadMUSType_RW,pFpii_t) \
GO(Mix_LoadMUS_RW,pFpi_t) \
GO(Mix_LoadWAV_RW,pFpi_t) \
GO(Mix_SetPostMix,vFpp_t) \
GO(Mix_RegisterEffect, iFippp_t) \
GO(Mix_UnregisterEffect, iFip_t) \
GO(Mix_ChannelFinished,vFp_t) \
GO(Mix_HookMusic, vFpp_t) \
GO(Mix_HookMusicFinished, vFp_t) \
GO(Mix_SetPosition, iFiwC_t) \
typedef struct sdl2mixer_my_s {
#define GO(A, B) B A;
SUPER()
#undef GO
x64emu_t* PostCallback;
x64emu_t* hookMusicCB;
} sdl2mixer_my_t;
static void* getSDL2MixerMy(library_t* lib)
{
sdl2mixer_my_t* my = (sdl2mixer_my_t*)calloc(1, sizeof(sdl2mixer_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
SUPER()
#undef GO
return my;
}
static void freeSDL2MixerMy(library_t* lib)
{
// sdl2mixer_my_t *my = lib->priv.w.p2;
}
#undef SUPER
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// EffectFunc
#define GO(A) \
static uintptr_t my_EffectFunc_fct_##A = 0; \
static void my_EffectFunc_##A(int chan, void *stream, int len, void *udata) \
{ \
RunFunction(my_context, my_EffectFunc_fct_##A, 4, chan, stream, len, udata); \
}
SUPER()
#undef GO
static void* find_EffectFunc_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_EffectFunc_fct_##A == (uintptr_t)fct) return my_EffectFunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_EffectFunc_fct_##A == 0) {my_EffectFunc_fct_##A = (uintptr_t)fct; return my_EffectFunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1Mixer EffectFunc callback\n");
return NULL;
}
// EffectDone
#define GO(A) \
static uintptr_t my_EffectDone_fct_##A = 0; \
static void my_EffectDone_##A(int chan, void *udata) \
{ \
RunFunction(my_context, my_EffectDone_fct_##A, 2, chan, udata); \
}
SUPER()
#undef GO
static void* find_EffectDone_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_EffectDone_fct_##A == (uintptr_t)fct) return my_EffectDone_##A;
SUPER()
#undef GO
#define GO(A) if(my_EffectDone_fct_##A == 0) {my_EffectDone_fct_##A = (uintptr_t)fct; return my_EffectDone_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1Mixer EffectDone callback\n");
return NULL;
}
// MixFunc
#define GO(A) \
static uintptr_t my_MixFunc_fct_##A = 0; \
static void my_MixFunc_##A(void *udata, uint8_t *stream, int len) \
{ \
RunFunction(my_context, my_MixFunc_fct_##A, 3, udata, stream, len); \
}
SUPER()
#undef GO
static void* find_MixFunc_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_MixFunc_fct_##A == (uintptr_t)fct) return my_MixFunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_MixFunc_fct_##A == 0) {my_MixFunc_fct_##A = (uintptr_t)fct; return my_MixFunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1Mixer MixFunc callback\n");
return NULL;
}
// ChannelFinished
#define GO(A) \
static uintptr_t my_ChannelFinished_fct_##A = 0; \
static void my_ChannelFinished_##A(int channel) \
{ \
RunFunction(my_context, my_ChannelFinished_fct_##A, 1, channel); \
}
SUPER()
#undef GO
static void* find_ChannelFinished_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_ChannelFinished_fct_##A == (uintptr_t)fct) return my_ChannelFinished_##A;
SUPER()
#undef GO
#define GO(A) if(my_ChannelFinished_fct_##A == 0) {my_ChannelFinished_fct_##A = (uintptr_t)fct; return my_ChannelFinished_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1Mixer ChannelFinished callback\n");
return NULL;
}
// MusicFinished
#define GO(A) \
static uintptr_t my_MusicFinished_fct_##A = 0; \
static void my_MusicFinished_##A() \
{ \
RunFunction(my_context, my_MusicFinished_fct_##A, 0); \
}
SUPER()
#undef GO
static void* find_MusicFinished_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_MusicFinished_fct_##A == (uintptr_t)fct) return my_MusicFinished_##A;
SUPER()
#undef GO
#define GO(A) if(my_MusicFinished_fct_##A == 0) {my_MusicFinished_fct_##A = (uintptr_t)fct; return my_MusicFinished_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1Mixer MusicFinished callback\n");
return NULL;
}
#undef SUPER
EXPORT void* my2_Mix_LoadMUSType_RW(x64emu_t* emu, void* a, int32_t b, int32_t c)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->Mix_LoadMUSType_RW(rw, b, c);
if(c==0)
RWNativeEnd2(rw);
return r;
}
EXPORT void* my2_Mix_LoadMUS_RW(x64emu_t* emu, void* a, int32_t f)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->Mix_LoadMUS_RW(rw, f);
if(f==0)
RWNativeEnd2(rw); // this one never free the RWops
return r;
}
EXPORT void* my2_Mix_LoadWAV_RW(x64emu_t* emu, void* a, int32_t f)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->Mix_LoadWAV_RW(rw, f);
if(f==0)
RWNativeEnd2(rw);
return r;
}
EXPORT void my2_Mix_SetPostMix(x64emu_t* emu, void* a, void* b)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
my->Mix_SetPostMix(find_MixFunc_Fct(a), b);
}
EXPORT int32_t my2_Mix_RegisterEffect(x64emu_t*emu, int32_t channel, void* cb_effect, void* cb_done, void* arg)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
return my->Mix_RegisterEffect(channel, find_EffectFunc_Fct(cb_effect), find_EffectDone_Fct(cb_done), arg);
}
EXPORT int32_t my2_Mix_UnregisterEffect(x64emu_t* emu, int channel, void* f)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
return my->Mix_UnregisterEffect(channel, find_EffectFunc_Fct(f));
}
EXPORT void my2_Mix_ChannelFinished(x64emu_t* emu, void* cb)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
my->Mix_ChannelFinished(find_ChannelFinished_Fct(cb));
}
EXPORT void my2_Mix_HookMusic(x64emu_t* emu, void* f, void* arg)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
my->Mix_HookMusic(find_MixFunc_Fct(f), arg);
}
EXPORT void my2_Mix_HookMusicFinished(x64emu_t* emu, void* f)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
my->Mix_HookMusicFinished(find_MusicFinished_Fct(f));
}
// This is a hack for AntiChamber
EXPORT int my2_MinorityMix_SetPosition(x64emu_t* emu, int channel, int16_t angle)
{
sdl2mixer_my_t *my = (sdl2mixer_my_t *)emu->context->sdl2mixerlib->priv.w.p2;
return my->Mix_SetPosition(channel, angle, 0);
}
const char* sdl2mixerName = "libSDL2_mixer-2.0.so.0";
#define LIBNAME sdl2mixer
#define CUSTOM_INIT \
box64->sdl2mixerlib = lib; \
lib->priv.w.p2 = getSDL2MixerMy(lib); \
lib->altmy = strdup("my2_");
#define CUSTOM_FINI \
freeSDL2MixerMy(lib); \
free(lib->priv.w.p2); \
((box64context_t*)(lib->context))->sdl2mixerlib = NULL;
#include "wrappedlib_init.h"

View File

@ -0,0 +1,86 @@
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
#error meh!
#endif
DATA(__data_start, 4)
DATA(_edata, 4)
// _fini
// _init
GO(Mix_AllocateChannels, iFi)
GOM(Mix_ChannelFinished, vFEp)
GO(Mix_CloseAudio, vFv)
// Mix_EachSoundFont
GO(Mix_ExpireChannel,iFii)
GO(Mix_FadeInChannelTimed,iFipiii)
GO(Mix_FadeInMusic,iFpii)
GO(Mix_FadeInMusicPos,iFpiid)
GO(Mix_FadeOutChannel,iFii)
GO(Mix_FadeOutGroup,iFii)
GO(Mix_FadeOutMusic,iFi)
GO(Mix_FadingChannel,iFi)
GO(Mix_FadingMusic,iFv)
GO(Mix_FreeChunk,vFp)
GO(Mix_FreeMusic,vFp)
GO(Mix_GetChunk,pFi)
GO(Mix_GetChunkDecoder,pFi)
GO(Mix_GetMusicDecoder,pFi)
GO(Mix_GetMusicHookData,pFv)
GO(Mix_GetMusicType,iFp)
GO(Mix_GetNumChunkDecoders,iFv)
GO(Mix_GetNumMusicDecoders,iFv)
GO(Mix_GetSoundFonts,pFv)
GO(Mix_GetSynchroValue,iFv)
GO(Mix_GroupAvailable,iFi)
GO(Mix_GroupChannel,iFii)
GO(Mix_GroupChannels,iFiii)
GO(Mix_GroupCount,iFi)
GO(Mix_GroupNewer,iFi)
GO(Mix_GroupOldest,iFi)
GO(Mix_HaltChannel,iFi)
GO(Mix_HaltGroup,iFi)
GO(Mix_HaltMusic,iFv)
// Mix_HasChunkDecoder
GOM(Mix_HookMusic, vFEpp)
GOM(Mix_HookMusicFinished, vFEp)
GO(Mix_Init,iFi)
GO(Mix_Linked_Version,pFv)
GO(Mix_LoadMUS,pFp)
GOM(Mix_LoadMUSType_RW,pFEpii)
GOM(Mix_LoadMUS_RW,pFEpi)
GOM(Mix_LoadWAV_RW,pFEpi)
GO(Mix_OpenAudio,iFiuii)
GO(Mix_OpenAudioDevice, iFiuiipi)
GO(Mix_Pause,vFi)
GO(Mix_PauseMusic,vFv)
GO(Mix_Paused,iFi)
GO(Mix_PausedMusic,iFv)
GO(Mix_PlayChannelTimed,iFipii)
GO(Mix_PlayMusic,iFpi)
GO(Mix_Playing,iFi)
GO(Mix_PlayingMusic,iFv)
GO(Mix_QuerySpec,iFppp)
GO(Mix_QuickLoad_RAW,pFpu)
GO(Mix_QuickLoad_WAV,pFp)
GO(Mix_Quit,vFv)
GO(Mix_Pause, vFi)
GOM(Mix_RegisterEffect, iFEippp)
GO(Mix_ReserveChannels,iFi)
GO(Mix_Resume,vFi)
GO(Mix_ResumeMusic,vFv)
GO(Mix_RewindMusic,vFv)
GO(Mix_SetDistance,iFiu)
GO(Mix_SetMusicCMD,iFp)
GO(Mix_SetMusicPosition,iFd)
GO(Mix_SetPanning,iFiuu)
GO(Mix_SetPosition,iFiwC)
GOM(MinorityMix_SetPosition, iFEiw)
GOM(Mix_SetPostMix,vFEpp)
GO(Mix_SetReverseStereo,iFii)
GO(Mix_SetSoundFonts,iFp)
GO(Mix_SetSynchroValue,iFi)
GO(Mix_UnregisterAllEffects, iFi)
GOM(Mix_UnregisterEffect, iFEip)
GO(Mix_Volume,iFii)
GO(Mix_VolumeChunk,iFpi)
GO(Mix_VolumeMusic,iFi)

71
src/wrapped/wrappedsdl2ttf.c Executable file
View File

@ -0,0 +1,71 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "box64context.h"
#include "sdl2rwops.h"
typedef void* (*pFpii_t)(void*, int32_t, int32_t);
typedef void* (*pFpiii_t)(void*, int32_t, int32_t, int32_t);
typedef struct sdl2ttf_my_s {
pFpii_t TTF_OpenFontRW;
pFpiii_t TTF_OpenFontIndexRW;
} sdl2ttf_my_t;
static void* getSDL2TTFMy(library_t* lib)
{
sdl2ttf_my_t* my = (sdl2ttf_my_t*)calloc(1, sizeof(sdl2ttf_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
GO(TTF_OpenFontIndexRW,pFpiii_t)
GO(TTF_OpenFontRW, pFpii_t)
#undef GO
return my;
}
static library_t* my_lib = NULL;
void EXPORT *my2_TTF_OpenFontIndexRW(x64emu_t* emu, void* a, int32_t b, int32_t c, int32_t d)
{
sdl2ttf_my_t *my = (sdl2ttf_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t* rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->TTF_OpenFontIndexRW(rw, b, c, d);
if(b==0)
RWNativeEnd2(rw);
return r;
}
void EXPORT *my2_TTF_OpenFontRW(x64emu_t* emu, void* a, int32_t b, int32_t c)
{
sdl2ttf_my_t *my = (sdl2ttf_my_t *)my_lib->priv.w.p2;
SDL2_RWops_t* rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->TTF_OpenFontRW(rw, b, c);
if(b==0)
RWNativeEnd2(rw);
return r;
}
const char* sdl2ttfName = "libSDL2_ttf-2.0.so.0";
#define LIBNAME sdl2ttf
#define CUSTOM_INIT \
my_lib = lib; \
lib->altmy = strdup("my2_"); \
lib->priv.w.p2 = getSDL2TTFMy(lib);
#define CUSTOM_FINI \
free(lib->priv.w.p2); \
my_lib = NULL;
#include "wrappedlib_init.h"

View File

@ -0,0 +1,49 @@
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
#error Meh!
#endif
GO(TTF_ByteSwappedUNICODE, vFi)
GO(TTF_CloseFont, vFp)
GO(TTF_FontAscent, iFp)
GO(TTF_FontDescent, iFp)
GO(TTF_FontFaceFamilyName, pFp)
GO(TTF_FontFaceIsFixedWidth, iFp)
GO(TTF_FontFaces, iFp)
GO(TTF_FontFaceStyleName, pFp)
GO(TTF_FontHeight, iFp)
GO(TTF_FontLineSkip, iFp)
GO(TTF_GetFontHinting, iFp)
GO(TTF_GetFontKerning, iFp)
GO(TTF_GetFontKerningSize, iFp)
GO(TTF_GetFontOutline, iFp)
GO(TTF_GetFontStyle, iFp)
GO(TTF_GlyphIsProvided, iFpu)
GO(TTF_GlyphMetrics, iFpuppppp)
GO(TTF_Init, iFv)
GO(TTF_Linked_Version, pFv)
GO(TTF_OpenFont, pFpi)
GO(TTF_OpenFontIndex, pFpii)
GOM(TTF_OpenFontIndexRW, pFEpiii)
GOM(TTF_OpenFontRW, pFEpii)
GO(TTF_Quit, vFv)
GO(TTF_RenderGlyph_Blended, pFpuu)
GO(TTF_RenderGlyph_Shaded, pFpuuu)
GO(TTF_RenderGlyph_Solid, pFpuu)
GO(TTF_RenderText_Blended, pFppu)
GO(TTF_RenderText_Shaded, pFppuu)
GO(TTF_RenderText_Solid, pFppu)
GO(TTF_RenderUNICODE_Blended, pFppu)
GO(TTF_RenderUNICODE_Shaded, pFppuu)
GO(TTF_RenderUNICODE_Solid, pFppu)
GO(TTF_RenderUTF8_Blended, pFppu)
GO(TTF_RenderUTF8_Shaded, pFppuu)
GO(TTF_RenderUTF8_Solid, pFppu)
GO(TTF_SetFontHinting, vFpi)
GO(TTF_SetFontKerning, vFpi)
GO(TTF_SetFontOutline, vFpi)
GO(TTF_SetFontStyle, vFpi)
GO(TTF_SizeText, iFpppp)
GO(TTF_SizeUNICODE, iFpppp)
GO(TTF_SizeUTF8, iFpppp)
GO(TTF_WasInit, iFv)

111
src/wrapped/wrappedsmpeg2.c Executable file
View File

@ -0,0 +1,111 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "librarian.h"
#include "x64emu.h"
#include "callback.h"
#include "box64context.h"
#include "sdl2rwops.h"
#include "myalign.h"
const char* smpeg2Name = "libsmpeg2-2.0.so.0";
#define LIBNAME smpeg2
typedef void (*vFpp_t)(void*, void*);
typedef void (*vFpppp_t)(void*, void*, void*, void*);
typedef void* (*pFppi_t)(void*, void*, int32_t);
typedef void* (*pFipi_t)(int32_t, void*, int32_t);
typedef void* (*pFpipi_t)(void*, int32_t, void*, int32_t);
typedef void* (*pFppii_t)(void*, void*, int32_t, int32_t);
typedef struct smpeg2_my_s {
// functions
vFpppp_t SMPEG_setdisplay;
pFppii_t SMPEG_new_rwops;
} smpeg2_my_t;
static void* getSMPEG2My(library_t* lib)
{
smpeg2_my_t* my = (smpeg2_my_t*)calloc(1, sizeof(smpeg2_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
GO(SMPEG_setdisplay, vFpppp_t)
GO(SMPEG_new_rwops, pFppii_t)
#undef GO
return my;
}
static void freeSMPEG2My(void* lib)
{
//smpeg2_my_t *my = (smpeg2_my_t *)lib;
}
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// dispcallback ...
#define GO(A) \
static uintptr_t my_dispcallback_fct_##A = 0; \
static void my_dispcallback_##A(void* data, void* frame) \
{ \
RunFunction(my_context, my_dispcallback_fct_##A, 2, data, frame); \
}
SUPER()
#undef GO
static void* find_dispcallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_dispcallback_fct_##A == (uintptr_t)fct) return my_dispcallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_dispcallback_fct_##A == 0) {my_dispcallback_fct_##A = (uintptr_t)fct; return my_dispcallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libsmpeg2 dispcallback callback\n");
return NULL;
}
#undef SUPER
EXPORT void my2_SMPEG_setdisplay(x64emu_t* emu, void* mpeg, void* cb, void* data, void* lock)
{
library_t* lib = GetLibInternal(smpeg2Name);
smpeg2_my_t* my = (smpeg2_my_t*)lib->priv.w.p2;
my->SMPEG_setdisplay(mpeg, find_dispcallback_Fct(cb), data, lock);
}
EXPORT void* my2_SMPEG_new_rwops(x64emu_t* emu, void* src, void* info, int32_t f, int32_t audio)
{
library_t* lib = GetLibInternal(smpeg2Name);
smpeg2_my_t* my = (smpeg2_my_t*)lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)src);
void* ret = my->SMPEG_new_rwops(rw, info, f, audio);
if(!f) {
RWNativeEnd2(rw);
}
return ret;
}
#define CUSTOM_INIT \
lib->priv.w.p2 = getSMPEG2My(lib); \
lib->altmy = strdup("my2_");
#define CUSTOM_FINI \
freeSMPEG2My(lib->priv.w.p2); \
free(lib->priv.w.p2); \
#include "wrappedlib_init.h"

View File

@ -0,0 +1,29 @@
#if defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)
GO(SMPEG_actualSpec,vFpp)
GO(SMPEG_delete,vFp)
GO(SMPEG_enableaudio,vFpi)
GO(SMPEG_enablevideo,vFpi)
GO(SMPEG_error,pFp)
GO(SMPEG_getinfo,vFpp)
GO(SMPEG_loop,vFpi)
GO(SMPEG_new,pFppi)
GO(SMPEG_new_data,pFpipi)
GO(SMPEG_new_descr,pFipi)
GOM(SMPEG_new_rwops,pFEppii)
GO(SMPEG_pause,vFp)
GO(SMPEG_play,vFp)
GO(SMPEG_playAudio,iFppi)
GO(SMPEG_playAudioSDL,vFppi)
GO(SMPEG_renderFinal,vFp)
GO(SMPEG_renderFrame,vFpi)
GO(SMPEG_rewind,vFp)
GO(SMPEG_seek,vFpi)
GOM(SMPEG_setdisplay,vFEpppp)
GO(SMPEG_setvolume,vFpi)
GO(SMPEG_skip,vFpf)
GO(SMPEG_status,iFp)
GO(SMPEG_stop,vFp)
GO(SMPEG_wantedSpec,iFpp)
#endif