Update to v072r12 release.

byuu says:

This release defaults DSP-3 loading to use the uPD77C25 core. It also
pre-emptively does the same for the DSP-2 and DSP-4. v072r11 did this
for the DSP-1.

I've also renamed my string<>integer conversion function names:

strhex -> hex
strsigned -> integer
strunsigned -> decimal
strbin -> binary
strdouble -> fp (this one will no doubt be trouble since 'file fp' is
    a common idiom. floatingpoint is too long, float and double are
    already reserved.)
This commit is contained in:
Tim Allen 2010-12-23 01:13:14 +11:00
parent 9762a092d2
commit a62aa94b65
31 changed files with 266 additions and 265 deletions

View File

@ -45,11 +45,11 @@ namespace nall {
void set(string s) {
switch(type) {
case boolean_t: *(bool*)data = (s == "true"); break;
case signed_t: *(signed*)data = strsigned(s); break;
case unsigned_t: *(unsigned*)data = strunsigned(s); break;
case double_t: *(double*)data = strdouble(s); break;
case string_t: s.trim("\""); *(string*)data = s; break;
case boolean_t: *(bool*)data = (s == "true"); break;
case signed_t: *(signed*)data = integer(s); break;
case unsigned_t: *(unsigned*)data = decimal(s); break;
case double_t: *(double*)data = fp(s); break;
case string_t: s.trim("\""); *(string*)data = s; break;
}
}
};

View File

