Skip to content

Commit 5cb1fe0

Browse files
SergioMartin86vadosnaprimerCasualPokePlayer
authored
Update Genesis Plus GX Core (#3889)
* Added deep freeze functionality * Adding support for selecting sound chip * Adding LUA interface to the deepfreeze list * Implemented sprite always on top in the VDP * Found and fixed the issue that manifested itself in a reset Gargoyles and an outright fail in Ristar. The issue was the use of a union type containing overlapping cd and cartdrige data. Using struct now to keep them separated * Fix PC reg in tracelogs --------- Co-authored-by: feos <[email protected]> Co-authored-by: CasualPokePlayer <[email protected]>
1 parent fd36a37 commit 5cb1fe0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+976
-86703
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@
7373
path = quicknes/core
7474
url = https://github.com/TASEmulators/quickerNES.git
7575
branch = main
76+
[submodule "waterbox/gpgx/Genesis-Plus-GX"]
77+
path = waterbox/gpgx/Genesis-Plus-GX
78+
url = https://github.com/TASEmulators/Genesis-Plus-GX.git
79+
branch = tasvideos-2

Assets/dll/gpgx.wbx.zst

20.6 KB
Binary file not shown.

src/BizHawk.Client.Common/lua/LuaHelperLibs/GenesisLuaLibrary.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.ComponentModel;
33

4+
using BizHawk.Emulation.Common;
45
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
56

67
// ReSharper disable UnusedMember.Global
@@ -15,12 +16,15 @@ public GenesisLuaLibrary(ILuaLibraries luaLibsImpl, ApiContainer apiContainer, A
1516

1617
public override string Name => "genesis";
1718

19+
[RequiredService]
20+
private GPGX gpgx { get; set; }
21+
1822
private GPGX.GPGXSettings Settings
1923
{
2024
get => APIs.Emulation.GetSettings() as GPGX.GPGXSettings ?? new GPGX.GPGXSettings();
2125
set => APIs.Emulation.PutSettings(value);
2226
}
23-
27+
2428
[LuaMethodExample("if ( genesis.getlayer_bga( ) ) then\r\n\tconsole.log( \"Returns whether the bg layer A is displayed\" );\r\nend;")]
2529
[LuaMethod("getlayer_bga", "Returns whether the bg layer A is displayed")]
2630
public bool GetLayerBgA()
@@ -62,5 +66,19 @@ public void SetLayerBgW(bool value)
6266
s.DrawBGW = value;
6367
Settings = s;
6468
}
69+
70+
[LuaMethodExample("genesis.add_deepfreeze_value( 0xFF00, 0x01 );")]
71+
[LuaMethod("add_deepfreeze_value", "Adds an address to deepfreeze to a given value. The value will not change at any point during emulation.")]
72+
public int AddDeepFreezeValue(int address, byte value)
73+
{
74+
return gpgx.AddDeepFreezeValue(address, value);
75+
}
76+
77+
[LuaMethodExample("genesis.clear_deepfreeze_list();")]
78+
[LuaMethod("clear_deepfreeze_list", "Clears the list of deep frozen variables")]
79+
public void ClearDeepFreezeList()
80+
{
81+
gpgx.ClearDeepFreezeList();
82+
}
6583
}
6684
}

src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ public class GPGXSyncSettings
263263
[DefaultValue(LibGPGX.Region.Autodetect)]
264264
public LibGPGX.Region Region { get; set; }
265265

266+
[DisplayName("FM Sound Chip Type")]
267+
[Description("Sets the method used to emulate the FM synthesizer (main sound generator) of the Mega Drive/Genesis. 'MAME' options are fast, and run full speed on most systems. 'Nuked' options are cycle accurate, very high quality, and have substantial CPU requirements. The 'YM2612' chip is used by the original Model 1 Mega Drive/Genesis. The 'YM3438' is used in later Mega Drive/Genesis revisions.")]
268+
[DefaultValue(LibGPGX.InitSettings.GenesisFMSoundChipType.MAME_YM2612)]
269+
public LibGPGX.InitSettings.GenesisFMSoundChipType GenesisFMSoundChip { get; set; }
270+
266271
[DisplayName("Audio Filter")]
267272
[DefaultValue(LibGPGX.InitSettings.FilterType.LowPass)]
268273
public LibGPGX.InitSettings.FilterType Filter { get; set; }
@@ -303,6 +308,11 @@ public class GPGXSyncSettings
303308
[DefaultValue(0xffff00ff)]
304309
public uint BackdropColor { get; set; }
305310

