mirror of
https://github.com/libretro/mgba.git
synced 2024-11-23 16:10:01 +00:00
Core: Add generic checksum function
This commit is contained in:
parent
e52001e406
commit
22a36e0af9
1
CHANGES
1
CHANGES
@ -46,6 +46,7 @@ Misc:
|
||||
- Feature: Move game database from flatfile to SQLite3
|
||||
- GB Audio: Start implementing "zombie" audio (fixes mgba.io/i/389)
|
||||
- VFS: Fix some minor VFile issues with FILEs
|
||||
- Core: Add generic checksum function
|
||||
|
||||
0.5.2: (2016-12-31)
|
||||
Bugfixes:
|
||||
|
@ -33,6 +33,10 @@ enum mPlatform {
|
||||
#endif
|
||||
};
|
||||
|
||||
enum mCoreChecksumType {
|
||||
CHECKSUM_CRC32,
|
||||
};
|
||||
|
||||
struct mRTCSource;
|
||||
struct mCoreConfig;
|
||||
struct mCoreSync;
|
||||
@ -77,6 +81,7 @@ struct mCore {
|
||||
bool (*loadSave)(struct mCore*, struct VFile* vf);
|
||||
bool (*loadTemporarySave)(struct mCore*, struct VFile* vf);
|
||||
void (*unloadROM)(struct mCore*);
|
||||
void (*checksum)(const struct mCore*, void* data, enum mCoreChecksumType type);
|
||||
|
||||
bool (*loadBIOS)(struct mCore*, struct VFile* vf, int biosID);
|
||||
bool (*selectBIOS)(struct mCore*, int biosID);
|
||||
|
@ -211,6 +211,16 @@ static void _GBCoreUnloadROM(struct mCore* core) {
|
||||
return GBUnloadROM(core->board);
|
||||
}
|
||||
|
||||
static void _GBCoreChecksum(const struct mCore* core, void* data, enum mCoreChecksumType type) {
|
||||
struct GB* gb = (struct GB*) core->board;
|
||||
switch (type) {
|
||||
case CHECKSUM_CRC32:
|
||||
memcpy(data, &gb->romCrc32, sizeof(gb->romCrc32));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void _GBCoreReset(struct mCore* core) {
|
||||
struct GBCore* gbcore = (struct GBCore*) core;
|
||||
struct GB* gb = (struct GB*) core->board;
|
||||
@ -543,6 +553,7 @@ struct mCore* GBCoreCreate(void) {
|
||||
core->loadTemporarySave = _GBCoreLoadTemporarySave;
|
||||
core->loadPatch = _GBCoreLoadPatch;
|
||||
core->unloadROM = _GBCoreUnloadROM;
|
||||
core->checksum = _GBCoreChecksum;
|
||||
core->reset = _GBCoreReset;
|
||||
core->runFrame = _GBCoreRunFrame;
|
||||
core->runLoop = _GBCoreRunLoop;
|
||||
|
@ -247,6 +247,16 @@ static void _GBACoreUnloadROM(struct mCore* core) {
|
||||
return GBAUnloadROM(core->board);
|
||||
}
|
||||
|
||||
static void _GBACoreChecksum(const struct mCore* core, void* data, enum mCoreChecksumType type) {
|
||||
struct GBA* gba = (struct GBA*) core->board;
|
||||
switch (type) {
|
||||
case CHECKSUM_CRC32:
|
||||
memcpy(data, &gba->romCrc32, sizeof(gba->romCrc32));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void _GBACoreReset(struct mCore* core) {
|
||||
struct GBACore* gbacore = (struct GBACore*) core;
|
||||
struct GBA* gba = (struct GBA*) core->board;
|
||||
@ -562,6 +572,7 @@ struct mCore* GBACoreCreate(void) {
|
||||
core->loadTemporarySave = _GBACoreLoadTemporarySave;
|
||||
core->loadPatch = _GBACoreLoadPatch;
|
||||
core->unloadROM = _GBACoreUnloadROM;
|
||||
core->checksum = _GBACoreChecksum;
|
||||
core->reset = _GBACoreReset;
|
||||
core->runFrame = _GBACoreRunFrame;
|
||||
core->runLoop = _GBACoreRunLoop;
|
||||
|
@ -48,12 +48,13 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
|
||||
m_ui.id->setText(tr("(unknown)"));
|
||||
}
|
||||
|
||||
core->checksum(core, &crc32, CHECKSUM_CRC32);
|
||||
|
||||
switch (controller->thread()->core->platform(controller->thread()->core)) {
|
||||
#ifdef M_CORE_GBA
|
||||
case PLATFORM_GBA: {
|
||||
GBA* gba = static_cast<GBA*>(core->board);
|
||||
m_ui.size->setText(QString::number(gba->pristineRomSize) + tr(" bytes"));
|
||||
crc32 = gba->romCrc32;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -61,7 +62,6 @@ ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
|
||||
case PLATFORM_GB: {
|
||||
GB* gb = static_cast<GB*>(core->board);
|
||||
m_ui.size->setText(QString::number(gb->pristineRomSize) + tr(" bytes"));
|
||||
crc32 = gb->romCrc32;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -831,25 +831,7 @@ void Window::updateTitle(float fps) {
|
||||
const NoIntroDB* db = GBAApp::app()->gameDB();
|
||||
NoIntroGame game{};
|
||||
uint32_t crc32 = 0;
|
||||
|
||||
switch (m_controller->thread()->core->platform(m_controller->thread()->core)) {
|
||||
#ifdef M_CORE_GBA
|
||||
case PLATFORM_GBA: {
|
||||
GBA* gba = static_cast<GBA*>(m_controller->thread()->core->board);
|
||||
crc32 = gba->romCrc32;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
case PLATFORM_GB: {
|
||||
GB* gb = static_cast<GB*>(m_controller->thread()->core->board);
|
||||
crc32 = gb->romCrc32;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m_controller->thread()->core->checksum(m_controller->thread()->core, &crc32, CHECKSUM_CRC32);
|
||||
|
||||
char gameTitle[17] = { '\0' };
|
||||
mCore* core = m_controller->thread()->core;
|
||||
|
Loading…
Reference in New Issue
Block a user