ref: de199b06f13d2bbde2b4c95cc6de98a8ca483a08
parent: ace29d7136fa8b79b839639fc7a6fb90775f4b77
author: Jacob Moody <moody@posixcafe.org>
date: Sun Feb 5 23:17:15 EST 2023
stub the rest for duke3d
--- a/include/npe/SDL2/SDL.h
+++ b/include/npe/SDL2/SDL.h
@@ -34,6 +34,7 @@
typedef union SDL_Color SDL_Color;
typedef struct SDL_Palette SDL_Palette;
typedef struct SDL_RendererInfo SDL_RendererInfo;
+typedef struct SDL_mutex SDL_mutex;
#pragma incomplete SDL_Cursor
#pragma incomplete SDL_Renderer
@@ -140,9 +141,20 @@
char *SDL_GetPrefPath(char *org, char *app);
int SDL_SetRenderDrawColor(SDL_Renderer *r, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
int SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode *mode);
+int SDL_GetNumDisplayModes(int displayIndex);
void SDL_ShowWindow(SDL_Window *w);
int SDL_RenderSetIntegerScale(SDL_Renderer *r, SDL_bool enable);
int SDL_GetNumVideoDisplays(void);
+void SDL_SetModState(SDL_Keymod modstate);
+SDL_mutex* SDL_CreateMutex(void);
+void SDL_DestroyMutex(SDL_mutex*);
+int SDL_LockMutex(SDL_mutex*);
+int SDL_UnlockMutex(SDL_mutex*);
+#define SDL_mutexV(x) SDL_UnlockMutex(x)
+#define SDL_mutexP(x) SDL_LockMutex(x)
+int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
+int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
+int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
enum {
SDL_QUERY = -1,
@@ -268,6 +280,10 @@
struct SDL_RendererInfo {
int max_texture_width;
int max_texture_height;
+};
+
+struct SDL_mutex {
+ Lock l;
};
#endif
--- /dev/null
+++ b/include/npe/SDL2/SDL_mixer.h
@@ -1,0 +1,47 @@
+#ifndef _npe_SDL_mixer_h_
+#define _npe_SDL_mixer_h_
+
+#include <SDL2/SDL_rwops.h>
+
+/* The internal format for an audio chunk */
+typedef struct Mix_Chunk {
+ int allocated;
+ Uint8 *abuf;
+ Uint32 alen;
+ Uint8 volume; /* Per-sample volume, 0-128 */
+} Mix_Chunk;
+
+typedef struct Mix_Music {
+ int type;
+} Mix_Music;
+
+typedef void (*Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
+typedef void (*Mix_EffectDone_t)(int chan, void *udata);
+
+int Mix_OpenAudio(int,Uint16,int,int);
+char* Mix_GetError(void);
+int Mix_RegisterEffect(int,Mix_EffectFunc_t,Mix_EffectDone_t,void*);
+Mix_Chunk* Mix_QuickLoad_RAW(Uint8*, Uint32);
+int Mix_PlayChannel(int,Mix_Chunk*,int);
+int Mix_HaltChannel(int);
+void Mix_FreeChunk(Mix_Chunk*);
+void Mix_CloseAudio(void);
+int Mix_Init(int);
+int Mix_VolumeMusic(int);
+int Mix_PlayingMusic(void);
+int Mix_PausedMusic(void);
+void Mix_ResumeMusic(void);
+void Mix_PauseMusic(void);
+int Mix_PlayingMusic(void);
+int Mix_PausedMusic(void);
+int Mix_HaltMusic(void);
+int Mix_PlayMusic(Mix_Music *music, int loops);
+Mix_Music* Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
+
+enum {
+ MIX_INIT_MID = 1,
+
+ MIX_DEFAULT_FORMAT = 1,
+};
+
+#endif
--- a/include/npe/SDL2/SDL_rwops.h
+++ b/include/npe/SDL2/SDL_rwops.h
@@ -21,6 +21,7 @@
};
SDL_RWops *SDL_RWFromFile(const char *, const char *);
+SDL_RWops *SDL_RWFromMem(void*, int);
size_t SDL_RWread(SDL_RWops *, void *, size_t, size_t);
size_t SDL_RWwrite(SDL_RWops *, const void *, size_t, size_t);
vlong SDL_RWseek(SDL_RWops *, vlong, int);
--- a/include/npe/config.h
+++ b/include/npe/config.h
@@ -1,4 +1,4 @@
#ifndef _npe_config_h_
-#define _npe_confg_h_
+#define _npe_config_h_
#endif
--- /dev/null
+++ b/libnpe_sdl2/mixer.c
@@ -1,0 +1,124 @@
+#include "_sdl.h"
+
+#include <SDL2/SDL_mixer.h>
+
+int
+Mix_OpenAudio(int freq, Uint16 format, int channels, int chunk)
+{
+ USED(freq);
+ USED(format);
+ USED(channels);
+ USED(chunk);
+
+ return 0; //lies
+}
+
+char*
+Mix_GetError(void)
+{
+ return "";
+}
+
+int
+Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg)
+{
+ USED(chan);
+ USED(f);
+ USED(d);
+ USED(arg);
+ return 1;
+}
+
+Mix_Chunk*
+Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len)
+{
+ USED(mem);
+ USED(len);
+ return nil;
+}
+
+int
+Mix_PlayChannel(int chan, Mix_Chunk *chunk, int loops)
+{
+ USED(chan);
+ USED(chunk);
+ USED(loops);
+ return -1;
+}
+
+int
+Mix_HaltChannel(int channel)
+{
+ USED(channel);
+ return 0;
+}
+
+void
+Mix_FreeChunk(Mix_Chunk *c)
+{
+ USED(c);
+}
+
+void
+Mix_CloseAudio(void)
+{
+
+}
+
+int
+Mix_Init(int flags)
+{
+ USED(flags);
+ return 0;
+}
+
+int
+Mix_VolumeMusic(int vol)
+{
+ USED(vol);
+ return 0;
+}
+
+int
+Mix_PlayingMusic(void)
+{
+ return 0;
+}
+
+int
+Mix_PausedMusic(void)
+{
+ return 0;
+}
+void
+Mix_ResumeMusic(void)
+{
+
+}
+
+void
+Mix_PauseMusic(void)
+{
+}
+
+int
+Mix_HaltMusic(void)
+{
+ return 0;
+}
+
+int
+Mix_PlayMusic(Mix_Music *music, int loops)
+{
+ USED(music);
+ USED(loops);
+ return 0;
+}
+
+Mix_Music*
+Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)
+{
+ USED(src);
+ USED(freesrc);
+ return nil;
+}
--- a/libnpe_sdl2/mkfile
+++ b/libnpe_sdl2/mkfile
@@ -12,6 +12,7 @@
rwops.$O\
scale.$O\
sdl2.$O\
+ mixer.$O\
threads.$O\
UPDATE=\
--- a/libnpe_sdl2/rwops.c
+++ b/libnpe_sdl2/rwops.c
@@ -54,6 +54,12 @@
return nil;
}
+SDL_RWops*
+SDL_RWFromMem(void *mem, int size)
+{
+ return nil;
+}
+
size_t
SDL_RWread(SDL_RWops *o, void *b, size_t sz, size_t n)
{
--- a/libnpe_sdl2/sdl2.c
+++ b/libnpe_sdl2/sdl2.c
@@ -386,6 +386,35 @@
return s;
}
+int
+SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
+{
+ USED(dst);
+ USED(rect);
+ USED(color);
+ return -1;
+}
+
+int
+SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
+{
+ USED(palette);
+ USED(colors);
+ USED(firstcolor);
+ USED(ncolors);
+ return -1;
+}
+
+int
+SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
+{
+ USED(src);
+ USED(srcrect);
+ USED(dst);
+ USED(dstrect);
+ return -1;
+}
+
void
SDL_FreeSurface(SDL_Surface *surface)
{
@@ -841,6 +870,21 @@
return SDL_GetDesktopDisplayMode(displayIndex, mode);
}
+int
+SDL_GetNumDisplayModes(int displayIndex)
+{
+ if(displayIndex != 0)
+ return -1;
+ return 1;
+}
+
+int
+SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode *mode)
+{
+ USED(modeIndex);
+ return SDL_GetDesktopDisplayMode(displayIndex, mode);
+}
+
void
SDL_SetWindowTitle(SDL_Window *, char *title)
{
@@ -1194,4 +1238,40 @@
SDL_GetRelativeMouseMode(void)
{
return SDL_FALSE;
+}
+
+SDL_mutex*
+SDL_CreateMutex(void)
+{
+ SDL_mutex *m;
+
+ m = mallocz(sizeof *m, 1);
+ return m;
+}
+
+void
+SDL_DestroyMutex(SDL_mutex *m)
+{
+ free(m);
+}
+
+int
+SDL_LockMutex(SDL_mutex *m)
+{
+ lock(&m->l);
+ return 0;
+}
+
+int
+SDL_UnlockMutex(SDL_mutex *m)
+{
+ unlock(&m->l);
+ return 0;
+}
+
+void
+SDL_SetModState(SDL_Keymod modstate)
+{
+ /* FIXME: do we care? */
+ USED(modstate);
}