Merge branch 'master' into 3ds-audio

This commit is contained in:
camthehaxman 2024-01-19 08:19:24 -06:00
commit c2f2f9570a
21 changed files with 121 additions and 90 deletions

12
.gitignore vendored
View File

@ -20,9 +20,19 @@ android/app/.externalNativeBuild/
android/local.properties android/local.properties
*.iml *.iml
# Console build results
build-360/
build-3ds/
build-dc/
build-gc/
build-n64/
build-ps2/
build-ps3/
build-vita/
build-wii/
# Build results # Build results
[Dd]ebug/ [Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/ [Rr]elease/
[Rr]eleases/ [Rr]eleases/
x64/ x64/

View File

@ -248,14 +248,14 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate
return 0; return 0;
} }
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 size) { cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 size) {
ALuint buffer; ALuint buffer;
ALenum err; ALenum err;
if (!ctx->free) return ERR_INVALID_ARGUMENT; if (!ctx->free) return ERR_INVALID_ARGUMENT;
buffer = ctx->freeIDs[--ctx->free]; buffer = ctx->freeIDs[--ctx->free];
_alBufferData(buffer, ctx->channels, data, size, ctx->sampleRate); _alBufferData(buffer, ctx->channels, chunk, size, ctx->sampleRate);
if ((err = _alGetError())) return err; if ((err = _alGetError())) return err;
_alSourceQueueBuffers(ctx->source, 1, &buffer); _alSourceQueueBuffers(ctx->source, 1, &buffer);
if ((err = _alGetError())) return err; if ((err = _alGetError())) return err;
@ -299,7 +299,7 @@ cc_result Audio_PlayData(struct AudioContext* ctx, struct AudioData* data) {
data->sampleRate = Audio_AdjustSampleRate(data); data->sampleRate = Audio_AdjustSampleRate(data);
if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate))) return res; if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate))) return res;
if ((res = Audio_QueueData(ctx, data->data, data->size))) return res; if ((res = Audio_QueueChunk(ctx, data->data, data->size))) return res;
if ((res = Audio_Play(ctx))) return res; if ((res = Audio_Play(ctx))) return res;
return 0; return 0;
} }
@ -322,6 +322,14 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
if (err) String_AppendConst(dst, err); if (err) String_AppendConst(dst, err);
return err != NULL; return err != NULL;
} }
void* Audio_AllocChunk(cc_uint32 size) {
return Mem_TryAlloc(size, 1);
}
void Audio_FreeChunk(void* data) {
Mem_Free(data);
}
#elif defined CC_BUILD_WINMM #elif defined CC_BUILD_WINMM
/*########################################################################################################################* /*########################################################################################################################*
*------------------------------------------------------WinMM backend------------------------------------------------------* *------------------------------------------------------WinMM backend------------------------------------------------------*
@ -448,7 +456,7 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate
return res; return res;
} }
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 dataSize) { cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 dataSize) {
cc_result res = 0; cc_result res = 0;
WAVEHDR* hdr; WAVEHDR* hdr;
int i; int i;
@ -458,7 +466,7 @@ cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 dataSi
if (!(hdr->dwFlags & WHDR_DONE)) continue; if (!(hdr->dwFlags & WHDR_DONE)) continue;
Mem_Set(hdr, 0, sizeof(WAVEHDR)); Mem_Set(hdr, 0, sizeof(WAVEHDR));
hdr->lpData = (LPSTR)data; hdr->lpData = (LPSTR)chunk;
hdr->dwBufferLength = dataSize; hdr->dwBufferLength = dataSize;
hdr->dwLoops = 1; hdr->dwLoops = 1;
@ -504,7 +512,7 @@ cc_result Audio_PlayData(struct AudioContext* ctx, struct AudioData* data) {
data->sampleRate = Audio_AdjustSampleRate(data); data->sampleRate = Audio_AdjustSampleRate(data);
if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate))) return res; if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate))) return res;
if ((res = Audio_QueueData(ctx, data->data, data->size))) return res; if ((res = Audio_QueueChunk(ctx, data->data, data->size))) return res;
return 0; return 0;
} }
@ -516,6 +524,14 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
String_AppendConst(dst, buffer); String_AppendConst(dst, buffer);
return true; return true;
} }
void* Audio_AllocChunk(cc_uint32 size) {
return Mem_TryAlloc(size, 1);
}
void Audio_FreeChunk(void* data) {
Mem_Free(data);
}
#elif defined CC_BUILD_OPENSLES #elif defined CC_BUILD_OPENSLES
/*########################################################################################################################* /*########################################################################################################################*
*----------------------------------------------------OpenSL ES backend----------------------------------------------------* *----------------------------------------------------OpenSL ES backend----------------------------------------------------*
@ -676,8 +692,8 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate
return 0; return 0;
} }
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 size) { cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 size) {
return (*ctx->playerQueue)->Enqueue(ctx->playerQueue, data, size); return (*ctx->playerQueue)->Enqueue(ctx->playerQueue, chunk, size);
} }
static cc_result Audio_Pause(struct AudioContext* ctx) { static cc_result Audio_Pause(struct AudioContext* ctx) {
@ -712,7 +728,7 @@ cc_result Audio_PlayData(struct AudioContext* ctx, struct AudioData* data) {
/* rate is in milli, so 1000 = normal rate */ /* rate is in milli, so 1000 = normal rate */
if ((res = (*ctx->playerRate)->SetRate(ctx->playerRate, data->rate * 10))) return res; if ((res = (*ctx->playerRate)->SetRate(ctx->playerRate, data->rate * 10))) return res;
if ((res = Audio_QueueData(ctx, data->data, data->size))) return res; if ((res = Audio_QueueChunk(ctx, data->data, data->size))) return res;
if ((res = Audio_Play(ctx))) return res; if ((res = Audio_Play(ctx))) return res;
return 0; return 0;
} }
@ -744,6 +760,14 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
if (err) String_AppendConst(dst, err); if (err) String_AppendConst(dst, err);
return err != NULL; return err != NULL;
} }
void* Audio_AllocChunk(cc_uint32 size) {
return Mem_TryAlloc(size, 1);
}
void Audio_FreeChunk(void* data) {
Mem_Free(data);
}
#elif defined CC_BUILD_3DS #elif defined CC_BUILD_3DS
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------------3DS backend-------------------------------------------------------* *-------------------------------------------------------3DS backend-------------------------------------------------------*
@ -807,12 +831,12 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate
return 0; return 0;
} }
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 dataSize) { cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 dataSize) {
ndspWaveBuf* buf; ndspWaveBuf* buf;
// DSP audio buffers must be aligned to a multiple of 0x80, according to the example code I could find. // DSP audio buffers must be aligned to a multiple of 0x80, according to the example code I could find.
if (((uintptr_t)data & 0x7F) != 0) { if (((uintptr_t)chunk & 0x7F) != 0) {
Platform_Log1("Audio_QueueData: tried to queue buffer with non-aligned audio buffer 0x%x\n", &data); Platform_Log1("Audio_QueueData: tried to queue buffer with non-aligned audio buffer 0x%x\n", &chunk);
} }
if ((dataSize & 0x7F) != 0) { if ((dataSize & 0x7F) != 0) {
Platform_Log1("Audio_QueueData: unaligned audio data size 0x%x\n", &dataSize); Platform_Log1("Audio_QueueData: unaligned audio data size 0x%x\n", &dataSize);
@ -825,7 +849,7 @@ cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 dataSi
if (buf->status == NDSP_WBUF_QUEUED || buf->status == NDSP_WBUF_PLAYING) if (buf->status == NDSP_WBUF_QUEUED || buf->status == NDSP_WBUF_PLAYING)
continue; continue;
buf->data_pcm16 = data; buf->data_pcm16 = chunk;
buf->nsamples = dataSize / (sizeof(cc_int16) * (ctx->stereo ? 2 : 1)); buf->nsamples = dataSize / (sizeof(cc_int16) * (ctx->stereo ? 2 : 1));
//Platform_Log1("PLAYING ON: %i", &ctx->chanID); //Platform_Log1("PLAYING ON: %i", &ctx->chanID);
DSP_FlushDataCache(buf->data_pcm16, dataSize); DSP_FlushDataCache(buf->data_pcm16, dataSize);
@ -870,13 +894,22 @@ cc_result Audio_PlayData(struct AudioContext* ctx, struct AudioData* data) {
cc_result res; cc_result res;
if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate))) return res; if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate))) return res;
if ((res = Audio_QueueData(ctx, data->data, data->size))) return res; if ((res = Audio_QueueChunk(ctx, data->data, data->size))) return res;
return 0; return 0;
} }
cc_bool Audio_DescribeError(cc_result res, cc_string* dst) { cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
return false; return false;
} }
void* Audio_AllocChunk(cc_uint32 size) {
// The DSP needs audio data aligned to a multiple of 0x80 according to examples, and linearAlloc does just that.
return linearAlloc(size);
}
void Audio_FreeChunk(void* data) {
linearFree(data);
}
#elif defined CC_BUILD_WEBAUDIO #elif defined CC_BUILD_WEBAUDIO
/*########################################################################################################################* /*########################################################################################################################*
*-----------------------------------------------------WebAudio backend----------------------------------------------------* *-----------------------------------------------------WebAudio backend----------------------------------------------------*
@ -904,7 +937,7 @@ void Audio_Close(struct AudioContext* ctx) {
cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate) { cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate) {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 size) { cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 size) {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
cc_result Audio_Play(struct AudioContext* ctx) { return ERR_NOT_SUPPORTED; } cc_result Audio_Play(struct AudioContext* ctx) { return ERR_NOT_SUPPORTED; }
@ -934,6 +967,14 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) {
String_AppendUtf8(dst, buffer, len); String_AppendUtf8(dst, buffer, len);
return len > 0; return len > 0;
} }
void* Audio_AllocChunk(cc_uint32 size) {
return Mem_TryAlloc(size, 1);
}
void Audio_FreeChunk(void* data) {
Mem_Free(data);
}
#endif #endif
/*########################################################################################################################* /*########################################################################################################################*
@ -1044,11 +1085,7 @@ static cc_result Sound_ReadWaveData(struct Stream* stream, struct Sound* snd) {
if (bitsPerSample != 16) return WAV_ERR_SAMPLE_BITS; if (bitsPerSample != 16) return WAV_ERR_SAMPLE_BITS;
size -= WAV_FMT_SIZE; size -= WAV_FMT_SIZE;
} else if (fourCC == WAV_FourCC('d','a','t','a')) { } else if (fourCC == WAV_FourCC('d','a','t','a')) {
#ifdef __3DS__ snd->data = Audio_AllocChunk(size);
snd->data = linearAlloc(size);
#else
snd->data = Mem_TryAlloc(size, 1);
#endif
snd->size = size; snd->size = size;
if (!snd->data) return ERR_OUT_OF_MEMORY; if (!snd->data) return ERR_OUT_OF_MEMORY;
@ -1326,7 +1363,7 @@ static cc_result Music_Buffer(cc_int16* data, int maxSamples, struct VorbisState
} }
if (Audio_MusicVolume < 100) { ApplyVolume(data, samples, Audio_MusicVolume); } if (Audio_MusicVolume < 100) { ApplyVolume(data, samples, Audio_MusicVolume); }
res2 = Audio_QueueData(&music_ctx, data, samples * 2); res2 = Audio_QueueChunk(&music_ctx, data, samples * 2);
if (res2) { music_stopping = true; return res2; } if (res2) { music_stopping = true; return res2; }
return res; return res;
} }
@ -1358,12 +1395,7 @@ static cc_result Music_PlayOgg(struct Stream* source) {
samplesPerSecond = channels * sampleRate; samplesPerSecond = channels * sampleRate;
cur = 0; cur = 0;
#ifdef __3DS__ data = (cc_int16*)Audio_AllocChunk(chunkSize * AUDIO_MAX_BUFFERS * 2);
// linearAlloc aligns data to a multiple of 0x80
data = linearAlloc(chunkSize * AUDIO_MAX_BUFFERS * 2);
#else
data = (cc_int16*)Mem_TryAlloc(chunkSize * AUDIO_MAX_BUFFERS, 2);
#endif
if (!data) { res = ERR_OUT_OF_MEMORY; goto cleanup; } if (!data) { res = ERR_OUT_OF_MEMORY; goto cleanup; }
/* fill up with some samples before playing */ /* fill up with some samples before playing */

