2010-12-29 11:03:42 +00:00
|
|
|
struct CPU : Processor, MMIO {
|
2010-12-28 06:03:02 +00:00
|
|
|
#include "core/core.hpp"
|
2010-12-29 11:03:42 +00:00
|
|
|
#include "mmio/mmio.hpp"
|
2010-12-28 06:03:02 +00:00
|
|
|
#include "timing/timing.hpp"
|
2010-12-28 01:53:15 +00:00
|
|
|
|
2011-01-04 10:42:27 +00:00
|
|
|
bool trace;
|
|
|
|
|
2011-01-02 04:46:54 +00:00
|
|
|
enum class Interrupt : unsigned {
|
|
|
|
Vblank,
|
|
|
|
Stat,
|
|
|
|
Timer,
|
|
|
|
Serial,
|
|
|
|
Joypad,
|
|
|
|
};
|
|
|
|
|
2010-12-28 06:03:02 +00:00
|
|
|
struct Status {
|
2011-01-04 10:42:27 +00:00
|
|
|
unsigned clock;
|
2011-01-02 04:46:54 +00:00
|
|
|
bool halt;
|
|
|
|
bool stop;
|
|
|
|
|
2010-12-29 11:03:42 +00:00
|
|
|
bool ime;
|
2010-12-30 07:18:47 +00:00
|
|
|
unsigned timer0;
|
|
|
|
unsigned timer1;
|
|
|
|
unsigned timer2;
|
|
|
|
unsigned timer3;
|
|
|
|
|
|
|
|
//$ff00 JOYP
|
|
|
|
bool p15;
|
|
|
|
bool p14;
|
2010-12-31 05:43:47 +00:00
|
|
|
uint8 joyp;
|
2011-01-06 10:16:07 +00:00
|
|
|
uint8 mlt_req;
|
2010-12-30 07:18:47 +00:00
|
|
|
|
|
|
|
//$ff04 DIV
|
|
|
|
uint8 div;
|
|
|
|
|
|
|
|
//$ff05 TIMA
|
|
|
|
uint8 tima;
|
|
|
|
|
|
|
|
//$ff06 TMA
|
|
|
|
uint8 tma;
|
|
|
|
|
|
|
|
//$ff07 TAC
|
|
|
|
bool timer_enable;
|
|
|
|
unsigned timer_clock;
|
|
|
|
|
|
|
|
//$ff0f IF
|
|
|
|
bool interrupt_request_joypad;
|
|
|
|
bool interrupt_request_serial;
|
|
|
|
bool interrupt_request_timer;
|
|
|
|
bool interrupt_request_stat;
|
|
|
|
bool interrupt_request_vblank;
|
|
|
|
|
|
|
|
//$ffff IE
|
|
|
|
bool interrupt_enable_joypad;
|
|
|
|
bool interrupt_enable_serial;
|
|
|
|
bool interrupt_enable_timer;
|
|
|
|
bool interrupt_enable_stat;
|
|
|
|
bool interrupt_enable_vblank;
|
2010-12-28 06:03:02 +00:00
|
|
|
} status;
|
|
|
|
|
2010-12-29 11:03:42 +00:00
|
|
|
uint8 wram[8192];
|
|
|
|
uint8 hram[128];
|
|
|
|
|
2010-12-28 06:03:02 +00:00
|
|
|
static void Main();
|
2010-12-28 01:53:15 +00:00
|
|
|
void main();
|
2011-01-02 04:46:54 +00:00
|
|
|
void interrupt_raise(Interrupt id);
|
2010-12-30 07:18:47 +00:00
|
|
|
void interrupt_test();
|
|
|
|
void interrupt_exec(uint16 pc);
|
2010-12-28 01:53:15 +00:00
|
|
|
void power();
|
2010-12-28 06:03:02 +00:00
|
|
|
CPU();
|
2010-12-28 01:53:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CPU cpu;
|