about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-09-16 17:25:06 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-09-16 17:25:06 +0200
commit1503241c7aa89e8c54e6935881717f41cc25e47c (patch)
treeaad3149cff21785082491c64ba646131c2db7663 /src
parent37a1261693f89f8b27475707935c7b0d4c0cbc5f (diff)
downloadbox64-1503241c7aa89e8c54e6935881717f41cc25e47c.tar.gz
box64-1503241c7aa89e8c54e6935881717f41cc25e47c.zip
[BOX32] Added some more 32bits wrapped function, and fixing some SDL ones
Diffstat (limited to 'src')
-rw-r--r--src/include/sdl1align32.h15
-rw-r--r--src/libtools/sdl1align32.c7
-rw-r--r--src/wrapped32/generated/functions_list.txt2
-rw-r--r--src/wrapped32/generated/wrappedsdl1types32.h2
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h2
-rw-r--r--src/wrapped32/wrappedsdl1.c35
-rw-r--r--src/wrapped32/wrappedsdl1_private.h4
7 files changed, 60 insertions, 7 deletions
diff --git a/src/include/sdl1align32.h b/src/include/sdl1align32.h
index ec05f604..c7e8c1f2 100644
--- a/src/include/sdl1align32.h
+++ b/src/include/sdl1align32.h
@@ -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);
@@ -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_
\ No newline at end of file
diff --git a/src/libtools/sdl1align32.c b/src/libtools/sdl1align32.c
index 8fd2cddc..cb0b8176 100644
--- a/src/libtools/sdl1align32.c
+++ b/src/libtools/sdl1align32.c
@@ -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;
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 056141ea..46b5baf9 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -1214,6 +1214,8 @@ wrappedsdl1:
   - SDL_OpenAudio
 - pFpi:
   - SDL_LoadBMP_RW
+- pFpu:
+  - SDL_ListModes
 - pFpp:
   - SDL_CreateThread
   - SDL_LoadFunction
diff --git a/src/wrapped32/generated/wrappedsdl1types32.h b/src/wrapped32/generated/wrappedsdl1types32.h
index ad3f83ab..d808531e 100644
--- a/src/wrapped32/generated/wrappedsdl1types32.h
+++ b/src/wrapped32/generated/wrappedsdl1types32.h
@@ -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*);
@@ -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) \
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index ad2694f1..af9bdbf8 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -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
diff --git a/src/wrapped32/wrappedsdl1.c b/src/wrapped32/wrappedsdl1.c
index fa6d92c1..8fedb35e 100644
--- a/src/wrapped32/wrappedsdl1.c
+++ b/src/wrapped32/wrappedsdl1.c
@@ -366,6 +366,8 @@ 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));
@@ -373,8 +375,8 @@ EXPORT void* my32_SDL_GetVideoInfo()
             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;
 }
 
@@ -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;
@@ -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?
diff --git a/src/wrapped32/wrappedsdl1_private.h b/src/wrapped32/wrappedsdl1_private.h
index d50a7c8f..fa42b638 100644
--- a/src/wrapped32/wrappedsdl1_private.h
+++ b/src/wrapped32/wrappedsdl1_private.h
@@ -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)
@@ -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)