Skip to content

Commit

Permalink
add ability to run DSP on separate thread
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Aug 29, 2018
1 parent 2064920 commit 686ec95
Show file tree
Hide file tree
Showing 16 changed files with 1,908 additions and 119 deletions.
81 changes: 41 additions & 40 deletions Makefile
@@ -1,40 +1,41 @@
DEBUG = 0
HAVE_CHD = 1
THREADED_DSP=0

ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
endif
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
endif
endif

# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
system_platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
system_platform = win
endif

TARGET_NAME := 4do
GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif

SPACE :=
Expand All @@ -52,8 +53,8 @@ ifneq (,$(findstring unix,$(platform)))

TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -lm -shared -Wl,--no-undefined -Wl,--version-script=link.T

SHARED := -lpthread -lm -shared -Wl,--no-undefined -Wl,--version-script=link.T
THREADED_DSP = 1

# Raspberry Pi
ifneq (,$(findstring rpi,$(platform)))
Expand All @@ -70,7 +71,7 @@ ifneq (,$(findstring unix,$(platform)))
CFLAGS = -mcpu=cortex-a53
endif

# ODROIDs
# ODROIDs
else ifneq (,$(findstring odroid,$(platform)))
CFLAGS += -fomit-frame-pointer -ffast-math -DARM -marm -mfloat-abi=hard

Expand Down Expand Up @@ -138,43 +139,43 @@ else ifeq ($(platform), qnx)
TARGET := $(TARGET_NAME)_libretro_$(platform).so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
CC = qcc -Vgcc_ntoarmv7le
CC = qcc -Vgcc_ntoarmv7le
else ifeq ($(platform), ps3)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
STATIC_LINKING = 1
FLAGS += -DMSB_FIRST -D__CELLOS_LV2__
OLD_GCC = 1
FLAGS += -DMSB_FIRST -D__CELLOS_LV2__
OLD_GCC = 1
else ifeq ($(platform), sncps3)
TARGET := $(TARGET_NAME)_libretro_ps3.a
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
STATIC_LINKING = 1
FLAGS += -DMSB_FIRST
NO_GCC = 1
FLAGS += -DMSB_FIRST
NO_GCC = 1

# PSP1
else ifeq ($(platform), psp1)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = psp-gcc$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
CC = psp-gcc$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
STATIC_LINKING = 1
FLAGS += -G0
FLAGS += -G0

# Vita
else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = arm-vita-eabi-gcc$(EXE_EXT)
AR = arm-vita-eabi-ar$(EXE_EXT)
CC = arm-vita-eabi-gcc$(EXE_EXT)
AR = arm-vita-eabi-ar$(EXE_EXT)
STATIC_LINKING = 1
FLAGS += -DVITA
FLAGS += -DVITA

# CTR (3DS)
else ifeq ($(platform), ctr)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
STATIC_LINKING = 1
FLAGS += -D_3DS

Expand All @@ -186,7 +187,7 @@ else ifeq ($(platform), switch)

# Emscripten
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
STATIC_LINKING = 1

# Windows MSVC 2003 Xbox 1
Expand All @@ -199,8 +200,8 @@ export INCLUDE := $(XDK)/xbox/include
export LIB := $(XDK)/xbox/lib
PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH)
PSS_STYLE :=2
CFLAGS += -D_XBOX -D_XBOX1
STATIC_LINKING=1
CFLAGS += -D_XBOX -D_XBOX1
STATIC_LINKING = 1
HAS_GCC := 0
# Windows MSVC 2010 Xbox 360
else ifeq ($(platform), xbox360_msvc2010)
Expand Down
7 changes: 6 additions & 1 deletion Makefile.common
Expand Up @@ -20,7 +20,8 @@ SOURCES_C := \
$(CORE_DIR)/retro_cdimage.c \
$(CORE_DIR)/lr_input.c \
$(CORE_DIR)/lr_input_crosshair.c \
$(CORE_DIR)/lr_input_descs.c
$(CORE_DIR)/lr_input_descs.c \
$(CORE_DIR)/lr_dsp.c

SOURCES_C += \
$(4DO_DIR)/freedo_3do.c \
Expand Down Expand Up @@ -68,6 +69,10 @@ FLAGS += \
-DHAVE_STDLIB_H \
-DHAVE_SYS_PARAM_H

ifeq ($(THREADED_DSP), 1)
FLAGS += -DTHREADED_DSP
endif

ifeq ($(HAVE_CHD), 1)
FLAGS += \
-DHAVE_CHD \
Expand Down
2 changes: 1 addition & 1 deletion libfreedo/freedo_3do.c
Expand Up @@ -136,7 +136,7 @@ freedo_3do_internal_frame(vdlp_frame_t *frame_,

freedo_quarz_push_cycles(cycles_);
if(freedo_quarz_queue_dsp())
io_interface(EXT_PUSH_SAMPLE,(void*)(uintptr_t)freedo_dsp_loop());
io_interface(EXT_DSP_TRIGGER,NULL);

if(freedo_quarz_queue_timer())
freedo_clio_timer_execute();
Expand Down
49 changes: 5 additions & 44 deletions libfreedo/freedo_core.h
Expand Up @@ -24,56 +24,17 @@ Felix Lazarev
#ifndef __3DO_SYSTEM_HEADER_DEFINITION
#define __3DO_SYSTEM_HEADER_DEFINITION

#include <stdint.h>
#include <boolean.h>

#include "extern_c.h"

#pragma pack(push,1)

struct BitmapCrop
{
int left;
int top;
int bottom;
int right;
};

struct GetFrameBitmapParams
{
struct VDLFrame* sourceFrame;
void* destinationBitmap;
int destinationBitmapWidthPixels;
struct BitmapCrop* bitmapCrop;
int copyWidthPixels;
int copyHeightPixels;
bool addBlackBorder;
bool copyPointlessAlphaByte;
bool allowCrop;
int resultingWidth;
int resultingHeight;
};

#pragma pack(pop)
#include <stdint.h>
#include <boolean.h>

#define EXT_READ_ROMS 1
#define EXT_SWAPFRAME 5 //frame swap (in mutlithreaded) or frame draw(single treaded)
#define EXT_PUSH_SAMPLE 6 //sends sample to the buffer
#define EXT_KPRINT 9
#define EXT_DEBUG_PRINT 10
#define EXT_FRAMETRIGGER_MT 12 //multitasking
#define EXT_READ2048 14 //for XBUS Plugin
#define EXT_GET_DISC_SIZE 15
#define EXT_ON_SECTOR 16
#define EXT_ARM_SYNC 17
#define EXT_SWAPFRAME 1 /* frame should be read */
#define EXT_DSP_TRIGGER 2 /* DSP should be triggered
(freedo_dsp_loop) */

typedef void* (*freedo_ext_interface_t)(int, void*);

#define FDP_FREEDOCORE_VERSION 0
#define FDP_DO_FRAME_MT 4 //multitasking

#define BIOS_ANVIL (0x40)

EXTERN_C_BEGIN

extern int HIRESMODE;
Expand Down

0 comments on commit 686ec95

Please sign in to comment.