Implement fullscreen and add sound
This commit is contained in:
parent
e9352c051a
commit
f6c983c156
@ -27,7 +27,7 @@
|
|||||||
#include "tsf.h"
|
#include "tsf.h"
|
||||||
|
|
||||||
//#define DEBUG_SAMPLE
|
//#define DEBUG_SAMPLE
|
||||||
#define DEBUG_OUTPUT
|
// #define DEBUG_OUTPUT
|
||||||
//#define DUMP_WAV
|
//#define DUMP_WAV
|
||||||
//#define DUMP_BUFFER
|
//#define DUMP_BUFFER
|
||||||
|
|
||||||
@ -162,6 +162,7 @@ static unsigned int bufferSampleSize(segaapiContext_t *context)
|
|||||||
|
|
||||||
static void updateBufferLoop(segaapiContext_t *context)
|
static void updateBufferLoop(segaapiContext_t *context)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -176,16 +177,6 @@ static void updateBufferLoop(segaapiContext_t *context)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data, ALuint samplerate, ALenum internalformat)
|
|
||||||
{
|
|
||||||
|
|
||||||
ALsizei FrameSize = FramesToBytes(samples, channels, type);
|
|
||||||
|
|
||||||
offset *= FrameSize;
|
|
||||||
|
|
||||||
alBufferData(buffer + offset, internalformat, data, FrameSize, samplerate);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void updateBufferData(segaapiContext_t *context, unsigned int offset, size_t length)
|
static void updateBufferData(segaapiContext_t *context, unsigned int offset, size_t length)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -236,37 +227,29 @@ static void updateBufferData(segaapiContext_t *context, unsigned int offset, siz
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
ALint position;
|
|
||||||
alGetSourcei(context->alSource, AL_SAMPLE_OFFSET, &position); // TODO: Patch if looping is active
|
|
||||||
|
|
||||||
ALint unsafe[2];
|
|
||||||
alGetSourceiv(context->alSource, AL_BYTE_RW_OFFSETS_SOFT, unsafe); // AL_BYTE_OFFSET
|
|
||||||
|
|
||||||
// We should update the playing buffer
|
// We should update the playing buffer
|
||||||
// OpenAL doesn't want to let us do this!!
|
// OpenAL doesn't want to let us do this!!
|
||||||
if (offset != -1)
|
if (offset != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
// alBufferSubSamplesSOFT(context->alBuffer, offset / bufferSampleSize(context), length / bufferSampleSize(context), alChannels, alType, &context->data[offset], context->sampleRate, alFormat);
|
unsigned int sampleSize = bufferSampleSize(context);
|
||||||
dbgPrint("Soft update in buffer %X at %u (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, offset, length, position, unsafe[0], unsafe[1]);
|
|
||||||
|
|
||||||
ALint position;
|
ALint position;
|
||||||
alGetSourcei(context->alSource, AL_BYTE_OFFSET, &position);
|
alGetSourcei(context->alSource, AL_SAMPLE_OFFSET, &position);
|
||||||
|
|
||||||
alSourcei(context->alSource, AL_BUFFER, AL_NONE);
|
alSourcei(context->alSource, AL_BUFFER, AL_NONE);
|
||||||
|
// alBufferData(context->alBuffer, alFormat, context->data + (offset / sampleSize), FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
||||||
alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
||||||
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
||||||
alSourcei(context->alSource, AL_BYTE_OFFSET, position);
|
alSourcei(context->alSource, AL_SAMPLE_OFFSET, position);
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the buffer and write again
|
|
||||||
alSourcei(context->alSource, AL_BUFFER, AL_NONE);
|
alSourcei(context->alSource, AL_BUFFER, AL_NONE);
|
||||||
alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate);
|
||||||
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
||||||
|
|
||||||
// updateBufferLoop(context);
|
// updateBufferLoop(context);
|
||||||
dbgPrint("Hard update in buffer %X (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, context->size, position, unsafe[0], unsafe[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetBuffer(segaapiContext_t *context)
|
static void resetBuffer(segaapiContext_t *context)
|
||||||
@ -320,7 +303,8 @@ int SEGAAPI_Play(void *hHandle)
|
|||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
return SEGAERR_BAD_PARAM;
|
return SEGAERR_BAD_PARAM;
|
||||||
|
|
||||||
alSourcei(context->alSource, AL_LOOPING, context->loop ? AL_TRUE : AL_FALSE);
|
// alSourcei(context->alSource, AL_LOOPING, context->loop ? AL_TRUE : AL_FALSE);
|
||||||
|
alSourcei(context->alSource, AL_LOOPING, AL_FALSE);
|
||||||
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
alSourcei(context->alSource, AL_BUFFER, context->alBuffer);
|
||||||
alSourcePlay(context->alSource);
|
alSourcePlay(context->alSource);
|
||||||
return SEGA_SUCCESS;
|
return SEGA_SUCCESS;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#include <X11/extensions/xf86vmode.h>
|
#include <X11/extensions/xf86vmode.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "jvs.h"
|
#include "jvs.h"
|
||||||
@ -76,15 +78,20 @@ Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int
|
|||||||
width = getConfig()->width;
|
width = getConfig()->width;
|
||||||
height = getConfig()->height;
|
height = getConfig()->height;
|
||||||
|
|
||||||
width = 10;
|
|
||||||
height = 10;
|
|
||||||
|
|
||||||
// Ensure that the windows will respond with keyboard and mouse events
|
// Ensure that the windows will respond with keyboard and mouse events
|
||||||
attributes->event_mask = attributes->event_mask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
|
attributes->event_mask = attributes->event_mask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
|
||||||
attributes->override_redirect = 0;
|
// attributes->override_redirect = False;
|
||||||
|
|
||||||
Window window = _XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valueMask, attributes);
|
Window window = _XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valueMask, attributes);
|
||||||
printf("%d %d %d %d\n", x, y, width, height);
|
printf("%d %d %d %d\n", x, y, width, height);
|
||||||
|
|
||||||
|
if (getConfig()->fullscreen)
|
||||||
|
{
|
||||||
|
Atom wm_state = XInternAtom(display, "_NET_WM_STATE", true);
|
||||||
|
Atom wm_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
|
||||||
|
XChangeProperty(display, window, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user