finally decouple Config from the core. baahhahahahah

This commit is contained in:
Arisotura 2021-11-18 01:17:51 +01:00
parent 65c2a844ac
commit 19ddaee13b
35 changed files with 128 additions and 236 deletions

View File

@ -24,7 +24,6 @@
#include "ARMInterpreter.h"
#include "AREngine.h"
#include "ARMJIT.h"
#include "Config.h"
#ifdef JIT_ENABLED
#include "ARMJIT.h"

View File

@ -20,7 +20,6 @@
#include "../ARMJIT_Internal.h"
#include "../ARMInterpreter.h"
#include "../Config.h"
#ifdef __SWITCH__
#include <switch.h>

View File

@ -19,7 +19,6 @@
#include "ARMJIT_Compiler.h"
#include "../ARMInterpreter.h"
#include "../Config.h"
#include <assert.h>
#include <stdarg.h>
@ -638,11 +637,11 @@ const Compiler::CompileFunc T_Comp[ARMInstrInfo::tk_Count] = {
// LDR/STR sp rel
F(T_Comp_MemSPRel), F(T_Comp_MemSPRel),
// PUSH/POP
F(T_Comp_PUSH_POP), F(T_Comp_PUSH_POP),
F(T_Comp_PUSH_POP), F(T_Comp_PUSH_POP),
// LDMIA, STMIA
F(T_Comp_LDMIA_STMIA), F(T_Comp_LDMIA_STMIA),
F(T_Comp_LDMIA_STMIA), F(T_Comp_LDMIA_STMIA),
// Branch
F(T_Comp_BCOND), F(T_Comp_BranchXchangeReg), F(T_Comp_BranchXchangeReg), F(T_Comp_B), F(T_Comp_BL_LONG_1), F(T_Comp_BL_LONG_2),
F(T_Comp_BCOND), F(T_Comp_BranchXchangeReg), F(T_Comp_BranchXchangeReg), F(T_Comp_B), F(T_Comp_BL_LONG_1), F(T_Comp_BL_LONG_2),
// Unk, SVC
NULL, NULL,
F(T_Comp_BL_Merged)
@ -832,7 +831,7 @@ JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[]
SetJumpTarget(skipExecute);
}
}
}
}
@ -888,7 +887,7 @@ void Compiler::Comp_AddCycles_CI(Gen::X64Reg i, int add)
s32 cycles = Num ?
NDS::ARM7MemTimings[CurInstr.CodeCycles][Thumb ? 0 : 2]
: ((R15 & 0x2) ? 0 : CurInstr.CodeCycles);
if (!Thumb && CurInstr.Cond() < 0xE)
{
LEA(32, RSCRATCH, MDisp(i, add + cycles));
@ -933,7 +932,7 @@ void Compiler::Comp_AddCycles_CDI()
{
cycles = numC + numD + 1;
}
if (!Thumb && CurInstr.Cond() < 0xE)
ADD(32, MDisp(RCPU, offsetof(ARM, Cycles)), Imm8(cycles));
else

View File

@ -18,8 +18,6 @@
#include "ARMJIT_Compiler.h"
#include "../Config.h"
using namespace Gen;
namespace ARMJIT

View File

@ -11,7 +11,6 @@ add_library(core STATIC
ARMInterpreter_ALU.cpp
ARMInterpreter_Branch.cpp
ARMInterpreter_LoadStore.cpp
Config.cpp
CP15.cpp
CRC32.cpp
DMA.cpp

View File

@ -1,143 +0,0 @@
/*
Copyright 2016-2021 Arisotura
This file is part of melonDS.
melonDS is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "Config.h"
#include "Platform.h"
namespace Config
{
const char* kConfigFile = "melonDS.ini";
int AudioBitrate;
ConfigEntry ConfigFile[] =
{
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
{"", -1, NULL, 0, NULL, 0}
};
extern ConfigEntry PlatformConfigFile[];
void Load()
{
ConfigEntry* entry = &ConfigFile[0];
int c = 0;
for (;;)
{
if (!entry->Value)
{
if (c > 0) break;
entry = &PlatformConfigFile[0];
if (!entry->Value) break;
c++;
}
if (entry->Type == 0)
*(int*)entry->Value = entry->DefaultInt;
else
{
strncpy((char*)entry->Value, entry->DefaultStr, entry->StrLength);
((char*)entry->Value)[entry->StrLength] = '\0';
}
entry++;
}
FILE* f = Platform::OpenLocalFile(kConfigFile, "r");
if (!f) return;
char linebuf[1024];
char entryname[32];
char entryval[1024];
while (!feof(f))
{
if (fgets(linebuf, 1024, f) == nullptr)
break;
int ret = sscanf(linebuf, "%31[A-Za-z_0-9]=%[^\t\r\n]", entryname, entryval);
entryname[31] = '\0';
if (ret < 2) continue;
ConfigEntry* entry = &ConfigFile[0];
c = 0;
for (;;)
{
if (!entry->Value)
{
if (c > 0) break;
entry = &PlatformConfigFile[0];
if (!entry->Value) break;
c++;
}
if (!strncmp(entry->Name, entryname, 32))
{
if (entry->Type == 0)
*(int*)entry->Value = strtol(entryval, NULL, 10);
else
strncpy((char*)entry->Value, entryval, entry->StrLength);
break;
}
entry++;
}
}
fclose(f);
}
void Save()
{
FILE* f = Platform::OpenLocalFile(kConfigFile, "w");
if (!f) return;
ConfigEntry* entry = &ConfigFile[0];
int c = 0;
for (;;)
{
if (!entry->Value)
{
if (c > 0) break;
entry = &PlatformConfigFile[0];
if (!entry->Value) break;
c++;
}
if (entry->Type == 0)
fprintf(f, "%s=%d\r\n", entry->Name, *(int*)entry->Value);
else
fprintf(f, "%s=%s\r\n", entry->Name, (char*)entry->Value);
entry++;
}
fclose(f);
}
}

View File

@ -1,49 +0,0 @@
/*
Copyright 2016-2021 Arisotura
This file is part of melonDS.
melonDS is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <stdio.h>
#include "types.h"
namespace Config
{
struct ConfigEntry
{
char Name[32];
int Type;
void* Value;
int DefaultInt;
const char* DefaultStr;
int StrLength; // should be set to actual array length minus one
};
FILE* GetConfigFile(const char* fileName, const char* permissions);
bool HasConfigFile(const char* fileName);
void Load();
void Save();
extern int AudioBitrate;
}
#endif // CONFIG_H

View File

@ -22,7 +22,6 @@
#include "DSi_SD.h"
#include "DSi_NWifi.h"
#include "Platform.h"
#include "Config.h"
// observed IRQ behavior during transfers

View File

@ -22,7 +22,6 @@
#include "NDS.h"
#include "GPU.h"
#include "FIFO.h"
#include "Config.h"
// 3D engine notes
@ -2164,7 +2163,7 @@ void ExecuteCommand()
VertexSlotCounter = 0;
VertexSlotsFree = 1;
break;
case 0x60: // viewport x1,y1,x2,y2
VertexPipelineCmdDelayed8();
// note: viewport Y coordinates are upside-down
@ -2413,7 +2412,7 @@ void ExecuteCommand()
CurVertex[2] = ExecParams[1] & 0xFFFF;
PosTest();
break;
case 0x70: // box test
NumTestCommands -= 3;
BoxTest(ExecParams);

View File

@ -22,7 +22,6 @@
#include <string.h>
#include "NDS.h"
#include "GPU.h"
#include "Config.h"
#include "GPU3D_OpenGL_shaders.h"
namespace GPU3D

View File

@ -23,7 +23,6 @@
#include <string.h>
#include "NDS.h"
#include "GPU.h"
#include "Config.h"
namespace GPU3D

View File

@ -23,7 +23,6 @@
#include "NDS.h"
#include "GPU.h"
#include "Config.h"
#include "OpenGLSupport.h"
#include "GPU_OpenGL_shaders.h"

View File

@ -19,7 +19,6 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "Config.h"
#include "NDS.h"
#include "ARM.h"
#include "NDSCart.h"
@ -634,6 +633,8 @@ void Reset()
RTC::Reset();
Wifi::Reset();
// TODO: move the SOUNDBIAS/degrade logic to SPU?
// The SOUNDBIAS register does nothing on DSi
SPU::SetApplyBias(ConsoleType == 0);
@ -646,9 +647,10 @@ void Reset()
degradeAudio = false;
}
if (Config::AudioBitrate == 1) // Always 10-bit
int bitrate = Platform::GetConfigInt(Platform::AudioBitrate);
if (bitrate == 1) // Always 10-bit
degradeAudio = true;
else if (Config::AudioBitrate == 2) // Always 16-bit
else if (bitrate == 2) // Always 16-bit
degradeAudio = false;
SPU::SetDegrade10Bit(degradeAudio);

View File

@ -77,6 +77,8 @@ enum ConfigEntry
Firm_BirthdayDay,
Firm_Color,
Firm_Message,
AudioBitrate,
};
int GetConfigInt(ConfigEntry entry);

View File

@ -99,6 +99,8 @@ bool Init()
AudioLock = Platform::Mutex_Create();
InterpType = 0;
ApplyBias = true;
Degrade10Bit = false;
// generate interpolation tables
// values are 1:1:14 fixed-point

View File

@ -25,7 +25,6 @@
#include "ArchiveUtil.h"
#endif
#include "FrontendUtil.h"
#include "Config.h"
#include "SharedConfig.h"
#include "Platform.h"

View File

@ -22,7 +22,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "AudioSettingsDialog.h"
#include "ui_AudioSettingsDialog.h"

View File

@ -4,6 +4,7 @@ SET(SOURCES_QT_SDL
main.cpp
main_shaders.h
CheatsDialog.cpp
Config.cpp
EmuSettingsDialog.cpp
InputConfig/InputConfigDialog.cpp
InputConfig/MapButton.h
@ -22,7 +23,6 @@ SET(SOURCES_QT_SDL
OSD_shaders.h
font.h
Platform.cpp
PlatformConfig.cpp
QPathInput.h
ArchiveUtil.h
@ -33,6 +33,7 @@ SET(SOURCES_QT_SDL
../Util_Audio.cpp
../FrontendUtil.h
../mic_blow.h
../SharedConfig.h
${CMAKE_SOURCE_DIR}/res/melon.qrc
)

View File

@ -24,7 +24,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "CheatsDialog.h"
#include "ui_CheatsDialog.h"

View File

@ -19,7 +19,9 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "PlatformConfig.h"
#include "Platform.h"
#include "Config.h"
namespace Config
{
@ -112,6 +114,7 @@ int DirectLAN;
int SavestateRelocSRAM;
int AudioInterp;
int AudioBitrate;
int AudioVolume;
int MicInputType;
char MicWavPath[1024];
@ -127,7 +130,10 @@ int MouseHideSeconds;
int PauseLostFocus;
ConfigEntry PlatformConfigFile[] =
const char* kConfigFile = "melonDS.ini";
ConfigEntry ConfigFile[] =
{
{"Key_A", 0, &KeyMapping[0], -1, NULL, 0},
{"Key_B", 0, &KeyMapping[1], -1, NULL, 0},
@ -265,6 +271,7 @@ ConfigEntry PlatformConfigFile[] =
{"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 0, NULL, 0},
{"AudioInterp", 0, &AudioInterp, 0, NULL, 0},
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
{"AudioVolume", 0, &AudioVolume, 256, NULL, 0},
{"MicInputType", 0, &MicInputType, 1, NULL, 0},
{"MicWavPath", 1, MicWavPath, 0, "", 1023},
@ -291,4 +298,81 @@ ConfigEntry PlatformConfigFile[] =
{"", -1, NULL, 0, NULL, 0}
};
void Load()
{
ConfigEntry* entry = &ConfigFile[0];
for (;;)
{
if (!entry->Value) break;
if (entry->Type == 0)
*(int*)entry->Value = entry->DefaultInt;
else
{
strncpy((char*)entry->Value, entry->DefaultStr, entry->StrLength);
((char*)entry->Value)[entry->StrLength] = '\0';
}
entry++;
}
FILE* f = Platform::OpenLocalFile(kConfigFile, "r");
if (!f) return;
char linebuf[1024];
char entryname[32];
char entryval[1024];
while (!feof(f))
{
if (fgets(linebuf, 1024, f) == nullptr)
break;
int ret = sscanf(linebuf, "%31[A-Za-z_0-9]=%[^\t\r\n]", entryname, entryval);
entryname[31] = '\0';
if (ret < 2) continue;
ConfigEntry* entry = &ConfigFile[0];
for (;;)
{
if (!entry->Value) break;
if (!strncmp(entry->Name, entryname, 32))
{
if (entry->Type == 0)
*(int*)entry->Value = strtol(entryval, NULL, 10);
else
strncpy((char*)entry->Value, entryval, entry->StrLength);
break;
}
entry++;
}
}
fclose(f);
}
void Save()
{
FILE* f = Platform::OpenLocalFile(kConfigFile, "w");
if (!f) return;
ConfigEntry* entry = &ConfigFile[0];
for (;;)
{
if (!entry->Value) break;
if (entry->Type == 0)
fprintf(f, "%s=%d\r\n", entry->Name, *(int*)entry->Value);
else
fprintf(f, "%s=%s\r\n", entry->Name, (char*)entry->Value);
entry++;
}
fclose(f);
}
}

View File

@ -19,8 +19,6 @@
#ifndef PLATFORMCONFIG_H
#define PLATFORMCONFIG_H
#include "Config.h"
enum
{
HK_Lid = 0,
@ -40,6 +38,17 @@ enum
namespace Config
{
struct ConfigEntry
{
char Name[32];
int Type;
void* Value;
int DefaultInt;
const char* DefaultStr;
int StrLength; // should be set to actual array length minus one
};
extern int KeyMapping[12];
extern int JoyMapping[12];
@ -128,6 +137,7 @@ extern int DirectLAN;
extern int SavestateRelocSRAM;
extern int AudioInterp;
extern int AudioBitrate;
extern int AudioVolume;
extern int MicInputType;
extern char MicWavPath[1024];
@ -142,6 +152,10 @@ extern int MouseHide;
extern int MouseHideSeconds;
extern int PauseLostFocus;
void Load();
void Save();
}
#endif // PLATFORMCONFIG_H

View File

@ -25,7 +25,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "EmuSettingsDialog.h"
#include "ui_EmuSettingsDialog.h"

View File

@ -16,7 +16,7 @@
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#include "PlatformConfig.h"
#include "Config.h"
#include "FirmwareSettingsDialog.h"
#include "ui_FirmwareSettingsDialog.h"

View File

@ -20,7 +20,7 @@
#include <SDL2/SDL.h>
#include "Input.h"
#include "PlatformConfig.h"
#include "Config.h"
namespace Input

View File

@ -25,7 +25,6 @@
#include "types.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "MapButton.h"
#include "Input.h"

View File

@ -22,7 +22,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
InterfaceSettingsDialog* InterfaceSettingsDialog::currentDlg = nullptr;

View File

@ -25,7 +25,7 @@
#include <pcap/pcap.h>
#include "../Wifi.h"
#include "LAN_PCap.h"
#include "PlatformConfig.h"
#include "Config.h"
#ifdef __WIN32__
#include <iphlpapi.h>

View File

@ -23,7 +23,6 @@
#include <string.h>
#include "Wifi.h"
#include "LAN_Socket.h"
#include "Config.h"
#include "FIFO.h"
#include <slirp/libslirp.h>

View File

@ -29,7 +29,7 @@
#include "OSD_shaders.h"
#include "font.h"
#include "PlatformConfig.h"
#include "Config.h"
extern MainWindow* mainWindow;

View File

@ -51,7 +51,7 @@
#include <QOpenGLContext>
#include "Platform.h"
#include "PlatformConfig.h"
#include "Config.h"
#include "LAN_Socket.h"
#include "LAN_PCap.h"
#include <string>
@ -140,6 +140,8 @@ int GetConfigInt(ConfigEntry entry)
case Firm_BirthdayMonth: return Config::FirmwareBirthdayMonth;
case Firm_BirthdayDay: return Config::FirmwareBirthdayDay;
case Firm_Color: return Config::FirmwareFavouriteColour;
case AudioBitrate: return Config::AudioBitrate;
}
return 0;

View File

@ -25,7 +25,6 @@
#include "NDSCart.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
QString IntToHex(u64 num)
{

View File

@ -23,7 +23,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "FrontendUtil.h"
#include "DSi_NAND.h"

View File

@ -23,7 +23,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "VideoSettingsDialog.h"
#include "ui_VideoSettingsDialog.h"

View File

@ -22,7 +22,6 @@
#include "types.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "LAN_Socket.h"
#include "LAN_PCap.h"

View File

@ -75,7 +75,6 @@
#include "Wifi.h"
#include "Platform.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "Savestate.h"