Skip to content
Permalink
Browse files

Merge pull request #61 from retro-wertz/gb

gb palette fix, color correction and cleanup
  • Loading branch information
hizzlekizzle committed Jul 18, 2019
2 parents 8462ca7 + bd5ba43 commit bdd4386805cc07f3aae92263d3a4294acc308976
Showing with 30 additions and 69 deletions.
  1. +2 −2 src/gb/gbMemory.cpp
  2. +0 −2 src/gba/GBA.cpp
  3. +0 −27 src/libretro/UtilRetro.cpp
  4. +16 −37 src/libretro/libretro.cpp
  5. +12 −1 src/libretro/libretro_core_options.h
@@ -308,7 +308,7 @@ mapperMBC3 gbDataMBC3 = {
0, // timer latched hours
0, // timer latched days
0, // timer latched control
0 // last time
{0} // last time
};

void memoryUpdateMBC3Clock()
@@ -1176,7 +1176,7 @@ mapperTAMA5 gbDataTAMA5 = {
0, // timer latched months
0, // timer latched years
0, // timer latched control
(time_t)-1 // last time
{(time_t)-1} // last time
};

void memoryUpdateTAMA5Clock()
@@ -142,8 +142,6 @@ const uint8_t gamepakWaitState[4] = { 4, 3, 2, 8 };
const uint8_t gamepakWaitState0[2] = { 2, 1 };
const uint8_t gamepakWaitState1[2] = { 4, 1 };
const uint8_t gamepakWaitState2[2] = { 8, 1 };
const bool isInRom[16] = { false, false, false, false, false, false, false, false,
true, true, true, true, true, true, false, false };

uint8_t memoryWait[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0 };
uint8_t memoryWait32[16] = { 0, 0, 5, 0, 0, 1, 1, 0, 7, 7, 9, 9, 13, 13, 4, 0 };
@@ -49,18 +49,6 @@ extern int systemBlueShift;
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];

const char gb_image_header[] =
{
static_cast<const char>
(
0xce, 0xed, 0x66, 0x66, 0xcc, 0x0d, 0x00, 0x0b, 0x03, 0x73, 0x00,
0x83, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x08, 0x11, 0x1f, 0x88, 0x89,
0x00, 0x0e, 0xdc, 0xcc, 0x6e, 0xe6, 0xdd, 0xdd, 0xd9, 0x99, 0xbb,
0xbb, 0x67, 0x63, 0x6e, 0x0e, 0xec, 0xcc, 0xdd, 0xdc, 0x99, 0x9f,
0xbb, 0xb9, 0x33, 0x3e
)
};

bool utilWritePNGFile(const char* fileName, int w, int h, uint8_t* pix)
{
return false;
@@ -108,21 +96,6 @@ bool utilIsGBAImage(const char* file)

bool utilIsGBImage(const char* file)
{
/*
FILE *fp;
bool ret = false;
char buffer[47];
if (!file || !(fp = fopen (file, "r"))) //TODO more checks here (does file exist, is it a file, a symlink or a blockdevice)
return ret;
fseek (fp, 0, SEEK_END);
if (ftell (fp) >= 0x8000) { //afaik there can be no gb-rom smaller than this
fseek (fp, 0x104, SEEK_SET);
fread (buffer, sizeof (char), 47, fp);
ret = !memcmp (buffer, gb_image_header, 47);
}
fclose (fp);
return ret;
*/
if (strlen(file) > 4) {
const char *p = strrchr(file, '.');

@@ -187,6 +187,11 @@ static void set_gbPalette(void)
gbPalette[i] = pal[i];
}

static void set_gbColorCorrection(int value)
{
gbColorOption = value;
}

extern int gbRomType; // gets type from header 0x147
extern int gbBattery; // enabled when gbRamSize != 0

@@ -498,40 +503,6 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
void retro_set_environment(retro_environment_t cb)
{
environ_cb = cb;

struct retro_variable variables[] = {
{ "vbam_solarsensor", "Solar Sensor Level; 0|1|2|3|4|5|6|7|8|9|10" },
{ "vbam_usebios", "Use BIOS file (Restart); disabled|enabled" },
{ "vbam_soundinterpolation", "Sound Interpolation; enabled|disabled" },
{ "vbam_soundfiltering", "Sound Filtering; 5|6|7|8|9|10|0|1|2|3|4" },
{ "vbam_gbHardware", "(GB) Emulated Hardware; gbc|auto|sgb|gb|gba|sgb2" },
{ "vbam_palettes", "(GB) Color Palette; black and white|blue sea|dark knight|green forest|hot desert|pink dreams|wierd colors|original gameboy|gba sp" },
{ "vbam_showborders", "(GB) Show Borders; disabled|enabled|auto" },
{ "vbam_turboenable", "Enable Turbo Buttons; disabled|enabled" },
{ "vbam_turbodelay", "Turbo Delay (in frames); 3|4|5|6|7|8|9|10|11|12|13|14|15|1|2" },
{ "vbam_astick_deadzone", "Sensors Deadzone (%); 15|20|25|30|0|5|10"},
{ "vbam_gyro_sensitivity", "Sensor Sensitivity (Gyroscope) (%); 100|105|110|115|120|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95"},
{ "vbam_tilt_sensitivity", "Sensor Sensitivity (Tilt) (%); 100|105|110|115|120|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95"},
{ "vbam_swap_astick", "Swap Left/Right Analog; disabled|enabled" },
{ "vbam_layer_1", "Show layer 1; enabled|disabled" },
{ "vbam_layer_2", "Show layer 2; enabled|disabled" },
{ "vbam_layer_3", "Show layer 3; enabled|disabled" },
{ "vbam_layer_4", "Show layer 4; enabled|disabled" },
{ "vbam_layer_5", "Show sprite layer; enabled|disabled" },
{ "vbam_layer_6", "Show window layer 1; enabled|disabled" },
{ "vbam_layer_7", "Show window layer 2; enabled|disabled" },
{ "vbam_layer_8", "Show sprite window layer; enabled|disabled" },
{ "vbam_sound_1", "Sound channel 1; enabled|disabled" },
{ "vbam_sound_2", "Sound channel 2; enabled|disabled" },
{ "vbam_sound_3", "Sound channel 3; enabled|disabled" },
{ "vbam_sound_4", "Sound channel 4; enabled|disabled" },
{ "vbam_sound_5", "Direct Sound A; enabled|disabled" },
{ "vbam_sound_6", "Direct Sound B; enabled|disabled" },
{ NULL, NULL },
};

// cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);

libretro_set_core_options(environ_cb);
}

@@ -896,6 +867,7 @@ static void gb_init(void)
gbSoundSetDeclicking(1);

gbReset(); // also resets sound;
set_gbPalette();

// VBA-M always updates time based on current time and not in-game time.
// No need to add RTC data to RETRO_MEMORY_RTC, so its safe to place this here.
@@ -1092,7 +1064,7 @@ static void update_variables(bool startup)
var.key = "vbam_gbHardware";
var.value = NULL;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && startup) {
if (strcmp(var.value, "auto") == 0)
gbEmulatorType = 0;
else if (strcmp(var.value, "gbc") == 0)
@@ -1193,6 +1165,15 @@ static void update_variables(bool startup)
if (lastpal != current_gbPalette)
set_gbPalette();
}

var.key = "vbam_gbcoloroption";
var.value = NULL;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = (!strcmp(var.value, "enabled")) ? 1 : 0;
set_gbColorCorrection(val);
}
}

// System analog stick range is -0x7fff to 0x7fff
@@ -1636,8 +1617,6 @@ void systemMessage(int, const char* fmt, ...)
va_end(ap);
}

static int rumble_state, rumble_down;

uint32_t systemReadJoypad(int which)
{
uint32_t J = 0;
@@ -110,7 +110,7 @@ struct retro_core_option_definition option_defs_us[] = {
{
"vbam_gbHardware",
"(GB) Emulated Hardware",
"Sets the Game Boy hardware type to emulate.",
"Sets the Game Boy hardware type to emulate. Restart core to apply.",
{
{ "gbc", "Game Boy Color" },
{ "auto", "Automatic" },
@@ -145,6 +145,17 @@ struct retro_core_option_definition option_defs_us[] = {
},
"disabled"
},
{
"vbam_gbcoloroption",
"(GB) Color Correction",
"Applies color correction which fixes colors in some games games.",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"vbam_turboenable",
"Enable Turbo Buttons",

0 comments on commit bdd4386

Please sign in to comment.
You can’t perform that action at this time.