Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed May 18, 2023
2 parents 2ea09d0 + 6721c93 commit ce89f8c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## Changes

- **Merged Woof 11.0.0 and 11.1.0's changes**, therefore:
- **Merged Woof 11.0.0 to 11.1.1's changes**, therefore:
- _'FREEZE'_ cheat now has only one mode
- Changed default positions for _Time_ and _Stats_ displays in NUGHUD
- **FOV is now changed gradually** in most cases
Expand Down
7 changes: 7 additions & 0 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ void I_ToggleExclusiveFullScreen(void)

if (exclusive_fullscreen)
{
SDL_DisplayMode mode;
if (SDL_GetCurrentDisplayMode(video_display, &mode) != 0)
{
I_Error("Could not get display mode for video display #%d: %s",
video_display, SDL_GetError());
}
SDL_SetWindowSize(screen, mode.w, mode.h);
SDL_SetWindowFullscreen(screen, SDL_WINDOW_FULLSCREEN);
}
else
Expand Down
33 changes: 22 additions & 11 deletions src/i_winmusic.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ static buffer_t buffer;

#define STREAM_MAX_EVENTS 4

#define MAKE_EVT(a, b, c, d) ((DWORD)((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)))
#define MAKE_EVT(a, b, c, d) \
((DWORD)(a) | ((DWORD)(b) << 8) | ((DWORD)(c) << 16) | ((DWORD)(d) << 24))

#define PADDED_SIZE(x) (((x) + sizeof(DWORD) - 1) & ~(sizeof(DWORD) - 1))

Expand All @@ -159,7 +160,7 @@ static void MidiError(const char *prefix, DWORD dwError)
mmr = midiOutGetErrorTextW(dwError, (LPWSTR)werror, MAXERRORLENGTH);
if (mmr == MMSYSERR_NOERROR)
{
char *error = ConvertWideToUtf8(werror);
char *error = M_ConvertWideToUtf8(werror);
fprintf(stderr, "%s: %s.\n", prefix, error);
free(error);
}
Expand Down Expand Up @@ -271,8 +272,9 @@ static void SendLongMsg(unsigned int delta_time, const byte *ptr,
WriteBufferPad();
}

static void SendNullRPN(unsigned int delta_time, byte channel)
static void SendNullRPN(unsigned int delta_time, const midi_event_t *event)
{
const byte channel = event->data.channel.channel;
SendShortMsg(delta_time, MIDI_EVENT_CONTROLLER, channel,
MIDI_CONTROLLER_RPN_LSB, MIDI_RPN_NULL);
SendShortMsg(0, MIDI_EVENT_CONTROLLER, channel,
Expand Down Expand Up @@ -311,9 +313,18 @@ static void UpdateTempo(unsigned int delta_time, const midi_event_t *event)
static void SendManualVolumeMsg(unsigned int delta_time, byte channel,
byte volume)
{
const byte scaled_volume = (byte)(volume * volume_factor + 0.5f) & 0x7F;
unsigned int scaled_volume;

scaled_volume = volume * volume_factor + 0.5f;

if (scaled_volume > 127)
{
scaled_volume = 127;
}

SendShortMsg(delta_time, MIDI_EVENT_CONTROLLER, channel,
MIDI_CONTROLLER_VOLUME_MSB, scaled_volume);

channel_volume[channel] = volume;
}

Expand Down Expand Up @@ -400,10 +411,6 @@ static void ResetDevice(void)
ResetControllers();
break;

case RESET_TYPE_GM:
SendLongMsg(0, gm_system_on, sizeof(gm_system_on));
break;

case RESET_TYPE_GS:
SendLongMsg(0, gs_reset, sizeof(gs_reset));
use_fallback = (winmm_complevel != COMP_VANILLA);
Expand All @@ -412,6 +419,10 @@ static void ResetDevice(void)
case RESET_TYPE_XG:
SendLongMsg(0, xg_system_on, sizeof(xg_system_on));
break;

default:
SendLongMsg(0, gm_system_on, sizeof(gm_system_on));
break;
}

// MS GS Wavetable Synth doesn't reset pitch bend sensitivity.
Expand Down Expand Up @@ -993,7 +1004,7 @@ static boolean AddToBuffer_Standard(unsigned int delta_time,
else
{
// MS GS Wavetable Synth nulls RPN for any NRPN.
SendNullRPN(delta_time, event->data.channel.channel);
SendNullRPN(delta_time, event);
}
break;

Expand All @@ -1015,7 +1026,7 @@ static boolean AddToBuffer_Standard(unsigned int delta_time,
else
{
// MS GS Wavetable Synth ignores other RPNs.
SendNullRPN(delta_time, event->data.channel.channel);
SendNullRPN(delta_time, event);
}
break;
}
Expand All @@ -1037,7 +1048,7 @@ static boolean AddToBuffer_Standard(unsigned int delta_time,
else
{
// MS GS Wavetable Synth ignores other RPNs.
SendNullRPN(delta_time, event->data.channel.channel);
SendNullRPN(delta_time, event);
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/m_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static wchar_t *ConvertUtf8ToWide(const char *str)
return ConvertMultiByteToWide(str, CP_UTF8);
}

char *ConvertWideToUtf8(const wchar_t *wstr)
char *M_ConvertWideToUtf8(const wchar_t *wstr)
{
return ConvertWideToMultiByte(wstr, CP_UTF8);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ char *M_ConvertSysNativeMBToUtf8(const char *str)
return NULL;
}

ret = ConvertWideToUtf8(wstr);
ret = M_ConvertWideToUtf8(wstr);

free(wstr);

Expand Down Expand Up @@ -413,7 +413,7 @@ char *M_getenv(const char *name)

if (wenv)
{
env = ConvertWideToUtf8(wenv);
env = M_ConvertWideToUtf8(wenv);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/m_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void M_MakeDirectory(const char *dir);
char *M_getenv(const char *name);

#ifdef _WIN32
char *ConvertWideToUtf8(const wchar_t *wstr);
char *M_ConvertWideToUtf8(const wchar_t *wstr);
#endif

char *M_ConvertSysNativeMBToUtf8(const char *str);
Expand Down
2 changes: 0 additions & 2 deletions src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7622,8 +7622,6 @@ void M_ResetSetupMenu(void)
void M_ResetSetupMenuVideo(void)
{
DISABLE_ITEM(!hires, enem_settings2[enem2_fuzz]); // [Nugget] Now in page 2
// [Nugget] Since we allow widescreen with correction disabled, disable this check
/*DISABLE_ITEM(!use_aspect, gen_settings1[gen1_widescreen]);*/
}

//
Expand Down
16 changes: 9 additions & 7 deletions src/memio.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,24 @@ size_t mem_fread(void *buf, size_t size, size_t nmemb, MEMFILE *stream)
return 0;
}

if (stream->read_eof)
{
stream->eof = true;
}

// Trying to read more bytes than we have left?

items = nmemb;

if (items * size > stream->buflen - stream->position)
{
if (stream->read_eof)
{
stream->eof = true;
}
else
{
stream->read_eof = true;
}

items = (stream->buflen - stream->position) / size;
}

stream->read_eof = (items > 0 ? false : true);

// Copy bytes to buffer

memcpy(buf, stream->buf + stream->position, items * size);
Expand Down

0 comments on commit ce89f8c

Please sign in to comment.