311+
[DisplayName("Sprites always on top")]
312+
[Description("Forces sprites to always be displayed on top")]
313+
[DefaultValue(false)]
314+
public bool SpritesAlwaysOnTop { get; set; }
315+
306316
public LibGPGX.InitSettings GetNativeSettings(GameInfo game)
307317
{
308318
return new LibGPGX.InitSettings
@@ -320,6 +330,8 @@ public LibGPGX.InitSettings GetNativeSettings(GameInfo game)
320330
InputSystemB = SystemForSystem(ControlTypeRight),
321331
Region = Region,
322332
ForceSram = game["sram"],
333+
GenesisFMSoundChip = GenesisFMSoundChip,
334+
SpritesAlwaysOnTop = SpritesAlwaysOnTop
323335
};
324336
}
325337

src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
1313
{
14-
[PortedCore(CoreNames.Gpgx, "", "r874", "https://code.google.com/p/genplus-gx/")]
14+
[PortedCore(CoreNames.Gpgx, "Eke-Eke", "25a90c6", "https://github.com/ekeeke/Genesis-Plus-GX")]
1515
public partial class GPGX : IEmulator, IVideoProvider, ISaveRam, IStatable, IRegionable,
1616
IInputPollable, IDebuggable, IDriveLight, ICodeDataLogger, IDisassemblable
1717
{
@@ -44,7 +44,7 @@ public GPGX(CoreLoadParameters<GPGXSettings, GPGXSyncSettings> lp)
4444
SbrkHeapSizeKB = 512,
4545
SealedHeapSizeKB = 4 * 1024,
4646
InvisibleHeapSizeKB = 4 * 1024,
47-
PlainHeapSizeKB = 34 * 1024,
47+
PlainHeapSizeKB = 48 * 1024,
4848
MmapHeapSizeKB = 1 * 1024,
4949
SkipCoreConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
5050
SkipMemoryConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
@@ -214,7 +214,7 @@ private int load_archive(string filename, IntPtr buffer, int maxsize)
214214
srcdata = GetCDData(_cds[0]);
215215
if (srcdata.Length != maxsize)
216216
{
217-
Console.WriteLine("Couldn't satisfy firmware request {0} because of struct size.", filename);
217+
Console.WriteLine("Couldn't satisfy firmware request {0} because of struct size ({1} != {2}).", filename, srcdata.Length, maxsize);
218218
return 0;
219219
}
220220
}
@@ -314,8 +314,12 @@ public static LibGPGX.CDData GetCDDataStruct(Disc cd)
314314
//zero 07-jul-2015 - throws a dollar in the pile, since he probably messed it up worse
315315
for (int i = 0; i < LibGPGX.CD_MAX_TRACKS; i++)
316316
{
317+
ret.tracks[i].loopEnabled = 0;
318+
ret.tracks[i].loopOffset = 0;
319+
317320
if (i < ntrack)
318321
{
322+
ret.tracks[i].mode = ses.Tracks[i].Mode;
319323
ret.tracks[i].start = ses.Tracks[i + 1].LBA;
320324
ret.tracks[i].end = ses.Tracks[i + 2].LBA;
321325
if (i == ntrack - 1)
@@ -326,6 +330,7 @@ public static LibGPGX.CDData GetCDDataStruct(Disc cd)
326330
}
327331
else
328332
{
333+
ret.tracks[i].mode = 0;
329334
ret.tracks[i].start = 0;
330335
ret.tracks[i].end = 0;
331336
}
@@ -412,6 +417,16 @@ public VDPView UpdateVDPViewContext()
412417
Core.gpgx_flush_vram(); // fully regenerate internal caches as needed
413418
return new VDPView(v, _elf);
414419
}
420+
421+
public int AddDeepFreezeValue(int address, byte value)
422+
{
423+
return Core.gpgx_add_deepfreeze_list_entry(address, value);
424+
}
425+
426+
public void ClearDeepFreezeList()
427+
{
428+
Core.gpgx_clear_deepfreeze_list();
429+
}
415430

416431
public DisplayType Region { get; }
417432
}

