add mod/xm

This commit is contained in:
Nishi 2026-01-27 14:36:27 +09:00
commit 1af31757fd
Signed by: nishi
GPG key ID: 27EF69B208EB9343
15 changed files with 499 additions and 47 deletions

View file

@ -8,11 +8,12 @@
extern "C" {
#endif
GSDECL GSClient GSClientCreate(GSEngine engine);
GSDECL void GSClientDestroy(GSClient client);
GSDECL void GSClientStep(GSClient client);
GSDECL GSGL GSClientGetGL(GSClient client);
GSDECL void GSClientToggleSkybox(GSClient client, GSBool toggle);
GSDECL GSClient GSClientCreate(GSEngine engine);
GSDECL void GSClientDestroy(GSClient client);
GSDECL void GSClientStep(GSClient client);
GSDECL GSGL GSClientGetGL(GSClient client);
GSDECL GSSoundEngine GSClientGetSoundEngine(GSClient client);
GSDECL void GSClientToggleSkybox(GSClient client, GSBool toggle);
#ifdef __cplusplus
}

View file

@ -17,6 +17,8 @@
#include <GearSrc/SkyBox.h>
#include <GearSrc/CRC.h>
#include <GearSrc/Model.h>
#include <GearSrc/SoundDriver.h>
#include <GearSrc/SoundEngine.h>
#include <GearSrc/Sound.h>
#endif

View file

@ -8,10 +8,22 @@
extern "C" {
#endif
#define GSSoundRate 48000
GSDECL GSSound GSSoundOpen(GSClient client);
/* sound.c */
GSDECL GSSound GSSoundNew(GSSoundEngine sengine);
GSDECL GSSound GSSoundOpen(GSSoundEngine sengine, const char* path);
GSDECL void GSSoundClose(GSSound sound);
GSDECL void GSSoundToggleLoop(GSSound sound, GSBool toggle);
GSDECL void GSSoundStart(GSSound sound);
GSDECL void GSSoundResume(GSSound sound);
GSDECL void GSSoundPause(GSSound audio);
GSDECL void GSSoundLock(GSSound sound);
GSDECL void GSSoundUnlock(GSSound sound);
/* snd_xm.c */
GSDECL GSSound GSSoundOpenXM(GSSoundEngine sengine, GSFile file);
/* snd_mod.c */
GSDECL GSSound GSSoundOpenMOD(GSSoundEngine sengine, GSFile file);
#ifdef __cplusplus
}

View file

@ -0,0 +1,20 @@
#ifndef __GEARSRC_SOUNDDRIVER_H__
#define __GEARSRC_SOUNDDRIVER_H__
#include <GearSrc/MachDep.h>
#include <GearSrc/TypeDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GSSoundDriverRate 48000
GSDECL GSSoundDriver GSSoundDriverOpen(GSClient client, GSSoundDriverReadCallback callback, void* opaque);
GSDECL void GSSoundDriverClose(GSSoundDriver sound);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,20 @@
#ifndef __GEARSRC_SOUNDENGINE_H__
#define __GEARSRC_SOUNDENGINE_H__
#include <GearSrc/MachDep.h>
#include <GearSrc/TypeDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
GSDECL GSSoundEngine GSSoundEngineCreate(GSClient client);
GSDECL void GSSoundEngineDestroy(GSSoundEngine sengine);
GSDECL void GSSoundEngineLock(GSSoundEngine sengine);
GSDECL void GSSoundEngineUnlock(GSSoundEngine sengine);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -46,15 +46,17 @@ typedef struct _GSEngineParam GSEngineParam;
typedef struct _GSResourceKV GSResourceKV;
typedef struct _GSBox GSBox;
#ifdef _GEARSRC
typedef struct _GSClient* GSClient;
typedef struct _GSServer* GSServer;
typedef struct _GSEngine* GSEngine;
typedef struct _GSFile* GSFile;
typedef struct _GSResource* GSResource;
typedef struct _GSGL* GSGL;
typedef struct _GSSkyBox* GSSkyBox;
typedef struct _GSModel* GSModel;
typedef struct _GSSound* GSSound;
typedef struct _GSClient* GSClient;
typedef struct _GSServer* GSServer;
typedef struct _GSEngine* GSEngine;
typedef struct _GSFile* GSFile;
typedef struct _GSResource* GSResource;
typedef struct _GSGL* GSGL;
typedef struct _GSSkyBox* GSSkyBox;
typedef struct _GSModel* GSModel;
typedef struct _GSSoundDriver* GSSoundDriver;
typedef struct _GSSoundEngine* GSSoundEngine;
typedef struct _GSSound* GSSound;
typedef struct _GSModelFace GSModelFace;
typedef struct _GSModelMaterial GSModelMaterial;
@ -69,6 +71,8 @@ typedef void* GSResource;
typedef void* GSGL;
typedef void* GSSkyBox;
typedef void* GSModel;
typedef void* GSSoundDriver;
typedef void* GSSoundEngine;
typedef void* GSSound;
#endif
typedef float GSNumber;
@ -85,6 +89,12 @@ typedef void (*GSSleepCallback)(int ms);
typedef void (*GSRenderCallback)(GSEngine engine);
typedef void (*GSAfterRenderCallback)(GSEngine engine);
typedef void (*GSSoundDriverReadCallback)(void* opaque, GSI16* out, int frame);
typedef void (*GSSoundResetCallback)(GSSound audio);
typedef int (*GSSoundReadCallback)(GSSound audio, GSI16* out, int frame);
typedef void (*GSSoundCloseCallback)(GSSound audio);
struct _GSBox {
GSVector3 a;
GSVector3 b;
@ -162,8 +172,41 @@ struct _GSModel {
struct _GSSound {
GSEngine engine;
GSBool paused;
GSBool loop;
ma_mutex mutex;
GSFile file;
void* opaque1;
void* opaque2;
GSSoundResetCallback reset;
GSSoundReadCallback read;
GSSoundCloseCallback close;
};
struct _GSSoundDriver {
GSEngine engine;
ma_device device;
ma_device_config config;
int ready;
GSSoundDriverReadCallback callback;
void* opaque;
};
struct _GSSoundEngine {
GSEngine engine;
GSSoundDriver driver;
ma_mutex mutex;
GSSound* sound;
};
struct _GSClient {
@ -189,7 +232,7 @@ struct _GSClient {
GSSkyBox skybox;
GSBool skybox_enabled;
GSSound sound;
GSSoundEngine sengine;
};
struct _GSServer {