From 3783548c24b2e39c59cf25161521a76451a7bfda Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Thu, 20 Mar 2003 04:05:12 +0000 Subject: [PATCH] starting d2 cd detection (cddb discid) support --- ChangeLog | 3 +++ arch/sdl/rbaudio.c | 42 +++++++++++++++++++++++++++++++++++++++++- include/rbaudio.h | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a63ed4df..64f46b4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2003-03-19 Bradley Bell + * arch/sdl/rbaudio.c, include/rbaudio.h: starting d2 cd detection + (cddb discid) support + * arch/sdl/digi.c, main/kludge.c: implemented digi_link_sound_to_object3 for looping sounds, other looping stuff diff --git a/arch/sdl/rbaudio.c b/arch/sdl/rbaudio.c index a53df1a8..33b20ccd 100644 --- a/arch/sdl/rbaudio.c +++ b/arch/sdl/rbaudio.c @@ -1,4 +1,4 @@ -/* $Id: rbaudio.c,v 1.6 2003-03-19 19:21:34 btb Exp $ */ +/* $Id: rbaudio.c,v 1.7 2003-03-20 04:05:12 btb Exp $ */ /* * * SDL CD Audio functions @@ -161,3 +161,43 @@ int CD_blast_mixer() { return 0; } + + +static int cddb_sum(int n) +{ + int ret; + + /* For backward compatibility this algorithm must not change */ + + ret = 0; + + while (n > 0) { + ret = ret + (n % 10); + n = n / 10; + } + + return (ret); +} + + +unsigned long RBAGetDiscID() +{ + int i, t = 0, n = 0; + + if (!initialised) + return 0; + + /* For backward compatibility this algorithm must not change */ + + i = 0; + + while (i < s_cd->numtracks) { + n = n + cddb_sum(s_cd->track[i].length / CD_FPS); + i++; + } + + t = (s_cd->track[s_cd->numtracks].length / CD_FPS) - + (s_cd->track[0].length / CD_FPS); + + return ((n % 0xff) << 24 | t << 8 | s_cd->numtracks); +} diff --git a/include/rbaudio.h b/include/rbaudio.h index d0834b12..216a61f2 100644 --- a/include/rbaudio.h +++ b/include/rbaudio.h @@ -54,4 +54,7 @@ extern int RBAResume(); //is called. Returns 0 if no track playing, else track number int RBAGetTrackNum(); +// get the cddb discid for the current cd. +unsigned long RBAGetDiscID(); + #endif -- 2.39.2