From fce61e33bbd751cd2500d31ab36381aef7a10627 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Tue, 29 Oct 2019 17:58:06 +0100 Subject: [PATCH] Implement frames/MSF conversion as functions Macros FRAMES_TO_MSF and MSF_TO_FRAMES come from SDL_cdrom library. SDL_cdrom was removed from SDL2 and these macros are used also in code not directly related to SDL_cdrom library, so a replacement is needed. Turns out output pointer type is different on Windows (int*) than it is on Linux (unsigned char*); given choice between using void* for parameters and a template function, I prefer template. --- src/dos/cdrom.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/dos/cdrom.h b/src/dos/cdrom.h index c1219c7a..4ac398af 100644 --- a/src/dos/cdrom.h +++ b/src/dos/cdrom.h @@ -54,6 +54,25 @@ typedef struct SCtrl { Bit8u vol[4]; // channel volume } TCtrl; +// Conversion function from frames to Minutes/Second/Frames +// +template +inline void frames_to_msf(int frames, T *m, T *s, T *f) { + const int cd_fps = 75; + *f = frames % cd_fps; + frames /= cd_fps; + *s = frames % 60; + frames /= 60; + *m = frames; +} + +// Conversion function from Minutes/Second/Frames to frames +// +inline int msf_to_frames(int m, int s, int f) { + const int cd_fps = 75; + return m * 60 * cd_fps + s * cd_fps + f; +} + extern int CDROM_GetMountType(char* path, int force); class CDROM_Interface