Gate CHD support and clean up user-facing UI text

This commit is contained in:
moonpower
2026-04-09 19:08:02 +02:00
parent 23b2bf6858
commit dbaa214255
21 changed files with 891 additions and 84 deletions
+449 -22
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -1,24 +1,24 @@
#ifndef CHD_H
#define CHD_H
#ifdef USE_CHD
#include "disc.h"
// To-do: Implement CHD support
typedef struct {
uint32_t dummy;
} chd_t;
typedef struct chd_s chd_t;
chd_t* chd_create(void);
void chd_init(chd_t* cue);
int chd_load(chd_t* cue, const char* path);
// Disc interface
int chd_read(chd_t* cue, uint32_t lba, void* buf);
int chd_read_sector(chd_t* cue, uint32_t lba, void* buf);
int chd_query(chd_t* cue, uint32_t lba);
int chd_get_track_number(chd_t* cue, uint32_t lba);
int chd_get_track_count(chd_t* cue);
int chd_get_track_lba(chd_t* cue, int track);
void chd_destroy(chd_t* cue);
#endif
#endif
#endif
+24 -7
View File
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include "disc.h"
#include "cue.h"
@@ -13,6 +14,9 @@ const char* disc_cd_extensions[] = {
"cue",
"bin",
"iso",
#ifdef USE_CHD
"chd",
#endif
0
};
@@ -80,17 +84,28 @@ psx_disc_t* psx_disc_create(void) {
}
int disc_get_extension(const char* path) {
const char* ptr = &path[strlen(path) - 1];
char ext[16];
const char* ptr;
size_t len;
int i = 0;
while ((*ptr != '.') && (ptr != path))
--ptr;
if (ptr == path)
if (!path || !path[0])
return CD_EXT_UNSUPPORTED;
ptr = strrchr(path, '.');
if (!ptr || !ptr[1])
return CD_EXT_UNSUPPORTED;
len = strlen(ptr + 1);
if (len >= sizeof(ext))
return CD_EXT_UNSUPPORTED;
for (size_t index = 0; index < len; ++index)
ext[index] = (char)tolower((unsigned char)ptr[1 + index]);
ext[len] = '\0';
while (disc_cd_extensions[i]) {
if (!strcmp(ptr + 1, disc_cd_extensions[i]))
if (!strcmp(ext, disc_cd_extensions[i]))
return i;
++i;
@@ -170,6 +185,7 @@ int psx_disc_open_as(psx_disc_t* disc, const char* path, int type) {
disc->destroy = raw_destroy;
} break;
#ifdef USE_CHD
case CD_EXT_CHD: {
chd_t* chd = chd_create();
@@ -182,13 +198,14 @@ int psx_disc_open_as(psx_disc_t* disc, const char* path, int type) {
}
disc->udata = chd;
disc->read_sector = (read_sector_func)chd_read;
disc->read_sector = (read_sector_func)chd_read_sector;
disc->query_sector = (query_sector_func)chd_query;
disc->get_track_number = (get_track_number_func)chd_get_track_number;
disc->get_track_count = (get_track_count_func)chd_get_track_count;
disc->get_track_lba = (get_track_lba_func)chd_get_track_lba;
disc->destroy = (destroy_func)chd_destroy;
} break;
#endif
default:
return CDT_ERROR;
+3 -1
View File
@@ -29,7 +29,9 @@ enum {
CD_EXT_CUE = 0,
CD_EXT_BIN,
CD_EXT_ISO,
#ifdef USE_CHD
CD_EXT_CHD,
#endif
CD_EXT_UNSUPPORTED
};
@@ -70,4 +72,4 @@ int psx_disc_get_track_lba(psx_disc_t* disc, int track);
void psx_disc_close(psx_disc_t* disc);
void psx_disc_destroy(psx_disc_t* disc);
#endif
#endif