2012-04-29 06:16:44 +00:00
|
|
|
#include <sfc/sfc.hpp>
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2012-04-26 10:51:13 +00:00
|
|
|
namespace SuperFamicom {
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-05 05:03:21 +00:00
|
|
|
#include "bus.cpp"
|
|
|
|
#include "dma.cpp"
|
|
|
|
#include "memory.cpp"
|
Update to v099r13 release.
byuu says:
Changelog:
- GB core code cleanup completed
- GBA core code cleanup completed
- some more cleanup on missed processor/arm functions/variables
- fixed FC loading icarus bug
- "Load ROM File" icarus functionality restored
- minor code unification efforts all around (not perfect yet)
- MMIO->IO
- mmio.cpp->io.cpp
- read,write->readIO,writeIO
It's been a very long work in progress ... starting all the way back with
v094r09, but the major part of the higan code cleanup is now completed! Of
course, it's very important to note that this is only for the basic style:
- under_score functions and variables are now camelCase
- return-type function-name() are now auto function-name() -> return-type
- Natural<T>/Integer<T> replace (u)intT_n types where possible
- signed/unsigned are now int/uint
- most of the x==true,x==false tests changed to x,!x
A lot of spot improvements to consistency, simplicity and quality have
gone in along the way, of course. But we'll probably never fully finishing
beautifying every last line of code in the entire codebase. Still,
this is a really great start. Going forward, WIP diffs should start
being smaller and of higher quality once again.
I know the joke is, "until my coding style changes again", but ... this
was way too stressful, way too time consuming, and way too risky. I'm
too old and tired now for extreme upheavel like this again. The only
major change I'm slowly mulling over would be renaming the using
Natural<T>/Integer<T> = (u)intT; shorthand to something that isn't as
easily confused with the (u)int_t types ... but we'll see. I'll definitely
continue to change small things all the time, but for the larger picture,
I need to just accept the style I have and live with it.
2016-06-29 11:10:28 +00:00
|
|
|
#include "io.cpp"
|
2010-08-09 13:28:56 +00:00
|
|
|
#include "serialization.cpp"
|
2016-06-05 05:03:21 +00:00
|
|
|
SA1 sa1;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-02-09 11:51:12 +00:00
|
|
|
auto SA1::Enter() -> void {
|
|
|
|
while(true) scheduler.synchronize(), sa1.main();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto SA1::main() -> void {
|
|
|
|
if(mmio.sa1_rdyb || mmio.sa1_resb) {
|
|
|
|
//SA-1 co-processor is asleep
|
|
|
|
tick();
|
Update to v100r14 release.
byuu says:
(Windows: compile with -fpermissive to silence an annoying error. I'll
fix it in the next WIP.)
I completely replaced the time management system in higan and overhauled
the scheduler.
Before, processor threads would have "int64 clock"; and there would
be a 1:1 relationship between two threads. When thread A ran for X
cycles, it'd subtract X * B.Frequency from clock; and when thread B ran
for Y cycles, it'd add Y * A.Frequency from clock. This worked well
and allowed perfect precision; but it doesn't work when you have more
complicated relationships: eg the 68K can sync to the Z80 and PSG; the
Z80 to the 68K and PSG; so the PSG needs two counters.
The new system instead uses a "uint64 clock" variable that represents
time in attoseconds. Every time the scheduler exits, it subtracts
the smallest clock count from all threads, to prevent an overflow
scenario. The only real downside is that rounding errors mean that
roughly every 20 minutes, we have a rounding error of one clock cycle
(one 20,000,000th of a second.) However, this only applies to systems
with multiple oscillators, like the SNES. And when you're in that
situation ... there's no such thing as a perfect oscillator anyway. A
real SNES will be thousands of times less out of spec than 1hz per 20
minutes.
The advantages are pretty immense. First, we obviously can now support
more complex relationships between threads. Second, we can build a
much more abstracted scheduler. All of libco is now abstracted away
completely, which may permit a state-machine / coroutine version of
Thread in the future. We've basically gone from this:
auto SMP::step(uint clocks) -> void {
clock += clocks * (uint64)cpu.frequency;
dsp.clock -= clocks;
if(dsp.clock < 0 && !scheduler.synchronizing()) co_switch(dsp.thread);
if(clock >= 0 && !scheduler.synchronizing()) co_switch(cpu.thread);
}
To this:
auto SMP::step(uint clocks) -> void {
Thread::step(clocks);
synchronize(dsp);
synchronize(cpu);
}
As you can see, we don't have to do multiple clock adjustments anymore.
This is a huge win for the SNES CPU that had to update the SMP, DSP, all
peripherals and all coprocessors. Likewise, we don't have to synchronize
all coprocessors when one runs, now we can just synchronize the active
one to the CPU.
Third, when changing the frequencies of threads (think SGB speed setting
modes, GBC double-speed mode, etc), it no longer causes the "int64
clock" value to be erroneous.
Fourth, this results in a fairly decent speedup, mostly across the
board. Aside from the GBA being mostly a wash (for unknown reasons),
it's about an 8% - 12% speedup in every other emulation core.
Now, all of this said ... this was an unbelievably massive change, so
... you know what that means >_> If anyone can help test all types of
SNES coprocessors, and some other system games, it'd be appreciated.
----
Lastly, we have a bitchin' new about screen. It unfortunately adds
~200KiB onto the binary size, because the PNG->C++ header file
transformation doesn't compress very well, and I want to keep the
original resource files in with the higan archive. I might try some
things to work around this file size increase in the future, but for now
... yeah, slightly larger archive sizes, sorry.
The logo's a bit busted on Windows (the Label control's background
transparency and alignment settings aren't working), but works well on
GTK. I'll have to fix Windows before the next official release. For now,
look on my Twitter feed if you want to see what it's supposed to look
like.
----
EDIT: forgot about ICD2::Enter. It's doing some weird inverse
run-to-save thing that I need to implement support for somehow. So, save
states on the SGB core probably won't work with this WIP.
2016-07-30 03:56:12 +00:00
|
|
|
synchronize(cpu);
|
2016-02-09 11:51:12 +00:00
|
|
|
return;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2016-02-09 11:51:12 +00:00
|
|
|
|
2016-06-05 05:03:21 +00:00
|
|
|
if(status.interruptPending) {
|
|
|
|
status.interruptPending = false;
|
2016-03-26 01:56:15 +00:00
|
|
|
interrupt();
|
2016-02-09 11:51:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
instruction();
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-07-17 03:24:28 +00:00
|
|
|
//override R65816::interrupt() to support SA-1 vector location IO registers
|
|
|
|
auto SA1::interrupt() -> void {
|
|
|
|
read(r.pc.d);
|
|
|
|
idle();
|
|
|
|
if(!r.e) writeSP(r.pc.b);
|
|
|
|
writeSP(r.pc.h);
|
|
|
|
writeSP(r.pc.l);
|
|
|
|
writeSP(r.e ? (r.p & ~0x10) : r.p);
|
|
|
|
r.pc.w = r.vector;
|
|
|
|
r.pc.b = 0x00;
|
|
|
|
r.p.i = 1;
|
|
|
|
r.p.d = 0;
|
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
auto SA1::lastCycle() -> void {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(mmio.sa1_nmi && !mmio.sa1_nmicl) {
|
2016-06-05 05:03:21 +00:00
|
|
|
status.interruptPending = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.vector = mmio.cnv;
|
2010-08-09 13:28:56 +00:00
|
|
|
mmio.sa1_nmifl = true;
|
|
|
|
mmio.sa1_nmicl = 1;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.wai = false;
|
|
|
|
} else if(!r.p.i) {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(mmio.timer_irqen && !mmio.timer_irqcl) {
|
2016-06-05 05:03:21 +00:00
|
|
|
status.interruptPending = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.vector = mmio.civ;
|
2010-08-09 13:28:56 +00:00
|
|
|
mmio.timer_irqfl = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.wai = false;
|
2010-08-09 13:28:56 +00:00
|
|
|
} else if(mmio.dma_irqen && !mmio.dma_irqcl) {
|
2016-06-05 05:03:21 +00:00
|
|
|
status.interruptPending = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.vector = mmio.civ;
|
2010-08-09 13:28:56 +00:00
|
|
|
mmio.dma_irqfl = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.wai = false;
|
2010-08-09 13:28:56 +00:00
|
|
|
} else if(mmio.sa1_irq && !mmio.sa1_irqcl) {
|
2016-06-05 05:03:21 +00:00
|
|
|
status.interruptPending = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.vector = mmio.civ;
|
2010-08-09 13:28:56 +00:00
|
|
|
mmio.sa1_irqfl = true;
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.wai = false;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
auto SA1::interruptPending() const -> bool {
|
2016-06-05 05:03:21 +00:00
|
|
|
return status.interruptPending;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SA1::tick() -> void {
|
2010-08-09 13:28:56 +00:00
|
|
|
step(2);
|
Update to v100r14 release.
byuu says:
(Windows: compile with -fpermissive to silence an annoying error. I'll
fix it in the next WIP.)
I completely replaced the time management system in higan and overhauled
the scheduler.
Before, processor threads would have "int64 clock"; and there would
be a 1:1 relationship between two threads. When thread A ran for X
cycles, it'd subtract X * B.Frequency from clock; and when thread B ran
for Y cycles, it'd add Y * A.Frequency from clock. This worked well
and allowed perfect precision; but it doesn't work when you have more
complicated relationships: eg the 68K can sync to the Z80 and PSG; the
Z80 to the 68K and PSG; so the PSG needs two counters.
The new system instead uses a "uint64 clock" variable that represents
time in attoseconds. Every time the scheduler exits, it subtracts
the smallest clock count from all threads, to prevent an overflow
scenario. The only real downside is that rounding errors mean that
roughly every 20 minutes, we have a rounding error of one clock cycle
(one 20,000,000th of a second.) However, this only applies to systems
with multiple oscillators, like the SNES. And when you're in that
situation ... there's no such thing as a perfect oscillator anyway. A
real SNES will be thousands of times less out of spec than 1hz per 20
minutes.
The advantages are pretty immense. First, we obviously can now support
more complex relationships between threads. Second, we can build a
much more abstracted scheduler. All of libco is now abstracted away
completely, which may permit a state-machine / coroutine version of
Thread in the future. We've basically gone from this:
auto SMP::step(uint clocks) -> void {
clock += clocks * (uint64)cpu.frequency;
dsp.clock -= clocks;
if(dsp.clock < 0 && !scheduler.synchronizing()) co_switch(dsp.thread);
if(clock >= 0 && !scheduler.synchronizing()) co_switch(cpu.thread);
}
To this:
auto SMP::step(uint clocks) -> void {
Thread::step(clocks);
synchronize(dsp);
synchronize(cpu);
}
As you can see, we don't have to do multiple clock adjustments anymore.
This is a huge win for the SNES CPU that had to update the SMP, DSP, all
peripherals and all coprocessors. Likewise, we don't have to synchronize
all coprocessors when one runs, now we can just synchronize the active
one to the CPU.
Third, when changing the frequencies of threads (think SGB speed setting
modes, GBC double-speed mode, etc), it no longer causes the "int64
clock" value to be erroneous.
Fourth, this results in a fairly decent speedup, mostly across the
board. Aside from the GBA being mostly a wash (for unknown reasons),
it's about an 8% - 12% speedup in every other emulation core.
Now, all of this said ... this was an unbelievably massive change, so
... you know what that means >_> If anyone can help test all types of
SNES coprocessors, and some other system games, it'd be appreciated.
----
Lastly, we have a bitchin' new about screen. It unfortunately adds
~200KiB onto the binary size, because the PNG->C++ header file
transformation doesn't compress very well, and I want to keep the
original resource files in with the higan archive. I might try some
things to work around this file size increase in the future, but for now
... yeah, slightly larger archive sizes, sorry.
The logo's a bit busted on Windows (the Label control's background
transparency and alignment settings aren't working), but works well on
GTK. I'll have to fix Windows before the next official release. For now,
look on my Twitter feed if you want to see what it's supposed to look
like.
----
EDIT: forgot about ICD2::Enter. It's doing some weird inverse
run-to-save thing that I need to implement support for somehow. So, save
states on the SGB core probably won't work with this WIP.
2016-07-30 03:56:12 +00:00
|
|
|
if(++status.counter == 0) synchronize(cpu);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
//adjust counters:
|
|
|
|
//note that internally, status counters are in clocks;
|
|
|
|
//whereas MMIO register counters are in dots (4 clocks = 1 dot)
|
|
|
|
if(mmio.hvselb == 0) {
|
|
|
|
//HV timer
|
|
|
|
status.hcounter += 2;
|
|
|
|
if(status.hcounter >= 1364) {
|
|
|
|
status.hcounter = 0;
|
|
|
|
if(++status.vcounter >= status.scanlines) status.vcounter = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//linear timer
|
|
|
|
status.hcounter += 2;
|
|
|
|
status.vcounter += (status.hcounter >> 11);
|
|
|
|
status.hcounter &= 0x07ff;
|
|
|
|
status.vcounter &= 0x01ff;
|
|
|
|
}
|
|
|
|
|
|
|
|
//test counters for timer IRQ
|
|
|
|
switch((mmio.ven << 1) + (mmio.hen << 0)) {
|
2013-05-05 09:21:30 +00:00
|
|
|
case 0: break;
|
2016-06-05 05:03:21 +00:00
|
|
|
case 1: if(status.hcounter == (mmio.hcnt << 2)) triggerIRQ(); break;
|
|
|
|
case 2: if(status.vcounter == mmio.vcnt && status.hcounter == 0) triggerIRQ(); break;
|
|
|
|
case 3: if(status.vcounter == mmio.vcnt && status.hcounter == (mmio.hcnt << 2)) triggerIRQ(); break;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-05 05:03:21 +00:00
|
|
|
auto SA1::triggerIRQ() -> void {
|
2010-08-09 13:28:56 +00:00
|
|
|
mmio.timer_irqfl = true;
|
|
|
|
if(mmio.timer_irqen) mmio.timer_irqcl = 0;
|
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SA1::init() -> void {
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SA1::load() -> void {
|
Update to v075 release.
byuu says:
This release brings improved Super Game Boy emulation, the final SHA256
hashes for the DSP-(1,1B,2,3,4) and ST-(0010,0011) coprocessors, user
interface improvements, and major internal code restructuring.
Changelog (since v074):
- completely rewrote memory sub-system to support 1-byte granularity in
XML mapping
- removed Memory inheritance and MMIO class completely, any address can
be mapped to any function now
- SuperFX: removed SuperFXBus : Bus, now implemented manually
- SA-1: removed SA1Bus : Bus, now implemented manually
- entire bus mapping is now static, happens once on cartridge load
- as a result, read/write handlers now handle MMC mapping; slower
average case, far faster worst case
- namespace memory is no more, RAM arrays are stored inside the chips
they are owned by now
- GameBoy: improved CPU HALT emulation, fixes Zelda: Link's Awakening
scrolling
- GameBoy: added serial emulation (cannot connect to another GB yet),
fixes Shin Megami Tensei - Devichil
- GameBoy: improved LCD STAT emulation, fixes Sagaia
- ui: added fullscreen support (F11 key), video settings allows for
three scale settings
- ui: fixed brightness, contrast, gamma, audio volume, input frequency
values on program startup
- ui: since Qt is dead, config file becomes bsnes.cfg once again
- Super Game Boy: you can now load the BIOS without a game inserted to
see a pretty white box
- ui-gameboy: can be built without SNES components now
- libsnes: now a UI target, compile with 'make ui=ui-libsnes'
- libsnes: added WRAM, APURAM, VRAM, OAM, CGRAM access (cheat search,
etc)
- source: removed launcher/, as the Qt port is now gone
- source: Makefile restructuring to better support new ui targets
- source: lots of other internal code cleanup work
2011-01-27 08:52:34 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SA1::unload() -> void {
|
2012-07-08 02:57:34 +00:00
|
|
|
rom.reset();
|
|
|
|
iram.reset();
|
|
|
|
bwram.reset();
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SA1::power() -> void {
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.a = 0x0000;
|
|
|
|
r.x = 0x0000;
|
|
|
|
r.y = 0x0000;
|
|
|
|
r.s = 0x01ff;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto SA1::reset() -> void {
|
2016-07-10 05:28:26 +00:00
|
|
|
create(SA1::Enter, system.colorburst() * 6.0);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
cpubwram.dma = false;
|
2015-11-14 00:52:51 +00:00
|
|
|
for(auto addr : range(iram.size())) {
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
iram.write(addr, 0x00);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
Update to v098r11 release.
byuu says:
Changelog:
- fixed nall/path.hpp compilation issue
- fixed ruby/audio/xaudio header declaration compilation issue (again)
- cleaned up xaudio2.hpp file to match my coding syntax (12.5% of the
file was whitespace overkill)
- added null terminator entry to nall/windows/utf8.hpp argc[] array
- nall/windows/guid.hpp uses the Windows API for generating the GUID
- this should stop all the bug reports where two nall users were
generating GUIDs at the exact same second
- fixed hiro/cocoa compilation issue with uint# types
- fixed major higan/sfc Super Game Boy audio latency issue
- fixed higan/sfc CPU core bug with pei, [dp], [dp]+y instructions
- major cleanups to higan/processor/r65816 core
- merged emulation/native-mode opcodes
- use camel-case naming on memory.hpp functions
- simplify address masking code for memory.hpp functions
- simplify a few opcodes themselves (avoid redundant copies, etc)
- rename regs.* to r.* to match modern convention of other CPU cores
- removed device.order<> concept from Emulator::Interface
- cores will now do the translation to make the job of the UI easier
- fixed plurality naming of arrays in Emulator::Interface
- example: emulator.ports[p].devices[d].inputs[i]
- example: vector<Medium> media
- probably more surprises
Major show-stoppers to the next official release:
- we need to work on GB core improvements: LY=153/0 case, multiple STAT
IRQs case, GBC audio output regs, etc.
- we need to re-add software cursors for light guns (Super Scope,
Justifier)
- after the above, we need to fix the turbo button for the Super Scope
I really have no idea how I want to implement the light guns. Ideally,
we'd want it in higan/video, so we can support the NES Zapper with the
same code. But this isn't going to be easy, because only the SNES knows
when its output is interlaced, and its resolutions can vary as
{256,512}x{224,240,448,480} which requires pixel doubling that was
hard-coded to the SNES-specific behavior, but isn't appropriate to be
exposed in higan/video.
2016-05-25 11:13:02 +00:00
|
|
|
r.pc.d = 0x000000;
|
|
|
|
r.x.h = 0x00;
|
|
|
|
r.y.h = 0x00;
|
|
|
|
r.s.h = 0x01;
|
|
|
|
r.d = 0x0000;
|
|
|
|
r.db = 0x00;
|
|
|
|
r.p = 0x34;
|
|
|
|
r.e = 1;
|
|
|
|
r.mdr = 0x00;
|
|
|
|
r.wai = false;
|
|
|
|
r.vector = 0x0000;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-05 05:03:21 +00:00
|
|
|
status.counter = 0;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-05 05:03:21 +00:00
|
|
|
status.interruptPending = false;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
status.scanlines = (system.region() == System::Region::NTSC ? 262 : 312);
|
|
|
|
status.vcounter = 0;
|
|
|
|
status.hcounter = 0;
|
|
|
|
|
|
|
|
dma.line = 0;
|
|
|
|
|
|
|
|
//$2200 CCNT
|
|
|
|
mmio.sa1_irq = false;
|
|
|
|
mmio.sa1_rdyb = false;
|
|
|
|
mmio.sa1_resb = true;
|
|
|
|
mmio.sa1_nmi = false;
|
|
|
|
mmio.smeg = 0;
|
|
|
|
|
|
|
|
//$2201 SIE
|
|
|
|
mmio.cpu_irqen = false;
|
|
|
|
mmio.chdma_irqen = false;
|
|
|
|
|
|
|
|
//$2202 SIC
|
|
|
|
mmio.cpu_irqcl = false;
|
|
|
|
mmio.chdma_irqcl = false;
|
|
|
|
|
|
|
|
//$2203,$2204 CRV
|
|
|
|
mmio.crv = 0x0000;
|
|
|
|
|
|
|
|
//$2205,$2206 CNV
|
|
|
|
mmio.cnv = 0x0000;
|
|
|
|
|
|
|
|
//$2207,$2208 CIV
|
|
|
|
mmio.civ = 0x0000;
|
|
|
|
|
|
|
|
//$2209 SCNT
|
|
|
|
mmio.cpu_irq = false;
|
|
|
|
mmio.cpu_ivsw = false;
|
|
|
|
mmio.cpu_nvsw = false;
|
|
|
|
mmio.cmeg = 0;
|
|
|
|
|
|
|
|
//$220a CIE
|
|
|
|
mmio.sa1_irqen = false;
|
|
|
|
mmio.timer_irqen = false;
|
|
|
|
mmio.dma_irqen = false;
|
|
|
|
mmio.sa1_nmien = false;
|
|
|
|
|
|
|
|
//$220b CIC
|
|
|
|
mmio.sa1_irqcl = false;
|
|
|
|
mmio.timer_irqcl = false;
|
|
|
|
mmio.dma_irqcl = false;
|
|
|
|
mmio.sa1_nmicl = false;
|
|
|
|
|
|
|
|
//$220c,$220d SNV
|
|
|
|
mmio.snv = 0x0000;
|
|
|
|
|
|
|
|
//$220e,$220f SIV
|
|
|
|
mmio.siv = 0x0000;
|
|
|
|
|
|
|
|
//$2210
|
|
|
|
mmio.hvselb = false;
|
|
|
|
mmio.ven = false;
|
|
|
|
mmio.hen = false;
|
|
|
|
|
|
|
|
//$2212,$2213 HCNT
|
|
|
|
mmio.hcnt = 0x0000;
|
|
|
|
|
|
|
|
//$2214,$2215 VCNT
|
|
|
|
mmio.vcnt = 0x0000;
|
|
|
|
|
|
|
|
//$2220-2223 CXB, DXB, EXB, FXB
|
2012-05-12 02:34:35 +00:00
|
|
|
mmio.cbmode = 0;
|
|
|
|
mmio.dbmode = 0;
|
|
|
|
mmio.ebmode = 0;
|
|
|
|
mmio.fbmode = 0;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
mmio.cb = 0x00;
|
|
|
|
mmio.db = 0x01;
|
2012-05-12 02:34:35 +00:00
|
|
|
mmio.eb = 0x02;
|
|
|
|
mmio.fb = 0x03;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
//$2224 BMAPS
|
|
|
|
mmio.sbm = 0x00;
|
|
|
|
|
|
|
|
//$2225 BMAP
|
|
|
|
mmio.sw46 = false;
|
|
|
|
mmio.cbm = 0x00;
|
|
|
|
|
|
|
|
//$2226 SWBE
|
|
|
|
mmio.swen = false;
|
|
|
|
|
|
|
|
//$2227 CWBE
|
|
|
|
mmio.cwen = false;
|
|
|
|
|
|
|
|
//$2228 BWPA
|
|
|
|
mmio.bwp = 0x0f;
|
|
|
|
|
|
|
|
//$2229 SIWP
|
|
|
|
mmio.siwp = 0x00;
|
|
|
|
|
|
|
|
//$222a CIWP
|
|
|
|
mmio.ciwp = 0x00;
|
|
|
|
|
|
|
|
//$2230 DCNT
|
|
|
|
mmio.dmaen = false;
|
|
|
|
mmio.dprio = false;
|
|
|
|
mmio.cden = false;
|
|
|
|
mmio.cdsel = false;
|
|
|
|
mmio.dd = 0;
|
|
|
|
mmio.sd = 0;
|
|
|
|
|
|
|
|
//$2231 CDMA
|
|
|
|
mmio.chdend = false;
|
|
|
|
mmio.dmasize = 0;
|
|
|
|
mmio.dmacb = 0;
|
|
|
|
|
|
|
|
//$2232-$2234 SDA
|
|
|
|
mmio.dsa = 0x000000;
|
|
|
|
|
|
|
|
//$2235-$2237 DDA
|
|
|
|
mmio.dda = 0x000000;
|
|
|
|
|
|
|
|
//$2238,$2239 DTC
|
|
|
|
mmio.dtc = 0x0000;
|
|
|
|
|
|
|
|
//$223f BBF
|
|
|
|
mmio.bbf = 0;
|
|
|
|
|
|
|
|
//$2240-$224f BRF
|
2016-06-05 05:03:21 +00:00
|
|
|
for(auto& n : mmio.brf) n = 0x00;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
//$2250 MCNT
|
|
|
|
mmio.acm = 0;
|
|
|
|
mmio.md = 0;
|
|
|
|
|
|
|
|
//$2251,$2252 MA
|
|
|
|
mmio.ma = 0x0000;
|
|
|
|
|
|
|
|
//$2253,$2254 MB
|
|
|
|
mmio.mb = 0x0000;
|
|
|
|
|
|
|
|
//$2258 VBD
|
|
|
|
mmio.hl = false;
|
|
|
|
mmio.vb = 16;
|
|
|
|
|
|
|
|
//$2259-$225b
|
|
|
|
mmio.va = 0x000000;
|
|
|
|
mmio.vbit = 0;
|
|
|
|
|
|
|
|
//$2300 SFR
|
|
|
|
mmio.cpu_irqfl = false;
|
|
|
|
mmio.chdma_irqfl = false;
|
|
|
|
|
|
|
|
//$2301 CFR
|
|
|
|
mmio.sa1_irqfl = false;
|
|
|
|
mmio.timer_irqfl = false;
|
|
|
|
mmio.dma_irqfl = false;
|
|
|
|
mmio.sa1_nmifl = false;
|
|
|
|
|
|
|
|
//$2302,$2303 HCR
|
|
|
|
mmio.hcr = 0x0000;
|
|
|
|
|
|
|
|
//$2304,$2305 VCR
|
|
|
|
mmio.vcr = 0x0000;
|
|
|
|
|
|
|
|
//$2306-$230a MR
|
|
|
|
mmio.mr = 0;
|
|
|
|
|
|
|
|
//$230b
|
|
|
|
mmio.overflow = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|