2016-01-28 11:39:49 +00:00
|
|
|
struct CPU : Processor::V30MZ, Thread, IO {
|
2016-02-04 21:18:06 +00:00
|
|
|
enum class Interrupt : uint {
|
|
|
|
SerialSend,
|
|
|
|
Input,
|
|
|
|
Cartridge,
|
|
|
|
SerialReceive,
|
|
|
|
LineCompare,
|
|
|
|
VblankTimer,
|
|
|
|
Vblank,
|
|
|
|
HblankTimer,
|
|
|
|
};
|
|
|
|
|
2016-01-27 11:31:39 +00:00
|
|
|
static auto Enter() -> void;
|
|
|
|
auto main() -> void;
|
2016-01-28 11:39:49 +00:00
|
|
|
auto step(uint clocks) -> void;
|
|
|
|
|
|
|
|
auto wait(uint clocks = 1) -> void override;
|
|
|
|
auto read(uint20 addr) -> uint8 override;
|
|
|
|
auto write(uint20 addr, uint8 data) -> void override;
|
2016-01-30 06:40:35 +00:00
|
|
|
auto in(uint16 port) -> uint8 override;
|
|
|
|
auto out(uint16 port, uint8 data) -> void override;
|
2016-01-28 11:39:49 +00:00
|
|
|
|
2016-01-27 11:31:39 +00:00
|
|
|
auto power() -> void;
|
|
|
|
|
2016-02-04 10:29:08 +00:00
|
|
|
//io.cpp
|
2016-03-02 11:19:33 +00:00
|
|
|
auto keypadRead() -> uint4;
|
2016-01-30 06:40:35 +00:00
|
|
|
auto portRead(uint16 addr) -> uint8 override;
|
|
|
|
auto portWrite(uint16 addr, uint8 data) -> void override;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//interrupt.cpp
|
|
|
|
auto poll() -> void;
|
|
|
|
auto raise(Interrupt) -> void;
|
|
|
|
auto lower(Interrupt) -> void;
|
|
|
|
|
2016-02-04 10:29:08 +00:00
|
|
|
//dma.cpp
|
|
|
|
auto dmaTransfer() -> void;
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
struct Registers {
|
|
|
|
//$0040-0042 DMA_SRC
|
2016-02-04 10:29:08 +00:00
|
|
|
uint20 dmaSource;
|
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//$0044-0045 DMA_DST
|
2016-02-16 09:27:55 +00:00
|
|
|
uint16 dmaTarget;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//$0046-0047 DMA_LEN
|
2016-02-16 09:27:55 +00:00
|
|
|
uint16 dmaLength;
|
2016-02-04 10:29:08 +00:00
|
|
|
|
2016-02-04 21:18:06 +00:00
|
|
|
//$0048 DMA_CTRL
|
2016-03-02 11:19:33 +00:00
|
|
|
uint1 dmaEnable;
|
|
|
|
uint1 dmaMode; //0 = increment; 1 = decrement
|
2016-02-04 21:18:06 +00:00
|
|
|
|
|
|
|
//$00b0 INT_BASE
|
|
|
|
uint8 interruptBase;
|
|
|
|
|
|
|
|
//$00b2 INT_ENABLE
|
|
|
|
uint8 interruptEnable;
|
|
|
|
|
|
|
|
//$00b4 INT_STATUS
|
|
|
|
uint8 interruptStatus;
|
2016-03-02 11:19:33 +00:00
|
|
|
|
|
|
|
//$00b5 KEYPAD
|
|
|
|
uint1 ypadEnable;
|
|
|
|
uint1 xpadEnable;
|
|
|
|
uint1 buttonEnable;
|
2016-02-04 21:18:06 +00:00
|
|
|
} r;
|
2016-01-27 11:31:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CPU cpu;
|