2018-12-22 10:28:15 +00:00
|
|
|
namespace Heuristics {
|
|
|
|
|
|
|
|
struct NeoGeoPocketColor {
|
|
|
|
NeoGeoPocketColor(vector<uint8_t>& data, string location);
|
|
|
|
explicit operator bool() const;
|
|
|
|
auto manifest() const -> string;
|
2019-01-21 05:27:24 +00:00
|
|
|
auto title() const -> string;
|
2018-12-22 10:28:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
vector<uint8_t>& data;
|
|
|
|
string location;
|
|
|
|
};
|
|
|
|
|
|
|
|
NeoGeoPocketColor::NeoGeoPocketColor(vector<uint8_t>& data, string location) : data(data), location(location) {
|
|
|
|
}
|
|
|
|
|
|
|
|
NeoGeoPocketColor::operator bool() const {
|
2019-01-21 05:27:24 +00:00
|
|
|
switch(data.size()) {
|
|
|
|
case 0x080000: return true; // 4mbit
|
|
|
|
case 0x100000: return true; // 8mbit
|
|
|
|
case 0x200000: return true; //16mbit
|
|
|
|
case 0x280000: return true; //20mbit
|
|
|
|
case 0x300000: return true; //24mbit
|
|
|
|
case 0x400000: return true; //32mbit
|
|
|
|
}
|
|
|
|
return false;
|
2018-12-22 10:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto NeoGeoPocketColor::manifest() const -> string {
|
2019-01-21 05:27:24 +00:00
|
|
|
if(!operator bool()) return {};
|
|
|
|
|
2018-12-22 10:28:15 +00:00
|
|
|
string output;
|
|
|
|
output.append("game\n");
|
|
|
|
output.append(" sha256: ", Hash::SHA256(data).digest(), "\n");
|
|
|
|
output.append(" label: ", Location::prefix(location), "\n");
|
|
|
|
output.append(" name: ", Location::prefix(location), "\n");
|
2019-01-21 05:27:24 +00:00
|
|
|
output.append(" title: ", title(), "\n");
|
2018-12-22 10:28:15 +00:00
|
|
|
output.append(" board\n");
|
|
|
|
output.append(Memory{}.type("ROM").size(data.size()).content("Program").text());
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2019-01-21 05:27:24 +00:00
|
|
|
auto NeoGeoPocketColor::title() const -> string {
|
|
|
|
if(!operator bool()) return {};
|
|
|
|
|
|
|
|
string title;
|
|
|
|
title.size(12);
|
|
|
|
for(uint index : range(12)) {
|
|
|
|
char letter = data[0x24 + index];
|
|
|
|
if(letter >= 0x20 && letter <= 0x7e) title.get()[index] = letter;
|
|
|
|
}
|
|
|
|
return title.strip();
|
|
|
|
}
|
|
|
|
|
2018-12-22 10:28:15 +00:00
|
|
|
}
|