mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 04:55:13 +00:00
fix windows build...
This commit is contained in:
parent
ce32f921bd
commit
2baed0cff0
8 changed files with 149 additions and 6 deletions
|
@ -111,7 +111,6 @@ src/engine/platform/dummy.cpp)
|
|||
|
||||
set(GUI_SOURCES
|
||||
extern/imgui/imgui.cpp
|
||||
extern/imgui/imgui_demo.cpp
|
||||
extern/imgui/imgui_draw.cpp
|
||||
extern/imgui/imgui_tables.cpp
|
||||
extern/imgui/imgui_widgets.cpp
|
||||
|
@ -124,6 +123,10 @@ src/gui/font_main.cpp
|
|||
src/gui/font_pat.cpp
|
||||
src/gui/gui.cpp)
|
||||
|
||||
if (WIN32)
|
||||
list(APPEND ENGINE_SOURCES src/utfutils.cpp)
|
||||
endif()
|
||||
|
||||
if (BUILD_GUI)
|
||||
add_executable(furnace ${ENGINE_SOURCES} ${AUDIO_SOURCES} ${GUI_SOURCES} src/main.cpp)
|
||||
target_compile_definitions(furnace PUBLIC HAVE_GUI)
|
||||
|
|
|
@ -1156,7 +1156,6 @@ void DivEngine::renderSamples() {
|
|||
DivSample* s=song.sample[i];
|
||||
if ((memPos&0xf00000)!=((memPos+s->adpcmRendLength)&0xf00000)) {
|
||||
memPos=(memPos+0xfffff)&0xf00000;
|
||||
printf("aligning to %lx.\n",memPos);
|
||||
}
|
||||
memcpy(adpcmMem+memPos,s->adpcmRendData,s->adpcmRendLength);
|
||||
s->rendOff=memPos;
|
||||
|
@ -1340,7 +1339,7 @@ void DivEngine::quitDispatch() {
|
|||
}
|
||||
|
||||
bool DivEngine::init(String outName) {
|
||||
SNDFILE* outFile;
|
||||
SNDFILE* outFile=NULL;
|
||||
SF_INFO outInfo;
|
||||
if (outName!="") {
|
||||
// init out file
|
||||
|
|
|
@ -40,6 +40,7 @@ struct DivChannelState {
|
|||
volSpeed(0),
|
||||
cut(-1),
|
||||
rowDelay(0),
|
||||
volMax(0),
|
||||
delayOrder(0),
|
||||
delayRow(0),
|
||||
vibratoDepth(0),
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -314,3 +315,7 @@ int main(int argc, char** argv) {
|
|||
e.quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winMain.cpp"
|
||||
#endif
|
||||
|
|
|
@ -9,9 +9,8 @@ typedef std::string String;
|
|||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#ifdef _WIN32
|
||||
typedef std::wstring WString;
|
||||
#endif
|
||||
|
||||
struct TAParam {
|
||||
|
|
94
src/utfutils.cpp
Normal file
94
src/utfutils.cpp
Normal file
|
@ -0,0 +1,94 @@
|
|||
#include "utfutils.h"
|
||||
|
||||
int decodeUTF8(const unsigned char* data, char& len) {
|
||||
int ret=0xfffd;
|
||||
if (data[0]<0x80) {
|
||||
ret=data[0];
|
||||
len=1;
|
||||
} else if (data[0]<0xc0) {
|
||||
ret=0xfffd; // invalid
|
||||
len=1;
|
||||
} else if (data[0]<0xe0) {
|
||||
if (data[1]>=0x80 && data[1]<0xc0) {
|
||||
len=2;
|
||||
ret=((data[0]&31)<<6)|
|
||||
(data[1]&63);
|
||||
} else len=1;
|
||||
} else if (data[0]<0xf0) {
|
||||
if (data[1]>=0x80 && data[1]<0xc0) {
|
||||
if (data[2]>=0x80 && data[2]<0xc0) {
|
||||
len=3;
|
||||
ret=((data[0]&15)<<12)|
|
||||
((data[1]&63)<<6)|
|
||||
(data[2]&63);
|
||||
} else len=2;
|
||||
} else len=1;
|
||||
} else if (data[0]<0xf5) {
|
||||
if (data[1]>=0x80 && data[1]<0xc0) {
|
||||
if (data[2]>=0x80 && data[2]<0xc0) {
|
||||
if (data[3]>=0x80 && data[3]<0xc0) {
|
||||
len=4;
|
||||
ret=((data[0]&7)<<18)|
|
||||
((data[1]&63)<<12)|
|
||||
((data[2]&63)<<6)|
|
||||
(data[3]&63);
|
||||
} else len=3;
|
||||
} else len=2;
|
||||
} else len=1;
|
||||
} else {
|
||||
len=1;
|
||||
return 0xfffd;
|
||||
}
|
||||
|
||||
if ((ret>=0xd800 && ret<=0xdfff) || ret>=0x110000) return 0xfffd;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t utf8len(const char* s) {
|
||||
size_t p=0;
|
||||
size_t r=0;
|
||||
char cl;
|
||||
while (s[p]!=0) {
|
||||
r++;
|
||||
decodeUTF8((const unsigned char*)&s[p],cl);
|
||||
p+=cl;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
char utf8csize(const unsigned char* c) {
|
||||
char ret;
|
||||
decodeUTF8(c,ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WString utf8To16(const char* s) {
|
||||
WString ret;
|
||||
int ch, p;
|
||||
char chs;
|
||||
p=0;
|
||||
while (s[p]!=0) {
|
||||
ch=decodeUTF8((const unsigned char*)&s[p],chs);
|
||||
ret+=(unsigned short)ch;
|
||||
p+=chs;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
String utf16To8(const wchar_t* s) {
|
||||
String ret;
|
||||
for (size_t i=0; i<wcslen(s); i++) {
|
||||
if (s[i]<0x80) {
|
||||
ret+=s[i];
|
||||
} else if (s[i]<0x800) {
|
||||
ret+=(0xc0+((s[i]>>6)&31));
|
||||
ret+=(0x80+((s[i])&63));
|
||||
} else {
|
||||
ret+=(0xe0+((s[i]>>12)&15));
|
||||
ret+=(0x80+((s[i]>>6)&63));
|
||||
ret+=(0x80+((s[i])&63));
|
||||
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
15
src/utfutils.h
Normal file
15
src/utfutils.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef _UTFUTILS_H
|
||||
#define _UTFUTILS_H
|
||||
#include "ta-utils.h"
|
||||
|
||||
size_t utf8len(const char* s);
|
||||
size_t utf8clen(const char* s);
|
||||
size_t utf8pos(const char* s, size_t inpos);
|
||||
size_t utf8cpos(const char* s, size_t inpos);
|
||||
size_t utf8findcpos(const char* s, float inpos);
|
||||
char utf8csize(const unsigned char* c);
|
||||
|
||||
WString utf8To16(const char* in);
|
||||
String utf16To8(const wchar_t* in);
|
||||
|
||||
#endif
|
27
src/winMain.cpp
Normal file
27
src/winMain.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "utfutils.h"
|
||||
|
||||
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInst, PSTR args, int state) {
|
||||
int argc=0;
|
||||
wchar_t** argw=CommandLineToArgvW(GetCommandLineW(),&argc);
|
||||
char** argv=new char*[argc+1];
|
||||
argv[argc]=NULL;
|
||||
for (int i=0; i<argc; i++) {
|
||||
std::string str=utf16To8(argw[i]);
|
||||
argv[i]=new char[str.size()+1];
|
||||
strcpy(argv[i],str.c_str());
|
||||
}
|
||||
return main(argc,argv);
|
||||
}
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE inst, HINSTANCE prevInst, PWSTR args, int state) {
|
||||
int argc=0;
|
||||
wchar_t** argw=CommandLineToArgvW(args,&argc);
|
||||
char** argv=new char*[argc+1];
|
||||
argv[argc]=NULL;
|
||||
for (int i=0; i<argc; i++) {
|
||||
std::string str=utf16To8(argw[i]);
|
||||
argv[i]=new char[str.size()+1];
|
||||
strcpy(argv[i],str.c_str());
|
||||
}
|
||||
return main(argc,argv);
|
||||
}
|
Loading…
Reference in a new issue