@ -92,7 +92,7 @@ struct Keyboard {
string s(name);
if(!strbegin(name, "KB")) return 0;
s.ltrim("KB");
unsigned id = strunsigned(s);
unsigned id = decimal(s);
auto pos = strpos(s, "::");
if(!pos) return 0;
s = substr(s, pos() + 2);
@ -189,7 +189,7 @@ struct Mouse {
string s(name);
if(!strbegin(name, "MS")) return 0;
s.ltrim("MS");
unsigned id = strunsigned(s);
unsigned id = decimal(s);
auto pos = strpos(s, "::");
if(!pos) return 0;
s = substr(s, pos() + 2);
@ -313,7 +313,7 @@ struct Joypad {
string s(name);
if(!strbegin(name, "JP")) return 0;
s.ltrim("JP");
unsigned id = strunsigned(s);
unsigned id = decimal(s);
auto pos = strpos(s, "::");
if(!pos) return 0;
s = substr(s, pos() + 2);

View File

@ -125,7 +125,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
if(type == TypeGameBoy) {
xml << "<cartridge rtc='" << gameboy_has_rtc(data, size) << "'>\n";
if(gameboy_ram_size(data, size) > 0) {
xml << " <ram size='" << strhex(gameboy_ram_size(data, size)) << "'/>\n";
xml << " <ram size='" << hex(gameboy_ram_size(data, size)) << "'/>\n";
}
xml << "</cartridge>\n";
xmlMemoryMap = xml;
@ -171,9 +171,9 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " <spc7110>\n";
xml << " <mcu>\n";
xml << " <map address='d0-ff:0000-ffff' offset='100000' size='" << strhex(size - 0x100000) << "'/>\n";
xml << " <map address='d0-ff:0000-ffff' offset='100000' size='" << hex(size - 0x100000) << "'/>\n";
xml << " </mcu>\n";
xml << " <ram size='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << 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";
@ -198,7 +198,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " </rom>\n";
if(ram_size > 0) {
xml << " <ram size='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
@ -219,7 +219,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " </rom>\n";
if(ram_size > 0) {
xml << " <ram size='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
@ -237,7 +237,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " </rom>\n";
if(ram_size > 0) {
xml << " <ram size='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << 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";
@ -252,7 +252,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " </rom>\n";
if(ram_size > 0) {
xml << " <ram size='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
@ -270,7 +270,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
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='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='00-3f:6000-7fff' size='2000'/>\n";
xml << " <map mode='linear' address='60-7f:0000-ffff'/>\n";
xml << " <map mode='linear' address='80-bf:6000-7fff' size='2000'/>\n";
@ -292,7 +292,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
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='" << strhex(ram_size) << "'>\n";
xml << " <bwram size='" << hex(ram_size) << "'>\n";
xml << " <map mode='linear' address='00-3f:6000-7fff'/>\n";
xml << " <map mode='linear' address='40-4f:0000-ffff'/>\n";
xml << " <map mode='linear' address='80-bf:6000-7fff'/>\n";
@ -309,7 +309,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " <map mode='linear' address='80-9f:8000-ffff' offset='200000'/>\n";
xml << " <map mode='linear' address='a0-bf:8000-ffff' offset='100000'/>\n";
xml << " </rom>\n";
xml << " <ram size='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << 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";
@ -325,7 +325,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
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='" << strhex(ram_size) << "'>\n";
xml << " <ram size='" << 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";
@ -408,7 +408,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
}
if(has_dsp1) {
xml << " <upd77c25 program='dsp1b.bin'>\n";
xml << " <upd77c25 program='dsp1b.bin' sha256='d85ba8271a5b28a25e078d7f72722de1d6990a9f098a8d574c4338adcef883a6'>\n";
if(dsp1_mapper == DSP1LoROM1MB) {
xml << " <dr>\n";
xml << " <map address='20-3f:8000-bfff'/>\n";
@ -441,7 +441,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
}
if(has_dsp2) {
xml << " <necdsp program='DSP-2'>\n";
xml << " <upd77c25 program='dsp2.bin'>\n";
xml << " <dr>\n";
xml << " <map address='20-3f:8000-bfff'/>\n";
xml << " <map address='a0-bf:8000-bfff'/>\n";
@ -450,11 +450,11 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " <map address='20-3f:c000-ffff'/>\n";
xml << " <map address='a0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml << " </necdsp>\n";
xml << " </upd77c25>\n";
}
if(has_dsp3) {
xml << " <necdsp program='DSP-3'>\n";
xml << " <upd77c25 program='dsp3.bin' sha256='7044784484a0f9a869e5b03f685fa2bb5324d52a03716b9632c096206d51985b'>\n";
xml << " <dr>\n";
xml << " <map address='20-3f:8000-bfff'/>\n";
xml << " <map address='a0-bf:8000-bfff'/>\n";
@ -463,11 +463,11 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " <map address='20-3f:c000-ffff'/>\n";
xml << " <map address='a0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml << " </necdsp>\n";
xml << " </upd77c25>\n";
}
if(has_dsp4) {
xml << " <necdsp program='DSP-4'>\n";
xml << " <upd77c25 program='dsp4.bin'>\n";
xml << " <dr>\n";
xml << " <map address='30-3f:8000-bfff'/>\n";
xml << " <map address='b0-bf:8000-bfff'/>\n";
@ -476,7 +476,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " <map address='30-3f:c000-ffff'/>\n";
xml << " <map address='b0-bf:c000-ffff'/>\n";
xml << " </sr>\n";
xml << " </necdsp>\n";
xml << " </upd77c25>\n";
}
if(has_obc1) {

View File

@ -418,36 +418,36 @@ inline string SNESCPU::disassemble(unsigned pc, bool accum, bool index, uint8_t
unsigned mode = opcodeInfo[opcode].mode;
if(mode == Implied) return name;
if(mode == Constant) return { name, " #$", strhex<2>(pl) };
if(mode == AccumConstant) return { name, " #$", accum ? "" : strhex<2>(ph), strhex<2>(pl) };
if(mode == IndexConstant) return { name, " #$", index ? "" : strhex<2>(ph), strhex<2>(pl) };
if(mode == Direct) return { name, " $", strhex<2>(pl) };
if(mode == DirectX) return { name, " $", strhex<2>(pl), ",x" };
if(mode == DirectY) return { name, " $", strhex<2>(pl), ",y" };
if(mode == IDirect) return { name, " ($", strhex<2>(pl), ")" };
if(mode == IDirectX) return { name, " ($", strhex<2>(pl), ",x)" };
if(mode == IDirectY) return { name, " ($", strhex<2>(pl), "),y" };
if(mode == ILDirect) return { name, " [$", strhex<2>(pl), "]" };
if(mode == ILDirectY) return { name, " [$", strhex<2>(pl), "],y" };
if(mode == Address) return { name, " $", strhex<2>(ph), strhex<2>(pl) };
if(mode == AddressX) return { name, " $", strhex<2>(ph), strhex<2>(pl), ",x" };
if(mode == AddressY) return { name, " $", strhex<2>(ph), strhex<2>(pl), ",y" };
if(mode == IAddressX) return { name, " ($", strhex<2>(ph), strhex<2>(pl), ",x)" };
if(mode == ILAddress) return { name, " [$", strhex<2>(ph), strhex<2>(pl), "]" };
if(mode == PAddress) return { name, " $", strhex<2>(ph), strhex<2>(pl) };
if(mode == PIAddress) return { name, " ($", strhex<2>(ph), strhex<2>(pl), ")" };
if(mode == Long) return { name, " $", strhex<2>(pb), strhex<2>(ph), strhex<2>(pl) };
if(mode == LongX) return { name, " $", strhex<2>(pb), strhex<2>(ph), strhex<2>(pl), ",x" };
if(mode == Stack) return { name, " $", strhex<2>(pl), ",s" };
if(mode == IStackY) return { name, " ($", strhex<2>(pl), ",s),y" };
if(mode == BlockMove) return { name, " $", strhex<2>(ph), ",$", strhex<2>(pl) };
if(mode == Constant) return { name, " #$", hex<2>(pl) };
if(mode == AccumConstant) return { name, " #$", accum ? "" : hex<2>(ph), hex<2>(pl) };
if(mode == IndexConstant) return { name, " #$", index ? "" : hex<2>(ph), hex<2>(pl) };
if(mode == Direct) return { name, " $", hex<2>(pl) };
if(mode == DirectX) return { name, " $", hex<2>(pl), ",x" };
if(mode == DirectY) return { name, " $", hex<2>(pl), ",y" };
if(mode == IDirect) return { name, " ($", hex<2>(pl), ")" };
if(mode == IDirectX) return { name, " ($", hex<2>(pl), ",x)" };
if(mode == IDirectY) return { name, " ($", hex<2>(pl), "),y" };
if(mode == ILDirect) return { name, " [$", hex<2>(pl), "]" };
if(mode == ILDirectY) return { name, " [$", hex<2>(pl), "],y" };
if(mode == Address) return { name, " $", hex<2>(ph), hex<2>(pl) };
if(mode == AddressX) return { name, " $", hex<2>(ph), hex<2>(pl), ",x" };
if(mode == AddressY) return { name, " $", hex<2>(ph), hex<2>(pl), ",y" };
if(mode == IAddressX) return { name, " ($", hex<2>(ph), hex<2>(pl), ",x)" };
if(mode == ILAddress) return { name, " [$", hex<2>(ph), hex<2>(pl), "]" };
if(mode == PAddress) return { name, " $", hex<2>(ph), hex<2>(pl) };
if(mode == PIAddress) return { name, " ($", hex<2>(ph), hex<2>(pl), ")" };
if(mode == Long) return { name, " $", hex<2>(pb), hex<2>(ph), hex<2>(pl) };
if(mode == LongX) return { name, " $", hex<2>(pb), hex<2>(ph), hex<2>(pl), ",x" };
if(mode == Stack) return { name, " $", hex<2>(pl), ",s" };
if(mode == IStackY) return { name, " ($", hex<2>(pl), ",s),y" };
if(mode == BlockMove) return { name, " $", hex<2>(ph), ",$", hex<2>(pl) };
if(mode == RelativeShort) {
unsigned addr = (pc + 2) + (int8_t)(pl << 0);
return { name, " $", strhex<4>(addr) };
return { name, " $", hex<4>(addr) };
}
if(mode == RelativeLong) {
unsigned addr = (pc + 3) + (int16_t)((ph << 8) + (pl << 0));
return { name, " $", strhex<4>(addr) };
return { name, " $", hex<4>(addr) };
}
return "";

View File

@ -495,67 +495,67 @@ inline string SNESSMP::disassemble(uint16_t pc, uint8_t opcode, uint8_t pl, uint
if(mode == Implied) return name;
if(mode == TVector) return { name, " ", opcode >> 4 };
if(mode == Direct) return { name, " $", strhex<2>(pl) };
if(mode == DirectRelative) return { name, " $", strhex<2>(pl), ",$", strhex<4>(pc + 3 + (int8_t)ph) };
if(mode == ADirect) return { name, " a,$", strhex<2>(pl) };
if(mode == AAbsolute) return { name, " a,$", strhex<4>(pa) };
if(mode == Direct) return { name, " $", hex<2>(pl) };
if(mode == DirectRelative) return { name, " $", hex<2>(pl), ",$", hex<4>(pc + 3 + (int8_t)ph) };
if(mode == ADirect) return { name, " a,$", hex<2>(pl) };
if(mode == AAbsolute) return { name, " a,$", hex<4>(pa) };
if(mode == AIX) return { name, "a,(x)" };
if(mode == AIDirectX) return { name, " a,($", strhex<2>(pl), "+x)" };
if(mode == AConstant) return { name, " a,#$", strhex<2>(pl) };
if(mode == DirectDirect) return { name, " $", strhex<2>(ph), ",$", strhex<2>(pl) };
if(mode == CAbsoluteBit) return { name, " c,$", strhex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == Absolute) return { name, " $", strhex<4>(pa) };
if(mode == AIDirectX) return { name, " a,($", hex<2>(pl), "+x)" };
if(mode == AConstant) return { name, " a,#$", hex<2>(pl) };
if(mode == DirectDirect) return { name, " $", hex<2>(ph), ",$", hex<2>(pl) };
if(mode == CAbsoluteBit) return { name, " c,$", hex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == Absolute) return { name, " $", hex<4>(pa) };
if(mode == P) return { name, " p" };
if(mode == AbsoluteA) return { name, " $", strhex<4>(pa), ",a" };
if(mode == Relative) return { name, " $", strhex<4>(pc + 2 + (int8_t)pl) };
if(mode == ADirectX) return { name, " a,$", strhex<2>(pl), "+x" };
if(mode == AAbsoluteX) return { name, " a,$", strhex<4>(pa), "+x" };
if(mode == AAbsoluteY) return { name, " a,$", strhex<4>(pa), "+y" };
if(mode == AIDirectY) return { name, " a,($", strhex<2>(pl), ")+y" };
if(mode == DirectConstant) return { name, " $", strhex<2>(ph), ",#$", strhex<2>(pl) };
if(mode == AbsoluteA) return { name, " $", hex<4>(pa), ",a" };
if(mode == Relative) return { name, " $", hex<4>(pc + 2 + (int8_t)pl) };
if(mode == ADirectX) return { name, " a,$", hex<2>(pl), "+x" };
if(mode == AAbsoluteX) return { name, " a,$", hex<4>(pa), "+x" };
if(mode == AAbsoluteY) return { name, " a,$", hex<4>(pa), "+y" };
if(mode == AIDirectY) return { name, " a,($", hex<2>(pl), ")+y" };
if(mode == DirectConstant) return { name, " $", hex<2>(ph), ",#$", hex<2>(pl) };
if(mode == IXIY) return { name, " (x),(y)" };
if(mode == DirectX) return { name, " $", strhex<2>(pl), "+x" };
if(mode == DirectX) return { name, " $", hex<2>(pl), "+x" };
if(mode == A) return { name, " a" };
if(mode == X) return { name, " x" };
if(mode == XAbsolute) return { name, " x,$", strhex<4>(pa) };
if(mode == IAbsoluteX) return { name, " ($", strhex<4>(pa), "+x)" };
if(mode == CNAbsoluteBit) return { name, " c,!$", strhex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == XDirect) return { name, " x,$", strhex<2>(pl) };
if(mode == PVector) return { name, " $ff", strhex<2>(pl) };
if(mode == YaDirect) return { name, " ya,$", strhex<2>(pl) };
if(mode == XAbsolute) return { name, " x,$", hex<4>(pa) };
if(mode == IAbsoluteX) return { name, " ($", hex<4>(pa), "+x)" };
if(mode == CNAbsoluteBit) return { name, " c,!$", hex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == XDirect) return { name, " x,$", hex<2>(pl) };
if(mode == PVector) return { name, " $ff", hex<2>(pl) };
if(mode == YaDirect) return { name, " ya,$", hex<2>(pl) };
if(mode == XA) return { name, " x,a" };
if(mode == YAbsolute) return { name, " y,$", strhex<4>(pa) };
if(mode == YAbsolute) return { name, " y,$", hex<4>(pa) };
if(mode == Y) return { name, " y" };
if(mode == AX) return { name, " a,x" };
if(mode == YDirect) return { name, " y,$", strhex<2>(pl) };
if(mode == YConstant) return { name, " y,#$", strhex<2>(pl) };
if(mode == YDirect) return { name, " y,$", hex<2>(pl) };
if(mode == YConstant) return { name, " y,#$", hex<2>(pl) };
if(mode == XSp) return { name, " x,sp" };
if(mode == YaX) return { name, " ya,x" };
if(mode == IXPA) return { name, " (x)+,a" };
if(mode == SpX) return { name, " sp,x" };
if(mode == AIXP) return { name, " a,(x)+" };
if(mode == DirectA) return { name, " $", strhex<2>(pl), ",a" };
if(mode == DirectA) return { name, " $", hex<2>(pl), ",a" };
if(mode == IXA) return { name, " (x),a" };
if(mode == IDirectXA) return { name, " ($", strhex<2>(pl), "+x),a" };
if(mode == XConstant) return { name, " x,#$", strhex<2>(pl) };
if(mode == AbsoluteX) return { name, " $", strhex<4>(pa), ",x" };
if(mode == AbsoluteBitC) return { name, " $", strhex<4>(pa & 0x1fff), ":", pa >> 13, ",c" };
if(mode == DirectY) return { name, " $", strhex<2>(pl), ",y" };
if(mode == AbsoluteY) return { name, " $", strhex<4>(pa), ",y" };
if(mode == IDirectXA) return { name, " ($", hex<2>(pl), "+x),a" };
if(mode == XConstant) return { name, " x,#$", hex<2>(pl) };
if(mode == AbsoluteX) return { name, " $", hex<4>(pa), ",x" };
if(mode == AbsoluteBitC) return { name, " $", hex<4>(pa & 0x1fff), ":", pa >> 13, ",c" };
if(mode == DirectY) return { name, " $", hex<2>(pl), ",y" };
if(mode == AbsoluteY) return { name, " $", hex<4>(pa), ",y" };
if(mode == Ya) return { name, " ya" };
if(mode == DirectXA) return { name, " $", strhex<2>(pl), "+x,a" };
if(mode == AbsoluteXA) return { name, " $", strhex<4>(pa), "+x,a" };
if(mode == AbsoluteYA) return { name, " $", strhex<4>(pa), "+y,a" };
if(mode == IDirectYA) return { name, " ($", strhex<2>(pl), ")+y,a" };
if(mode == DirectYX) return { name, " $", strhex<2>(pl), "+y,x" };
if(mode == DirectYa) return { name, " $", strhex<2>(pl), ",ya" };
if(mode == DirectXY) return { name, " $", strhex<2>(pl), "+x,y" };
if(mode == DirectXA) return { name, " $", hex<2>(pl), "+x,a" };
if(mode == AbsoluteXA) return { name, " $", hex<4>(pa), "+x,a" };
if(mode == AbsoluteYA) return { name, " $", hex<4>(pa), "+y,a" };
if(mode == IDirectYA) return { name, " ($", hex<2>(pl), ")+y,a" };
if(mode == DirectYX) return { name, " $", hex<2>(pl), "+y,x" };
if(mode == DirectYa) return { name, " $", hex<2>(pl), ",ya" };
if(mode == DirectXY) return { name, " $", hex<2>(pl), "+x,y" };
if(mode == AY) return { name, " a,y" };
if(mode == DirectXRelative) return { name, " $", strhex<2>(pl), ",$", strhex<4>(pc + 3 + (int8_t)ph) };
if(mode == XDirectY) return { name, " x,$", strhex<2>(pl), "+y" };
if(mode == YDirectX) return { name, " y,$", strhex<2>(pl), "+x" };
if(mode == DirectXRelative) return { name, " $", hex<2>(pl), ",$", hex<4>(pc + 3 + (int8_t)ph) };
if(mode == XDirectY) return { name, " x,$", hex<2>(pl), "+y" };
if(mode == YDirectX) return { name, " y,$", hex<2>(pl), "+x" };
if(mode == YA) return { name, " y,a" };
if(mode == YRelative) return { name, " y,$", strhex<4>(pc + 2 + (int8_t)pl) };
if(mode == YRelative) return { name, " y,$", hex<4>(pc + 2 + (int8_t)pl) };
return "";
}
@ -569,67 +569,67 @@ inline string SNESSMP::disassemble(uint16_t pc, bool p, uint8_t opcode, uint8_t
if(mode == Implied) return name;
if(mode == TVector) return { name, " ", opcode >> 4 };
if(mode == Direct) return { name, " $", strhex<3>(pdl) };
if(mode == DirectRelative) return { name, " $", strhex<3>(pdl), ",$", strhex<4>(pc + 3 + (int8_t)ph) };
if(mode == ADirect) return { name, " a,$", strhex<3>(pdl) };
if(mode == AAbsolute) return { name, " a,$", strhex<4>(pa) };
if(mode == Direct) return { name, " $", hex<3>(pdl) };
if(mode == DirectRelative) return { name, " $", hex<3>(pdl), ",$", hex<4>(pc + 3 + (int8_t)ph) };
if(mode == ADirect) return { name, " a,$", hex<3>(pdl) };
if(mode == AAbsolute) return { name, " a,$", hex<4>(pa) };
if(mode == AIX) return { name, "a,(x)" };
if(mode == AIDirectX) return { name, " a,($", strhex<3>(pdl), "+x)" };
if(mode == AConstant) return { name, " a,#$", strhex<2>(pl) };
if(mode == DirectDirect) return { name, " $", strhex<3>(pdh), ",$", strhex<3>(pdl) };
if(mode == CAbsoluteBit) return { name, " c,$", strhex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == Absolute) return { name, " $", strhex<4>(pa) };
if(mode == AIDirectX) return { name, " a,($", hex<3>(pdl), "+x)" };
if(mode == AConstant) return { name, " a,#$", hex<2>(pl) };
if(mode == DirectDirect) return { name, " $", hex<3>(pdh), ",$", hex<3>(pdl) };
if(mode == CAbsoluteBit) return { name, " c,$", hex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == Absolute) return { name, " $", hex<4>(pa) };
if(mode == P) return { name, " p" };
if(mode == AbsoluteA) return { name, " $", strhex<4>(pa), ",a" };
if(mode == Relative) return { name, " $", strhex<4>(pc + 2 + (int8_t)pl) };
if(mode == ADirectX) return { name, " a,$", strhex<3>(pdl), "+x" };
if(mode == AAbsoluteX) return { name, " a,$", strhex<4>(pa), "+x" };
if(mode == AAbsoluteY) return { name, " a,$", strhex<4>(pa), "+y" };
if(mode == AIDirectY) return { name, " a,($", strhex<3>(pdl), ")+y" };
if(mode == DirectConstant) return { name, " $", strhex<3>(pdh), ",#$", strhex<2>(pl) };
if(mode == AbsoluteA) return { name, " $", hex<4>(pa), ",a" };
if(mode == Relative) return { name, " $", hex<4>(pc + 2 + (int8_t)pl) };
if(mode == ADirectX) return { name, " a,$", hex<3>(pdl), "+x" };
if(mode == AAbsoluteX) return { name, " a,$", hex<4>(pa), "+x" };
if(mode == AAbsoluteY) return { name, " a,$", hex<4>(pa), "+y" };
if(mode == AIDirectY) return { name, " a,($", hex<3>(pdl), ")+y" };
if(mode == DirectConstant) return { name, " $", hex<3>(pdh), ",#$", hex<2>(pl) };
if(mode == IXIY) return { name, " (x),(y)" };
if(mode == DirectX) return { name, " $", strhex<3>(pdl), "+x" };
if(mode == DirectX) return { name, " $", hex<3>(pdl), "+x" };
if(mode == A) return { name, " a" };
if(mode == X) return { name, " x" };
if(mode == XAbsolute) return { name, " x,$", strhex<4>(pa) };
if(mode == IAbsoluteX) return { name, " ($", strhex<4>(pa), "+x)" };
if(mode == CNAbsoluteBit) return { name, " c,!$", strhex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == XDirect) return { name, " x,$", strhex<3>(pdl) };
if(mode == PVector) return { name, " $ff", strhex<2>(pl) };
if(mode == YaDirect) return { name, " ya,$", strhex<3>(pdl) };
if(mode == XAbsolute) return { name, " x,$", hex<4>(pa) };
if(mode == IAbsoluteX) return { name, " ($", hex<4>(pa), "+x)" };
if(mode == CNAbsoluteBit) return { name, " c,!$", hex<4>(pa & 0x1fff), ":", pa >> 13 };
if(mode == XDirect) return { name, " x,$", hex<3>(pdl) };
if(mode == PVector) return { name, " $ff", hex<2>(pl) };
if(mode == YaDirect) return { name, " ya,$", hex<3>(pdl) };
if(mode == XA) return { name, " x,a" };
if(mode == YAbsolute) return { name, " y,$", strhex<4>(pa) };
if(mode == YAbsolute) return { name, " y,$", hex<4>(pa) };
if(mode == Y) return { name, " y" };
if(mode == AX) return { name, " a,x" };
if(mode == YDirect) return { name, " y,$", strhex<3>(pdl) };
if(mode == YConstant) return { name, " y,#$", strhex<2>(pl) };
if(mode == YDirect) return { name, " y,$", hex<3>(pdl) };
if(mode == YConstant) return { name, " y,#$", hex<2>(pl) };
if(mode == XSp) return { name, " x,sp" };
if(mode == YaX) return { name, " ya,x" };
if(mode == IXPA) return { name, " (x)+,a" };
if(mode == SpX) return { name, " sp,x" };
if(mode == AIXP) return { name, " a,(x)+" };
if(mode == DirectA) return { name, " $", strhex<3>(pdl), ",a" };
if(mode == DirectA) return { name, " $", hex<3>(pdl), ",a" };
if(mode == IXA) return { name, " (x),a" };
if(mode == IDirectXA) return { name, " ($", strhex<3>(pdl), "+x),a" };
if(mode == XConstant) return { name, " x,#$", strhex<2>(pl) };
if(mode == AbsoluteX) return { name, " $", strhex<4>(pa), ",x" };
if(mode == AbsoluteBitC) return { name, " $", strhex<4>(pa & 0x1fff), ":", pa >> 13, ",c" };
if(mode == DirectY) return { name, " $", strhex<3>(pdl), ",y" };
if(mode == AbsoluteY) return { name, " $", strhex<4>(pa), ",y" };
if(mode == IDirectXA) return { name, " ($", hex<3>(pdl), "+x),a" };
if(mode == XConstant) return { name, " x,#$", hex<2>(pl) };
if(mode == AbsoluteX) return { name, " $", hex<4>(pa), ",x" };
if(mode == AbsoluteBitC) return { name, " $", hex<4>(pa & 0x1fff), ":", pa >> 13, ",c" };
if(mode == DirectY) return { name, " $", hex<3>(pdl), ",y" };
if(mode == AbsoluteY) return { name, " $", hex<4>(pa), ",y" };
if(mode == Ya) return { name, " ya" };
if(mode == DirectXA) return { name, " $", strhex<3>(pdl), "+x,a" };
if(mode == AbsoluteXA) return { name, " $", strhex<4>(pa), "+x,a" };
if(mode == AbsoluteYA) return { name, " $", strhex<4>(pa), "+y,a" };
if(mode == IDirectYA) return { name, " ($", strhex<3>(pdl), ")+y,a" };
if(mode == DirectYX) return { name, " $", strhex<3>(pdl), "+y,x" };
if(mode == DirectYa) return { name, " $", strhex<3>(pdl), ",ya" };
if(mode == DirectXY) return { name, " $", strhex<3>(pdl), "+x,y" };
if(mode == DirectXA) return { name, " $", hex<3>(pdl), "+x,a" };
if(mode == AbsoluteXA) return { name, " $", hex<4>(pa), "+x,a" };
if(mode == AbsoluteYA) return { name, " $", hex<4>(pa), "+y,a" };
if(mode == IDirectYA) return { name, " ($", hex<3>(pdl), ")+y,a" };
if(mode == DirectYX) return { name, " $", hex<3>(pdl), "+y,x" };
if(mode == DirectYa) return { name, " $", hex<3>(pdl), ",ya" };
if(mode == DirectXY) return { name, " $", hex<3>(pdl), "+x,y" };
if(mode == AY) return { name, " a,y" };
if(mode == DirectXRelative) return { name, " $", strhex<3>(pdl), ",$", strhex<4>(pc + 3 + (int8_t)ph) };
if(mode == XDirectY) return { name, " x,$", strhex<3>(pdl), "+y" };
if(mode == YDirectX) return { name, " y,$", strhex<3>(pdl), "+x" };
if(mode == DirectXRelative) return { name, " $", hex<3>(pdl), ",$", hex<4>(pc + 3 + (int8_t)ph) };
if(mode == XDirectY) return { name, " x,$", hex<3>(pdl), "+y" };
if(mode == YDirectX) return { name, " y,$", hex<3>(pdl), "+x" };
if(mode == YA) return { name, " y,a" };
if(mode == YRelative) return { name, " y,$", strhex<4>(pc + 2 + (int8_t)pl) };
if(mode == YRelative) return { name, " y,$", hex<4>(pc + 2 + (int8_t)pl) };
return "";
}

View File

@ -113,11 +113,11 @@ namespace nall {
inline char* strlower(char *str);
inline char* strupper(char *str);
inline char* strtr(char *dest, const char *before, const char *after);
inline uintmax_t strhex (const char *str);
inline intmax_t strsigned (const char *str);
inline uintmax_t strunsigned(const char *str);
inline uintmax_t strbin (const char *str);
inline double strdouble (const char *str);
inline uintmax_t hex (const char *str);
inline intmax_t integer(const char *str);
inline uintmax_t decimal(const char *str);
inline uintmax_t binary (const char *str);
inline double fp (const char *str);
//math.hpp
inline bool strint (const char *str, int &result);
@ -145,12 +145,12 @@ namespace nall {
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);
template<unsigned length = 0, char padding = '0'> inline string strhex(uintmax_t value);
template<unsigned length = 0, char padding = '0'> inline string strsigned(intmax_t value);
template<unsigned length = 0, char padding = '0'> inline string strunsigned(uintmax_t value);
template<unsigned length = 0, char padding = '0'> inline string strbin(uintmax_t value);
inline unsigned strdouble(char *str, double value);
inline string strdouble(double value);
template<unsigned length = 0, char padding = '0'> inline string hex(uintmax_t value);
template<unsigned length = 0, char padding = '0'> inline string integer(intmax_t value);
template<unsigned length = 0, char padding = '0'> inline string decimal(uintmax_t value);
template<unsigned length = 0, char padding = '0'> inline string binary(uintmax_t value);
inline unsigned fp(char *str, double value);
inline string fp(double value);
//variadic.hpp
template<typename... Args> inline void print(Args&&... args);

View File

@ -5,9 +5,9 @@ namespace nall {
//this is needed, as C++0x does not support explicit template specialization inside classes
template<> inline string to_string<bool> (bool v) { return v ? "true" : "false"; }
template<> inline string to_string<signed int> (signed int v) { return strsigned(v); }
template<> inline string to_string<unsigned int> (unsigned int v) { return strunsigned(v); }
template<> inline string to_string<double> (double v) { return strdouble(v); }
template<> inline string to_string<signed int> (signed int v) { return integer(v); }
template<> inline string to_string<unsigned int> (unsigned int v) { return decimal(v); }
template<> inline string to_string<double> (double v) { return fp(v); }
template<> inline string to_string<char*> (char *v) { return v; }
template<> inline string to_string<const char*> (const char *v) { return v; }
template<> inline string to_string<string> (string v) { return v; }

View File

@ -40,7 +40,7 @@ char* strtr(char *dest, const char *before, const char *after) {
return dest;
}
uintmax_t strhex(const char *str) {
uintmax_t hex(const char *str) {
if(!str) return 0;
uintmax_t result = 0;
@ -60,7 +60,7 @@ uintmax_t strhex(const char *str) {
return result;
}
intmax_t strsigned(const char *str) {
intmax_t integer(const char *str) {
if(!str) return 0;
intmax_t result = 0;
bool negate = false;
@ -81,7 +81,7 @@ intmax_t strsigned(const char *str) {
return !negate ? result : -result;
}
uintmax_t strunsigned(const char *str) {
uintmax_t decimal(const char *str) {
if(!str) return 0;
uintmax_t result = 0;
@ -95,7 +95,7 @@ uintmax_t strunsigned(const char *str) {
return result;
}
uintmax_t strbin(const char *str) {
uintmax_t binary(const char *str) {
if(!str) return 0;
uintmax_t result = 0;
@ -113,7 +113,7 @@ uintmax_t strbin(const char *str) {
return result;
}
double strdouble(const char *str) {
double fp(const char *str) {
if(!str) return 0.0;
bool negate = false;

View File

@ -26,9 +26,9 @@ string& string::append(const char *s) {
}
string& string::append(bool value) { append(value ? "true" : "false"); return *this; }
string& string::append(signed int value) { append(strsigned(value)); return *this; }
string& string::append(unsigned int value) { append(strunsigned(value)); return *this; }
string& string::append(double value) { append(strdouble(value)); return *this; }
string& string::append(signed int value) { append(integer(value)); return *this; }
string& string::append(unsigned int value) { append(decimal(value)); return *this; }
string& string::append(double value) { append(fp(value)); return *this; }
string::operator const char*() const {
return data;

View File

@ -27,7 +27,7 @@ string substr(const char *src, unsigned start, unsigned length) {
/* arithmetic <> string */
template<unsigned length, char padding> string strhex(uintmax_t value) {
template<unsigned length, char padding> string hex(uintmax_t value) {
string output;
unsigned offset = 0;
@ -51,7 +51,7 @@ template<unsigned length, char padding> string strhex(uintmax_t value) {
return output;
}
template<unsigned length, char padding> string strsigned(intmax_t value) {
template<unsigned length, char padding> string integer(intmax_t value) {
string output;
unsigned offset = 0;
@ -77,7 +77,7 @@ template<unsigned length, char padding> string strsigned(intmax_t value) {
return output;
}
template<unsigned length, char padding> string strunsigned(uintmax_t value) {
template<unsigned length, char padding> string decimal(uintmax_t value) {
string output;
unsigned offset = 0;
@ -99,7 +99,7 @@ template<unsigned length, char padding> string strunsigned(uintmax_t value) {
return output;
}
template<unsigned length, char padding> string strbin(uintmax_t value) {
template<unsigned length, char padding> string binary(uintmax_t value) {
string output;
unsigned offset = 0;
@ -124,7 +124,7 @@ template<unsigned length, char padding> string strbin(uintmax_t value) {
//using sprintf is certainly not the most ideal method to convert
//a double to a string ... but attempting to parse a double by
//hand, digit-by-digit, results in subtle rounding errors.
unsigned strdouble(char *str, double value) {
unsigned fp(char *str, double value) {
char buffer[256];
sprintf(buffer, "%f", value);
@ -145,10 +145,10 @@ unsigned strdouble(char *str, double value) {
return length + 1;
}
string strdouble(double value) {
string fp(double value) {
string temp;
temp.reserve(strdouble(0, value));
strdouble(temp(), value);
temp.reserve(fp(0, value));
fp(temp(), value);
return temp;
}

View File

@ -80,7 +80,7 @@ void HexEditor::update() {
string output;
unsigned offset = hexEditor->offset;
for(unsigned row = 0; row < hexEditor->rows; row++) {
output.append(strhex<8>(offset));
output.append(hex<8>(offset));
output.append(" ");
string hexdata;
@ -88,7 +88,7 @@ void HexEditor::update() {
for(unsigned column = 0; column < hexEditor->columns; column++) {
if(offset < hexEditor->size) {
uint8_t data = onRead(offset++);
hexdata.append(strhex<2>(data));
hexdata.append(hex<2>(data));
hexdata.append(" ");
char buffer[2] = { data >= 0x20 && data <= 0x7e ? (char)data : '.', 0 };
ansidata.append(buffer);

View File

@ -14,7 +14,7 @@ static void ListBox_change(ListBox *self) {
}
static void ListBox_tick(GtkCellRendererToggle *cell, gchar *path_string, ListBox *self) {
unsigned index = strunsigned(path_string);
unsigned index = decimal(path_string);
self->setChecked(index, !self->checked(index));
if(self->onTick) self->onTick(index);
}

View File

@ -47,8 +47,8 @@ bool PPUDebugger::property(unsigned id, string &name, string &value) {
}
//internal
item("S-PPU1 MDR", string("0x", strhex<2>(regs.ppu1_mdr)));
item("S-PPU2 MDR", string("0x", strhex<2>(regs.ppu2_mdr)));
item("S-PPU1 MDR", string("0x", hex<2>(regs.ppu1_mdr)));
item("S-PPU2 MDR", string("0x", hex<2>(regs.ppu2_mdr)));
//$2100
item("$2100", "");
@ -59,11 +59,11 @@ bool PPUDebugger::property(unsigned id, string &name, string &value) {
item("$2101", "");
item("OAM Base Size", (unsigned)regs.oam_basesize);
item("OAM Name Select", (unsigned)regs.oam_nameselect);
item("OAM Name Base Address", string("0x", strhex<4>(regs.oam_tdaddr)));
item("OAM Name Base Address", string("0x", hex<4>(regs.oam_tdaddr)));
//$2102-$2103
item("$2102-$2103", "");
item("OAM Base Address", string("0x", strhex<4>(regs.oam_baseaddr)));
item("OAM Base Address", string("0x", hex<4>(regs.oam_baseaddr)));
item("OAM Priority", regs.oam_priority);
//$2105
@ -87,33 +87,33 @@ bool PPUDebugger::property(unsigned id, string &name, string &value) {
//$2107
item("$2107", "");
item("BG1 Screen Address", string("0x", strhex<4>(regs.bg_scaddr[BG1])));
item("BG1 Screen Address", string("0x", hex<4>(regs.bg_scaddr[BG1])));
item("BG1 Screen Size", screen_size[regs.bg_scsize[BG1]]);
//$2108
item("$2108", "");
item("BG2 Screen Address", string("0x", strhex<4>(regs.bg_scaddr[BG2])));
item("BG2 Screen Address", string("0x", hex<4>(regs.bg_scaddr[BG2])));
item("BG2 Screen Size", screen_size[regs.bg_scsize[BG2]]);
//$2109
item("$2109", "");
item("BG3 Screen Address", string("0x", strhex<4>(regs.bg_scaddr[BG3])));
item("BG3 Screen Address", string("0x", hex<4>(regs.bg_scaddr[BG3])));
item("BG3 Screen Size", screen_size[regs.bg_scsize[BG3]]);
//$210a
item("$210a", "");
item("BG4 Screen Address", string("0x", strhex<4>(regs.bg_scaddr[BG4])));
item("BG4 Screen Address", string("0x", hex<4>(regs.bg_scaddr[BG4])));
item("BG4 Screen Size", screen_size[regs.bg_scsize[BG4]]);
//$210b
item("$210b", "");
item("BG1 Name Base Address", string("0x", strhex<4>(regs.bg_tdaddr[BG1])));
item("BG2 Name Base Address", string("0x", strhex<4>(regs.bg_tdaddr[BG2])));
item("BG1 Name Base Address", string("0x", hex<4>(regs.bg_tdaddr[BG1])));
item("BG2 Name Base Address", string("0x", hex<4>(regs.bg_tdaddr[BG2])));
//$210c
item("$210c", "");
item("BG3 Name Base Address", string("0x", strhex<4>(regs.bg_tdaddr[BG3])));
item("BG4 Name Base Address", string("0x", strhex<4>(regs.bg_tdaddr[BG4])));
item("BG3 Name Base Address", string("0x", hex<4>(regs.bg_tdaddr[BG3])));
item("BG4 Name Base Address", string("0x", hex<4>(regs.bg_tdaddr[BG4])));
//$210d
item("$210d", "");
@ -157,7 +157,7 @@ bool PPUDebugger::property(unsigned id, string &name, string &value) {
//$2116-$2117
item("$2116-$2117", "");
item("VRAM Address", string("0x", strhex<4>(regs.vram_addr)));
item("VRAM Address", string("0x", hex<4>(regs.vram_addr)));
//$211a
item("$211a", "");
@ -191,7 +191,7 @@ bool PPUDebugger::property(unsigned id, string &name, string &value) {
//$2121
item("$2121", "");
item("CGRAM Address", string("0x", strhex<4>(regs.cgram_addr)));
item("CGRAM Address", string("0x", hex<4>(regs.cgram_addr)));
//$2123
item("$2123", "");

View File

@ -49,6 +49,7 @@ void Cartridge::load(Mode cartridge_mode, const lstring &xml_list) {
has_serial = false;
parse_xml(xml_list);
//print(xml_list[0], "\n");
if(ram_size > 0) {
memory::cartram.map(allocate<uint8_t>(ram_size, 0xff), ram_size);
@ -104,7 +105,7 @@ void Cartridge::load(Mode cartridge_mode, const lstring &xml_list) {
sha256_hash(&sha, shahash);
string hash;
foreach(n, shahash) hash << strhex<2>(n);
foreach(n, shahash) hash << hex<2>(n);
sha256 = hash;
bus.load_cart();

View File

@ -75,7 +75,7 @@ void Cartridge::parse_xml_gameboy(const char *data) {
if(leaf.name == "ram") {
foreach(attr, leaf.attribute) {
if(attr.name == "size") {
supergameboy_ram_size = strhex(attr.content);
supergameboy_ram_size = hex(attr.content);
}
}
}
@ -91,8 +91,8 @@ void Cartridge::xml_parse_rom(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -101,7 +101,7 @@ void Cartridge::xml_parse_rom(xml_element &root) {
void Cartridge::xml_parse_ram(xml_element &root) {
foreach(attr, root.attribute) {
if(attr.name == "size") ram_size = strhex(attr.content);
if(attr.name == "size") ram_size = hex(attr.content);
}
foreach(leaf, root.element) {
@ -110,8 +110,8 @@ void Cartridge::xml_parse_ram(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -129,15 +129,15 @@ void Cartridge::xml_parse_superfx(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
}
} else if(node.name == "ram") {
foreach(attr, node.attribute) {
if(attr.name == "size") ram_size = strhex(attr.content);
if(attr.name == "size") ram_size = hex(attr.content);
}
foreach(leaf, node.element) {
@ -146,8 +146,8 @@ void Cartridge::xml_parse_superfx(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -177,8 +177,8 @@ void Cartridge::xml_parse_sa1(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -190,15 +190,15 @@ void Cartridge::xml_parse_sa1(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
}
} else if(node.name == "bwram") {
foreach(attr, node.attribute) {
if(attr.name == "size") ram_size = strhex(attr.content);
if(attr.name == "size") ram_size = hex(attr.content);
}
foreach(leaf, node.element) {
@ -207,8 +207,8 @@ void Cartridge::xml_parse_sa1(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -281,8 +281,8 @@ void Cartridge::xml_parse_bsx(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -322,8 +322,8 @@ void Cartridge::xml_parse_sufamiturbo(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
if(m.memory->size() > 0) mapping.append(m);
}
@ -335,8 +335,8 @@ void Cartridge::xml_parse_sufamiturbo(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
if(m.memory->size() > 0) mapping.append(m);
}
@ -438,7 +438,7 @@ void Cartridge::xml_parse_spc7110(xml_element &root) {
Mapping m(spc7110mcu);
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "offset") spc7110_data_rom_offset = strhex(attr.content);
if(attr.name == "offset") spc7110_data_rom_offset = hex(attr.content);
}
mapping.append(m);
}
@ -455,7 +455,7 @@ void Cartridge::xml_parse_spc7110(xml_element &root) {
}
} else if(node.name == "ram") {
foreach(attr, node.attribute) {
if(attr.name == "size") ram_size = strhex(attr.content);
if(attr.name == "size") ram_size = hex(attr.content);
}
foreach(leaf, node.element) {
@ -464,8 +464,8 @@ void Cartridge::xml_parse_spc7110(xml_element &root) {
foreach(attr, leaf.attribute) {
if(attr.name == "address") xml_parse_address(m, attr.content);
if(attr.name == "mode") xml_parse_mode(m, attr.content);
if(attr.name == "offset") m.offset = strhex(attr.content);
if(attr.name == "size") m.size = strhex(attr.content);
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
mapping.append(m);
}
@ -662,20 +662,20 @@ void Cartridge::xml_parse_address(Mapping &m, const string &data) {
lstring subpart;
subpart.split("-", part[0]);
if(subpart.size() == 1) {
m.banklo = strhex(subpart[0]);
m.banklo = hex(subpart[0]);
m.bankhi = m.banklo;
} else if(subpart.size() == 2) {
m.banklo = strhex(subpart[0]);
m.bankhi = strhex(subpart[1]);
m.banklo = hex(subpart[0]);
m.bankhi = hex(subpart[1]);
}
subpart.split("-", part[1]);
if(subpart.size() == 1) {
m.addrlo = strhex(subpart[0]);
m.addrlo = hex(subpart[0]);
m.addrhi = m.addrlo;
} else if(subpart.size() == 2) {
m.addrlo = strhex(subpart[0]);
m.addrhi = strhex(subpart[1]);
m.addrlo = hex(subpart[0]);
m.addrhi = hex(subpart[1]);
}
}

View File

@ -84,7 +84,7 @@ bool Cheat::decode(const char *s, unsigned &addr, uint8 &data, Type &type) {
for(unsigned i = 0; i < 8; i++) if(!ischr(t[i])) return false;
type = Type::ProActionReplay;
unsigned r = strhex((const char*)t);
unsigned r = hex((const char*)t);
addr = r >> 8;
data = r & 0xff;
return true;
@ -96,7 +96,7 @@ bool Cheat::decode(const char *s, unsigned &addr, uint8 &data, Type &type) {
type = Type::GameGenie;
t.transform("df4709156bc8a23e", "0123456789abcdef");
unsigned r = strhex((const char*)t);
unsigned r = hex((const char*)t);
//8421 8421 8421 8421 8421 8421
//abcd efgh ijkl mnop qrst uvwx
//ijkl qrst opab cduv wxef ghmn
@ -125,7 +125,7 @@ bool Cheat::encode(string &s, unsigned addr, uint8 data, Type type) {
char t[16];
if(type == Type::ProActionReplay) {
s = string(strhex<6>(addr), strhex<2>(data));
s = string(hex<6>(addr), hex<2>(data));
return true;
} else if(type == Type::GameGenie) {
unsigned r = addr;
@ -141,7 +141,7 @@ bool Cheat::encode(string &s, unsigned addr, uint8 data, Type type) {
| (!!(r & 0x080000) << 5) | (!!(r & 0x040000) << 4)
| (!!(r & 0x020000) << 3) | (!!(r & 0x010000) << 2)
| (!!(r & 0x000800) << 1) | (!!(r & 0x000400) << 0);
s = string(strhex<2>(data), strhex<2>(addr >> 16), "-", strhex<4>(addr & 0xffff));
s = string(hex<2>(data), hex<2>(addr >> 16), "-", hex<4>(addr & 0xffff));
s.transform("0123456789abcdef", "df4709156bc8a23e");
return true;
} else {

View File

@ -1,5 +1,5 @@
string UPD77C25::disassemble(uint11 ip) {
string output = { strhex<3>(ip), " " };
string output = { hex<3>(ip), " " };
uint24 opcode = programROM[ip];
uint2 type = opcode >> 22;
@ -171,7 +171,7 @@ string UPD77C25::disassemble(uint11 ip) {
default: output << "?????? "; break;
}
output << "$" << strhex<3>(na);
output << "$" << hex<3>(na);
}
if(type == 3) { //LD
@ -179,7 +179,7 @@ string UPD77C25::disassemble(uint11 ip) {
uint16 id = opcode >> 6;
uint4 dst = opcode >> 0;
output << "$" << strhex<4>(id) << ",";
output << "$" << hex<4>(id) << ",";
switch(dst) {
case 0: output << "non"; break;

View File

@ -56,11 +56,11 @@ bool CPUDebugger::property(unsigned id, string &name, string &value) {
}
//internal
item("S-CPU MDR", string("0x", strhex<2>(regs.mdr)));
item("S-CPU MDR", string("0x", hex<2>(regs.mdr)));
//$2181-2183
item("$2181-$2183", "");
item("WRAM Address", string("0x", strhex<6>(status.wram_addr)));
item("WRAM Address", string("0x", hex<6>(status.wram_addr)));
//$4016
item("$4016", "");
@ -75,45 +75,45 @@ bool CPUDebugger::property(unsigned id, string &name, string &value) {
//$4201
item("$4201", "");
item("PIO", string("0x", strhex<2>(status.pio)));
item("PIO", string("0x", hex<2>(status.pio)));
//$4202
item("$4202", "");
item("Multiplicand", string("0x", strhex<2>(status.wrmpya)));
item("Multiplicand", string("0x", hex<2>(status.wrmpya)));
//$4203
item("$4203", "");
item("Multiplier", string("0x", strhex<2>(status.wrmpyb)));
item("Multiplier", string("0x", hex<2>(status.wrmpyb)));
//$4204-$4205
item("$4204-$4205", "");
item("Dividend", string("0x", strhex<4>(status.wrdiva)));
item("Dividend", string("0x", hex<4>(status.wrdiva)));
//$4206
item("$4206", "");
item("Divisor", string("0x", strhex<2>(status.wrdivb)));
item("Divisor", string("0x", hex<2>(status.wrdivb)));
//$4207-$4208
item("$4207-$4208", "");
item("H-Time", string("0x", strhex<4>(status.hirq_pos)));
item("H-Time", string("0x", hex<4>(status.hirq_pos)));
//$4209-$420a
item("$4209-$420a", "");
item("V-Time", string("0x", strhex<4>(status.virq_pos)));
item("V-Time", string("0x", hex<4>(status.virq_pos)));
//$420b
unsigned dma_enable = 0;
for(unsigned n = 0; n < 8; n++) dma_enable |= channel[n].dma_enabled << n;
item("$420b", "");
item("DMA Enable", string("0x", strhex<2>(dma_enable)));
item("DMA Enable", string("0x", hex<2>(dma_enable)));
//$420c
unsigned hdma_enable = 0;
for(unsigned n = 0; n < 8; n++) hdma_enable |= channel[n].hdma_enabled << n;
item("$420c", "");
item("HDMA Enable", string("0x", strhex<2>(hdma_enable)));
item("HDMA Enable", string("0x", hex<2>(hdma_enable)));
//$420d
item("$420d", "");
@ -130,25 +130,25 @@ bool CPUDebugger::property(unsigned id, string &name, string &value) {
item("Transfer Mode", (unsigned)channel[i].transfer_mode);
//$43x1
item("B-Bus Address", string("0x", strhex<4>(channel[i].dest_addr)));
item("B-Bus Address", string("0x", hex<4>(channel[i].dest_addr)));
//$43x2-$43x3
item("A-Bus Address", string("0x", strhex<4>(channel[i].source_addr)));
item("A-Bus Address", string("0x", hex<4>(channel[i].source_addr)));
//$43x4
item("A-Bus Bank", string("0x", strhex<2>(channel[i].source_bank)));
item("A-Bus Bank", string("0x", hex<2>(channel[i].source_bank)));
//$43x5-$43x6
item("Transfer Size / Indirect Address", string("0x", strhex<4>(channel[i].transfer_size)));
item("Transfer Size / Indirect Address", string("0x", hex<4>(channel[i].transfer_size)));
//$43x7
item("Indirect Bank", string("0x", strhex<2>(channel[i].indirect_bank)));
item("Indirect Bank", string("0x", hex<2>(channel[i].indirect_bank)));
//$43x8-$43x9
item("Table Address", string("0x", strhex<4>(channel[i].hdma_addr)));
item("Table Address", string("0x", hex<4>(channel[i].hdma_addr)));
//$43xa
item("Line Counter", string("0x", strhex<2>(channel[i].line_counter)));
item("Line Counter", string("0x", hex<2>(channel[i].line_counter)));
}
#undef item

View File

@ -68,7 +68,7 @@ bool SMPDebugger::property(unsigned id, string &name, string &value) {
//$00f2
item("$00f2", "");
item("DSP Address", string("0x", strhex<2>(status.dsp_addr)));
item("DSP Address", string("0x", hex<2>(status.dsp_addr)));
#undef item
return false;

View File

@ -1,12 +1,12 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "072.11";
static const char Version[] = "072.12";
static const unsigned SerializerVersion = 14;
}
}
//#define DEBUGGER
#define DEBUGGER
#define CHEAT_SYSTEM
#include <libco/libco.h>

View File

@ -75,7 +75,7 @@ void CPUDebugger::refreshDisassembly() {
buffer.append("...\n");
} else {
unsigned addr = offset[n];
buffer.append(strhex<6>(addr));
buffer.append(hex<6>(addr));
buffer.append(" ");
string text = SNESCPU::disassemble(
addr, usage[addr] & 2, usage[addr] & 1,

View File

@ -75,7 +75,7 @@ void SMPDebugger::refreshDisassembly() {
buffer.append("...\n");
} else {
uint16_t addr = offset[n];
buffer.append(strhex<4>(addr));
buffer.append(hex<4>(addr));
buffer.append(" ");
string text = SNESSMP::disassemble(
addr, read(addr + 0), read(addr + 1), read(addr + 2)

View File

@ -37,8 +37,8 @@ void BreakpointEditor::toggleBreakpoint(unsigned n) {
SNES::debugger.breakpoint[n].enabled = false;
} else {
SNES::debugger.breakpoint[n].enabled = true;
SNES::debugger.breakpoint[n].addr = strhex(addressBox[n].text());
SNES::debugger.breakpoint[n].data = strhex(valueBox[n].text());
SNES::debugger.breakpoint[n].addr = hex(addressBox[n].text());
SNES::debugger.breakpoint[n].data = hex(valueBox[n].text());
if(valueBox[n].text() == "") SNES::debugger.breakpoint[n].data = -1; //break on any value
SNES::debugger.breakpoint[n].mode = (SNES::Debugger::Breakpoint::Mode)typeBox[n].selection();
SNES::debugger.breakpoint[n].source = (SNES::Debugger::Breakpoint::Source)sourceBox[n].selection();

View File

@ -42,7 +42,7 @@ void MemoryEditor::create() {
};
gotoBox.onChange = []() {
unsigned addr = strhex(memoryEditor.gotoBox.text());
unsigned addr = hex(memoryEditor.gotoBox.text());
memoryEditor.editor.setOffset(addr % memoryEditor.size);
memoryEditor.editor.update();
};

View File

@ -151,7 +151,7 @@ void Application::loadGeometry() {
lstring position;
position.split(",", window->position);
Geometry geom = window->geometry();
window->setGeometry(strunsigned(position[0]), strunsigned(position[1]), geom.width, geom.height);
window->setGeometry(decimal(position[0]), decimal(position[1]), geom.width, geom.height);
}
}

View File

@ -5,7 +5,7 @@ void CheatEditor::load(string filename) {
cheatList.reset();
for(unsigned i = 0; i < 128; i++) {
cheatList.addItem("");
cheatText[i][CheatSlot] = strunsigned<3, ' '>(i + 1);
cheatText[i][CheatSlot] = decimal<3, ' '>(i + 1);
cheatText[i][CheatCode] = "";
cheatText[i][CheatDesc] = "";
}

View File

@ -41,7 +41,7 @@ void StateManager::synchronize() {
void StateManager::refresh() {
for(unsigned i = 0; i < 32; i++) {
stateList.setItem(i, {
strunsigned<2, ' '>(i + 1), "\t",
decimal<2, ' '>(i + 1), "\t",
slotLoadDescription(i)
});
}

View File

@ -40,8 +40,8 @@ void BreakpointItem::toggle() {
if(state) {
SNES::debugger.breakpoint[id].enabled = true;
SNES::debugger.breakpoint[id].addr = strhex(addr->text().toUtf8().data()) & 0xffffff;
SNES::debugger.breakpoint[id].data = strhex(data->text().toUtf8().data()) & 0xff;
SNES::debugger.breakpoint[id].addr = hex(addr->text().toUtf8().data()) & 0xffffff;
SNES::debugger.breakpoint[id].data = hex(data->text().toUtf8().data()) & 0xff;
if(data->text().length() == 0) SNES::debugger.breakpoint[id].data = -1;
SNES::debugger.breakpoint[id].mode = (SNES::Debugger::Breakpoint::Mode)mode->currentIndex();
SNES::debugger.breakpoint[id].source = (SNES::Debugger::Breakpoint::Source)source->currentIndex();

View File

@ -99,7 +99,7 @@ void MemoryEditor::sourceChanged(int index) {
case 4: memorySource = SNES::Debugger::MemorySource::CGRAM; editor->setSize(512); break;
}
editor->setOffset(strhex(addr->text().toUtf8().data()));
editor->setOffset(hex(addr->text().toUtf8().data()));
editor->refresh();
}
@ -112,7 +112,7 @@ void MemoryEditor::refresh() {
}
void MemoryEditor::updateOffset() {
editor->setOffset(strhex(addr->text().toUtf8().data()));
editor->setOffset(hex(addr->text().toUtf8().data()));
refresh();
}

View File

@ -110,7 +110,7 @@ void CheatEditorWindow::load(const char *filename) {
auto item = new QTreeWidgetItem(list);
item->setData(0, Qt::UserRole, QVariant(i));
item->setText(0, strunsigned<3, ' '>(i + 1));
item->setText(0, decimal<3, ' '>(i + 1));
item->setCheckState(0, part[0] == "enabled" ? Qt::Checked : Qt::Unchecked);
item->setText(1, part[1]);
item->setText(2, part[2]);

View File

@ -143,9 +143,9 @@ void CheatFinderWindow::searchMemory() {
string text = valueEdit->text().toUtf8().constData();
//auto-detect input data type
if(strbegin(text, "0x")) data = strhex((const char*)text + 2);
else if(strbegin(text, "-")) data = strsigned(text);
else data = strunsigned(text);
if(strbegin(text, "0x")) data = hex((const char*)text + 2);
else if(strbegin(text, "-")) data = integer(text);
else data = decimal(text);
if(addrList.size() == 0) {
//search for the first time: enqueue all possible values so they are all searched