mirror of
https://github.com/libretro/snes9xherd.git
synced 2024-11-26 17:20:49 +00:00
Make using other CPUs available for more than superfx.
This commit is contained in:
parent
0d34187679
commit
a4928dd49f
@ -76,7 +76,7 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
endif
|
||||
|
||||
#CC = gcc
|
||||
TARGET_NAME := snes9x2010
|
||||
TARGET_NAME := snes9xherd
|
||||
LIBM = -lm
|
||||
|
||||
ifeq ($(STATIC_LINKING),1)
|
||||
|
@ -12,8 +12,8 @@ SOURCES_C := $(CORE_DIR)/src/apu.c \
|
||||
$(CORE_DIR)/src/cpuexec.c \
|
||||
$(CORE_DIR)/src/dsp.c \
|
||||
$(CORE_DIR)/src/fxemu.c \
|
||||
$(CORE_DIR)/src/herdfx.c \
|
||||
$(CORE_DIR)/src/globals.c \
|
||||
$(CORE_DIR)/src/herd.c \
|
||||
$(CORE_DIR)/src/memmap.c \
|
||||
$(CORE_DIR)/src/obc1.c \
|
||||
$(CORE_DIR)/src/ppu.c \
|
||||
|
@ -1,4 +1,4 @@
|
||||
TARGET_NAME ?= snes9x2010
|
||||
TARGET_NAME ?= snes9xherd
|
||||
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
TARGET = $(TARGET_NAME)_libretro_$(platform).a
|
||||
|
@ -7,17 +7,17 @@
|
||||
<style type="text/css">
|
||||
<!-- ul { list-style-type:none } h2 { margin-top:3em } h3 { margin-top:2em } -->
|
||||
</style>
|
||||
<title>Porting Snes9x 2010</title>
|
||||
<title>Porting Snes9x 2010/herd</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="text-align:center">How to Port Snes9x 2010 to a New Platform</h1>
|
||||
<h1 style="text-align:center">How to Port Snes9x 2010/herd to a New Platform</h1>
|
||||
<div style="text-align:right">
|
||||
Version: 1.52<br>
|
||||
(c) Copyright 1998 Gary Henderson
|
||||
</div>
|
||||
<h2>Introduction</h2>
|
||||
<p>
|
||||
This is brief description of the steps to port Snes9x 2010 (a fork of Snes9x) to the new platform. It describes what code you have to write and what functions exist that you can make use of. It also gives some insights as to how Snes9x actually works, although that will be subject of another document yet to be written.
|
||||
This is brief description of the steps to port Snes9x 2010/herd (a fork of Snes9x) to the new platform. It describes what code you have to write and what functions exist that you can make use of. It also gives some insights as to how Snes9x actually works, although that will be subject of another document yet to be written.
|
||||
</p>
|
||||
<h2>System Requirements</h2>
|
||||
<p>
|
||||
|
@ -202,8 +202,8 @@
|
||||
#include "../src/cheats.h"
|
||||
#include "../src/display.h"
|
||||
|
||||
//use hosts 2nd-8th cpu if avalible as the super fx(snes in-cart gpu)
|
||||
#include "../src/herdfx.h"
|
||||
//use hosts 2nd-8th cpu if avalible
|
||||
#include "../src/herd.h"
|
||||
|
||||
#define LR_MAP_BUTTON(id, name) S9xMapButton((id), S9xGetCommandT((name)))
|
||||
#define MAKE_BUTTON(pad, btn) (((pad)<<4)|(btn))
|
||||
@ -666,8 +666,7 @@ void retro_init (void)
|
||||
|
||||
void retro_deinit(void)
|
||||
{
|
||||
if(Settings.SuperFX == TRUE)
|
||||
stopSFXcuttlefish();//multithreading
|
||||
stopthreads();
|
||||
S9xDeinitAPU();
|
||||
Deinit();
|
||||
S9xGraphicsDeinit();
|
||||
@ -1046,10 +1045,8 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(Settings.SuperFX == TRUE){
|
||||
if(startSFXcuttlefish())return FALSE;//multithreading
|
||||
}
|
||||
|
||||
if(initthreads())return FALSE;
|
||||
|
||||
check_variables();
|
||||
|
||||
|
@ -189,8 +189,8 @@
|
||||
#include "cheats.h"
|
||||
#include "snapshot.h"
|
||||
|
||||
//use hosts 2nd-8th cpu if avalible as the super fx(snes in-cart gpu)
|
||||
#include "herdfx.h"
|
||||
//use hosts 2nd-8th cpu if avalible
|
||||
#include "herd.h"
|
||||
|
||||
extern struct SLineData LineData[240];
|
||||
extern struct SLineMatrixData LineMatrixData[240];
|
||||
@ -972,7 +972,8 @@ void S9xDoHEventProcessing (void)
|
||||
if (Settings.SuperFX && !SuperFX.oneLineDone && CHECK_EXEC_SUPERFX())
|
||||
{
|
||||
//start superfx
|
||||
sfxrun_cuttle();
|
||||
queuefunction(S9xSuperFXExec);
|
||||
run_cuttle();
|
||||
usingsfx = TRUE;
|
||||
}
|
||||
|
||||
@ -1053,14 +1054,6 @@ void S9xDoHEventProcessing (void)
|
||||
|
||||
if (PPU.HTimerPosition == 0)
|
||||
S9xCheckMissingHTimerPosition();
|
||||
|
||||
/*
|
||||
if(usingsfx){
|
||||
//rejoin superfx
|
||||
waitforcuttler();
|
||||
usingsfx = FALSE;
|
||||
}
|
||||
*/
|
||||
|
||||
if (CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE) /* VBlank starts from V=225(240). */
|
||||
{
|
||||
@ -1148,7 +1141,7 @@ void S9xDoHEventProcessing (void)
|
||||
|
||||
if(usingsfx){
|
||||
//rejoin superfx
|
||||
sfxwait_cuttle();
|
||||
wait_cuttle();
|
||||
usingsfx = FALSE;
|
||||
}
|
||||
|
||||
|
56
src/herd.c
Normal file
56
src/herd.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <rthreads/rsemaphore.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include "snes9x.h"
|
||||
#include "fxemu.h"
|
||||
|
||||
static sthread_t* cuttlefishthread;
|
||||
static int keeprunning;
|
||||
static ssem_t* cuttle_start;
|
||||
static ssem_t* cuttle_done;
|
||||
|
||||
static void (*tasks[50])();
|
||||
static int remainingtasks;
|
||||
|
||||
static void cuttlelikeafish(void* unusedpointer){
|
||||
while(1){
|
||||
ssem_wait(cuttle_start);
|
||||
if(!keeprunning)break;
|
||||
while(remainingtasks >= 0){
|
||||
tasks[remainingtasks]();
|
||||
remainingtasks--;
|
||||
}
|
||||
ssem_signal(cuttle_done);
|
||||
}
|
||||
}
|
||||
|
||||
int initthreads(){
|
||||
remainingtasks = -1;
|
||||
keeprunning = 1;
|
||||
cuttlefishthread = sthread_create(cuttlelikeafish,NULL);
|
||||
cuttle_start = ssem_new(0);
|
||||
cuttle_done = ssem_new(0);
|
||||
return !cuttlefishthread || !cuttle_start || !cuttle_done;
|
||||
}
|
||||
|
||||
void stopthreads(){
|
||||
remainingtasks = -1;
|
||||
keeprunning = 0;
|
||||
ssem_signal(cuttle_start);
|
||||
sthread_join(cuttlefishthread);
|
||||
ssem_free(cuttle_start);
|
||||
ssem_free(cuttle_done);
|
||||
}
|
||||
|
||||
void run_cuttle(){
|
||||
ssem_signal(cuttle_start);
|
||||
}
|
||||
|
||||
void wait_cuttle(){
|
||||
ssem_wait(cuttle_done);
|
||||
}
|
||||
|
||||
void queuefunction(void (*func)(void)){
|
||||
remainingtasks++;
|
||||
tasks[remainingtasks] = func;
|
||||
}
|
8
src/herd.h
Normal file
8
src/herd.h
Normal file
@ -0,0 +1,8 @@
|
||||
int initthreads();
|
||||
void stopthreads();
|
||||
|
||||
void run_cuttle();
|
||||
void wait_cuttle();
|
||||
|
||||
//do NOT queue new funcions between run_cuttle and wait_cuttle,it may corrupt the task queue
|
||||
void queuefunction(void (*func)(void));
|
43
src/herdfx.c
43
src/herdfx.c
@ -1,43 +0,0 @@
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <rthreads/rsemaphore.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include "snes9x.h"
|
||||
#include "fxemu.h"
|
||||
|
||||
static sthread_t* cuttlefishthread;
|
||||
static int keeprunning;
|
||||
static ssem_t* cuttle_startframe;
|
||||
static ssem_t* cuttle_framedone;
|
||||
|
||||
static void superfxcuttlefish(void* unusedpointer){
|
||||
while(keeprunning){
|
||||
ssem_wait(cuttle_startframe);
|
||||
S9xSuperFXExec();
|
||||
ssem_signal(cuttle_framedone);
|
||||
}
|
||||
}
|
||||
|
||||
int startSFXcuttlefish(){
|
||||
//S9xSuperFXExec(); on seprate thread
|
||||
keeprunning = 1;
|
||||
cuttlefishthread = sthread_create(superfxcuttlefish,NULL);
|
||||
cuttle_startframe = ssem_new(0);
|
||||
cuttle_framedone = ssem_new(0);
|
||||
return !cuttlefishthread || !cuttle_startframe || !cuttle_framedone;
|
||||
}
|
||||
|
||||
void stopSFXcuttlefish(){
|
||||
keeprunning = 0;
|
||||
ssem_signal(cuttle_startframe);
|
||||
sthread_join(cuttlefishthread);
|
||||
ssem_free(cuttle_startframe);
|
||||
ssem_free(cuttle_framedone);
|
||||
}
|
||||
|
||||
void sfxrun_cuttle(){
|
||||
ssem_signal(cuttle_startframe);
|
||||
}
|
||||
|
||||
void sfxwait_cuttle(){
|
||||
ssem_wait(cuttle_framedone);
|
||||
}
|
10
src/herdfx.h
10
src/herdfx.h
@ -1,10 +0,0 @@
|
||||
#include <retro_inline.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <rthreads/rsemaphore.h>
|
||||
|
||||
int startSFXcuttlefish();
|
||||
void stopSFXcuttlefish();
|
||||
|
||||
void sfxrun_cuttle();
|
||||
void sfxwait_cuttle();
|
Loading…
Reference in New Issue
Block a user