2017-10-02 09:12:25 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "CharacterDefinition.h"
|
|
|
|
|
2017-10-04 14:37:11 +00:00
|
|
|
#include <Ram.h>
|
2017-10-02 09:12:25 +00:00
|
|
|
|
2018-06-24 19:58:20 +00:00
|
|
|
EightBit::GameBoy::CharacterDefinition::CharacterDefinition(Ram& vram, const uint16_t address)
|
2018-05-02 01:47:47 +00:00
|
|
|
: m_vram(vram),
|
2017-10-22 20:25:06 +00:00
|
|
|
m_address(address) {
|
2017-10-02 09:12:25 +00:00
|
|
|
}
|
|
|
|
|
2018-06-24 19:58:20 +00:00
|
|
|
std::array<int, 8> EightBit::GameBoy::CharacterDefinition::get(int row) {
|
2017-10-02 09:12:25 +00:00
|
|
|
|
|
|
|
std::array<int, 8> returned;
|
|
|
|
|
2017-10-23 23:04:13 +00:00
|
|
|
const auto planeAddress = m_address + row * 2;
|
2017-10-02 09:12:25 +00:00
|
|
|
|
2018-05-02 01:47:47 +00:00
|
|
|
const auto planeLow = m_vram.peek(planeAddress);
|
|
|
|
const auto planeHigh = m_vram.peek(planeAddress + 1);
|
2017-10-02 09:12:25 +00:00
|
|
|
|
|
|
|
for (int bit = 0; bit < 8; ++bit) {
|
|
|
|
|
2017-10-23 23:04:13 +00:00
|
|
|
const auto mask = 1 << bit;
|
2017-10-02 09:12:25 +00:00
|
|
|
|
2017-10-23 23:04:13 +00:00
|
|
|
const auto bitLow = planeLow & mask ? 1 : 0;
|
|
|
|
const auto bitHigh = planeHigh & mask ? 0b10 : 0;
|
2017-10-02 09:12:25 +00:00
|
|
|
|
2017-10-23 23:04:13 +00:00
|
|
|
const auto colour = bitHigh | bitLow;
|
2017-10-02 09:12:25 +00:00
|
|
|
|
|
|
|
returned[7 - bit] = colour;
|
|
|
|
}
|
|
|
|
|
|
|
|
return returned;
|
|
|
|
}
|