2016-04-09 05:20:41 +00:00
|
|
|
struct PPU : Thread, PPUcounter {
|
|
|
|
alwaysinline auto interlace() const -> bool { return display.interlace; }
|
|
|
|
alwaysinline auto overscan() const -> bool { return display.overscan; }
|
|
|
|
alwaysinline auto vdisp() const -> uint { return !regs.overscan ? 225 : 240; }
|
|
|
|
|
2010-08-09 13:33:44 +00:00
|
|
|
PPU();
|
|
|
|
~PPU();
|
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
alwaysinline auto step(uint clocks) -> void;
|
|
|
|
alwaysinline auto synchronizeCPU() -> void;
|
|
|
|
|
2016-04-09 05:20:41 +00:00
|
|
|
static auto Enter() -> void;
|
2016-02-09 11:51:12 +00:00
|
|
|
auto main() -> void;
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
2016-04-09 05:20:41 +00:00
|
|
|
//memory.cpp
|
|
|
|
alwaysinline auto getVramAddress() -> uint16;
|
|
|
|
alwaysinline auto vramRead(uint addr) -> uint8;
|
|
|
|
alwaysinline auto vramWrite(uint addr, uint8 data) -> void;
|
|
|
|
alwaysinline auto oamRead(uint addr) -> uint8;
|
|
|
|
alwaysinline auto oamWrite(uint addr, uint8 data) -> void;
|
|
|
|
alwaysinline auto cgramRead(uint addr) -> uint8;
|
|
|
|
alwaysinline auto cgramWrite(uint addr, uint8 data) -> void;
|
|
|
|
|
|
|
|
//mmio.cpp
|
|
|
|
auto read(uint24 addr, uint8 data) -> uint8;
|
|
|
|
auto write(uint24 addr, uint8 data) -> void;
|
|
|
|
auto latchCounters() -> void;
|
|
|
|
auto updateVideoMode() -> void;
|
|
|
|
|
2016-02-16 09:27:55 +00:00
|
|
|
uint8 vram[64 * 1024];
|
|
|
|
uint8 oam[544];
|
|
|
|
uint8 cgram[512];
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
|
2012-02-09 12:53:55 +00:00
|
|
|
privileged:
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
uint ppu1_version = 1; //allowed: 1
|
|
|
|
uint ppu2_version = 3; //allowed: 1, 2, 3
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
uint32* output = nullptr;
|
Update to v068r12 release.
(there was no r11 release posted to the WIP thread)
byuu says:
This took ten hours of mind boggling insanity to pull off.
It upgrades the S-PPU dot-based renderer to fetch one tile, and then
output all of its pixels before fetching again. It sounds easy enough,
but it's insanely difficult. I ended up taking one small shortcut, in
that rather than fetch at -7, I fetch at the first instance where a tile
is needed to plot to x=0. So if you have {-3 to +4 } as a tile, it
fetches at -3. That won't work so well on hardware, if two BGs fetch at
the same X offset, they won't have time.
I have had no luck staggering the reads at BG1=-7, BG3=-5, etc. While
I can shift and fetch just fine, what happens is that when a new tile is
fetched in, that gives a new palette, priority, etc; and this ends up
happening between two tiles which results in the right-most edges of the
screen ending up with the wrong colors and such.
Offset-per-tile is cheap as always. Although looking at it, I'm not sure
how BG3 could pre-fetch, especially with the way one or two OPT modes
can fetch two tiles.
There's no magic in Hoffset caching yet, so the SMW1 pixel issue is
still there.
Mode 7 got a bugfix, it was off-by-one horizontally from the mosaic
code. After re-designing the BG mosaic, I ended up needing a separate
mosaic for Mode7, and in the process I fixed that bug. The obvious
change is that the Chrono Trigger Mode7->Mode2 transition doesn't cause
the pendulum to jump anymore.
Windows were simplified just a tad. The range testing is shared for all
modes now. Ironically, it's a bit slower, but I'll take less code over
more speed for the accuracy core.
Speaking of speed, because there's so much less calculations per pixel
for BGs, performance for the entire emulator has gone up by 30% in the
accuracy core. Pretty neat overall, I can maintain 60fps in all but,
yeah you can guess can't you?
2010-09-04 03:36:03 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
bool interlace;
|
|
|
|
bool overscan;
|
|
|
|
} display;
|
|
|
|
|
2016-04-09 05:20:41 +00:00
|
|
|
alwaysinline auto addClocks(uint) -> void;
|
|
|
|
|
|
|
|
auto scanline() -> void;
|
|
|
|
auto frame() -> void;
|
Update to v098r06 release.
byuu says:
Changelog:
- emulation cores now refresh video from host thread instead of
cothreads (fix AMD crash)
- SFC: fixed another bug with leap year months in SharpRTC emulation
- SFC: cleaned up camelCase on function names for
armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes
- GB: added MBC1M emulation (requires manually setting mapper=MBC1M in
manifest.bml for now, sorry)
- audio: implemented Emulator::Audio mixer and effects processor
- audio: implemented Emulator::Stream interface
- it is now possible to have more than two audio streams: eg SNES
+ SGB + MSU1 + Voicer-Kun (eventually)
- audio: added reverb delay + reverb level settings; exposed balance
configuration in UI
- video: reworked palette generation to re-enable saturation, gamma,
luminance adjustments
- higan/emulator.cpp is gone since there was nothing left in it
I know you guys are going to say the color adjust/balance/reverb stuff
is pointless. And indeed it mostly is. But I like the idea of allowing
some fun special effects and configurability that isn't system-wide.
Note: there seems to be some kind of added audio lag in the SGB
emulation now, and I don't really understand why. The code should be
effectively identical to what I had before. The only main thing is that
I'm sampling things to 48000hz instead of 32040hz before mixing. There's
no point where I'm intentionally introducing added latency though. I'm
kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be
much appreciated :/
I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as
well, and that would be very bad.
2016-04-22 13:35:51 +00:00
|
|
|
auto refresh() -> void;
|
2016-04-09 05:20:41 +00:00
|
|
|
|
|
|
|
struct Registers {
|
|
|
|
uint8 ppu1_mdr;
|
|
|
|
uint8 ppu2_mdr;
|
|
|
|
|
|
|
|
uint16 vram_readbuffer;
|
|
|
|
uint8 oam_latchdata;
|
|
|
|
uint8 cgram_latchdata;
|
|
|
|
uint8 bgofs_latchdata;
|
|
|
|
uint8 mode7_latchdata;
|
|
|
|
bool counters_latched;
|
|
|
|
bool latch_hcounter;
|
|
|
|
bool latch_vcounter;
|
|
|
|
|
|
|
|
uint10 oam_iaddr;
|
|
|
|
uint9 cgram_iaddr;
|
|
|
|
|
|
|
|
//$2100 INIDISP
|
|
|
|
bool display_disable;
|
|
|
|
uint4 display_brightness;
|
|
|
|
|
|
|
|
//$2102 OAMADDL
|
|
|
|
//$2103 OAMADDH
|
|
|
|
uint10 oam_baseaddr;
|
|
|
|
uint10 oam_addr;
|
|
|
|
bool oam_priority;
|
|
|
|
|
|
|
|
//$2105 BGMODE
|
|
|
|
bool bg3_priority;
|
|
|
|
uint8 bgmode;
|
|
|
|
|
|
|
|
//$210d BG1HOFS
|
|
|
|
uint16 mode7_hoffset;
|
|
|
|
|
|
|
|
//$210e BG1VOFS
|
|
|
|
uint16 mode7_voffset;
|
|
|
|
|
|
|
|
//$2115 VMAIN
|
|
|
|
bool vram_incmode;
|
|
|
|
uint2 vram_mapping;
|
|
|
|
uint8 vram_incsize;
|
|
|
|
|
|
|
|
//$2116 VMADDL
|
|
|
|
//$2117 VMADDH
|
|
|
|
uint16 vram_addr;
|
|
|
|
|
|
|
|
//$211a M7SEL
|
|
|
|
uint2 mode7_repeat;
|
|
|
|
bool mode7_vflip;
|
|
|
|
bool mode7_hflip;
|
|
|
|
|
|
|
|
//$211b M7A
|
|
|
|
uint16 m7a;
|
|
|
|
|
|
|
|
//$211c M7B
|
|
|
|
uint16 m7b;
|
|
|
|
|
|
|
|
//$211d M7C
|
|
|
|
uint16 m7c;
|
|
|
|
|
|
|
|
//$211e M7D
|
|
|
|
uint16 m7d;
|
|
|
|
|
|
|
|
//$211f M7X
|
|
|
|
uint16 m7x;
|
|
|
|
|
|
|
|
//$2120 M7Y
|
|
|
|
uint16 m7y;
|
|
|
|
|
|
|
|
//$2121 CGADD
|
|
|
|
uint9 cgram_addr;
|
|
|
|
|
|
|
|
//$2133 SETINI
|
|
|
|
bool mode7_extbg;
|
|
|
|
bool pseudo_hires;
|
|
|
|
bool overscan;
|
|
|
|
bool interlace;
|
|
|
|
|
|
|
|
//$213c OPHCT
|
|
|
|
uint16 hcounter;
|
|
|
|
|
|
|
|
//$213d OPVCT
|
|
|
|
uint16 vcounter;
|
|
|
|
} regs;
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#include "background/background.hpp"
|
|
|
|
#include "screen/screen.hpp"
|
|
|
|
#include "sprite/sprite.hpp"
|
|
|
|
#include "window/window.hpp"
|
|
|
|
|
|
|
|
Background bg1;
|
|
|
|
Background bg2;
|
|
|
|
Background bg3;
|
|
|
|
Background bg4;
|
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
|
|
|
Sprite sprite;
|
2010-08-09 13:28:56 +00:00
|
|
|
Window window;
|
|
|
|
Screen screen;
|
|
|
|
|
2010-08-09 13:33:44 +00:00
|
|
|
friend class PPU::Background;
|
|
|
|
friend class PPU::Sprite;
|
|
|
|
friend class PPU::Window;
|
|
|
|
friend class PPU::Screen;
|
Update to v098r06 release.
byuu says:
Changelog:
- emulation cores now refresh video from host thread instead of
cothreads (fix AMD crash)
- SFC: fixed another bug with leap year months in SharpRTC emulation
- SFC: cleaned up camelCase on function names for
armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes
- GB: added MBC1M emulation (requires manually setting mapper=MBC1M in
manifest.bml for now, sorry)
- audio: implemented Emulator::Audio mixer and effects processor
- audio: implemented Emulator::Stream interface
- it is now possible to have more than two audio streams: eg SNES
+ SGB + MSU1 + Voicer-Kun (eventually)
- audio: added reverb delay + reverb level settings; exposed balance
configuration in UI
- video: reworked palette generation to re-enable saturation, gamma,
luminance adjustments
- higan/emulator.cpp is gone since there was nothing left in it
I know you guys are going to say the color adjust/balance/reverb stuff
is pointless. And indeed it mostly is. But I like the idea of allowing
some fun special effects and configurability that isn't system-wide.
Note: there seems to be some kind of added audio lag in the SGB
emulation now, and I don't really understand why. The code should be
effectively identical to what I had before. The only main thing is that
I'm sampling things to 48000hz instead of 32040hz before mixing. There's
no point where I'm intentionally introducing added latency though. I'm
kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be
much appreciated :/
I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as
well, and that would be very bad.
2016-04-22 13:35:51 +00:00
|
|
|
friend class Scheduler;
|
2012-02-09 12:53:55 +00:00
|
|
|
|
|
|
|
struct Debugger {
|
2016-02-18 10:32:22 +00:00
|
|
|
hook<auto (uint16, uint8) -> void> vram_read;
|
|
|
|
hook<auto (uint16, uint8) -> void> oam_read;
|
|
|
|
hook<auto (uint16, uint8) -> void> cgram_read;
|
|
|
|
hook<auto (uint16, uint8) -> void> vram_write;
|
|
|
|
hook<auto (uint16, uint8) -> void> oam_write;
|
|
|
|
hook<auto (uint16, uint8) -> void> cgram_write;
|
2012-02-09 12:53:55 +00:00
|
|
|
} debugger;
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
|
|
|
|
Update to v085r03 release.
byuu says:
Changelog:
- fixed cursor being visible under Metacity window manager (hopefully
doesn't cause regression with other WMs)
- show normal cursor when using SDL video driver
- added menu accelerators (meh, why not?)
- removed debugvirtual, ChipDebugger and chip/debugger functionality
entirely
- alt/smp disassembler moved up
- fixed alt/smp incw/decw instructions (unsigned->uint16 for internal
variables)
My plan going forward for a debugger is not to hardcode functionality
that causes the 10-15% slowdown right into the emulator itself.
Instead, I'm going to make a callback class, which will be a specialized
version of nall::function:
- can call function even if not assigned (results in no-op, return type
must have a trivial default constructor)
- if compiled without #define DEBUGGER, the entire thing turns into
a huge no-op; and will be eliminated entirely when compiled
- strategically place the functions: cb_step, cb_read, cb_write, etc.
From here, the ui-debugger GUI will bind the callbacks, implement
breakpoint checking, usage table generation, etc itself.
I'll probably have to add some breakout commands to exit the emulation
core prior to a frame event in some cases as well.
I didn't initially want any debugger-related stuff in the base cores,
but the #if debugger sCPUDebugger #else sCPU #endif stuff was already
more of a burden than this will be.
2012-02-04 09:23:53 +00:00
|
|
|
extern PPU ppu;
|