mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Realised my colour error: mapping the ROM numbers as though they were the hardware numbers. Having fixed that, spotted that I was deserialising R and B the wrong way around and dividing by too much. Colours now appear to be correct.
This commit is contained in:
parent
c6e340a8a2
commit
4b6370eb86
@ -161,7 +161,7 @@ class CRTCBusHandler {
|
|||||||
"vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)"
|
"vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)"
|
||||||
"{"
|
"{"
|
||||||
"uint sample = texture(texID, coordinate).r;"
|
"uint sample = texture(texID, coordinate).r;"
|
||||||
"return vec3(float(sample & 3u), float((sample >> 2) & 3u), float((sample >> 4) & 3u)) / 3.0;"
|
"return vec3(float((sample >> 4) & 3u), float((sample >> 2) & 3u), float(sample & 3u)) / 2.0;"
|
||||||
"}");
|
"}");
|
||||||
// TODO: better vectorise the above.
|
// TODO: better vectorise the above.
|
||||||
}
|
}
|
||||||
@ -183,24 +183,16 @@ class CRTCBusHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void select_pen(int pen) {
|
void select_pen(int pen) {
|
||||||
printf("Pen %d:\n", pen);
|
|
||||||
pen_ = pen;
|
pen_ = pen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_colour(uint8_t colour) {
|
void set_colour(uint8_t colour) {
|
||||||
printf("Colour %d\n", colour);
|
|
||||||
if(pen_ & 16) {
|
if(pen_ & 16) {
|
||||||
printf("border: %d -> %02x\n", colour, mapped_palette_value(colour));
|
|
||||||
border_ = mapped_palette_value(colour);
|
border_ = mapped_palette_value(colour);
|
||||||
// TODO: should flush any border currently in progress
|
// TODO: should flush any border currently in progress
|
||||||
} else {
|
} else {
|
||||||
palette_[pen_] = mapped_palette_value(colour);
|
palette_[pen_] = mapped_palette_value(colour);
|
||||||
|
|
||||||
// for(int c = 0; c < 16; c++) {
|
|
||||||
// printf("%02x ", palette_[c]);
|
|
||||||
// }
|
|
||||||
// printf("\n");
|
|
||||||
|
|
||||||
// TODO: no need for a full regeneration, of every mode, every time
|
// TODO: no need for a full regeneration, of every mode, every time
|
||||||
for(int c = 0; c < 256; c++) {
|
for(int c = 0; c < 256; c++) {
|
||||||
// prepare mode 0
|
// prepare mode 0
|
||||||
@ -235,10 +227,19 @@ class CRTCBusHandler {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t mapped_palette_value(uint8_t colour) {
|
uint8_t mapped_palette_value(uint8_t colour) {
|
||||||
uint8_t r = (colour / 3) % 3;
|
#define COL(r, g, b) (r << 4) | (g << 2) | b
|
||||||
uint8_t g = (colour / 9) % 3;
|
static const uint8_t mapping[32] = {
|
||||||
uint8_t b = colour % 3;
|
COL(1, 1, 1), COL(1, 1, 1), COL(0, 2, 1), COL(2, 2, 1),
|
||||||
return (uint8_t)(r | (g << 2) | (b << 4));
|
COL(0, 0, 1), COL(2, 0, 1), COL(0, 1, 1), COL(2, 1, 1),
|
||||||
|
COL(2, 0, 1), COL(2, 2, 1), COL(2, 2, 0), COL(2, 2, 2),
|
||||||
|
COL(2, 0, 0), COL(2, 0, 2), COL(2, 1, 0), COL(2, 1, 1),
|
||||||
|
COL(0, 0, 1), COL(0, 2, 1), COL(0, 2, 0), COL(0, 2, 2),
|
||||||
|
COL(0, 0, 0), COL(0, 0, 2), COL(0, 1, 0), COL(0, 1, 2),
|
||||||
|
COL(1, 0, 1), COL(1, 2, 1), COL(1, 2, 0), COL(1, 2, 2),
|
||||||
|
COL(1, 0, 0), COL(1, 0, 2), COL(1, 1, 0), COL(1, 1, 2),
|
||||||
|
};
|
||||||
|
#undef COL
|
||||||
|
return mapping[colour];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cycles_;
|
unsigned int cycles_;
|
||||||
|
Loading…
Reference in New Issue
Block a user