mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-26 19:05:41 -04:00
dep/libchdr: Add subtype parsing functions
This commit is contained in:
parent
738ede0c39
commit
82b3907804
@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef __CDROM_H__
|
#ifdef __cplusplus
|
||||||
#define __CDROM_H__
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <libchdr/chdconfig.h>
|
#include <libchdr/chdconfig.h>
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -47,11 +49,15 @@ enum
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CD_SUB_NORMAL = 0, /* "cooked" 96 bytes per sector */
|
CD_SUB_NONE = 0, /* no subcode data stored */
|
||||||
CD_SUB_RAW, /* raw uninterleaved 96 bytes per sector */
|
CD_SUB_RAW_INTERLEAVED, /* raw interleaved 96 bytes per sector */
|
||||||
CD_SUB_NONE /* no subcode data stored */
|
CD_SUB_RAW, /* raw non-interleaved 96 bytes per sector */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* cdrom_get_subtype_string(uint32_t subtype);
|
||||||
|
bool cdrom_parse_subtype_string(const char* typestring, uint32_t* subtype, uint32_t* subsize);
|
||||||
|
|
||||||
|
|
||||||
#define CD_FLAG_GDROM 0x00000001 /* disc is a GD-ROM, all tracks should be stored with GD-ROM metadata */
|
#define CD_FLAG_GDROM 0x00000001 /* disc is a GD-ROM, all tracks should be stored with GD-ROM metadata */
|
||||||
#define CD_FLAG_GDROMLE 0x00000002 /* legacy GD-ROM, with little-endian CDDA data */
|
#define CD_FLAG_GDROMLE 0x00000002 /* legacy GD-ROM, with little-endian CDDA data */
|
||||||
|
|
||||||
@ -81,10 +87,10 @@ static inline uint32_t lba_to_msf(uint32_t lba)
|
|||||||
{
|
{
|
||||||
uint8_t m, s, f;
|
uint8_t m, s, f;
|
||||||
|
|
||||||
m = lba / (60 * 75);
|
m = (uint8_t)(lba / (60 * 75));
|
||||||
lba -= m * (60 * 75);
|
lba -= m * (60 * 75);
|
||||||
s = lba / 75;
|
s = (uint8_t)(lba / 75);
|
||||||
f = lba % 75;
|
f = (uint8_t)(lba % 75);
|
||||||
|
|
||||||
return ((m / 10) << 20) | ((m % 10) << 16) |
|
return ((m / 10) << 20) | ((m % 10) << 16) |
|
||||||
((s / 10) << 12) | ((s % 10) << 8) |
|
((s / 10) << 12) | ((s % 10) << 8) |
|
||||||
@ -107,4 +113,6 @@ static inline uint32_t lba_to_msf_alt(int lba)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __CDROM_H__ */
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
@ -20,6 +20,35 @@
|
|||||||
|
|
||||||
#include <libchdr/cdrom.h>
|
#include <libchdr/cdrom.h>
|
||||||
|
|
||||||
|
const char* cdrom_get_subtype_string(uint32_t subtype)
|
||||||
|
{
|
||||||
|
switch (subtype)
|
||||||
|
{
|
||||||
|
case CD_SUB_RAW: return "RW";
|
||||||
|
case CD_SUB_RAW_INTERLEAVED: return "RW_RAW";
|
||||||
|
default: return "NONE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cdrom_parse_subtype_string(const char* typestring, uint32_t* subtype, uint32_t* subsize)
|
||||||
|
{
|
||||||
|
// https://github.com/mamedev/mame/blob/d2d54fb8ed53a2e86d308067da8414f85b5929b0/src/lib/util/cdrom.cpp#L767
|
||||||
|
if (!strcmp(typestring, "RW"))
|
||||||
|
{
|
||||||
|
*subtype = CD_SUB_RAW;
|
||||||
|
*subsize = 96;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!strcmp(typestring, "RW_RAW"))
|
||||||
|
{
|
||||||
|
*subtype = CD_SUB_RAW_INTERLEAVED;
|
||||||
|
*subsize = 96;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WANT_RAW_DATA_SECTOR
|
#ifdef WANT_RAW_DATA_SECTOR
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user