Update to v080r02 release.

byuu says:

- added qstrlower and qstrupper; mainly for the sake of others wanting
  to patch bass
- added: string sha256(const uint8_t *data, unsigned size); for easier
  hash generation
- cleaned up the NEC DSP and Hitachi DSP XML mapping code; they are
  consistent now as well
- "necdsp" in paths.cfg is now "firmware", since it also affects the
  Hitachi DSP
- XML mapping was using program= for DSP-n/ST-001n and data= for Cx4;
  they both use firmware= now instead
- fixed icd2/interface casting issue for GCC 4.6.0 (thanks for the
  reminder, vEX)
- removed the last parts of code that used string << foo; and removed
  that from nall/string entirely
  - I need to do this for the debugger as well, I'll make sure that it
    compiles before v081 though
- converted all string(...) syntax to { ... } syntax that I could
  (obviously it won't cast to a function that takes const char* instead
  of const string&)

Probably some other tiny things. Just basic maintenance here.
This commit is contained in:
Tim Allen 2011-07-07 22:59:26 +10:00
parent 8ae6444af7
commit ec69109c0b
31 changed files with 641 additions and 572 deletions

View File

@ -54,6 +54,10 @@ namespace nall {
operator[](buffersize) = data;
}
void remove() {
if(size > 0) resize(size - 1); //remove last element only
}
template<typename U> void insert(unsigned index, const U list) {
unsigned listsize = container_size(list);
resize(buffersize + listsize);

View File

@ -34,11 +34,11 @@ namespace nall {
string get() const {
switch(type) {
case boolean_t: return string() << *(bool*)data;
case signed_t: return string() << *(signed*)data;
case unsigned_t: return string() << *(unsigned*)data;
case double_t: return string() << *(double*)data;
case string_t: return string() << "\"" << *(string*)data << "\"";
case boolean_t: return { *(bool*)data };
case signed_t: return { *(signed*)data };
case unsigned_t: return { *(unsigned*)data };
case double_t: return { *(double*)data };
case string_t: return { "\"", *(string*)data, "\"" };
}
return "???";
}
@ -105,9 +105,9 @@ namespace nall {
if(fp.open(filename, file::mode::write)) {
for(unsigned i = 0; i < list.size(); i++) {
string output;
output << list[i].name << " = " << list[i].get();
if(list[i].desc != "") output << " # " << list[i].desc;
output << "\r\n";
output.append(list[i].name, " = ", list[i].get());
if(list[i].desc != "") output.append(" # ", list[i].desc);
output.append("\r\n");
fp.print(output);
}

View File

@ -86,17 +86,17 @@ GameBoyCartridge::GameBoyCartridge(const uint8_t *romdata, unsigned romsize) {
if(info.mapper == "MBC2") info.ramsize = 512; //512 x 4-bit
xml << "<cartridge mapper='" << info.mapper << "'";
if(info.rtc) xml << " rtc='true'";
if(info.rumble) xml << " rumble='true'";
xml << ">\n";
xml.append("<cartridge mapper='", info.mapper, "'");
if(info.rtc) xml.append(" rtc='true'");
if(info.rumble) xml.append(" rumble='true'");
xml.append(">\n");
xml << " <rom size='" << hex(romsize) << "'/>\n"; //TODO: trust/check info.romsize?
xml.append(" <rom size='", hex(romsize), "'/>\n"); //TODO: trust/check info.romsize?
if(info.ramsize > 0)
xml << " <ram size='" << hex(info.ramsize) << "' battery='" << info.battery << "'/>\n";
xml.append(" <ram size='", hex(info.ramsize), "' battery='", info.battery, "'/>\n");
xml << "</cartridge>\n";
xml.append("</cartridge>\n");
xml.transform("'", "\"");
}

View File

@ -110,7 +110,7 @@ struct Keyboard {
break;
}
}
return string() << "KB" << ID << "::" << KeyboardScancodeName[index];
return { "KB", ID, "::", KeyboardScancodeName[index] };
}
uint16_t operator[](Scancode code) const { return Base + ID * Size + code; }
@ -207,7 +207,7 @@ struct Mouse {
break;
}
}
return string() << "MS" << ID << "::" << MouseScancodeName[index];
return { "MS", ID, "::", MouseScancodeName[index] };
}
uint16_t operator[](Scancode code) const { return Base + ID * Size + code; }
@ -330,7 +330,7 @@ struct Joypad {
index = code - (Base + Size * i);
}
}
return string() << "JP" << ID << "::" << JoypadScancodeName[index];
return { "JP", ID, "::", JoypadScancodeName[index] };
}
uint16_t operator[](Scancode code) const { return Base + ID * Size + code; }

View File

