aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt144
-rw-r--r--cmake/Toolchain-cross-MinGW-w64-x86_64.cmake24
-rw-r--r--melon.rc8
-rw-r--r--src/SPU.cpp11
-rw-r--r--src/SPU.h2
-rw-r--r--src/libui_sdl/main.cpp65
-rw-r--r--src/version.h2
7 files changed, 195 insertions, 61 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d824f6f..fcbe773 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,47 +34,51 @@ SET(SOURCES
src/libui_sdl/libui/common/matrix.c
src/libui_sdl/libui/common/shouldquit.c
src/libui_sdl/libui/common/userbugs.c
- src/libui_sdl/libui/unix/alloc.c
- src/libui_sdl/libui/unix/area.c
- src/libui_sdl/libui/unix/box.c
- src/libui_sdl/libui/unix/button.c
- src/libui_sdl/libui/unix/cellrendererbutton.c
- src/libui_sdl/libui/unix/checkbox.c
- src/libui_sdl/libui/unix/child.c
- src/libui_sdl/libui/unix/colorbutton.c
- src/libui_sdl/libui/unix/combobox.c
- src/libui_sdl/libui/unix/control.c
- src/libui_sdl/libui/unix/datetimepicker.c
- src/libui_sdl/libui/unix/debug.c
- src/libui_sdl/libui/unix/draw.c
- src/libui_sdl/libui/unix/drawmatrix.c
- src/libui_sdl/libui/unix/drawpath.c
- src/libui_sdl/libui/unix/drawtext.c
- src/libui_sdl/libui/unix/editablecombo.c
- src/libui_sdl/libui/unix/entry.c
- src/libui_sdl/libui/unix/fontbutton.c
- src/libui_sdl/libui/unix/form.c
- src/libui_sdl/libui/unix/future.c
- src/libui_sdl/libui/unix/graphemes.c
- src/libui_sdl/libui/unix/grid.c
- src/libui_sdl/libui/unix/group.c
- src/libui_sdl/libui/unix/image.c
- src/libui_sdl/libui/unix/label.c
- src/libui_sdl/libui/unix/main.c
- src/libui_sdl/libui/unix/menu.c
- src/libui_sdl/libui/unix/multilineentry.c
- src/libui_sdl/libui/unix/progressbar.c
- src/libui_sdl/libui/unix/radiobuttons.c
- src/libui_sdl/libui/unix/separator.c
- src/libui_sdl/libui/unix/slider.c
- src/libui_sdl/libui/unix/spinbox.c
- src/libui_sdl/libui/unix/stddialogs.c
- src/libui_sdl/libui/unix/tab.c
- src/libui_sdl/libui/unix/text.c
- src/libui_sdl/libui/unix/util.c
- src/libui_sdl/libui/unix/window.c)
+)
if (UNIX)
+ LIST(APPEND SOURCES
+ src/libui_sdl/libui/unix/alloc.c
+ src/libui_sdl/libui/unix/area.c
+ src/libui_sdl/libui/unix/box.c
+ src/libui_sdl/libui/unix/button.c
+ src/libui_sdl/libui/unix/cellrendererbutton.c
+ src/libui_sdl/libui/unix/checkbox.c
+ src/libui_sdl/libui/unix/child.c
+ src/libui_sdl/libui/unix/colorbutton.c
+ src/libui_sdl/libui/unix/combobox.c
+ src/libui_sdl/libui/unix/control.c
+ src/libui_sdl/libui/unix/datetimepicker.c
+ src/libui_sdl/libui/unix/debug.c
+ src/libui_sdl/libui/unix/draw.c
+ src/libui_sdl/libui/unix/drawmatrix.c
+ src/libui_sdl/libui/unix/drawpath.c
+ src/libui_sdl/libui/unix/drawtext.c
+ src/libui_sdl/libui/unix/editablecombo.c
+ src/libui_sdl/libui/unix/entry.c
+ src/libui_sdl/libui/unix/fontbutton.c
+ src/libui_sdl/libui/unix/form.c
+ src/libui_sdl/libui/unix/future.c
+ src/libui_sdl/libui/unix/graphemes.c
+ src/libui_sdl/libui/unix/grid.c
+ src/libui_sdl/libui/unix/group.c
+ src/libui_sdl/libui/unix/image.c
+ src/libui_sdl/libui/unix/label.c
+ src/libui_sdl/libui/unix/main.c
+ src/libui_sdl/libui/unix/menu.c
+ src/libui_sdl/libui/unix/multilineentry.c
+ src/libui_sdl/libui/unix/progressbar.c
+ src/libui_sdl/libui/unix/radiobuttons.c
+ src/libui_sdl/libui/unix/separator.c
+ src/libui_sdl/libui/unix/slider.c
+ src/libui_sdl/libui/unix/spinbox.c
+ src/libui_sdl/libui/unix/stddialogs.c
+ src/libui_sdl/libui/unix/tab.c
+ src/libui_sdl/libui/unix/text.c
+ src/libui_sdl/libui/unix/util.c
+ src/libui_sdl/libui/unix/window.c
+ )
+
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
@@ -86,6 +90,68 @@ if (UNIX)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
LINK_LIBRARIES("dl")
endif ()
+elseif (WIN32)
+ LIST(APPEND SOURCES
+ src/libui_sdl/libui/windows/alloc.cpp
+ src/libui_sdl/libui/windows/area.cpp
+ src/libui_sdl/libui/windows/areadraw.cpp
+ src/libui_sdl/libui/windows/areaevents.cpp
+ src/libui_sdl/libui/windows/areascroll.cpp
+ src/libui_sdl/libui/windows/areautil.cpp
+ src/libui_sdl/libui/windows/box.cpp
+ src/libui_sdl/libui/windows/button.cpp
+ src/libui_sdl/libui/windows/checkbox.cpp
+ src/libui_sdl/libui/windows/colorbutton.cpp
+ src/libui_sdl/libui/windows/colordialog.cpp
+ src/libui_sdl/libui/windows/combobox.cpp
+ src/libui_sdl/libui/windows/container.cpp
+ src/libui_sdl/libui/windows/control.cpp
+ src/libui_sdl/libui/windows/d2dscratch.cpp
+ src/libui_sdl/libui/windows/datetimepicker.cpp
+ src/libui_sdl/libui/windows/debug.cpp
+ src/libui_sdl/libui/windows/draw.cpp
+ src/libui_sdl/libui/windows/drawmatrix.cpp
+ src/libui_sdl/libui/windows/drawpath.cpp
+ src/libui_sdl/libui/windows/drawtext.cpp
+ src/libui_sdl/libui/windows/dwrite.cpp
+ src/libui_sdl/libui/windows/editablecombo.cpp
+ #src/libui_sdl/libui/windows/entry.cpp
+ src/libui_sdl/libui/windows/events.cpp
+ src/libui_sdl/libui/windows/fontbutton.cpp
+ src/libui_sdl/libui/windows/fontdialog.cpp
+ src/libui_sdl/libui/windows/form.cpp
+ src/libui_sdl/libui/windows/graphemes.cpp
+ src/libui_sdl/libui/windows/grid.cpp
+ src/libui_sdl/libui/windows/group.cpp
+ src/libui_sdl/libui/windows/init.cpp
+ src/libui_sdl/libui/windows/label.cpp
+ src/libui_sdl/libui/windows/main.cpp
+ src/libui_sdl/libui/windows/menu.cpp
+ src/libui_sdl/libui/windows/multilineentry.cpp
+ src/libui_sdl/libui/windows/parent.cpp
+ src/libui_sdl/libui/windows/progressbar.cpp
+ src/libui_sdl/libui/windows/radiobuttons.cpp
+ src/libui_sdl/libui/windows/separator.cpp
+ src/libui_sdl/libui/windows/sizing.cpp
+ src/libui_sdl/libui/windows/slider.cpp
+ src/libui_sdl/libui/windows/spinbox.cpp
+ src/libui_sdl/libui/windows/stddialogs.cpp
+ #src/libui_sdl/libui/windows/tab.cpp
+ #src/libui_sdl/libui/windows/tabpage.cpp
+ src/libui_sdl/libui/windows/text.cpp
+ src/libui_sdl/libui/windows/utf16.cpp
+ src/libui_sdl/libui/windows/utilwin.cpp
+ src/libui_sdl/libui/windows/window.cpp
+ src/libui_sdl/libui/windows/winpublic.cpp
+ src/libui_sdl/libui/windows/winutil.cpp
+ src/libui_sdl/libui/windows/resources.rc
+ )
+
+ LINK_LIBRARIES("comctl32")
+ LINK_LIBRARIES("d2d1")
+ LINK_LIBRARIES("dwrite")
+ LINK_LIBRARIES("usp10")
+ LINK_LIBRARIES("ws2_32")
endif (UNIX)
find_package(SDL2 REQUIRED)
diff --git a/cmake/Toolchain-cross-MinGW-w64-x86_64.cmake b/cmake/Toolchain-cross-MinGW-w64-x86_64.cmake
new file mode 100644
index 0000000..1d98710
--- /dev/null
+++ b/cmake/Toolchain-cross-MinGW-w64-x86_64.cmake
@@ -0,0 +1,24 @@
+# https://cmake.org/Wiki/CMake_Cross_Compiling
+
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+SET(COMPILER_PREFIX "x86_64-w64-mingw32")
+
+# which compilers to use for C and C++
+find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
+find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
+
+# pkg-config
+find_program(PKG_CONFIG_EXECUTABLE NAMES ${COMPILER_PREFIX}-pkg-config)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}/sys-root/mingw)
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/melon.rc b/melon.rc
index 993d723..ccf9766 100644
--- a/melon.rc
+++ b/melon.rc
@@ -6,8 +6,8 @@
//include version information in .exe, modify these values to match your needs
1 VERSIONINFO
-FILEVERSION 0,6,0,0
-PRODUCTVERSION 0,6,0,0
+FILEVERSION 0,6,1,0
+PRODUCTVERSION 0,6,1,0
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
@@ -15,14 +15,14 @@ FILETYPE VFT_APP
BLOCK "040904E4"
{
VALUE "CompanyName", "Melon Factory of Kuribo64"
- VALUE "FileVersion", "0.6"
+ VALUE "FileVersion", "0.6b"
VALUE "FileDescription", "DS emulator, sorta. also 1st quality melon."
VALUE "InternalName", "SDnolem"
VALUE "LegalCopyright", "2016-2017 StapleButter & co."
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", "zafkflzdasd.exe"
VALUE "ProductName", "melonDS"
- VALUE "ProductVersion", "0.6"
+ VALUE "ProductVersion", "0.6b"
}
}
BLOCK "VarFileInfo"
diff --git a/src/SPU.cpp b/src/SPU.cpp
index a0d8dc8..7f70e65 100644
--- a/src/SPU.cpp
+++ b/src/SPU.cpp
@@ -684,19 +684,26 @@ void Mix(u32 samples)
}
-void ReadOutput(s16* data, int samples)
+int ReadOutput(s16* data, int samples)
{
+ if (OutputReadOffset == OutputWriteOffset)
+ return 0;
+
for (int i = 0; i < samples; i++)
{
*data++ = OutputBuffer[OutputReadOffset];
*data++ = OutputBuffer[OutputReadOffset + 1];
- if (OutputReadOffset != OutputWriteOffset)
+ //if (OutputReadOffset != OutputWriteOffset)
{
OutputReadOffset += 2;
OutputReadOffset &= ((2*OutputBufferSize)-1);
}
+ if (OutputReadOffset == OutputWriteOffset)
+ return i+1;
}
+
+ return samples;
}
diff --git a/src/SPU.h b/src/SPU.h
index cc0127a..85c27ee 100644
--- a/src/SPU.h
+++ b/src/SPU.h
@@ -31,7 +31,7 @@ void SetBias(u16 bias);
void Mix(u32 samples);
-void ReadOutput(s16* data, int samples);
+int ReadOutput(s16* data, int samples);
u8 Read8(u32 addr);
u16 Read16(u32 addr);
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 841aa9c..61742b5 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -96,7 +96,46 @@ void UpdateWindowTitle(void* data)
void AudioCallback(void* data, Uint8* stream, int len)
{
- SPU::ReadOutput((s16*)stream, len>>2);
+ // resampling:
+ // buffer length is 1024 samples
+ // which is 710 samples at the original sample rate
+
+ //SPU::ReadOutput((s16*)stream, len>>2);
+ s16 buf_in[710*2];
+ s16* buf_out = (s16*)stream;
+
+ int num_in = SPU::ReadOutput(buf_in, 710);
+ int num_out = 1024;
+
+ int margin = 6;
+ if (num_in < 710-margin)
+ {
+ int last = num_in-1;
+ if (last < 0) last = 0;
+
+ for (int i = num_in; i < 710-margin; i++)
+ ((u32*)buf_in)[i] = ((u32*)buf_in)[last];
+
+ num_in = 710-margin;
+ }
+
+ float res_incr = num_in / (float)num_out;
+ float res_timer = 0;
+ int res_pos = 0;
+
+ for (int i = 0; i < 1024; i++)
+ {
+ // TODO: interp!!
+ buf_out[i*2 ] = buf_in[res_pos*2 ];
+ buf_out[i*2+1] = buf_in[res_pos*2+1];
+
+ res_timer += res_incr;
+ while (res_timer >= 1.0)
+ {
+ res_timer -= 1.0;
+ res_pos++;
+ }
+ }
}
int EmuThreadFunc(void* burp)
@@ -111,15 +150,9 @@ int EmuThreadFunc(void* burp)
ScreenDrawInited = false;
Touching = false;
- // DS:
- // 547.060546875 samples per frame
- // 32823.6328125 samples per second
- //
- // 48000 samples per second:
- // 800 samples per frame
SDL_AudioSpec whatIwant, whatIget;
memset(&whatIwant, 0, sizeof(SDL_AudioSpec));
- whatIwant.freq = 32824; // 32823.6328125
+ whatIwant.freq = 47340;
whatIwant.format = AUDIO_S16LSB;
whatIwant.channels = 2;
whatIwant.samples = 1024;
@@ -1112,11 +1145,6 @@ int main(int argc, char** argv)
uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL);
uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1);
- uiMenuItemSetChecked(MenuItem_ScreenRot[ScreenRotation], 1);
- uiMenuItemSetChecked(MenuItem_ScreenGap[ScreenGap], 1);
- uiMenuItemSetChecked(MenuItem_ScreenLayout[ScreenLayout], 1);
- uiMenuItemSetChecked(MenuItem_ScreenSizing[ScreenSizing], 1);
-
int w = Config::WindowWidth;
int h = Config::WindowHeight;
@@ -1156,11 +1184,20 @@ int main(int argc, char** argv)
#define SANITIZE(var, min, max) if ((var < min) || (var > max)) var = 0;
SANITIZE(ScreenRotation, 0, 3);
- SANITIZE(ScreenGap, 0, 5);
SANITIZE(ScreenLayout, 0, 2);
SANITIZE(ScreenSizing, 0, 3);
#undef SANITIZE
+ uiMenuItemSetChecked(MenuItem_ScreenRot[ScreenRotation], 1);
+ uiMenuItemSetChecked(MenuItem_ScreenLayout[ScreenLayout], 1);
+ uiMenuItemSetChecked(MenuItem_ScreenSizing[ScreenSizing], 1);
+
+ for (int i = 0; i < 6; i++)
+ {
+ if (ScreenGap == kScreenGap[i])
+ uiMenuItemSetChecked(MenuItem_ScreenGap[i], 1);
+ }
+
OnSetScreenRotation(MenuItem_ScreenRot[ScreenRotation], MainWindow, (void*)&kScreenRot[ScreenRotation]);
EmuRunning = 2;
diff --git a/src/version.h b/src/version.h
index deaf3f3..9e2d867 100644
--- a/src/version.h
+++ b/src/version.h
@@ -19,7 +19,7 @@
#ifndef VERSION_H
#define VERSION_H
-#define MELONDS_VERSION "0.6"
+#define MELONDS_VERSION "0.6b"
#define MELONDS_URL "http://melonds.kuribo64.net/"