-
Notifications
You must be signed in to change notification settings - Fork 0
/
BbcScreen.h
75 lines (61 loc) · 2.34 KB
/
BbcScreen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright © 2010-2021 Matt Robinson
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#define BBCSCREEN_PALETTE_SIZE 16 // Size of the BBC palette
#define BBCSCREEN_MAX_MEMSIZE 40960 // Size of screen memory storage
#ifdef __cplusplus
#include <functional>
class BbcScreen
{
public:
static const int PALETTE_SIZE = BBCSCREEN_PALETTE_SIZE;
static const int MAX_MEMSIZE = BBCSCREEN_MAX_MEMSIZE;
#undef BBCSCREEN_PALETTE_SIZE
#undef BBCSCREEN_MAX_MEMSIZE
typedef std::function<void(int x, int y, uint8_t colour)> DrawPixel;
explicit BbcScreen(int screenMemSize);
BbcScreen(int screenMemSize, uint8_t *screenData);
void setMode(uint8_t mode);
uint8_t getMode();
void setScreenByte(int address, uint8_t byte);
uint8_t getScreenByte(int address);
int getScreenWidth();
int getScreenHeight();
void setColour(uint8_t colour, uint8_t value);
uint8_t getColour(uint8_t colour);
void draw(DrawPixel callback);
private:
int screenMemSize_;
int screenWidth_;
int screenHeight_;
int blockRows_;
uint8_t mode_ = 1;
uint8_t palette_[PALETTE_SIZE];
uint8_t screenStorage_[MAX_MEMSIZE];
void init(int screenMemSize);
void draw04(DrawPixel callback);
void draw15(DrawPixel callback);
void draw2(DrawPixel callback);
};
extern "C" {
#endif
typedef struct BbcScreenS *BbcScreenP;
typedef void (*DrawPixelP)(int x, int y, uint8_t colour);
BbcScreenP BbcScreen_create(int screenMemSize);
BbcScreenP BbcScreen_create2(int screenMemSize, uint8_t *screenData);
void BbcScreen_delete(BbcScreenP screen);
void BbcScreen_setMode(BbcScreenP screen, uint8_t mode);
uint8_t BbcScreen_getMode(BbcScreenP screen);
void BbcScreen_setScreenByte(BbcScreenP screen, int address, uint8_t byte);
uint8_t BbcScreen_getScreenByte(BbcScreenP screen, int address);
int BbcScreen_getScreenWidth(BbcScreenP screen);
int BbcScreen_getScreenHeight(BbcScreenP screen);
void BbcScreen_setColour(BbcScreenP screen, uint8_t colour, uint8_t value);
uint8_t BbcScreen_getColour(BbcScreenP screen, uint8_t colour);
void BbcScreen_draw(BbcScreenP screen, DrawPixelP callback);
#ifdef __cplusplus
}
#endif