EightBit/LR35902/inc/ObjectAttribute.h
Adrian Conlon 9796f9d600 First stab at associating the "Display" class more closely with the Bus.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2017-10-04 15:37:11 +01:00

42 lines
1.1 KiB
C++

#pragma once
#include <cstdint>
#include <Ram.h>
#include <Processor.h>
namespace EightBit {
namespace GameBoy {
class ObjectAttribute {
public:
ObjectAttribute() {}
ObjectAttribute(Ram& ram, uint16_t address, int height) {
m_positionY = ram.peek(address);
m_positionX = ram.peek(address + 1);
m_pattern = ram.peek(address + 2);
if (height == 16)
m_pattern >>= 1;
m_flags = ram.peek(address + 3);
}
uint8_t positionY() const { return m_positionY; }
uint8_t positionX() const { return m_positionX; }
uint8_t pattern() const { return m_pattern; }
uint8_t flags() const { return m_flags; }
uint8_t priority() const { return flags() & Processor::Bit7; }
bool highPriority() const { return priority() != 0; }
bool lowPriority() const { return priority() == 0; }
bool flipY() const { return (flags() & Processor::Bit6) != 0; }
bool flipX() const { return (flags() & Processor::Bit5) != 0; }
int palette() const { return (flags() & Processor::Bit4) >> 3; }
private:
uint8_t m_positionY;
uint8_t m_positionX;
uint8_t m_pattern;
uint8_t m_flags;
};
}
}