View File

@ -48,11 +48,11 @@ void Audio_Close(struct AudioContext* ctx);
/* Sets the format of the audio data to be played. */ /* Sets the format of the audio data to be played. */
/* NOTE: Changing the format can be expensive, depending on the backend. */ /* NOTE: Changing the format can be expensive, depending on the backend. */
cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate); cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate);
/* Queues the given audio data for playing. */ /* Queues the given audio chunk for playing. */
/* NOTE: You MUST ensure Audio_Poll indicates a buffer is free before calling this. */ /* NOTE: You MUST ensure Audio_Poll indicates a buffer is free before calling this. */
/* NOTE: Some backends directly read from the data - therefore you MUST NOT modify it */ /* NOTE: Some backends directly read from the data - therefore you MUST NOT modify it */
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 size); cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 size);
/* Begins playing audio. Audio_QueueData must have been used before this. */ /* Begins playing audio. Audio_QueueChunk must have been used before this. */
cc_result Audio_Play(struct AudioContext* ctx); cc_result Audio_Play(struct AudioContext* ctx);
/* Polls the audio context and then potentially unqueues buffer */ /* Polls the audio context and then potentially unqueues buffer */
/* Returns the number of buffers being played or queued */ /* Returns the number of buffers being played or queued */
@ -65,4 +65,9 @@ cc_result Audio_PlayData(struct AudioContext* ctx, struct AudioData* data);
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data); cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data);
/* Outputs more detailed information about errors with audio. */ /* Outputs more detailed information about errors with audio. */
cc_bool Audio_DescribeError(cc_result res, cc_string* dst); cc_bool Audio_DescribeError(cc_result res, cc_string* dst);
/* Allocates a chunk of data to store audio samples */
void* Audio_AllocChunk(cc_uint32 size);
/* Frees a previously allocated chunk of data */
void Audio_FreeChunk(void* chunk);
#endif #endif