src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/LibGPGX.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,23 @@ public enum FilterType : byte
4848
ThreeBand = 2
4949
}
5050
public FilterType Filter;
51+
5152
public INPUT_SYSTEM InputSystemA;
5253
public INPUT_SYSTEM InputSystemB;
5354
public bool SixButton;
5455
public bool ForceSram;
56+
57+
public enum GenesisFMSoundChipType : byte
58+
{
59+
MAME_YM2612,
60+
MAME_ASIC_YM3438,
61+
MAME_Enhanced_YM3438,
62+
Nuked_YM2612,
63+
Nuked_YM3438
64+
}
65+
public GenesisFMSoundChipType GenesisFMSoundChip;
66+
67+
public bool SpritesAlwaysOnTop;
5568
}
5669

5770
[BizImport(CallingConvention.Cdecl)]
@@ -271,6 +284,9 @@ public struct CDTrack
271284
{
272285
public int start;
273286
public int end;
287+
public int mode;
288+
public int loopEnabled;
289+
public int loopOffset;
274290
}
275291

276292
[StructLayout(LayoutKind.Sequential)]
@@ -282,6 +298,12 @@ public class CDData
282298
public readonly CDTrack[] tracks = new CDTrack[CD_MAX_TRACKS];
283299
}
284300

301+
[BizImport(CallingConvention.Cdecl)]
302+
public abstract int gpgx_add_deepfreeze_list_entry(int address, byte value);
303+
304+
[BizImport(CallingConvention.Cdecl)]
305+
public abstract void gpgx_clear_deepfreeze_list();
306+
285307
[BizImport(CallingConvention.Cdecl)]
286308
public abstract void gpgx_set_cdd_callback(cd_read_cb cddcb);
287309

src/BizHawk.Emulation.Cores/CoreNames.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static class CoreNames
2929
public const string GBHawkLink3x = "GBHawkLink3x";
3030
public const string GBHawkLink4x = "GBHawkLink4x";
3131
public const string GGHawkLink = "GGHawkLink";
32-
public const string Gpgx = "Genplus-gx";
32+
public const string Gpgx = "GenesisPlusGX";
3333
public const string Handy = "Handy";
3434
public const string HyperNyma = "HyperNyma";
3535
public const string IntelliHawk = "IntelliHawk";

waterbox/gpgx/.vscode/settings.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

waterbox/gpgx/Genesis-Plus-GX

Submodule Genesis-Plus-GX added at 499dd30

waterbox/gpgx/Makefile

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,87 @@
1-
CCFLAGS := -Icore -Iutil -Icore/m68k -Icore/z80 -Icore/input_hw \
2-
-Icore/cart_hw -Icore/cart_hw/svp -Icore/sound -Icore/ntsc -Icore/cd_hw \
1+
GPGX_DIR := Genesis-Plus-GX
2+
3+
CCFLAGS := -Iutil \
4+
-I${GPGX_DIR}/core \
5+
-I${GPGX_DIR}/core/m68k \
6+
-I${GPGX_DIR}/core/z80 \
7+
-I${GPGX_DIR}/core/input_hw \
8+
-I${GPGX_DIR}/core/cart_hw \
9+
-I${GPGX_DIR}/core/cart_hw/svp \
10+
-I${GPGX_DIR}/core/sound \
11+
-I${GPGX_DIR}/core/ntsc \
12+
-I${GPGX_DIR}/core/cd_hw \
13+
-I${GPGX_DIR}/core/debug \
14+
-Icinterface \
15+
-Iutil \
316
-Wall -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast -Werror=implicit-function-declaration \
4-
-std=c99 -fomit-frame-pointer \
5-
-DLSB_FIRST -DUSE_32BPP_RENDERING -DINLINE=static\ __inline__ -fcommon
17+
-std=c99 -fomit-frame-pointer -Wfatal-errors \
18+
-DUSE_BIZHAWK_CALLBACKS \
19+
-DHAVE_YM3438_CORE \
20+
-DHAVE_OPLL_CORE \
21+
-DUSE_RAM_DEEPFREEZE \
22+
-DLSB_FIRST \
23+
-DUSE_32BPP_RENDERING \
24+
-DHOOK_CPU \
25+
-DINLINE=static\ __inline__ \
26+
-fcommon
627

728
LDFLAGS :=
829

930
TARGET := gpgx.wbx
1031

11-
SRCS = $(shell find $(ROOT_DIR) -type f -name '*.c')
32+
SRCS = $(GPGX_DIR)/core/sound/sound.c \
33+
$(GPGX_DIR)/core/sound/ym3438.c \
34+
$(GPGX_DIR)/core/sound/opll.c \
35+
$(GPGX_DIR)/core/sound/eq.c \
36+
$(GPGX_DIR)/core/sound/ym2413.c \
37+
$(GPGX_DIR)/core/sound/blip_buf.c \
38+
$(GPGX_DIR)/core/sound/psg.c \
39+
$(GPGX_DIR)/core/sound/ym2612.c \
40+
$(GPGX_DIR)/core/membnk.c \
41+
$(GPGX_DIR)/core/vdp_ctrl.c \
42+
$(GPGX_DIR)/core/z80/z80.c \
43+
$(GPGX_DIR)/core/io_ctrl.c \
44+
$(GPGX_DIR)/core/ntsc/sms_ntsc.c \
45+
$(GPGX_DIR)/core/ntsc/md_ntsc.c \
46+
$(GPGX_DIR)/core/m68k/s68kcpu.c \
47+
$(GPGX_DIR)/core/m68k/m68kcpu.c \
48+
$(GPGX_DIR)/core/memz80.c \
49+
$(GPGX_DIR)/core/genesis.c \
50+
$(GPGX_DIR)/core/vdp_render.c \
51+
$(GPGX_DIR)/core/system.c \
52+
$(GPGX_DIR)/core/cd_hw/cd_cart.c \
53+
$(GPGX_DIR)/core/cd_hw/cdc.c \
54+
$(GPGX_DIR)/core/cd_hw/pcm.c \
55+
$(GPGX_DIR)/core/cd_hw/gfx.c \
56+
$(GPGX_DIR)/core/cd_hw/scd.c \
57+
$(GPGX_DIR)/core/cd_hw/cdd.c \
58+
$(GPGX_DIR)/core/input_hw/sportspad.c \
59+
$(GPGX_DIR)/core/input_hw/activator.c \
60+
$(GPGX_DIR)/core/input_hw/mouse.c \
61+
$(GPGX_DIR)/core/input_hw/paddle.c \
62+
$(GPGX_DIR)/core/input_hw/gamepad.c \
63+
$(GPGX_DIR)/core/input_hw/input.c \
64+
$(GPGX_DIR)/core/input_hw/terebi_oekaki.c \
65+
$(GPGX_DIR)/core/input_hw/teamplayer.c \
66+
$(GPGX_DIR)/core/input_hw/graphic_board.c \
67+
$(GPGX_DIR)/core/input_hw/lightgun.c \
68+
$(GPGX_DIR)/core/input_hw/xe_1ap.c \
69+
$(GPGX_DIR)/core/mem68k.c \
70+
$(GPGX_DIR)/core/cart_hw/svp/ssp16.c \
71+
$(GPGX_DIR)/core/cart_hw/svp/svp.c \
72+
$(GPGX_DIR)/core/cart_hw/areplay.c \
73+
$(GPGX_DIR)/core/cart_hw/eeprom_spi.c \
74+
$(GPGX_DIR)/core/cart_hw/sram.c \
75+
$(GPGX_DIR)/core/cart_hw/eeprom_93c.c \
76+
$(GPGX_DIR)/core/cart_hw/sms_cart.c \
77+
$(GPGX_DIR)/core/cart_hw/eeprom_i2c.c \
78+
$(GPGX_DIR)/core/cart_hw/ggenie.c \
79+
$(GPGX_DIR)/core/cart_hw/md_cart.c \
80+
$(GPGX_DIR)/core/cart_hw/megasd.c \
81+
$(GPGX_DIR)/core/debug/cpuhook.c \
82+
$(GPGX_DIR)/core/loadrom.c \
83+
cinterface/cddImpl.c \
84+
cinterface/cinterface.c \
85+
util/scrc32.c
1286

1387
include ../common.mak

waterbox/gpgx/cinterface/callbacks.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ typedef ECL_ENTRY void (*CDCallback)(int32 addr, int32 addrtype, int32 flags);
1010
extern ECL_ENTRY void (*biz_execcb)(unsigned addr);
1111
extern ECL_ENTRY void (*biz_readcb)(unsigned addr);
1212
extern ECL_ENTRY void (*biz_writecb)(unsigned addr);
13-
extern CDCallback biz_cdcallback;
14-
extern unsigned biz_lastpc;
13+
extern CDCallback biz_cdcb;
1514

1615
extern ECL_ENTRY void (*cdd_readcallback)(int lba, void *dest, int audio);
1716

0 commit comments

Comments
 (0)