update sameboy

This commit is contained in:
CasualPokePlayer 2022-08-10 12:34:46 -07:00
parent b8444f8bd2
commit 1a27aae45b
6 changed files with 36 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@ -69,19 +69,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
DISABLED, DISABLED,
[Display(Name = "Correct Color Curves")] [Display(Name = "Correct Color Curves")]
CORRECT_CURVES, CORRECT_CURVES,
[Display(Name = "Emulate Hardware")] [Display(Name = "Modern - Balanced")]
EMULATE_HARDWARE, MODERN_BALANCED,
[Display(Name = "Preserve Brightness")] [Display(Name = "Modern - Boost Contrast")]
PRESERVE_BRIGHTNESS, MODERN_BOOST_CONTRAST,
[Display(Name = "Reduce Contrast")] [Display(Name = "Reduce Contrast")]
REDUCE_CONTRAST, REDUCE_CONTRAST,
[Display(Name = "Harsh Reality")] [Display(Name = "Harsh Reality")]
LOW_CONTRAST, LOW_CONTRAST,
[Display(Name = "Modern - Accurate")]
MODERN_ACCURATE,
} }
[DisplayName("GBC Color Correction")] [DisplayName("GBC Color Correction")]
[Description("Selects which color correction method to use in GBC mode. Does nothing in GB mode.")] [Description("Selects which color correction method to use in GBC mode. Does nothing in GB mode.")]
[DefaultValue(ColorCorrectionMode.EMULATE_HARDWARE)] [DefaultValue(ColorCorrectionMode.MODERN_BALANCED)]
[TypeConverter(typeof(DescribableEnumConverter))] [TypeConverter(typeof(DescribableEnumConverter))]
public ColorCorrectionMode ColorCorrection { get; set; } public ColorCorrectionMode ColorCorrection { get; set; }
@ -192,9 +194,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
GB_MODEL_CGB_E = 0x205, GB_MODEL_CGB_E = 0x205,
// GB_MODEL_AGB_0 = 0x206, // GB_MODEL_AGB_0 = 0x206,
// GB_MODEL_AGB_A = 0x207, // GB_MODEL_AGB_A = 0x207,
// GB_MODEL_GBP_A = 0x207 | 0x20,
[Display(Name = "AGB")] [Display(Name = "AGB")]
GB_MODEL_AGB = 0x207, GB_MODEL_AGB = 0x207,
[Display(Name = "GBP")]
GB_MODEL_GBP = 0x207 | 0x20,
// GB_MODEL_AGB_B = 0x208, // GB_MODEL_AGB_B = 0x208,
// GB_MODEL_AGB_E = 0x209,
// GB_MODEL_GBP_E = 0x209 | 0x20,
} }
[DisplayName("Console Mode")] [DisplayName("Console Mode")]

View File

