mirror of
https://github.com/libretro/beetle-pcfx-libretro.git
synced 2024-11-27 02:11:04 +00:00
Initial PS3 compilation support
This commit is contained in:
parent
50b924e3fe
commit
5937957a01
51
Makefile
51
Makefile
@ -132,14 +132,16 @@ else ifeq ($(platform), ps3)
|
||||
CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
|
||||
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
|
||||
ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN
|
||||
OLD_GCC := 1
|
||||
else ifeq ($(platform), sncps3)
|
||||
TARGET := $(TARGET_NAME)_ps3.a
|
||||
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
|
||||
CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
|
||||
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
|
||||
ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN
|
||||
|
||||
CXXFLAGS += -Xc+=exceptions
|
||||
OLD_GCC := 1
|
||||
NO_GCC := 1
|
||||
else ifeq ($(platform), psl1ght)
|
||||
TARGET := $(TARGET_NAME)_psl1ght.a
|
||||
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
|
||||
@ -174,6 +176,7 @@ else
|
||||
TARGET := retro.dll
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
IS_X86 = 1
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
LDFLAGS += -static-libgcc -static-libstdc++ -lwinmm
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
@ -247,34 +250,50 @@ SOURCES_C := $(MPC_SRC) $(TREMOR_SRC) $(LIBRETRO_SOURCES_C) $(TRIO_SOURCES)
|
||||
|
||||
SOURCES := $(LIBRETRO_SOURCES) $(CORE_SOURCES) $(MEDNAFEN_SOURCES) $(HW_CPU_SOURCES) $(HW_MISC_SOURCES) $(HW_SOUND_SOURCES) $(HW_VIDEO_SOURCES)
|
||||
|
||||
WARNINGS := -Wall \
|
||||
-Wno-sign-compare \
|
||||
-Wno-unused-variable \
|
||||
-Wno-unused-function \
|
||||
-Wno-uninitialized \
|
||||
$(NEW_GCC_WARNING_FLAGS) \
|
||||
-Wno-strict-aliasing
|
||||
|
||||
EXTRA_GCC_FLAGS := -funroll-loops -ffast-math
|
||||
|
||||
ifeq ($(NO_GCC),1)
|
||||
EXTRA_GCC_FLAGS :=
|
||||
WARNINGS :=
|
||||
FLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
|
||||
OBJECTS := $(SOURCES:.cpp=.o) $(SOURCES_C:.c=.o)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
ifeq ($(DEBUG),0)
|
||||
FLAGS += -O3 -ffast-math -funroll-loops
|
||||
FLAGS += -O3 $(EXTRA_GCC_FLAGS)
|
||||
else
|
||||
FLAGS += -O0 -g
|
||||
endif
|
||||
|
||||
ifneq ($(OLD_GCC),1)
|
||||
NEW_GCC_WARNING_FLAGS += -Wno-narrowing \
|
||||
-Wno-unused-but-set-variable \
|
||||
-Wno-unused-result \
|
||||
-Wno-overflow
|
||||
NEW_GCC_FLAGS += -fno-strict-overflow
|
||||
endif
|
||||
|
||||
LDFLAGS += $(fpic) $(SHARED)
|
||||
FLAGS += -Wall $(fpic) -fno-strict-overflow
|
||||
FLAGS += $(fpic) $(NEW_GCC_FLAGS)
|
||||
FLAGS += -I. -Imednafen -Imednafen/include -Imednafen/intl $(CORE_INCDIR)
|
||||
|
||||
WARNINGS := -Wall \
|
||||
-Wno-narrowing \
|
||||
-Wno-unused-but-set-variable \
|
||||
-Wno-sign-compare \
|
||||
-Wno-unused-variable \
|
||||
-Wno-unused-function \
|
||||
-Wno-uninitialized \
|
||||
-Wno-unused-result \
|
||||
-Wno-strict-aliasing \
|
||||
-Wno-overflow
|
||||
FLAGS += $(ENDIANNESS_DEFINES) -DSIZEOF_DOUBLE=8 $(WARNINGS) -DMEDNAFEN_VERSION=\"0.9.26\" -DPACKAGE=\"mednafen\" -DMEDNAFEN_VERSION_NUMERIC=926 -DPSS_STYLE=1 -DMPC_FIXED_POINT $(CORE_DEFINE) -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -DNDEBUG -D_LOW_ACCURACY_ $(EXTRA_INCLUDES)
|
||||
|
||||
FLAGS += $(ENDIANNESS_DEFINES) -DSIZEOF_DOUBLE=8 $(WARNINGS) \
|
||||
-DMEDNAFEN_VERSION=\"0.9.26\" -DPACKAGE=\"mednafen\" -DMEDNAFEN_VERSION_NUMERIC=926 -DPSS_STYLE=1 -DMPC_FIXED_POINT -DARCH_X86 $(CORE_DEFINE) -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -DNDEBUG $(EXTRA_INCLUDES)
|
||||
ifeq ($(IS_X86), 1)
|
||||
FLAGS += -DARCH_X86
|
||||
endif
|
||||
|
||||
ifeq ($(CACHE_CD), 1)
|
||||
FLAGS += -D__LIBRETRO_CACHE_CD__
|
||||
@ -294,7 +313,7 @@ endif
|
||||
|
||||
|
||||
CXXFLAGS += $(FLAGS)
|
||||
CFLAGS += $(FLAGS) -std=gnu99
|
||||
CFLAGS += $(FLAGS)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
// Some really bad preprocessor abuse follows to handle platforms that don't have fseeko and ftello...and of course
|
||||
// for largefile support on Windows:
|
||||
|
||||
|
@ -116,20 +116,8 @@ void ErrnoHolder::SetErrno(int the_errno)
|
||||
local_strerror[0] = 0;
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_STRERROR_R
|
||||
const char *retv;
|
||||
|
||||
retv = srr_wrap(strerror_r(the_errno, local_strerror, 256), local_strerror);
|
||||
|
||||
if(retv != local_strerror)
|
||||
strncpy(local_strerror, retv, 255);
|
||||
|
||||
#else // No strerror_r :(
|
||||
|
||||
strncpy(local_strerror, strerror(the_errno), 255);
|
||||
|
||||
#endif
|
||||
|
||||
local_strerror[255] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -183,98 +183,3 @@ void _Huffman_MakeTree( huff_sym_t * sym, unsigned int num_symbols)
|
||||
|
||||
_Huffman_MakeCodes(sym, num_symbols);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
/**
|
||||
* Print the huffman tables
|
||||
* print_type = 0 => print the coding table
|
||||
* print_type = 1 => print the decoding table
|
||||
* print_type = 2 => print the full codes in symbols order
|
||||
* print_type = 3 => print the full codes in codes order
|
||||
* @param sym
|
||||
* @param num_symbols
|
||||
* @param print_type
|
||||
* @param offset
|
||||
*/
|
||||
void _Huffman_PrintCodes(huff_sym_t * sym, unsigned int num_symbols, int print_type, int offset)
|
||||
{
|
||||
unsigned int total_cnt = 0, total_size = 0, optim_size = 0, i;
|
||||
int packs[4];
|
||||
|
||||
switch( print_type ) {
|
||||
case 0 :
|
||||
qsort(sym, num_symbols, sizeof(huff_sym_t),
|
||||
(int (*)(const void *, const void *)) _Huffman_CompSym);
|
||||
printf("{\n ");
|
||||
for( i = 0; i < num_symbols; i++) {
|
||||
if (i != 0)
|
||||
printf(", ");
|
||||
printf("{%u, %u}", sym[i].Code, sym[i].Bits);
|
||||
}
|
||||
printf("\n}\n");
|
||||
break;
|
||||
case 1:
|
||||
qsort(sym, num_symbols, sizeof(huff_sym_t),
|
||||
(int (*)(const void *, const void *)) _Huffman_CompBits);
|
||||
printf("{\n ");
|
||||
for( i = num_symbols - 1; i >= 0; i--) {
|
||||
printf("{0x%.8x, %u, %i}", sym[i].Code << (32 - sym[i].Bits), sym[i].Bits, sym[i].Symbol - offset);
|
||||
if (i != 0)
|
||||
printf(", ");
|
||||
}
|
||||
printf("\n}\n");
|
||||
break;
|
||||
case 4:
|
||||
qsort(sym, num_symbols, sizeof(huff_sym_t),
|
||||
(int (*)(const void *, const void *)) _Huffman_CompBits);
|
||||
printf("{\n ");
|
||||
for( i = num_symbols - 1; i >= 0; i--) {
|
||||
int symbol = sym[i].Symbol;
|
||||
packs[3] = symbol / (offset * offset * offset);
|
||||
packs[2] = (symbol - packs[3] * offset * offset * offset) / (offset * offset);
|
||||
packs[1] = (symbol - (packs[3] * offset + packs[2]) * offset * offset) / offset;
|
||||
packs[0] = symbol - ((packs[3] * offset + packs[2]) * offset + packs[1] * offset);
|
||||
packs[0] -= offset >> 1;
|
||||
packs[1] -= offset >> 1;
|
||||
packs[2] -= offset >> 1;
|
||||
packs[3] -= offset >> 1;
|
||||
symbol = ((packs[3] & 15) << 12) | ((packs[2] & 15) << 8) | ((packs[1] & 15) << 4) | (packs[0] & 15);
|
||||
printf("{0x%.8x, %u, %i}", sym[i].Code << (32 - sym[i].Bits), sym[i].Bits, symbol);
|
||||
if (i != 0)
|
||||
printf(", ");
|
||||
}
|
||||
printf("\n}\n");
|
||||
break;
|
||||
default:
|
||||
if (print_type == 2)
|
||||
qsort(sym, num_symbols, sizeof(huff_sym_t),
|
||||
(int (*)(const void *, const void *)) _Huffman_CompSym);
|
||||
else
|
||||
qsort(sym, num_symbols, sizeof(huff_sym_t),
|
||||
(int (*)(const void *, const void *)) _Huffman_CompBits);
|
||||
|
||||
printf("Symbol Count Lenth Code\n");
|
||||
for( i = 0; i < num_symbols; i++) {
|
||||
int k = sym[i].Bits - 1;
|
||||
printf("%-10i %-10u %-10u ", sym[i].Symbol - offset, sym[i].Count, sym[i].Bits);
|
||||
for (; k >= 0 ; k--)
|
||||
printf("%u", (sym[i].Code >> k) & 1 );
|
||||
printf("\n");
|
||||
|
||||
total_cnt += sym[i].Count;
|
||||
total_size += sym[i].Count * sym[i].Bits;
|
||||
if (sym[i].Count != 0)
|
||||
optim_size += sym[i].Count * __builtin_log2(sym[i].Count);
|
||||
}
|
||||
optim_size = total_cnt * __builtin_log2(total_cnt) - optim_size;
|
||||
printf("\ncount : %u huff : %f bps ", total_cnt, (float)total_size / total_cnt);
|
||||
printf("opt : %f bps ", (float)optim_size / total_cnt);
|
||||
printf("loss : %f bps (%f %%)\n", (float)(total_size - optim_size) / total_cnt, (float)(total_size - optim_size) * 100 / optim_size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -43,7 +43,6 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef _PCE_H
|
||||
|
||||
#include "../mednafen-types.h"
|
||||
#include "../mednafen.h"
|
||||
#include "../state.h"
|
||||
#include "../general.h"
|
||||
#include "../memory.h"
|
||||
#include "mednafen-types.h"
|
||||
#include "mednafen.h"
|
||||
#include "state.h"
|
||||
#include "general.h"
|
||||
#include "mednafen-memory.h"
|
||||
|
||||
#define PCE_MASTER_CLOCK 21477272.727273
|
||||
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "../mempatcher.h"
|
||||
#include "../cputest/cputest.h"
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "../msvc_compat.h"
|
||||
#endif
|
||||
|
20
stubs.cpp
20
stubs.cpp
@ -5,6 +5,11 @@
|
||||
#include "mednafen/general.h"
|
||||
#include "mednafen/mednafen-driver.h"
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
#include <sys/timer.h>
|
||||
#include <ppu_intrinsics.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -22,7 +27,9 @@
|
||||
|
||||
void MDFND_Sleep(unsigned int time)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(__CELLOS_LV2__)
|
||||
sys_timer_usleep(time * 1000);
|
||||
#elif defined(_WIN32)
|
||||
Sleep(time);
|
||||
#else
|
||||
usleep(time * 1000);
|
||||
@ -94,7 +101,16 @@ uint32 MDFND_GetTime()
|
||||
static bool first = true;
|
||||
static uint32_t start_ms;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(__CELLOS_LV2__)
|
||||
uint64_t time = __mftb();
|
||||
uint32_t ms = (time - start_ms) / 1000;
|
||||
|
||||
if (first)
|
||||
{
|
||||
start_ms = ms;
|
||||
first = false;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
DWORD ms = timeGetTime();
|
||||
if (first)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user