2012-04-17 12:16:54 +00:00
|
|
|
bool Cartridge::EEPROM::read(unsigned addr) {
|
|
|
|
return data[addr >> 3] & 0x80 >> (addr & 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cartridge::EEPROM::write(unsigned addr, bool bit) {
|
|
|
|
if(bit == 0) data[addr >> 3] &=~ (0x80 >> (addr & 7));
|
|
|
|
if(bit == 1) data[addr >> 3] |= (0x80 >> (addr & 7));
|
|
|
|
}
|
|
|
|
|
2012-04-09 06:19:32 +00:00
|
|
|
bool Cartridge::EEPROM::read() {
|
|
|
|
bool bit = 1;
|
|
|
|
|
Update to v087r30 release.
byuu says:
Changelog:
- DMA channel masks added (some are 27-bit source/target and some are
14-bit length -- hooray, varuint_t class.)
- No more state.pending flags. Instead, we set dma.pending flag when we
want a transfer (fixes GBA Video - Pokemon audio) [Cydrak]
- fixed OBJ Vmosaic [Cydrak, krom]
- OBJ cannot read <=0x13fff in BG modes 3-5 (fixes the garbled tile at
the top-left of some games)
- DMA timing should be much closer to hardware now, but probably not
perfect
- PPU frame blending uses blargg's bit-perfect, rounded method (slower,
but what can you do?)
- GBA carts really unload now
- added nall/gba/cartridge.hpp: used when there is no manifest. Scans
ROMs for library tags, and selects the first valid one found
- added EEPROM auto-detection when EEPROM size=0. Forces disk/save state
size to 8192 (otherwise states could crash between pre and post
detect.)
- detects first read after a set read address command when the size
is zero, and sets all subsequent bit-lengths to that value, prints
detected size to terminal
- added nall/nes/cartridge.hpp: moves iNES detection out of emulation
core.
Important to note: long-term goal is to remove all
nall/(system)/cartridge.hpp detections from the core and replace with
databases. All in good time.
Anyway, the GBA workarounds should work for ~98.5% of the library, if my
pre-scanning was correct (~40 games with odd tags. I reject ones without
numeric versions now, too.)
I think we're basically at a point where we can release a new version
now. Compatibility should be relatively high (at least for a first
release), and fixes are only going to affect one or two games at a time.
I'd like to start doing some major cleaning house internally (rename
NES->Famicom, SNES->SuperFamicom and such.) Would be much wiser to do
that on a .01 WIP to minimize regressions.
The main problems with a release now:
- speed is pretty bad, haven't really optimized much yet (not sure how
much we can improve it yet, this usually isn't easy)
- sound isn't -great-, but the GBA audio sucks anyway :P
- couple of known bugs (Sonic X video, etc.)
2012-04-22 10:49:19 +00:00
|
|
|
//EEPROM size auto-detection
|
|
|
|
if(bits == 0 && mode == Mode::ReadAddress) {
|
|
|
|
print("EEPROM address bits: ", --addressbits, "\n");
|
|
|
|
bits = addressbits == 6 ? 6 : 14;
|
|
|
|
size = 8192;
|
|
|
|
mode = Mode::ReadData;
|
|
|
|
offset = 0;
|
|
|
|
//fallthrough
|
|
|
|
}
|
|
|
|
|
2012-04-09 06:19:32 +00:00
|
|
|
if(mode == Mode::ReadData) {
|
2012-04-17 12:16:54 +00:00
|
|
|
if(offset >= 4) bit = read(address * 64 + (offset - 4));
|
2012-04-09 06:19:32 +00:00
|
|
|
if(++offset == 68) mode = Mode::Wait;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cartridge::EEPROM::write(bool bit) {
|
|
|
|
if(mode == Mode::Wait) {
|
|
|
|
if(bit == 1) mode = Mode::Command;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(mode == Mode::Command) {
|
|
|
|
if(bit == 0) mode = Mode::WriteAddress;
|
|
|
|
if(bit == 1) mode = Mode::ReadAddress;
|
|
|
|
offset = 0;
|
|
|
|
address = 0;
|
Update to v087r30 release.
byuu says:
Changelog:
- DMA channel masks added (some are 27-bit source/target and some are
14-bit length -- hooray, varuint_t class.)
- No more state.pending flags. Instead, we set dma.pending flag when we
want a transfer (fixes GBA Video - Pokemon audio) [Cydrak]
- fixed OBJ Vmosaic [Cydrak, krom]
- OBJ cannot read <=0x13fff in BG modes 3-5 (fixes the garbled tile at
the top-left of some games)
- DMA timing should be much closer to hardware now, but probably not
perfect
- PPU frame blending uses blargg's bit-perfect, rounded method (slower,
but what can you do?)
- GBA carts really unload now
- added nall/gba/cartridge.hpp: used when there is no manifest. Scans
ROMs for library tags, and selects the first valid one found
- added EEPROM auto-detection when EEPROM size=0. Forces disk/save state
size to 8192 (otherwise states could crash between pre and post
detect.)
- detects first read after a set read address command when the size
is zero, and sets all subsequent bit-lengths to that value, prints
detected size to terminal
- added nall/nes/cartridge.hpp: moves iNES detection out of emulation
core.
Important to note: long-term goal is to remove all
nall/(system)/cartridge.hpp detections from the core and replace with
databases. All in good time.
Anyway, the GBA workarounds should work for ~98.5% of the library, if my
pre-scanning was correct (~40 games with odd tags. I reject ones without
numeric versions now, too.)
I think we're basically at a point where we can release a new version
now. Compatibility should be relatively high (at least for a first
release), and fixes are only going to affect one or two games at a time.
I'd like to start doing some major cleaning house internally (rename
NES->Famicom, SNES->SuperFamicom and such.) Would be much wiser to do
that on a .01 WIP to minimize regressions.
The main problems with a release now:
- speed is pretty bad, haven't really optimized much yet (not sure how
much we can improve it yet, this usually isn't easy)
- sound isn't -great-, but the GBA audio sucks anyway :P
- couple of known bugs (Sonic X video, etc.)
2012-04-22 10:49:19 +00:00
|
|
|
addressbits = 0;
|
2012-04-09 06:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else if(mode == Mode::ReadAddress) {
|
|
|
|
address = (address << 1) | bit;
|
Update to v087r30 release.
byuu says:
Changelog:
- DMA channel masks added (some are 27-bit source/target and some are
14-bit length -- hooray, varuint_t class.)
- No more state.pending flags. Instead, we set dma.pending flag when we
want a transfer (fixes GBA Video - Pokemon audio) [Cydrak]
- fixed OBJ Vmosaic [Cydrak, krom]
- OBJ cannot read <=0x13fff in BG modes 3-5 (fixes the garbled tile at
the top-left of some games)
- DMA timing should be much closer to hardware now, but probably not
perfect
- PPU frame blending uses blargg's bit-perfect, rounded method (slower,
but what can you do?)
- GBA carts really unload now
- added nall/gba/cartridge.hpp: used when there is no manifest. Scans
ROMs for library tags, and selects the first valid one found
- added EEPROM auto-detection when EEPROM size=0. Forces disk/save state
size to 8192 (otherwise states could crash between pre and post
detect.)
- detects first read after a set read address command when the size
is zero, and sets all subsequent bit-lengths to that value, prints
detected size to terminal
- added nall/nes/cartridge.hpp: moves iNES detection out of emulation
core.
Important to note: long-term goal is to remove all
nall/(system)/cartridge.hpp detections from the core and replace with
databases. All in good time.
Anyway, the GBA workarounds should work for ~98.5% of the library, if my
pre-scanning was correct (~40 games with odd tags. I reject ones without
numeric versions now, too.)
I think we're basically at a point where we can release a new version
now. Compatibility should be relatively high (at least for a first
release), and fixes are only going to affect one or two games at a time.
I'd like to start doing some major cleaning house internally (rename
NES->Famicom, SNES->SuperFamicom and such.) Would be much wiser to do
that on a .01 WIP to minimize regressions.
The main problems with a release now:
- speed is pretty bad, haven't really optimized much yet (not sure how
much we can improve it yet, this usually isn't easy)
- sound isn't -great-, but the GBA audio sucks anyway :P
- couple of known bugs (Sonic X video, etc.)
2012-04-22 10:49:19 +00:00
|
|
|
addressbits++;
|
Update to v087r26 release.
byuu says:
Changelog:
- fixed FIFO[1] reset behavior (fixes audio in Sword of Mana)
- added FlashROM emulation (both sizes)
- GBA parses RAM settings from manifest.xml now
- save RAM is written to disk now
- added save state support (it's currently broken, though)
- fixed ROM/RAM access timings
- open bus should mostly work (we don't do the PC+12 stuff yet)
- emulated the undocumented memory control register (mirror IWRAM,
disable I+EWRAM, EWRAM wait state count)
- emulated keypad interrupts
- emulated STOP (freezes video, audio, DMA and timers; only breaks on
keypad IRQs)
- probably a lot more, it was a long night ...
Show stoppers, missing things, broken things, etc:
- ST018 is still completely broken
- GBC audio sequencer apparently needs work
- GBA audio FIFO buffer seems too quiet
- PHI / ROM prefetch needs to be emulated (no idea on how to do this,
especially PHI)
- SOUNDBIAS 64/128/256khz modes should output at that resolution
(really, we need to simulate PWM properly, no idea on how to do this)
- object mosaic top-left coordinates are wrong (minor, fixing will
actually make the effect look worse)
- need to emulate PPU greenswap and color palette distortion (no idea on
how do this)
- need GBA save type database (I would also LIKE to blacklist
/ patch-out trainers, but that's a discussion for another day.)
- some ARM ops advance the prefetch buffer, so you can read PC+12 in
some cases
2012-04-16 12:19:39 +00:00
|
|
|
if(++offset == bits) {
|
2012-04-09 06:19:32 +00:00
|
|
|
mode = Mode::ReadValidate;
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(mode == Mode::ReadValidate) {
|
|
|
|
if(bit == 1); //invalid
|
|
|
|
mode = Mode::ReadData;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(mode == Mode::WriteAddress) {
|
|
|
|
address = (address << 1) | bit;
|
Update to v087r26 release.
byuu says:
Changelog:
- fixed FIFO[1] reset behavior (fixes audio in Sword of Mana)
- added FlashROM emulation (both sizes)
- GBA parses RAM settings from manifest.xml now
- save RAM is written to disk now
- added save state support (it's currently broken, though)
- fixed ROM/RAM access timings
- open bus should mostly work (we don't do the PC+12 stuff yet)
- emulated the undocumented memory control register (mirror IWRAM,
disable I+EWRAM, EWRAM wait state count)
- emulated keypad interrupts
- emulated STOP (freezes video, audio, DMA and timers; only breaks on
keypad IRQs)
- probably a lot more, it was a long night ...
Show stoppers, missing things, broken things, etc:
- ST018 is still completely broken
- GBC audio sequencer apparently needs work
- GBA audio FIFO buffer seems too quiet
- PHI / ROM prefetch needs to be emulated (no idea on how to do this,
especially PHI)
- SOUNDBIAS 64/128/256khz modes should output at that resolution
(really, we need to simulate PWM properly, no idea on how to do this)
- object mosaic top-left coordinates are wrong (minor, fixing will
actually make the effect look worse)
- need to emulate PPU greenswap and color palette distortion (no idea on
how do this)
- need GBA save type database (I would also LIKE to blacklist
/ patch-out trainers, but that's a discussion for another day.)
- some ARM ops advance the prefetch buffer, so you can read PC+12 in
some cases
2012-04-16 12:19:39 +00:00
|
|
|
if(++offset == bits) {
|
2012-04-09 06:19:32 +00:00
|
|
|
mode = Mode::WriteData;
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(mode == Mode::WriteData) {
|
2012-04-17 12:16:54 +00:00
|
|
|
write(address * 64 + offset, bit);
|
2012-04-09 06:19:32 +00:00
|
|
|
if(++offset == 64) {
|
|
|
|
mode = Mode::WriteValidate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(mode == Mode::WriteValidate) {
|
|
|
|
if(bit == 1); //invalid
|
|
|
|
mode = Mode::Wait;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cartridge::EEPROM::power() {
|
|
|
|
mode = Mode::Wait;
|
|
|
|
offset = 0;
|
|
|
|
address = 0;
|
|
|
|
}
|
2012-04-17 12:16:54 +00:00
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
void Cartridge::EEPROM::serialize(serializer& s) {
|
2012-04-17 12:16:54 +00:00
|
|
|
s.array(data, size);
|
|
|
|
s.integer(size);
|
|
|
|
s.integer(mask);
|
|
|
|
s.integer(test);
|
|
|
|
s.integer(bits);
|
|
|
|
s.integer((unsigned&)mode);
|
|
|
|
s.integer(offset);
|
|
|
|
s.integer(address);
|
|
|
|
}
|