* 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:
Fatbag 2012-06-28 07:00:45 -05:00
parent f00c41f26c
commit 56f6487206
13 changed files with 63 additions and 53 deletions

View file

@ -18,13 +18,13 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Base options
set(CFLAGS "-Wall -Wextra -Wabi -pedantic -m32 -mmmx -msse -msse2 -msse3 -mfpmath=both -msahf -fvisibility=internal")
set(LDFLAGS "-m32 -fvisibility=hidden -fvisibility-inlines-hidden")
set(CFLAGS "-Wall -Wextra -Wabi -pedantic -m32 -mmmx -msse -msse2 -msse3 -mfpmath=both -msahf -malign-double -mpc32 -fvisibility=hidden")
set(LDFLAGS "-m32")
set(RCFLAGS "-F pe-i386")
set(ASMFLAGS "-O3 -F win32")
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()
# 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")
# Speed

View file

@ -5,11 +5,7 @@
ruby-specific header to provide mingw-friendly xaudio2 interfaces
*/
#include <windows.h>
#undef NULL
#define NULL 0
#include <guiddef.h>
#include <unknwn.h>
#include <mmreg.h>
DEFINE_GUID(CLSID_XAudio2, 0xe21a7345, 0xeb21, 0x468e, 0xbe, 0x50, 0x80, 0x4d, 0xb9, 0x7c, 0xf7, 0x08);

View file

@ -23,6 +23,13 @@
static void Shutdown();
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 result;
@ -121,4 +128,6 @@ static void Shutdown()
Graphics::Shutdown();
System::Shutdown();
Window::Shutdown();
}
}
#endif

View file

@ -19,18 +19,24 @@
*/
//Compiler/platform constants
#define WINVER 0x0502
#define _WIN32_WINNT 0x0502
#define _CRT_SECURE_NO_WARNINGS
#ifdef _WIN32
#define WINVER 0x0502
#define _WIN32_WINNT 0x0502
#define NTDDI_VERSION 0x05010300
#define _CRT_SECURE_NO_WARNINGS
#endif
//Standard libraries
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#undef NULL
#define NULL 0
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef NULL
#define NULL 0
#endif
//Codebase libraries
#include "FileHandler.hpp"

View file

@ -23,8 +23,6 @@
namespace System {
HINSTANCE hInst = NULL;
HANDLE Process;
HANDLE ProcessHeap;
LARGE_INTEGER ClockFreq;
volatile float FramePeriod;
UserInput_t UserInput = UserInput_t();

View file

@ -23,8 +23,6 @@ namespace System {
void Shutdown();
extern HINSTANCE hInst;
extern HANDLE Process;
extern HANDLE ProcessHeap;
extern LARGE_INTEGER ClockFreq;
extern volatile float FramePeriod;

View file

@ -25,6 +25,9 @@ set(FILEHANDLER_SOURCES
wav/read_wav.c
xa/read_xa.c
)
if(WIN32)
set(FILEHANDLER_SOURCES ${FILEHANDLER_SOURCES} resource.rc)
endif()
include_directories(${CMAKE_SOURCE_DIR}/Libraries/FileHandler)

View file

@ -21,38 +21,37 @@
namespace File {
int Error = 0;
unsigned FileSize = 0;
size_t FileSize = 0;
uint8_t * ReadFile(const char * Filename){
HANDLE hFile = CreateFile(Filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if(hFile == INVALID_HANDLE_VALUE){
File::Error = (GetLastError() == ERROR_FILE_NOT_FOUND) ? FERR_NOT_FOUND : FERR_OPEN;
FILE * hFile = fopen(Filename, "rb");
if(hFile == NULL){
File::Error = FERR_OPEN;
return NULL;
}
FileSize = GetFileSize(hFile, NULL);
FileSize = File::GetFileSize(hFile);
if(FileSize == 0){
CloseHandle(hFile);
fclose(hFile);
File::Error = FERR_BLANK;
return NULL;
}
uint8_t * InData = (uint8_t*) malloc(FileSize);
if(InData == NULL){
CloseHandle(hFile);
fclose(hFile);
File::Error = FERR_MEMORY;
return NULL;
}
DWORD bytestransferred;
BOOL result = ::ReadFile(hFile, InData, FileSize, &bytestransferred, NULL);
CloseHandle(hFile);
if(!result || bytestransferred != FileSize){
size_t bytestransferred = fread(InData, 1, FileSize, hFile);
if(bytestransferred != FileSize){
free(InData);
fclose(hFile);
File::Error = FERR_READ;
return NULL;
}
return InData;
}

View file

@ -24,12 +24,12 @@
#include <stddef.h>
#include <stdio.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 {
uint32_t Group;
@ -68,6 +68,13 @@ struct Sound_t {
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 size_t FileSize;

View file

@ -16,7 +16,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define NOWINDOWS
#include "FileHandler.hpp"
#include <setjmp.h> //Used by libpng
#include "bmp/read_bmp.h"

View file

@ -18,21 +18,9 @@
#include "config.h"
#include <windows.h>
#include <stdlib.h>
#include <string.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 <stdint.h>
#include "libfar.h"

View file

@ -8,5 +8,4 @@
#define VERSION_B 0
#define VERSION_C 1
#define VERSION_STR "1.0.1"
/* You should fill the revision in if you're compiling from the trunk */
#define REVISION 0

View file

@ -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
FILEVERSION VERSION_A,VERSION_B,VERSION_C,REVISION