diff --git a/ext/peanut_gb_options.h b/ext/peanut_gb_options.h new file mode 100644 index 0000000..f345fec --- /dev/null +++ b/ext/peanut_gb_options.h @@ -0,0 +1,6 @@ +#define ENABLE_LCD 1 +#define ENABLE_SOUND 0 // 1 +#define ENABLE_SDCARD 0 // 1 +#define PEANUT_GB_HIGH_LCD_ACCURACY 1 +#define PEANUT_GB_USE_BIOS 0 +#define PEANUT_FULL_GBC_SUPPORT 1 diff --git a/src/core.h b/src/core.h index 01e7be8..883b11d 100644 --- a/src/core.h +++ b/src/core.h @@ -2,9 +2,6 @@ #include -#define GBCOLOR_HEADER_ONLY -#include "gbcolors.h" - enum class ScalingMode { NORMAL = 0, STRETCH, @@ -34,8 +31,6 @@ union core_cmd { uint32_t full; }; -extern palette_t palette; // Colour palette - void lcd_draw_line(struct gb_s* gb, const uint8_t* pixels, const uint_fast8_t line); void core1_init(); diff --git a/src/lcd_core.cpp b/src/lcd_core.cpp index 6d91c41..b591a54 100644 --- a/src/lcd_core.cpp +++ b/src/lcd_core.cpp @@ -1,6 +1,7 @@ #include #define PEANUT_GB_HEADER_ONLY +#include "peanut_gb_options.h" #include "peanut_gb.h" // Note: must be included before core @@ -14,7 +15,8 @@ static uint8_t scaledLineOffsetTable[LCD_HEIGHT]; // scaled to 240 lines /* Pixel data is stored in here. */ static uint8_t pixels_buffer[LCD_WIDTH]; -palette_t palette; // Colour palette +extern struct gb_s gb; +extern palette_t palette; // Colour palette volatile ScalingMode scalingMode = ScalingMode::NORMAL; @@ -131,16 +133,18 @@ void lcd_text(char* s, uint8_t x, uint8_t y, uint16_t color, uint16_t bgcolor) { tft.drawString(s, x, y); } -void lcd_display_control(bool invert, int /*ili9225_color_mode_e*/ colour_mode) { - // TODO -} - void core1_lcd_draw_line(const uint_fast8_t line) { static uint16_t fb[LCD_WIDTH]; - for (unsigned int x = 0; x < LCD_WIDTH; x++) { - fb[x] = palette[(pixels_buffer[x] & LCD_PALETTE_ALL) >> 4] - [pixels_buffer[x] & 3]; + if (gb.cgb.cgbMode) { + for (unsigned int x = 0; x < LCD_WIDTH; x++) { + fb[x] = gb.cgb.fixPalette[pixels_buffer[x]]; + } + } else { + for (unsigned int x = 0; x < LCD_WIDTH; x++) { + fb[x] = palette[(pixels_buffer[x] & LCD_PALETTE_ALL) >> 4] + [pixels_buffer[x] & 3]; + } } lcd_write_pixels(fb, line, LCD_WIDTH); diff --git a/src/main.cpp b/src/main.cpp index f510a47..8e2b461 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,11 +14,7 @@ */ // Peanut-GB emulator settings -#define ENABLE_LCD 1 -#define ENABLE_SOUND 0 // 1 -#define ENABLE_SDCARD 0 // 1 -#define PEANUT_GB_HIGH_LCD_ACCURACY 1 -#define PEANUT_GB_USE_BIOS 0 +#include "peanut_gb_options.h" #include "peanut_gb.h" /* C Headers */ @@ -40,6 +36,9 @@ #include "game_bin.h" #include "i2s.h" +#define GBCOLOR_HEADER_ONLY +#include "gbcolors.h" + /* GPIO Connections. */ #ifdef USE_PAD_GPIO #define PIN_UP 2 @@ -87,6 +86,8 @@ static uint8_t manual_palette_selected = 0; static PCF8574 pcf8574(0x20, 16, 17); +struct gb_s gb; +palette_t palette; // Colour palette static struct { @@ -100,8 +101,6 @@ static struct unsigned down : 1; } prev_joypad_bits; -static struct gb_s gb; - #define putstdio(x) write(1, x, strlen(x)) /**