@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
{ {
FirmwareID fwid = new( FirmwareID fwid = new(
IsCgb ? "GBC" : "GB", IsCgb ? "GBC" : "GB",
_syncSettings.ConsoleMode is SameboySyncSettings.GBModel.GB_MODEL_AGB _syncSettings.ConsoleMode >= SameboySyncSettings.GBModel.GB_MODEL_AGB
? "AGB" ? "AGB"
: "World"); : "World");
bios = comm.CoreFileProvider.GetFirmwareOrThrow(fwid, "BIOS Not Found, Cannot Load. Change SyncSettings to run without BIOS."); bios = comm.CoreFileProvider.GetFirmwareOrThrow(fwid, "BIOS Not Found, Cannot Load. Change SyncSettings to run without BIOS.");
@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
else else
{ {
bios = Zstd.DecompressZstdStream(new MemoryStream(IsCgb bios = Zstd.DecompressZstdStream(new MemoryStream(IsCgb
? _syncSettings.ConsoleMode is SameboySyncSettings.GBModel.GB_MODEL_AGB ? Resources.SameboyAgbBoot.Value : Resources.SameboyCgbBoot.Value ? _syncSettings.ConsoleMode >= SameboySyncSettings.GBModel.GB_MODEL_AGB ? Resources.SameboyAgbBoot.Value : Resources.SameboyCgbBoot.Value
: Resources.SameboyDmgBoot.Value)).ToArray(); : Resources.SameboyDmgBoot.Value)).ToArray();
} }

View File

@ -1,12 +1,10 @@
#undef GB_INTERNAL // don't rely on GB_INTERNAL in interface
#include "gb.h" #include "gb.h"
#include "blip_buf.h" #include "blip_buf.h"
#include "stdio.h" #include "stdio.h"
#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __attribute__((visibility("default"))) #define EXPORT __attribute__((visibility("default")))
#endif
typedef int8_t s8; typedef int8_t s8;
typedef int16_t s16; typedef int16_t s16;
@ -45,11 +43,12 @@ typedef struct
printer_callback_t printer_cb; printer_callback_t printer_cb;
scanline_callback_t scanline_cb; scanline_callback_t scanline_cb;
u32 scanline_sl; u32 scanline_sl;
bool vblank_occured; bool vblank_occurred;
bool new_frame_present;
u64 cc; u64 cc;
} biz_t; } biz_t;
static u8 PeekIO(biz_t* biz, u8 addr) static inline u8 PeekIO(biz_t* biz, u8 addr)
{ {
u8* io = GB_get_direct_access(&biz->gb, GB_DIRECT_ACCESS_IO, NULL, NULL); u8* io = GB_get_direct_access(&biz->gb, GB_DIRECT_ACCESS_IO, NULL, NULL);
return io[addr]; return io[addr];
@ -81,7 +80,12 @@ static u32 rgb_cb(GB_gameboy_t *gb, u8 r, u8 g, u8 b)
static void vblank_cb(GB_gameboy_t* gb, GB_vblank_type_t type) static void vblank_cb(GB_gameboy_t* gb, GB_vblank_type_t type)
{ {
((biz_t*)gb)->vblank_occured = true; biz_t* biz = (biz_t*)gb;
biz->vblank_occurred = true;
if (type != GB_VBLANK_TYPE_REPEAT)
{
biz->new_frame_present = true;
}
} }
static u8 camera_pixel_cb(GB_gameboy_t* gb, u8 x, u8 y) static u8 camera_pixel_cb(GB_gameboy_t* gb, u8 x, u8 y)
@ -177,7 +181,7 @@ EXPORT void sameboy_setrumblecallback(biz_t* biz, rumble_callback_t callback)
biz->rumble_cb = callback; biz->rumble_cb = callback;
} }
static double FromRawToG(u16 raw) static inline double FromRawToG(u16 raw)
{ {
return (raw - 0x81D0) / (0x70 * 1.0); return (raw - 0x81D0) / (0x70 * 1.0);
} }
@ -199,7 +203,9 @@ EXPORT void sameboy_frameadvance(biz_t* biz, GB_key_mask_t keys, u16 x, u16 y, s
} }
u32 cycles = 0; u32 cycles = 0;
biz->vblank_occured = false; biz->vblank_occurred = false;
biz->new_frame_present = false;
do do
{ {
u8 oldjoyp = PeekIO(biz, GB_IO_JOYP) & 0x30; u8 oldjoyp = PeekIO(biz, GB_IO_JOYP) & 0x30;
@ -212,7 +218,7 @@ EXPORT void sameboy_frameadvance(biz_t* biz, GB_key_mask_t keys, u16 x, u16 y, s
biz->input_cb(); biz->input_cb();
} }
} }
while (!biz->vblank_occured && cycles < 35112); while (!biz->vblank_occurred && cycles < 35112);
blip_end_frame(biz->blip_l, biz->nsamps); blip_end_frame(biz->blip_l, biz->nsamps);
blip_end_frame(biz->blip_r, biz->nsamps); blip_end_frame(biz->blip_r, biz->nsamps);
@ -223,7 +229,7 @@ EXPORT void sameboy_frameadvance(biz_t* biz, GB_key_mask_t keys, u16 x, u16 y, s
blip_read_samples(biz->blip_r, sbuf + 1, samps, 1); blip_read_samples(biz->blip_r, sbuf + 1, samps, 1);
*nsamp = samps; *nsamp = samps;
if (biz->vblank_occured && render) if (biz->new_frame_present && render)
{ {
memcpy(vbuf, biz->vbuf, sizeof biz->vbuf); memcpy(vbuf, biz->vbuf, sizeof biz->vbuf);
} }
@ -498,7 +504,7 @@ EXPORT void sameboy_setscanlinecallback(biz_t* biz, scanline_callback_t callback
GB_set_lcd_line_callback(&biz->gb, callback ? ScanlineCallbackRelay : NULL); GB_set_lcd_line_callback(&biz->gb, callback ? ScanlineCallbackRelay : NULL);
} }
static struct GB_color_s argb_to_rgb(u32 argb) static inline struct GB_color_s argb_to_rgb(u32 argb)
{ {
struct GB_color_s ret; struct GB_color_s ret;
ret.r = argb >> 16 & 0xFF; ret.r = argb >> 16 & 0xFF;

@ -1 +1 @@
Subproject commit 03f4f03661d10a366c2302a4299362878d1aea91 Subproject commit 52ab20054486330a8757641230f55c716ea525e6