Get rid of Decode_XA. A few minor changes.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1235 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-22 00:35:09 +00:00
parent b1fd826954
commit 8e3d3080c0
10 changed files with 28 additions and 376 deletions

View File

@ -88,6 +88,9 @@ u32 cdReadTime;// = ((PSXCLK / 75) / BIAS);
#define CDR_INT(eCycle) PSX_INT(IopEvt_Cdrom, eCycle)
#define CDREAD_INT(eCycle) PSX_INT(IopEvt_CdromRead, eCycle)
static void AddIrqQueue(u8 irq, u32 ecycle);
static __forceinline void StartReading(u32 type) {
cdr.Reading = type;
cdr.FirstSector = 1;

View File

@ -20,9 +20,23 @@
#define __CDROM_H__
#include "IopCommon.h"
#include "Decode_XA.h"
#include "PS2Edefs.h"
// Not used.
typedef struct {
s32 y0, y1;
} ADPCM_Decode_t;
// Not used.
typedef struct {
s32 freq;
s32 nbits;
s32 stereo;
s32 nsamples;
ADPCM_Decode_t left, right;
s16 pcm[16384];
} xa_decode_t;
struct cdrStruct
{
u8 OCUP;
@ -72,8 +86,6 @@ struct cdrStruct
char Unused[4087];
};
void AddIrqQueue(u8 irq, u32 ecycle);
extern cdrStruct cdr;
void cdrReset();

View File

@ -1,322 +0,0 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
//============================================
//=== Audio XA decoding
//=== Kazzuya
//============================================
//=== Modified by linuzappz
//============================================
#include <stdio.h>
#include "Decode_XA.h"
#ifdef __WIN32__
#pragma warning(disable:4244)
#endif
#define NOT(_X_) (!(_X_))
#define CLAMP(_X_,_MI_,_MA_) {if(_X_<_MI_)_X_=_MI_;if(_X_>_MA_)_X_=_MA_;}
//============================================
//=== ADPCM DECODING ROUTINES
//============================================
static double K0[4] = {
0.0,
0.9375,
1.796875,
1.53125
};
static double K1[4] = {
0.0,
0.0,
-0.8125,
-0.859375
};
#define BLKSIZ 28 /* block size (32 - 4 nibbles) */
//===========================================
void ADPCM_InitDecode( ADPCM_Decode_t *decp )
{
decp->y0 = 0;
decp->y1 = 0;
}
//===========================================
#define SH 4
#define SHC 10
#define IK0(fid) ((int)((-K0[fid]) * (1<<SHC)))
#define IK1(fid) ((int)((-K1[fid]) * (1<<SHC)))
void ADPCM_DecodeBlock16( ADPCM_Decode_t *decp, u8 filter_range, const void *vblockp, short *destp, int inc ) {
int i;
int range, filterid;
long fy0, fy1;
const u16 *blockp;
blockp = (const u16*)vblockp;
filterid = (filter_range >> 4) & 0x0f;
range = (filter_range >> 0) & 0x0f;
fy0 = decp->y0;
fy1 = decp->y1;
for (i = BLKSIZ/4; i; --i) {
s32 y;
s32 x0, x1, x2, x3;
y = *blockp++;
x3 = (s16)( y & 0xf000) >> range; x3 <<= SH;
x2 = (s16)((y << 4) & 0xf000) >> range; x2 <<= SH;
x1 = (s16)((y << 8) & 0xf000) >> range; x1 <<= SH;
x0 = (s16)((y << 12) & 0xf000) >> range; x0 <<= SH;
x0 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x0;
x1 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x1;
x2 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x2;
x3 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x3;
CLAMP( x0, -32768<<SH, 32767<<SH ); *destp = x0 >> SH; destp += inc;
CLAMP( x1, -32768<<SH, 32767<<SH ); *destp = x1 >> SH; destp += inc;
CLAMP( x2, -32768<<SH, 32767<<SH ); *destp = x2 >> SH; destp += inc;
CLAMP( x3, -32768<<SH, 32767<<SH ); *destp = x3 >> SH; destp += inc;
}
decp->y0 = fy0;
decp->y1 = fy1;
}
static int headtable[4] = {0,2,8,10};
//===========================================
static void xa_decode_data( xa_decode_t *xdp, u8 *srcp ) {
const u8 *sound_groupsp;
const u8 *sound_datap, *sound_datap2;
s32 i, j, k, nbits;
u16 data[4096], *datap;
s16 *destp;
destp = xdp->pcm;
nbits = xdp->nbits == 4 ? 4 : 2;
if (xdp->stereo) { // stereo
for (j=0; j < 18; j++) {
sound_groupsp = srcp + j * 128; // sound groups header
sound_datap = sound_groupsp + 16; // sound data just after the header
for (i=0; i < nbits; i++) {
datap = data;
sound_datap2 = sound_datap + i;
if ((xdp->nbits == 8) && (xdp->freq == 37800)) { // level A
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
}
else { // level B/C
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] & 0x0f) |
((u16)(sound_datap2[ 4] & 0x0f) << 4) |
((u16)(sound_datap2[ 8] & 0x0f) << 8) |
((u16)(sound_datap2[12] & 0x0f) << 12);
}
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+0], data,
destp+0, 2 );
datap = data;
sound_datap2 = sound_datap + i;
if ((xdp->nbits == 8) && (xdp->freq == 37800)) { // level A
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
}
else { // level B/C
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] >> 4) |
((u16)(sound_datap2[ 4] >> 4) << 4) |
((u16)(sound_datap2[ 8] >> 4) << 8) |
((u16)(sound_datap2[12] >> 4) << 12);
}
}
ADPCM_DecodeBlock16( &xdp->right, sound_groupsp[headtable[i]+1], data,
destp+1, 2 );
destp += 28*2;
}
}
}
else { // mono
for (j=0; j < 18; j++) {
sound_groupsp = srcp + j * 128; // sound groups header
sound_datap = sound_groupsp + 16; // sound data just after the header
for (i=0; i < nbits; i++) {
datap = data;
sound_datap2 = sound_datap + i;
if ((xdp->nbits == 8) && (xdp->freq == 37800)) { // level A
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
}
else { // level B/C
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] & 0x0f) |
((u16)(sound_datap2[ 4] & 0x0f) << 4) |
((u16)(sound_datap2[ 8] & 0x0f) << 8) |
((u16)(sound_datap2[12] & 0x0f) << 12);
}
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+0], data,
destp, 1 );
destp += 28;
datap = data;
sound_datap2 = sound_datap + i;
if ((xdp->nbits == 8) && (xdp->freq == 37800)) { // level A
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
}
else { // level B/C
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] >> 4) |
((u16)(sound_datap2[ 4] >> 4) << 4) |
((u16)(sound_datap2[ 8] >> 4) << 8) |
((u16)(sound_datap2[12] >> 4) << 12);
}
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+1], data,
destp, 1 );
destp += 28;
}
}
}
}
//============================================
//=== XA SPECIFIC ROUTINES
//============================================
typedef struct {
u8 filenum;
u8 channum;
u8 submode;
u8 coding;
u8 filenum2;
u8 channum2;
u8 submode2;
u8 coding2;
} xa_subheader_t;
#define SUB_SUB_EOF (1<<7) // end of file
#define SUB_SUB_RT (1<<6) // real-time sector
#define SUB_SUB_FORM (1<<5) // 0 form1 1 form2
#define SUB_SUB_TRIGGER (1<<4) // used for interrupt
#define SUB_SUB_DATA (1<<3) // contains data
#define SUB_SUB_AUDIO (1<<2) // contains audio
#define SUB_SUB_VIDEO (1<<1) // contains video
#define SUB_SUB_EOR (1<<0) // end of record
#define AUDIO_CODING_GET_STEREO(_X_) ( (_X_) & 3)
#define AUDIO_CODING_GET_FREQ(_X_) (((_X_) >> 2) & 3)
#define AUDIO_CODING_GET_BPS(_X_) (((_X_) >> 4) & 3)
#define AUDIO_CODING_GET_EMPHASIS(_X_) (((_X_) >> 6) & 1)
#define SUB_UNKNOWN 0
#define SUB_VIDEO 1
#define SUB_AUDIO 2
//============================================
static s32 parse_xa_audio_sector( xa_decode_t *xdp,
xa_subheader_t *subheadp,
u8*sectorp,
s32 is_first_sector ) {
if ( is_first_sector ) {
switch ( AUDIO_CODING_GET_FREQ(subheadp->coding) ) {
case 0: xdp->freq = 37800; break;
case 1: xdp->freq = 18900; break;
default: xdp->freq = 0; break;
}
switch ( AUDIO_CODING_GET_BPS(subheadp->coding) ) {
case 0: xdp->nbits = 4; break;
case 1: xdp->nbits = 8; break;
default: xdp->nbits = 0; break;
}
switch ( AUDIO_CODING_GET_STEREO(subheadp->coding) ) {
case 0: xdp->stereo = 0; break;
case 1: xdp->stereo = 1; break;
default: xdp->stereo = 0; break;
}
if ( xdp->freq == 0 )
return -1;
ADPCM_InitDecode( &xdp->left );
ADPCM_InitDecode( &xdp->right );
xdp->nsamples = 18 * 28 * 8;
if (xdp->stereo == 1) xdp->nsamples /= 2;
}
xa_decode_data( xdp, sectorp );
return 0;
}
//================================================================
//=== THIS IS WHAT YOU HAVE TO CALL
//=== xdp - structure were all important data are returned
//=== sectorp - data in input
//=== pcmp - data in output
//=== is_first_sector - 1 if it's the 1st sector of the stream
//=== - 0 for any other successive sector
//=== return -1 if error
//================================================================
s32 xa_decode_sector( xa_decode_t *xdp,
u8 *sectorp, s32 is_first_sector ) {
if (parse_xa_audio_sector(xdp, (xa_subheader_t *)sectorp, sectorp + sizeof(xa_subheader_t), is_first_sector))
return -1;
return 0;
}
/* EXAMPLE:
"nsamples" is the number of 16 bit samples
every sample is 2 bytes in mono and 4 bytes in stereo
xa_decode_t xa;
sectorp = read_first_sector();
xa_decode_sector( &xa, sectorp, 1 );
play_wave( xa.pcm, xa.freq, xa.nsamples );
while ( --n_sectors )
{
sectorp = read_next_sector();
xa_decode_sector( &xa, sectorp, 0 );
play_wave( xa.pcm, xa.freq, xa.nsamples );
}
*/

