mirror of https://github.com/bsnes-emu/bsnes.git
Style fixes
This commit is contained in:
parent
ea18ba9335
commit
5a56c3b882
19
Core/gb.c
19
Core/gb.c
|
@ -349,8 +349,7 @@ int GB_load_isx(GB_gameboy_t *gb, const char *path)
|
|||
#endif
|
||||
|
||||
size_t needed_size = bank * 0x4000 + address + length;
|
||||
if (needed_size > 1024 * 1024 * 32)
|
||||
goto error;
|
||||
if (needed_size > 1024 * 1024 * 32) goto error;
|
||||
|
||||
if (gb->rom_size < needed_size) {
|
||||
gb->rom = realloc(gb->rom, needed_size);
|
||||
|
@ -358,8 +357,7 @@ int GB_load_isx(GB_gameboy_t *gb, const char *path)
|
|||
gb->rom_size = needed_size;
|
||||
}
|
||||
|
||||
if (fread(gb->rom + (bank * 0x4000 + address), length, 1, f) != 1)
|
||||
goto error;
|
||||
if (fread(gb->rom + (bank * 0x4000 + address), length, 1, f) != 1) goto error;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -378,16 +376,15 @@ int GB_load_isx(GB_gameboy_t *gb, const char *path)
|
|||
length = __builtin_bswap32(length);
|
||||
#endif
|
||||
size_t needed_size = address + length;
|
||||
if (needed_size > 1024 * 1024 * 32)
|
||||
goto error;
|
||||
if (needed_size > 1024 * 1024 * 32) goto error;
|
||||
|
||||
if (gb->rom_size < needed_size) {
|
||||
gb->rom = realloc(gb->rom, needed_size);
|
||||
memset(gb->rom + gb->rom_size, 0, needed_size - gb->rom_size);
|
||||
gb->rom_size = needed_size;
|
||||
}
|
||||
|
||||
if (fread(gb->rom + address, length, 1, f) != 1)
|
||||
goto error;
|
||||
if (fread(gb->rom + address, length, 1, f) != 1) goto error;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -406,8 +403,7 @@ int GB_load_isx(GB_gameboy_t *gb, const char *path)
|
|||
#endif
|
||||
while (count--) {
|
||||
READ(length);
|
||||
if (fread(name, length, 1, f) != 1)
|
||||
goto error;
|
||||
if (fread(name, length, 1, f) != 1) goto error;
|
||||
name[length] = 0;
|
||||
READ(flag); // unused
|
||||
|
||||
|
@ -439,8 +435,7 @@ int GB_load_isx(GB_gameboy_t *gb, const char *path)
|
|||
#endif
|
||||
while (count--) {
|
||||
READ(length);
|
||||
if (fread(name, length + 1, 1, f) != 1)
|
||||
goto error;
|
||||
if (fread(name, length + 1, 1, f) != 1) goto error;
|
||||
name[length] = 0;
|
||||
READ(flag); // unused
|
||||
|
||||
|
|
|
@ -62,40 +62,54 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
|
|||
if (is_different(w7, w4)) pattern |= 64;
|
||||
if (is_different(w8, w4)) pattern |= 128;
|
||||
|
||||
if ((P(0xbf,0x37) || P(0xdb,0x13)) && is_different(w1, w5))
|
||||
if ((P(0xbf,0x37) || P(0xdb,0x13)) && is_different(w1, w5)) {
|
||||
return interp_2px(w4, 3.0, w3, 1.0);
|
||||
if ((P(0xdb,0x49) || P(0xef,0x6d)) && is_different(w7, w3))
|
||||
}
|
||||
if ((P(0xdb,0x49) || P(0xef,0x6d)) && is_different(w7, w3)) {
|
||||
return interp_2px(w4, 3.0, w1, 1.0);
|
||||
if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && is_different(w3, w1))
|
||||
}
|
||||
if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && is_different(w3, w1)) {
|
||||
return w4;
|
||||
}
|
||||
if ((P(0x6f,0x2a) || P(0x5b,0x0a) || P(0xbf,0x3a) || P(0xdf,0x5a) ||
|
||||
P(0x9f,0x8a) || P(0xcf,0x8a) || P(0xef,0x4e) || P(0x3f,0x0e) ||
|
||||
P(0xfb,0x5a) || P(0xbb,0x8a) || P(0x7f,0x5a) || P(0xaf,0x8a) ||
|
||||
P(0xeb,0x8a)) && is_different(w3, w1))
|
||||
P(0xeb,0x8a)) && is_different(w3, w1)) {
|
||||
return interp_2px(w4, 3.0, w0, 1.0);
|
||||
if (P(0x0b,0x08))
|
||||
}
|
||||
if (P(0x0b,0x08)) {
|
||||
return interp_3px(w4, 2.0, w0, 1.0, w1, 1.0);
|
||||
if (P(0x0b,0x02))
|
||||
}
|
||||
if (P(0x0b,0x02)) {
|
||||
return interp_3px(w4, 2.0, w0, 1.0, w3, 1.0);
|
||||
if (P(0x2f,0x2f))
|
||||
}
|
||||
if (P(0x2f,0x2f)) {
|
||||
return interp_3px(w4, 1.04, w3, 1.0, w1, 1.0);
|
||||
if (P(0xbf,0x37) || P(0xdb,0x13))
|
||||
}
|
||||
if (P(0xbf,0x37) || P(0xdb,0x13)) {
|
||||
return interp_3px(w4, 5.0, w1, 2.0, w3, 1.0);
|
||||
if (P(0xdb,0x49) || P(0xef,0x6d))
|
||||
}
|
||||
if (P(0xdb,0x49) || P(0xef,0x6d)) {
|
||||
return interp_3px(w4, 5.0, w3, 2.0, w1, 1.0);
|
||||
if (P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || P(0x6b,0x43))
|
||||
}
|
||||
if (P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || P(0x6b,0x43)) {
|
||||
return interp_2px(w4, 3.0, w3, 1.0);
|
||||
if (P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || P(0x3b,0x19))
|
||||
}
|
||||
if (P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || P(0x3b,0x19)) {
|
||||
return interp_2px(w4, 3.0, w1, 1.0);
|
||||
if (P(0x7e,0x2a) || P(0xef,0xab) || P(0xbf,0x8f) || P(0x7e,0x0e))
|
||||
}
|
||||
if (P(0x7e,0x2a) || P(0xef,0xab) || P(0xbf,0x8f) || P(0x7e,0x0e)) {
|
||||
return interp_3px(w4, 2.0, w3, 3.0, w1, 3.0);
|
||||
}
|
||||
if (P(0xfb,0x6a) || P(0x6f,0x6e) || P(0x3f,0x3e) || P(0xfb,0xfa) ||
|
||||
P(0xdf,0xde) || P(0xdf,0x1e))
|
||||
P(0xdf,0xde) || P(0xdf,0x1e)) {
|
||||
return interp_2px(w4, 3.0, w0, 1.0);
|
||||
}
|
||||
if (P(0x0a,0x00) || P(0x4f,0x4b) || P(0x9f,0x1b) || P(0x2f,0x0b) ||
|
||||
P(0xbe,0x0a) || P(0xee,0x0a) || P(0x7e,0x0a) || P(0xeb,0x4b) ||
|
||||
P(0x3b,0x1b))
|
||||
P(0x3b,0x1b)) {
|
||||
return interp_3px(w4, 2.0, w3, 1.0, w1, 1.0);
|
||||
}
|
||||
|
||||
return interp_3px(w4, 6.0, w3, 1.0, w1, 1.0);
|
||||
}
|
||||
|
|
|
@ -63,21 +63,27 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
|
|||
if (is_different(w7, w4)) pattern |= 1 << 6;
|
||||
if (is_different(w8, w4)) pattern |= 1 << 7;
|
||||
|
||||
if ((P(0xbf,0x37) || P(0xdb,0x13)) && is_different(w1, w5))
|
||||
if ((P(0xbf,0x37) || P(0xdb,0x13)) && is_different(w1, w5)) {
|
||||
return mix(w4, w3, 0.5 - p.x);
|
||||
if ((P(0xdb,0x49) || P(0xef,0x6d)) && is_different(w7, w3))
|
||||
}
|
||||
if ((P(0xdb,0x49) || P(0xef,0x6d)) && is_different(w7, w3)) {
|
||||
return mix(w4, w1, 0.5 - p.y);
|
||||
if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && is_different(w3, w1))
|
||||
}
|
||||
if ((P(0x0b,0x0b) || P(0xfe,0x4a) || P(0xfe,0x1a)) && is_different(w3, w1)) {
|
||||
return w4;
|
||||
}
|
||||
if ((P(0x6f,0x2a) || P(0x5b,0x0a) || P(0xbf,0x3a) || P(0xdf,0x5a) ||
|
||||
P(0x9f,0x8a) || P(0xcf,0x8a) || P(0xef,0x4e) || P(0x3f,0x0e) ||
|
||||
P(0xfb,0x5a) || P(0xbb,0x8a) || P(0x7f,0x5a) || P(0xaf,0x8a) ||
|
||||
P(0xeb,0x8a)) && is_different(w3, w1))
|
||||
P(0xeb,0x8a)) && is_different(w3, w1)) {
|
||||
return mix(w4, mix(w4, w0, 0.5 - p.x), 0.5 - p.y);
|
||||
if (P(0x0b,0x08))
|
||||
}
|
||||
if (P(0x0b,0x08)) {
|
||||
return mix(mix(w0 * 0.375 + w1 * 0.25 + w4 * 0.375, w4 * 0.5 + w1 * 0.5, p.x * 2.0), w4, p.y * 2.0);
|
||||
if (P(0x0b,0x02))
|
||||
}
|
||||
if (P(0x0b,0x02)) {
|
||||
return mix(mix(w0 * 0.375 + w3 * 0.25 + w4 * 0.375, w4 * 0.5 + w3 * 0.5, p.y * 2.0), w4, p.x * 2.0);
|
||||
}
|
||||
if (P(0x2f,0x2f)) {
|
||||
float dist = length(p - vec2(0.5));
|
||||
float pixel_size = length(1.0 / (output_resolution / input_resolution));
|
||||
|
@ -142,7 +148,6 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
|
|||
}
|
||||
|
||||
return mix(r, w4, (dist + pixel_size / 2 - 1.0) / pixel_size);
|
||||
|
||||
}
|
||||
|
||||
if (P(0x7e,0x2a) || P(0xef,0xab)) {
|
||||
|
@ -169,15 +174,18 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
|
|||
return mix(r, w4, (dist + pixel_size / 2 - 1.0) / pixel_size);
|
||||
}
|
||||
|
||||
if (P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || P(0x6b,0x43))
|
||||
if (P(0x1b,0x03) || P(0x4f,0x43) || P(0x8b,0x83) || P(0x6b,0x43)) {
|
||||
return mix(w4, w3, 0.5 - p.x);
|
||||
}
|
||||
|
||||
if (P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || P(0x3b,0x19))
|
||||
if (P(0x4b,0x09) || P(0x8b,0x89) || P(0x1f,0x19) || P(0x3b,0x19)) {
|
||||
return mix(w4, w1, 0.5 - p.y);
|
||||
}
|
||||
|
||||
if (P(0xfb,0x6a) || P(0x6f,0x6e) || P(0x3f,0x3e) || P(0xfb,0xfa) ||
|
||||
P(0xdf,0xde) || P(0xdf,0x1e))
|
||||
P(0xdf,0xde) || P(0xdf,0x1e)) {
|
||||
return mix(w4, w0, (1.0 - p.x - p.y) / 2.0);
|
||||
}
|
||||
|
||||
if (P(0x4f,0x4b) || P(0x9f,0x1b) || P(0x2f,0x0b) ||
|
||||
P(0xbe,0x0a) || P(0xee,0x0a) || P(0x7e,0x0a) || P(0xeb,0x4b) ||
|
||||
|
@ -204,17 +212,20 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
|
|||
return mix(r, w4, (dist + pixel_size / 2 - 0.5) / pixel_size);
|
||||
}
|
||||
|
||||
if (P(0x0b,0x01))
|
||||
if (P(0x0b,0x01)) {
|
||||
return mix(mix(w4, w3, 0.5 - p.x), mix(w1, (w1 + w3) / 2.0, 0.5 - p.x), 0.5 - p.y);
|
||||
}
|
||||
|
||||
if (P(0x0b,0x00))
|
||||
if (P(0x0b,0x00)) {
|
||||
return mix(mix(w4, w3, 0.5 - p.x), mix(w1, w0, 0.5 - p.x), 0.5 - p.y);
|
||||
}
|
||||
|
||||
float dist = p.x + p.y;
|
||||
float pixel_size = length(1.0 / (output_resolution / input_resolution));
|
||||
|
||||
if (dist > 0.5 + pixel_size / 2)
|
||||
if (dist > 0.5 + pixel_size / 2) {
|
||||
return w4;
|
||||
}
|
||||
|
||||
/* We need more samples to "solve" this diagonal */
|
||||
vec4 x0 = texture(image, position + vec2( -o.x * 2.0, -o.y * 2.0));
|
||||
|
@ -239,7 +250,7 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou
|
|||
pattern >>= 1;
|
||||
}
|
||||
|
||||
if (diagonal_bias <= 0) {
|
||||
if (diagonal_bias <= 0) {
|
||||
vec4 r = mix(w1, w3, p.y - p.x + 0.5);
|
||||
if (dist < 0.5 - pixel_size / 2) {
|
||||
return r;
|
||||
|
|
|
@ -370,8 +370,9 @@ static void init_for_current_model(unsigned id)
|
|||
snprintf(buf, sizeof(buf), "%s%c%s_boot.bin", retro_system_directory, slash, model_name);
|
||||
log_cb(RETRO_LOG_INFO, "Initializing as model: %s\n", model_name);
|
||||
log_cb(RETRO_LOG_INFO, "Loading boot image: %s\n", buf);
|
||||
if (GB_load_boot_rom(&gameboy[i], buf))
|
||||
if (GB_load_boot_rom(&gameboy[i], buf)) {
|
||||
GB_load_boot_rom_from_buffer(&gameboy[i], boot_code, boot_length);
|
||||
}
|
||||
GB_set_user_data(&gameboy[i], (void*)NULL);
|
||||
|
||||
GB_set_pixels_output(&gameboy[i],(unsigned int*)(frame_buf + i * ((model[i] == MODEL_SGB || model[i] == MODEL_SGB2) ? SGB_VIDEO_PIXELS : VIDEO_PIXELS)));
|
||||
|
@ -386,8 +387,9 @@ static void init_for_current_model(unsigned id)
|
|||
GB_set_vblank_callback(&gameboy[0], (GB_vblank_callback_t) vblank1);
|
||||
if (emulated_devices == 2) {
|
||||
GB_set_vblank_callback(&gameboy[1], (GB_vblank_callback_t) vblank2);
|
||||
if (link_cable_emulation)
|
||||
if (link_cable_emulation) {
|
||||
set_link_cable_state(true);
|
||||
}
|
||||
}
|
||||
|
||||
struct retro_memory_descriptor descs[11];
|
||||
|
@ -492,56 +494,73 @@ static void check_variables()
|
|||
var.key = "sameboy_color_correction_mode";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "off") == 0)
|
||||
if (strcmp(var.value, "off") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED);
|
||||
else if (strcmp(var.value, "correct curves") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "correct curves") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_CORRECT_CURVES);
|
||||
else if (strcmp(var.value, "emulate hardware") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "emulate hardware") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE);
|
||||
else if (strcmp(var.value, "preserve brightness") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "preserve brightness") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS);
|
||||
else if (strcmp(var.value, "reduce contrast") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "reduce contrast") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_rumble";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "never") == 0)
|
||||
if (strcmp(var.value, "never") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[0], GB_RUMBLE_DISABLED);
|
||||
else if (strcmp(var.value, "rumble-enabled games") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "rumble-enabled games") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[0], GB_RUMBLE_CARTRIDGE_ONLY);
|
||||
else if (strcmp(var.value, "all games") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "all games") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[0], GB_RUMBLE_ALL_GAMES);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_high_pass_filter_mode";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "off") == 0)
|
||||
if (strcmp(var.value, "off") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_OFF);
|
||||
else if (strcmp(var.value, "accurate") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "accurate") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_ACCURATE);
|
||||
else if (strcmp(var.value, "remove dc offset") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "remove dc offset") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_REMOVE_DC_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_model";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
enum model new_model = model[0];
|
||||
if (strcmp(var.value, "Game Boy") == 0)
|
||||
if (strcmp(var.value, "Game Boy") == 0) {
|
||||
new_model = MODEL_DMG;
|
||||
else if (strcmp(var.value, "Game Boy Color") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Game Boy Color") == 0) {
|
||||
new_model = MODEL_CGB;
|
||||
else if (strcmp(var.value, "Game Boy Advance") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Game Boy Advance") == 0) {
|
||||
new_model = MODEL_AGB;
|
||||
else if (strcmp(var.value, "Super Game Boy") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Super Game Boy") == 0) {
|
||||
new_model = MODEL_SGB;
|
||||
else if (strcmp(var.value, "Super Game Boy 2") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Super Game Boy 2") == 0) {
|
||||
new_model = MODEL_SGB2;
|
||||
else
|
||||
}
|
||||
else {
|
||||
new_model = MODEL_AUTO;
|
||||
}
|
||||
|
||||
if (new_model != model[0]) {
|
||||
geometry_updated = true;
|
||||
|
@ -553,104 +572,134 @@ static void check_variables()
|
|||
var.key = "sameboy_border";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "enabled") == 0)
|
||||
if (strcmp(var.value, "enabled") == 0) {
|
||||
sgb_border = 1;
|
||||
else if (strcmp(var.value, "disabled") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "disabled") == 0) {
|
||||
sgb_border = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var.key = "sameboy_color_correction_mode_1";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "off") == 0)
|
||||
if (strcmp(var.value, "off") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_DISABLED);
|
||||
else if (strcmp(var.value, "correct curves") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "correct curves") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_CORRECT_CURVES);
|
||||
else if (strcmp(var.value, "emulate hardware") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "emulate hardware") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE);
|
||||
else if (strcmp(var.value, "preserve brightness") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "preserve brightness") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS);
|
||||
else if (strcmp(var.value, "reduce contrast") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "reduce contrast") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_color_correction_mode_2";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "off") == 0)
|
||||
if (strcmp(var.value, "off") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_DISABLED);
|
||||
else if (strcmp(var.value, "correct curves") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "correct curves") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_CORRECT_CURVES);
|
||||
else if (strcmp(var.value, "emulate hardware") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "emulate hardware") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_EMULATE_HARDWARE);
|
||||
else if (strcmp(var.value, "preserve brightness") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "preserve brightness") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS);
|
||||
else if (strcmp(var.value, "reduce contrast") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "reduce contrast") == 0) {
|
||||
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var.key = "sameboy_rumble_1";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "never") == 0)
|
||||
if (strcmp(var.value, "never") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[0], GB_RUMBLE_DISABLED);
|
||||
else if (strcmp(var.value, "rumble-enabled games") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "rumble-enabled games") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[0], GB_RUMBLE_CARTRIDGE_ONLY);
|
||||
else if (strcmp(var.value, "all games") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "all games") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[0], GB_RUMBLE_ALL_GAMES);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_rumble_2";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "never") == 0)
|
||||
if (strcmp(var.value, "never") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[1], GB_RUMBLE_DISABLED);
|
||||
else if (strcmp(var.value, "rumble-enabled games") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "rumble-enabled games") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[1], GB_RUMBLE_CARTRIDGE_ONLY);
|
||||
else if (strcmp(var.value, "all games") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "all games") == 0) {
|
||||
GB_set_rumble_mode(&gameboy[1], GB_RUMBLE_ALL_GAMES);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_high_pass_filter_mode_1";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "off") == 0)
|
||||
if (strcmp(var.value, "off") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_OFF);
|
||||
else if (strcmp(var.value, "accurate") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "accurate") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_ACCURATE);
|
||||
else if (strcmp(var.value, "remove dc offset") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "remove dc offset") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[0], GB_HIGHPASS_REMOVE_DC_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_high_pass_filter_mode_2";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "off") == 0)
|
||||
if (strcmp(var.value, "off") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[1], GB_HIGHPASS_OFF);
|
||||
else if (strcmp(var.value, "accurate") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "accurate") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[1], GB_HIGHPASS_ACCURATE);
|
||||
else if (strcmp(var.value, "remove dc offset") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "remove dc offset") == 0) {
|
||||
GB_set_highpass_filter_mode(&gameboy[1], GB_HIGHPASS_REMOVE_DC_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_model_1";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
enum model new_model = model[0];
|
||||
if (strcmp(var.value, "Game Boy") == 0)
|
||||
if (strcmp(var.value, "Game Boy") == 0) {
|
||||
new_model = MODEL_DMG;
|
||||
else if (strcmp(var.value, "Game Boy Color") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Game Boy Color") == 0) {
|
||||
new_model = MODEL_CGB;
|
||||
else if (strcmp(var.value, "Game Boy Advance") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Game Boy Advance") == 0) {
|
||||
new_model = MODEL_AGB;
|
||||
else if (strcmp(var.value, "Super Game Boy") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Super Game Boy") == 0) {
|
||||
new_model = MODEL_SGB;
|
||||
else if (strcmp(var.value, "Super Game Boy 2") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Super Game Boy 2") == 0) {
|
||||
new_model = MODEL_SGB2;
|
||||
else
|
||||
}
|
||||
else {
|
||||
new_model = MODEL_AUTO;
|
||||
}
|
||||
|
||||
if (model[0] != new_model) {
|
||||
model[0] = new_model;
|
||||
|
@ -662,18 +711,24 @@ static void check_variables()
|
|||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
enum model new_model = model[1];
|
||||
if (strcmp(var.value, "Game Boy") == 0)
|
||||
if (strcmp(var.value, "Game Boy") == 0) {
|
||||
new_model = MODEL_DMG;
|
||||
else if (strcmp(var.value, "Game Boy Color") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Game Boy Color") == 0) {
|
||||
new_model = MODEL_CGB;
|
||||
else if (strcmp(var.value, "Game Boy Advance") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Game Boy Advance") == 0) {
|
||||
new_model = MODEL_AGB;
|
||||
else if (strcmp(var.value, "Super Game Boy") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Super Game Boy") == 0) {
|
||||
new_model = MODEL_SGB;
|
||||
else if (strcmp(var.value, "Super Game Boy 2") == 0)
|
||||
}
|
||||
else if (strcmp(var.value, "Super Game Boy 2") == 0) {
|
||||
new_model = MODEL_SGB;
|
||||
else
|
||||
}
|
||||
else {
|
||||
new_model = MODEL_AUTO;
|
||||
}
|
||||
|
||||
if (model[1] != new_model) {
|
||||
model[1] = new_model;
|
||||
|
@ -684,10 +739,12 @@ static void check_variables()
|
|||
var.key = "sameboy_screen_layout";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "top-down") == 0)
|
||||
if (strcmp(var.value, "top-down") == 0) {
|
||||
screen_layout = LAYOUT_TOP_DOWN;
|
||||
else
|
||||
}
|
||||
else {
|
||||
screen_layout = LAYOUT_LEFT_RIGHT;
|
||||
}
|
||||
|
||||
geometry_updated = true;
|
||||
}
|
||||
|
@ -696,23 +753,29 @@ static void check_variables()
|
|||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
bool tmp = link_cable_emulation;
|
||||
if (strcmp(var.value, "enabled") == 0)
|
||||
if (strcmp(var.value, "enabled") == 0) {
|
||||
link_cable_emulation = true;
|
||||
else
|
||||
}
|
||||
else {
|
||||
link_cable_emulation = false;
|
||||
if (link_cable_emulation && link_cable_emulation != tmp)
|
||||
}
|
||||
if (link_cable_emulation && link_cable_emulation != tmp) {
|
||||
set_link_cable_state(true);
|
||||
else if (!link_cable_emulation && link_cable_emulation != tmp)
|
||||
}
|
||||
else if (!link_cable_emulation && link_cable_emulation != tmp) {
|
||||
set_link_cable_state(false);
|
||||
}
|
||||
}
|
||||
|
||||
var.key = "sameboy_audio_output";
|
||||
var.value = NULL;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "Game Boy #1") == 0)
|
||||
if (strcmp(var.value, "Game Boy #1") == 0) {
|
||||
audio_out = GB_1;
|
||||
else
|
||||
}
|
||||
else {
|
||||
audio_out = GB_2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,20 +784,26 @@ void retro_init(void)
|
|||
{
|
||||
const char *dir = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) {
|
||||
snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", dir);
|
||||
else
|
||||
}
|
||||
else {
|
||||
snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", ".");
|
||||
}
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir) {
|
||||
snprintf(retro_save_directory, sizeof(retro_save_directory), "%s", dir);
|
||||
else
|
||||
}
|
||||
else {
|
||||
snprintf(retro_save_directory, sizeof(retro_save_directory), "%s", ".");
|
||||
}
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging))
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) {
|
||||
log_cb = logging.log;
|
||||
else
|
||||
}
|
||||
else {
|
||||
log_cb = fallback_log;
|
||||
}
|
||||
}
|
||||
|
||||
void retro_deinit(void)
|
||||
|
@ -839,8 +908,9 @@ void retro_set_video_refresh(retro_video_refresh_t cb)
|
|||
|
||||
void retro_reset(void)
|
||||
{
|
||||
for (int i = 0; i < emulated_devices; i++)
|
||||
for (int i = 0; i < emulated_devices; i++) {
|
||||
GB_reset(&gameboy[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -849,8 +919,9 @@ void retro_run(void)
|
|||
|
||||
bool updated = false;
|
||||
|
||||
if (!initialized)
|
||||
if (!initialized) {
|
||||
geometry_updated = false;
|
||||
}
|
||||
|
||||
if (geometry_updated) {
|
||||
struct retro_system_av_info info;
|
||||
|
@ -859,22 +930,26 @@ void retro_run(void)
|
|||
geometry_updated = false;
|
||||
}
|
||||
|
||||
if (!frame_buf)
|
||||
if (!frame_buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) {
|
||||
check_variables();
|
||||
}
|
||||
|
||||
if (emulated_devices == 2) {
|
||||
GB_update_keys_status(&gameboy[0], 0);
|
||||
GB_update_keys_status(&gameboy[1], 1);
|
||||
}
|
||||
else if (emulated_devices == 1 && (model[0] == MODEL_SGB || model[0] == MODEL_SGB2)) {
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
GB_update_keys_status(&gameboy[0], i);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
GB_update_keys_status(&gameboy[0], 0);
|
||||
}
|
||||
|
||||
vblank1_occurred = vblank2_occurred = false;
|
||||
signed delta = 0;
|
||||
|
@ -911,16 +986,18 @@ void retro_run(void)
|
|||
}
|
||||
else {
|
||||
if (model[0] == MODEL_SGB || model[0] == MODEL_SGB2) {
|
||||
if (sgb_border == 1)
|
||||
if (sgb_border == 1) {
|
||||
video_cb(frame_buf, SGB_VIDEO_WIDTH, SGB_VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t));
|
||||
}
|
||||
else {
|
||||
int crop = SGB_VIDEO_WIDTH * ((SGB_VIDEO_HEIGHT - VIDEO_HEIGHT) / 2) + ((SGB_VIDEO_WIDTH - VIDEO_WIDTH) / 2);
|
||||
|
||||
video_cb(frame_buf + crop, VIDEO_WIDTH, VIDEO_HEIGHT, SGB_VIDEO_WIDTH * sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_WIDTH * sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -955,10 +1032,12 @@ bool retro_load_game(const struct retro_game_info *info)
|
|||
bool achievements = true;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &achievements);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) {
|
||||
log_cb(RETRO_LOG_INFO, "Rumble environment supported\n");
|
||||
else
|
||||
}
|
||||
else {
|
||||
log_cb(RETRO_LOG_INFO, "Rumble environment not supported\n");
|
||||
}
|
||||
|
||||
check_variables();
|
||||
return true;
|
||||
|
@ -966,8 +1045,9 @@ bool retro_load_game(const struct retro_game_info *info)
|
|||
|
||||
void retro_unload_game(void)
|
||||
{
|
||||
for (int i = 0; i < emulated_devices; i++)
|
||||
for (int i = 0; i < emulated_devices; i++) {
|
||||
GB_free(&gameboy[i]);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned retro_get_region(void)
|
||||
|
@ -978,10 +1058,12 @@ unsigned retro_get_region(void)
|
|||
bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num_info)
|
||||
{
|
||||
|
||||
if (type == RETRO_GAME_TYPE_GAMEBOY_LINK_2P)
|
||||
if (type == RETRO_GAME_TYPE_GAMEBOY_LINK_2P) {
|
||||
emulated_devices = 2;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return false; /* all other types are unhandled for now */
|
||||
}
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars_dual);
|
||||
check_variables();
|
||||
|
@ -1012,10 +1094,12 @@ bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
|
|||
bool achievements = true;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &achievements);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) {
|
||||
log_cb(RETRO_LOG_INFO, "Rumble environment supported\n");
|
||||
else
|
||||
}
|
||||
else {
|
||||
log_cb(RETRO_LOG_INFO, "Rumble environment not supported\n");
|
||||
}
|
||||
|
||||
check_variables();
|
||||
return true;
|
||||
|
@ -1048,8 +1132,9 @@ size_t retro_serialize_size(void)
|
|||
bool retro_serialize(void *data, size_t size)
|
||||
{
|
||||
|
||||
if (!initialized || !data)
|
||||
if (!initialized || !data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t offset = 0;
|
||||
|
||||
|
@ -1096,19 +1181,23 @@ void *retro_get_memory_data(unsigned type)
|
|||
data = gameboy[0].ram;
|
||||
break;
|
||||
case RETRO_MEMORY_SAVE_RAM:
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0)
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0) {
|
||||
data = gameboy[0].mbc_ram;
|
||||
else
|
||||
}
|
||||
else {
|
||||
data = NULL;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_VIDEO_RAM:
|
||||
data = gameboy[0].vram;
|
||||
break;
|
||||
case RETRO_MEMORY_RTC:
|
||||
if (gameboy[0].cartridge_type->has_battery)
|
||||
if (gameboy[0].cartridge_type->has_battery) {
|
||||
data = GB_GET_SECTION(&gameboy[0], rtc);
|
||||
else
|
||||
}
|
||||
else {
|
||||
data = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1117,28 +1206,36 @@ void *retro_get_memory_data(unsigned type)
|
|||
else {
|
||||
switch (type) {
|
||||
case RETRO_MEMORY_GAMEBOY_1_SRAM:
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0)
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0) {
|
||||
data = gameboy[0].mbc_ram;
|
||||
else
|
||||
}
|
||||
else {
|
||||
data = NULL;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_GAMEBOY_2_SRAM:
|
||||
if (gameboy[1].cartridge_type->has_battery && gameboy[1].mbc_ram_size != 0)
|
||||
if (gameboy[1].cartridge_type->has_battery && gameboy[1].mbc_ram_size != 0) {
|
||||
data = gameboy[1].mbc_ram;
|
||||
else
|
||||
}
|
||||
else {
|
||||
data = NULL;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_GAMEBOY_1_RTC:
|
||||
if (gameboy[0].cartridge_type->has_battery)
|
||||
if (gameboy[0].cartridge_type->has_battery) {
|
||||
data = GB_GET_SECTION(&gameboy[0], rtc);
|
||||
else
|
||||
}
|
||||
else {
|
||||
data = NULL;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_GAMEBOY_2_RTC:
|
||||
if (gameboy[1].cartridge_type->has_battery)
|
||||
if (gameboy[1].cartridge_type->has_battery) {
|
||||
data = GB_GET_SECTION(&gameboy[1], rtc);
|
||||
else
|
||||
}
|
||||
else {
|
||||
data = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1157,19 +1254,23 @@ size_t retro_get_memory_size(unsigned type)
|
|||
size = gameboy[0].ram_size;
|
||||
break;
|
||||
case RETRO_MEMORY_SAVE_RAM:
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0)
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0) {
|
||||
size = gameboy[0].mbc_ram_size;
|
||||
else
|
||||
}
|
||||
else {
|
||||
size = 0;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_VIDEO_RAM:
|
||||
size = gameboy[0].vram_size;
|
||||
break;
|
||||
case RETRO_MEMORY_RTC:
|
||||
if (gameboy[0].cartridge_type->has_battery)
|
||||
if (gameboy[0].cartridge_type->has_battery) {
|
||||
size = GB_SECTION_SIZE(rtc);
|
||||
else
|
||||
}
|
||||
else {
|
||||
size = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1178,24 +1279,30 @@ size_t retro_get_memory_size(unsigned type)
|
|||
else {
|
||||
switch (type) {
|
||||
case RETRO_MEMORY_GAMEBOY_1_SRAM:
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0)
|
||||
if (gameboy[0].cartridge_type->has_battery && gameboy[0].mbc_ram_size != 0) {
|
||||
size = gameboy[0].mbc_ram_size;
|
||||
else
|
||||
}
|
||||
else {
|
||||
size = 0;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_GAMEBOY_2_SRAM:
|
||||
if (gameboy[1].cartridge_type->has_battery && gameboy[1].mbc_ram_size != 0)
|
||||
if (gameboy[1].cartridge_type->has_battery && gameboy[1].mbc_ram_size != 0) {
|
||||
size = gameboy[1].mbc_ram_size;
|
||||
else
|
||||
}
|
||||
else {
|
||||
size = 0;
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_GAMEBOY_1_RTC:
|
||||
if (gameboy[0].cartridge_type->has_battery)
|
||||
if (gameboy[0].cartridge_type->has_battery) {
|
||||
size = GB_SECTION_SIZE(rtc);
|
||||
}
|
||||
break;
|
||||
case RETRO_MEMORY_GAMEBOY_2_RTC:
|
||||
if (gameboy[1].cartridge_type->has_battery)
|
||||
if (gameboy[1].cartridge_type->has_battery) {
|
||||
size = GB_SECTION_SIZE(rtc);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue