2010-08-09 13:28:56 +00:00
|
|
|
//Memory
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
auto Memory::size() const -> uint { return 0; }
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
//StaticRAM
|
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
StaticRAM::StaticRAM(uint size) : _size(size) { _data = new uint8[_size]; }
|
|
|
|
StaticRAM::~StaticRAM() { delete[] _data; }
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto StaticRAM::data() -> uint8* { return _data; }
|
|
|
|
auto StaticRAM::size() const -> uint { return _size; }
|
Update to v094r39 release.
byuu says:
Changelog:
- SNES mid-scanline BGMODE fixes finally merged (can run
atx2.zip{mode7.smc}+mtest(2).sfc properly now)
- Makefile now discards all built-in rules and variables
- switch on bool warning disabled for GCC now as well (was already
disabled for Clang)
- when loading a game, if any required files are missing, display
a warning message box (manifest.bml, program.rom, bios.rom, etc)
- when loading a game (or a game slot), if manifest.bml is missing, it
will invoke icarus to try and generate it
- if that fails (icarus is missing or the folder is bad), you will get
a warning telling you that the manifest can't be loaded
The warning prompt on missing files work for both games and the .sys
folders and their files. For some reason, failing to load the DMG/CGB
BIOS is causing a crash before I can display the modal dialog. I have no
idea why, and the stack frame backtrace is junk.
I also can't seem to abort the failed loading process. If I call
Program::unloadMedia(), I get a nasty segfault. Again with a really
nasty stack trace. So for now, it'll just end up sitting there emulating
an empty ROM (solid black screen.) In time, I'd like to fix that too.
Lastly, I need a better method than popen for Windows. popen is kind of
ugly and flashes a console window for a brief second even if the
application launched is linked with -mwindows. Not sure if there even is
one (I need to read the stdout result, so CreateProcess may not work
unless I do something nasty like "> %tmp%/temp") I'm also using the
regular popen instead of _wpopen, so for this WIP, it won't work if your
game folder has non-English letters in the path.
2015-08-04 09:00:55 +00:00
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto StaticRAM::read(uint24 addr, uint8) -> uint8 { return _data[addr]; }
|
|
|
|
auto StaticRAM::write(uint24 addr, uint8 data) -> void { _data[addr] = data; }
|
|
|
|
auto StaticRAM::operator[](uint24 addr) -> uint8& { return _data[addr]; }
|
|
|
|
auto StaticRAM::operator[](uint24 addr) const -> const uint8& { return _data[addr]; }
|
Update to v094r39 release.
byuu says:
Changelog:
- SNES mid-scanline BGMODE fixes finally merged (can run
atx2.zip{mode7.smc}+mtest(2).sfc properly now)
- Makefile now discards all built-in rules and variables
- switch on bool warning disabled for GCC now as well (was already
disabled for Clang)
- when loading a game, if any required files are missing, display
a warning message box (manifest.bml, program.rom, bios.rom, etc)
- when loading a game (or a game slot), if manifest.bml is missing, it
will invoke icarus to try and generate it
- if that fails (icarus is missing or the folder is bad), you will get
a warning telling you that the manifest can't be loaded
The warning prompt on missing files work for both games and the .sys
folders and their files. For some reason, failing to load the DMG/CGB
BIOS is causing a crash before I can display the modal dialog. I have no
idea why, and the stack frame backtrace is junk.
I also can't seem to abort the failed loading process. If I call
Program::unloadMedia(), I get a nasty segfault. Again with a really
nasty stack trace. So for now, it'll just end up sitting there emulating
an empty ROM (solid black screen.) In time, I'd like to fix that too.
Lastly, I need a better method than popen for Windows. popen is kind of
ugly and flashes a console window for a brief second even if the
application launched is linked with -mwindows. Not sure if there even is
one (I need to read the stdout result, so CreateProcess may not work
unless I do something nasty like "> %tmp%/temp") I'm also using the
regular popen instead of _wpopen, so for this WIP, it won't work if your
game folder has non-English letters in the path.
2015-08-04 09:00:55 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
//MappedRAM
|
|
|
|
|
Update to v094r39 release.
byuu says:
Changelog:
- SNES mid-scanline BGMODE fixes finally merged (can run
atx2.zip{mode7.smc}+mtest(2).sfc properly now)
- Makefile now discards all built-in rules and variables
- switch on bool warning disabled for GCC now as well (was already
disabled for Clang)
- when loading a game, if any required files are missing, display
a warning message box (manifest.bml, program.rom, bios.rom, etc)
- when loading a game (or a game slot), if manifest.bml is missing, it
will invoke icarus to try and generate it
- if that fails (icarus is missing or the folder is bad), you will get
a warning telling you that the manifest can't be loaded
The warning prompt on missing files work for both games and the .sys
folders and their files. For some reason, failing to load the DMG/CGB
BIOS is causing a crash before I can display the modal dialog. I have no
idea why, and the stack frame backtrace is junk.
I also can't seem to abort the failed loading process. If I call
Program::unloadMedia(), I get a nasty segfault. Again with a really
nasty stack trace. So for now, it'll just end up sitting there emulating
an empty ROM (solid black screen.) In time, I'd like to fix that too.
Lastly, I need a better method than popen for Windows. popen is kind of
ugly and flashes a console window for a brief second even if the
application launched is linked with -mwindows. Not sure if there even is
one (I need to read the stdout result, so CreateProcess may not work
unless I do something nasty like "> %tmp%/temp") I'm also using the
regular popen instead of _wpopen, so for this WIP, it won't work if your
game folder has non-English letters in the path.
2015-08-04 09:00:55 +00:00
|
|
|
auto MappedRAM::reset() -> void {
|
2016-06-17 13:03:54 +00:00
|
|
|
delete[] _data;
|
|
|
|
_data = nullptr;
|
|
|
|
_size = 0;
|
|
|
|
_writeProtect = false;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
auto MappedRAM::map(uint8* source, uint length) -> void {
|
2010-08-09 13:28:56 +00:00
|
|
|
reset();
|
2016-06-17 13:03:54 +00:00
|
|
|
_data = source;
|
|
|
|
_size = _data ? length : 0;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
Update to v094r39 release.
byuu says:
Changelog:
- SNES mid-scanline BGMODE fixes finally merged (can run
atx2.zip{mode7.smc}+mtest(2).sfc properly now)
- Makefile now discards all built-in rules and variables
- switch on bool warning disabled for GCC now as well (was already
disabled for Clang)
- when loading a game, if any required files are missing, display
a warning message box (manifest.bml, program.rom, bios.rom, etc)
- when loading a game (or a game slot), if manifest.bml is missing, it
will invoke icarus to try and generate it
- if that fails (icarus is missing or the folder is bad), you will get
a warning telling you that the manifest can't be loaded
The warning prompt on missing files work for both games and the .sys
folders and their files. For some reason, failing to load the DMG/CGB
BIOS is causing a crash before I can display the modal dialog. I have no
idea why, and the stack frame backtrace is junk.
I also can't seem to abort the failed loading process. If I call
Program::unloadMedia(), I get a nasty segfault. Again with a really
nasty stack trace. So for now, it'll just end up sitting there emulating
an empty ROM (solid black screen.) In time, I'd like to fix that too.
Lastly, I need a better method than popen for Windows. popen is kind of
ugly and flashes a console window for a brief second even if the
application launched is linked with -mwindows. Not sure if there even is
one (I need to read the stdout result, so CreateProcess may not work
unless I do something nasty like "> %tmp%/temp") I'm also using the
regular popen instead of _wpopen, so for this WIP, it won't work if your
game folder has non-English letters in the path.
2015-08-04 09:00:55 +00:00
|
|
|
auto MappedRAM::copy(const stream& memory) -> void {
|
2016-06-17 13:03:54 +00:00
|
|
|
if(_data) delete[] _data;
|
2012-04-29 06:16:44 +00:00
|
|
|
//round size up to multiple of 256-bytes
|
2016-06-17 13:03:54 +00:00
|
|
|
_size = (memory.size() & ~255) + ((bool)(memory.size() & 255) << 8);
|
|
|
|
_data = new uint8[_size]();
|
|
|
|
memory.read((uint8_t*)_data, memory.size());
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
Update to v094r39 release.
byuu says:
Changelog:
- SNES mid-scanline BGMODE fixes finally merged (can run
atx2.zip{mode7.smc}+mtest(2).sfc properly now)
- Makefile now discards all built-in rules and variables
- switch on bool warning disabled for GCC now as well (was already
disabled for Clang)
- when loading a game, if any required files are missing, display
a warning message box (manifest.bml, program.rom, bios.rom, etc)
- when loading a game (or a game slot), if manifest.bml is missing, it
will invoke icarus to try and generate it
- if that fails (icarus is missing or the folder is bad), you will get
a warning telling you that the manifest can't be loaded
The warning prompt on missing files work for both games and the .sys
folders and their files. For some reason, failing to load the DMG/CGB
BIOS is causing a crash before I can display the modal dialog. I have no
idea why, and the stack frame backtrace is junk.
I also can't seem to abort the failed loading process. If I call
Program::unloadMedia(), I get a nasty segfault. Again with a really
nasty stack trace. So for now, it'll just end up sitting there emulating
an empty ROM (solid black screen.) In time, I'd like to fix that too.
Lastly, I need a better method than popen for Windows. popen is kind of
ugly and flashes a console window for a brief second even if the
application launched is linked with -mwindows. Not sure if there even is
one (I need to read the stdout result, so CreateProcess may not work
unless I do something nasty like "> %tmp%/temp") I'm also using the
regular popen instead of _wpopen, so for this WIP, it won't work if your
game folder has non-English letters in the path.
2015-08-04 09:00:55 +00:00
|
|
|
auto MappedRAM::read(const stream& memory) -> void {
|
2016-06-17 13:03:54 +00:00
|
|
|
memory.read((uint8_t*)_data, min(memory.size(), _size));
|
2012-07-08 02:57:34 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto MappedRAM::writeProtect(bool writeProtect) -> void { _writeProtect = writeProtect; }
|
|
|
|
auto MappedRAM::data() -> uint8* { return _data; }
|
|
|
|
auto MappedRAM::size() const -> uint { return _size; }
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-17 13:03:54 +00:00
|
|
|
auto MappedRAM::read(uint24 addr, uint8) -> uint8 { return _data[addr]; }
|
|
|
|
auto MappedRAM::write(uint24 addr, uint8 data) -> void { if(!_writeProtect) _data[addr] = data; }
|
|
|
|
auto MappedRAM::operator[](uint24 addr) const -> const uint8& { return _data[addr]; }
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
//Bus
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
auto Bus::mirror(uint addr, uint size) -> uint {
|
2014-01-28 10:04:58 +00:00
|
|
|
if(size == 0) return 0;
|
2015-12-14 09:41:06 +00:00
|
|
|
uint base = 0;
|
|
|
|
uint mask = 1 << 23;
|
2014-01-28 10:04:58 +00:00
|
|
|
while(addr >= size) {
|
|
|
|
while(!(addr & mask)) mask >>= 1;
|
|
|
|
addr -= mask;
|
|
|
|
if(size > mask) {
|
|
|
|
size -= mask;
|
|
|
|
base += mask;
|
2012-05-14 13:32:55 +00:00
|
|
|
}
|
2014-01-28 10:04:58 +00:00
|
|
|
mask >>= 1;
|
2012-05-14 13:32:55 +00:00
|
|
|
}
|
2014-01-28 10:04:58 +00:00
|
|
|
return base + addr;
|
2012-05-14 13:32:55 +00:00
|
|
|
}
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
auto Bus::reduce(uint addr, uint mask) -> uint {
|
2014-01-28 10:04:58 +00:00
|
|
|
while(mask) {
|
2015-12-14 09:41:06 +00:00
|
|
|
uint bits = (mask & -mask) - 1;
|
2014-01-28 10:04:58 +00:00
|
|
|
addr = ((addr >> 1) & ~bits) | (addr & bits);
|
|
|
|
mask = (mask & (mask - 1)) >> 1;
|
Update to v091r05 release.
[No prior releases were posted to the WIP thread. -Ed.]
byuu says:
Super Famicom mapping system has been reworked as discussed with the
mask= changes. offset becomes base, mode is gone. Also added support for
comma-separated fields in the address fields, to reduce the number of
map lines needed.
<?xml version="1.0" encoding="UTF-8"?>
<cartridge region="NTSC">
<superfx revision="2">
<rom name="program.rom" size="0x200000"/>
<ram name="save.rwm" size="0x8000"/>
<map id="io" address="00-3f,80-bf:3000-32ff"/>
<map id="rom" address="00-3f:8000-ffff" mask="0x8000"/>
<map id="rom" address="40-5f:0000-ffff"/>
<map id="ram" address="00-3f,80-bf:6000-7fff" size="0x2000"/>
<map id="ram" address="70-71:0000-ffff"/>
</superfx>
</cartridge>
Or in BML:
cartridge region=NTSC
superfx revision=2
rom name=program.rom size=0x200000
ram name=save.rwm size=0x8000
map id=io address=00-3f,80-bf:3000-32ff
map id=rom address=00-3f:8000-ffff mask=0x8000
map id=rom address=40-5f:0000-ffff
map id=ram address=00-3f,80-bf:6000-7fff size=0x2000
map id=ram address=70-71:0000-ffff
As a result of the changes, old mappings will no longer work. The above
XML example will run Super Mario World 2: Yoshi's Island. Otherwise,
you'll have to write your own.
All that's left now is to work some sort of database mapping system in,
so I can start dumping carts en masse.
The NES changes that FitzRoy asked for are mostly in as well.
Also, part of the reason I haven't released a WIP ... but fuck it, I'm
not going to wait forever to post a new WIP.
I've added a skeleton driver to emulate Campus Challenge '92 and
Powerfest '94. There's no actual emulation, except for the stuff I can
glean from looking at the pictures of the board. It has a DSP-1 (so
SR/DR registers), four ROMs that map in and out, RAM, etc.
I've also added preliminary mapping to upload high scores to a website,
but obviously I need the ROMs first.
2012-10-09 08:25:32 +00:00
|
|
|
}
|
2014-01-28 10:04:58 +00:00
|
|
|
return addr;
|
Update to v091r05 release.
[No prior releases were posted to the WIP thread. -Ed.]
byuu says:
Super Famicom mapping system has been reworked as discussed with the
mask= changes. offset becomes base, mode is gone. Also added support for
comma-separated fields in the address fields, to reduce the number of
map lines needed.
<?xml version="1.0" encoding="UTF-8"?>
<cartridge region="NTSC">
<superfx revision="2">
<rom name="program.rom" size="0x200000"/>
<ram name="save.rwm" size="0x8000"/>
<map id="io" address="00-3f,80-bf:3000-32ff"/>
<map id="rom" address="00-3f:8000-ffff" mask="0x8000"/>
<map id="rom" address="40-5f:0000-ffff"/>
<map id="ram" address="00-3f,80-bf:6000-7fff" size="0x2000"/>
<map id="ram" address="70-71:0000-ffff"/>
</superfx>
</cartridge>
Or in BML:
cartridge region=NTSC
superfx revision=2
rom name=program.rom size=0x200000
ram name=save.rwm size=0x8000
map id=io address=00-3f,80-bf:3000-32ff
map id=rom address=00-3f:8000-ffff mask=0x8000
map id=rom address=40-5f:0000-ffff
map id=ram address=00-3f,80-bf:6000-7fff size=0x2000
map id=ram address=70-71:0000-ffff
As a result of the changes, old mappings will no longer work. The above
XML example will run Super Mario World 2: Yoshi's Island. Otherwise,
you'll have to write your own.
All that's left now is to work some sort of database mapping system in,
so I can start dumping carts en masse.
The NES changes that FitzRoy asked for are mostly in as well.
Also, part of the reason I haven't released a WIP ... but fuck it, I'm
not going to wait forever to post a new WIP.
I've added a skeleton driver to emulate Campus Challenge '92 and
Powerfest '94. There's no actual emulation, except for the stuff I can
glean from looking at the pictures of the board. It has a DSP-1 (so
SR/DR registers), four ROMs that map in and out, RAM, etc.
I've also added preliminary mapping to upload high scores to a website,
but obviously I need the ROMs first.
2012-10-09 08:25:32 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 09:32:49 +00:00
|
|
|
auto Bus::read(uint24 addr, uint8 data) -> uint8 {
|
2015-12-14 09:41:06 +00:00
|
|
|
data = reader[lookup[addr]](target[addr], data);
|
2014-01-13 09:35:46 +00:00
|
|
|
if(cheat.enable()) {
|
|
|
|
if(auto result = cheat.find(addr, data)) return result();
|
|
|
|
}
|
|
|
|
return data;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 09:32:49 +00:00
|
|
|
auto Bus::write(uint24 addr, uint8 data) -> void {
|
2011-01-18 10:17:48 +00:00
|
|
|
return writer[lookup[addr]](target[addr], data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|