2017-08-29 21:23:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-09-15 17:23:02 +00:00
|
|
|
#include <array>
|
2017-08-29 21:23:32 +00:00
|
|
|
#include <cstdint>
|
|
|
|
|
2017-10-01 10:32:41 +00:00
|
|
|
#include "ObjectAttribute.h"
|
2017-08-29 21:23:32 +00:00
|
|
|
|
|
|
|
namespace EightBit {
|
2017-10-19 21:43:09 +00:00
|
|
|
|
|
|
|
class Ram;
|
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
namespace GameBoy {
|
2017-09-15 17:23:02 +00:00
|
|
|
|
2017-10-19 21:43:09 +00:00
|
|
|
class AbstractColourPalette;
|
2017-09-15 17:23:02 +00:00
|
|
|
class CharacterDefinition;
|
2017-10-19 21:43:09 +00:00
|
|
|
class Bus;
|
2017-09-15 17:23:02 +00:00
|
|
|
|
2018-05-02 01:47:47 +00:00
|
|
|
class Display final {
|
2017-09-07 00:15:28 +00:00
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
BufferWidth = 256,
|
|
|
|
BufferHeight = 256,
|
|
|
|
BufferCharacterWidth = BufferWidth / 8,
|
|
|
|
BufferCharacterHeight = BufferHeight / 8,
|
|
|
|
RasterWidth = 160,
|
|
|
|
RasterHeight = 144,
|
2018-05-04 02:38:39 +00:00
|
|
|
PixelCount = RasterWidth * RasterHeight,
|
2017-09-07 00:15:28 +00:00
|
|
|
};
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2017-11-20 19:17:49 +00:00
|
|
|
Display(const AbstractColourPalette* colours, Bus& bus, Ram& oam, Ram& vram);
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2018-05-04 02:38:39 +00:00
|
|
|
const std::array<uint32_t, PixelCount>& pixels() const;
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
void render();
|
2017-10-01 10:32:41 +00:00
|
|
|
void loadObjectAttributes();
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
private:
|
2018-08-11 20:19:19 +00:00
|
|
|
std::array<uint32_t, PixelCount> m_pixels = { 0 };
|
2017-09-07 00:15:28 +00:00
|
|
|
Bus& m_bus;
|
2017-10-04 17:00:53 +00:00
|
|
|
Ram& m_oam;
|
|
|
|
Ram& m_vram;
|
2017-09-07 00:15:28 +00:00
|
|
|
const AbstractColourPalette* m_colours;
|
2018-08-11 20:19:19 +00:00
|
|
|
std::array<ObjectAttribute, 40> m_objectAttributes = { ObjectAttribute() };
|
2017-11-11 11:12:09 +00:00
|
|
|
uint8_t m_control = 0;
|
|
|
|
uint8_t m_scanLine = 0;
|
2017-09-15 16:25:55 +00:00
|
|
|
|
|
|
|
std::array<int, 4> createPalette(int address);
|
|
|
|
|
|
|
|
void renderBackground();
|
|
|
|
void renderBackground(
|
|
|
|
int bgArea, int bgCharacters,
|
|
|
|
int offsetX, int offsetY,
|
|
|
|
const std::array<int, 4>& palette);
|
|
|
|
|
|
|
|
void renderObjects();
|
2017-09-15 17:23:02 +00:00
|
|
|
|
|
|
|
void renderTile(
|
2017-09-17 08:46:28 +00:00
|
|
|
int height,
|
2017-10-02 14:28:41 +00:00
|
|
|
int drawX, int drawY,
|
2017-09-15 17:23:02 +00:00
|
|
|
bool flipX, bool flipY, bool allowTransparencies,
|
|
|
|
const std::array<int, 4>& palette,
|
2018-06-24 19:58:20 +00:00
|
|
|
CharacterDefinition& definition);
|
2017-09-07 00:15:28 +00:00
|
|
|
};
|
|
|
|
}
|
2017-08-29 21:23:32 +00:00
|
|
|
}
|