@ -49,7 +49,7 @@ namespace nall {
uint64_t len;
};
void sha256_init(sha256_ctx *p) {
inline void sha256_init(sha256_ctx *p) {
memset(p, 0, sizeof(sha256_ctx));
memcpy(p->h, T_H, sizeof(T_H));
}
@ -90,7 +90,7 @@ namespace nall {
p->inlen = 0;
}
void sha256_chunk(sha256_ctx *p, const uint8_t *s, unsigned len) {
inline void sha256_chunk(sha256_ctx *p, const uint8_t *s, unsigned len) {
unsigned l;
p->len += len;
@ -107,7 +107,7 @@ namespace nall {
}
}
void sha256_final(sha256_ctx *p) {
inline void sha256_final(sha256_ctx *p) {
uint64_t len;
p->in[p->inlen++] = 0x80;
@ -124,7 +124,7 @@ namespace nall {
sha256_block(p);
}
void sha256_hash(sha256_ctx *p, uint8_t *s) {
inline void sha256_hash(sha256_ctx *p, uint8_t *s) {
uint32_t *t = (uint32_t*)s;
for(unsigned i = 0; i < 8; i++) ST32BE(t++, p->h[i]);
}

View File

@ -111,426 +111,426 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
string xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
if(type == TypeBsx) {
xml << "<cartridge/>";
xml.append("<cartridge/>");
xmlMemoryMap = xml.transform("'", "\"");
return;
}
if(type == TypeSufamiTurbo) {
xml << "<cartridge/>";
xml.append("<cartridge/>");
xmlMemoryMap = xml.transform("'", "\"");
return;
}
if(type == TypeGameBoy) {
xml << "<cartridge rtc='" << gameboy_has_rtc(data, size) << "'>\n";
xml.append("<cartridge rtc='", gameboy_has_rtc(data, size), "'>\n");
if(gameboy_ram_size(data, size) > 0) {
xml << " <ram size='0x" << hex(gameboy_ram_size(data, size)) << "'/>\n";
xml.append(" <ram size='0x", hex(gameboy_ram_size(data, size)), "'/>\n");
}
xml << "</cartridge>\n";
xml.append("</cartridge>\n");
xmlMemoryMap = xml.transform("'", "\"");
return;
}
xml << "<cartridge";
xml.append("<cartridge");
if(region == NTSC) {
xml << " region='NTSC'";
xml.append(" region='NTSC'");
} else {
xml << " region='PAL'";
xml.append(" region='PAL'");
}
xml << ">\n";
xml.append(">\n");
if(type == TypeSuperGameBoy1Bios) {
xml << " <rom>\n";
xml << " <map mode='linear' address='00-7f:8000-ffff'/>\n";
xml << " <map mode='linear' address='80-ff:8000-ffff'/>\n";
xml << " </rom>\n";
xml << " <icd2 revision='1'>\n";
xml << " <map address='00-3f:6000-7fff'/>\n";
xml << " <map address='80-bf:6000-7fff'/>\n";
xml << " </icd2>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-7f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-ff:8000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <icd2 revision='1'>\n");
xml.append(" <map address='00-3f:6000-7fff'/>\n");
xml.append(" <map address='80-bf:6000-7fff'/>\n");
xml.append(" </icd2>\n");
} else if(type == TypeSuperGameBoy2Bios) {
xml << " <rom>\n";
xml << " <map mode='linear' address='00-7f:8000-ffff'/>\n";
xml << " <map mode='linear' address='80-ff:8000-ffff'/>\n";
xml << " </rom>\n";
xml << " <icd2 revision='2'>\n";
xml << " <map address='00-3f:6000-7fff'/>\n";
xml << " <map address='80-bf:6000-7fff'/>\n";
xml << " </icd2>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-7f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-ff:8000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <icd2 revision='2'>\n");
xml.append(" <map address='00-3f:6000-7fff'/>\n");
xml.append(" <map address='80-bf:6000-7fff'/>\n");
xml.append(" </icd2>\n");
} else if(has_cx4) {
xml << " <hitachidsp model='HG51B169' frequency='20000000' data='cx4.bin' sha256='ae8d4d1961b93421ff00b3caa1d0f0ce7783e749772a3369c36b3dbf0d37ef18'>\n";
xml << " <rom>\n";
xml << " <map mode='linear' address='00-7f:8000-ffff'/>\n";
xml << " <map mode='linear' address='80-ff:8000-ffff'/>\n";
xml << " </rom>\n";
xml << " <mmio>\n";
xml << " <map address='00-3f:6000-7fff'/>\n";
xml << " <map address='80-bf:6000-7fff'/>\n";
xml << " </mmio>\n";
xml << " </hitachidsp>\n";
xml.append(" <hitachidsp model='HG51B169' frequency='20000000' firmware='cx4.bin' sha256='ae8d4d1961b93421ff00b3caa1d0f0ce7783e749772a3369c36b3dbf0d37ef18'>\n");
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-7f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-ff:8000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <mmio>\n");
xml.append(" <map address='00-3f:6000-7fff'/>\n");
xml.append(" <map address='80-bf:6000-7fff'/>\n");
xml.append(" </mmio>\n");
xml.append(" </hitachidsp>\n");
} else if(has_spc7110) {
xml << " <rom>\n";
xml << " <map mode='shadow' address='00-0f:8000-ffff'/>\n";
xml << " <map mode='shadow' address='80-bf:8000-ffff'/>\n";
xml << " <map mode='linear' address='c0-cf:0000-ffff'/>\n";
xml << " </rom>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='shadow' address='00-0f:8000-ffff'/>\n");
xml.append(" <map mode='shadow' address='80-bf:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='c0-cf:0000-ffff'/>\n");
xml.append(" </rom>\n");
xml << " <spc7110>\n";
xml << " <mcu>\n";
xml << " <map address='d0-ff:0000-ffff' offset='0x100000' size='0x" << hex(size - 0x100000) << "'/>\n";
xml << " </mcu>\n";
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='00:6000-7fff'/>\n";
xml << " <map mode='linear' address='30:6000-7fff'/>\n";
xml << " </ram>\n";
xml << " <mmio>\n";
xml << " <map address='00-3f:4800-483f'/>\n";
xml << " <map address='80-bf:4800-483f'/>\n";
xml << " </mmio>\n";
xml.append(" <spc7110>\n");
xml.append(" <mcu>\n");
xml.append(" <map address='d0-ff:0000-ffff' offset='0x100000' size='0x", hex(size - 0x100000), "'/>\n");
xml.append(" </mcu>\n");
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='00:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='30:6000-7fff'/>\n");
xml.append(" </ram>\n");
xml.append(" <mmio>\n");
xml.append(" <map address='00-3f:4800-483f'/>\n");
xml.append(" <map address='80-bf:4800-483f'/>\n");
xml.append(" </mmio>\n");
if(has_spc7110rtc) {
xml << " <rtc>\n";
xml << " <map address='00-3f:4840-4842'/>\n";
xml << " <map address='80-bf:4840-4842'/>\n";
xml << " </rtc>\n";
xml.append(" <rtc>\n");
xml.append(" <map address='00-3f:4840-4842'/>\n");
xml.append(" <map address='80-bf:4840-4842'/>\n");
xml.append(" </rtc>\n");
}
xml << " <dcu>\n";
xml << " <map address='50:0000-ffff'/>\n";
xml << " </dcu>\n";
xml << " </spc7110>\n";
xml.append(" <dcu>\n");
xml.append(" <map address='50:0000-ffff'/>\n");
xml.append(" </dcu>\n");
xml.append(" </spc7110>\n");
} else if(mapper == LoROM) {
xml << " <rom>\n";
xml << " <map mode='linear' address='00-7f:8000-ffff'/>\n";
xml << " <map mode='linear' address='80-ff:8000-ffff'/>\n";
xml << " </rom>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-7f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-ff:8000-ffff'/>\n");
xml.append(" </rom>\n");
if(ram_size > 0) {
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='20-3f:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='a0-bf:6000-7fff'/>\n");
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
xml << " <map mode='linear' address='f0-ff:0000-7fff'/>\n";
xml.append(" <map mode='linear' address='70-7f:0000-7fff'/>\n");
xml.append(" <map mode='linear' address='f0-ff:0000-7fff'/>\n");
} else {
xml << " <map mode='linear' address='70-7f:0000-ffff'/>\n";
xml << " <map mode='linear' address='f0-ff:0000-ffff'/>\n";
xml.append(" <map mode='linear' address='70-7f:0000-ffff'/>\n");
xml.append(" <map mode='linear' address='f0-ff:0000-ffff'/>\n");
}
xml << " </ram>\n";
xml.append(" </ram>\n");
}
} else if(mapper == HiROM) {
xml << " <rom>\n";
xml << " <map mode='shadow' address='00-3f:8000-ffff'/>\n";
xml << " <map mode='linear' address='40-7f:0000-ffff'/>\n";
xml << " <map mode='shadow' address='80-bf:8000-ffff'/>\n";
xml << " <map mode='linear' address='c0-ff:0000-ffff'/>\n";
xml << " </rom>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='shadow' address='00-3f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='40-7f:0000-ffff'/>\n");
xml.append(" <map mode='shadow' address='80-bf:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='c0-ff:0000-ffff'/>\n");
xml.append(" </rom>\n");
if(ram_size > 0) {
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='20-3f:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='a0-bf:6000-7fff'/>\n");
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
xml.append(" <map mode='linear' address='70-7f:0000-7fff'/>\n");
} else {
xml << " <map mode='linear' address='70-7f:0000-ffff'/>\n";
xml.append(" <map mode='linear' address='70-7f:0000-ffff'/>\n");
}
xml << " </ram>\n";
xml.append(" </ram>\n");
}
} else if(mapper == ExLoROM) {
xml << " <rom>\n";
xml << " <map mode='linear' address='00-3f:8000-ffff'/>\n";
xml << " <map mode='linear' address='40-7f:0000-ffff'/>\n";
xml << " <map mode='linear' address='80-bf:8000-ffff'/>\n";
xml << " </rom>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-3f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='40-7f:0000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-bf:8000-ffff'/>\n");
xml.append(" </rom>\n");
if(ram_size > 0) {
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
xml << " </ram>\n";
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='20-3f:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='a0-bf:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='70-7f:0000-7fff'/>\n");
xml.append(" </ram>\n");
}
} else if(mapper == ExHiROM) {
xml << " <rom>\n";
xml << " <map mode='shadow' address='00-3f:8000-ffff' offset='0x400000'/>\n";
xml << " <map mode='linear' address='40-7f:0000-ffff' offset='0x400000'/>\n";
xml << " <map mode='shadow' address='80-bf:8000-ffff' offset='0x000000'/>\n";
xml << " <map mode='linear' address='c0-ff:0000-ffff' offset='0x000000'/>\n";
xml << " </rom>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='shadow' address='00-3f:8000-ffff' offset='0x400000'/>\n");
xml.append(" <map mode='linear' address='40-7f:0000-ffff' offset='0x400000'/>\n");
xml.append(" <map mode='shadow' address='80-bf:8000-ffff' offset='0x000000'/>\n");
xml.append(" <map mode='linear' address='c0-ff:0000-ffff' offset='0x000000'/>\n");
xml.append(" </rom>\n");
if(ram_size > 0) {
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='20-3f:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='a0-bf:6000-7fff'/>\n");
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
xml.append(" <map mode='linear' address='70-7f:0000-7fff'/>\n");
} else {
xml << " <map mode='linear' address='70-7f:0000-ffff'/>\n";
xml.append(" <map mode='linear' address='70-7f:0000-ffff'/>\n");
}
xml << " </ram>\n";
xml.append(" </ram>\n");
}
} else if(mapper == SuperFXROM) {
xml << " <superfx revision='2'>\n";
xml << " <rom>\n";
xml << " <map mode='linear' address='00-3f:8000-ffff'/>\n";
xml << " <map mode='linear' address='40-5f:0000-ffff'/>\n";
xml << " <map mode='linear' address='80-bf:8000-ffff'/>\n";
xml << " <map mode='linear' address='c0-df:0000-ffff'/>\n";
xml << " </rom>\n";
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='00-3f:6000-7fff' size='0x2000'/>\n";
xml << " <map mode='linear' address='60-7f:0000-ffff'/>\n";
xml << " <map mode='linear' address='80-bf:6000-7fff' size='0x2000'/>\n";
xml << " <map mode='linear' address='e0-ff:0000-ffff'/>\n";
xml << " </ram>\n";
xml << " <mmio>\n";
xml << " <map address='00-3f:3000-32ff'/>\n";
xml << " <map address='80-bf:3000-32ff'/>\n";
xml << " </mmio>\n";
xml << " </superfx>\n";
xml.append(" <superfx revision='2'>\n");
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-3f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='40-5f:0000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-bf:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='c0-df:0000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='00-3f:6000-7fff' size='0x2000'/>\n");
xml.append(" <map mode='linear' address='60-7f:0000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-bf:6000-7fff' size='0x2000'/>\n");
xml.append(" <map mode='linear' address='e0-ff:0000-ffff'/>\n");
xml.append(" </ram>\n");
xml.append(" <mmio>\n");
xml.append(" <map address='00-3f:3000-32ff'/>\n");
xml.append(" <map address='80-bf:3000-32ff'/>\n");
xml.append(" </mmio>\n");
xml.append(" </superfx>\n");
} else if(mapper == SA1ROM) {
xml << " <sa1>\n";
xml << " <mcu>\n";
xml << " <rom>\n";
xml << " <map mode='direct' address='00-3f:8000-ffff'/>\n";
xml << " <map mode='direct' address='80-bf:8000-ffff'/>\n";
xml << " <map mode='direct' address='c0-ff:0000-ffff'/>\n";
xml << " </rom>\n";
xml << " <ram>\n";
xml << " <map mode='direct' address='00-3f:6000-7fff'/>\n";
xml << " <map mode='direct' address='80-bf:6000-7fff'/>\n";
xml << " </ram>\n";
xml << " </mcu>\n";
xml << " <iram size='0x800'>\n";
xml << " <map mode='linear' address='00-3f:3000-37ff'/>\n";
xml << " <map mode='linear' address='80-bf:3000-37ff'/>\n";
xml << " </iram>\n";
xml << " <bwram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='40-4f:0000-ffff'/>\n";
xml << " </bwram>\n";
xml << " <mmio>\n";
xml << " <map address='00-3f:2200-23ff'/>\n";
xml << " <map address='80-bf:2200-23ff'/>\n";
xml << " </mmio>\n";
xml << " </sa1>\n";
xml.append(" <sa1>\n");
xml.append(" <mcu>\n");
xml.append(" <rom>\n");
xml.append(" <map mode='direct' address='00-3f:8000-ffff'/>\n");
xml.append(" <map mode='direct' address='80-bf:8000-ffff'/>\n");
xml.append(" <map mode='direct' address='c0-ff:0000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <ram>\n");
xml.append(" <map mode='direct' address='00-3f:6000-7fff'/>\n");
xml.append(" <map mode='direct' address='80-bf:6000-7fff'/>\n");
xml.append(" </ram>\n");
xml.append(" </mcu>\n");
xml.append(" <iram size='0x800'>\n");
xml.append(" <map mode='linear' address='00-3f:3000-37ff'/>\n");
xml.append(" <map mode='linear' address='80-bf:3000-37ff'/>\n");
xml.append(" </iram>\n");
xml.append(" <bwram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='40-4f:0000-ffff'/>\n");
xml.append(" </bwram>\n");
xml.append(" <mmio>\n");
xml.append(" <map address='00-3f:2200-23ff'/>\n");
xml.append(" <map address='80-bf:2200-23ff'/>\n");
xml.append(" </mmio>\n");
xml.append(" </sa1>\n");
} else if(mapper == BSCLoROM) {
xml << " <rom>\n";
xml << " <map mode='linear' address='00-1f:8000-ffff' offset='0x000000'/>\n";
xml << " <map mode='linear' address='20-3f:8000-ffff' offset='0x100000'/>\n";
xml << " <map mode='linear' address='80-9f:8000-ffff' offset='0x200000'/>\n";
xml << " <map mode='linear' address='a0-bf:8000-ffff' offset='0x100000'/>\n";
xml << " </rom>\n";
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
xml << " <map mode='linear' address='f0-ff:0000-7fff'/>\n";
xml << " </ram>\n";
xml << " <bsx>\n";
xml << " <slot>\n";
xml << " <map mode='linear' address='c0-ef:0000-ffff'/>\n";
xml << " </slot>\n";
xml << " </bsx>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-1f:8000-ffff' offset='0x000000'/>\n");
xml.append(" <map mode='linear' address='20-3f:8000-ffff' offset='0x100000'/>\n");
xml.append(" <map mode='linear' address='80-9f:8000-ffff' offset='0x200000'/>\n");
xml.append(" <map mode='linear' address='a0-bf:8000-ffff' offset='0x100000'/>\n");
xml.append(" </rom>\n");
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='70-7f:0000-7fff'/>\n");
xml.append(" <map mode='linear' address='f0-ff:0000-7fff'/>\n");
xml.append(" </ram>\n");
xml.append(" <bsx>\n");
xml.append(" <slot>\n");
xml.append(" <map mode='linear' address='c0-ef:0000-ffff'/>\n");
xml.append(" </slot>\n");
xml.append(" </bsx>\n");
} else if(mapper == BSCHiROM) {
xml << " <rom>\n";
xml << " <map mode='shadow' address='00-1f:8000-ffff'/>\n";
xml << " <map mode='linear' address='40-5f:0000-ffff'/>\n";
xml << " <map mode='shadow' address='80-9f:8000-ffff'/>\n";
xml << " <map mode='linear' address='c0-df:0000-ffff'/>\n";
xml << " </rom>\n";
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
xml << " </ram>\n";
xml << " <bsx>\n";
xml << " <slot>\n";
xml << " <map mode='shadow' address='20-3f:8000-ffff'/>\n";
xml << " <map mode='linear' address='60-7f:0000-ffff'/>\n";
xml << " <map mode='shadow' address='a0-bf:8000-ffff'/>\n";
xml << " <map mode='linear' address='e0-ff:0000-ffff'/>\n";
xml << " </slot>\n";
xml << " </bsx>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='shadow' address='00-1f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='40-5f:0000-ffff'/>\n");
xml.append(" <map mode='shadow' address='80-9f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='c0-df:0000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <ram size='0x", hex(ram_size), "'>\n");
xml.append(" <map mode='linear' address='20-3f:6000-7fff'/>\n");
xml.append(" <map mode='linear' address='a0-bf:6000-7fff'/>\n");
xml.append(" </ram>\n");
xml.append(" <bsx>\n");
xml.append(" <slot>\n");
xml.append(" <map mode='shadow' address='20-3f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='60-7f:0000-ffff'/>\n");
xml.append(" <map mode='shadow' address='a0-bf:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='e0-ff:0000-ffff'/>\n");
xml.append(" </slot>\n");
xml.append(" </bsx>\n");
} else if(mapper == BSXROM) {
xml << " <bsx>\n";
xml << " <mcu>\n";
xml << " <map address='00-3f:8000-ffff'/>\n";
xml << " <map address='80-bf:8000-ffff'/>\n";
xml << " <map address='40-7f:0000-ffff'/>\n";
xml << " <map address='c0-ff:0000-ffff'/>\n";
xml << " <map address='20-3f:6000-7fff'/>\n";
xml << " </mcu>\n";
xml << " <mmio>\n";
xml << " <map address='00-3f:5000-5fff'/>\n";
xml << " <map address='80-bf:5000-5fff'/>\n";
xml << " </mmio>\n";
xml << " </bsx>\n";
xml.append(" <bsx>\n");
xml.append(" <mcu>\n");
xml.append(" <map address='00-3f:8000-ffff'/>\n");
xml.append(" <map address='80-bf:8000-ffff'/>\n");
xml.append(" <map address='40-7f:0000-ffff'/>\n");
xml.append(" <map address='c0-ff:0000-ffff'/>\n");
xml.append(" <map address='20-3f:6000-7fff'/>\n");
xml.append(" </mcu>\n");
xml.append(" <mmio>\n");
xml.append(" <map address='00-3f:5000-5fff'/>\n");
xml.append(" <map address='80-bf:5000-5fff'/>\n");
xml.append(" </mmio>\n");
xml.append(" </bsx>\n");
} else if(mapper == STROM) {
xml << " <rom>\n";
xml << " <map mode='linear' address='00-1f:8000-ffff'/>\n";
xml << " <map mode='linear' address='80-9f:8000-ffff'/>\n";
xml << " </rom>\n";
xml << " <sufamiturbo>\n";
xml << " <slot id='A'>\n";
xml << " <rom>\n";
xml << " <map mode='linear' address='20-3f:8000-ffff'/>\n";
xml << " <map mode='linear' address='a0-bf:8000-ffff'/>\n";
xml << " </rom>\n";
xml << " <ram size='0x20000'>\n";
xml << " <map mode='linear' address='60-63:8000-ffff'/>\n";
xml << " <map mode='linear' address='e0-e3:8000-ffff'/>\n";
xml << " </ram>\n";
xml << " </slot>\n";
xml << " <slot id='B'>\n";
xml << " <rom>\n";
xml << " <map mode='linear' address='40-5f:8000-ffff'/>\n";
xml << " <map mode='linear' address='c0-df:8000-ffff'/>\n";
xml << " </rom>\n";
xml << " <ram size='0x20000'>\n";
xml << " <map mode='linear' address='70-73:8000-ffff'/>\n";
xml << " <map mode='linear' address='f0-f3:8000-ffff'/>\n";
xml << " </ram>\n";
xml << " </slot>\n";
xml << " </sufamiturbo>\n";
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='00-1f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='80-9f:8000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <sufamiturbo>\n");
xml.append(" <slot id='A'>\n");
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='20-3f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='a0-bf:8000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <ram size='0x20000'>\n");
xml.append(" <map mode='linear' address='60-63:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='e0-e3:8000-ffff'/>\n");
xml.append(" </ram>\n");
xml.append(" </slot>\n");
xml.append(" <slot id='B'>\n");
xml.append(" <rom>\n");
xml.append(" <map mode='linear' address='40-5f:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='c0-df:8000-ffff'/>\n");
xml.append(" </rom>\n");
xml.append(" <ram size='0x20000'>\n");
xml.append(" <map mode='linear' address='70-73:8000-ffff'/>\n");
xml.append(" <map mode='linear' address='f0-f3:8000-ffff'/>\n");
xml.append(" </ram>\n");
xml.append(" </slot>\n");
xml.append(" </sufamiturbo>\n");
}
if(has_srtc) {
xml << " <srtc>\n";
xml << " <map address='00-3f:2800-2801'/>\n";
xml << " <map address='80-bf:2800-2801'/>\n";
xml << " </srtc>\n";
xml.append(" <srtc>\n");
xml.append(" <map address='00-3f:2800-2801'/>\n");
xml.append(" <map address='80-bf:2800-2801'/>\n");
xml.append(" </srtc>\n");
}
if(has_sdd1) {
xml << " <sdd1>\n";
xml << " <mcu>\n";
xml << " <map address='c0-ff:0000-ffff'/>\n";
xml << " </mcu>\n";
xml << " <mmio>\n";
xml << " <map address='00-3f:4800-4807'/>\n";
xml << " <map address='80-bf:4800-4807'/>\n";
xml << " </mmio>\n";
xml << " </sdd1>\n";
xml.append(" <sdd1>\n");
xml.append(" <mcu>\n");
xml.append(" <map address='c0-ff:0000-ffff'/>\n");
xml.append(" </mcu>\n");
xml.append(" <mmio>\n");
xml.append(" <map address='00-3f:4800-4807'/>\n");
xml.append(" <map address='80-bf:4800-4807'/>\n");
xml.append(" </mmio>\n");
xml.append(" </sdd1>\n");
}
if(has_dsp1) {
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp1b.bin' sha256='4d42db0f36faef263d6b93f508e8c1c4ae8fc2605fd35e3390ecc02905cd420c'>\n";
xml.append(" <necdsp model='uPD7725' frequency='8000000' firmware='dsp1b.bin' sha256='4d42db0f36faef263d6b93f508e8c1c4ae8fc2605fd35e3390ecc02905cd420c'>\n");
if(dsp1_mapper == DSP1LoROM1MB) {
xml << " <dr>\n";
xml << " <map address='20-3f:8000-bfff'/>\n";
xml << " <map address='a0-bf:8000-bfff'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='20-3f:c000-ffff'/>\n";
xml << " <map address='a0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml.append(" <dr>\n");
xml.append(" <map address='20-3f:8000-bfff'/>\n");
xml.append(" <map address='a0-bf:8000-bfff'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='20-3f:c000-ffff'/>\n");
xml.append(" <map address='a0-bf:c000-ffff'/>\n");
xml.append(" </sr>\n");
} else if(dsp1_mapper == DSP1LoROM2MB) {
xml << " <dr>\n";
xml << " <map address='60-6f:0000-3fff'/>\n";
xml << " <map address='e0-ef:0000-3fff'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='60-6f:4000-7fff'/>\n";
xml << " <map address='e0-ef:4000-7fff'/>\n";
xml << " </sr>\n";
xml.append(" <dr>\n");
xml.append(" <map address='60-6f:0000-3fff'/>\n");
xml.append(" <map address='e0-ef:0000-3fff'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='60-6f:4000-7fff'/>\n");
xml.append(" <map address='e0-ef:4000-7fff'/>\n");
xml.append(" </sr>\n");
} else if(dsp1_mapper == DSP1HiROM) {
xml << " <dr>\n";
xml << " <map address='00-1f:6000-6fff'/>\n";
xml << " <map address='80-9f:6000-6fff'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='00-1f:7000-7fff'/>\n";
xml << " <map address='80-9f:7000-7fff'/>\n";
xml << " </sr>\n";
xml.append(" <dr>\n");
xml.append(" <map address='00-1f:6000-6fff'/>\n");
xml.append(" <map address='80-9f:6000-6fff'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='00-1f:7000-7fff'/>\n");
xml.append(" <map address='80-9f:7000-7fff'/>\n");
xml.append(" </sr>\n");
}
xml << " </necdsp>\n";
xml.append(" </necdsp>\n");
}
if(has_dsp2) {
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp2.bin' sha256='5efbdf96ed0652790855225964f3e90e6a4d466cfa64df25b110933c6cf94ea1'>\n";
xml << " <dr>\n";
xml << " <map address='20-3f:8000-bfff'/>\n";
xml << " <map address='a0-bf:8000-bfff'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='20-3f:c000-ffff'/>\n";
xml << " <map address='a0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml << " </necdsp>\n";
xml.append(" <necdsp model='uPD7725' frequency='8000000' firmware='dsp2.bin' sha256='5efbdf96ed0652790855225964f3e90e6a4d466cfa64df25b110933c6cf94ea1'>\n");
xml.append(" <dr>\n");
xml.append(" <map address='20-3f:8000-bfff'/>\n");
xml.append(" <map address='a0-bf:8000-bfff'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='20-3f:c000-ffff'/>\n");
xml.append(" <map address='a0-bf:c000-ffff'/>\n");
xml.append(" </sr>\n");
xml.append(" </necdsp>\n");
}
if(has_dsp3) {
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp3.bin' sha256='2e635f72e4d4681148bc35429421c9b946e4f407590e74e31b93b8987b63ba90'>\n";
xml << " <dr>\n";
xml << " <map address='20-3f:8000-bfff'/>\n";
xml << " <map address='a0-bf:8000-bfff'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='20-3f:c000-ffff'/>\n";
xml << " <map address='a0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml << " </necdsp>\n";
xml.append(" <necdsp model='uPD7725' frequency='8000000' firmware='dsp3.bin' sha256='2e635f72e4d4681148bc35429421c9b946e4f407590e74e31b93b8987b63ba90'>\n");
xml.append(" <dr>\n");
xml.append(" <map address='20-3f:8000-bfff'/>\n");
xml.append(" <map address='a0-bf:8000-bfff'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='20-3f:c000-ffff'/>\n");
xml.append(" <map address='a0-bf:c000-ffff'/>\n");
xml.append(" </sr>\n");
xml.append(" </necdsp>\n");
}
if(has_dsp4) {
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp4.bin' sha256='63ede17322541c191ed1fdf683872554a0a57306496afc43c59de7c01a6e764a'>\n";
xml << " <dr>\n";
xml << " <map address='30-3f:8000-bfff'/>\n";
xml << " <map address='b0-bf:8000-bfff'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='30-3f:c000-ffff'/>\n";
xml << " <map address='b0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml << " </necdsp>\n";
xml.append(" <necdsp model='uPD7725' frequency='8000000' firmware='dsp4.bin' sha256='63ede17322541c191ed1fdf683872554a0a57306496afc43c59de7c01a6e764a'>\n");
xml.append(" <dr>\n");
xml.append(" <map address='30-3f:8000-bfff'/>\n");
xml.append(" <map address='b0-bf:8000-bfff'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='30-3f:c000-ffff'/>\n");
xml.append(" <map address='b0-bf:c000-ffff'/>\n");
xml.append(" </sr>\n");
xml.append(" </necdsp>\n");
}
if(has_obc1) {
xml << " <obc1>\n";
xml << " <map address='00-3f:6000-7fff'/>\n";
xml << " <map address='80-bf:6000-7fff'/>\n";
xml << " </obc1>\n";
xml.append(" <obc1>\n");
xml.append(" <map address='00-3f:6000-7fff'/>\n");
xml.append(" <map address='80-bf:6000-7fff'/>\n");
xml.append(" </obc1>\n");
}
if(has_st010) {
xml << " <necdsp model='uPD96050' frequency='10000000' program='st0010.bin' sha256='55c697e864562445621cdf8a7bf6e84ae91361e393d382a3704e9aa55559041e'>\n";
xml << " <dr>\n";
xml << " <map address='60:0000'/>\n";
xml << " <map address='e0:0000'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='60:0001'/>\n";
xml << " <map address='e0:0001'/>\n";
xml << " </sr>\n";
xml << " <dp>\n";
xml << " <map address='68-6f:0000-0fff'/>\n";
xml << " <map address='e8-ef:0000-0fff'/>\n";
xml << " </dp>\n";
xml << " </necdsp>\n";
xml.append(" <necdsp model='uPD96050' frequency='10000000' firmware='st0010.bin' sha256='55c697e864562445621cdf8a7bf6e84ae91361e393d382a3704e9aa55559041e'>\n");
xml.append(" <dr>\n");
xml.append(" <map address='60:0000'/>\n");
xml.append(" <map address='e0:0000'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='60:0001'/>\n");
xml.append(" <map address='e0:0001'/>\n");
xml.append(" </sr>\n");
xml.append(" <dp>\n");
xml.append(" <map address='68-6f:0000-0fff'/>\n");
xml.append(" <map address='e8-ef:0000-0fff'/>\n");
xml.append(" </dp>\n");
xml.append(" </necdsp>\n");
}
if(has_st011) {
xml << " <necdsp model='uPD96050' frequency='15000000' program='st0011.bin' sha256='651b82a1e26c4fa8dd549e91e7f923012ed2ca54c1d9fd858655ab30679c2f0e'>\n";
xml << " <dr>\n";
xml << " <map address='60:0000'/>\n";
xml << " <map address='e0:0000'/>\n";
xml << " </dr>\n";
xml << " <sr>\n";
xml << " <map address='60:0001'/>\n";
xml << " <map address='e0:0001'/>\n";
xml << " </sr>\n";
xml << " <dp>\n";
xml << " <map address='68-6f:0000-0fff'/>\n";
xml << " <map address='e8-ef:0000-0fff'/>\n";
xml << " </dp>\n";
xml << " </necdsp>\n";
xml.append(" <necdsp model='uPD96050' frequency='15000000' firmware='st0011.bin' sha256='651b82a1e26c4fa8dd549e91e7f923012ed2ca54c1d9fd858655ab30679c2f0e'>\n");
xml.append(" <dr>\n");
xml.append(" <map address='60:0000'/>\n");
xml.append(" <map address='e0:0000'/>\n");
xml.append(" </dr>\n");
xml.append(" <sr>\n");
xml.append(" <map address='60:0001'/>\n");
xml.append(" <map address='e0:0001'/>\n");
xml.append(" </sr>\n");
xml.append(" <dp>\n");
xml.append(" <map address='68-6f:0000-0fff'/>\n");
xml.append(" <map address='e8-ef:0000-0fff'/>\n");
xml.append(" </dp>\n");
xml.append(" </necdsp>\n");
}
if(has_st018) {
xml << " <setarisc program='ST-0018'>\n";
xml << " <map address='00-3f:3800-38ff'/>\n";
xml << " <map address='80-bf:3800-38ff'/>\n";
xml << " </setarisc>\n";
xml.append(" <setarisc firmware='ST-0018'>\n");
xml.append(" <map address='00-3f:3800-38ff'/>\n");
xml.append(" <map address='80-bf:3800-38ff'/>\n");
xml.append(" </setarisc>\n");
}
xml << "</cartridge>\n";
xml.append("</cartridge>\n");
xmlMemoryMap = xml.transform("'", "\"");
}

