From fd73a2bc8bc830054a4fcc418c630f4ad648be21 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 10 Oct 2024 09:46:32 +0200 Subject: [BOX32] Morewrapped SDL2 function, and improved handling of SDL_PixelFormat --- src/include/sdl2align32.h | 9 ++++ src/libtools/sdl2align32.c | 72 ++++++++++++++++++++++++++ src/wrapped32/generated/functions_list.txt | 9 ++++ src/wrapped32/generated/wrappedsdl2types32.h | 8 ++- src/wrapped32/generated/wrapper32.c | 6 +++ src/wrapped32/generated/wrapper32.h | 3 ++ src/wrapped32/wrappedlibc_private.h | 2 +- src/wrapped32/wrappedsdl2.c | 30 ++++++++++- src/wrapped32/wrappedsdl2_private.h | 76 ++++++++++++++-------------- 9 files changed, 174 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/include/sdl2align32.h b/src/include/sdl2align32.h index dd93d85e..91f54ea2 100644 --- a/src/include/sdl2align32.h +++ b/src/include/sdl2align32.h @@ -838,6 +838,13 @@ typedef struct my_SDL2_PixelFormat_32_s { ptr_t next; } my_SDL2_PixelFormat_32_t; +// used to mirror the pixelformat on x86 side, as the one in native side is a global static used by SDL2 and so cannot be inplace shrinked +typedef struct my_SDL2_PixelFormat_32_ext_s { + my_SDL2_PixelFormat_32_t fmt; + my_SDL2_PixelFormat_t* ref; + struct my_SDL2_PixelFormat_32_ext_s* next; +} my_SDL2_PixelFormat_32_ext_t; + typedef struct my_SDL2_Rect_32_s { int x, y; int w, h; @@ -890,9 +897,11 @@ void inplace_SDL2_Event_enlarge(void* e); void inplace_SDL2_Palette_to_32(void* a); void inplace_SDL2_PixelFormat_to_32(void* a); +void* replace_SDL2_PixelFormat_to_32_ext(void* a); void inplace_SDL2_Surface_to_32(void* a); void inplace_SDL2_Palette_to_64(void* a); void inplace_SDL2_PixelFormat_to_64(void* a); +void* replace_SDL2_PixelFormat_to_64_ext(void* a); void inplace_SDL2_Surface_to_64(void* a); void inplace_SDL2_RWops_to_32(void* a); diff --git a/src/libtools/sdl2align32.c b/src/libtools/sdl2align32.c index 540d3cc5..377b85e1 100644 --- a/src/libtools/sdl2align32.c +++ b/src/libtools/sdl2align32.c @@ -456,14 +456,82 @@ void inplace_SDL2_PixelFormat_to_32(void* a) } } +// used to mirror the pixelformat on x86 side, as the one in native side is a global static used by SDL2 and so cannot be inplace shrinked +// TODO: the pixelformats are leaking. There is no mecanism to remove them +// test of refcount should be done when surface are removed to delete the format, in sync with SDL2 +static my_SDL2_PixelFormat_32_ext_t* pixelformat_head = NULL; + +static my_SDL2_PixelFormat_32_ext_t* find_pixelformat_ext(my_SDL2_PixelFormat_t* a) +{ + my_SDL2_PixelFormat_32_ext_t* head = pixelformat_head; + while(head) { + if(head->ref == a) + return head; + head = head->next; + } + return NULL; +} + +void* replace_SDL2_PixelFormat_to_32_ext(void* a) +{ + if(!a) return NULL; + my_SDL2_PixelFormat_t* src = a; + my_SDL2_PixelFormat_32_ext_t* dst = find_pixelformat_ext(src); + if(dst) return dst; + // create a new one + dst = calloc(1, sizeof(my_SDL2_PixelFormat_32_ext_t)+(src->palette?sizeof(my_SDL2_Palette_32_t):0)); // not using box_calloc as we want this to be 32bits + // copye the values + dst->ref = src; + dst->fmt.format = src->format; + if(src->palette) { + my_SDL2_Palette_32_t* pal = (void*)((uintptr_t)dst)+sizeof(my_SDL2_PixelFormat_32_ext_t); + dst->fmt.palette = to_ptrv(pal); + pal->ncolors = src->palette->ncolors; + pal->colors = to_ptrv(src->palette->colors); + pal->version = src->palette->version; + pal->refcount = src->palette->refcount; + } else dst->fmt.palette = 0; + dst->fmt.BitsPerPixel = src->BitsPerPixel; + dst->fmt.BytesPerPixel = src->BytesPerPixel; + dst->fmt.Rmask = src->Rmask; + dst->fmt.Gmask = src->Gmask; + dst->fmt.Bmask = src->Bmask; + dst->fmt.Amask = src->Amask; + dst->fmt.Rloss = src->Rloss; + dst->fmt.Gloss = src->Gloss; + dst->fmt.Bloss = src->Bloss; + dst->fmt.Aloss = src->Aloss; + dst->fmt.Rshift = src->Rshift; + dst->fmt.Gshift = src->Gshift; + dst->fmt.Bshift = src->Bshift; + dst->fmt.Ashift = src->Ashift; + dst->fmt.refcount = src->refcount; + dst->fmt.next = to_ptrv(src->next); + // insert at head and return the value + dst->next = pixelformat_head; + pixelformat_head = dst; + return dst; +} + +void* replace_SDL2_PixelFormat_to_64_ext(void* a) +{ + if(!a) return a; + my_SDL2_PixelFormat_32_ext_t* dst = a; + return dst->ref; +} + void inplace_SDL2_Surface_to_32(void* a) { if (!a) return; my_SDL2_Surface_t* src = a; my_SDL2_Surface_32_t* dst = a; dst->flags = src->flags; + #if 0 inplace_SDL2_PixelFormat_to_32(src->format); dst->format = to_ptrv(src->format); + #else + dst->format = to_ptrv(replace_SDL2_PixelFormat_to_32_ext(src->format)); + #endif dst->w = src->w; dst->h = src->h; dst->pitch = src->pitch; @@ -542,9 +610,13 @@ void inplace_SDL2_Surface_to_64(void* a) dst->pitch = src->pitch; dst->h = src->h; dst->w = src->w; + #if 0 uintptr_t p = (uintptr_t)(src->format); inplace_SDL2_PixelFormat_to_64((void*)p); dst->format = from_ptrv(src->format); + #else + dst->format = replace_SDL2_PixelFormat_to_64_ext(from_ptrv(src->format)); + #endif dst->flags = src->flags; } diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 53515b46..4722335f 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -256,6 +256,7 @@ #() pFXu -> pFXu #() pFXL -> pFXL #() pFXp -> pFXp +#() hFEp -> hFEp #() hFpa -> hFpa #() SFip -> SFip #() SFpp -> SFpp @@ -470,6 +471,7 @@ #() uFuuu -> uFuuu #() uFuup -> uFuup #() uFupp -> uFupp +#() uFpii -> uFpii #() uFpuU -> uFpuU #() uFpup -> uFpup #() uFppu -> uFppu @@ -1409,6 +1411,7 @@ #() iFXiLLdduudd -> iFXiLLdduudd #() iFXuuLiuiiLL -> iFXuuLiuiiLL #() iFXLLpiiuuii -> iFXLLpiiuuii +#() pFEpiiiiuuuu -> pFEpiiiiuuuu #() pFpppppppppp -> pFpppppppppp #() pFXpuiipuuii -> pFXpuiipuuii #() iFXiiLiiibiip_ip -> iFXiiLiiiBip @@ -2257,6 +2260,8 @@ wrappedsdl2: - SDL_GetBasePath - pFp: - SDL_GL_GetProcAddress +- hFp: + - SDL_GetThreadID - JFi: - SDL_JoystickGetDeviceGUID - vFpp: @@ -2299,6 +2304,8 @@ wrappedsdl2: - SDL_CreateColorCursor - pFpuu: - SDL_ConvertSurfaceFormat +- pFppu: + - SDL_ConvertSurface - pFppp: - SDL_CreateThread - iFpLpp: @@ -2316,6 +2323,8 @@ wrappedsdl2: - SDL_CreateRGBSurfaceWithFormatFrom - pFuiiiuuuu: - SDL_CreateRGBSurface +- pFpiiiiuuuu: + - SDL_CreateRGBSurfaceFrom % JFEi -> pFEpi wrappedsdl2image: - pFp: diff --git a/src/wrapped32/generated/wrappedsdl2types32.h b/src/wrapped32/generated/wrappedsdl2types32.h index 10e83607..447aab69 100644 --- a/src/wrapped32/generated/wrappedsdl2types32.h +++ b/src/wrapped32/generated/wrappedsdl2types32.h @@ -16,6 +16,7 @@ typedef int32_t (*iFp_t)(void*); typedef int64_t (*IFp_t)(void*); typedef void* (*pFv_t)(void); typedef void* (*pFp_t)(void*); +typedef uintptr_t (*hFp_t)(void*); typedef SDL2_GUID_t (*JFi_t)(int32_t); typedef void (*vFpp_t)(void*, void*); typedef void (*vFpV_t)(void*, ...); @@ -32,6 +33,7 @@ typedef int64_t (*IFpIi_t)(void*, int64_t, int32_t); typedef void* (*pFipp_t)(int32_t, void*, void*); typedef void* (*pFpii_t)(void*, int32_t, int32_t); typedef void* (*pFpuu_t)(void*, uint32_t, uint32_t); +typedef void* (*pFppu_t)(void*, void*, uint32_t); typedef void* (*pFppp_t)(void*, void*, void*); typedef int32_t (*iFpLpp_t)(void*, uintptr_t, void*, void*); typedef int32_t (*iFpLpV_t)(void*, uintptr_t, void*, ...); @@ -40,6 +42,7 @@ typedef int32_t (*iFpiuuu_t)(void*, int32_t, uint32_t, uint32_t, uint32_t); typedef uint32_t (*uFpippi_t)(void*, int32_t, void*, void*, int32_t); typedef void* (*pFpiiiiu_t)(void*, int32_t, int32_t, int32_t, int32_t, uint32_t); typedef void* (*pFuiiiuuuu_t)(uint32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, uint32_t, uint32_t); +typedef void* (*pFpiiiiuuuu_t)(void*, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, uint32_t, uint32_t); #define SUPER() ADDED_FUNCTIONS() \ GO(SDL_FreeSurface, vFp_t) \ @@ -50,6 +53,7 @@ typedef void* (*pFuiiiuuuu_t)(uint32_t, int32_t, int32_t, int32_t, uint32_t, uin GO(SDL_RWtell, IFp_t) \ GO(SDL_GetBasePath, pFv_t) \ GO(SDL_GL_GetProcAddress, pFp_t) \ + GO(SDL_GetThreadID, hFp_t) \ GO(SDL_JoystickGetDeviceGUID, JFi_t) \ GO(SDL_AddEventWatch, vFpp_t) \ GO(SDL_DelEventWatch, vFpp_t) \ @@ -76,6 +80,7 @@ typedef void* (*pFuiiiuuuu_t)(uint32_t, int32_t, int32_t, int32_t, uint32_t, uin GO(SDL_GetClosestDisplayMode, pFipp_t) \ GO(SDL_CreateColorCursor, pFpii_t) \ GO(SDL_ConvertSurfaceFormat, pFpuu_t) \ + GO(SDL_ConvertSurface, pFppu_t) \ GO(SDL_CreateThread, pFppp_t) \ GO(SDL_vsnprintf, iFpLpp_t) \ GO(SDL_snprintf, iFpLpV_t) \ @@ -84,6 +89,7 @@ typedef void* (*pFuiiiuuuu_t)(uint32_t, int32_t, int32_t, int32_t, uint32_t, uin GO(SDL_PeepEvents, iFpiuuu_t) \ GO(SDL_OpenAudioDevice, uFpippi_t) \ GO(SDL_CreateRGBSurfaceWithFormatFrom, pFpiiiiu_t) \ - GO(SDL_CreateRGBSurface, pFuiiiuuuu_t) + GO(SDL_CreateRGBSurface, pFuiiiuuuu_t) \ + GO(SDL_CreateRGBSurfaceFrom, pFpiiiiuuuu_t) #endif // __wrappedsdl2TYPES32_H_ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index 1406160d..1be6a3bc 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -346,6 +346,7 @@ typedef void* (*pFXi_t)(void*, int32_t); typedef void* (*pFXu_t)(void*, uint32_t); typedef void* (*pFXL_t)(void*, uintptr_t); typedef void* (*pFXp_t)(void*, void*); +typedef uintptr_t (*hFEp_t)(x64emu_t*, void*); typedef uintptr_t (*hFpa_t)(void*, void*); typedef void* (*SFip_t)(int32_t, void*); typedef void* (*SFpp_t)(void*, void*); @@ -560,6 +561,7 @@ typedef uint32_t (*uFipu_t)(int32_t, void*, uint32_t); typedef uint32_t (*uFuuu_t)(uint32_t, uint32_t, uint32_t); typedef uint32_t (*uFuup_t)(uint32_t, uint32_t, void*); typedef uint32_t (*uFupp_t)(uint32_t, void*, void*); +typedef uint32_t (*uFpii_t)(void*, int32_t, int32_t); typedef uint32_t (*uFpuU_t)(void*, uint32_t, uint64_t); typedef uint32_t (*uFpup_t)(void*, uint32_t, void*); typedef uint32_t (*uFppu_t)(void*, void*, uint32_t); @@ -1499,6 +1501,7 @@ typedef int32_t (*iFppuuiiuuuu_t)(void*, void*, uint32_t, uint32_t, int32_t, int typedef int32_t (*iFXiLLdduudd_t)(void*, int32_t, uintptr_t, uintptr_t, double, double, uint32_t, uint32_t, double, double); typedef int32_t (*iFXuuLiuiiLL_t)(void*, uint32_t, uint32_t, uintptr_t, int32_t, uint32_t, int32_t, int32_t, uintptr_t, uintptr_t); typedef int32_t (*iFXLLpiiuuii_t)(void*, uintptr_t, uintptr_t, void*, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t); +typedef void* (*pFEpiiiiuuuu_t)(x64emu_t*, void*, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, uint32_t, uint32_t); typedef void* (*pFpppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFXpuiipuuii_t)(void*, void*, uint32_t, int32_t, int32_t, void*, uint32_t, uint32_t, int32_t, int32_t); typedef int32_t (*iFXiiLiiibiip_ip_t)(void*, int32_t, int32_t, uintptr_t, int32_t, int32_t, int32_t, struct_iip_t*, int32_t, void*); @@ -1831,6 +1834,7 @@ void pFXi_32(x64emu_t *emu, uintptr_t fcn) { pFXi_t fn = (pFXi_t)fcn; R_EAX = to void pFXu_32(x64emu_t *emu, uintptr_t fcn) { pFXu_t fn = (pFXu_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8))); } void pFXL_32(x64emu_t *emu, uintptr_t fcn) { pFXL_t fn = (pFXL_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)))); } void pFXp_32(x64emu_t *emu, uintptr_t fcn) { pFXp_t fn = (pFXp_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8))); } +void hFEp_32(x64emu_t *emu, uintptr_t fcn) { hFEp_t fn = (hFEp_t)fcn; R_EAX = to_hash(fn(emu, from_ptriv(R_ESP + 4))); } void hFpa_32(x64emu_t *emu, uintptr_t fcn) { hFpa_t fn = (hFpa_t)fcn; R_EAX = to_hash(fn(from_ptriv(R_ESP + 4), from_locale(from_ptri(ptr_t, R_ESP + 8)))); } void SFip_32(x64emu_t *emu, uintptr_t fcn) { SFip_t fn = (SFip_t)fcn; R_EAX = to_ptrv(io_convert_from(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8)))); } void SFpp_32(x64emu_t *emu, uintptr_t fcn) { SFpp_t fn = (SFpp_t)fcn; R_EAX = to_ptrv(io_convert_from(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8)))); } @@ -2045,6 +2049,7 @@ void uFipu_32(x64emu_t *emu, uintptr_t fcn) { uFipu_t fn = (uFipu_t)fcn; R_EAX = void uFuuu_32(x64emu_t *emu, uintptr_t fcn) { uFuuu_t fn = (uFuuu_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); } void uFuup_32(x64emu_t *emu, uintptr_t fcn) { uFuup_t fn = (uFuup_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); } void uFupp_32(x64emu_t *emu, uintptr_t fcn) { uFupp_t fn = (uFupp_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); } +void uFpii_32(x64emu_t *emu, uintptr_t fcn) { uFpii_t fn = (uFpii_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12)); } void uFpuU_32(x64emu_t *emu, uintptr_t fcn) { uFpuU_t fn = (uFpuU_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint64_t, R_ESP + 12)); } void uFpup_32(x64emu_t *emu, uintptr_t fcn) { uFpup_t fn = (uFpup_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); } void uFppu_32(x64emu_t *emu, uintptr_t fcn) { uFppu_t fn = (uFppu_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); } @@ -2984,6 +2989,7 @@ void iFppuuiiuuuu_32(x64emu_t *emu, uintptr_t fcn) { iFppuuiiuuuu_t fn = (iFppuu void iFXiLLdduudd_32(x64emu_t *emu, uintptr_t fcn) { iFXiLLdduudd_t fn = (iFXiLLdduudd_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptri(double, R_ESP + 20), from_ptri(double, R_ESP + 28), from_ptri(uint32_t, R_ESP + 36), from_ptri(uint32_t, R_ESP + 40), from_ptri(double, R_ESP + 44), from_ptri(double, R_ESP + 52)); } void iFXuuLiuiiLL_32(x64emu_t *emu, uintptr_t fcn) { iFXuuLiuiiLL_t fn = (iFXuuLiuiiLL_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptri(int32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptri(int32_t, R_ESP + 32), from_ulong(from_ptri(ulong_t, R_ESP + 36)), from_ulong(from_ptri(ulong_t, R_ESP + 40))); } void iFXLLpiiuuii_32(x64emu_t *emu, uintptr_t fcn) { iFXLLpiiuuii_t fn = (iFXLLpiiuuii_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32), from_ptri(int32_t, R_ESP + 36), from_ptri(int32_t, R_ESP + 40)); } +void pFEpiiiiuuuu_32(x64emu_t *emu, uintptr_t fcn) { pFEpiiiiuuuu_t fn = (pFEpiiiiuuuu_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32), from_ptri(uint32_t, R_ESP + 36))); } void pFpppppppppp_32(x64emu_t *emu, uintptr_t fcn) { pFpppppppppp_t fn = (pFpppppppppp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32), from_ptriv(R_ESP + 36), from_ptriv(R_ESP + 40))); } void pFXpuiipuuii_32(x64emu_t *emu, uintptr_t fcn) { pFXpuiipuuii_t fn = (pFXpuiipuuii_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptriv(R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32), from_ptri(int32_t, R_ESP + 36), from_ptri(int32_t, R_ESP + 40))); } void iFXiiLiiibiip_ip_32(x64emu_t *emu, uintptr_t fcn) { iFXiiLiiibiip_ip_t fn = (iFXiiLiiibiip_ip_t)fcn; struct_iip_t arg_32={0}; if (*(ptr_t*)(from_ptr((R_ESP + 32)))) from_struct_iip(&arg_32, *(ptr_t*)(from_ptr((R_ESP + 32)))); R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28), *(ptr_t*)(from_ptr((R_ESP + 32))) ? &arg_32 : NULL, from_ptri(int32_t, R_ESP + 36), from_ptriv(R_ESP + 40)); if (*(ptr_t*)(from_ptr((R_ESP + 32)))) to_struct_iip(*(ptr_t*)(from_ptr((R_ESP + 32))), &arg_32); } diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 359a79f4..f76816c0 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -297,6 +297,7 @@ void pFXi_32(x64emu_t *emu, uintptr_t fnc); void pFXu_32(x64emu_t *emu, uintptr_t fnc); void pFXL_32(x64emu_t *emu, uintptr_t fnc); void pFXp_32(x64emu_t *emu, uintptr_t fnc); +void hFEp_32(x64emu_t *emu, uintptr_t fnc); void hFpa_32(x64emu_t *emu, uintptr_t fnc); void SFip_32(x64emu_t *emu, uintptr_t fnc); void SFpp_32(x64emu_t *emu, uintptr_t fnc); @@ -511,6 +512,7 @@ void uFipu_32(x64emu_t *emu, uintptr_t fnc); void uFuuu_32(x64emu_t *emu, uintptr_t fnc); void uFuup_32(x64emu_t *emu, uintptr_t fnc); void uFupp_32(x64emu_t *emu, uintptr_t fnc); +void uFpii_32(x64emu_t *emu, uintptr_t fnc); void uFpuU_32(x64emu_t *emu, uintptr_t fnc); void uFpup_32(x64emu_t *emu, uintptr_t fnc); void uFppu_32(x64emu_t *emu, uintptr_t fnc); @@ -1450,6 +1452,7 @@ void iFppuuiiuuuu_32(x64emu_t *emu, uintptr_t fnc); void iFXiLLdduudd_32(x64emu_t *emu, uintptr_t fnc); void iFXuuLiuiiLL_32(x64emu_t *emu, uintptr_t fnc); void iFXLLpiiuuii_32(x64emu_t *emu, uintptr_t fnc); +void pFEpiiiiuuuu_32(x64emu_t *emu, uintptr_t fnc); void pFpppppppppp_32(x64emu_t *emu, uintptr_t fnc); void pFXpuiipuuii_32(x64emu_t *emu, uintptr_t fnc); void iFXiiLiiibiip_ip_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index d3700b9d..b1ce41c0 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -1492,7 +1492,7 @@ GO(sethostent, vFi) GOW(setitimer, iFirLLLL_BLLLL_) GOM(setjmp, iFEp) //%% GOM(_setjmp, iFEp) //%% -//GO(setlinebuf, vFp) +GO(setlinebuf, vFS) GO(setlocale, tFip) // setlogin GO(setlogmask, iFi) diff --git a/src/wrapped32/wrappedsdl2.c b/src/wrapped32/wrappedsdl2.c index 5508a228..267ca237 100644 --- a/src/wrapped32/wrappedsdl2.c +++ b/src/wrapped32/wrappedsdl2.c @@ -340,6 +340,14 @@ EXPORT void* my32_2_SDL_CreateRGBSurface(x64emu_t* emu, uint32_t flags, int widt return p; } +EXPORT void* my32_2_SDL_CreateRGBSurfaceFrom(x64emu_t* emu, void* pixels, int width, int height, int depth, int pitch, uint32_t rmask, uint32_t gmask, uint32_t bmask, uint32_t amask) +{ + void* p = my->SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, rmask, gmask, bmask, amask); + inplace_SDL2_Surface_to_32(p); + return p; +} + + EXPORT void my32_2_SDL_SetWindowIcon(x64emu_t* emu, void* window, void* icon) { inplace_SDL2_Surface_to_64(icon); @@ -379,12 +387,21 @@ EXPORT int my32_2_SDL_SetColorKey(void* s, int flag, uint32_t color) return ret; } +EXPORT void* my32_2_SDL_ConvertSurface(void* s, my_SDL2_PixelFormat_32_t* fmt, uint32_t flags) +{ + inplace_SDL2_Surface_to_64(s); + void* ret = my->SDL_ConvertSurface(s, replace_SDL2_PixelFormat_to_64_ext(fmt), flags); + inplace_SDL2_Surface_to_32(s); + if(ret!=s) inplace_SDL2_Surface_to_32(ret); + return ret; +} + EXPORT void* my32_2_SDL_ConvertSurfaceFormat(void* s, uint32_t fmt, uint32_t flags) { inplace_SDL2_Surface_to_64(s); void* ret = my->SDL_ConvertSurfaceFormat(s, fmt, flags); inplace_SDL2_Surface_to_32(s); - inplace_SDL2_Surface_to_32(ret); + if(ret!=s) inplace_SDL2_Surface_to_32(ret); return ret; } @@ -615,6 +632,17 @@ EXPORT int my32_2_SDL_ShowMessageBox(my_SDL_MessageBoxData_32_t* msgbox, int* bt return my->SDL_ShowMessageBox(&msgbox_l, btn); } +EXPORT unsigned long my32_2_SDL_GetThreadID(x64emu_t* emu, void* thread) +{ + unsigned long ret = my->SDL_GetThreadID(thread); + int max = 10; + while (!ret && max--) { + sched_yield(); + ret = my->SDL_GetThreadID(thread); + } + return ret; +} + #define ALTMY my32_2_ #define CUSTOM_INIT \ diff --git a/src/wrapped32/wrappedsdl2_private.h b/src/wrapped32/wrappedsdl2_private.h index 5445f22a..5b449ad6 100644 --- a/src/wrapped32/wrappedsdl2_private.h +++ b/src/wrapped32/wrappedsdl2_private.h @@ -24,16 +24,16 @@ GO(SDL_atan2f, fFff) GO(SDL_atanf, fFf) GO(SDL_atof, dFp) GO(SDL_atoi, iFp) -//GO(SDL_AtomicAdd, iFpi) -//GO(SDL_AtomicCAS, uFpii) -//GO(SDL_AtomicCASPtr, uFppp) -//GO(SDL_AtomicGet, iFp) -//GO(SDL_AtomicGetPtr, pFp) -//GO(SDL_AtomicLock, vFp) -//GO(SDL_AtomicSet, iFpi) -//GO(SDL_AtomicSetPtr, pFpp) -//GO(SDL_AtomicTryLock, uFp) -//GO(SDL_AtomicUnlock, vFp) +GO(SDL_AtomicAdd, iFpi) +GO(SDL_AtomicCAS, uFpii) +GO(SDL_AtomicCASPtr, uFppp) +GO(SDL_AtomicGet, iFp) +GO(SDL_AtomicGetPtr, pFp) +GO(SDL_AtomicLock, vFp) +GO(SDL_AtomicSet, iFpi) +GO(SDL_AtomicSetPtr, pFpp) +GO(SDL_AtomicTryLock, uFp) +GO(SDL_AtomicUnlock, vFp) //GO(SDL_AudioInit, iFp) GO(SDL_AudioQuit, vFv) //GO(SDL_AudioStreamAvailable, iFp) @@ -59,7 +59,7 @@ GO(SDL_CloseAudioDevice, vFu) //GO(SDL_CondWaitTimeout, iFppu) //GO(SDL_ConvertAudio, iFp) //GO(SDL_ConvertPixels, iFiiupiupi) -//GO(SDL_ConvertSurface, pFppu) +GOM(SDL_ConvertSurface, pFppu) //%noE GOM(SDL_ConvertSurfaceFormat, pFpuu) //%noE //GO(SDL_copysign, dFdd) //GO(SDL_copysignf, fFff) @@ -71,10 +71,10 @@ GOM(SDL_CreateColorCursor, pFpii) //%noE GO(SDL_CreateMutex, pFv) GO(SDL_CreateRenderer, pFpiu) GOM(SDL_CreateRGBSurface, pFEuiiiuuuu) -//GO(SDL_CreateRGBSurfaceFrom, pFpiiiiuuuu) +GOM(SDL_CreateRGBSurfaceFrom, pFEpiiiiuuuu) //GO(SDL_CreateRGBSurfaceWithFormat, pFuiiiu) GOM(SDL_CreateRGBSurfaceWithFormatFrom, pFEpiiiiu) -//GO(SDL_CreateSemaphore, pFu) +GO(SDL_CreateSemaphore, pFu) //GO(SDL_CreateShapedWindow, pFpuuuuu) //GO(SDL_CreateSoftwareRenderer, pFp) GO(SDL_CreateSystemCursor, pFu) @@ -92,7 +92,7 @@ GOM(SDL_DelEventWatch, vFEpp) //GO(SDL_DestroyCond, vFp) //GO(SDL_DestroyMutex, vFp) GO(SDL_DestroyRenderer, vFp) -//GO(SDL_DestroySemaphore, vFp) +GO(SDL_DestroySemaphore, vFp) GO(SDL_DestroyTexture, vFp) GO(SDL_DestroyWindow, vFp) //GO(SDL_DestroyWindowSurface, iFp) @@ -187,8 +187,8 @@ GO(SDL_GetClipboardText, pFv) //GO(SDL_GetClipRect, vFpp) GOM(SDL_GetClosestDisplayMode, pFipp) //%noE //GO(SDL_GetColorKey, iFpp) -//GO(SDL_GetCPUCacheLineSize, iFv) -//GO(SDL_GetCPUCount, iFv) +GO(SDL_GetCPUCacheLineSize, iFv) +GO(SDL_GetCPUCount, iFv) GO(SDL_GetCurrentAudioDriver, pFv) GOM(SDL_GetCurrentDisplayMode, iFip) //%noE GO(SDL_GetCurrentVideoDriver, pFv) @@ -261,11 +261,11 @@ GO(SDL_GetRelativeMouseMode, iFv) //GO(SDL_GetSurfaceAlphaMod, iFpp) //GO(SDL_GetSurfaceBlendMode, iFpp) //GO(SDL_GetSurfaceColorMod, iFpppp) -//GO(SDL_GetSystemRAM, iFv) +GO(SDL_GetSystemRAM, iFv) //GO(SDL_GetTextureAlphaMod, iFpp) //GO(SDL_GetTextureBlendMode, iFpp) //GO(SDL_GetTextureColorMod, iFpppp) -//GOM(SDL_GetThreadID, LFEp) +GOM(SDL_GetThreadID, hFEp) //GO(SDL_GetThreadName, pFp) GO(SDL_GetTicks, uFv) //GO(SDL_GetTicks64, UFv) @@ -564,25 +564,25 @@ GOM(SDL_RWFromFile, pFEpp) //GOM(SDL_SaveDollarTemplate, iFEip) GO(SDL_scalbn, dFdi) GO(SDL_scalbnf, fFfi) -//GO(SDL_SemPost, iFp) -//GO(SDL_SemTryWait, iFp) -//GO(SDL_SemValue, uFp) -//GO(SDL_SemWait, iFp) -//GO(SDL_SemWaitTimeout, iFpu) -//GO(SDL_SensorClose, vFp) -//GO(SDL_SensorFromInstanceID, pFi) -//GO(SDL_SensorGetData, iFppi) -//GO(SDL_SensorGetDataWithTimestamp, iFpppi) -//GO(SDL_SensorGetDeviceInstanceID, iFi) -//GO(SDL_SensorGetDeviceName, pFi) -//GO(SDL_SensorGetDeviceNonPortableType, iFi) -//GO(SDL_SensorGetDeviceType, iFi) -//GO(SDL_SensorGetInstanceID, iFp) -//GO(SDL_SensorGetName, pFp) -//GO(SDL_SensorGetNonPortableType, iFp) -//GO(SDL_SensorGetType, iFp) -//GO(SDL_SensorOpen, pFi) -//GO(SDL_SensorUpdate, vFv) +GO(SDL_SemPost, iFp) +GO(SDL_SemTryWait, iFp) +GO(SDL_SemValue, uFp) +GO(SDL_SemWait, iFp) +GO(SDL_SemWaitTimeout, iFpu) +GO(SDL_SensorClose, vFp) +GO(SDL_SensorFromInstanceID, pFi) +GO(SDL_SensorGetData, iFppi) +GO(SDL_SensorGetDataWithTimestamp, iFpppi) +GO(SDL_SensorGetDeviceInstanceID, iFi) +GO(SDL_SensorGetDeviceName, pFi) +GO(SDL_SensorGetDeviceNonPortableType, iFi) +GO(SDL_SensorGetDeviceType, iFi) +GO(SDL_SensorGetInstanceID, iFp) +GO(SDL_SensorGetName, pFp) +GO(SDL_SensorGetNonPortableType, iFp) +GO(SDL_SensorGetType, iFp) +GO(SDL_SensorOpen, pFi) +GO(SDL_SensorUpdate, vFv) // SDL_SetAssertionHandler GO(SDL_SetClipboardText, iFp) //GO(SDL_SetClipRect, uFpp) @@ -673,7 +673,7 @@ GO(SDL_strtoull, LFppi) GO(SDL_strupr, pFp) GO(SDL_tan, dFd) GO(SDL_tanf, fFf) -//GO(SDL_ThreadID, LFv) +GO(SDL_ThreadID, hFv) //GO(SDL_TLSCreate, uFv) //GO(SDL_TLSGet, pFu) //GOM(SDL_TLSSet, iFEupp) -- cgit 1.4.1