2012-04-26 10:51:13 +00:00
|
|
|
struct CPU : Processor::LR35902, Thread, MMIO {
|
2015-11-21 07:36:48 +00:00
|
|
|
enum class Interrupt : uint { Vblank, Stat, Timer, Serial, Joypad };
|
|
|
|
|
2016-02-09 11:51:12 +00:00
|
|
|
static auto Enter() -> void;
|
2015-11-21 07:36:48 +00:00
|
|
|
auto main() -> void;
|
2016-06-05 22:10:01 +00:00
|
|
|
auto raise(Interrupt id) -> void;
|
2016-06-28 10:43:47 +00:00
|
|
|
auto interruptTest() -> void;
|
2015-11-21 07:36:48 +00:00
|
|
|
auto stop() -> bool;
|
|
|
|
auto power() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
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
|
|
|
//io.cpp
|
2016-06-28 10:43:47 +00:00
|
|
|
auto wramAddress(uint16 addr) const -> uint;
|
|
|
|
auto joypPoll() -> void;
|
|
|
|
auto readIO(uint16 addr) -> uint8;
|
|
|
|
auto writeIO(uint16 addr, uint8 data) -> void;
|
2015-11-21 07:36:48 +00:00
|
|
|
|
|
|
|
//memory.cpp
|
2016-06-05 22:10:01 +00:00
|
|
|
auto io() -> void override;
|
|
|
|
auto read(uint16 addr) -> uint8 override;
|
|
|
|
auto write(uint16 addr, uint8 data) -> void override;
|
2016-06-28 10:43:47 +00:00
|
|
|
auto cycleEdge() -> void;
|
|
|
|
auto readDMA(uint16 addr) -> uint8;
|
|
|
|
auto writeDMA(uint16 addr, uint8 data) -> void;
|
|
|
|
auto readDebugger(uint16 addr) -> uint8;
|
2015-11-21 07:36:48 +00:00
|
|
|
|
|
|
|
//timing.cpp
|
2016-06-28 10:43:47 +00:00
|
|
|
auto step(uint clocks) -> void;
|
|
|
|
auto timer262144hz() -> void;
|
|
|
|
auto timer65536hz() -> void;
|
|
|
|
auto timer16384hz() -> void;
|
|
|
|
auto timer8192hz() -> void;
|
|
|
|
auto timer4096hz() -> void;
|
2015-11-21 07:36:48 +00:00
|
|
|
auto hblank() -> void;
|
2011-01-02 04:46:54 +00:00
|
|
|
|
2010-12-28 06:03:02 +00:00
|
|
|
struct Status {
|
2016-01-11 10:31:30 +00:00
|
|
|
uint22 clock;
|
2010-12-30 07:18:47 +00:00
|
|
|
|
|
|
|
//$ff00 JOYP
|
|
|
|
bool p15;
|
|
|
|
bool p14;
|
2010-12-31 05:43:47 +00:00
|
|
|
uint8 joyp;
|
2016-06-28 10:43:47 +00:00
|
|
|
uint8 mltReq;
|
2010-12-30 07:18:47 +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
|
|
|
//$ff01 SB
|
2016-06-28 10:43:47 +00:00
|
|
|
uint8 serialData;
|
|
|
|
uint serialBits;
|
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
|
|
|
|
|
|
|
//$ff02 SC
|
2016-06-28 10:43:47 +00:00
|
|
|
bool serialTransfer;
|
|
|
|
bool serialClock;
|
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
|
|
|
|
2010-12-30 07:18:47 +00:00
|
|
|
//$ff04 DIV
|
2016-01-11 10:31:30 +00:00
|
|
|
uint16 div;
|
2010-12-30 07:18:47 +00:00
|
|
|
|
|
|
|
//$ff05 TIMA
|
|
|
|
uint8 tima;
|
|
|
|
|
|
|
|
//$ff06 TMA
|
|
|
|
uint8 tma;
|
|
|
|
|
|
|
|
//$ff07 TAC
|
2016-06-28 10:43:47 +00:00
|
|
|
bool timerEnable;
|
|
|
|
uint timerClock;
|
2010-12-30 07:18:47 +00:00
|
|
|
|
|
|
|
//$ff0f IF
|
2016-06-28 10:43:47 +00:00
|
|
|
bool interruptRequestJoypad;
|
|
|
|
bool interruptRequestSerial;
|
|
|
|
bool interruptRequestTimer;
|
|
|
|
bool interruptRequestStat;
|
|
|
|
bool interruptRequestVblank;
|
2010-12-30 07:18:47 +00:00
|
|
|
|
2011-10-27 00:00:17 +00:00
|
|
|
//$ff4d KEY1
|
2016-06-28 10:43:47 +00:00
|
|
|
bool speedDouble;
|
|
|
|
bool speedSwitch;
|
2011-10-27 00:00:17 +00:00
|
|
|
|
|
|
|
//$ff51,$ff52 HDMA1,HDMA2
|
2016-06-28 10:43:47 +00:00
|
|
|
uint16 dmaSource;
|
2011-10-27 00:00:17 +00:00
|
|
|
|
|
|
|
//$ff53,$ff54 HDMA3,HDMA4
|
2016-06-28 10:43:47 +00:00
|
|
|
uint16 dmaTarget;
|
2011-10-27 00:00:17 +00:00
|
|
|
|
|
|
|
//$ff55 HDMA5
|
2016-06-28 10:43:47 +00:00
|
|
|
bool dmaMode;
|
|
|
|
uint16 dmaLength;
|
|
|
|
bool dmaCompleted;
|
2011-10-27 00:00:17 +00:00
|
|
|
|
|
|
|
//$ff6c ???
|
|
|
|
uint8 ff6c;
|
|
|
|
|
|
|
|
//$ff70 SVBK
|
2016-06-28 10:43:47 +00:00
|
|
|
uint3 wramBank;
|
2011-10-27 00:00:17 +00:00
|
|
|
|
|
|
|
//$ff72-$ff75 ???
|
|
|
|
uint8 ff72;
|
|
|
|
uint8 ff73;
|
|
|
|
uint8 ff74;
|
|
|
|
uint8 ff75;
|
|
|
|
|
2010-12-30 07:18:47 +00:00
|
|
|
//$ffff IE
|
2016-06-28 10:43:47 +00:00
|
|
|
bool interruptEnableJoypad;
|
|
|
|
bool interruptEnableSerial;
|
|
|
|
bool interruptEnableTimer;
|
|
|
|
bool interruptEnableStat;
|
|
|
|
bool interruptEnableVblank;
|
2010-12-28 06:03:02 +00:00
|
|
|
} status;
|
|
|
|
|
2011-10-27 00:00:17 +00:00
|
|
|
uint8 wram[32768]; //GB=8192, GBC=32768
|
2010-12-29 11:03:42 +00:00
|
|
|
uint8 hram[128];
|
2010-12-28 01:53:15 +00:00
|
|
|
};
|
|
|
|
|
2011-01-22 08:15:49 +00:00
|
|
|
extern CPU cpu;
|