Revamp Waterbox Setup (#3529)
* Waterbox setup has been revamped to use the latest llvm parts (llvm 16 for compiler_rt/libunwind/libcxx/libcxxabi). * Clang is now possible to use, and is the preferred compiler (due to superior performance). * Supported compilers are now clang 14/15/16, and gcc 12. * Other core updates are mixed in. --------- Co-authored-by: Morilli <35152647+Morilli@users.noreply.github.com>
This commit is contained in:
parent
44322e6a7d
commit
0a2d4405f0
|
@ -31,6 +31,7 @@
|
|||
[submodule "waterbox/llvm-project"]
|
||||
path = waterbox/llvm-project
|
||||
url = https://github.com/llvm/llvm-project.git
|
||||
branch = llvmorg-16.0.0
|
||||
[submodule "submodules/libdarm"]
|
||||
path = submodules/libdarm
|
||||
url = https://github.com/jbremer/darm.git
|
||||
|
@ -54,7 +55,7 @@
|
|||
[submodule "waterbox/mame-arcade/mame"]
|
||||
path = waterbox/mame-arcade/mame
|
||||
url = https://github.com/TASEmulators/mame.git
|
||||
branch = mamehawk0250
|
||||
branch = mamehawk0252
|
||||
[submodule "ExternalProjects/librcheevos/rcheevos"]
|
||||
path = ExternalProjects/librcheevos/rcheevos
|
||||
url = https://github.com/RetroAchievements/rcheevos.git
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -61,6 +61,13 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
[BizImport(cc)]
|
||||
public abstract void mame_nvram_load();
|
||||
|
||||
// info
|
||||
[UnmanagedFunctionPointer(cc)]
|
||||
public delegate void InfoCallbackDelegate(string info);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void mame_info_get_warnings_string(InfoCallbackDelegate cb);
|
||||
|
||||
// log
|
||||
[UnmanagedFunctionPointer(cc)]
|
||||
public delegate void LogCallbackDelegate(OutputChannel channel, int size, string data);
|
||||
|
|
|
@ -14,7 +14,7 @@ using BizHawk.Emulation.Cores.Waterbox;
|
|||
|
||||
namespace BizHawk.Emulation.Cores.Arcades.MAME
|
||||
{
|
||||
[PortedCore(CoreNames.MAME, "MAMEDev", "0.250", "https://github.com/mamedev/mame.git", isReleased: true)]
|
||||
[PortedCore(CoreNames.MAME, "MAMEDev", "0.252", "https://github.com/mamedev/mame.git")]
|
||||
public partial class MAME : IRomInfo
|
||||
{
|
||||
[CoreConstructor(VSystemID.Raw.Arcade)]
|
||||
|
@ -32,6 +32,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
_baseTimeCallback = MAMEBaseTimeCallback;
|
||||
_inputPollCallback = InputCallbacks.Call;
|
||||
_filenameCallback = name => _nvramFilenames.Add(name);
|
||||
_infoCallback = info => lp.Comm.Notify(info);
|
||||
|
||||
_exe = new(new()
|
||||
{
|
||||
|
@ -48,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
|
||||
using (_exe.EnterExit())
|
||||
{
|
||||
_adapter = CallingConventionAdapters.MakeWaterbox(new Delegate[] { _logCallback, _baseTimeCallback, _inputPollCallback, _filenameCallback }, _exe);
|
||||
_adapter = CallingConventionAdapters.MakeWaterbox(new Delegate[] { _logCallback, _baseTimeCallback, _inputPollCallback, _filenameCallback, _infoCallback }, _exe);
|
||||
_core = BizInvoker.GetInvoker<LibMAME>(_exe, _exe, _adapter);
|
||||
StartMAME(lp.Roms);
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
if (_loadFailure != string.Empty)
|
||||
{
|
||||
Dispose();
|
||||
throw new Exception("\n\n" + _loadFailure);
|
||||
throw new("\n\n" + _loadFailure);
|
||||
}
|
||||
|
||||
RomDetails = _gameFullName + "\r\n" + string.Join("\r\n", _romHashes.Select(static r => $"{r.Key} - {r.Value}"));
|
||||
|
@ -72,6 +73,9 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
lp.Game.Hash = SHA1Checksum.ComputeDigestHex(Encoding.ASCII.GetBytes(hashes));
|
||||
lp.Game.Status = _romHashes.Values.Any(static s => s is "NO GOOD DUMP KNOWN") ? RomStatus.Unknown : RomStatus.GoodDump;
|
||||
|
||||
_core.mame_info_get_warnings_string(_infoCallback);
|
||||
_infoCallback = null;
|
||||
|
||||
_exe.Seal();
|
||||
}
|
||||
|
||||
|
@ -82,6 +86,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
private readonly LibMAME.LogCallbackDelegate _logCallback;
|
||||
private readonly LibMAME.BaseTimeCallbackDelegate _baseTimeCallback;
|
||||
private readonly LibMAME.InputPollCallbackDelegate _inputPollCallback;
|
||||
private readonly LibMAME.InfoCallbackDelegate _infoCallback;
|
||||
|
||||
public string RomDetails { get; }
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
|
||||
public PutSettingsDirtyBits PutSettings(Ares64Settings o)
|
||||
{
|
||||
var ret = Ares64Settings.NeedsReboot(_settings, o);
|
||||
_settings = o;
|
||||
return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None;
|
||||
return PutSettingsDirtyBits.None;
|
||||
}
|
||||
|
||||
public PutSettingsDirtyBits PutSyncSettings(Ares64SyncSettings o)
|
||||
|
@ -39,14 +38,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
[DefaultValue(LibAres64.DeinterlacerType.Weave)]
|
||||
public LibAres64.DeinterlacerType Deinterlacer { get; set; }
|
||||
|
||||
[DisplayName("Skip VI Processing")]
|
||||
[Description("Skips video filtering done by the VI. Gives a minor performance boost but may worsen video quality.")]
|
||||
[DefaultValue(false)]
|
||||
public bool FastVI { get; set; }
|
||||
|
||||
public Ares64Settings()
|
||||
=> SettingsUtil.SetDefaultValues(this);
|
||||
|
||||
public Ares64Settings Clone()
|
||||
=> (Ares64Settings)MemberwiseClone();
|
||||
|
||||
public static bool NeedsReboot(Ares64Settings x, Ares64Settings y)
|
||||
=> !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
|
||||
public class Ares64SyncSettings
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
||||
{
|
||||
public partial class Ares64
|
||||
{
|
||||
private ITraceable Tracer { get; }
|
||||
private readonly LibAres64.TraceCallback _tracecb;
|
||||
|
||||
private void MakeTrace(IntPtr disasm)
|
||||
{
|
||||
var disasmStr = Mershul.PtrToStringUtf8(disasm);
|
||||
if (!disasmStr.StartsWith("CPU")) // garbage, ignore
|
||||
{
|
||||
return;
|
||||
}
|
||||
disasmStr = disasmStr.Remove(0, 5); // remove "CPU "
|
||||
disasmStr = disasmStr.Replace("\n", ""); // remove newlines
|
||||
disasmStr = Regex.Replace(disasmStr, @"\{.*\}", ""); // remove any {*} patterns
|
||||
disasmStr = disasmStr.PadRight(36); // pad
|
||||
|
||||
var regs = GetCpuFlagsAndRegisters();
|
||||
var regsStr = "";
|
||||
foreach (var r in regs)
|
||||
{
|
||||
if (r.Key is not "PC")
|
||||
{
|
||||
regsStr += r.Key + $":{r.Value.Value:X16} ";
|
||||
}
|
||||
}
|
||||
|
||||
regsStr = regsStr.Remove(regsStr.Length - 1, 1);
|
||||
|
||||
Tracer.Put(new(
|
||||
disassembly: disasmStr,
|
||||
registerInfo: regsStr));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,19 +45,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
};
|
||||
|
||||
N64Controller = CreateControllerDefinition(ControllerSettings);
|
||||
_tracecb = MakeTrace;
|
||||
|
||||
_core = PreInit<LibAres64>(new WaterboxOptions
|
||||
{
|
||||
Filename = "ares64.wbx",
|
||||
SbrkHeapSizeKB = 2 * 1024,
|
||||
SealedHeapSizeKB = 4,
|
||||
InvisibleHeapSizeKB = 6 * 1024,
|
||||
InvisibleHeapSizeKB = 22 * 1024,
|
||||
PlainHeapSizeKB = 4,
|
||||
MmapHeapSizeKB = 512 * 1024,
|
||||
SkipCoreConsistencyCheck = CoreComm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
|
||||
SkipMemoryConsistencyCheck = CoreComm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
|
||||
}, new[] { _tracecb, });
|
||||
});
|
||||
|
||||
static bool IsGBRom(byte[] rom)
|
||||
{
|
||||
|
@ -154,7 +153,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
Gb4RomData = (IntPtr)gb4RomPtr,
|
||||
Gb4RomLen = GetGBRomOrNull(3)?.Length ?? 0,
|
||||
};
|
||||
if (!_core.Init(ref loadData, ControllerSettings, pal, _settings.Deinterlacer == LibAres64.DeinterlacerType.Bob, GetRtcTime(!DeterministicEmulation)))
|
||||
if (!_core.Init(ref loadData, ControllerSettings, pal, GetRtcTime(!DeterministicEmulation)))
|
||||
{
|
||||
throw new InvalidOperationException("Init returned false!");
|
||||
}
|
||||
|
@ -163,9 +162,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
|
||||
PostInit();
|
||||
|
||||
Tracer = new TraceBuffer("r3400: PC, mnemonic, operands, registers (GPRs, MultLO, MultHI)");
|
||||
_serviceProvider.Register(Tracer);
|
||||
|
||||
_disassembler = new(_core);
|
||||
_serviceProvider.Register<IDisassemblable>(_disassembler);
|
||||
}
|
||||
|
@ -257,8 +253,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
|
||||
protected override LibWaterboxCore.FrameInfo FrameAdvancePrep(IController controller, bool render, bool rendersound)
|
||||
{
|
||||
_core.SetTraceCallback(Tracer.IsEnabled() ? _tracecb : null);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (ControllerSettings[i] == LibAres64.ControllerType.Rumblepak)
|
||||
|
@ -290,9 +284,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
|
||||
Reset = controller.IsPressed("Reset"),
|
||||
Power = controller.IsPressed("Power"),
|
||||
|
||||
BobDeinterlacer = _settings.Deinterlacer == LibAres64.DeinterlacerType.Bob,
|
||||
FastVI = _settings.FastVI,
|
||||
SkipDraw = !render,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadStateBinaryInternal(BinaryReader reader)
|
||||
=> _core.PostLoadState();
|
||||
|
||||
// creates an "error table" for the disk
|
||||
// see https://github.com/ares-emulator/ares/blob/09aa6346c71a770fc68e9540d86156dd4769d677/mia/medium/nintendo-64dd.cpp#L102-L189
|
||||
private static byte[] CreateErrorTable(byte[] disk)
|
||||
|
|
|
@ -74,6 +74,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
|
||||
public bool Reset;
|
||||
public bool Power;
|
||||
|
||||
public bool BobDeinterlacer;
|
||||
public bool FastVI;
|
||||
public bool SkipDraw;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
@ -100,20 +104,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Ares64
|
|||
}
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract bool Init(ref LoadData loadData, ControllerType[] controllerSettings, bool isPal, bool bobDeinterlace, long initTime);
|
||||
public abstract bool Init(ref LoadData loadData, ControllerType[] controllerSettings, bool isPal, long initTime);
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract bool GetRumbleStatus(int num);
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract void PostLoadState();
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract void GetDisassembly(uint address, uint instruction, byte[] buf);
|
||||
|
||||
[UnmanagedFunctionPointer(CC)]
|
||||
public delegate void TraceCallback(IntPtr disasm);
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract void SetTraceCallback(TraceCallback callback);
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract void GetRegisters(ulong[] buf);
|
||||
}
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
From c9af34027bc9cb852a4e5e96154a7bd89531a6de Mon Sep 17 00:00:00 2001
|
||||
From: Craig Topper <craig.topper@intel.com>
|
||||
Date: Wed, 16 Sep 2020 21:56:01 -0700
|
||||
Subject: [PATCH] Add __divmodti4 to match libgcc.
|
||||
|
||||
gcc has used this on x86-64 since at least version 7.
|
||||
|
||||
Reviewed By: MaskRay
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D80506
|
||||
---
|
||||
compiler-rt/lib/builtins/CMakeLists.txt | 1 +
|
||||
compiler-rt/lib/builtins/README.txt | 2 +
|
||||
compiler-rt/lib/builtins/divmodti4.c | 32 +++++++
|
||||
.../test/builtins/Unit/divmodti4_test.c | 91 +++++++++++++++++++
|
||||
4 files changed, 126 insertions(+)
|
||||
create mode 100644 compiler-rt/lib/builtins/divmodti4.c
|
||||
create mode 100644 compiler-rt/test/builtins/Unit/divmodti4_test.c
|
||||
|
||||
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
index 8dbe15364ab8..3c50df179764 100644
|
||||
--- a/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
@@ -71,6 +71,7 @@ set(GENERIC_SOURCES
|
||||
divdi3.c
|
||||
divmoddi4.c
|
||||
divmodsi4.c
|
||||
+ divmodti4.c
|
||||
divsc3.c
|
||||
divsf3.c
|
||||
divsi3.c
|
||||
diff --git a/compiler-rt/lib/builtins/README.txt b/compiler-rt/lib/builtins/README.txt
|
||||
index f9e1bc805092..d66d725e7ab5 100644
|
||||
--- a/compiler-rt/lib/builtins/README.txt
|
||||
+++ b/compiler-rt/lib/builtins/README.txt
|
||||
@@ -87,6 +87,8 @@ du_int __udivmoddi4(du_int a, du_int b, du_int* rem); // a / b, *rem = a % b u
|
||||
tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); // a / b, *rem = a % b unsigned
|
||||
su_int __udivmodsi4(su_int a, su_int b, su_int* rem); // a / b, *rem = a % b unsigned
|
||||
si_int __divmodsi4(si_int a, si_int b, si_int* rem); // a / b, *rem = a % b signed
|
||||
+di_int __divmoddi4(di_int a, di_int b, di_int* rem); // a / b, *rem = a % b signed
|
||||
+ti_int __divmodti4(ti_int a, ti_int b, ti_int* rem); // a / b, *rem = a % b signed
|
||||
|
||||
|
||||
|
||||
diff --git a/compiler-rt/lib/builtins/divmodti4.c b/compiler-rt/lib/builtins/divmodti4.c
|
||||
new file mode 100644
|
||||
index 000000000000..b243ba4ef853
|
||||
--- /dev/null
|
||||
+++ b/compiler-rt/lib/builtins/divmodti4.c
|
||||
@@ -0,0 +1,32 @@
|
||||
+//===-- divmodti4.c - Implement __divmodti4 -------------------------------===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
+// See https://llvm.org/LICENSE.txt for license information.
|
||||
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+//
|
||||
+// This file implements __divmodti4 for the compiler_rt library.
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+#include "int_lib.h"
|
||||
+
|
||||
+#ifdef CRT_HAS_128BIT
|
||||
+
|
||||
+// Returns: a / b, *rem = a % b
|
||||
+
|
||||
+COMPILER_RT_ABI ti_int __divmodti4(ti_int a, ti_int b, ti_int *rem) {
|
||||
+ const int bits_in_tword_m1 = (int)(sizeof(ti_int) * CHAR_BIT) - 1;
|
||||
+ ti_int s_a = a >> bits_in_tword_m1; // s_a = a < 0 ? -1 : 0
|
||||
+ ti_int s_b = b >> bits_in_tword_m1; // s_b = b < 0 ? -1 : 0
|
||||
+ a = (a ^ s_a) - s_a; // negate if s_a == -1
|
||||
+ b = (b ^ s_b) - s_b; // negate if s_b == -1
|
||||
+ s_b ^= s_a; // sign of quotient
|
||||
+ tu_int r;
|
||||
+ ti_int q = (__udivmodti4(a, b, &r) ^ s_b) - s_b; // negate if s_b == -1
|
||||
+ *rem = (r ^ s_a) - s_a; // negate if s_a == -1
|
||||
+ return q;
|
||||
+}
|
||||
+
|
||||
+#endif // CRT_HAS_128BIT
|
||||
diff --git a/compiler-rt/test/builtins/Unit/divmodti4_test.c b/compiler-rt/test/builtins/Unit/divmodti4_test.c
|
||||
new file mode 100644
|
||||
index 000000000000..a9f70dcf1c1e
|
||||
--- /dev/null
|
||||
+++ b/compiler-rt/test/builtins/Unit/divmodti4_test.c
|
||||
@@ -0,0 +1,91 @@
|
||||
+// RUN: %clang_builtins %s %librt -o %t && %run %t
|
||||
+// REQUIRES: librt_has_divmodti4
|
||||
+// REQUIRES: int128
|
||||
+//===-- divmodti4_test.c - Test __divmodti4 -------------------------------===//
|
||||
+//
|
||||
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
+// See https://llvm.org/LICENSE.txt for license information.
|
||||
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+//
|
||||
+// This file tests __divmodti4 for the compiler_rt library.
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+#include "int_lib.h"
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+#ifdef CRT_HAS_128BIT
|
||||
+
|
||||
+// Effects: if rem != 0, *rem = a % b
|
||||
+// Returns: a / b
|
||||
+
|
||||
+COMPILER_RT_ABI ti_int __divmodti4(ti_int a, ti_int b, ti_int* rem);
|
||||
+
|
||||
+int test__divmodti4(ti_int a, ti_int b, ti_int expected_q, ti_int expected_r) {
|
||||
+ ti_int r;
|
||||
+ ti_int q = __divmodti4(a, b, &r);
|
||||
+ if (q != expected_q || r != expected_r)
|
||||
+ {
|
||||
+ utwords at;
|
||||
+ at.all = a;
|
||||
+ utwords bt;
|
||||
+ bt.all = b;
|
||||
+ utwords expected_qt;
|
||||
+ expected_qt.all = expected_q;
|
||||
+ utwords expected_rt;
|
||||
+ expected_rt.all = expected_r;
|
||||
+ utwords qt;
|
||||
+ qt.all = q;
|
||||
+ utwords rt;
|
||||
+ rt.all = r;
|
||||
+ printf("error in __divmodti4: 0x%.16llX%.16llX / 0x%.16llX%.16llX = "
|
||||
+ "0x%.16llX%.16llX, R = 0x%.16llX%.16llX, expected 0x%.16llX%.16llX, "
|
||||
+ "0x%.16llX%.16llX\n",
|
||||
+ at.s.high, at.s.low, bt.s.high, bt.s.low, qt.s.high, qt.s.low,
|
||||
+ rt.s.high, rt.s.low, expected_qt.s.high, expected_qt.s.low,
|
||||
+ expected_rt.s.high, expected_rt.s.low);
|
||||
+ }
|
||||
+ return !(q == expected_q && r == expected_r);
|
||||
+}
|
||||
+
|
||||
+char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
|
||||
+
|
||||
+tu_int tests[][4] =
|
||||
+{
|
||||
+{ (ti_int) 0, (ti_int) 1, (ti_int) 0, (ti_int) 0 },
|
||||
+{ (ti_int) 0, (ti_int)-1, (ti_int) 0, (ti_int) 0 },
|
||||
+{ (ti_int) 2, (ti_int) 1, (ti_int) 2, (ti_int) 0 },
|
||||
+{ (ti_int) 2, (ti_int)-1, (ti_int)-2, (ti_int) 0 },
|
||||
+{ (ti_int)-2, (ti_int) 1, (ti_int)-2, (ti_int) 0 },
|
||||
+{ (ti_int)-2, (ti_int)-1, (ti_int) 2, (ti_int) 0 },
|
||||
+{ (ti_int) 5, (ti_int) 3, (ti_int) 1, (ti_int) 2 },
|
||||
+{ (ti_int) 5, (ti_int)-3, (ti_int)-1, (ti_int) 2 },
|
||||
+{ (ti_int)-5, (ti_int) 3, (ti_int)-1, (ti_int)-2 },
|
||||
+{ (ti_int)-5, (ti_int)-3, (ti_int) 1, (ti_int)-2 },
|
||||
+{ (ti_int)0x8000000000000000LL << 64 | 0, (ti_int) 1, (ti_int)0x8000000000000000LL << 64 | 0, (ti_int)0x0LL },
|
||||
+{ (ti_int)0x8000000000000000LL << 64 | 0, (ti_int)-1, (ti_int)0x8000000000000000LL << 64 | 0, (ti_int)0x0LL },
|
||||
+{ (ti_int)0x8000000000000000LL << 64 | 0, (ti_int)-2, (ti_int)0x4000000000000000LL << 64 | 0, (ti_int)0x0LL },
|
||||
+{ (ti_int)0x8000000000000000LL << 64 | 0, (ti_int) 2, (ti_int)0xC000000000000000LL << 64 | 0, (ti_int)0x0LL },
|
||||
+{ (ti_int)0x8000000000000000LL << 64 | 0, (ti_int)-3, (ti_int)0x2AAAAAAAAAAAAAAALL << 64 | 0xAAAAAAAAAAAAAAAALL, (ti_int)-2 },
|
||||
+{ (ti_int)0x8000000000000000LL << 64 | 0, (ti_int) 3, (ti_int)0xD555555555555555LL << 64 | 0x5555555555555556LL, (ti_int)-2 },
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+#ifdef CRT_HAS_128BIT
|
||||
+ const unsigned N = sizeof(tests) / sizeof(tests[0]);
|
||||
+ unsigned i;
|
||||
+ for (i = 0; i < N; ++i)
|
||||
+ if (test__divmodti4(tests[i][0], tests[i][1], tests[i][2], tests[i][3]))
|
||||
+ return 1;
|
||||
+
|
||||
+
|
||||
+#else
|
||||
+ printf("skipped\n");
|
||||
+#endif
|
||||
+ return 0;
|
||||
+}
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -3,8 +3,6 @@
|
|||
#include <emulibc.h>
|
||||
#include <waterboxcore.h>
|
||||
|
||||
#define EXPORT extern "C" ECL_EXPORT
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Unplugged,
|
||||
|
@ -44,22 +42,15 @@ struct BizPlatform : ares::Platform
|
|||
{
|
||||
auto attach(ares::Node::Object) -> void override;
|
||||
auto pak(ares::Node::Object) -> ares::VFS::Pak override;
|
||||
auto log(string_view) -> void override;
|
||||
auto video(ares::Node::Video::Screen, const u32*, u32, u32, u32) -> void override;
|
||||
auto audio(ares::Node::Audio::Stream) -> void override;
|
||||
auto input(ares::Node::Input::Input) -> void override;
|
||||
|
||||
ares::VFS::Pak bizpak = nullptr;
|
||||
u32* videobuf = nullptr;
|
||||
u32 pitch = 0;
|
||||
u32 width = 0;
|
||||
u32 height = 0;
|
||||
u16* soundbuf = alloc_invisible<u16>(1024 * 2);
|
||||
u32 nsamps = 0;
|
||||
bool hack = false;
|
||||
void (*inputcb)() = nullptr;
|
||||
bool lagged = true;
|
||||
void (*tracecb)(const char*) = nullptr;
|
||||
};
|
||||
|
||||
auto BizPlatform::attach(ares::Node::Object node) -> void
|
||||
|
@ -75,19 +66,6 @@ auto BizPlatform::pak(ares::Node::Object) -> ares::VFS::Pak
|
|||
return bizpak;
|
||||
}
|
||||
|
||||
auto BizPlatform::log(string_view message) -> void
|
||||
{
|
||||
if (tracecb) tracecb(message.data());
|
||||
}
|
||||
|
||||
auto BizPlatform::video(ares::Node::Video::Screen screen, const u32* data, u32 pitch, u32 width, u32 height) -> void
|
||||
{
|
||||
videobuf = (u32*)data;
|
||||
this->pitch = pitch >> 2;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
auto BizPlatform::audio(ares::Node::Audio::Stream stream) -> void
|
||||
{
|
||||
while (stream->pending())
|
||||
|
@ -346,7 +324,11 @@ static inline SaveType DetectSaveType(u8* rom)
|
|||
return ret;
|
||||
}
|
||||
|
||||
namespace ares::Nintendo64 { extern bool BobDeinterlace; }
|
||||
namespace ares::Nintendo64
|
||||
{
|
||||
extern bool BobDeinterlace;
|
||||
extern bool FastVI;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -470,7 +452,13 @@ static bool LoadDisk(LoadData* loadData)
|
|||
return true;
|
||||
}
|
||||
|
||||
EXPORT bool Init(LoadData* loadData, ControllerType* controllers, bool isPal, bool bobDeinterlace, u64 initTime)
|
||||
namespace angrylion
|
||||
{
|
||||
extern u32 * OutFrameBuffer;
|
||||
extern u32 OutHeight;
|
||||
}
|
||||
|
||||
ECL_EXPORT bool Init(LoadData* loadData, ControllerType* controllers, bool isPal, u64 initTime)
|
||||
{
|
||||
platform = new BizPlatform;
|
||||
platform->bizpak = new vfs::directory;
|
||||
|
@ -479,6 +467,9 @@ EXPORT bool Init(LoadData* loadData, ControllerType* controllers, bool isPal, bo
|
|||
biztime = initTime;
|
||||
ares::Nintendo64::dd.rtcCallback = GetBizTime;
|
||||
|
||||
angrylion::OutFrameBuffer = NULL;
|
||||
angrylion::OutHeight = isPal ? 576 : 480;
|
||||
|
||||
u8* data;
|
||||
u32 len;
|
||||
string name;
|
||||
|
@ -593,8 +584,6 @@ EXPORT bool Init(LoadData* loadData, ControllerType* controllers, bool isPal, bo
|
|||
SET_RTC_CALLBACK(3);
|
||||
SET_RTC_CALLBACK(4);
|
||||
|
||||
ares::Nintendo64::BobDeinterlace = bobDeinterlace;
|
||||
|
||||
root->power(false);
|
||||
root->run(); // HACK, first frame dirties a ton of memory, so we emulate it then seal (this should be investigated, not sure why 60MBish of memory would be dirtied in a single frame?)
|
||||
return true;
|
||||
|
@ -602,7 +591,7 @@ EXPORT bool Init(LoadData* loadData, ControllerType* controllers, bool isPal, bo
|
|||
|
||||
// todo: might need to account for mbc5 rumble?
|
||||
// largely pointless tho
|
||||
EXPORT bool GetRumbleStatus(u32 num)
|
||||
ECL_EXPORT bool GetRumbleStatus(u32 num)
|
||||
{
|
||||
ares::Nintendo64::Gamepad* c = nullptr;
|
||||
switch (num)
|
||||
|
@ -710,7 +699,7 @@ static void SysBusAccess(u8* buffer, u64 address, u64 count, bool write)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
ECL_EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
{
|
||||
int i = 0;
|
||||
ADD_MEMORY_DOMAIN(rdram.ram, "RDRAM", MEMORYAREA_FLAGS_PRIMARY);
|
||||
|
@ -760,6 +749,10 @@ struct MyFrameInfo : public FrameInfo
|
|||
|
||||
bool Reset;
|
||||
bool Power;
|
||||
|
||||
bool BobDeinterlace;
|
||||
bool FastVI;
|
||||
bool SkipDraw;
|
||||
};
|
||||
|
||||
#define UPDATE_CONTROLLER(NUM) do { \
|
||||
|
@ -791,8 +784,13 @@ struct MyFrameInfo : public FrameInfo
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
{
|
||||
ares::Nintendo64::BobDeinterlace = f->BobDeinterlace;
|
||||
ares::Nintendo64::FastVI = f->FastVI;
|
||||
|
||||
angrylion::OutFrameBuffer = f->SkipDraw ? NULL : f->VideoBuffer;
|
||||
|
||||
biztime = f->Time;
|
||||
|
||||
if (f->Power)
|
||||
|
@ -814,16 +812,8 @@ EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
|
||||
root->run();
|
||||
|
||||
f->Width = platform->width;
|
||||
f->Height = platform->height;
|
||||
u32* src = platform->videobuf;
|
||||
u32* dst = f->VideoBuffer;
|
||||
for (int i = 0; i < f->Height; i++)
|
||||
{
|
||||
memcpy(dst, src, f->Width * 4);
|
||||
dst += f->Width;
|
||||
src += platform->pitch;
|
||||
}
|
||||
f->Width = 640;
|
||||
f->Height = angrylion::OutHeight;
|
||||
|
||||
f->Samples = platform->nsamps;
|
||||
memcpy(f->SoundBuffer, platform->soundbuf, f->Samples * 4);
|
||||
|
@ -831,24 +821,23 @@ EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
f->Lagged = platform->lagged;
|
||||
}
|
||||
|
||||
EXPORT void SetInputCallback(void (*callback)())
|
||||
ECL_EXPORT void SetInputCallback(void (*callback)())
|
||||
{
|
||||
platform->inputcb = callback;
|
||||
}
|
||||
|
||||
EXPORT void GetDisassembly(u32 address, u32 instruction, char* buf)
|
||||
ECL_EXPORT void PostLoadState()
|
||||
{
|
||||
ares::Nintendo64::cpu.recompiler.reset();
|
||||
}
|
||||
|
||||
ECL_EXPORT void GetDisassembly(u32 address, u32 instruction, char* buf)
|
||||
{
|
||||
auto s = ares::Nintendo64::cpu.disassembler.disassemble(address, instruction).strip();
|
||||
strcpy(buf, s.data());
|
||||
}
|
||||
|
||||
EXPORT void SetTraceCallback(void (*callback)(const char*))
|
||||
{
|
||||
ares::Nintendo64::cpu.debugger.tracer.instruction->setEnabled(!!callback);
|
||||
platform->tracecb = callback;
|
||||
}
|
||||
|
||||
EXPORT void GetRegisters(u64* buf)
|
||||
ECL_EXPORT void GetRegisters(u64* buf)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
|
|
|
@ -5,12 +5,14 @@ THIRDPARTY_PATH = $(ROOT_DIR)/ares/thirdparty
|
|||
ANGRYLION_PATH = $(THIRDPARTY_PATH)/angrylion-rdp/mylittle-nocomment
|
||||
SLJIT_PATH = $(THIRDPARTY_PATH)/sljit/sljit_src
|
||||
|
||||
CXXFLAGS := -std=gnu++17 -march=nehalem \
|
||||
CXXFLAGS := -std=gnu++17 -march=x86-64-v2 \
|
||||
-I../libco -I.$(ROOT_DIR)/ares -I.$(ARES_PATH) -I.$(THIRDPARTY_PATH) -I.$(ANGRYLION_PATH) \
|
||||
-Werror=int-to-pointer-cast -Wno-unused-but-set-variable -Wno-format-security \
|
||||
-Wno-parentheses -Wno-reorder -Wno-unused-variable -Wno-delete-non-virtual-dtor \
|
||||
-Wno-sign-compare -Wno-switch -Wno-unused-local-typedefs -Wno-bool-operation \
|
||||
-fno-strict-aliasing -fwrapv -fno-operator-names -fexpensive-optimizations \
|
||||
-Wno-mismatched-tags -Wno-missing-braces -Wno-overloaded-virtual \
|
||||
-Wno-unused-private-field -Wno-sometimes-uninitialized \
|
||||
-fno-strict-aliasing -fwrapv -fno-operator-names \
|
||||
-DSLJIT_HAVE_CONFIG_PRE=1 -DSLJIT_HAVE_CONFIG_POST=1
|
||||
|
||||
TARGET = ares64.wbx
|
||||
|
@ -41,11 +43,9 @@ SRCS_N64 = \
|
|||
$(ARES_PATH)/n64/rdp/rdp.cpp
|
||||
|
||||
SRCS_ANGRYLION = \
|
||||
$(ANGRYLION_PATH)/main.cpp \
|
||||
$(ANGRYLION_PATH)/angrylion.cpp \
|
||||
$(ANGRYLION_PATH)/n64video.cpp
|
||||
|
||||
#note these are not actually used as recompiler is disabled
|
||||
#these still need to be built though if you want a debug build
|
||||
SRCS_SLJIT = \
|
||||
$(SLJIT_PATH)/sljitLir.c \
|
||||
$(THIRDPARTY_PATH)/sljitAllocator.cpp
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace ares::Memory {
|
|||
FixedAllocator::FixedAllocator() {
|
||||
}
|
||||
#else
|
||||
alignas(4096) u8 fixedBuffer[128_MiB];
|
||||
alignas(4096) u8 fixedBuffer[8_MiB];
|
||||
|
||||
FixedAllocator::FixedAllocator() {
|
||||
_allocator.resize(sizeof(fixedBuffer), 0, fixedBuffer);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
struct Accuracy {
|
||||
//enable all accuracy flags
|
||||
static constexpr bool Reference = 1;
|
||||
static constexpr bool Reference = 0;
|
||||
|
||||
struct CPU {
|
||||
static constexpr bool Interpreter = 0 | Reference;
|
||||
|
@ -15,7 +15,7 @@ struct Accuracy {
|
|||
static constexpr bool Recompiler = !Interpreter;
|
||||
|
||||
//VU instructions
|
||||
static constexpr bool SISD = 0;// | Reference | !ARCHITECTURE_SUPPORTS_SSE4_1;
|
||||
static constexpr bool SISD = 0 | Reference | !ARCHITECTURE_SUPPORTS_SSE4_1;
|
||||
static constexpr bool SIMD = !SISD;
|
||||
};
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ auto CPU::instruction() -> void {
|
|||
|
||||
if constexpr(Accuracy::CPU::Recompiler) {
|
||||
auto address = devirtualize(ipu.pc)(0);
|
||||
auto block = recompiler.block(address);
|
||||
block->execute(*this);
|
||||
auto& block = recompiler.block(address);
|
||||
block.execute(*this);
|
||||
}
|
||||
|
||||
if constexpr(Accuracy::CPU::Interpreter) {
|
||||
|
@ -143,8 +143,8 @@ auto CPU::power(bool reset) -> void {
|
|||
context.setMode();
|
||||
|
||||
if constexpr(Accuracy::CPU::Recompiler) {
|
||||
auto buffer = ares::Memory::FixedAllocator::get().tryAcquire(64_MiB);
|
||||
recompiler.allocator.resize(64_MiB, bump_allocator::executable | bump_allocator::zero_fill, buffer);
|
||||
auto buffer = ares::Memory::FixedAllocator::get().tryAcquire(4_MiB);
|
||||
recompiler.allocator.resize(4_MiB, bump_allocator::executable | bump_allocator::zero_fill, buffer);
|
||||
recompiler.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -821,7 +821,8 @@ struct CPU : Thread {
|
|||
};
|
||||
|
||||
struct Pool {
|
||||
Block* blocks[1 << 6];
|
||||
Block blocks[1 << 6];
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
auto reset() -> void {
|
||||
|
@ -841,13 +842,14 @@ struct CPU : Thread {
|
|||
auto pool = pools[address >> 8 & 0x1fffff];
|
||||
if(!pool) return;
|
||||
memory::jitprotect(false);
|
||||
pool->blocks[address >> 2 & 0x3f] = nullptr;
|
||||
pool->blocks[address >> 2 & 0x3f].code = nullptr;
|
||||
memory::jitprotect(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
auto invalidatePool(u32 address) -> void {
|
||||
pools[address >> 8 & 0x1fffff] = nullptr;
|
||||
auto pool = pools[address >> 8 & 0x1fffff];
|
||||
if(pool && pool->dirty) memory::fill(pool, sizeof(Pool));
|
||||
}
|
||||
|
||||
auto invalidateRange(u32 address, u32 length) -> void {
|
||||
|
@ -857,9 +859,9 @@ struct CPU : Thread {
|
|||
}
|
||||
|
||||
auto pool(u32 address) -> Pool*;
|
||||
auto block(u32 address) -> Block*;
|
||||
auto block(u32 address) -> Block&;
|
||||
|
||||
auto emit(u32 address) -> Block*;
|
||||
auto emit(u32 address, Block& block) -> void;
|
||||
auto emitEXECUTE(u32 instruction) -> bool;
|
||||
auto emitSPECIAL(u32 instruction) -> bool;
|
||||
auto emitREGIMM(u32 instruction) -> bool;
|
||||
|
@ -868,7 +870,7 @@ struct CPU : Thread {
|
|||
auto emitCOP2(u32 instruction) -> bool;
|
||||
|
||||
bump_allocator allocator;
|
||||
Pool* pools[1 << 21]; //2_MiB * sizeof(void*) == 16_MiB
|
||||
Pool** pools = alloc_invisible<Pool*>(1 << 21); //2_MiB * sizeof(void*) == 16_MiB
|
||||
} recompiler{*this};
|
||||
|
||||
struct Disassembler {
|
||||
|
|
|
@ -4,15 +4,17 @@ auto CPU::Recompiler::pool(u32 address) -> Pool* {
|
|||
return pool;
|
||||
}
|
||||
|
||||
auto CPU::Recompiler::block(u32 address) -> Block* {
|
||||
if(auto block = pool(address)->blocks[address >> 2 & 0x3f]) return block;
|
||||
auto block = emit(address);
|
||||
pool(address)->blocks[address >> 2 & 0x3f] = block;
|
||||
auto CPU::Recompiler::block(u32 address) -> Block& {
|
||||
auto pool = this->pool(address);
|
||||
auto& block = pool->blocks[address >> 2 & 0x3f];
|
||||
if(block.code) return block;
|
||||
emit(address, block);
|
||||
pool->dirty = true;
|
||||
memory::jitprotect(true);
|
||||
return block;
|
||||
}
|
||||
|
||||
auto CPU::Recompiler::emit(u32 address) -> Block* {
|
||||
auto CPU::Recompiler::emit(u32 address, Block& block) -> void {
|
||||
if(unlikely(allocator.available() < 1_MiB)) {
|
||||
print("CPU allocator flush\n");
|
||||
memory::jitprotect(false);
|
||||
|
@ -21,7 +23,6 @@ auto CPU::Recompiler::emit(u32 address) -> Block* {
|
|||
reset();
|
||||
}
|
||||
|
||||
auto block = (Block*)allocator.acquire(sizeof(Block));
|
||||
beginFunction(3);
|
||||
|
||||
bool hasBranched = 0;
|
||||
|
@ -42,10 +43,9 @@ auto CPU::Recompiler::emit(u32 address) -> Block* {
|
|||
jumpEpilog();
|
||||
|
||||
memory::jitprotect(false);
|
||||
block->code = endFunction();
|
||||
block.code = endFunction();
|
||||
|
||||
//print(hex(PC, 8L), " ", instructions, " ", size(), "\n");
|
||||
return block;
|
||||
}
|
||||
|
||||
#define Sa (instruction >> 6 & 31)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <n64/n64.hpp>
|
||||
|
||||
#include "Gfx #1.3.h"
|
||||
#include "angrylion.h"
|
||||
|
||||
namespace ares::Nintendo64 {
|
||||
|
||||
|
@ -14,14 +14,12 @@ auto RDP::load(Node::Object parent) -> void {
|
|||
node = parent->append<Node::Object>("RDP");
|
||||
debugger.load(node);
|
||||
|
||||
angrylion::RomOpen();
|
||||
angrylion::Init();
|
||||
}
|
||||
|
||||
auto RDP::unload() -> void {
|
||||
debugger = {};
|
||||
node.reset();
|
||||
|
||||
angrylion::RomClosed();
|
||||
}
|
||||
|
||||
auto RDP::crash(const char *reason) -> void {
|
||||
|
|
|
@ -115,8 +115,8 @@ auto RSP::power(bool reset) -> void {
|
|||
}
|
||||
|
||||
if constexpr(Accuracy::RSP::Recompiler) {
|
||||
auto buffer = ares::Memory::FixedAllocator::get().tryAcquire(64_MiB);
|
||||
recompiler.allocator.resize(64_MiB, bump_allocator::executable | bump_allocator::zero_fill, buffer);
|
||||
auto buffer = ares::Memory::FixedAllocator::get().tryAcquire(4_MiB);
|
||||
recompiler.allocator.resize(4_MiB, bump_allocator::executable | bump_allocator::zero_fill, buffer);
|
||||
recompiler.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <n64/n64.hpp>
|
||||
|
||||
#include "Gfx #1.3.h"
|
||||
#include "angrylion.h"
|
||||
|
||||
namespace ares::Nintendo64 {
|
||||
|
||||
|
@ -9,6 +9,10 @@ VI vi;
|
|||
#include "debugger.cpp"
|
||||
#include "serialization.cpp"
|
||||
|
||||
bool BobDeinterlace = false;
|
||||
bool FastVI = false;
|
||||
u32* OutFrameBuffer;
|
||||
|
||||
auto VI::load(Node::Object parent) -> void {
|
||||
node = parent->append<Node::Object>("VI");
|
||||
|
||||
|
@ -55,9 +59,8 @@ auto VI::main() -> void {
|
|||
io.vcounter = 0;
|
||||
io.field = io.field + 1 & io.serrate;
|
||||
|
||||
angrylion::UpdateScreen();
|
||||
refreshed = true;
|
||||
screen->frame();
|
||||
angrylion::UpdateScreen(FastVI);
|
||||
refresh();
|
||||
}
|
||||
|
||||
if(Region::NTSC()) step(system.frequency() / 60 / 262);
|
||||
|
@ -68,15 +71,9 @@ auto VI::step(u32 clocks) -> void {
|
|||
Thread::clock += clocks;
|
||||
}
|
||||
|
||||
bool BobDeinterlace = 0;
|
||||
|
||||
auto VI::refresh() -> void {
|
||||
u32 width = 640;
|
||||
u32 height = Region::PAL() ? 576 : 480;
|
||||
screen->setViewport(0, 0, width, height);
|
||||
u32* src = angrylion::FinalizeFrame(BobDeinterlace);
|
||||
u32* dst = screen->pixels(1).data();
|
||||
memcpy(dst, src, width * height * sizeof(u32));
|
||||
angrylion::FinalizeFrame(BobDeinterlace);
|
||||
refreshed = true;
|
||||
}
|
||||
|
||||
auto VI::power(bool reset) -> void {
|
||||
|
|
|
@ -278,7 +278,7 @@ template<typename T> alwaysinline auto ror(const Pair& lhs, const T& rhs) -> Pai
|
|||
return lhs >> rhs | lhs << (PairBits - rhs);
|
||||
}
|
||||
|
||||
#define EI enable_if_t<is_integral<T>::value>
|
||||
#define EI /*typename =*/ enable_if_t<is_integral<T>::value>
|
||||
|
||||
template<typename T, EI> auto& operator*= (T& lhs, const Pair& rhs) { return lhs = lhs * T(rhs); }
|
||||
template<typename T, EI> auto& operator/= (T& lhs, const Pair& rhs) { return lhs = lhs / T(rhs); }
|
||||
|
|
|
@ -2,34 +2,34 @@
|
|||
|
||||
namespace nall {
|
||||
|
||||
template<typename T, enable_if_t<is_unsigned<T>::value>>
|
||||
template<typename T, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto upper(T value) -> T {
|
||||
return value >> sizeof(T) * 4;
|
||||
}
|
||||
|
||||
template<typename T, enable_if_t<is_unsigned<T>::value>>
|
||||
template<typename T, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto lower(T value) -> T {
|
||||
static const T Mask = ~T(0) >> sizeof(T) * 4;
|
||||
return value & Mask;
|
||||
}
|
||||
|
||||
template<typename T, typename U, enable_if_t<is_unsigned<T>::value>, enable_if_t<is_unsigned<U>::value>>
|
||||
template<typename T, typename U, typename = enable_if_t<is_unsigned<T>::value>, typename = enable_if_t<is_unsigned<U>::value>>
|
||||
inline auto mul(T lhs, U rhs) -> uintmax {
|
||||
return lhs * rhs;
|
||||
}
|
||||
|
||||
template<typename T, enable_if_t<is_unsigned<T>::value>>
|
||||
template<typename T, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto square(T value) -> uintmax {
|
||||
return value * value;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
inline auto rol(T lhs, U rhs, enable_if_t<is_unsigned<T>::value>* = 0) -> T {
|
||||
template<typename T, typename U, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto rol(T lhs, U rhs) -> T {
|
||||
return lhs << rhs | lhs >> sizeof(T) * 8 - rhs;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
inline auto ror(T lhs, U rhs, enable_if_t<is_unsigned<T>::value>* = 0) -> T {
|
||||
template<typename T, typename U, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto ror(T lhs, U rhs) -> T {
|
||||
return lhs >> rhs | lhs << sizeof(T) * 8 - rhs;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace nall::recompiler {
|
|||
sljit_label* epilogue = nullptr;
|
||||
|
||||
generic(bump_allocator& alloc) : allocator(alloc) {}
|
||||
~generic() { /*resetCompiler();*/ }
|
||||
~generic() { resetCompiler(); }
|
||||
|
||||
auto beginFunction(int args) -> void {
|
||||
assert(args <= 3);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fd4173287f22271908b82148470e4e1e34707228
|
||||
Subproject commit 7b20c1c308340fcf8ccd15b97ebbb52a61c3cca0
|
|
@ -4,6 +4,7 @@ CXXFLAGS := -std=c++17 \
|
|||
-I../libco -I./bsnes \
|
||||
-Werror=int-to-pointer-cast \
|
||||
-Wno-parentheses -Wno-sign-compare -Wno-unused-variable -Wno-trigraphs -Wno-switch -Wno-reorder -Wno-misleading-indentation \
|
||||
-Wno-unqualified-std-cast-call -Wno-mismatched-tags -Wno-overloaded-virtual -Wno-bitwise-instead-of-logical \
|
||||
-fno-threadsafe-statics -fno-strict-aliasing -fwrapv
|
||||
|
||||
CCFLAGS := -std=c11 -DGB_INTERNAL -DGB_DISABLE_DEBUGGER -DGB_DISABLE_CHEATS -D_GNU_SOURCE -DGB_VERSION= \
|
||||
|
|
|
@ -278,7 +278,8 @@ template<typename T> alwaysinline auto ror(const Pair& lhs, const T& rhs) -> Pai
|
|||
return lhs >> rhs | lhs << (PairBits - rhs);
|
||||
}
|
||||
|
||||
#define EI enable_if_t<is_integral<T>::value>
|
||||
// FIXME: the current code just suppresses these operator overloads, fixing it however just breaks a ton of other code
|
||||
#define EI /*typename =*/ enable_if_t<is_integral<T>::value>
|
||||
|
||||
template<typename T, EI> auto& operator*= (T& lhs, const Pair& rhs) { return lhs = lhs * T(rhs); }
|
||||
template<typename T, EI> auto& operator/= (T& lhs, const Pair& rhs) { return lhs = lhs / T(rhs); }
|
||||
|
|
|
@ -2,34 +2,34 @@
|
|||
|
||||
namespace nall {
|
||||
|
||||
template<typename T, enable_if_t<is_unsigned<T>::value>>
|
||||
template<typename T, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto upper(T value) -> T {
|
||||
return value >> sizeof(T) * 4;
|
||||
}
|
||||
|
||||
template<typename T, enable_if_t<is_unsigned<T>::value>>
|
||||
template<typename T, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto lower(T value) -> T {
|
||||
static const T Mask = ~T(0) >> sizeof(T) * 4;
|
||||
return value & Mask;
|
||||
}
|
||||
|
||||
template<typename T, typename U, enable_if_t<is_unsigned<T>::value>, enable_if_t<is_unsigned<U>::value>>
|
||||
template<typename T, typename U, typename = enable_if_t<is_unsigned<T>::value>, typename = enable_if_t<is_unsigned<U>::value>>
|
||||
inline auto mul(T lhs, U rhs) -> uintmax {
|
||||
return lhs * rhs;
|
||||
}
|
||||
|
||||
template<typename T, enable_if_t<is_unsigned<T>::value>>
|
||||
template<typename T, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto square(T value) -> uintmax {
|
||||
return value * value;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
inline auto rol(T lhs, U rhs, enable_if_t<is_unsigned<T>::value>* = 0) -> T {
|
||||
template<typename T, typename U, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto rol(T lhs, U rhs) -> T {
|
||||
return lhs << rhs | lhs >> sizeof(T) * 8 - rhs;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
inline auto ror(T lhs, U rhs, enable_if_t<is_unsigned<T>::value>* = 0) -> T {
|
||||
template<typename T, typename U, typename = enable_if_t<is_unsigned<T>::value>>
|
||||
inline auto ror(T lhs, U rhs) -> T {
|
||||
return lhs >> rhs | lhs << sizeof(T) * 8 - rhs;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ struct file : inode {
|
|||
|
||||
static auto truncate(const string& filename, uint64_t size) -> bool {
|
||||
#if defined(API_POSIX)
|
||||
return truncate(filename, size) == 0;
|
||||
return ::truncate(filename, size) == 0;
|
||||
#elif defined(API_WINDOWS)
|
||||
if(auto fp = _wfopen(utf16_t(filename), L"rb+")) {
|
||||
bool result = _chsize(fileno(fp), size) == 0;
|
||||
|
|
|
@ -23,18 +23,24 @@ print-%: ;
|
|||
|
||||
#LD_PLUGIN := $(shell gcc --print-file-name=liblto_plugin.so)
|
||||
|
||||
ifneq (,$(wildcard $(SYSROOT)/bin/musl-clang))
|
||||
CC := $(SYSROOT)/bin/musl-clang
|
||||
else ifneq (,$(wildcard $(SYSROOT)/bin/musl-gcc))
|
||||
CC := $(SYSROOT)/bin/musl-gcc
|
||||
else
|
||||
$(error Compiler not found in sysroot)
|
||||
endif
|
||||
COMMONFLAGS := -fvisibility=hidden -I$(WATERBOX_DIR)/emulibc -Wall -mcmodel=large \
|
||||
-mstack-protector-guard=global -no-pie -fno-pic -fno-pie -fcf-protection=none \
|
||||
-mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none \
|
||||
-MD -MP
|
||||
CCFLAGS := $(CCFLAGS) $(COMMONFLAGS)
|
||||
LDFLAGS := $(LDFLAGS) -static -Wl,--eh-frame-hdr -T $(LINKSCRIPT) #-Wl,--plugin,$(LD_PLUGIN)
|
||||
CCFLAGS := $(COMMONFLAGS) $(CCFLAGS)
|
||||
LDFLAGS := $(LDFLAGS) -static -no-pie -Wl,--eh-frame-hdr,-O2 -T $(LINKSCRIPT) #-Wl,--plugin,$(LD_PLUGIN)
|
||||
CCFLAGS_DEBUG := -O0 -g
|
||||
CCFLAGS_RELEASE := -O3 -flto
|
||||
CCFLAGS_RELEASE_ASONLY := -O3
|
||||
LDFLAGS_DEBUG :=
|
||||
LDFLAGS_RELEASE :=
|
||||
CXXFLAGS := $(CXXFLAGS) $(COMMONFLAGS) -I$(SYSROOT)/include/c++/v1 -fno-use-cxa-atexit
|
||||
CXXFLAGS := $(COMMONFLAGS) $(CXXFLAGS) -I$(SYSROOT)/include/c++/v1 -fno-use-cxa-atexit -fvisibility-inlines-hidden
|
||||
CXXFLAGS_DEBUG := -O0 -g
|
||||
CXXFLAGS_RELEASE := -O3 -flto
|
||||
CXXFLAGS_RELEASE_ASONLY := -O3
|
||||
|
@ -95,13 +101,13 @@ $(TARGET_DEBUG): $(DOBJS) $(EMULIBC_DOBJS) $(LINKSCRIPT)
|
|||
install: $(TARGET_RELEASE)
|
||||
@cp -f $< $(OUTPUTDLL_DIR)
|
||||
@zstd --stdout --ultra -22 --threads=0 $< > $(OUTPUTDLL_DIR)/$(TARGET).zst
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst || true
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst 2> /dev/null || true
|
||||
@echo Release build of $(TARGET) installed.
|
||||
|
||||
install-debug: $(TARGET_DEBUG)
|
||||
@cp -f $< $(OUTPUTDLL_DIR)
|
||||
@zstd --stdout --ultra -22 --threads=0 $< > $(OUTPUTDLL_DIR)/$(TARGET).zst
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst || true
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst 2> /dev/null || true
|
||||
@echo Debug build of $(TARGET) installed.
|
||||
|
||||
else
|
||||
|
|
|
@ -17,7 +17,7 @@ struct __WbxSysLayout {
|
|||
struct __AddressRange plain;
|
||||
struct __AddressRange mmap;
|
||||
};
|
||||
__attribute__((section(".invis"))) __attribute__((visibility("default"))) struct __WbxSysLayout __wbxsysinfo;
|
||||
ECL_INVISIBLE ECL_EXPORT struct __WbxSysLayout __wbxsysinfo;
|
||||
|
||||
void* alloc_helper(size_t size, const struct __AddressRange* range, unsigned long* current, const char* name)
|
||||
{
|
||||
|
|
|
@ -2,25 +2,34 @@
|
|||
set -e
|
||||
if [ -z "$SYSROOT" ]; then export SYSROOT="$(realpath "$(dirname "$0")/../sysroot")"; fi
|
||||
if [ -z "$LLVMDIR" ]; then export LLVMDIR="$(realpath "$(dirname "$0")/../llvm-project")"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-gcc" ]; then export CC="$SYSROOT/bin/musl-gcc"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-clang" ]; then export CC="$SYSROOT/bin/musl-clang"; fi
|
||||
|
||||
rm -rf build-
|
||||
mkdir build-
|
||||
cd build-
|
||||
export CFLAGS="-mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie"
|
||||
export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie"
|
||||
export ASMFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export CFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export CXXFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none -fno-use-cxa-atexit"
|
||||
export LDFLAGS="-no-pie"
|
||||
|
||||
cmake \
|
||||
-DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DCMAKE_ASM_COMPILER="$CC" \
|
||||
-DCMAKE_C_COMPILER="$CC" \
|
||||
-DCMAKE_CXX_COMPILER="$CC" \
|
||||
-DLLVM_TARGET_TRIPLE="x86_64-unknown-linux-gnu" \
|
||||
-DCOMPILER_RT_BUILD_CRT=OFF \
|
||||
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
|
||||
-DCOMPILER_RT_BUILD_XRAY=OFF \
|
||||
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
|
||||
-DCOMPILER_RT_BUILD_PROFILE=OFF \
|
||||
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
|
||||
-DCOMPILER_RT_BUILD_ORC=OFF \
|
||||
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
|
||||
-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF \
|
||||
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
|
||||
-UCOMPILER_RT_BAREMETAL_BUILD \
|
||||
-DCOMPILER_RT_BAREMETAL_BUILD=ON \
|
||||
-DCOMPILER_RT_HAS_FPIC_FLAG=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
|
||||
-DCMAKE_AR="/usr/bin/gcc-ar" \
|
||||
-DCMAKE_RANLIB="/usr/bin/gcc-ranlib" \
|
||||
$LLVMDIR/compiler-rt
|
||||
|
|
|
@ -2,18 +2,30 @@
|
|||
set -e
|
||||
if [ -z "$SYSROOT" ]; then export SYSROOT="$(realpath "$(dirname "$0")/../sysroot")"; fi
|
||||
if [ -z "$LLVMDIR" ]; then export LLVMDIR="$(realpath "$(dirname "$0")/../llvm-project")"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-gcc" ]; then export CC="$SYSROOT/bin/musl-gcc"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-clang" ]; then export CC="$SYSROOT/bin/musl-clang"; fi
|
||||
|
||||
rm -rf build0
|
||||
mkdir build0
|
||||
cd build0
|
||||
export CFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie -D_LIBUNWIND_IS_BAREMETAL -D_LIBUNWIND_SUPPORT_DWARF_UNWIND"
|
||||
export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie -D_LIBUNWIND_IS_BAREMETAL -D_LIBUNWIND_SUPPORT_DWARF_UNWIND"
|
||||
export ASMFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export CFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export CXXFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none -fno-use-cxa-atexit"
|
||||
export LDFLAGS="-no-pie"
|
||||
|
||||
# libunwind cmake script never actually does enable_language(ASM) or project(... ASM) it would seem
|
||||
# this is probably due to this being intended to be called from another script
|
||||
# but this ends up breaking our standalone building of libunwind
|
||||
# there isn't a simple fix with a command line option, so...
|
||||
|
||||
printf "%s\n%s\n" "enable_language(ASM)" "add_subdirectory($LLVMDIR/libunwind .)" > CMakeLists.txt
|
||||
|
||||
cmake \
|
||||
-DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DCMAKE_ASM_COMPILER="$CC" \
|
||||
-DCMAKE_C_COMPILER="$CC" \
|
||||
-DCMAKE_CXX_COMPILER="$CC" \
|
||||
-DLIBUNWIND_ENABLE_SHARED=OFF \
|
||||
-DLIBUNWIND_USE_COMPILER_RT=ON \
|
||||
-DLIBUNWIND_IS_BAREMETAL=ON \
|
||||
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
|
||||
-DCMAKE_AR="/usr/bin/gcc-ar" \
|
||||
-DCMAKE_RANLIB="/usr/bin/gcc-ranlib" \
|
||||
$LLVMDIR/libunwind
|
||||
.
|
||||
|
|
|
@ -2,26 +2,35 @@
|
|||
set -e
|
||||
if [ -z "$SYSROOT" ]; then export SYSROOT="$(realpath "$(dirname "$0")/../sysroot")"; fi
|
||||
if [ -z "$LLVMDIR" ]; then export LLVMDIR="$(realpath "$(dirname "$0")/../llvm-project")"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-gcc" ]; then export CC="$SYSROOT/bin/musl-gcc"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-clang" ]; then export CC="$SYSROOT/bin/musl-clang"; fi
|
||||
|
||||
# libcxx needs futex.h in atomic.cpp for FUTEX_WAIT_PRIVATE and FUTEX_WAKE_PRIVATE
|
||||
# the host linux header pulls in a ton of other headers, so let's just make one ourselves
|
||||
mkdir -p "$SYSROOT/include/linux"
|
||||
rm -f "$SYSROOT/include/linux/futex.h"
|
||||
printf "%s\n%s\n" "#define FUTEX_WAIT_PRIVATE 128" "#define FUTEX_WAKE_PRIVATE 129" > "$SYSROOT/include/linux/futex.h"
|
||||
|
||||
rm -rf build1
|
||||
mkdir build1
|
||||
cd build1
|
||||
export CFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie"
|
||||
export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie"
|
||||
export CFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export CXXFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none -fno-use-cxa-atexit"
|
||||
export LDFLAGS="-no-pie"
|
||||
|
||||
cmake \
|
||||
-DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
|
||||
-DLIBCXXABI_ENABLE_PIC=OFF \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_BAREMETAL=ON \
|
||||
-DLIBCXXABI_SILENT_TERMINATE=ON \
|
||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_INCLUDE_TESTS=OFF \
|
||||
-DLIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI=OFF \
|
||||
-DLIBCXXABI_LIBCXX_INCLUDES="$LLVMDIR/libcxx/include" \
|
||||
-DCMAKE_C_COMPILER="$CC" \
|
||||
-DCMAKE_CXX_COMPILER="$CC" \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF \
|
||||
-DLIBCXX_CXX_ABI="system-libcxxabi" \
|
||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LLVMDIR/libcxxabi/include" \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
||||
-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=OFF \
|
||||
-DLIBCXX_ENABLE_RANDOM_DEVICE=OFF \
|
||||
-DLIBCXX_HAS_MUSL_LIBC=ON \
|
||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
||||
-DLIBCXX_INCLUDE_TESTS=OFF \
|
||||
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
|
||||
-DLIBCXX_INCLUDE_DOCS=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
|
||||
-DCMAKE_AR="/usr/bin/gcc-ar" \
|
||||
-DCMAKE_RANLIB="/usr/bin/gcc-ranlib" \
|
||||
$LLVMDIR/libcxxabi
|
||||
$LLVMDIR/libcxx
|
||||
|
|
|
@ -2,32 +2,24 @@
|
|||
set -e
|
||||
if [ -z "$SYSROOT" ]; then export SYSROOT="$(realpath "$(dirname "$0")/../sysroot")"; fi
|
||||
if [ -z "$LLVMDIR" ]; then export LLVMDIR="$(realpath "$(dirname "$0")/../llvm-project")"; fi
|
||||
|
||||
#libcxx needs this one trivial file to autodetect sendfile(2), which musl does support
|
||||
mkdir -p "$SYSROOT/include/linux"
|
||||
cp -n "/usr/include/linux/version.h" "$SYSROOT/include/linux"
|
||||
if [ -f "$SYSROOT/bin/musl-gcc" ]; then export CC="$SYSROOT/bin/musl-gcc"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-clang" ]; then export CC="$SYSROOT/bin/musl-clang"; fi
|
||||
|
||||
rm -rf build2
|
||||
mkdir build2
|
||||
cd build2
|
||||
export CFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie"
|
||||
export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie"
|
||||
export CFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export CXXFLAGS="-w -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none -fno-use-cxa-atexit -I$SYSROOT/include/c++/v1/"
|
||||
export LDFLAGS="-no-pie"
|
||||
|
||||
cmake \
|
||||
-DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \
|
||||
-DLIBCXX_ENABLE_SHARED=OFF \
|
||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
|
||||
-DLIBCXX_CXX_ABI="libcxxabi" \
|
||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LLVMDIR/libcxxabi/include" \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
||||
-DLIBCXX_ENABLE_EXCEPTIONS=ON \
|
||||
-DLIBCXX_ENABLE_RTTI=ON \
|
||||
-DLIBCXX_HAS_MUSL_LIBC=ON \
|
||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
||||
-DLIBCXX_INCLUDE_TESTS=OFF \
|
||||
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
|
||||
-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=OFF \
|
||||
-DCMAKE_C_COMPILER="$CC" \
|
||||
-DCMAKE_CXX_COMPILER="$CC" \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_BAREMETAL=ON \
|
||||
-DLIBCXXABI_SILENT_TERMINATE=ON \
|
||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_INCLUDE_TESTS=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
|
||||
-DCMAKE_AR="/usr/bin/gcc-ar" \
|
||||
-DCMAKE_RANLIB="/usr/bin/gcc-ranlib" \
|
||||
$LLVMDIR/libcxx
|
||||
$LLVMDIR/libcxxabi
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
./setup-llvm.sh
|
||||
./configure-for-waterbox-phase-- && cd build- && make -j && make install && cd ..
|
||||
printf "completed phase -1\n"
|
||||
./configure-for-waterbox-phase-0 && cd build0 && make -j && make install && cd ..
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
Building and installing libcxx:
|
||||
|
||||
1. Check out the llvm-project submodule if you haven't already.
|
||||
2. Come to this folder
|
||||
3. Run ./do-everything.sh
|
||||
1. Run ./do-everything.sh
|
||||
* This will initialize and update the llvm-project submodule if you haven't already done that
|
||||
* This isn't resumable at all, so if it crashes or you're curious about the process,
|
||||
read its source and execute the commands individually.
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
LLVM_TAG=llvmorg-16.0.0
|
||||
LLVM_DIRS="cmake compiler-rt libunwind libcxx libcxxabi"
|
||||
LLVM_PATH=../llvm-project
|
||||
LLVM_GIT_DIR=$(git rev-parse --absolute-git-dir)/modules/waterbox/llvm-project
|
||||
|
||||
if [ -d "$LLVM_PATH" ]; then
|
||||
if [ ! -e "$LLVM_PATH/.git" ] || ! git -C "$LLVM_PATH" rev-parse $LLVM_TAG > /dev/null 2>&1; then
|
||||
rm -rf "$LLVM_PATH"
|
||||
git submodule deinit -f "$LLVM_PATH"
|
||||
rm -rf "$LLVM_GIT_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d "$LLVM_PATH" ]; then
|
||||
git submodule init "$LLVM_PATH"
|
||||
git clone --separate-git-dir="$LLVM_GIT_DIR" --filter=tree:0 --sparse https://github.com/llvm/llvm-project.git "$LLVM_PATH"
|
||||
fi
|
||||
|
||||
cd "$LLVM_PATH"
|
||||
if [ `git describe` != $LLVM_TAG ] || ! ls $LLVM_DIRS > /dev/null 2>&1; then
|
||||
git checkout $LLVM_TAG && git sparse-checkout set $LLVM_DIRS
|
||||
fi
|
|
@ -5,10 +5,11 @@ CXXFLAGS := -DHOOKS -DBIZHAWK -DPROFILE_COMPATIBILITY -DGAMEBOY \
|
|||
-D_GNU_SOURCE \
|
||||
-Werror=int-to-pointer-cast \
|
||||
-I../libco -I./bsnes \
|
||||
-Wno-parentheses -Wno-sign-compare \
|
||||
-Wno-unused-variable -Wno-unused-function \
|
||||
-Wno-parentheses -Wno-sign-compare -Wno-unused-variable -Wno-unused-function \
|
||||
-Wno-switch -Wno-switch-bool -Wno-reorder -Wno-return-type -Wno-bool-operation \
|
||||
-Wno-mismatched-tags -Wno-delete-non-virtual-dtor \
|
||||
-fno-threadsafe-statics \
|
||||
-std=c++0x
|
||||
-std=gnu++17
|
||||
|
||||
TARGET = libsnes.wbx
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
}
|
||||
|
||||
void remove() {
|
||||
if(size > 0) resize(size - 1); //remove last element only
|
||||
if(size() > 0) resize(size() - 1); //remove last element only
|
||||
}
|
||||
|
||||
void remove(unsigned index, unsigned count = 1) {
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
//writeonly<foo> bar;
|
||||
//bar = true;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__clang__)
|
||||
#define DUMB(X)
|
||||
#else
|
||||
#define DUMB(X) X
|
||||
|
|
|
@ -12,9 +12,9 @@ struct flag_t {
|
|||
return data;
|
||||
}
|
||||
|
||||
inline unsigned operator|=(unsigned data) { return operator=(operator unsigned() | data); }
|
||||
inline unsigned operator^=(unsigned data) { return operator=(operator unsigned() ^ data); }
|
||||
inline unsigned operator&=(unsigned data) { return operator=(operator unsigned() & data); }
|
||||
inline unsigned operator|=(unsigned data) { return this->operator=(operator unsigned() | data); }
|
||||
inline unsigned operator^=(unsigned data) { return this->operator=(operator unsigned() ^ data); }
|
||||
inline unsigned operator&=(unsigned data) { return this->operator=(operator unsigned() & data); }
|
||||
|
||||
flag_t() : n(0), v(0), m(0), x(0), d(0), i(0), z(0), c(0) {}
|
||||
};
|
||||
|
|
|
@ -597,9 +597,8 @@ void new_emuthread()
|
|||
//DLL INTERFACE
|
||||
|
||||
#include <emulibc.h>
|
||||
#define EXPORT extern "C" ECL_EXPORT
|
||||
|
||||
EXPORT void* DllInit()
|
||||
ECL_EXPORT void* DllInit()
|
||||
{
|
||||
#define T(s,n) static_assert(offsetof(CommStruct,s)==n,#n)
|
||||
T(cmd, 0);
|
||||
|
@ -640,7 +639,7 @@ EXPORT void* DllInit()
|
|||
return &comm;
|
||||
}
|
||||
|
||||
EXPORT void Message(eMessage msg)
|
||||
ECL_EXPORT void Message(eMessage msg)
|
||||
{
|
||||
if (msg == eMessage_Resume)
|
||||
{
|
||||
|
@ -679,18 +678,18 @@ EXPORT void Message(eMessage msg)
|
|||
|
||||
|
||||
//receives the given buffer and COPIES it. use this for returning values from SIGs
|
||||
EXPORT void CopyBuffer(int id, void* ptr, int32 size)
|
||||
ECL_EXPORT void CopyBuffer(int id, void* ptr, int32 size)
|
||||
{
|
||||
comm.CopyBuffer(id, ptr, size);
|
||||
}
|
||||
|
||||
//receives the given buffer and STASHES IT. use this (carefully) for sending params for CMDs
|
||||
EXPORT void SetBuffer(int id, void* ptr, int32 size)
|
||||
ECL_EXPORT void SetBuffer(int id, void* ptr, int32 size)
|
||||
{
|
||||
comm.SetBuffer(id, ptr, size);
|
||||
}
|
||||
|
||||
EXPORT void PostLoadState()
|
||||
ECL_EXPORT void PostLoadState()
|
||||
{
|
||||
SNES::ppu.flush_tiledata_cache();
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit eaae6dfc545000e335e6f89abb9c78818383d7ad
|
||||
Subproject commit 08d094a0e457360ad8b94b017d2dc277e697ca76
|
|
@ -11,6 +11,12 @@ cd melon && make -f Makefile $1 -j && cd -
|
|||
cd picodrive && make -f Makefile $1 -j && cd -
|
||||
cd snes9x && make -f Makefile $1 -j && cd -
|
||||
cd tic80 && make -f Makefile $1 -j && cd -
|
||||
cd virtualjaguar && make -f Makefile $1 -j && cd -
|
||||
cd uzem && make -f Makefile $1 -j && cd -
|
||||
cd virtualjaguar && make -f Makefile $1 -j && cd -
|
||||
cd nyma && ./make-all-released-cores.sh $1 && cd -
|
||||
|
||||
# this won't include MAME by default, due to the large amount of time it takes to build it
|
||||
# to include MAME just do INCLUDE_MAME=1 ./make-all-cores.sh
|
||||
if test "$INCLUDE_MAME" ; then
|
||||
cd mame-arcade && make -f Makefile $1 -j && cd -
|
||||
fi
|
||||
|
|
|
@ -24,7 +24,7 @@ $(TARGET_RELEASE):
|
|||
@$(MAKE) SUBTARGET=arcade WATERBOX=1 OPTIMIZE=s DEPRECATED=0 NOWERROR=1 \
|
||||
WBX_DIR=$(WATERBOX_DIR) BUILDDIR=$(OBJ_DIR) -C $(ROOT_DIR)/mame
|
||||
@mv -f $(ROOT_DIR)/mame/$(TARGET) $(TARGET_RELEASE)
|
||||
@strip --strip-all -wK "mame_*" -K "co_clean" -K "ecl_seal" $(TARGET_RELEASE)
|
||||
@strip --strip-all -wK "mame_*" -K "co_clean" -K "ecl_seal" -K "__wbxsysinfo" $(TARGET_RELEASE)
|
||||
|
||||
$(TARGET_DEBUG):
|
||||
@$(MAKE) SUBTARGET=arcade WATERBOX=1 OPTIMIZE=g DEBUG=1 SYMBOLS=1 PROFILER=0 DEPRECATED=0 NOWERROR=1 \
|
||||
|
@ -34,13 +34,13 @@ $(TARGET_DEBUG):
|
|||
install: $(TARGET_RELEASE)
|
||||
@cp -f $< $(OUTPUTDLL_DIR)
|
||||
@zstd --stdout --ultra -22 --threads=0 $< > $(OUTPUTDLL_DIR)/$(TARGET).zst
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst || true
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst 2> /dev/null || true
|
||||
@echo Release build of $(TARGET) installed.
|
||||
|
||||
install-debug: $(TARGET_DEBUG)
|
||||
@cp -f $< $(OUTPUTDLL_DIR)
|
||||
@zstd --stdout --ultra -22 --threads=0 $< > $(OUTPUTDLL_DIR)/$(TARGET).zst
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst || true
|
||||
@cp $(OUTPUTDLL_DIR)/$(TARGET).zst $(OUTPUTDLLCOPY_DIR)/$(TARGET).zst 2> /dev/null || true
|
||||
@echo Debug build of $(TARGET) installed.
|
||||
|
||||
.PHONY: clean clean-release clean-debug
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9fced86213548ec78e713ab1574381d0569ac6da
|
||||
Subproject commit 17a174c60c2b616f6375dfbb9713d38762692ed6
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#define EXPORT extern "C" ECL_EXPORT
|
||||
|
||||
static GPU::RenderSettings biz_render_settings { false, 1, false };
|
||||
static bool biz_skip_fw;
|
||||
static time_t biz_time;
|
||||
|
@ -93,7 +91,7 @@ static bool LoadDSiWare(u8* TmdData)
|
|||
return ret;
|
||||
}
|
||||
|
||||
EXPORT bool Init(LoadFlags loadFlags, LoadData* loadData, FirmwareSettings* fwSettings)
|
||||
ECL_EXPORT bool Init(LoadFlags loadFlags, LoadData* loadData, FirmwareSettings* fwSettings)
|
||||
{
|
||||
Config::ExternalBIOSEnable = !!(loadFlags & USE_REAL_BIOS);
|
||||
Config::AudioBitrate = loadData->AudioBitrate;
|
||||
|
@ -152,13 +150,13 @@ EXPORT bool Init(LoadFlags loadFlags, LoadData* loadData, FirmwareSettings* fwSe
|
|||
namespace NDSCart { extern CartCommon* Cart; }
|
||||
extern bool NdsSaveRamIsDirty;
|
||||
|
||||
EXPORT void PutSaveRam(u8* data, u32 len)
|
||||
ECL_EXPORT void PutSaveRam(u8* data, u32 len)
|
||||
{
|
||||
NDS::LoadSave(data, len);
|
||||
NdsSaveRamIsDirty = false;
|
||||
}
|
||||
|
||||
EXPORT void GetSaveRam(u8* data)
|
||||
ECL_EXPORT void GetSaveRam(u8* data)
|
||||
{
|
||||
if (NDSCart::Cart)
|
||||
{
|
||||
|
@ -167,12 +165,12 @@ EXPORT void GetSaveRam(u8* data)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT s32 GetSaveRamLength()
|
||||
ECL_EXPORT s32 GetSaveRamLength()
|
||||
{
|
||||
return NDSCart::Cart ? NDSCart::Cart->GetSaveLen() : 0;
|
||||
}
|
||||
|
||||
EXPORT bool SaveRamIsDirty()
|
||||
ECL_EXPORT bool SaveRamIsDirty()
|
||||
{
|
||||
return NdsSaveRamIsDirty;
|
||||
}
|
||||
|
@ -311,7 +309,7 @@ static void ARM7Access(u8* buffer, s64 address, s64 count, bool write)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
ECL_EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
{
|
||||
m[0].Data = NDS::MainRAM;
|
||||
m[0].Name = "Main RAM";
|
||||
|
@ -394,7 +392,7 @@ static void MicFeedNoise(s8 vol)
|
|||
|
||||
static bool RunningFrame = false;
|
||||
|
||||
EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
{
|
||||
RunningFrame = true;
|
||||
|
||||
|
@ -465,22 +463,22 @@ EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
|
||||
void (*InputCallback)() = nullptr;
|
||||
|
||||
EXPORT void SetInputCallback(void (*callback)())
|
||||
ECL_EXPORT void SetInputCallback(void (*callback)())
|
||||
{
|
||||
InputCallback = callback;
|
||||
}
|
||||
|
||||
EXPORT void GetRegs(u32* regs)
|
||||
ECL_EXPORT void GetRegs(u32* regs)
|
||||
{
|
||||
NDS::GetRegs(regs);
|
||||
}
|
||||
|
||||
EXPORT void SetReg(s32 ncpu, s32 index, s32 val)
|
||||
ECL_EXPORT void SetReg(s32 ncpu, s32 index, s32 val)
|
||||
{
|
||||
NDS::SetReg(ncpu, index, val);
|
||||
}
|
||||
|
||||
EXPORT u32 GetCallbackCycleOffset()
|
||||
ECL_EXPORT u32 GetCallbackCycleOffset()
|
||||
{
|
||||
return RunningFrame ? NDS::GetSysClockCycles(2) : 0;
|
||||
}
|
||||
|
@ -489,7 +487,7 @@ void (*ReadCallback)(u32) = nullptr;
|
|||
void (*WriteCallback)(u32) = nullptr;
|
||||
void (*ExecuteCallback)(u32) = nullptr;
|
||||
|
||||
EXPORT void SetMemoryCallback(u32 which, void (*callback)(u32 addr))
|
||||
ECL_EXPORT void SetMemoryCallback(u32 which, void (*callback)(u32 addr))
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
|
@ -524,13 +522,13 @@ void TraceTrampoline(TraceMask_t type, u32* regs, u32 opcode)
|
|||
TraceCallback(type, opcode, regs, disasm, NDS::GetSysClockCycles(2));
|
||||
}
|
||||
|
||||
EXPORT void SetTraceCallback(void (*callback)(TraceMask_t mask, u32 opcode, u32* regs, char* disasm, u32 cyclesOff), TraceMask_t mask)
|
||||
ECL_EXPORT void SetTraceCallback(void (*callback)(TraceMask_t mask, u32 opcode, u32* regs, char* disasm, u32 cyclesOff), TraceMask_t mask)
|
||||
{
|
||||
TraceCallback = callback;
|
||||
TraceMask = callback ? mask : TRACE_NONE;
|
||||
}
|
||||
|
||||
EXPORT void GetDisassembly(TraceMask_t type, u32 opcode, char* ret)
|
||||
ECL_EXPORT void GetDisassembly(TraceMask_t type, u32 opcode, char* ret)
|
||||
{
|
||||
static char disasm[TRACE_STRING_LENGTH];
|
||||
memset(disasm, 0, sizeof disasm);
|
||||
|
@ -551,17 +549,17 @@ namespace Platform
|
|||
extern void (*ThreadStartCallback)();
|
||||
}
|
||||
|
||||
EXPORT uintptr_t GetFrameThreadProc()
|
||||
ECL_EXPORT uintptr_t GetFrameThreadProc()
|
||||
{
|
||||
return Platform::FrameThreadProc;
|
||||
}
|
||||
|
||||
EXPORT void SetThreadStartCallback(void (*callback)())
|
||||
ECL_EXPORT void SetThreadStartCallback(void (*callback)())
|
||||
{
|
||||
Platform::ThreadStartCallback = callback;
|
||||
}
|
||||
|
||||
EXPORT u32 GetNANDSize()
|
||||
ECL_EXPORT u32 GetNANDSize()
|
||||
{
|
||||
if (NANDFilePtr)
|
||||
{
|
||||
|
@ -572,7 +570,7 @@ EXPORT u32 GetNANDSize()
|
|||
return 0;
|
||||
}
|
||||
|
||||
EXPORT void GetNANDData(char* buf)
|
||||
ECL_EXPORT void GetNANDData(char* buf)
|
||||
{
|
||||
if (NANDFilePtr)
|
||||
{
|
||||
|
@ -584,7 +582,7 @@ EXPORT void GetNANDData(char* buf)
|
|||
|
||||
namespace GPU { void ResetVRAMCache(); }
|
||||
|
||||
EXPORT void ResetCaches()
|
||||
ECL_EXPORT void ResetCaches()
|
||||
{
|
||||
GPU::ResetVRAMCache();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
CCFLAGS := -Wno-discarded-qualifiers -Wno-pointer-sign
|
||||
CCFLAGS := -Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-sign
|
||||
|
||||
CXXFLAGS := -DMELONDS_VERSION="" \
|
||||
-I./melonDS/src -I./melonDS/src/teakra/include \
|
||||
-Wall -Wextra -Werror=int-to-pointer-cast \
|
||||
-Wfatal-errors -Wno-unused-parameter -Wno-unused-variable \
|
||||
-Wno-unused-but-set-variable -Wno-sign-compare \
|
||||
-Wno-deprecated-declarations -Wno-missing-braces \
|
||||
-Wno-bitwise-instead-of-logical -Wno-unused-private-field \
|
||||
-fno-strict-aliasing -std=c++17
|
||||
|
||||
TARGET = melonDS.wbx
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7c0f0934f1dcd93dacd64e76094a8d3ad62c1244
|
||||
Subproject commit a7e1f6a0838c11801228c5695d68428d007648ed
|
|
@ -1 +1 @@
|
|||
Subproject commit 0399bd4194ac74b1c9f1d7f75c6639a636e28a30
|
||||
Subproject commit e7aec3b9ab56cd86aff9838f56c154f1f73080f1
|
|
@ -7,18 +7,20 @@ MEDNAFLAGS := \
|
|||
-fno-strict-aliasing \
|
||||
-fomit-frame-pointer \
|
||||
-fsigned-char \
|
||||
-fno-aggressive-loop-optimizations \
|
||||
-fno-fast-math \
|
||||
-fno-unsafe-math-optimizations \
|
||||
-fjump-tables \
|
||||
-mfunction-return=keep \
|
||||
-mindirect-branch=keep \
|
||||
-mno-indirect-branch-register \
|
||||
-Wall -Wshadow -Wempty-body -Wignored-qualifiers \
|
||||
-Wvla -Wvariadic-macros -Wdisabled-optimization -Werror=write-strings \
|
||||
--param max-gcse-memory=300000000 \
|
||||
-Dprivate=public # the gods have abandoned us
|
||||
|
||||
ifneq (,$(wildcard ../sysroot/bin/musl-gcc))
|
||||
MEDNAFLAGS := $(MEDNAFLAGS) -fno-aggressive-loop-optimizations \
|
||||
-mindirect-branch=keep -mno-indirect-branch-register \
|
||||
--param max-gcse-memory=300000000
|
||||
endif
|
||||
|
||||
CCFLAGS := $(MEDNAFLAGS) -std=gnu99
|
||||
CXXFLAGS := $(MEDNAFLAGS) -std=gnu++11
|
||||
EXTRA_LIBS := -lz
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
MYPATH="`dirname \"$0\"`"
|
||||
SYSROOT="`realpath \"$MYPATH/../../sysroot\"`"
|
||||
export CC=$SYSROOT/bin/musl-gcc
|
||||
export CFLAGS="-O3 -mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie"
|
||||
if [ -f "$SYSROOT/bin/musl-gcc" ]; then export CC="$SYSROOT/bin/musl-gcc"; fi
|
||||
if [ -f "$SYSROOT/bin/musl-clang" ]; then export CC="$SYSROOT/bin/musl-clang"; fi
|
||||
export CFLAGS="-O3 -mcmodel=large -mstack-protector-guard=global -fno-pic -fno-pie -fcf-protection=none"
|
||||
export LDFLAGS="-no-pie"
|
||||
./configure --static --prefix=$SYSROOT
|
||||
|
|
|
@ -5,4 +5,4 @@ SYSROOT="`realpath \"$MYPATH/../../sysroot\"`"
|
|||
cp zlib.h $SYSROOT/include
|
||||
cp zconf.h $SYSROOT/include
|
||||
cp libz.a $SYSROOT/lib
|
||||
gcc-ranlib $SYSROOT/lib/libz.a
|
||||
ranlib $SYSROOT/lib/libz.a
|
||||
|
|
|
@ -818,7 +818,7 @@ void p32x_event_schedule_sh2(SH2 *sh2, enum p32x_event event, int after);
|
|||
void p32x_schedule_hint(SH2 *sh2, int m68k_cycles);
|
||||
|
||||
// 32x/memory.c
|
||||
struct Pico32xMem *Pico32xMem;
|
||||
extern struct Pico32xMem *Pico32xMem;
|
||||
unsigned int PicoRead8_32x(unsigned int a);
|
||||
unsigned int PicoRead16_32x(unsigned int a);
|
||||
void PicoWrite8_32x(unsigned int a, unsigned int d);
|
||||
|
|
|
@ -9,10 +9,12 @@ It consists of a modified musl libc, and build scripts to tie it all together.
|
|||
PREPARE A WIN10 WORKSTATION:
|
||||
Using the guidance at (https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel & https://docs.microsoft.com/en-us/windows/wsl/install-win10):
|
||||
1. Install WSL2
|
||||
2. Install Ubuntu 20.04 LTS (https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71)
|
||||
3. Clone the bizhawk repository. You can use it through /mnt or /home if you really like
|
||||
4. Install build tools: sudo apt-get update && sudo apt-get install gcc g++ make cmake llvm zstd
|
||||
4b. (Note for future work: ideally the llvm installed above would not be required)
|
||||
2. Install Ubuntu 22.04.2 LTS (https://apps.microsoft.com/store/detail/ubuntu-22042-lts/9PN20MSR04DW)
|
||||
3. Clone the bizhawk repository. You can use it through /mnt or /home if you really like
|
||||
4. The waterbox toolchain has a choice between gcc and clang. Currently, clang is the preferred compiler due to its generally superior performance all around.
|
||||
4a. (Clang) Install build tools: sudo apt-get update && sudo apt-get install make cmake clang lld llvm zstd
|
||||
4b. (GCC) Install build tools: sudo apt-get update && sudo apt-get install make cmake gcc-12 g++-12 llvm zstd
|
||||
5. Currently, GCC 12 is required when using a gcc environment (older gcc versions fail at building libcxx), this may change in the future.
|
||||
|
||||
PREPARE A WIN10 VM:
|
||||
1. Make sure the VM has "yo dawg" virtualization enabled on the guest. For example in VMWare Workstation, "Virtualize Intel VT-X/EPT or AMD-V/RVI"
|
||||
|
@ -20,14 +22,23 @@ It consists of a modified musl libc, and build scripts to tie it all together.
|
|||
3. If you wish to clone bizhawk on your host system (slower but maybe more convenient), you can use a VMWare shared folder and: `sudo mount -t drvfs Z: /mnt/z -o rw,relatime,metadata,uid=1000,gid=1000` (WSL won't auto-mount the shared drive)
|
||||
|
||||
PREPARE A LINUX WORKSTATION:
|
||||
1. TODO. This should work, but no one has tested it yet
|
||||
1. Debian/Ubuntu based distros work fine with the WIN10 Workstation instructions (confirmed working with Debian 11). Other distros should be able provide the needed programs in their package managers. make, cmake, gcc/g++ or clang/clang++, ld or lld (lld is required for clang), gcc-ar/gcc-ranlib or llvm-ar/llvm-ranlib (which pair you choose doesn't matter), llvm-config, zstd.
|
||||
2. For older Debian/Ubuntu based distros, the package manager might not provide a recent enough compiler for the waterbox toolchain. In these cases, it is recommended to obtain clang and other llvm tools from llvm's apt repository: https://apt.llvm.org/
|
||||
|
||||
2. Clone bizhawk sources
|
||||
* Make sure git's core.autocrlf is set to false, as the alternatives cause git to modify the line endings in .sh-looking files which WILL break the build process, from the very first step.
|
||||
* This is NOT git's default. You will need to change it!! Go ahead and set it false globally permanently, since do you really want git modifying files?
|
||||
* Make sure you have initialized and updated the needed submodules in the waterbox directory (for example, /waterbox/llvm-project and /waterbox/musl, etc.)
|
||||
* Make sure you have initialized and updated the needed submodules in the waterbox directory, a listing of these is here:
|
||||
* waterbox/musl (required for the entire waterbox toolchain)
|
||||
* waterbox/ares64/ares/thirdparty/angrylion-rdp (required for ares64)
|
||||
* submodules/sameboy/libsameboy (required for new BSNES)
|
||||
* waterbox/mame-arcade/mame (required for MAME)
|
||||
* waterbox/melon/melonDS (required for melonDS)
|
||||
* waterbox/nyma/mednafen (required for all Nyma cores)
|
||||
* waterbox/snes9x (required for Snes9x)
|
||||
* waterbox/llvm-project is needed for the entire waterbox toolchain, but initializing and updating this is handled automatically by later scripts, so you do not need to do anything about this
|
||||
|
||||
3. Consider whether it is time to update your build environment (i.e. sudo apt-get upgrade). We are not prescribing versions for build environment tools (gcc, etc.) so you may as well upgrade everything to the latest if you're making builds for other people.
|
||||
3. Consider whether it is time to update your build environment (i.e. sudo apt-get upgrade). Build environment tools are generally best kept at the latest version, to ensure top performance for our users.
|
||||
|
||||
4. Build libraries.
|
||||
cd musl
|
||||
|
@ -41,14 +52,19 @@ It consists of a modified musl libc, and build scripts to tie it all together.
|
|||
./do-everything.sh
|
||||
cd ..
|
||||
|
||||
5. If errors happen in the libcxx part, it can be due to musl mismatching your current build environment. This happens when your build environment is updated; musl does not track its build dependencies correctly. do `make clean` on musl (and delete the non-checkedin directories just to be safe) and try again from the musl step.
|
||||
4a. At ./wbox_configure, you may need to specify the compiler used. By default, it will try to use clang without a version suffix. If this is not present, it falls on the user to specify a CC variable (e.g. `CC=gcc-12 ./wbox_configure`). This is the only stage which the build tool may need to be manually specified, all future steps will remember this specification and thus need no manual input.
|
||||
|
||||
6. Some additional preparation is required before all the cores can be built:
|
||||
4b. If errors happen in the libcxx part, it can be due to musl mismatching your current build environment. This happens when your build environment is updated; musl does not track its build dependencies correctly. do `make clean` on musl (and delete the non-checkedin directories just to be safe) and try again from the musl step.
|
||||
|
||||
5. Some additional preparation is required before all the cores can be built:
|
||||
cd nyma && ./build-and-install-zlib.sh
|
||||
|
||||
7. You are now ready to start building cores. Each supports `make` and `make install`, as well as `make debug` and `make install-debug` for local development. From the root directory, the following should all be valid:
|
||||
6. You are now ready to start building cores. Each supports `make` and `make install`, as well as `make debug` and `make install-debug` for local development. From the root directory, the following should all be valid:
|
||||
cd ares64 && make install
|
||||
cd bsnescore && make install
|
||||
cd gpgx && make install
|
||||
cd libsnes && make install
|
||||
cd mame-arcade && make install
|
||||
cd melon && make install
|
||||
cd nyma && make -f faust.mak install
|
||||
cd nyma && make -f ngp.mak install
|
||||
|
@ -62,3 +78,6 @@ It consists of a modified musl libc, and build scripts to tie it all together.
|
|||
cd snes9x && make install
|
||||
cd tic80 && make install
|
||||
cd uzem && make install
|
||||
cd virtualjaguar && make install
|
||||
|
||||
Be aware MAME takes a very long while to build. Following suit, the provided make-all-cores.sh will only make MAME if INCLUDE_MAME is exported (e.g. `INCLUDE_MAME=1 ./make-all-cores.sh`).
|
||||
|
|
|
@ -5,10 +5,10 @@ INCLUDE_FLAGS = -I./include/ -I./src/ -I./src/core/ -I./vendor/blip-buf/ -I./ven
|
|||
-I./vendor/wren/src/vm/ -I./vendor/wren/src/vm/ -I./vendor/zlib/
|
||||
|
||||
CCFLAGS := -std=gnu11 -fno-strict-aliasing -fwrapv -DLUA_COMPAT_5_2 -DBUILD_DEPRECATED $(INCLUDE_FLAGS) \
|
||||
-Werror=int-to-pointer-cast -Wno-missing-braces -Wno-unused-variable \
|
||||
-Wno-pointer-sign -Wno-unused-function -Wno-format
|
||||
-Werror=int-to-pointer-cast -Wno-missing-braces -Wno-unused-variable -Wno-unused-but-set-variable -Wno-string-plus-int \
|
||||
-Wno-pointer-sign -Wno-unused-function -Wno-format -Wno-extern-initializer -Wno-deprecated-non-prototype
|
||||
|
||||
CXXFLAGS := -std=c++11 $(INCLUDE_FLAGS) -Wno-class-memaccess -fno-strict-aliasing -fwrapv
|
||||
CXXFLAGS := -std=c++11 $(INCLUDE_FLAGS) -Wno-unused-but-set-variable -fno-strict-aliasing -fwrapv
|
||||
|
||||
TARGET = tic80.wbx
|
||||
|
||||
|
|
|
@ -121,7 +121,11 @@ typedef int8_t i8;
|
|||
# if defined (M3_COMPILER_MSVC)
|
||||
# define vectorcall // For MSVC, better not to specify any call convention
|
||||
# elif defined(__x86_64__)
|
||||
# define vectorcall __attribute__((aligned(32)))
|
||||
# if defined(M3_COMPILER_CLANG)
|
||||
# define vectorcall __attribute__((vectorcall))
|
||||
# else
|
||||
# define vectorcall __attribute__((aligned(32)))
|
||||
# endif
|
||||
//# elif defined(__riscv) && (__riscv_xlen == 64)
|
||||
//# define vectorcall __attribute__((aligned(16)))
|
||||
# elif defined(__MINGW32__)
|
||||
|
|
|
@ -36,8 +36,6 @@ THE SOFTWARE.
|
|||
#include "../emulibc/emulibc.h"
|
||||
#include "../emulibc/waterboxcore.h"
|
||||
|
||||
#define EXPORT extern "C" ECL_EXPORT
|
||||
|
||||
// header for use with UzeRom files
|
||||
static RomHeader uzeRomHeader;
|
||||
static avr8 uzebox;
|
||||
|
@ -53,12 +51,12 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
EXPORT bool MouseEnabled()
|
||||
ECL_EXPORT bool MouseEnabled()
|
||||
{
|
||||
return uzeRomHeader.mouse;
|
||||
}
|
||||
|
||||
EXPORT bool Init()
|
||||
ECL_EXPORT bool Init()
|
||||
{
|
||||
const char *heximage = "romfile";
|
||||
|
||||
|
@ -103,7 +101,7 @@ EXPORT bool Init()
|
|||
return true;
|
||||
}
|
||||
|
||||
EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
ECL_EXPORT void GetMemoryAreas(MemoryArea *m)
|
||||
{
|
||||
m[0].Data = uzebox.sram;
|
||||
m[0].Name = "SRAM";
|
||||
|
@ -138,7 +136,7 @@ void SampleCallback(uint8_t val)
|
|||
audio_value = v;
|
||||
}
|
||||
|
||||
EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
{
|
||||
cycles = 0;
|
||||
uzebox.video_buffer = f->VideoBuffer;
|
||||
|
@ -175,7 +173,7 @@ EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
|
||||
void (*InputCallback)();
|
||||
|
||||
EXPORT void SetInputCallback(void (*callback)())
|
||||
ECL_EXPORT void SetInputCallback(void (*callback)())
|
||||
{
|
||||
InputCallback = callback;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#define EXPORT extern "C" ECL_EXPORT
|
||||
|
||||
typedef int8_t s8;
|
||||
typedef int16_t s16;
|
||||
typedef int32_t s32;
|
||||
|
@ -41,7 +39,7 @@ static void InitCommon(BizSettings* bizSettings)
|
|||
JaguarInit();
|
||||
}
|
||||
|
||||
EXPORT bool Init(BizSettings* bizSettings, u8* boot, u8* rom, u32 sz)
|
||||
ECL_EXPORT bool Init(BizSettings* bizSettings, u8* boot, u8* rom, u32 sz)
|
||||
{
|
||||
InitCommon(bizSettings);
|
||||
|
||||
|
@ -70,13 +68,13 @@ EXPORT bool Init(BizSettings* bizSettings, u8* boot, u8* rom, u32 sz)
|
|||
void (*cd_toc_callback)(void * dest);
|
||||
void (*cd_read_callback)(int32_t lba, void * dest);
|
||||
|
||||
EXPORT void SetCdCallbacks(void (*ctc)(void * dest), void (*cdrc)(int32_t lba, void * dest))
|
||||
ECL_EXPORT void SetCdCallbacks(void (*ctc)(void * dest), void (*cdrc)(int32_t lba, void * dest))
|
||||
{
|
||||
cd_toc_callback = ctc;
|
||||
cd_read_callback = cdrc;
|
||||
}
|
||||
|
||||
EXPORT void InitWithCd(BizSettings* bizSettings, u8* boot, u8* memtrack)
|
||||
ECL_EXPORT void InitWithCd(BizSettings* bizSettings, u8* boot, u8* memtrack)
|
||||
{
|
||||
InitCommon(bizSettings);
|
||||
if (memtrack)
|
||||
|
@ -104,12 +102,12 @@ static inline bool IsMemTrack()
|
|||
return jaguarMainROMCRC32 == 0xFDF37F47;
|
||||
}
|
||||
|
||||
EXPORT bool SaveRamIsDirty()
|
||||
ECL_EXPORT bool SaveRamIsDirty()
|
||||
{
|
||||
return IsMemTrack() ? mtDirty : eeprom_dirty;
|
||||
}
|
||||
|
||||
EXPORT void GetSaveRam(u8* dst)
|
||||
ECL_EXPORT void GetSaveRam(u8* dst)
|
||||
{
|
||||
if (IsMemTrack())
|
||||
{
|
||||
|
@ -123,7 +121,7 @@ EXPORT void GetSaveRam(u8* dst)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT void PutSaveRam(u8* src)
|
||||
ECL_EXPORT void PutSaveRam(u8* src)
|
||||
{
|
||||
if (IsMemTrack())
|
||||
{
|
||||
|
@ -185,7 +183,7 @@ static void SysBusAccess(u8* buffer, u64 address, u64 count, bool write)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT void GetMemoryAreas(MemoryArea* m)
|
||||
ECL_EXPORT void GetMemoryAreas(MemoryArea* m)
|
||||
{
|
||||
m[0].Data = jaguarMainRAM;
|
||||
m[0].Name = "DRAM";
|
||||
|
@ -256,7 +254,7 @@ struct MyFrameInfo : public FrameInfo
|
|||
|
||||
bool lagged;
|
||||
|
||||
EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
|
||||
{
|
||||
if (f->Reset)
|
||||
{
|
||||
|
@ -281,7 +279,7 @@ EXPORT void FrameAdvance(MyFrameInfo* f)
|
|||
|
||||
void (*InputCallback)() = 0;
|
||||
|
||||
EXPORT void SetInputCallback(void (*callback)())
|
||||
ECL_EXPORT void SetInputCallback(void (*callback)())
|
||||
{
|
||||
InputCallback = callback;
|
||||
}
|
||||
|
@ -290,7 +288,7 @@ void (*ReadCallback)(u32) = 0;
|
|||
void (*WriteCallback)(u32) = 0;
|
||||
void (*ExecuteCallback)(u32) = 0;
|
||||
|
||||
EXPORT void SetMemoryCallbacks(void (*rcb)(u32), void (*wcb)(u32), void (*ecb)(u32))
|
||||
ECL_EXPORT void SetMemoryCallbacks(void (*rcb)(u32), void (*wcb)(u32), void (*ecb)(u32))
|
||||
{
|
||||
ReadCallback = rcb;
|
||||
WriteCallback = wcb;
|
||||
|
@ -301,7 +299,7 @@ void (*CPUTraceCallback)(u32*) = 0;
|
|||
void (*GPUTraceCallback)(u32, u32*) = 0;
|
||||
void (*DSPTraceCallback)(u32, u32*) = 0;
|
||||
|
||||
EXPORT void SetTraceCallbacks(void (*ccb)(u32*), void (*gcb)(u32, u32*), void (*dcb)(u32, u32*))
|
||||
ECL_EXPORT void SetTraceCallbacks(void (*ccb)(u32*), void (*gcb)(u32, u32*), void (*dcb)(u32, u32*))
|
||||
{
|
||||
CPUTraceCallback = ccb;
|
||||
GPUTraceCallback = gcb;
|
||||
|
@ -311,7 +309,7 @@ EXPORT void SetTraceCallbacks(void (*ccb)(u32*), void (*gcb)(u32, u32*), void (*
|
|||
extern u32 gpu_pc;
|
||||
extern u32 dsp_pc;
|
||||
|
||||
EXPORT void GetRegisters(u32* regs)
|
||||
ECL_EXPORT void GetRegisters(u32* regs)
|
||||
{
|
||||
for (u32 i = 0; i < 18; i++)
|
||||
{
|
||||
|
@ -325,7 +323,7 @@ EXPORT void GetRegisters(u32* regs)
|
|||
regs[147] = dsp_pc;
|
||||
}
|
||||
|
||||
EXPORT void SetRegister(u32 which, u32 val)
|
||||
ECL_EXPORT void SetRegister(u32 which, u32 val)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ COMMON_FLAGS := -fno-strict-aliasing -fwrapv -I./src/ -I./src/m68000 \
|
|||
|
||||
CCFLAGS := -std=c11 $(COMMON_FLAGS) -Wno-implicit-function-declaration
|
||||
|
||||
CXXFLAGS := -std=c++11 $(COMMON_FLAGS)
|
||||
CXXFLAGS := -std=c++17 $(COMMON_FLAGS)
|
||||
|
||||
TARGET = virtualjaguar.wbx
|
||||
|
||||
|
|
|
@ -101,47 +101,6 @@ void OPReset(void)
|
|||
{
|
||||
}
|
||||
|
||||
static uint32_t object[8192];
|
||||
static uint32_t numberOfObjects;
|
||||
|
||||
static bool OPObjectExists(uint32_t address)
|
||||
{
|
||||
for(uint32_t i=0; i<numberOfObjects; i++)
|
||||
{
|
||||
if (address == object[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void OPDiscoverObjects(uint32_t address)
|
||||
{
|
||||
uint8_t objectType = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (OPObjectExists(address))
|
||||
return;
|
||||
|
||||
object[numberOfObjects++] = address;
|
||||
|
||||
uint32_t hi = JaguarReadLong(address + 0, OP);
|
||||
uint32_t lo = JaguarReadLong(address + 4, OP);
|
||||
objectType = lo & 0x07;
|
||||
uint32_t link = ((hi << 11) | (lo >> 21)) & 0x3FFFF8;
|
||||
|
||||
if (objectType == 3)
|
||||
{
|
||||
if (((lo & 0xFFFF) != 0x7FFB) && ((lo & 0xFFFF) != 0x8003))
|
||||
OPDiscoverObjects(address + 8);
|
||||
}
|
||||
|
||||
address = link;
|
||||
}
|
||||
while (objectType != 4);
|
||||
}
|
||||
|
||||
static uint32_t OPGetListPointer(void)
|
||||
{
|
||||
return GET16(tomRam8, 0x20) | (GET16(tomRam8, 0x22) << 16);
|
||||
|
|
Loading…
Reference in New Issue