bsnes/gba/cartridge/memory.hpp

69 lines
1.4 KiB
C++
Raw Normal View History

struct Memory {
auto ror(uint32 word, unsigned shift) -> uint32 {
return word << 32 - shift | word >> shift;
}
};
struct MROM : Memory {
uint8* data;
unsigned size;
unsigned mask;
auto read(unsigned mode, uint32 addr) -> uint32;
auto write(unsigned mode, uint32 addr, uint32 word) -> void;
} mrom;
struct SRAM : Memory {
uint8* data;
unsigned size;
unsigned mask;
auto read(unsigned mode, uint32 addr) -> uint32;
auto write(unsigned mode, uint32 addr, uint32 word) -> void;
auto serialize(serializer&) -> void;
} sram;
struct EEPROM : Memory {
uint8* data;
unsigned size;
unsigned mask;
unsigned test;
unsigned bits;
enum class Mode : unsigned {
Wait, Command, ReadAddress, ReadValidate, ReadData, WriteAddress, WriteData, WriteValidate
} mode;
unsigned offset;
unsigned address;
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
unsigned addressbits;
auto read(unsigned addr) -> bool;
auto write(unsigned addr, bool bit) -> void;
auto read() -> bool;
auto write(bool bit) -> void;
auto power() -> void;
auto serialize(serializer&) -> void;
} eeprom;
struct FLASH : Memory {
uint8* data;
unsigned size;
uint16 id;
bool unlockhi;
bool unlocklo;
bool idmode;
bool erasemode;
bool bankselect;
bool writeselect;
bool bank;
auto read(uint16 addr) -> uint8;
auto write(uint16 addr, uint8 byte) -> void;
auto power() -> void;
auto serialize(serializer&) -> void;
} flash;