From 003a1f4f8a34d9ca872c3d2ca6868f30afe5e063 Mon Sep 17 00:00:00 2001 From: CaiB Date: Wed, 20 May 2020 14:38:56 +0900 Subject: [PATCH] Marging --- .gitignore | 7 +++++- README.md | 22 +++++++++++++++++++ colorchord2/android/AndroidManifest.xml | 7 ++++-- colorchord2/android/Makefile | 3 ++- ...rd-android.conf => colorchord-android.txt} | 0 colorchord2/configs.c | 20 +++++++++++------ colorchord2/main.c | 10 ++++----- colorchord2/windows/compile-clang.bat | 1 + 8 files changed, 54 insertions(+), 16 deletions(-) rename colorchord2/android/{colorchord-android.conf => colorchord-android.txt} (100%) mode change 100755 => 100644 diff --git a/.gitignore b/.gitignore index 3841a63..d81e4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ colorchord2/windows/colorchord.def -colorchord2/colorchord.def \ No newline at end of file +colorchord2/colorchord.def +*.o +**/*.exp +**/*.ilk +**/*.pdb +colorchord2/colorchord.lib diff --git a/README.md b/README.md index a368eb2..30431c0 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ make Building with Windows ------------------- +There are 3 options available for building on Windows, MSYS2, clang, or TCC. +### MSYS2 With either 64bit or 32bit [MSYS2](https://msys2.github.io/) installed, run the _MSYS2 MSYS_ launcher and use `pacman` to set up a MinGW32 toolchain, if you don't have one already: ``` pacman -S mingw-w64-i686-toolchain @@ -71,6 +73,26 @@ To make colorchord, navigate to your working copy and type: mingw32-make colorchord.exe ``` +### clang +Start by [downloading](https://clang.llvm.org/) the clang compiler, and installing it. + +Edit the batch script at `colorchord2/windows/compile-clang.bat`: +- Verify that the executable location is correct, on line 1 (`CC`). + +If you have the Windows SDK installed, you should not need to do any additional work. +If you do not, you'll want to either [install it](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk/) to get the official headers, or use the unofficial headers instead by adding `-DNO_WIN_HEADERS` to the `CCFLAGS` line in the batch file above. + +Run the batch script, and it should output to `colorchord2/colorchord.exe`. + +### TCC +Start by [downloading TCC](http://savannah.nongnu.org/projects/tinycc/), and extracting it to a location of your choice. + +Edit the batch script at `colorchord2/windows/compile.bat`: +- Edit line 17 (`CC`) to be the location where you put TCC. If there are spaces in the path, wrap the entire path in quotes. + +Note that TCC is not able to use the Windows SDK, and as such using the unofficial headers is required, and automatically enabled when compiling with TCC. If you encounter issues, try the clang method above instead. + + Using ----- diff --git a/colorchord2/android/AndroidManifest.xml b/colorchord2/android/AndroidManifest.xml index 27265e1..4acec47 100644 --- a/colorchord2/android/AndroidManifest.xml +++ b/colorchord2/android/AndroidManifest.xml @@ -1,12 +1,15 @@ + android:versionCode="8"> + + - + diff --git a/colorchord2/android/Makefile b/colorchord2/android/Makefile index 883f7e4..b9c3df1 100644 --- a/colorchord2/android/Makefile +++ b/colorchord2/android/Makefile @@ -7,7 +7,8 @@ CFLAGS:=-I. -I.. -Irawdrawandroid/rawdraw -I../cnfa -I../../embeddedcommon \ -ffunction-sections -Os -s -DPRINTF_NO_OVERRIDDE -fvisibility=hidden \ -DRDALOGFNCB=example_log_function -#ANDROIDVERSION=24 +ANDROIDVERSION=22 +ANDROIDTARGET=28 LDFLAGS:=-s -lOpenSLES diff --git a/colorchord2/android/colorchord-android.conf b/colorchord2/android/colorchord-android.txt old mode 100755 new mode 100644 similarity index 100% rename from colorchord2/android/colorchord-android.conf rename to colorchord2/android/colorchord-android.txt diff --git a/colorchord2/configs.c b/colorchord2/configs.c index 2c26c03..b6788cb 100644 --- a/colorchord2/configs.c +++ b/colorchord2/configs.c @@ -48,16 +48,19 @@ void LoadFile( const char * filename ) void SetEnvValues( int force ) { - int i; + static int ifcheck; int hits = 0; - for( i = 0; i < InitialFileCount; i++ ) + + if( InitialFileCount ) { - double ft = OGGetFileTime( InitialFile[i] ); - if( FileTimes[i] != ft ) + //Only check one location per frame. + double ft = OGGetFileTime( InitialFile[ifcheck] ); + if( FileTimes[ifcheck] != ft ) { - FileTimes[i] = ft; + FileTimes[ifcheck] = ft; hits++; } + ifcheck = ( ifcheck + 1 ) % InitialFileCount; } if( !hits && !force ) return; @@ -109,6 +112,7 @@ void SetEnvValues( int force ) printf( "On Android, looking for configuration file in: %s\n", InitialFile[0] ); #endif + int i; for( i = 0; i < InitialFileCount; i++ ) { LoadFile( InitialFile[i] ); @@ -151,8 +155,10 @@ void SetupConfigs() { #ifdef ANDROID InitialFile[0] = "/sdcard/colorchord-android.txt"; - InitialFile[1] = "/sdcard/colorchord-android-overlay.txt"; - InitialFileCount = 2; + InitialFile[1] = "/storage/emulated/0/colorchord-android.txt"; + InitialFile[2] = "/sdcard/colorchord-android-overlay.txt"; + InitialFile[3] = "/storage/emulated/0/colorchord-android-overlay.txt"; + InitialFileCount = 4; #else InitialFile[0] = "default.conf"; #endif diff --git a/colorchord2/main.c b/colorchord2/main.c index fb3a9a1..59adea9 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -232,7 +232,7 @@ void HandleMotion( int x, int y, int mask ) { } -void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int samplesp ) +void SoundCB( struct CNFADriver * sd, short * in, short * out, int framesr, int framesp ) { int channelin = sd->channelsRec; int channelout = sd->channelsPlay; @@ -246,7 +246,7 @@ void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int if( in ) { - for( i = 0; i < samplesr; i++ ) + for( i = 0; i < framesr; i++ ) { if( sample_channel < 0 ) { @@ -285,17 +285,17 @@ void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int } } - SoundEventHappened( samplesr, in, 0, channelin ); + SoundEventHappened( framesr, in, 0, channelin ); } if( out ) { - for( j = 0; j < samplesp * channelout; j++ ) + for( j = 0; j < framesp * channelout; j++ ) { out[j] = 0; } - SoundEventHappened( samplesp, out, 1, channelout ); + SoundEventHappened( framesp, out, 1, channelout ); } diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index 91a2c56..900ea1d 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -1,3 +1,4 @@ +@echo off set CC="C:\Program Files\LLVM\bin\clang.exe" rem To enable OpenGL rendering use the -DCNFGOGL option set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS