mirror of
https://github.com/simtactics/niotso.git
synced 2025-03-22 10:52:20 +00:00
* Fixed MP3 playback with libmpg123
* Finally removed the dependency on libstdc++ with TDM GCC, reducing the size of the exe from 153kB to 87kB
This commit is contained in:
parent
f00c41f26c
commit
56f6487206
13 changed files with 63 additions and 53 deletions
|
@ -18,13 +18,13 @@ endif()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
# Base options
|
# Base options
|
||||||
set(CFLAGS "-Wall -Wextra -Wabi -pedantic -m32 -mmmx -msse -msse2 -msse3 -mfpmath=both -msahf -fvisibility=internal")
|
set(CFLAGS "-Wall -Wextra -Wabi -pedantic -m32 -mmmx -msse -msse2 -msse3 -mfpmath=both -msahf -malign-double -mpc32 -fvisibility=hidden")
|
||||||
set(LDFLAGS "-m32 -fvisibility=hidden -fvisibility-inlines-hidden")
|
set(LDFLAGS "-m32")
|
||||||
set(RCFLAGS "-F pe-i386")
|
set(RCFLAGS "-F pe-i386")
|
||||||
set(ASMFLAGS "-O3 -F win32")
|
set(ASMFLAGS "-O3 -F win32")
|
||||||
|
|
||||||
set(CFLAGS_LANG_C "-ansi")
|
set(CFLAGS_LANG_C "-ansi")
|
||||||
set(CFLAGS_LANG_CPP "-fno-exceptions -fno-rtti -fno-threadsafe-statics")
|
set(CFLAGS_LANG_CPP "-fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-threadsafe-statics")
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
|
@ -39,7 +39,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Size
|
# Size
|
||||||
set(CFLAGS_SIZE "${CFLAGS} -Os -g0 -fomit-frame-pointer -ffast-math -fmerge-all-constants -funsafe-loop-optimizations -fmerge-all-constants -fsched-pressure")
|
set(CFLAGS_SIZE "${CFLAGS} -Os -g0 -fomit-frame-pointer -ffast-math -fmerge-all-constants -funsafe-loop-optimizations -fmerge-all-constants -fsched-pressure -mstringop-strategy=rep_byte")
|
||||||
set(LDFLAGS_SIZE "${LDFLAGS} -s -fwhole-program")
|
set(LDFLAGS_SIZE "${LDFLAGS} -s -fwhole-program")
|
||||||
|
|
||||||
# Speed
|
# Speed
|
||||||
|
|
|
@ -5,11 +5,7 @@
|
||||||
ruby-specific header to provide mingw-friendly xaudio2 interfaces
|
ruby-specific header to provide mingw-friendly xaudio2 interfaces
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <unknwn.h>
|
||||||
#undef NULL
|
|
||||||
#define NULL 0
|
|
||||||
|
|
||||||
#include <guiddef.h>
|
|
||||||
#include <mmreg.h>
|
#include <mmreg.h>
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_XAudio2, 0xe21a7345, 0xeb21, 0x468e, 0xbe, 0x50, 0x80, 0x4d, 0xb9, 0x7c, 0xf7, 0x08);
|
DEFINE_GUID(CLSID_XAudio2, 0xe21a7345, 0xeb21, 0x468e, 0xbe, 0x50, 0x80, 0x4d, 0xb9, 0x7c, 0xf7, 0x08);
|
||||||
|
|
|
@ -23,6 +23,13 @@
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
Scene * CurrentScene;
|
Scene * CurrentScene;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
/* TDM GCC bonus feature; saves 66 kB in the binary :) */
|
||||||
|
/* */ void* operator new(unsigned size){return malloc(size);}
|
||||||
|
/* */ void operator delete(void *ptr){free(ptr);}
|
||||||
|
/* */ extern "C" void __cxa_pure_virtual(){}
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
@ -122,3 +129,5 @@ static void Shutdown()
|
||||||
System::Shutdown();
|
System::Shutdown();
|
||||||
Window::Shutdown();
|
Window::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,18 +19,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Compiler/platform constants
|
//Compiler/platform constants
|
||||||
#define WINVER 0x0502
|
#ifdef _WIN32
|
||||||
#define _WIN32_WINNT 0x0502
|
#define WINVER 0x0502
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _WIN32_WINNT 0x0502
|
||||||
|
#define NTDDI_VERSION 0x05010300
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
//Standard libraries
|
//Standard libraries
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#ifdef _WIN32
|
||||||
#undef NULL
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define NULL 0
|
#include <windows.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
//Codebase libraries
|
//Codebase libraries
|
||||||
#include "FileHandler.hpp"
|
#include "FileHandler.hpp"
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
namespace System {
|
namespace System {
|
||||||
|
|
||||||
HINSTANCE hInst = NULL;
|
HINSTANCE hInst = NULL;
|
||||||
HANDLE Process;
|
|
||||||
HANDLE ProcessHeap;
|
|
||||||
LARGE_INTEGER ClockFreq;
|
LARGE_INTEGER ClockFreq;
|
||||||
volatile float FramePeriod;
|
volatile float FramePeriod;
|
||||||
UserInput_t UserInput = UserInput_t();
|
UserInput_t UserInput = UserInput_t();
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace System {
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
extern HINSTANCE hInst;
|
extern HINSTANCE hInst;
|
||||||
extern HANDLE Process;
|
|
||||||
extern HANDLE ProcessHeap;
|
|
||||||
extern LARGE_INTEGER ClockFreq;
|
extern LARGE_INTEGER ClockFreq;
|
||||||
extern volatile float FramePeriod;
|
extern volatile float FramePeriod;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ set(FILEHANDLER_SOURCES
|
||||||
wav/read_wav.c
|
wav/read_wav.c
|
||||||
xa/read_xa.c
|
xa/read_xa.c
|
||||||
)
|
)
|
||||||
|
if(WIN32)
|
||||||
|
set(FILEHANDLER_SOURCES ${FILEHANDLER_SOURCES} resource.rc)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/Libraries/FileHandler)
|
include_directories(${CMAKE_SOURCE_DIR}/Libraries/FileHandler)
|
||||||
|
|
||||||
|
|
|
@ -21,38 +21,37 @@
|
||||||
namespace File {
|
namespace File {
|
||||||
|
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
unsigned FileSize = 0;
|
size_t FileSize = 0;
|
||||||
|
|
||||||
uint8_t * ReadFile(const char * Filename){
|
uint8_t * ReadFile(const char * Filename){
|
||||||
HANDLE hFile = CreateFile(Filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
FILE * hFile = fopen(Filename, "rb");
|
||||||
if(hFile == INVALID_HANDLE_VALUE){
|
if(hFile == NULL){
|
||||||
File::Error = (GetLastError() == ERROR_FILE_NOT_FOUND) ? FERR_NOT_FOUND : FERR_OPEN;
|
File::Error = FERR_OPEN;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSize = GetFileSize(hFile, NULL);
|
FileSize = File::GetFileSize(hFile);
|
||||||
if(FileSize == 0){
|
if(FileSize == 0){
|
||||||
CloseHandle(hFile);
|
fclose(hFile);
|
||||||
File::Error = FERR_BLANK;
|
File::Error = FERR_BLANK;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * InData = (uint8_t*) malloc(FileSize);
|
uint8_t * InData = (uint8_t*) malloc(FileSize);
|
||||||
if(InData == NULL){
|
if(InData == NULL){
|
||||||
CloseHandle(hFile);
|
fclose(hFile);
|
||||||
File::Error = FERR_MEMORY;
|
File::Error = FERR_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD bytestransferred;
|
size_t bytestransferred = fread(InData, 1, FileSize, hFile);
|
||||||
BOOL result = ::ReadFile(hFile, InData, FileSize, &bytestransferred, NULL);
|
if(bytestransferred != FileSize){
|
||||||
CloseHandle(hFile);
|
|
||||||
|
|
||||||
if(!result || bytestransferred != FileSize){
|
|
||||||
free(InData);
|
free(InData);
|
||||||
|
fclose(hFile);
|
||||||
File::Error = FERR_READ;
|
File::Error = FERR_READ;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InData;
|
return InData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory.h>
|
|
||||||
#ifndef NOWINDOWS
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define fhexport __declspec(dllexport)
|
#ifdef WIN32
|
||||||
|
#define fhexport __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define fhexport __attribute__((visibility ("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Asset_t {
|
struct Asset_t {
|
||||||
uint32_t Group;
|
uint32_t Group;
|
||||||
|
@ -68,6 +68,13 @@ struct Sound_t {
|
||||||
|
|
||||||
namespace File {
|
namespace File {
|
||||||
|
|
||||||
|
inline unsigned GetFileSize(FILE * hFile){
|
||||||
|
fseek(hFile, 0, SEEK_END);
|
||||||
|
unsigned FileSize = ftell(hFile);
|
||||||
|
fseek(hFile, 0, SEEK_SET);
|
||||||
|
return FileSize;
|
||||||
|
}
|
||||||
|
|
||||||
fhexport extern int Error;
|
fhexport extern int Error;
|
||||||
fhexport extern size_t FileSize;
|
fhexport extern size_t FileSize;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NOWINDOWS
|
|
||||||
#include "FileHandler.hpp"
|
#include "FileHandler.hpp"
|
||||||
#include <setjmp.h> //Used by libpng
|
#include <setjmp.h> //Used by libpng
|
||||||
#include "bmp/read_bmp.h"
|
#include "bmp/read_bmp.h"
|
||||||
|
|
|
@ -18,21 +18,9 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
#include <stdint.h>
|
|
||||||
#else
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef signed long int32_t;
|
|
||||||
typedef unsigned long uint32_t;
|
|
||||||
typedef unsigned int uintptr_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libfar.h"
|
#include "libfar.h"
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,4 @@
|
||||||
#define VERSION_B 0
|
#define VERSION_B 0
|
||||||
#define VERSION_C 1
|
#define VERSION_C 1
|
||||||
#define VERSION_STR "1.0.1"
|
#define VERSION_STR "1.0.1"
|
||||||
/* You should fill the revision in if you're compiling from the trunk */
|
|
||||||
#define REVISION 0
|
#define REVISION 0
|
|
@ -1,4 +1,12 @@
|
||||||
#include "config.h"
|
/* Name of package */
|
||||||
|
#define PACKAGE "libvitaboy"
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION_A 1
|
||||||
|
#define VERSION_B 0
|
||||||
|
#define VERSION_C 1
|
||||||
|
#define VERSION_STR "1.0.1"
|
||||||
|
#define REVISION 0
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION VERSION_A,VERSION_B,VERSION_C,REVISION
|
FILEVERSION VERSION_A,VERSION_B,VERSION_C,REVISION
|
||||||
|
|
Loading…
Add table
Reference in a new issue