Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixes for Take No Prisoners #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ wav-winmm.rc.o: wav-winmm.rc.in
wav-winmm.dll: wav-winmm.c wav-winmm.rc.o wav-winmm.def player.c stubs.c
mingw32-gcc -std=gnu99 -Wl,--enable-stdcall-fixup -Ilibs/include -O2 -shared -s -o wav-winmm.dll wav-winmm.c player.c stubs.c wav-winmm.def wav-winmm.rc.o -L. -lvorbisfile-3 -lwinmm -static-libgcc

wav-winmm-debug.dll: wav-winmm.c wav-winmm.rc.o wav-winmm.def player.c stubs.c
mingw32-gcc -std=gnu99 -Wl,--enable-stdcall-fixup -Ilibs/include -O2 -shared -s -o wav-winmm-debug.dll -D _DEBUG wav-winmm.c player.c stubs.c wav-winmm.def wav-winmm.rc.o -L. -lvorbisfile-3 -lwinmm -static-libgcc

clean:
rm -f wav-winmm.dll wav-winmm.rc.o
23 changes: 16 additions & 7 deletions wav-winmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ int player_main()
{
first = info.first;
last = info.last;
// Force last to be NON-inclusive.
if (last == first)
last++;
current = first;
updateTrack = 0;
}
Expand Down Expand Up @@ -324,7 +327,9 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
// FIXME: rounding to nearest track
if (time_format == MCI_FORMAT_TMSF)
{
info.first = MCI_TMSF_TRACK(parms->dwFrom);
// When dwFrom is 0, keep previously set info.
if (parms->dwFrom)
info.first = MCI_TMSF_TRACK(parms->dwFrom);

dprintf(" TRACK %d\n", MCI_TMSF_TRACK(parms->dwFrom));
dprintf(" MINUTE %d\n", MCI_TMSF_MINUTE(parms->dwFrom));
Expand Down Expand Up @@ -367,7 +372,9 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR

if (time_format == MCI_FORMAT_TMSF)
{
info.last = MCI_TMSF_TRACK(parms->dwTo);
// When dwTo is 0, keep previously set info.
if (parms->dwTo)
info.last = MCI_TMSF_TRACK(parms->dwTo);

dprintf(" TRACK %d\n", MCI_TMSF_TRACK(parms->dwTo));
dprintf(" MINUTE %d\n", MCI_TMSF_MINUTE(parms->dwTo));
Expand All @@ -381,7 +388,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
for (int i = info.first; i < MAX_TRACKS; i++)
{
// FIXME: use better matching
if (tracks[i].position + tracks[i].length > parms->dwFrom / 1000)
if (tracks[i].position + tracks[i].length > parms->dwTo / 1000)
{
info.last = i;
break;
Expand All @@ -393,11 +400,12 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
else
info.last = parms->dwTo;

if (info.last < info.first)
info.last = info.first;
// Keep info.last NON-inclusive.
if (info.last <= info.first)
info.last = info.first + 1;

if (info.last > lastTrack)
info.last = lastTrack;
if (info.last > lastTrack + 1)
info.last = lastTrack + 1;
}

if (info.first && (fdwCommand & MCI_FROM))
Expand Down Expand Up @@ -500,6 +508,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
if (parms->dwItem == MCI_STATUS_READY)
{
dprintf(" MCI_STATUS_READY\r\n");
parms->dwReturn = (numTracks > 0);
}

if (parms->dwItem == MCI_STATUS_TIME_FORMAT)
Expand Down