Skip to content

Commit

Permalink
3rdparty/libchdr: Purge almost all remaining patches
Browse files Browse the repository at this point in the history
Leaving only the chd_read_header_* functions, of which exists an equivalent in later libchdr versions
  • Loading branch information
TheLastRar committed Dec 18, 2024
1 parent 3b89020 commit e7f1ab7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 49 deletions.
26 changes: 9 additions & 17 deletions 3rdparty/libchdr/include/libchdr/cdrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

#pragma once

#ifdef __cplusplus
extern "C" {
#endif
#ifndef __CDROM_H__
#define __CDROM_H__

#include <stdint.h>
#include <stdbool.h>
#include <libchdr/chdconfig.h>

/***************************************************************************
Expand Down Expand Up @@ -49,15 +47,11 @@ enum

enum
{
CD_SUB_NONE = 0, /* no subcode data stored */
CD_SUB_RAW_INTERLEAVED, /* raw interleaved 96 bytes per sector */
CD_SUB_RAW, /* raw non-interleaved 96 bytes per sector */
CD_SUB_NORMAL = 0, /* "cooked" 96 bytes per sector */
CD_SUB_RAW, /* raw uninterleaved 96 bytes per sector */
CD_SUB_NONE /* no subcode data stored */
};

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_GDROMLE 0x00000002 /* legacy GD-ROM, with little-endian CDDA data */

Expand Down Expand Up @@ -87,10 +81,10 @@ static inline uint32_t lba_to_msf(uint32_t lba)
{
uint8_t m, s, f;

m = (uint8_t)(lba / (60 * 75));
m = lba / (60 * 75);
lba -= m * (60 * 75);
s = (uint8_t)(lba / 75);
f = (uint8_t)(lba % 75);
s = lba / 75;
f = lba % 75;

return ((m / 10) << 20) | ((m % 10) << 16) |
((s / 10) << 12) | ((s % 10) << 8) |
Expand All @@ -113,6 +107,4 @@ static inline uint32_t lba_to_msf_alt(int lba)
return ret;
}

#ifdef __cplusplus
} // extern "C"
#endif
#endif /* __CDROM_H__ */
2 changes: 1 addition & 1 deletion 3rdparty/libchdr/include/libchdr/chd.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ extern "C" {

#include <libchdr/coretypes.h>
#include <libchdr/chdconfig.h>
#include <stdbool.h>

/***************************************************************************
Expand Down Expand Up @@ -393,6 +392,7 @@ CHD_EXPORT core_file *chd_core_file(chd_file *chd);
CHD_EXPORT const char *chd_error_string(chd_error err);



/* ----- CHD header management ----- */

/* return a pointer to the extracted CHD header data */
Expand Down
29 changes: 0 additions & 29 deletions 3rdparty/libchdr/src/libchdr_cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,6 @@

#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

/***************************************************************************
Expand Down
3 changes: 1 addition & 2 deletions 3rdparty/libchdr/src/libchdr_chd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>

#include <libchdr/chd.h>
#include <libchdr/cdrom.h>
Expand Down Expand Up @@ -1951,7 +1950,7 @@ CHD_EXPORT chd_error chd_open_core_file(core_file *file, int mode, chd_file *par
memory
-------------------------------------------------*/

CHD_EXPORT chd_error chd_precache(chd_file* chd)
CHD_EXPORT chd_error chd_precache(chd_file *chd)
{
INT64 count;
UINT64 size;
Expand Down

0 comments on commit e7f1ab7

Please sign in to comment.