Skip to content

Commit 5aeb1ad

Browse files
Add JIT support for melonDS
1 parent a7a76c9 commit 5aeb1ad

File tree

6 files changed

+60
-7
lines changed

6 files changed

+60
-7
lines changed

Assets/dll/melonDS.wbx.zst

52.4 KB
Binary file not shown.

waterbox/common.mak

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CCFLAGS := $(COMMONFLAGS) $(CCFLAGS)
3737
LDFLAGS := $(LDFLAGS) -static -no-pie -Wl,--eh-frame-hdr,-O2 -T $(LINKSCRIPT) #-Wl,--plugin,$(LD_PLUGIN)
3838
CCFLAGS_DEBUG := -O0 -g
3939
CCFLAGS_RELEASE := -O3 -flto -DNDEBUG
40-
CCFLAGS_RELEASE_ASONLY := -O3
40+
CCFLAGS_RELEASE_ASONLY := -O3 -DNDEBUG
4141
LDFLAGS_DEBUG :=
4242
LDFLAGS_RELEASE :=
4343
CXXFLAGS := $(COMMONFLAGS) $(CXXFLAGS) -I$(SYSROOT)/include/c++/v1 -fno-use-cxa-atexit -fvisibility-inlines-hidden
@@ -72,6 +72,14 @@ $(OBJ_DIR)/%.cxx.o: %.cxx
7272
@echo cxx $<
7373
@mkdir -p $(@D)
7474
@$(CC) -c -o $@ $< $(CXXFLAGS) $(CXXFLAGS_RELEASE) $(PER_FILE_FLAGS_$<)
75+
$(OBJ_DIR)/%.s.o: %.s
76+
@echo cc $<
77+
@mkdir -p $(@D)
78+
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_RELEASE_ASONLY) $(PER_FILE_FLAGS_$<)
79+
$(OBJ_DIR)/%.S.o: %.S
80+
@echo cc $<
81+
@mkdir -p $(@D)
82+
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_RELEASE_ASONLY) $(PER_FILE_FLAGS_$<)
7583
$(DOBJ_DIR)/%.c.o: %.c
7684
@echo cc $<
7785
@mkdir -p $(@D)
@@ -84,6 +92,14 @@ $(DOBJ_DIR)/%.cxx.o: %.cxx
8492
@echo cxx $<
8593
@mkdir -p $(@D)
8694
@$(CC) -c -o $@ $< $(CXXFLAGS) $(CXXFLAGS_DEBUG) $(PER_FILE_FLAGS_$<)
95+
$(DOBJ_DIR)/%.s.o: %.s
96+
@echo cc $<
97+
@mkdir -p $(@D)
98+
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_DEBUG) $(PER_FILE_FLAGS_$<)
99+
$(DOBJ_DIR)/%.S.o: %.S
100+
@echo cc $<
101+
@mkdir -p $(@D)
102+
@$(CC) -c -o $@ $< $(CCFLAGS) $(CCFLAGS_DEBUG) $(PER_FILE_FLAGS_$<)
87103
$(OBJ_DIR)/%.c.s: %.c
88104
@echo cc -S $<
89105
@mkdir -p $(@D)

waterbox/melon/BizConsoleCreator.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,11 @@ struct ConsoleCreationArgs
13591359
bool EnableDLDI;
13601360
bool EnableDSiSDCard;
13611361

1362+
bool EnableJIT;
1363+
u32 MaxBlockSize;
1364+
bool LiteralOptimizations;
1365+
bool BranchOptimizations;
1366+
13621367
int BitDepth;
13631368
int Interpolation;
13641369

