2010-08-09 13:28:56 +00:00
|
|
|
struct Memory {
|
|
|
|
virtual inline unsigned size() const;
|
|
|
|
virtual uint8 read(unsigned addr) = 0;
|
|
|
|
virtual void write(unsigned addr, uint8 data) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MMIO {
|
|
|
|
virtual uint8 mmio_read(unsigned addr) = 0;
|
|
|
|
virtual void mmio_write(unsigned addr, uint8 data) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UnmappedMemory : Memory {
|
|
|
|
unsigned size() const;
|
|
|
|
uint8 read(unsigned);
|
|
|
|
void write(unsigned, uint8);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UnmappedMMIO : MMIO {
|
|
|
|
uint8 mmio_read(unsigned);
|
|
|
|
void mmio_write(unsigned, uint8);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StaticRAM : Memory {
|
|
|
|
inline uint8* data();
|
|
|
|
inline unsigned size() const;
|
|
|
|
|
|
|
|
inline uint8 read(unsigned addr);
|
|
|
|
inline void write(unsigned addr, uint8 n);
|
|
|
|
inline uint8& operator[](unsigned addr);
|
|
|
|
inline const uint8& operator[](unsigned addr) const;
|
|
|
|
|
|
|
|
inline StaticRAM(unsigned size);
|
|
|
|
inline ~StaticRAM();
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8 *data_;
|
|
|
|
unsigned size_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MappedRAM : Memory {
|
|
|
|
inline void reset();
|
|
|
|
inline void map(uint8*, unsigned);
|
|
|
|
inline void copy(const uint8*, unsigned);
|
|
|
|
|
|
|
|
inline void write_protect(bool status);
|
|
|
|
inline uint8* data();
|
|
|
|
inline unsigned size() const;
|
|
|
|
|
|
|
|
inline uint8 read(unsigned addr);
|
|
|
|
inline void write(unsigned addr, uint8 n);
|
|
|
|
inline const uint8& operator[](unsigned addr) const;
|
|
|
|
inline MappedRAM();
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8 *data_;
|
|
|
|
unsigned size_;
|
|
|
|
bool write_protect_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MMIOAccess : Memory {
|
Updated to v067r23 release.
byuu says:
Fixed bsnes launcher on Windows XP
Fixed Windows bsnes launcher internationalization support (emulator can
be in a folder with spaces and Japanese characters, and you can drag
a Japanese file name onto the launcher, and it will load it properly)
Moved fast CPU to use a switch table for MMIO, unfortunately for no
speed gain
Bus::read/write take uint24 parameters for address, luckily no speed
penalty
MMIOAccess gained a handle() function, and hid the mmio[] table. Makes
hooking it cleaner
Added malloc.h header to nall/function.hpp to fix a ridiculous GCC 4.5.0
error
Fixed a fairly large bug in the fast CPU IRQ handler, which fixes
Robocop et al
Forgot to bump revision to .24 in the compiled binaries, too lazy to
recompile or hex edit to change them
Unfortunately, in order to add nice battery usage, I have to add the
sleep calls to the video and audio wait loops. But they don't know
anything about the GUI and its settings, nor do I really want to make
them know about this setting. I do not want to force allow it. Even with
the media timer trick, Sleep(0) makes Vsync+Async fail a lot more
frequently than never sleeping at all. I would rather laptop users
suffer 100% utilization of a single core than for all users to not be
able to get good audio+video sync. Not sure what to do about that, so
I'll probably just remove the battery usage comment from performance
mode for now.
2010-08-18 05:33:29 +00:00
|
|
|
MMIO* handle(unsigned addr);
|
2010-08-09 13:28:56 +00:00
|
|
|
void map(unsigned addr, MMIO &access);
|
|
|
|
uint8 read(unsigned addr);
|
|
|
|
void write(unsigned addr, uint8 data);
|
2010-08-20 13:01:32 +00:00
|
|
|
MMIOAccess();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
Updated to v067r23 release.
byuu says:
Fixed bsnes launcher on Windows XP
Fixed Windows bsnes launcher internationalization support (emulator can
be in a folder with spaces and Japanese characters, and you can drag
a Japanese file name onto the launcher, and it will load it properly)
Moved fast CPU to use a switch table for MMIO, unfortunately for no
speed gain
Bus::read/write take uint24 parameters for address, luckily no speed
penalty
MMIOAccess gained a handle() function, and hid the mmio[] table. Makes
hooking it cleaner
Added malloc.h header to nall/function.hpp to fix a ridiculous GCC 4.5.0
error
Fixed a fairly large bug in the fast CPU IRQ handler, which fixes
Robocop et al
Forgot to bump revision to .24 in the compiled binaries, too lazy to
recompile or hex edit to change them
Unfortunately, in order to add nice battery usage, I have to add the
sleep calls to the video and audio wait loops. But they don't know
anything about the GUI and its settings, nor do I really want to make
them know about this setting. I do not want to force allow it. Even with
the media timer trick, Sleep(0) makes Vsync+Async fail a lot more
frequently than never sleeping at all. I would rather laptop users
suffer 100% utilization of a single core than for all users to not be
able to get good audio+video sync. Not sure what to do about that, so
I'll probably just remove the battery usage comment from performance
mode for now.
2010-08-18 05:33:29 +00:00
|
|
|
private:
|
Updated to v067r25 release.
byuu says:
Removed snes_spc, and the fast/smp + fast/dsp wrappers around it.
Cloned dsp to fast/dsp, and re-added the state machine, affects
Compatibility and Performance cores.
Added debugger support to fast/cpu, with full properties list and Qt
debugger functionality.
Rewrote all debugger property functions to return data directly:
- this avoids some annoying conflicts where ChipDebugger::foo()
overshadows Chip::foo()
- this removes the need for an extra 20-200 functions per debugger
core
- this makes the overall code size a good bit smaller
- this currently makes PPU::oam_basesize() inaccessible, so the OAM
viewer will show wrong sprite sizes
Used an evil trick to simplify MMIO read/write address decoding:
- MMIO *mmio[0x8000], where only 0x2000-5fff are used, allows direct
indexing without -0x2000 adjust
So end result: both save states and debugger support work on all three
cores now. Dual Orb II sound is fixed. The speed hit was worse than
I thought, -7% for compatibility, and -10% for performance. At this
point, the compatibility core is the exact same code and speed as v067
official, and the performance core is now only ~36-40% faster than the
compatibility core. Sigh, so much for my dream of using this on my
netbook. At 53fps average now, compared to 39fps before. Profiling will
only get that to ~58fps, and that's way too low for the more intensive
scenes (Zelda 3 rain, CT black omen, etc.)
It would probably be a good idea to find out why my DSP is so much
slower than blargg's, given that it's based upon the same code. The
simple ring buffer stuff can't possibly slow things down that much.
More precisely, it would probably be best to leave blargg's DSP in the
performance core since it's a pretty minor issue, but then I'd have to
have three DSPs: accuracy=threaded, compatibility=state-machine,
performance=blargg. Too much hassle.
Only code in the core emulator now that wasn't at the very least
rewritten for bsnes would be the DSP-3 and DSP-4 modules, which are
really, really lazily done #define hacks around the original C code.
2010-08-19 06:54:15 +00:00
|
|
|
MMIO *mmio[0x8000];
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Bus {
|
|
|
|
unsigned mirror(unsigned addr, unsigned size);
|
|
|
|
void map(unsigned addr, Memory &access, unsigned offset);
|
|
|
|
enum class MapMode : unsigned { Direct, Linear, Shadow };
|
|
|
|
void map(MapMode mode,
|
|
|
|
uint8 bank_lo, uint8 bank_hi,
|
|
|
|
uint16 addr_lo, uint16 addr_hi,
|
|
|
|
Memory &access, unsigned offset = 0, unsigned size = 0);
|
|
|
|
|
Updated to v067r23 release.
byuu says:
Fixed bsnes launcher on Windows XP
Fixed Windows bsnes launcher internationalization support (emulator can
be in a folder with spaces and Japanese characters, and you can drag
a Japanese file name onto the launcher, and it will load it properly)
Moved fast CPU to use a switch table for MMIO, unfortunately for no
speed gain
Bus::read/write take uint24 parameters for address, luckily no speed
penalty
MMIOAccess gained a handle() function, and hid the mmio[] table. Makes
hooking it cleaner
Added malloc.h header to nall/function.hpp to fix a ridiculous GCC 4.5.0
error
Fixed a fairly large bug in the fast CPU IRQ handler, which fixes
Robocop et al
Forgot to bump revision to .24 in the compiled binaries, too lazy to
recompile or hex edit to change them
Unfortunately, in order to add nice battery usage, I have to add the
sleep calls to the video and audio wait loops. But they don't know
anything about the GUI and its settings, nor do I really want to make
them know about this setting. I do not want to force allow it. Even with
the media timer trick, Sleep(0) makes Vsync+Async fail a lot more
frequently than never sleeping at all. I would rather laptop users
suffer 100% utilization of a single core than for all users to not be
able to get good audio+video sync. Not sure what to do about that, so
I'll probably just remove the battery usage comment from performance
mode for now.
2010-08-18 05:33:29 +00:00
|
|
|
alwaysinline uint8 read(uint24 addr);
|
|
|
|
alwaysinline void write(uint24 addr, uint8 data);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
bool load_cart();
|
|
|
|
void unload_cart();
|
|
|
|
|
|
|
|
void power();
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
struct Page {
|
|
|
|
Memory *access;
|
|
|
|
unsigned offset;
|
|
|
|
} page[65536];
|
|
|
|
|
|
|
|
void serialize(serializer&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void map_reset();
|
|
|
|
void map_xml();
|
|
|
|
void map_system();
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace memory {
|
Updated to v067r23 release.
byuu says:
Fixed bsnes launcher on Windows XP
Fixed Windows bsnes launcher internationalization support (emulator can
be in a folder with spaces and Japanese characters, and you can drag
a Japanese file name onto the launcher, and it will load it properly)
Moved fast CPU to use a switch table for MMIO, unfortunately for no
speed gain
Bus::read/write take uint24 parameters for address, luckily no speed
penalty
MMIOAccess gained a handle() function, and hid the mmio[] table. Makes
hooking it cleaner
Added malloc.h header to nall/function.hpp to fix a ridiculous GCC 4.5.0
error
Fixed a fairly large bug in the fast CPU IRQ handler, which fixes
Robocop et al
Forgot to bump revision to .24 in the compiled binaries, too lazy to
recompile or hex edit to change them
Unfortunately, in order to add nice battery usage, I have to add the
sleep calls to the video and audio wait loops. But they don't know
anything about the GUI and its settings, nor do I really want to make
them know about this setting. I do not want to force allow it. Even with
the media timer trick, Sleep(0) makes Vsync+Async fail a lot more
frequently than never sleeping at all. I would rather laptop users
suffer 100% utilization of a single core than for all users to not be
able to get good audio+video sync. Not sure what to do about that, so
I'll probably just remove the battery usage comment from performance
mode for now.
2010-08-18 05:33:29 +00:00
|
|
|
extern MMIOAccess mmio; //S-CPU, S-PPU
|
|
|
|
extern StaticRAM wram; //S-CPU
|
|
|
|
extern StaticRAM apuram; //S-SMP, S-DSP
|
|
|
|
extern StaticRAM vram; //S-PPU
|
|
|
|
extern StaticRAM oam; //S-PPU
|
|
|
|
extern StaticRAM cgram; //S-PPU
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
extern UnmappedMemory memory_unmapped;
|
Updated to v067r23 release.
byuu says:
Fixed bsnes launcher on Windows XP
Fixed Windows bsnes launcher internationalization support (emulator can
be in a folder with spaces and Japanese characters, and you can drag
a Japanese file name onto the launcher, and it will load it properly)
Moved fast CPU to use a switch table for MMIO, unfortunately for no
speed gain
Bus::read/write take uint24 parameters for address, luckily no speed
penalty
MMIOAccess gained a handle() function, and hid the mmio[] table. Makes
hooking it cleaner
Added malloc.h header to nall/function.hpp to fix a ridiculous GCC 4.5.0
error
Fixed a fairly large bug in the fast CPU IRQ handler, which fixes
Robocop et al
Forgot to bump revision to .24 in the compiled binaries, too lazy to
recompile or hex edit to change them
Unfortunately, in order to add nice battery usage, I have to add the
sleep calls to the video and audio wait loops. But they don't know
anything about the GUI and its settings, nor do I really want to make
them know about this setting. I do not want to force allow it. Even with
the media timer trick, Sleep(0) makes Vsync+Async fail a lot more
frequently than never sleeping at all. I would rather laptop users
suffer 100% utilization of a single core than for all users to not be
able to get good audio+video sync. Not sure what to do about that, so
I'll probably just remove the battery usage comment from performance
mode for now.
2010-08-18 05:33:29 +00:00
|
|
|
extern UnmappedMMIO mmio_unmapped;
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Bus bus;
|