Skip to content

Instantly share code, notes, and snippets.

@inactive123
Created October 12, 2011 00:01
Show Gist options
  • Save inactive123/1279836 to your computer and use it in GitHub Desktop.
Save inactive123/1279836 to your computer and use it in GitHub Desktop.
Vendetta fix - FBA PS3
diff --git a/Makefile b/Makefile
index b9f7e0f..8e876df 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,9 @@
+CELL_DEBUG_CONSOLE = 0
+CELL_DEBUG_FPS = 0
+CELL_DEBUG_LOGGER = 0
+CELL_DEBUG_MEMORY = 0
+MULTIMAN_SUPPORT = 0
+
CELL_BUILD_TOOLS = GCC
CELL_SDK ?= /usr/local/cell
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
@@ -180,10 +186,6 @@ PPU_SRCS += $(BURN_DIR)/cps3/cps3run.cpp $(BURN_DIR)/cps3/cps3sn
PPU_TARGET = bin/fbanext-ps3.ppu.elf
-CELL_DEBUG_CONSOLE = 0
-CELL_DEBUG_LOGGER = 0
-CELL_DEBUG_MEMORY = 0
-MULTIMAN_SUPPORT = 0
ifeq ($(CELL_DEBUG_CONSOLE),1)
PPU_CFLAGS += -DCELL_DEBUG_CONSOLE
diff --git a/src/burn/burn.cpp b/src/burn/burn.cpp
index d615e88..a9dc0ff 100644
--- a/src/burn/burn.cpp
+++ b/src/burn/burn.cpp
@@ -630,6 +630,7 @@ extern "C" int BurnDrvExit()
}
// Do one frame of game emulation
+#ifndef SN_TARGET_PS3
extern "C" int BurnDrvFrame()
{
#ifndef NO_CHEATS
@@ -646,6 +647,7 @@ extern "C" int BurnDrvFrame()
return pDriver[nBurnDrvSelect]->Frame(); // Forward to drivers function
}
+#endif
// Force redraw of the screen
extern "C" int BurnDrvRedraw()
diff --git a/src/burner/PS3/drv.cpp b/src/burner/PS3/drv.cpp
index 7c0dd17..d6d9b69 100644
--- a/src/burner/PS3/drv.cpp
+++ b/src/burner/PS3/drv.cpp
@@ -61,22 +61,14 @@ static int __cdecl DrvLoadRom(unsigned char* Dest, int* pnWrote, int i)
return nRet;
}
-//#define NEED_MEDIA_REINIT
// no need to reinit media when init a driver, modified by regret
int BurnerDrvInit(int nDrvNum, bool bRestore)
{
BurnerDrvExit(); // Make sure exited
-#ifdef NEED_MEDIA_REINIT
- mediaExit();
-#endif
nBurnDrvSelect = nDrvNum; // Set the driver number
-#ifdef NEED_MEDIA_REINIT
- mediaInit();
-#endif
- mediaInit();
// Define nMaxPlayers early; GameInpInit() needs it (normally defined in DoLibInit()).
nMaxPlayers = BurnDrvGetMaxPlayers();
@@ -114,6 +106,7 @@ int BurnerDrvInit(int nDrvNum, bool bRestore)
BurnExtLoadRom = DrvLoadRom;
bDrvOkay = 1; // Okay to use all BurnDrv functions
+ mediaInit();
bSaveRAM = false;
if (bRestore)
diff --git a/src/burner/PS3/main.cpp b/src/burner/PS3/main.cpp
index 21d8670..770e72e 100644
--- a/src/burner/PS3/main.cpp
+++ b/src/burner/PS3/main.cpp
@@ -15,7 +15,6 @@
#include "cellframework2/input/pad_input.h"
#include "cellframework2/audio/stream.h"
#include "audio_driver.h"
-#include "string.h"
#ifdef CELL_DEBUG_CONSOLE
#include <cell/control_console.h>
#endif
@@ -31,7 +30,9 @@ uint32_t bBurnFirstStartup;
int GameStatus = MENU;
int nAppVirtualFps = 6000;
int is_running = 0;
+#ifdef CELL_DEBUG_FPS
bool bShowFPS = false;
+#endif
int custom_aspect_ratio_mode = 0;
cell_audio_handle_t audio_handle;
const struct cell_audio_driver *driver;
@@ -250,7 +251,8 @@ int main(int argc, char **argv)
if(!is_running)
GameStatus = PAUSE;
CalculateViewports();
- int audiosize = nAudSize;
+ uint32_t audiosize = nAudSize;
+ pBurnSoundOut = pAudNextSound;
if(pVidTransImage)
{
if(bVidRecalcPalette)
diff --git a/src/burner/PS3/media.cpp b/src/burner/PS3/media.cpp
index 9ff3e79..2687da4 100644
--- a/src/burner/PS3/media.cpp
+++ b/src/burner/PS3/media.cpp
@@ -16,9 +16,26 @@ int mediaInit(void)
nAppVirtualFps = nBurnFPS;
- if (!bAudOkay)
+ //HACK - Vendetta for some dumb reason will run at crippling speed if
+ //naudSampleRate is 48KHz - so we'll need to force CellAudio into
+ //using a 44KHz samplerate and then resample to 48KHz (because that's
+ //the only audio samplerate supported by the PS3)
+
+ uint32_t new_samplerate = 0; // our new samplerate - reverts to default samplerate if hack is not applied
+
+ const char * parent_rom = BurnDrvGetTextA(DRV_PARENT);
+ char * rom_filename;
+ BurnDrvGetArchiveName(&rom_filename, 0);
+ int ret = strcmp(parent_rom,"vendetta");
+ int ret2 = strcmp(rom_filename,"vendetta");
+ if (ret == 0 || ret2 == 0)
+ new_samplerate = 44100;
+ else
+ new_samplerate = 48010;
+
+ if (!bAudOkay || new_samplerate != nAudSampleRate)
{
- audio_init(); // Init Sound (not critical if it fails)
+ audio_init(new_samplerate); // Init Sound (not critical if it fails)
}
// Assume no sound
diff --git a/src/interface/PS3/audio_driver.cpp b/src/interface/PS3/audio_driver.cpp
index 2f81d22..3ba472d 100644
--- a/src/interface/PS3/audio_driver.cpp
+++ b/src/interface/PS3/audio_driver.cpp
@@ -7,10 +7,10 @@
extern cell_audio_handle_t audio_handle;
extern const struct cell_audio_driver * driver;
-int nAudSampleRate = 48010; // Sample rate
-int nAudSegLen = 0; // Segment length in samples (calculated from Rate/Fps)
-int nAudSize = 0;
-int nAudAllocSegLen = 0; // Allocated segment length in samples
+uint32_t nAudSampleRate = 48010; // Sample rate
+uint32_t nAudSegLen = 0; // Segment length in samples (calculated from Rate/Fps)
+uint32_t nAudSize = 0;
+uint32_t nAudAllocSegLen = 0; // Allocated segment length in samples
bool bAudOkay = false; // True if sound was inited okay
bool bAudPlaying = false;
int16_t * pAudNextSound = NULL; // The next sound seg we will add to the sample loop
@@ -36,8 +36,9 @@ int audio_exit()
return 0;
}
-int audio_init(void)
+int audio_init(uint32_t samplerate)
{
+ nAudSampleRate = samplerate;
nAudSegLen = (nAudSampleRate * 100 + (nAppVirtualFps >> 1)) / nAppVirtualFps;
nAudAllocSegLen = nAudSegLen << 2;
nAudSize = nAudSegLen << 1;
@@ -45,7 +46,7 @@ int audio_init(void)
cell_audio_params params;
memset(&params, 0, sizeof(params));
params.channels = 2;
- params.samplerate = 48000;
+ params.samplerate = samplerate;
params.buffer_size = 8192;
params.sample_cb = NULL;
params.userdata = NULL;
diff --git a/src/interface/PS3/audio_driver.h b/src/interface/PS3/audio_driver.h
index 6268c28..e4cd781 100644
--- a/src/interface/PS3/audio_driver.h
+++ b/src/interface/PS3/audio_driver.h
@@ -2,16 +2,14 @@
#define __AUDIO_DRIVER_H
extern bool bAudPlaying;
-extern int nAudAllocSegLen;
-extern int nAudSize;
+extern uint32_t nAudAllocSegLen;
+extern uint32_t nAudSize;
int audio_new(void);
int audio_exit(void);
-int audio_init(void);
+int audio_init(uint32_t samplerate);
-#define audio_check(audiosize) \
-pBurnSoundOut = pAudNextSound; \
-driver->write(audio_handle, pBurnSoundOut, audiosize);
+#define audio_check(audiosize) driver->write(audio_handle, pBurnSoundOut, audiosize);
#define audio_play() bAudPlaying = true;
#define audio_stop() !(bAudPlaying = false)
diff --git a/src/interface/PS3/vid_interface_ps3.cpp b/src/interface/PS3/vid_interface_ps3.cpp
index 4cd314a..135290d 100644
--- a/src/interface/PS3/vid_interface_ps3.cpp
+++ b/src/interface/PS3/vid_interface_ps3.cpp
@@ -22,8 +22,8 @@ int nVidImagePitch = 0; // Memory buffer pitch
bool bVidRecalcPalette;
bool bVidFBOEnabled; // FBO/Dual shader mode
unsigned int bVidScalingFactor = 1; // Scaling factor for use with FBO mode
-unsigned char* pVidImage = NULL; // Memory buffer
-unsigned char* pVidTransImage = NULL;
+uint8_t * pVidImage = NULL; // Memory buffer
+uint8_t * pVidTransImage = NULL;
static unsigned int* pVidTransPalette = NULL;
const int transPaletteSize = 65536;
int nXOffset = 0;
@@ -81,7 +81,7 @@ int VidInit()
nBurnBpp = BPP_16_SCREEN_RENDER_TEXTURE_BPP;
pVidTransPalette = (unsigned int*)memalign(128, transPaletteSize * sizeof(int));
- pVidTransImage = (unsigned char*)memalign(128, nVidImageWidth * nVidImageHeight * (nBurnBpp >> 1) * sizeof(short));
+ pVidTransImage = (uint8_t *)memalign(128, nVidImageWidth * nVidImageHeight * (nBurnBpp >> 1) * sizeof(short));
BurnHighCol = HighCol15;
@@ -123,7 +123,7 @@ int VidExit()
int VidFrame_RecalcPalette()
{
unsigned short* pSrc = (unsigned short*)pVidTransImage;
- unsigned char* pDest = pVidImage;
+ uint8_t * pDest = pVidImage;
uint64_t r = 0;
do{
@@ -149,7 +149,7 @@ int VidFrame_RecalcPalette()
int VidFrame_Recalc()
{
unsigned short* pSrc = (unsigned short*)pVidTransImage;
- unsigned char* pDest = pVidImage;
+ uint8_t * pDest = pVidImage;
pBurnDraw = pVidTransImage;
nBurnPitch = nVidImageWidth << 1;
diff --git a/src/interface/interface-ps3.h b/src/interface/interface-ps3.h
index 97a1d05..7265c94 100644
--- a/src/interface/interface-ps3.h
+++ b/src/interface/interface-ps3.h
@@ -17,10 +17,9 @@ int InputExit();
void InputMake(void);
// Audio
-extern int nAudSampleRate; // sample rate
-extern int nAudSegCount; // Segments in the pdsbLoop buffer
-extern int nAudSegLen; // Segment length in samples (calculated from sound rate/FPS)
-extern int nAudAllocSegLen; // Allocated segment length in samples
+extern uint32_t nAudSampleRate; // sample rate
+extern uint32_t nAudSegLen; // Segment length in samples (calculated from sound rate/FPS)
+extern uint32_t nAudAllocSegLen; // Allocated segment length in samples
extern int16_t * pAudNextSound; // The next sound segment we will add to the sample loop
extern bool bAudOkay; // True if sound was inited okay
extern unsigned char * pVidTransImage;
@@ -39,11 +38,9 @@ extern int nVidScrnAspectX;
extern int nVidScrnAspectY;
extern float vidScrnAspect;
extern bool autoVidScrnAspect;
-extern unsigned char* pVidImage;
+extern uint8_t * pVidImage;
extern int nVidImageWidth;
extern int nVidImageHeight;
-extern int nVidImageLeft;
-extern int nVidImageTop;
extern int nVidImagePitch;
extern uint32_t shaderindex;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment