Skip to content

Commit

Permalink
[BOX32] Added some more 32bits wrapped function, and fixing some SDL …
Browse files Browse the repository at this point in the history
…ones
  • Loading branch information
ptitSeb committed Sep 16, 2024
1 parent 37a1261 commit 1503241
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 7 deletions.
15 changes: 13 additions & 2 deletions src/include/sdl1align32.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ typedef struct __attribute__((packed)) my_SDL_Surface_32_s
void inplace_SDL_Surface_to_64(void* a);
void inplace_SDL_Surface_to_32(void* a);
void inplace_SDL_PixelFormat_to_64(void* a);
void inplace_SDL_PixelFormat_to_64_nopalette(void* a);
void inplace_SDL_PixelFormat_to_32(void* a);
void inplace_SDL_Palette_to_64(void* a);
void inplace_SDL_Palette_to_32(void* a);
Expand Down Expand Up @@ -520,29 +521,39 @@ void inplace_SDL_RWops_to_32(void* a);
typedef struct my_SDL_VideoInfo_s {
uint32_t hw_available:1;
uint32_t wm_available:1;
uint32_t UnusedBits1:6;
uint32_t UnusedBits2:1;
uint32_t blit_hw:1;
uint32_t blit_hw_CC:1;
uint32_t blit_hw_A:1;
uint32_t blit_sw:1;
uint32_t blit_sw_CC:1;
uint32_t blit_sw_A:1;
uint32_t blit_fill;
uint32_t blit_fill:1;
uint32_t UnusedBits3:16;
uint32_t video_mem;
my_SDL_PixelFormat_t *vfmt;
int current_w;
int current_h;
} my_SDL_VideoInfo_t;

typedef struct my_SDL_VideoInfo_32_s {
uint32_t hw_available:1;
uint32_t wm_available:1;
uint32_t UnusedBits1:6;
uint32_t UnusedBits2:1;
uint32_t blit_hw:1;
uint32_t blit_hw_CC:1;
uint32_t blit_hw_A:1;
uint32_t blit_sw:1;
uint32_t blit_sw_CC:1;
uint32_t blit_sw_A:1;
uint32_t blit_fill;
uint32_t blit_fill:1;
uint32_t UnusedBits3:16;
uint32_t video_mem;
ptr_t vfmt; // my_SDL_PixelFormat_t *
int current_w;
int current_h;
} my_SDL_VideoInfo_32_t;

#endif//__MY_SDL1ALIGN32_H_
7 changes: 7 additions & 0 deletions src/libtools/sdl1align32.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ void inplace_SDL_Palette_to_32(void* a) {
my_SDL_Palette_32_t* dst = a;
dst->colors = to_ptrv(src->colors);
}
void inplace_SDL_PixelFormat_to_64_nopalette(void* a) {
if(!a) return;
my_SDL_PixelFormat_32_t* src = a;
my_SDL_PixelFormat_t* dst = a;
memmove(&dst->BitsPerPixel, &src->BitsPerPixel, sizeof(my_SDL_PixelFormat_t)-offsetof(my_SDL_PixelFormat_t, BitsPerPixel));
dst->palette = from_ptrv(src->palette);
}
void inplace_SDL_PixelFormat_to_64(void* a) {
if(!a) return;
my_SDL_PixelFormat_32_t* src = a;
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped32/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,8 @@ wrappedsdl1:
- SDL_OpenAudio
- pFpi:
- SDL_LoadBMP_RW
- pFpu:
- SDL_ListModes
- pFpp:
- SDL_CreateThread
- SDL_LoadFunction
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped32/generated/wrappedsdl1types32.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef void* (*pFp_t)(void*);
typedef void (*vFpp_t)(void*, void*);
typedef int32_t (*iFpp_t)(void*, void*);
typedef void* (*pFpi_t)(void*, int32_t);
typedef void* (*pFpu_t)(void*, uint32_t);
typedef void* (*pFpp_t)(void*, void*);
typedef void* (*pFiiiu_t)(int32_t, int32_t, int32_t, uint32_t);
typedef void (*vFupppp_t)(uint32_t, void*, void*, void*, void*);
Expand All @@ -46,6 +47,7 @@ typedef void (*vFupppp_t)(uint32_t, void*, void*, void*, void*);
GO(SDL_WM_SetIcon, vFpp_t) \
GO(SDL_OpenAudio, iFpp_t) \
GO(SDL_LoadBMP_RW, pFpi_t) \
GO(SDL_ListModes, pFpu_t) \
GO(SDL_CreateThread, pFpp_t) \
GO(SDL_LoadFunction, pFpp_t) \
GO(SDL_RWFromFile, pFpp_t) \
Expand Down
2 changes: 1 addition & 1 deletion src/wrapped32/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ DATAM(stdin, 4)
DATAM(stdout, 4)
// step // Weak
// stime
//GO(stpcpy, pFpp)
GO(stpcpy, pFpp)
// __stpcpy
GO(__stpcpy_chk, pFppL)
// __stpcpy_small
Expand Down
35 changes: 33 additions & 2 deletions src/wrapped32/wrappedsdl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,17 @@ EXPORT void* my32_SDL_GetVideoInfo()
vm.blit_sw_A = r->blit_sw_A;
vm.blit_fill = r->blit_fill;
vm.video_mem = r->video_mem;
vm.current_h = r->current_h;
vm.current_w = r->current_w;
if(r->vfmt) {
vm.vfmt = to_ptrv(&vm_format);
memcpy(&vm_format, r->vfmt, sizeof(vm_format));
if(r->vfmt->palette) {
vm_format.palette = &vm_palette;
memcpy(&vm_palette, r->vfmt->palette, sizeof(vm_palette));
}
inplace_SDL_PixelFormat_to_32(&vm_format);
} else vm.vfmt = 0;
inplace_SDL_PixelFormat_to_32(&vm);
return &vm;
}

Expand Down Expand Up @@ -486,7 +488,7 @@ static void* unwrapSurface(void* s)
{
if(!s) return s;
if(s==&sdl_vm_surface || s==sdl1_videomode_org) {
my_SDL_Surface_32_t* dst = s;
my_SDL_Surface_32_t* dst = (my_SDL_Surface_32_t*)&sdl_vm_surface;
// refressh surface...
dst->h = sdl1_videomode_org->h;
dst->w = sdl1_videomode_org->w;
Expand Down Expand Up @@ -568,6 +570,35 @@ EXPORT int my32_SDL_PollEvent(my_SDL_Event_32_t* evt)
return ret;
}

EXPORT void* my32_SDL_ListModes(my_SDL_PixelFormat_32_t* fmt, uint32_t flags)
{
my_SDL_PixelFormat_t format;
my_SDL_Palette_t palette;
if(fmt) {
memcpy(&format, fmt, sizeof(format));
inplace_SDL_PixelFormat_to_64_nopalette(&format);
if(fmt->palette) {
memcpy(&palette, from_ptrv(fmt->palette), sizeof(palette));
format.palette = &palette;
inplace_SDL_Palette_to_64(&palette);
}
}
void** ret = my->SDL_ListModes(fmt?(&format):NULL, flags);
if(!ret)
return ret;
if(ret==(void**)-1LL)
return ret;
static ptr_t available[256];
void** p = ret;
int idx = 0;
while((*p) && (idx<255)) {
available[idx++] = to_ptrv(*p);
++p;
}
available[idx++] = 0;
return &available;
}

//EXPORT int32_t my32_SDL_GetWMInfo(x64emu_t* emu, void* p)
//{
// // does SDL_SysWMinfo needs alignment?
Expand Down
4 changes: 2 additions & 2 deletions src/wrapped32/wrappedsdl1_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ GO(SDL_JoystickOpened, iFi)
GO(SDL_JoystickUpdate, vFv)
GOM(SDL_KillThread, vFEp)
//GO(SDL_Linked_Version, pFv)
//GO(SDL_ListModes, pFpu)
GOM(SDL_ListModes, pFpu) //%noE
GOM(SDL_LoadBMP_RW, pFEpi)
GOM(SDL_LoadFunction, pFEpp)
GOM(SDL_LoadObject, pFEp)
Expand Down Expand Up @@ -145,7 +145,7 @@ GO(SDL_SetAlpha, iFpuC)
//GO(SDL_SetError, vFpppppp) // use ..., so putting arbitrary number of arguments...
//GOM(SDL_SetEventFilter, vFEp)
GO(SDL_SetGamma, iFfff)
//GO(SDL_SetGammaRamp, iFppp)
GO(SDL_SetGammaRamp, iFppp)
GO(SDL_SetModState, vFu)
//GO(SDL_SetModuleHandle, vFp)
//GO(SDL_SetPalette, iFpipii)
Expand Down

0 comments on commit 1503241

Please sign in to comment.