@@ -1391,7 +1396,7 @@ ECL_EXPORT melonDS::NDS* CreateConsole(ConsoleCreationArgs* args, char* error)
13911396
melonDS::NDSCart::NDSCartArgs cartArgs{};
13921397
if (args->EnableDLDI)
13931398
{
1394-
cartArgs.SDCard =
1399+
cartArgs.SDCard = melonDS::FATStorageArgs
13951400
{
13961401
"dldi.bin",
13971402
SD_CARD_SIZE,
@@ -1424,6 +1429,18 @@ ECL_EXPORT melonDS::NDS* CreateConsole(ConsoleCreationArgs* args, char* error)
14241429
auto arm7Bios = CreateBiosImage<melonDS::ARM7BIOSImage>(args->Arm7BiosData, args->Arm7BiosLength, melonDS::bios_arm7_bin);
14251430
auto firmware = CreateFirmware(args->FirmwareData, args->FirmwareLength, args->DSi, args->FwSettings);
14261431

1432+
std::optional<melonDS::JITArgs> jitArgs = std::nullopt;
1433+
if (args->EnableJIT)
1434+
{
1435+
jitArgs = melonDS::JITArgs
1436+
{
1437+
args->MaxBlockSize,
1438+
args->LiteralOptimizations,
1439+
args->BranchOptimizations,
1440+
false,
1441+
};
1442+
}
1443+
14271444
auto bitDepth = static_cast<melonDS::AudioBitDepth>(args->BitDepth);
14281445
auto interpolation = static_cast<melonDS::AudioInterpolation>(args->Interpolation);
14291446

@@ -1495,7 +1512,7 @@ ECL_EXPORT melonDS::NDS* CreateConsole(ConsoleCreationArgs* args, char* error)
14951512
std::move(arm9Bios),
14961513
std::move(arm7Bios),
14971514
std::move(firmware),
1498-
std::nullopt,
1515+
std::move(jitArgs),
14991516
bitDepth,
15001517
interpolation,
15011518
std::nullopt,
@@ -1519,7 +1536,7 @@ ECL_EXPORT melonDS::NDS* CreateConsole(ConsoleCreationArgs* args, char* error)
15191536
std::move(arm9Bios),
15201537
std::move(arm7Bios),
15211538
std::move(firmware),
1522-
std::nullopt,
1539+
std::move(jitArgs),
15231540
bitDepth,
15241541
interpolation,
15251542
std::nullopt,

waterbox/melon/BizInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ ECL_EXPORT void FrameAdvance(MyFrameInfo* f)
117117
}
118118
}
119119

120+
melonDS::NDS::Current = f->NDS;
120121
f->NDS->RunFrame();
121122

122123
if (f->Keys & 0x1000)

waterbox/melon/Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
CCFLAGS := -Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-sign
22

3-
CXXFLAGS := -DOGLRENDERER_ENABLED \
3+
CXXFLAGS := -DOGLRENDERER_ENABLED -DJIT_ENABLED -DWATERBOX \
44
-I. -I./melonDS/src -I./melonDS/src/teakra/include \
55
-Wall -Wextra -Werror=int-to-pointer-cast \
66
-Wfatal-errors -Wno-unused-parameter -Wno-unused-variable \
77
-Wno-unused-but-set-variable -Wno-unused-function \
88
-Wno-sign-compare -Wno-deprecated-declarations \
99
-Wno-missing-braces -Wno-bitwise-instead-of-logical \
1010
-Wno-unused-private-field -Wno-logical-op-parentheses \
11-
-Wno-mismatched-tags -Wno-reorder-ctor \
11+
-Wno-mismatched-tags -Wno-reorder-ctor -Wno-invalid-offsetof \
12+
-Wno-bitwise-op-parentheses -Wno-vla-cxx-extension \
1213
-fno-strict-aliasing -fwrapv -std=c++17
1314

1415
TARGET = melonDS.wbx
@@ -66,6 +67,22 @@ CORE_GL_SRCS = \
6667
OpenGLSupport.cpp \
6768
frontend/Util_Video.cpp
6869

70+
CORE_JIT_SRCS = \
71+
ARM_InstrInfo.cpp \
72+
ARMJIT.cpp \
73+
ARMJIT_Memory.cpp \
74+
dolphin/CommonFuncs.cpp
75+
76+
CORE_JIT_X64_SRCS = \
77+
dolphin/x64ABI.cpp \
78+
dolphin/x64CPUDetect.cpp \
79+
dolphin/x64Emitter.cpp \
80+
ARMJIT_x64/ARMJIT_Compiler.cpp \
81+
ARMJIT_x64/ARMJIT_ALU.cpp \
82+
ARMJIT_x64/ARMJIT_LoadStore.cpp \
83+
ARMJIT_x64/ARMJIT_Branch.cpp \
84+
ARMJIT_x64/ARMJIT_Linkage.S
85+
6986
TEAKRA_SRCS = \
7087
ahbm.cpp \
7188
apbp.cpp \
@@ -100,6 +117,8 @@ BIZPLATFORM_SRCS = \
100117
SRCS = \
101118
$(addprefix melonDS/src/,$(CORE_SRCS)) \
102119
$(addprefix melonDS/src/,$(CORE_GL_SRCS)) \
120+
$(addprefix melonDS/src/,$(CORE_JIT_SRCS)) \
121+
$(addprefix melonDS/src/,$(CORE_JIT_X64_SRCS)) \
103122
$(addprefix melonDS/src/teakra/src/,$(TEAKRA_SRCS)) \
104123
$(addprefix melonDS/src/fatfs/,$(FATFS_SRCS)) \
105124
$(addprefix melonDS/src/,$(MISC_SRCS)) \

waterbox/melon/melonDS

0 commit comments

Comments
 (0)