66
bsnes/nall/stack.hpp Executable file
View File

@ -0,0 +1,66 @@
#ifndef NALL_STACK_HPP
#define NALL_STACK_HPP
#include <nall/vector.hpp>
namespace nall {
template<typename T> struct stack_fifo {
T& operator()() {
if(list.size() == 0) throw;
return list[0];
}
void reset() {
list.reset();
}
unsigned size() const {
return list.size();
}
void push(const T &value) {
list.append(value);
}
T pull() {
if(list.size() == 0) throw;
T value = list[0];
list.remove(0);
return value;
}
private:
linear_vector<T> list;
};
template<typename T> struct stack_filo {
T& operator()() {
if(list.size() == 0) throw;
return list[list.size() - 1];
}
void reset() {
list.reset();
}
unsigned size() const {
return list.size();
}
void push(const T &value) {
list.append(value);
}
T pull() {
if(list.size() == 0) throw;
T value = list[list.size() - 1];
list.remove(list.size() - 1);
return value;
}
private:
linear_vector<T> list;
};
}
#endif

View File

@ -3,6 +3,7 @@
#include <initializer_list>
#include <nall/platform.hpp>
#include <nall/sha256.hpp>
#include <nall/utility.hpp>
#include <nall/string/base.hpp>

View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
#include <nall/concept.hpp>
#include <nall/function.hpp>
#include <nall/stdint.hpp>
#include <nall/utf8.hpp>
#include <nall/vector.hpp>
@ -43,6 +44,8 @@ namespace nall {
inline string& lower();
inline string& upper();
inline string& qlower();
inline string& qupper();
inline string& transform(const char *before, const char *after);
template<unsigned limit = 0> inline string& ltrim(const char *key = " ");
@ -52,9 +55,6 @@ namespace nall {
inline optional<unsigned> position(const char *key) const;
inline optional<unsigned> qposition(const char *key) const;
template<typename T> inline string& operator= (T value);
template<typename T> inline string& operator<<(T value);
inline operator const char*() const;
inline char* operator()();
inline char& operator[](int);
@ -110,6 +110,8 @@ namespace nall {
//convert.hpp
inline char* strlower(char *str);
inline char* strupper(char *str);
inline char* qstrlower(char *str);
inline char* qstrupper(char *str);
inline char* strtr(char *dest, const char *before, const char *after);
inline uintmax_t hex (const char *str);
inline intmax_t integer(const char *str);
@ -142,7 +144,8 @@ namespace nall {
//utility.hpp
inline unsigned strlcpy(string &dest, const char *src, unsigned length);
inline unsigned strlcat(string &dest, const char *src, unsigned length);
inline string substr(const char *src, unsigned start = 0, unsigned length = 0);
inline string substr(const char *src, unsigned start = 0, unsigned length = ~0u);
inline string sha256(const uint8_t *data, unsigned size);
inline string integer(intmax_t value);
template<unsigned length = 0> inline string linteger(intmax_t value);

View File

@ -15,9 +15,6 @@ template<> inline const char* to_string<const char*> (const char *v) { return
template<> inline const char* to_string<string> (string v) { return v; }
template<> inline const char* to_string<const string&>(const string &v) { return v; }
template<typename T> string& string::operator= (T value) { return assign(to_string<T>(value)); }
template<typename T> string& string::operator<<(T value) { return append(to_string<T>(value)); }
template<typename T> lstring& lstring::operator<<(T value) {
operator[](size()).assign(to_string<T>(value));
return *this;

View File

@ -23,6 +23,26 @@ char* strupper(char *str) {
return str;
}
char* qstrlower(char *s) {
if(!s) return 0;
bool quoted = false;
while(*s) {
if(*s == '\"') quoted ^= 1;
if(quoted == false && *s >= 'A' && *s <= 'Z') *s += 0x20;
s++;
}
}
char* qstrupper(char *s) {
if(!s) return 0;
bool quoted = false;
while(*s) {
if(*s == '\"') quoted ^= 1;
if(quoted == false && *s >= 'a' && *s <= 'z') *s -= 0x20;
s++;
}
}
char* strtr(char *dest, const char *before, const char *after) {
if(!dest || !before || !after) return dest;
int sl = strlen(dest), bsl = strlen(before), asl = strlen(after);

View File

@ -3,6 +3,8 @@
namespace nall {
static function<int64_t (const char *&)> eval_fallback;
static int eval_integer(const char *&s) {
if(!*s) throw "unrecognized_integer";
int value = 0, x = *s, y = *(s + 1);
@ -74,6 +76,8 @@ static int eval(const char *&s, int depth = 0) {
else if((x >= '0' && x <= '9') || x == '\'') value = eval_integer(s);
else if(eval_fallback) value = eval_fallback(s); //optional user-defined syntax parsing
else throw "unrecognized_token";
while(true) {

View File

@ -15,7 +15,7 @@ unsigned strlcat(string &dest, const char *src, unsigned length) {
string substr(const char *src, unsigned start, unsigned length) {
string dest;
if(length == 0) {
if(length == ~0u) {
//copy entire string
dest = src + start;
} else {
@ -25,6 +25,18 @@ string substr(const char *src, unsigned start, unsigned length) {
return dest;
}
string sha256(const uint8_t *data, unsigned size) {
sha256_ctx sha;
uint8_t hash[32];
sha256_init(&sha);
sha256_chunk(&sha, data, size);
sha256_final(&sha);
sha256_hash(&sha, hash);
string result;
foreach(byte, hash) result.append(hex<2>(byte));
return result;
}
/* arithmetic <> string */
string integer(intmax_t value) {

View File

@ -19,6 +19,8 @@ bool string::iendswith(const char *str) const { return striend(data, str); }
string& string::lower() { nall::strlower(data); return *this; }
string& string::upper() { nall::strupper(data); return *this; }
string& string::qlower() { nall::qstrlower(data); return *this; }
string& string::qupper() { nall::qstrupper(data); return *this; }
string& string::transform(const char *before, const char *after) { nall::strtr(data, before, after); return *this; }
template<unsigned limit> string& string::ltrim(const char *key) { nall::ltrim<limit>(data, key); return *this; }

View File

@ -77,7 +77,7 @@ inline string xml_element::parse() const {
if(auto pos = strpos(source, "]]>")) {
if(pos() - 9 > 0) {
string cdata = substr(source, 9, pos() - 9);
data << cdata;
data.append(cdata);
offset += strlen(cdata);
}
source += 9 + offset + 3;

View File

@ -54,7 +54,7 @@ void Cartridge::load(Mode cartridge_mode, const lstring &xml_list) {
sha256_hash(&sha, shahash);
string hash;
foreach(n, shahash) hash << hex<2>(n);
foreach(n, shahash) hash.append(hex<2>(n));
sha256 = hash;
system.load();

View File

@ -284,8 +284,7 @@ void Cartridge::xml_parse_necdsp(xml_element &root) {
for(unsigned n = 0; n < 16384; n++) necdsp.programROM[n] = 0x000000;
for(unsigned n = 0; n < 2048; n++) necdsp.dataROM[n] = 0x0000;
string program, programhash;
string sha256;
string firmware, sha256;
foreach(attr, root.attribute) {
if(attr.name == "model") {
@ -293,36 +292,39 @@ void Cartridge::xml_parse_necdsp(xml_element &root) {
if(attr.content == "uPD96050") necdsp.revision = NECDSP::Revision::uPD96050;
} else if(attr.name == "frequency") {
necdsp.frequency = xml_parse_unsigned(attr.content);
} else if(attr.name == "program") {
program = attr.content;
} else if(attr.name == "firmware") {
firmware = attr.content;
} else if(attr.name == "sha256") {
sha256 = attr.content;
}
}
string path = { dir(system.interface->path(Slot::Base, ".dsp")), program };
string path = { dir(system.interface->path(Slot::Base, ".dsp")), firmware };
unsigned promsize = (necdsp.revision == NECDSP::Revision::uPD7725 ? 2048 : 16384);
unsigned dromsize = (necdsp.revision == NECDSP::Revision::uPD7725 ? 1024 : 2048);
unsigned filesize = promsize * 3 + dromsize * 2;
file fp;
if(fp.open(path, file::mode::read)) {
if(fp.size() == filesize) {
if(fp.open(path, file::mode::read) == false) {
system.interface->message({ "Warning: NEC DSP firmware ", firmware, " is missing." });
} else if(fp.size() != filesize) {
system.interface->message({ "Warning: NEC DSP firmware ", firmware, " is of the wrong file size." });
fp.close();
} else {
for(unsigned n = 0; n < promsize; n++) necdsp.programROM[n] = fp.readm(3);
for(unsigned n = 0; n < dromsize; n++) necdsp.dataROM[n] = fp.readm(2);
if(sha256 != "") {
//XML file specified SHA256 sum for program. Verify file matches the hash.
fp.seek(0);
uint8_t data[filesize];
fp.read(data, filesize);
sha256_ctx sha;
uint8 shahash[32];
sha256_init(&sha);
sha256_chunk(&sha, data, filesize);
sha256_final(&sha);
sha256_hash(&sha, shahash);
foreach(n, shahash) programhash.append(hex<2>(n));
if(sha256 != nall::sha256(data, filesize)) {
system.interface->message({ "Warning: Hitachi DSP firmware ", firmware, " SHA256 sum is incorrect." });
}
}
fp.close();
}
@ -359,16 +361,6 @@ void Cartridge::xml_parse_necdsp(xml_element &root) {
}
}
}
if(programhash == "") {
system.interface->message({ "Warning: NEC DSP program ", program, " is missing." });
} else if(sha256 != "" && sha256 != programhash) {
system.interface->message({
"Warning: NEC DSP program ", program, " SHA256 is incorrect.\n\n"
"Expected:\n", sha256, "\n\n"
"Actual:\n", programhash
});
}
}
void Cartridge::xml_parse_hitachidsp(xml_element &root) {
@ -377,24 +369,24 @@ void Cartridge::xml_parse_hitachidsp(xml_element &root) {
for(unsigned n = 0; n < 1024; n++) hitachidsp.dataROM[n] = 0x000000;
string dataROM, sha256;
string firmware, sha256;
foreach(attr, root.attribute) {
if(attr.name == "frequency") {
hitachidsp.frequency = xml_parse_unsigned(attr.content);
} else if(attr.name == "data") {
dataROM = attr.content;
} else if(attr.name == "firmware") {
firmware = attr.content;
} else if(attr.name == "sha256") {
sha256 = attr.content;
}
}
string path = { dir(system.interface->path(Slot::Base, ".dsp")), dataROM };
string path = { dir(system.interface->path(Slot::Base, ".dsp")), firmware };
file fp;
if(fp.open(path, file::mode::read) == false) {
system.interface->message({ "Warning: Hitachi DSP data ", dataROM, " is missing." });
system.interface->message({ "Warning: Hitachi DSP firmware ", firmware, " is missing." });
} else if(fp.size() != 1024 * 3) {
system.interface->message({ "Warning: Hitachi DSP data ", dataROM, " is of the wrong file size." });
system.interface->message({ "Warning: Hitachi DSP firmware ", firmware, " is of the wrong file size." });
fp.close();
} else {
for(unsigned n = 0; n < 1024; n++) hitachidsp.dataROM[n] = fp.readl(3);
@ -405,18 +397,8 @@ void Cartridge::xml_parse_hitachidsp(xml_element &root) {
uint8 data[3072];
fp.read(data, 3072);
sha256_ctx sha;
uint8 hash[32];
sha256_init(&sha);
sha256_chunk(&sha, data, 3072);
sha256_final(&sha);
sha256_hash(&sha, hash);
string filehash;
foreach(n, hash) filehash.append(hex<2>(n));
if(sha256 != filehash) {
system.interface->message({ "Warning: Hitachi DSP data ", dataROM, " SHA256 sum is incorrect." });
if(sha256 != nall::sha256(data, 3072)) {
system.interface->message({ "Warning: Hitachi DSP firmware ", firmware, " SHA256 sum is incorrect." });
}
}

View File

@ -86,7 +86,7 @@ bool Cheat::decode(const char *s, unsigned &addr, uint8 &data, Type &type) {
if(strlen(t) == 8 || (strlen(t) == 9 && t[6] == ':')) {
//strip ':'
if(strlen(t) == 9 && t[6] == ':') t = string() << substr(t, 0, 6) << substr(t, 7);
if(strlen(t) == 9 && t[6] == ':') t = { substr(t, 0, 6), substr(t, 7) };
//validate input
for(unsigned i = 0; i < 8; i++) if(!ischr(t[i])) return false;
@ -97,7 +97,7 @@ bool Cheat::decode(const char *s, unsigned &addr, uint8 &data, Type &type) {
return true;
} else if(strlen(t) == 9 && t[4] == '-') {
//strip '-'
t = string() << substr(t, 0, 4) << substr(t, 5);
t = { substr(t, 0, 4), substr(t, 5) };
//validate input
for(unsigned i = 0; i < 8; i++) if(!ischr(t[i])) return false;

View File

@ -101,7 +101,7 @@ bool ICD2::input_poll(unsigned id) {
case 3: data = ~r6007; break;
}
switch(id) {
switch((GameBoy::Input)id) {
case GameBoy::Input::Start: return data & 0x80;
case GameBoy::Input::Select: return data & 0x40;
case GameBoy::Input::B: return data & 0x20;

View File

@ -16,114 +16,97 @@ string NECDSP::disassemble(uint14 ip) {
uint4 dst = opcode >> 0;
switch(alu) {
case 0: output << "nop "; break;
case 1: output << "or "; break;
case 2: output << "and "; break;
case 3: output << "xor "; break;
case 4: output << "sub "; break;
case 5: output << "add "; break;
case 6: output << "sbb "; break;
case 7: output << "adc "; break;
case 8: output << "dec "; break;
case 9: output << "inc "; break;
case 10: output << "cmp "; break;
case 11: output << "shr1 "; break;
case 12: output << "shl1 "; break;
case 13: output << "shl2 "; break;
case 14: output << "shl4 "; break;
case 15: output << "xchg "; break;
case 0: output.append("nop "); break;
case 1: output.append("or "); break;
case 2: output.append("and "); break;
case 3: output.append("xor "); break;
case 4: output.append("sub "); break;
case 5: output.append("add "); break;
case 6: output.append("sbb "); break;
case 7: output.append("adc "); break;
case 8: output.append("dec "); break;
case 9: output.append("inc "); break;
case 10: output.append("cmp "); break;
case 11: output.append("shr1 "); break;
case 12: output.append("shl1 "); break;
case 13: output.append("shl2 "); break;
case 14: output.append("shl4 "); break;
case 15: output.append("xchg "); break;
}
if(alu < 8) {
switch(pselect) {
case 0: output << "ram,"; break;
case 1: output << "idb,"; break;
case 2: output << "m,"; break;
case 3: output << "n,"; break;
case 0: output.append("ram,"); break;
case 1: output.append("idb,"); break;
case 2: output.append("m," ); break;
case 3: output.append("n," ); break;
}
}
switch(asl) {
case 0: output << "a"; break;
case 1: output << "b"; break;
case 0: output.append("a"); break;
case 1: output.append("b"); break;
}
output << "\n mov ";
output.append("\n mov ");
switch(src) {
case 0: output << "trb,"; break;
case 1: output << "a,"; break;
case 2: output << "b,"; break;
case 3: output << "tr,"; break;
case 4: output << "dp,"; break;
case 5: output << "rp,"; break;
case 6: output << "ro,"; break;
case 7: output << "sgn,"; break;
case 8: output << "dr,"; break;
case 9: output << "drnf,"; break;
case 10: output << "sr,"; break;
case 11: output << "sim,"; break;
case 12: output << "sil,"; break;
case 13: output << "k,"; break;
case 14: output << "l,"; break;
case 15: output << "mem,"; break;
case 0: output.append("trb," ); break;
case 1: output.append("a," ); break;
case 2: output.append("b," ); break;
case 3: output.append("tr," ); break;
case 4: output.append("dp," ); break;
case 5: output.append("rp," ); break;
case 6: output.append("ro," ); break;
case 7: output.append("sgn," ); break;
case 8: output.append("dr," ); break;
case 9: output.append("drnf,"); break;
case 10: output.append("sr," ); break;
case 11: output.append("sim," ); break;
case 12: output.append("sil," ); break;
case 13: output.append("k," ); break;
case 14: output.append("l," ); break;
case 15: output.append("mem," ); break;
}
switch(dst) {
case 0: output << "non"; break;
case 1: output << "a"; break;
case 2: output << "b"; break;
case 3: output << "tr"; break;
case 4: output << "dp"; break;
case 5: output << "rp"; break;
case 6: output << "dr"; break;
case 7: output << "sr"; break;
case 8: output << "sol"; break;
case 9: output << "som"; break;
case 10: output << "k"; break;
case 11: output << "klr"; break;
case 12: output << "klm"; break;
case 13: output << "l"; break;
case 14: output << "trb"; break;
case 15: output << "mem"; break;
case 0: output.append("non"); break;
case 1: output.append("a" ); break;
case 2: output.append("b" ); break;
case 3: output.append("tr" ); break;
case 4: output.append("dp" ); break;
case 5: output.append("rp" ); break;
case 6: output.append("dr" ); break;
case 7: output.append("sr" ); break;
case 8: output.append("sol"); break;
case 9: output.append("som"); break;
case 10: output.append("k" ); break;
case 11: output.append("klr"); break;
case 12: output.append("klm"); break;
case 13: output.append("l" ); break;
case 14: output.append("trb"); break;
case 15: output.append("mem"); break;
}
if(dpl) {
switch(dpl) {
case 0: output << "\n dpnop"; break;
case 1: output << "\n dpinc"; break;
case 2: output << "\n dpdec"; break;
case 3: output << "\n dpclr"; break;
case 0: output.append("\n dpnop"); break;
case 1: output.append("\n dpinc"); break;
case 2: output.append("\n dpdec"); break;
case 3: output.append("\n dpclr"); break;
}
}
if(dphm) {
switch(dphm) {
case 0: output << "\n m0"; break;
case 1: output << "\n m1"; break;
case 2: output << "\n m2"; break;
case 3: output << "\n m3"; break;
case 4: output << "\n m4"; break;
case 5: output << "\n m5"; break;
case 6: output << "\n m6"; break;
case 7: output << "\n m7"; break;
case 8: output << "\n m8"; break;
case 9: output << "\n m9"; break;
case 10: output << "\n ma"; break;
case 11: output << "\n mb"; break;
case 12: output << "\n mc"; break;
case 13: output << "\n md"; break;
case 14: output << "\n me"; break;
case 15: output << "\n mf"; break;
}
output.append("\n m", hex<1>(dphm));
}
if(rpdcr == 1) {
output << "\n rpdec";
output.append("\n rpdec");
}
if(type == 1) {
output << "\n ret";
output.append("\n ret");
}
}
@ -135,75 +118,75 @@ string NECDSP::disassemble(uint14 ip) {
uint14 jp = (regs.pc & 0x2000) | (bank << 11) | (na << 0);
switch(brch) {
case 0x000: output << "jmpso "; jp = 0; break;
case 0x080: output << "jnca "; break;
case 0x082: output << "jca "; break;
case 0x084: output << "jncb "; break;
case 0x086: output << "jcb "; break;
case 0x088: output << "jnza "; break;
case 0x08a: output << "jza "; break;
case 0x08c: output << "jnzb "; break;
case 0x08e: output << "jzb "; break;
case 0x090: output << "jnova0 "; break;
case 0x092: output << "jova0 "; break;
case 0x094: output << "jnovb0 "; break;
case 0x096: output << "jovb0 "; break;
case 0x098: output << "jnova1 "; break;
case 0x09a: output << "jova1 "; break;
case 0x09c: output << "jnovb1 "; break;
case 0x09e: output << "jovb1 "; break;
case 0x0a0: output << "jnsa0 "; break;
case 0x0a2: output << "jsa0 "; break;
case 0x0a4: output << "jnsb0 "; break;
case 0x0a6: output << "jsb0 "; break;
case 0x0a8: output << "jnsa1 "; break;
case 0x0aa: output << "jsa1 "; break;
case 0x0ac: output << "jnsb1 "; break;
case 0x0ae: output << "jsb1 "; break;
case 0x0b0: output << "jdpl0 "; break;
case 0x0b1: output << "jdpln0 "; break;
case 0x0b2: output << "jdplf "; break;
case 0x0b3: output << "jdplnf "; break;
case 0x0b4: output << "jnsiak "; break;
case 0x0b6: output << "jsiak "; break;
case 0x0b8: output << "jnsoak "; break;
case 0x0ba: output << "jsoak "; break;
case 0x0bc: output << "jnrqm "; break;
case 0x0be: output << "jrqm "; break;
case 0x100: output << "ljmp "; jp &= ~0x2000; break;
case 0x101: output << "hjmp "; jp |= 0x2000; break;
case 0x140: output << "lcall "; jp &= ~0x2000; break;
case 0x141: output << "hcall "; jp |= 0x2000; break;
default: output << "?????? "; break;
case 0x000: output.append("jmpso "); jp = 0; break;
case 0x080: output.append("jnca "); break;
case 0x082: output.append("jca "); break;
case 0x084: output.append("jncb "); break;
case 0x086: output.append("jcb "); break;
case 0x088: output.append("jnza "); break;
case 0x08a: output.append("jza "); break;
case 0x08c: output.append("jnzb "); break;
case 0x08e: output.append("jzb "); break;
case 0x090: output.append("jnova0 "); break;
case 0x092: output.append("jova0 "); break;
case 0x094: output.append("jnovb0 "); break;
case 0x096: output.append("jovb0 "); break;
case 0x098: output.append("jnova1 "); break;
case 0x09a: output.append("jova1 "); break;
case 0x09c: output.append("jnovb1 "); break;
case 0x09e: output.append("jovb1 "); break;
case 0x0a0: output.append("jnsa0 "); break;
case 0x0a2: output.append("jsa0 "); break;
case 0x0a4: output.append("jnsb0 "); break;
case 0x0a6: output.append("jsb0 "); break;
case 0x0a8: output.append("jnsa1 "); break;
case 0x0aa: output.append("jsa1 "); break;
case 0x0ac: output.append("jnsb1 "); break;
case 0x0ae: output.append("jsb1 "); break;
case 0x0b0: output.append("jdpl0 "); break;
case 0x0b1: output.append("jdpln0 "); break;
case 0x0b2: output.append("jdplf "); break;
case 0x0b3: output.append("jdplnf "); break;
case 0x0b4: output.append("jnsiak "); break;
case 0x0b6: output.append("jsiak "); break;
case 0x0b8: output.append("jnsoak "); break;
case 0x0ba: output.append("jsoak "); break;
case 0x0bc: output.append("jnrqm "); break;
case 0x0be: output.append("jrqm "); break;
case 0x100: output.append("ljmp "); jp &= ~0x2000; break;
case 0x101: output.append("hjmp "); jp |= 0x2000; break;
case 0x140: output.append("lcall "); jp &= ~0x2000; break;
case 0x141: output.append("hcall "); jp |= 0x2000; break;
default: output.append("?????? "); break;
}
output << "$" << hex<4>(jp);
output.append("$", hex<4>(jp));
}
if(type == 3) { //LD
output << "ld ";
output.append("ld ");
uint16 id = opcode >> 6;
uint4 dst = opcode >> 0;
output << "$" << hex<4>(id) << ",";
output.append("$", hex<4>(id), ",");
switch(dst) {
case 0: output << "non"; break;
case 1: output << "a"; break;
case 2: output << "b"; break;
case 3: output << "tr"; break;
case 4: output << "dp"; break;
case 5: output << "rp"; break;
case 6: output << "dr"; break;
case 7: output << "sr"; break;
case 8: output << "sol"; break;
case 9: output << "som"; break;
case 10: output << "k"; break;
case 11: output << "klr"; break;
case 12: output << "klm"; break;
case 13: output << "l"; break;
case 14: output << "trb"; break;
case 15: output << "mem"; break;
case 0: output.append("non"); break;
case 1: output.append("a" ); break;
case 2: output.append("b" ); break;
case 3: output.append("tr" ); break;
case 4: output.append("dp" ); break;
case 5: output.append("rp" ); break;
case 6: output.append("dr" ); break;
case 7: output.append("sr" ); break;
case 8: output.append("sol"); break;
case 9: output.append("som"); break;
case 10: output.append("k" ); break;
case 11: output.append("klr"); break;
case 12: output.append("klm"); break;
case 13: output.append("l" ); break;
case 14: output.append("trb"); break;
case 15: output.append("mem"); break;
}
}

View File

@ -2,7 +2,6 @@ class Interface {
public:
virtual void video_refresh(const uint16_t *data, bool hires, bool interlace, bool overscan) {}
virtual void audio_sample(uint16_t l_sample, uint16_t r_sample) {}
virtual void input_poll() {}
virtual int16_t input_poll(bool port, Input::Device device, unsigned index, unsigned id) { return 0; }
virtual void message(const string &text) { print(text, "\n"); }

View File

@ -1,7 +1,7 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "080.01";
static const char Version[] = "080.02";
static const unsigned SerializerVersion = 21;
}
}

View File

@ -103,7 +103,7 @@ bool Cartridge::loadCartridge(SNES::MappedRAM &memory, string &XML, const char *
if(file::exists(filename) == false) return false;
file fp;
if(fp.open(filename, file::mode::read) == false) return false;
if(XML.readfile(string(nall::basename(filename), ".xml")) == false) XML = "";
if(XML.readfile({ nall::basename(filename), ".xml" }) == false) XML = "";
unsigned size = fp.size();
uint8_t *data = new uint8_t[size];

View File

@ -47,7 +47,7 @@ void Console::write(const string &text, bool echo) {
OS::processEvents();
}
if(traceToFile.checked() && logfile.open()) {
logfile.print(string(text, "\n"));
logfile.print(text, "\n");
}
}

View File

@ -137,7 +137,7 @@ void FileBrowser::fileActivate() {
string FileBrowser::cartridgeFolder(const string &pathname) {
if(strend(pathname, ".sfc/") == false) return "";
lstring list = directory::files(string(folder, "/", pathname));
lstring list = directory::files({ folder, "/", pathname });
string filename;
foreach(item, list) {
if(strend(item, ".sfc")) {

View File

@ -129,9 +129,6 @@ void Interface::audio_sample(uint16_t left, uint16_t right) {
audio.sample(left, right);
}
void Interface::input_poll() {
}
int16_t Interface::input_poll(bool port, SNES::Input::Device device, unsigned index, unsigned id) {
if(config.settings.focusPolicy == 1 && mainWindow.focused() == false) return 0;
return inputMapper.poll(port, device, index, id);

View File

@ -17,7 +17,6 @@ struct Filter : public library {
struct Interface : public SNES::Interface {
void video_refresh(const uint16_t *data, bool hires, bool interlace, bool overscan);
void audio_sample(uint16_t left, uint16_t right);
void input_poll();
int16_t input_poll(bool port, SNES::Input::Device device, unsigned index, unsigned id);
void message(const string &text);

View File

@ -60,7 +60,7 @@ string Path::load(SNES::Cartridge::Slot slot, const string &hint) {
if(hint == ".sav" && sav != "") filePath = sav;
if(hint == ".rtc" && rtc != "") filePath = rtc;
if(hint.endswith(".dsp") && necdsp != "") filePath = necdsp;
if(hint.endswith(".dsp") && firmware != "") filePath = firmware;
if(hint.endswith(".msu") && msu1 != "") filePath = msu1;
if(hint.endswith(".pcm") && msu1 != "") filePath = msu1;
if(hint.endswith(".so") && serial != "") filePath = serial;
@ -115,21 +115,21 @@ string Path::decode(const string &filePath, const string &basePath) {
if(path.beginswith("user/")) {
path.ltrim<1>("user/");
#if defined(PLATFORM_X) || defined(PLATFORM_OSX)
path = string(user, ".config/bsnes/", path);
path = { user, ".config/bsnes/", path };
#else
path = string(user, "bsnes/", path);
path = { user, "bsnes/", path };
#endif
} else if(path.beginswith("base/")) {
path.ltrim<1>("base/");
path = string(base, path);
path = { base, path };
} else if(path.beginswith("./")) {
path.ltrim<1>("./");
path = string(dir(basePath), path);
path = { dir(basePath), path };
} else if(path.beginswith("../")) {
string base = dir(basePath);
base.rtrim<1>("/");
path.ltrim<1>("../");
path = string(dir(base), path);
path = { dir(base), path };
}
return path;
@ -153,7 +153,7 @@ Path::Path() {
attach(sufamiTurboBios = "", "sufamiTurboBios");
attach(superGameBoyBios = "", "superGameBoyBios");
attach(necdsp = "", "necdsp");
attach(firmware = "", "firmware");
attach(msu1 = "", "msu1");
attach(serial = "", "serial");

View File

@ -11,7 +11,7 @@ struct Path : public configuration {
string sufamiTurboBios;
string superGameBoyBios;
string necdsp;
string firmware;
string msu1;
string serial;

View File

@ -53,7 +53,7 @@ void CheatDatabase::findCodes() {
string description, code;
foreach(element, node.element) {
if(element.name == "description") description = element.parse();
else if(element.name == "code") code.append(string(element.parse(), "+"));
else if(element.name == "code") code.append(element.parse(), "+");
}
code.rtrim<1>("+");
code.append("\t");

View File

@ -26,7 +26,7 @@ void CheatEditor::load() {
}
foreach(element, node.element) {
if(element.name == "description") description = element.parse();
else if(element.name == "code") code.append(string(element.parse(), "+"));
else if(element.name == "code") code.append(element.parse(), "+");
}
code.rtrim("+");
SNES::cheat[n].enabled = enabled;
@ -59,16 +59,16 @@ void CheatEditor::save() {
file fp;
if(fp.open(path.load(utility.slotPath(), ".cht"), file::mode::write)) {
fp.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fp.print(string("<cartridge sha256=\"", SNES::cartridge.sha256(), "\">\n"));
fp.print("<cartridge sha256=\"", SNES::cartridge.sha256(), "\">\n");
for(unsigned i = 0; i <= lastSave; i++) {
fp.print(string(" <cheat enabled=\"", cheatList.checked(i), "\">\n"));
fp.print(string(" <description><![CDATA[", cheatText[i][CheatDesc], "]]></description>\n"));
fp.print(" <cheat enabled=\"", cheatList.checked(i), "\">\n");
fp.print(" <description><![CDATA[", cheatText[i][CheatDesc], "]]></description>\n");
lstring list;
list.split("+", cheatText[i][CheatCode]);
foreach(code, list) {
fp.print(string(" <code>", code, "</code>\n"));
fp.print(" <code>", code, "</code>\n");
}
fp.print(string(" </cheat>\n"));
fp.print(" </cheat>\n");
}
fp.print("</cartridge>\n");
fp.close();