mirror of https://github.com/mgba-emu/mgba.git
GBA Hardware: Add a function for detecting a GB Player-compatible game
This commit is contained in:
parent
0772fc4967
commit
527fbf0fc5
|
@ -6,6 +6,7 @@
|
|||
#include "hardware.h"
|
||||
|
||||
#include "gba/serialize.h"
|
||||
#include "util/hash.h"
|
||||
|
||||
static void _readPins(struct GBACartridgeHardware* hw);
|
||||
static void _outputPins(struct GBACartridgeHardware* hw, unsigned pins);
|
||||
|
@ -420,6 +421,29 @@ uint8_t GBAHardwareTiltRead(struct GBACartridgeHardware* hw, uint32_t address) {
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
// == Game Boy Player
|
||||
|
||||
static const uint16_t _logoPalette[] = {
|
||||
0xFFDF, 0x640C, 0xE40C, 0xE42D, 0x644E, 0xE44E, 0xE46E, 0x68AF,
|
||||
0xE8B0, 0x68D0, 0x68F0, 0x6911, 0xE911, 0x6D32, 0xED32, 0xED73,
|
||||
0x6D93, 0xED94, 0x6DB4, 0xF1D5, 0x71F5, 0xF1F6, 0x7216, 0x7257,
|
||||
0xF657, 0x7678, 0xF678, 0xF699, 0xF6B9, 0x76D9, 0xF6DA, 0x7B1B,
|
||||
0xFB1B, 0xFB3C, 0x7B5C, 0x7B7D, 0xFF7D, 0x7F9D, 0x7FBE, 0x7FFF,
|
||||
0x642D, 0x648E, 0xE88F, 0xE8F1, 0x6D52, 0x6D73, 0xF1B4, 0xF216,
|
||||
0x7237, 0x7698, 0x7AFA, 0xFAFA, 0xFB5C, 0xFFBE, 0x7FDE, 0xFFFF,
|
||||
0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
|
||||
};
|
||||
|
||||
static const uint32_t _logoHash = 0xEEDA6963;
|
||||
|
||||
bool GBAHardwarePlayerCheckScreen(const struct GBAVideo* video) {
|
||||
if (memcmp(video->palette, _logoPalette, sizeof(_logoPalette)) != 0) {
|
||||
return false;
|
||||
}
|
||||
uint32_t hash = hash32(&video->renderer->vram[0x4000], 0x4000, 0);
|
||||
return hash == _logoHash;
|
||||
}
|
||||
|
||||
// == Serialization
|
||||
|
||||
void GBAHardwareSerialize(const struct GBACartridgeHardware* hw, struct GBASerializedState* state) {
|
||||
|
|
|
@ -129,6 +129,9 @@ void GBAHardwareGPIOWrite(struct GBACartridgeHardware* gpio, uint32_t address, u
|
|||
void GBAHardwareTiltWrite(struct GBACartridgeHardware* gpio, uint32_t address, uint8_t value);
|
||||
uint8_t GBAHardwareTiltRead(struct GBACartridgeHardware* gpio, uint32_t address);
|
||||
|
||||
struct GBAVideo;
|
||||
bool GBAHardwarePlayerCheckScreen(cosnt struct GBAVideo* video);
|
||||
|
||||
struct GBASerializedState;
|
||||
void GBAHardwareSerialize(const struct GBACartridgeHardware* gpio, struct GBASerializedState* state);
|
||||
void GBAHardwareDeserialize(struct GBACartridgeHardware* gpio, const struct GBASerializedState* state);
|
||||
|
|
Loading…
Reference in New Issue