adjust palettes
This commit is contained in:
+29
-13
@@ -46,6 +46,7 @@ void get_colour_palette(palette_t selected_palette, uint8_t table_entry, uint8_t
|
|||||||
#define RGB565(r, g, b) (((b) << 11) | ((g) << 5) | (r))
|
#define RGB565(r, g, b) (((b) << 11) | ((g) << 5) | (r))
|
||||||
#else
|
#else
|
||||||
// #define RGB565(r, g, b) (((r) << 11) | ((g) << 5) | (b))
|
// #define RGB565(r, g, b) (((r) << 11) | ((g) << 5) | (b))
|
||||||
|
#define RGB(r, g, b) RGB565((r >> 3), (g >> 2), (b >> 3))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t gamma_int = 40;
|
uint8_t gamma_int = 40;
|
||||||
@@ -455,9 +456,9 @@ void get_colour_palette(palette_t selected_palette, uint8_t table_entry, uint8_t
|
|||||||
}
|
}
|
||||||
if (table_entry == 0x16 && shuffling_flags == 0x00) {
|
if (table_entry == 0x16 && shuffling_flags == 0x00) {
|
||||||
const palette_t palette = {
|
const palette_t palette = {
|
||||||
{ RGB565(0x16, 0x31, 0x14), RGB565(0x11, 0x26, 0x0F), RGB565(0x0C, 0x1D, 0x0A), RGB565(0x06, 0x0E, 0x04) }, /* OBJ0 */
|
{RGB565(0x1F, 0x3F, 0x1F), RGB565(0x14, 0x29, 0x14), RGB565(0x0A, 0x14, 0x0A), RGB565(0x00, 0x00, 0x00)}, /* OBJ0 */
|
||||||
{ RGB565(0x16, 0x31, 0x14), RGB565(0x11, 0x26, 0x0F), RGB565(0x0C, 0x1D, 0x0A), RGB565(0x06, 0x0E, 0x04) }, /* OBJ1 */
|
{RGB565(0x1F, 0x3F, 0x1F), RGB565(0x14, 0x29, 0x14), RGB565(0x0A, 0x14, 0x0A), RGB565(0x00, 0x00, 0x00)}, /* OBJ1 */
|
||||||
{ RGB565(0x16, 0x31, 0x14), RGB565(0x11, 0x26, 0x0F), RGB565(0x0C, 0x1D, 0x0A), RGB565(0x06, 0x0E, 0x04) } /* BG */
|
{RGB565(0x1F, 0x3F, 0x1F), RGB565(0x14, 0x29, 0x14), RGB565(0x0A, 0x14, 0x0A), RGB565(0x00, 0x00, 0x00)} /* BG */
|
||||||
};
|
};
|
||||||
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
||||||
return;
|
return;
|
||||||
@@ -534,18 +535,30 @@ void get_colour_palette(palette_t selected_palette, uint8_t table_entry, uint8_t
|
|||||||
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (table_entry == 0xFF && shuffling_flags == 0xFE) { /* Game Boy Pocket palette (4 shades of grey) */
|
||||||
|
const palette_t palette = {
|
||||||
|
{RGB565(0x16, 0x31, 0x14), RGB565(0x11, 0x26, 0x0F), RGB565(0x0C, 0x1D, 0x0A), RGB565(0x06, 0x0E, 0x04)}, /* OBJ0 */
|
||||||
|
{RGB565(0x16, 0x31, 0x14), RGB565(0x11, 0x26, 0x0F), RGB565(0x0C, 0x1D, 0x0A), RGB565(0x06, 0x0E, 0x04)}, /* OBJ1 */
|
||||||
|
{RGB565(0x16, 0x31, 0x14), RGB565(0x11, 0x26, 0x0F), RGB565(0x0C, 0x1D, 0x0A), RGB565(0x06, 0x0E, 0x04)} /* BG */
|
||||||
|
};
|
||||||
|
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (table_entry == 0xFF && shuffling_flags == 0xFF) { /* Game Boy DMG palette (4 shades of green) */
|
||||||
|
const palette_t palette = {
|
||||||
|
{RGB(0x57, 0x82, 0x00), RGB(0x31, 0x74, 0x00), RGB(0x00, 0x51, 0x0A), RGB(0x00, 0x32, 0x0A)},
|
||||||
|
{RGB(0x57, 0x82, 0x00), RGB(0x31, 0x74, 0x00), RGB(0x00, 0x51, 0x0A), RGB(0x00, 0x32, 0x0A)},
|
||||||
|
{RGB(0x57, 0x82, 0x00), RGB(0x31, 0x74, 0x00), RGB(0x00, 0x51, 0x0A), RGB(0x00, 0x32, 0x0A)},
|
||||||
|
};
|
||||||
|
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* default palette */
|
/* default palette */
|
||||||
Serial.printf("E get_colour_palette: No palette found for table_entry=0x%02X shuffling_flags=0x%02X\n",
|
Serial.printf("E get_colour_palette: No palette found for table_entry=0x%02X shuffling_flags=0x%02X\n",
|
||||||
table_entry,
|
table_entry,
|
||||||
shuffling_flags);
|
shuffling_flags);
|
||||||
/* Game Boy DMG palette (4 shades of green) */
|
get_colour_palette(selected_palette, 0xFF, 0xFF);
|
||||||
const palette_t palette = {
|
|
||||||
{RGB565(0x1B, 0x3F, 0x0A), RGB565(0x15, 0x33, 0x08), RGB565(0x0E, 0x27, 0x06), RGB565(0x08, 0x1C, 0x08)}, /* OBJ0 */
|
|
||||||
{RGB565(0x1B, 0x3F, 0x0A), RGB565(0x15, 0x33, 0x08), RGB565(0x0E, 0x27, 0x06), RGB565(0x08, 0x1C, 0x08)}, /* OBJ1 */
|
|
||||||
{RGB565(0x1B, 0x3F, 0x0A), RGB565(0x15, 0x33, 0x08), RGB565(0x0E, 0x27, 0x06), RGB565(0x08, 0x1C, 0x08)} /* BG */
|
|
||||||
};
|
|
||||||
memcpy(selected_palette, palette, PALETTE_SIZE_IN_BYTES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1156,7 +1169,7 @@ void manual_assign_palette(palette_t palette, uint8_t selection) {
|
|||||||
case 3: /* B + Right */
|
case 3: /* B + Right */
|
||||||
get_colour_palette(palette, 0x13, 0x00);
|
get_colour_palette(palette, 0x13, 0x00);
|
||||||
break;
|
break;
|
||||||
case 4: /* B + Left Game Boy Pocket (monochrome 4-shades of white) */
|
case 4: /* B + Left */
|
||||||
get_colour_palette(palette, 0x16, 0x00);
|
get_colour_palette(palette, 0x16, 0x00);
|
||||||
break;
|
break;
|
||||||
case 5: /* Down */
|
case 5: /* Down */
|
||||||
@@ -1180,10 +1193,13 @@ void manual_assign_palette(palette_t palette, uint8_t selection) {
|
|||||||
case 11: /* B + Down */
|
case 11: /* B + Down */
|
||||||
get_colour_palette(palette, 0x1A, 0x05);
|
get_colour_palette(palette, 0x1A, 0x05);
|
||||||
break;
|
break;
|
||||||
case 12: /* A + B Original Game Boy DMG color palette (monochrome 4-shades of green!) */
|
case 12: /* A + B Original Game Boy DMG */
|
||||||
default: /* Original Game Boy DMG color palette (monochrome 4-shades of green!) */
|
|
||||||
get_colour_palette(palette, 0xFF, 0xFF);
|
get_colour_palette(palette, 0xFF, 0xFF);
|
||||||
break;
|
break;
|
||||||
|
case 13: /* Game Boy Pocket */
|
||||||
|
default:
|
||||||
|
get_colour_palette(palette, 0xFF, 0xFE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,10 +92,6 @@ union core_cmd {
|
|||||||
uint32_t full;
|
uint32_t full;
|
||||||
};
|
};
|
||||||
|
|
||||||
void nextPalette();
|
|
||||||
|
|
||||||
void prevPalette();
|
|
||||||
|
|
||||||
void lcd_init(bool isCore1);
|
void lcd_init(bool isCore1);
|
||||||
void lcd_draw_line(struct gb_s* gb, const uint8_t* pixels, const uint_fast8_t line);
|
void lcd_draw_line(struct gb_s* gb, const uint8_t* pixels, const uint_fast8_t line);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ extern i2s_config_t i2s_config;
|
|||||||
|
|
||||||
extern uint8_t gamma_int;
|
extern uint8_t gamma_int;
|
||||||
|
|
||||||
|
static uint8_t palette_selected = 0;
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
unsigned a : 1;
|
unsigned a : 1;
|
||||||
@@ -108,6 +110,27 @@ void initJoypad() {
|
|||||||
Serial.println("Joypad IOs initialized");
|
Serial.println("Joypad IOs initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PALETTE_COUNT 15
|
||||||
|
|
||||||
|
void updatePalette() {
|
||||||
|
if (palette_selected == 0) {
|
||||||
|
char rom_title[16];
|
||||||
|
auto_assign_palette(palette, gb_colour_hash(&gb), gb_get_rom_name(&gb, rom_title));
|
||||||
|
} else {
|
||||||
|
manual_assign_palette(palette, palette_selected - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void nextPalette() {
|
||||||
|
palette_selected = (palette_selected + 1) % PALETTE_COUNT;
|
||||||
|
updatePalette();
|
||||||
|
}
|
||||||
|
|
||||||
|
void prevPalette() {
|
||||||
|
palette_selected = (palette_selected + PALETTE_COUNT - 1) % PALETTE_COUNT;
|
||||||
|
updatePalette();
|
||||||
|
}
|
||||||
|
|
||||||
void handleSerial() {
|
void handleSerial() {
|
||||||
static uint64_t start_time = time_us_64();
|
static uint64_t start_time = time_us_64();
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ uint16_t* stream;
|
|||||||
i2s_config_t i2s_config;
|
i2s_config_t i2s_config;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t manual_palette_selected = 0;
|
|
||||||
|
|
||||||
uint_fast32_t frames = 0;
|
uint_fast32_t frames = 0;
|
||||||
|
|
||||||
void startEmulator() {
|
void startEmulator() {
|
||||||
@@ -170,16 +168,6 @@ void setup() {
|
|||||||
startEmulator();
|
startEmulator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nextPalette() {
|
|
||||||
manual_palette_selected = manual_palette_selected < 12 ? manual_palette_selected + 1 : 0;
|
|
||||||
manual_assign_palette(palette, manual_palette_selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
void prevPalette() {
|
|
||||||
manual_palette_selected = manual_palette_selected > 0 ? manual_palette_selected - 1 : 12;
|
|
||||||
manual_assign_palette(palette, manual_palette_selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
gb.gb_frame = 0;
|
gb.gb_frame = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user