This commit is contained in:
CaiB 2020-05-20 14:38:56 +09:00
parent 33f33ed9fd
commit 003a1f4f8a
8 changed files with 54 additions and 16 deletions

7
.gitignore vendored
View file

@ -1,2 +1,7 @@
colorchord2/windows/colorchord.def colorchord2/windows/colorchord.def
colorchord2/colorchord.def colorchord2/colorchord.def
*.o
**/*.exp
**/*.ilk
**/*.pdb
colorchord2/colorchord.lib

View file

@ -58,6 +58,8 @@ make
Building with Windows 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: 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 pacman -S mingw-w64-i686-toolchain
@ -71,6 +73,26 @@ To make colorchord, navigate to your working copy and type:
mingw32-make colorchord.exe 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 Using
----- -----

View file

@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" package="org.cnlohr.colorchord" <manifest xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" package="org.cnlohr.colorchord"
android:versionCode="5"> android:versionCode="8">
<uses-sdk android:minSdkVersion="22"
android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.SET_RELEASE_APP"/> <uses-permission android:name="android.permission.SET_RELEASE_APP"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/> <uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application android:debuggable="false" android:hasCode="false" android:label="colorchord" tools:replace="android:icon,android:theme,android:allowBackup,label" android:icon="@mipmap/icon" android:requestLegacyExternalStorage="true"> <application android:debuggable="false" android:hasCode="false" android:label="colorchord" tools:replace="android:icon,android:theme,android:allowBackup,label" android:icon="@mipmap/icon" > <!--android:requestLegacyExternalStorage="true" Not needed til Android 29 -->
<activity android:configChanges="keyboardHidden|orientation" android:label="colorchord" android:name="android.app.NativeActivity"> <activity android:configChanges="keyboardHidden|orientation" android:label="colorchord" android:name="android.app.NativeActivity">
<!-- This device filter seems to do nothing at all! If you figure out how to use it or what it does, let me know!! --> <!-- This device filter seems to do nothing at all! If you figure out how to use it or what it does, let me know!! -->

View file

@ -7,7 +7,8 @@ CFLAGS:=-I. -I.. -Irawdrawandroid/rawdraw -I../cnfa -I../../embeddedcommon \
-ffunction-sections -Os -s -DPRINTF_NO_OVERRIDDE -fvisibility=hidden \ -ffunction-sections -Os -s -DPRINTF_NO_OVERRIDDE -fvisibility=hidden \
-DRDALOGFNCB=example_log_function -DRDALOGFNCB=example_log_function
#ANDROIDVERSION=24 ANDROIDVERSION=22
ANDROIDTARGET=28
LDFLAGS:=-s -lOpenSLES LDFLAGS:=-s -lOpenSLES

View file

@ -48,16 +48,19 @@ void LoadFile( const char * filename )
void SetEnvValues( int force ) void SetEnvValues( int force )
{ {
int i; static int ifcheck;
int hits = 0; int hits = 0;
for( i = 0; i < InitialFileCount; i++ )
if( InitialFileCount )
{ {
double ft = OGGetFileTime( InitialFile[i] ); //Only check one location per frame.
if( FileTimes[i] != ft ) double ft = OGGetFileTime( InitialFile[ifcheck] );
if( FileTimes[ifcheck] != ft )
{ {
FileTimes[i] = ft; FileTimes[ifcheck] = ft;
hits++; hits++;
} }
ifcheck = ( ifcheck + 1 ) % InitialFileCount;
} }
if( !hits && !force ) return; if( !hits && !force ) return;
@ -109,6 +112,7 @@ void SetEnvValues( int force )
printf( "On Android, looking for configuration file in: %s\n", InitialFile[0] ); printf( "On Android, looking for configuration file in: %s\n", InitialFile[0] );
#endif #endif
int i;
for( i = 0; i < InitialFileCount; i++ ) for( i = 0; i < InitialFileCount; i++ )
{ {
LoadFile( InitialFile[i] ); LoadFile( InitialFile[i] );
@ -151,8 +155,10 @@ void SetupConfigs()
{ {
#ifdef ANDROID #ifdef ANDROID
InitialFile[0] = "/sdcard/colorchord-android.txt"; InitialFile[0] = "/sdcard/colorchord-android.txt";
InitialFile[1] = "/sdcard/colorchord-android-overlay.txt"; InitialFile[1] = "/storage/emulated/0/colorchord-android.txt";
InitialFileCount = 2; InitialFile[2] = "/sdcard/colorchord-android-overlay.txt";
InitialFile[3] = "/storage/emulated/0/colorchord-android-overlay.txt";
InitialFileCount = 4;
#else #else
InitialFile[0] = "default.conf"; InitialFile[0] = "default.conf";
#endif #endif

View file

@ -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 channelin = sd->channelsRec;
int channelout = sd->channelsPlay; int channelout = sd->channelsPlay;
@ -246,7 +246,7 @@ void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int
if( in ) if( in )
{ {
for( i = 0; i < samplesr; i++ ) for( i = 0; i < framesr; i++ )
{ {
if( sample_channel < 0 ) 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 ) if( out )
{ {
for( j = 0; j < samplesp * channelout; j++ ) for( j = 0; j < framesp * channelout; j++ )
{ {
out[j] = 0; out[j] = 0;
} }
SoundEventHappened( samplesp, out, 1, channelout ); SoundEventHappened( framesp, out, 1, channelout );
} }

View file

@ -1,3 +1,4 @@
@echo off
set CC="C:\Program Files\LLVM\bin\clang.exe" set CC="C:\Program Files\LLVM\bin\clang.exe"
rem To enable OpenGL rendering use the -DCNFGOGL option rem To enable OpenGL rendering use the -DCNFGOGL option
set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS