libgambatte/video: move m0irq to its own header
This commit is contained in:
parent
4b51300899
commit
f102bb4fc1
@ -24,6 +24,7 @@
|
|||||||
#include "osd_element.h"
|
#include "osd_element.h"
|
||||||
#include "scoped_ptr.h"
|
#include "scoped_ptr.h"
|
||||||
#include "video/lyc_irq.h"
|
#include "video/lyc_irq.h"
|
||||||
|
#include "video/m0_irq.h"
|
||||||
#include "video/next_m0_time.h"
|
#include "video/next_m0_time.h"
|
||||||
#include "video/ppu.h"
|
#include "video/ppu.h"
|
||||||
|
|
||||||
@ -44,56 +45,6 @@ private:
|
|||||||
InterruptRequester *const intreq_;
|
InterruptRequester *const intreq_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class M0Irq {
|
|
||||||
public:
|
|
||||||
M0Irq()
|
|
||||||
: statReg_(0)
|
|
||||||
, lycReg_(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcdReset(unsigned statReg, unsigned lycReg) {
|
|
||||||
statReg_ = statReg;
|
|
||||||
lycReg_ = lycReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void statRegChange(unsigned statReg,
|
|
||||||
unsigned long nextM0IrqTime, unsigned long cc, bool cgb) {
|
|
||||||
if (nextM0IrqTime - cc > cgb * 2U)
|
|
||||||
statReg_ = statReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lycRegChange(unsigned lycReg,
|
|
||||||
unsigned long nextM0IrqTime, unsigned long cc,
|
|
||||||
bool ds, bool cgb) {
|
|
||||||
if (nextM0IrqTime - cc > cgb * 5 + 1U - ds)
|
|
||||||
lycReg_ = lycReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void doEvent(unsigned char *ifreg, unsigned ly, unsigned statReg, unsigned lycReg) {
|
|
||||||
if (((statReg_ | statReg) & 0x08) && (!(statReg_ & 0x40) || ly != lycReg_))
|
|
||||||
*ifreg |= 2;
|
|
||||||
|
|
||||||
statReg_ = statReg;
|
|
||||||
lycReg_ = lycReg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveState(SaveState &state) const {
|
|
||||||
state.ppu.m0lyc = lycReg_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadState(SaveState const &state) {
|
|
||||||
lycReg_ = state.ppu.m0lyc;
|
|
||||||
statReg_ = state.mem.ioamhram.get()[0x141];
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned statReg() const { return statReg_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned char statReg_;
|
|
||||||
unsigned char lycReg_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LCD {
|
class LCD {
|
||||||
public:
|
public:
|
||||||
LCD(unsigned char const *oamram, unsigned char const *vram,
|
LCD(unsigned char const *oamram, unsigned char const *vram,
|
||||||
|
60
libgambatte/src/video/m0_irq.h
Normal file
60
libgambatte/src/video/m0_irq.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#ifndef M0_IRQ_H
|
||||||
|
#define M0_IRQ_H
|
||||||
|
|
||||||
|
#include "../savestate.h"
|
||||||
|
|
||||||
|
namespace gambatte {
|
||||||
|
|
||||||
|
class M0Irq {
|
||||||
|
public:
|
||||||
|
M0Irq()
|
||||||
|
: statReg_(0)
|
||||||
|
, lycReg_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcdReset(unsigned statReg, unsigned lycReg) {
|
||||||
|
statReg_ = statReg;
|
||||||
|
lycReg_ = lycReg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void statRegChange(unsigned statReg,
|
||||||
|
unsigned long nextM0IrqTime, unsigned long cc, bool cgb) {
|
||||||
|
if (nextM0IrqTime - cc > cgb * 2U)
|
||||||
|
statReg_ = statReg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lycRegChange(unsigned lycReg,
|
||||||
|
unsigned long nextM0IrqTime, unsigned long cc,
|
||||||
|
bool ds, bool cgb) {
|
||||||
|
if (nextM0IrqTime - cc > cgb * 5 + 1U - ds)
|
||||||
|
lycReg_ = lycReg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void doEvent(unsigned char *ifreg, unsigned ly, unsigned statReg, unsigned lycReg) {
|
||||||
|
if (((statReg_ | statReg) & 0x08) && (!(statReg_ & 0x40) || ly != lycReg_))
|
||||||
|
*ifreg |= 2;
|
||||||
|
|
||||||
|
statReg_ = statReg;
|
||||||
|
lycReg_ = lycReg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveState(SaveState &state) const {
|
||||||
|
state.ppu.m0lyc = lycReg_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadState(SaveState const &state) {
|
||||||
|
lycReg_ = state.ppu.m0lyc;
|
||||||
|
statReg_ = state.mem.ioamhram.get()[0x141];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned statReg() const { return statReg_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned char statReg_;
|
||||||
|
unsigned char lycReg_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user