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