cursed bit slice helper

This commit is contained in:
CocoSimone
2022-05-07 12:15:09 +02:00
parent fa13826af7
commit a2a6de65a1
3 changed files with 54 additions and 1 deletions

View File

@@ -2,5 +2,33 @@
#include <common.hpp>
namespace natsukashii::core {
struct Cpu {};
template <class A, class B>
struct RegisterPair {
A low;
B high;
auto operator=(const u16& rhs) {
low = rhs & 0xff;
high = rhs >> 8;
return *this;
}
};
union RegF {
struct {
unsigned z:1;
unsigned n:1;
unsigned h:1;
unsigned c:1;
unsigned:4;
};
u8 raw;
};
struct Cpu {
private:
RegisterPair<u8, RegF> af;
RegisterPair<u8, u8> bc;
RegisterPair<u8, u8> de;
RegisterPair<u8, u8> hl;
};
}