View File

@ -1,45 +0,0 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
//============================================
//=== Audio XA decoding
//=== Kazzuya
//============================================
#ifndef DECODEXA_H
#define DECODEXA_H
#include "PrecompiledHeader.h"
typedef struct {
s32 y0, y1;
} ADPCM_Decode_t;
typedef struct {
s32 freq;
s32 nbits;
s32 stereo;
s32 nsamples;
ADPCM_Decode_t left, right;
s16 pcm[16384];
} xa_decode_t;
s32 xa_decode_sector( xa_decode_t *xdp,
u8*sectorp,
s32 is_first_sector );
#endif

View File

@ -181,7 +181,7 @@ __forceinline void PMFHL_CLAMP(u16 dst, u16 src)
{
if ((int)src > (int)0x00007fff)
dst = 0x7fff;
else if ((int)src < (int)0xffff8000)
else if ((int)src < (int)0xffff8000) // Ints only go up to 0x7FFFFFFF. Something's not right here. --arcum42
dst = 0x8000;
else
dst = (u16)src;

View File

@ -15,7 +15,7 @@ INCLUDES = -I$(x86_dir) -I$(cdvd_dir) -I$(common_dir) -I$(third_dir)
noinst_LIBRARIES = libpcsx2.a
libpcsx2_a_SOURCES = \
AlignedMalloc.cpp Decode_XA.cpp HwRead.cpp MTGS.cpp R3000AInterpreter.cpp Sio.cpp VUflags.cpp \
AlignedMalloc.cpp HwRead.cpp MTGS.cpp R3000AInterpreter.cpp Sio.cpp VUflags.cpp \
Dump.cpp HwWrite.cpp R3000AOpcodeTables.cpp SourceLog.cpp VUmicroMem.cpp \
Elfheader.cpp Interpreter.cpp Memory.cpp R5900.cpp Stats.cpp VUops.cpp \
FPU.cpp IopBios.cpp MemoryCard.cpp R5900OpcodeImpl.cpp System.cpp Vif.cpp \
@ -34,7 +34,7 @@ ps2/Iop/IopHwRead.cpp ps2/Iop/IopHwWrite.cpp ps2/Iop/IopHw_Internal.h
libpcsx2_a_SOURCES += \
Common.h HashMap.h IopDma.h MemoryCard.h PrecompiledHeader.h SafeArray.h StringUtils.h Vif.h \
Counters.h HostGui.h IopHw.h MemoryTypes.h R3000A.h SamplProf.h System.h VifDma.h \
Decode_XA.h Hw.h IopMem.h Misc.h R5900.h SaveState.h Threading.h cheatscpp.h \
Hw.h IopMem.h Misc.h R5900.h SaveState.h Threading.h cheatscpp.h \
Dump.h IopBios.h IopSio2.h NakedAsm.h R5900Exceptions.h Sif.h VU.h vtlb.h \
COP0.h Elfheader.h IopBios2.h Mdec.h Patch.h R5900OpcodeTables.h Sifcmd.h VUflags.h \
Cache.h Exceptions.h IopCommon.h MemcpyFast.h Paths.h Sio.h Sio_internal.h VUmicro.h \

View File

@ -55,7 +55,7 @@ struct DECI2_DBGP_BRK{
extern DECI2_DBGP_BRK ebrk[32], ibrk[32];
extern s32 ebrk_count, ibrk_count;
extern volatile s32 runStatus;
extern volatile long runStatus;
extern s32 runCode, runCount;
extern Threading::Semaphore* runEvent;

View File

@ -90,7 +90,6 @@ void LoadBranchState();
void recompileNextInstruction(int delayslot);
void SetBranchReg( u32 reg );
void SetBranchImm( u32 imm );
u32 eeScaleBlockCycles();
void iFlushCall(int flushtype);
void recBranchCall( void (*func)() );

View File

@ -111,6 +111,7 @@ static u32 dumplog = 0;
static void iBranchTest(u32 newpc = 0xffffffff, bool noDispatch=false);
static void ClearRecLUT(BASEBLOCK* base, int count);
static u32 eeScaleBlockCycles();
#ifdef PCSX2_VM_COISSUE
static u8 _eeLoadWritesRs(u32 tempcode)

View File

@ -119,7 +119,11 @@ __emitinline void Internal::xJccKnownTarget( JccComparisonType comparison, const
// if the following assert fails it means we accidentally used slideForard on a backward
// jump (which is an invalid operation since there's nothing to slide forward).
if( slideForward ) jASSUME( displacement8 >= 0 );
if( slideForward )
{
// jASSUME has an else statement in it that would be abiguous without the brackets.
jASSUME( displacement8 >= 0 );
}
if( is_s8( displacement8 ) )
xJcc8( comparison, displacement8 );