View File

@ -708,7 +708,7 @@ static cc_result HttpClient_SendRequest(struct HttpClientState* state) {
HttpClient_Serialise(state); HttpClient_Serialise(state);
/* TODO check that wrote is >= inputMsg.length */ /* TODO check that wrote is >= inputMsg.length */
return HttpConnection_Write(state->conn, inputBuffer, inputMsg.length, &wrote); return HttpConnection_Write(state->conn, (cc_uint8*)inputBuffer, inputMsg.length, &wrote);
} }
@ -763,7 +763,8 @@ static int HttpClient_BeginBody(struct HttpRequest* req, struct HttpClientState*
static int HttpClient_GetChunkLength(const cc_string* line) { static int HttpClient_GetChunkLength(const cc_string* line) {
int length = 0, i, part; int length = 0, i, part;
for (i = 0; i < line->length; i++) { for (i = 0; i < line->length; i++)
{
char c = line->buffer[i]; char c = line->buffer[i];
/* RFC 7230, section 4.1.1 - Chunk Extensions */ /* RFC 7230, section 4.1.1 - Chunk Extensions */
if (c == ';') break; if (c == ';') break;
@ -786,7 +787,8 @@ static cc_result HttpClient_Process(struct HttpClientState* state, char* buffer,
case HTTP_RESPONSE_STATE_HEADER: case HTTP_RESPONSE_STATE_HEADER:
{ {
for (; offset < total;) { for (; offset < total;)
{
char c = buffer[offset++]; char c = buffer[offset++];
if (c == '\r') continue; if (c == '\r') continue;
if (c != '\n') { if (c != '\n') {
@ -837,7 +839,8 @@ static cc_result HttpClient_Process(struct HttpClientState* state, char* buffer,
/* RFC 7230, section 4.1 - Chunked Transfer Coding */ /* RFC 7230, section 4.1 - Chunked Transfer Coding */
case HTTP_RESPONSE_STATE_CHUNK_HEADER: case HTTP_RESPONSE_STATE_CHUNK_HEADER:
{ {
for (; offset < total;) { for (; offset < total;)
{
char c = buffer[offset++]; char c = buffer[offset++];
if (c == '\r') continue; if (c == '\r') continue;
if (c != '\n') { String_Append(&state->header, c); continue; } if (c != '\n') { String_Append(&state->header, c); continue; }
@ -874,7 +877,8 @@ static cc_result HttpClient_Process(struct HttpClientState* state, char* buffer,
/* RFC 7230, section 4.1.2 - Chunked Trailer Part */ /* RFC 7230, section 4.1.2 - Chunked Trailer Part */
case HTTP_RESPONSE_STATE_CHUNK_TRAILERS: case HTTP_RESPONSE_STATE_CHUNK_TRAILERS:
{ {
for (; offset < total;) { for (; offset < total;)
{
char c = buffer[offset++]; char c = buffer[offset++];
if (c == '\r') continue; if (c == '\r') continue;
if (c != '\n') { String_Append(&state->header, c); continue; } if (c != '\n') { String_Append(&state->header, c); continue; }
@ -904,7 +908,8 @@ static cc_result HttpClient_ParseResponse(struct HttpClientState* state) {
cc_uint32 total; cc_uint32 total;
cc_result res; cc_result res;
for (;;) { for (;;)
{
dst = state->dataLeft > INPUT_BUFFER_LEN ? (req->data + req->size) : buffer; dst = state->dataLeft > INPUT_BUFFER_LEN ? (req->data + req->size) : buffer;
res = HttpConnection_Read(state->conn, dst, INPUT_BUFFER_LEN, &total); res = HttpConnection_Read(state->conn, dst, INPUT_BUFFER_LEN, &total);

View File

@ -47,8 +47,14 @@ static int flagXOffset, flagYOffset;
static void HookEvents(void); static void HookEvents(void);
void LBackend_Init(void) { void LBackend_Init(void) {
xBorder = Display_ScaleX(1); xBorder2 = xBorder * 2; xBorder3 = xBorder * 3; xBorder4 = xBorder * 4; xBorder = Display_ScaleX(1);
yBorder = Display_ScaleY(1); yBorder2 = yBorder * 2; yBorder3 = yBorder * 3; yBorder4 = yBorder * 4; yBorder = Display_ScaleY(1);
if (xBorder < 1) { xBorder = 1; }
if (yBorder < 1) { yBorder = 1; }
xBorder2 = xBorder * 2; xBorder3 = xBorder * 3; xBorder4 = xBorder * 4;
yBorder2 = yBorder * 2; yBorder3 = yBorder * 3; yBorder4 = yBorder * 4;
xInputOffset = Display_ScaleX(5); xInputOffset = Display_ScaleX(5);
yInputOffset = Display_ScaleY(2); yInputOffset = Display_ScaleY(2);

View File

@ -19,8 +19,14 @@ static int oneX, twoX, fourX;
static int oneY, twoY, fourY; static int oneY, twoY, fourY;
void LWidget_CalcOffsets(void) { void LWidget_CalcOffsets(void) {
oneX = Display_ScaleX(1); twoX = oneX * 2; fourX = oneX * 4; oneX = Display_ScaleX(1);
oneY = Display_ScaleY(1); twoY = oneY * 2; fourY = oneY * 4; oneY = Display_ScaleY(1);
if (oneX < 1) { oneX = 1; }
if (oneY < 1) { oneY = 1; }
twoX = oneX * 2; fourX = oneX * 4;
twoY = oneY * 2; fourY = oneY * 4;
flagXOffset = Display_ScaleX(2); flagXOffset = Display_ScaleX(2);
flagYOffset = Display_ScaleY(6); flagYOffset = Display_ScaleY(6);

View File

@ -529,7 +529,7 @@ void Launcher_DrawTitle(struct FontDesc* font, const char* text, struct Context2
int x; int x;
/* Skip dragging logo when very small window to save space */ /* Skip dragging logo when very small window to save space */
if (WindowInfo.Height < 300) return; if (WindowInfo.Height < 240) return;
DrawTextArgs_Make(&args, &title, font, false); DrawTextArgs_Make(&args, &title, font, false);
x = ctx->width / 2 - Drawer2D_TextWidth(&args) / 2; x = ctx->width / 2 - Drawer2D_TextWidth(&args) / 2;

View File

@ -19,11 +19,12 @@ struct Vec4 { float x, y, z, w; };
/* 4x4 matrix. (for vertex transformations) */ /* 4x4 matrix. (for vertex transformations) */
struct Matrix { struct Vec4 row1, row2, row3, row4; }; struct Matrix { struct Vec4 row1, row2, row3, row4; };
#define Matrix_IdentityValue { \ #define Matrix_IdentityValue \
1.0f, 0.0f, 0.0f, 0.0f, \ { \
0.0f, 1.0f, 0.0f, 0.0f, \ { 1.0f, 0.0f, 0.0f, 0.0f }, \
0.0f, 0.0f, 1.0f, 0.0f, \ { 0.0f, 1.0f, 0.0f, 0.0f }, \
0.0f, 0.0f, 0.0f, 1.0f \ { 0.0f, 0.0f, 1.0f, 0.0f }, \
{ 0.0f, 0.0f, 0.0f, 1.0f } \
} }
/* Identity matrix. (A * Identity = A) */ /* Identity matrix. (A * Identity = A) */

View File

@ -64,9 +64,9 @@ CC_VAR extern struct _DisplayData {
} DisplayInfo; } DisplayInfo;
/* Scales the given X coordinate from 96 dpi to current display dpi. */ /* Scales the given X coordinate from 96 dpi to current display dpi. */
int Display_ScaleX(int x); static CC_INLINE int Display_ScaleX(int x) { return (int)(x * DisplayInfo.ScaleX); }
/* Scales the given Y coordinate from 96 dpi to current display dpi. */ /* Scales the given Y coordinate from 96 dpi to current display dpi. */
int Display_ScaleY(int y); static CC_INLINE int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); }
/* Data for the game/launcher window. */ /* Data for the game/launcher window. */
CC_VAR extern struct _WinData { CC_VAR extern struct _WinData {

View File

@ -18,9 +18,6 @@ static Result irrst_result;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on 3DS
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
// Note from https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/gfx.h // Note from https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/gfx.h
@ -42,8 +39,8 @@ void Window_Init(void) {
DisplayInfo.Width = height; // deliberately swapped DisplayInfo.Width = height; // deliberately swapped
DisplayInfo.Height = width; // deliberately swapped DisplayInfo.Height = width; // deliberately swapped
DisplayInfo.Depth = 4; // 32 bit DisplayInfo.Depth = 4; // 32 bit
DisplayInfo.ScaleX = 1; DisplayInfo.ScaleX = 0.5;
DisplayInfo.ScaleY = 1; DisplayInfo.ScaleY = 0.5;
WindowInfo.Width = height; // deliberately swapped WindowInfo.Width = height; // deliberately swapped
WindowInfo.Height = width; // deliberately swapped WindowInfo.Height = width; // deliberately swapped
@ -101,10 +98,10 @@ static void HandleButtons(u32 mods) {
static void ProcessJoystickInput(circlePosition* pos, double delta) { static void ProcessJoystickInput(circlePosition* pos, double delta) {
float scale = (delta * 60.0) / 8.0f; float scale = (delta * 60.0) / 8.0f;
// May not be exactly 0 on actual hardware // May not be exactly 0 on actual hardware
if (Math_AbsI(pos->dx) <= 8) pos->dx = 0; if (Math_AbsI(pos->dx) <= 16) pos->dx = 0;
if (Math_AbsI(pos->dy) <= 8) pos->dy = 0; if (Math_AbsI(pos->dy) <= 16) pos->dy = 0;
Event_RaiseRawMove(&PointerEvents.RawMoved, pos->dx * scale, -pos->dy * scale); Event_RaiseRawMove(&PointerEvents.RawMoved, pos->dx * scale, -pos->dy * scale);
} }
@ -148,7 +145,6 @@ void Window_ProcessEvents(double delta) {
hidCircleRead(&pos); hidCircleRead(&pos);
ProcessJoystickInput(&pos, delta); ProcessJoystickInput(&pos, delta);
} }
if (Input.RawMode && irrst_result == 0) { if (Input.RawMode && irrst_result == 0) {
circlePosition pos; circlePosition pos;
irrstScanInput(); irrstScanInput();
@ -277,4 +273,4 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
#endif #endif

View File

@ -15,9 +15,6 @@ static cc_bool launcherMode;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on 3DS
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
void Window_Init(void) { void Window_Init(void) {
DisplayInfo.Width = vid_mode->width; DisplayInfo.Width = vid_mode->width;

View File

@ -23,9 +23,6 @@ static GXRModeObj* rmode;
void* Window_XFB; void* Window_XFB;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on Wii/GameCube
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
static void OnPowerOff(void) { static void OnPowerOff(void) {

View File

@ -16,9 +16,6 @@ static cc_bool launcherMode;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on Wii/GameCube
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
void Window_Init(void) { void Window_Init(void) {
display_init(RESOLUTION_320x240, DEPTH_32_BPP, 2, GAMMA_NONE, FILTERS_DISABLED); display_init(RESOLUTION_320x240, DEPTH_32_BPP, 2, GAMMA_NONE, FILTERS_DISABLED);

View File

@ -26,9 +26,6 @@ static char padBuf[256] __attribute__((aligned(64)));
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on PS Vita
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
void Window_Init(void) { void Window_Init(void) {
DisplayInfo.Width = 640; DisplayInfo.Width = 640;

View File

@ -25,9 +25,6 @@ static KbConfig kb_config;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on PS Vita
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
static void sysutil_callback(u64 status, u64 param, void* usrdata) { static void sysutil_callback(u64 status, u64 param, void* usrdata) {
switch (status) { switch (status) {

View File

@ -21,9 +21,6 @@ static cc_bool launcherMode;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on Wii/GameCube
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
void Window_Init(void) { void Window_Init(void) {
DisplayInfo.Width = SCREEN_WIDTH; DisplayInfo.Width = SCREEN_WIDTH;

View File

@ -18,9 +18,6 @@ static SceTouchPanelInfo frontPanel;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on PS Vita
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
#define DISPLAY_WIDTH 960 #define DISPLAY_WIDTH 960
#define DISPLAY_HEIGHT 544 #define DISPLAY_HEIGHT 544

View File

@ -20,9 +20,6 @@ static xid_gamepad_in gp_state;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on Xbox
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
// TODO No idea if this even works // TODO No idea if this even works
static void OnDataReceived(UTR_T* utr) { static void OnDataReceived(UTR_T* utr) {

View File

@ -18,9 +18,6 @@ static cc_bool launcherMode;
struct _DisplayData DisplayInfo; struct _DisplayData DisplayInfo;
struct _WinData WindowInfo; struct _WinData WindowInfo;
// no DPI scaling on Xbox
int Display_ScaleX(int x) { return x; }
int Display_ScaleY(int y) { return y; }
// https://github.com/Free60Project/libxenon/blob/71a411cddfc26c9ccade08d054d87180c359797a/libxenon/drivers/console/console.c#L47 // https://github.com/Free60Project/libxenon/blob/71a411cddfc26c9ccade08d054d87180c359797a/libxenon/drivers/console/console.c#L47
struct ati_info { struct ati_info {

View File

@ -272,7 +272,7 @@ static void AppendVRAMStats(cc_string* info) {
} }
void Gfx_GetApiInfo(cc_string* info) { void Gfx_GetApiInfo(cc_string* info) {
GLint depthBits; GLint depthBits = 0;
int pointerSize = sizeof(void*) * 8; int pointerSize = sizeof(void*) * 8;
glGetIntegerv(GL_DEPTH_BITS, &depthBits); glGetIntegerv(GL_DEPTH_BITS, &depthBits);

View File

@ -10,9 +10,6 @@ struct _WinData WindowInfo;
#define Display_CentreX(width) (DisplayInfo.x + (DisplayInfo.Width - width) / 2) #define Display_CentreX(width) (DisplayInfo.x + (DisplayInfo.Width - width) / 2)
#define Display_CentreY(height) (DisplayInfo.y + (DisplayInfo.Height - height) / 2) #define Display_CentreY(height) (DisplayInfo.y + (DisplayInfo.Height - height) / 2)
int Display_ScaleX(int x) { return (int)(x * DisplayInfo.ScaleX); }
int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); }
static int cursorPrevX, cursorPrevY; static int cursorPrevX, cursorPrevY;
static cc_bool cursorVisible = true; static cc_bool cursorVisible = true;
/* Gets the position of the cursor in screen or window coordinates */ /* Gets the position of the cursor in screen or window coordinates */