2017-08-29 21:23:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
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
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
class Display {
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
BufferWidth = 256,
|
|
|
|
BufferHeight = 256,
|
|
|
|
BufferCharacterWidth = BufferWidth / 8,
|
|
|
|
BufferCharacterHeight = BufferHeight / 8,
|
|
|
|
RasterWidth = 160,
|
|
|
|
RasterHeight = 144,
|
|
|
|
};
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2017-10-04 17:00:53 +00:00
|
|
|
Display(const AbstractColourPalette* colours, Bus& bus, Ram& oam, Ram& vram);
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
const std::vector<uint32_t>& pixels() const;
|
2017-08-29 21:23:32 +00:00
|
|
|
|
2017-09-07 00:15:28 +00:00
|
|
|
void initialise();
|
|
|
|
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:
|
|
|
|
std::vector<uint32_t> m_pixels;
|
|
|
|
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;
|
2017-10-01 10:32:41 +00:00
|
|
|
std::array<ObjectAttribute, 40> m_objectAttributes;
|
2017-10-03 23:30:59 +00:00
|
|
|
uint8_t m_control;
|
|
|
|
uint8_t m_scanLine;
|
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();
|
|
|
|
void renderObjects(int objBlockHeight);
|
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,
|
|
|
|
const CharacterDefinition& definition);
|
2017-09-07 00:15:28 +00:00
|
|
|
};
|
|
|
|
}
|
2017-08-29 21:23:32 +00:00
|
|
|
}
|