Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
snes9x2002
Commits
53c2aa4d
Unverified
Commit
53c2aa4d
authored
Feb 24, 2022
by
Libretro-Admin
Committed by
GitHub
Feb 24, 2022
Browse files
Merge pull request #48 from jSTE0/microopt
Microopt
parents
e16cb16e
9d7fedb6
Pipeline
#91074
canceled with stages
Changes
5
Pipelines
10
Hide whitespace changes
Inline
Side-by-side
src/dsp1.c
View file @
53c2aa4d
...
...
@@ -588,7 +588,7 @@ void DSP1SetByte(uint8 byte, uint16 address)
Op11m
=
(
int16
)(
DSP1
.
parameters
[
0
]
|
(
DSP1
.
parameters
[
1
]
<<
8
));
Op11Zr
=
(
int16
)(
DSP1
.
parameters
[
2
]
|
(
DSP1
.
parameters
[
3
]
<<
8
));
Op11Yr
=
(
int16
)(
DSP1
.
parameters
[
4
]
|
(
DSP1
.
parameters
[
5
]
<<
8
));
Op11Xr
=
(
int16
)(
DSP1
.
parameters
[
7
]
|
(
DSP1
.
parameters
[
7
]
<<
8
));
Op11Xr
=
(
int16
)(
DSP1
.
parameters
[
6
]
|
(
DSP1
.
parameters
[
7
]
<<
8
));
DSPOp11
();
break
;
...
...
src/dsp1emu.c
View file @
53c2aa4d
...
...
@@ -255,11 +255,19 @@ void DSP1_Inverse(short Coefficient, short Exponent, short* iCoefficient, short*
}
// Step Three: Normalize
#ifdef __GNUC__
{
const
int
shift
=
__builtin_clz
(
Coefficient
)
-
(
8
*
sizeof
(
int
)
-
15
);
Coefficient
<<=
shift
;
Exponent
-=
shift
;
}
#else
while
(
Coefficient
<
0x4000
)
{
Coefficient
<<=
1
;
Exponent
--
;
}
#endif
// Step Four: Special Case
if
(
Coefficient
==
0x4000
)
...
...
@@ -395,9 +403,18 @@ short DSP1_Cos(short Angle)
void
DSP1_Normalize
(
short
m
,
short
*
Coefficient
,
short
*
Exponent
)
{
short
i
=
0x4000
;
short
e
=
0
;
#ifdef __GNUC__
int
n
=
m
<
0
?
~
m
:
m
;
if
(
n
==
0
)
e
=
15
;
else
e
=
__builtin_clz
(
n
)
-
(
8
*
sizeof
(
int
)
-
15
);
#else
short
i
=
0x4000
;
if
(
m
<
0
)
while
((
m
&
i
)
&&
i
)
{
...
...
@@ -410,6 +427,7 @@ void DSP1_Normalize(short m, short* Coefficient, short* Exponent)
i
>>=
1
;
e
++
;
}
#endif
if
(
e
>
0
)
*
Coefficient
=
m
*
DSP1ROM
[(
0x21
+
e
)
&
1023
]
<<
1
;
...
...
@@ -423,9 +441,18 @@ void DSP1_Normalizefloat(int Product, short* Coefficient, short* Exponent)
{
short
n
=
Product
&
0x7fff
;
short
m
=
Product
>>
15
;
short
i
=
0x4000
;
short
e
=
0
;
#ifdef __GNUC__
short
t
=
m
<
0
?
~
m
:
m
;
if
(
t
==
0
)
e
=
15
;
else
e
=
__builtin_clz
(
t
)
-
(
8
*
sizeof
(
int
)
-
15
);
#else
short
i
=
0x4000
;
if
(
m
<
0
)
while
((
m
&
i
)
&&
i
)
{
...
...
@@ -438,6 +465,7 @@ void DSP1_Normalizefloat(int Product, short* Coefficient, short* Exponent)
i
>>=
1
;
e
++
;
}
#endif
if
(
e
>
0
)
{
...
...
@@ -447,6 +475,14 @@ void DSP1_Normalizefloat(int Product, short* Coefficient, short* Exponent)
*
Coefficient
+=
n
*
DSP1ROM
[(
0x0040
-
e
)
&
1023
]
>>
15
;
else
{
#ifdef __GNUC__
t
=
m
<
0
?
~
(
n
|
0x8000
)
:
n
;
if
(
t
==
0
)
e
+=
15
;
else
e
+=
__builtin_clz
(
t
)
-
(
8
*
sizeof
(
int
)
-
15
);
#else
i
=
0x4000
;
if
(
m
<
0
)
...
...
@@ -461,6 +497,7 @@ void DSP1_Normalizefloat(int Product, short* Coefficient, short* Exponent)
i
>>=
1
;
e
++
;
}
#endif
if
(
e
>
15
)
*
Coefficient
=
n
*
DSP1ROM
[(
0x0012
+
e
)
&
1023
]
<<
1
;
...
...
src/fxemu.c
View file @
53c2aa4d
...
...
@@ -90,6 +90,7 @@
*******************************************************************************/
#include "fxemu.h"
#include "fxinst.h"
#include "memmap.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
...
...
@@ -245,28 +246,23 @@ static INLINE void fx_readRegisterSpace()
{
int
i
;
uint8
*
p
;
static
uint32
avHeight
[]
=
{
128
,
160
,
192
,
256
};
static
uint32
avMult
[]
=
{
16
,
32
,
32
,
64
};
static
const
uint32
avHeight
[]
=
{
128
,
160
,
192
,
256
};
static
const
uint32
avMult
[]
=
{
16
,
32
,
32
,
64
};
GSU
.
vErrorCode
=
0
;
/* Update R0-R15 */
p
=
GSU
.
pvRegisters
;
for
(
i
=
0
;
i
<
16
;
i
++
)
{
GSU
.
avReg
[
i
]
=
*
p
++
;
GSU
.
avReg
[
i
]
+=
((
uint32
)(
*
p
++
))
<<
8
;
}
for
(
i
=
0
;
i
<
16
;
i
++
,
p
+=
2
)
GSU
.
avReg
[
i
]
=
(
uint32
)
READ_WORD
(
p
);
/* Update other registers */
p
=
GSU
.
pvRegisters
;
GSU
.
vStatusReg
=
(
uint32
)
p
[
GSU_SFR
];
GSU
.
vStatusReg
|=
((
uint32
)
p
[
GSU_SFR
+
1
])
<<
8
;
GSU
.
vStatusReg
=
(
uint32
)
READ_WORD
(
&
p
[
GSU_SFR
]);
GSU
.
vPrgBankReg
=
(
uint32
)
p
[
GSU_PBR
];
GSU
.
vRomBankReg
=
(
uint32
)
p
[
GSU_ROMBR
];
GSU
.
vRamBankReg
=
((
uint32
)
p
[
GSU_RAMBR
])
&
(
FX_RAM_BANKS
-
1
);
GSU
.
vCacheBaseReg
=
(
uint32
)
p
[
GSU_CBR
];
GSU
.
vCacheBaseReg
|=
((
uint32
)
p
[
GSU_CBR
+
1
])
<<
8
;
GSU
.
vCacheBaseReg
=
(
uint32
)
READ_WORD
(
&
p
[
GSU_CBR
]);
/* Update status register variables */
GSU
.
vZero
=
!
(
GSU
.
vStatusReg
&
FLG_Z
);
...
...
@@ -459,11 +455,8 @@ static INLINE void fx_writeRegisterSpace()
uint8
*
p
;
p
=
GSU
.
pvRegisters
;
for
(
i
=
0
;
i
<
16
;
i
++
)
{
*
p
++
=
(
uint8
)
GSU
.
avReg
[
i
];
*
p
++
=
(
uint8
)(
GSU
.
avReg
[
i
]
>>
8
);
}
for
(
i
=
0
;
i
<
16
;
i
++
,
p
+=
2
)
WRITE_WORD
(
p
,
GSU
.
avReg
[
i
]);
/* Update status register */
if
(
USEX16
(
GSU
.
vZero
)
==
0
)
SF
(
Z
);
...
...
@@ -476,13 +469,11 @@ static INLINE void fx_writeRegisterSpace()
else
CF
(
CY
);
p
=
GSU
.
pvRegisters
;
p
[
GSU_SFR
]
=
(
uint8
)
GSU
.
vStatusReg
;
p
[
GSU_SFR
+
1
]
=
(
uint8
)(
GSU
.
vStatusReg
>>
8
);
WRITE_WORD
(
&
p
[
GSU_SFR
],
GSU
.
vStatusReg
);
p
[
GSU_PBR
]
=
(
uint8
)
GSU
.
vPrgBankReg
;
p
[
GSU_ROMBR
]
=
(
uint8
)
GSU
.
vRomBankReg
;
p
[
GSU_RAMBR
]
=
(
uint8
)
GSU
.
vRamBankReg
;
p
[
GSU_CBR
]
=
(
uint8
)
GSU
.
vCacheBaseReg
;
p
[
GSU_CBR
+
1
]
=
(
uint8
)(
GSU
.
vCacheBaseReg
>>
8
);
WRITE_WORD
(
&
p
[
GSU_CBR
],
GSU
.
vCacheBaseReg
);
fx_restoreCache
();
}
...
...
src/gfx.c
View file @
53c2aa4d
...
...
@@ -579,7 +579,7 @@ void S9xStartScreenRefresh()
GFX
.
DepthDelta
=
GFX
.
SubZBuffer
-
GFX
.
ZBuffer
;
GFX
.
Delta
=
(
GFX
.
SubScreen
-
GFX
.
Screen
)
>>
1
;
}
if
(
++
IPPU
.
FrameCount
%
Memory
.
ROMFramesPerSecond
==
0
)
if
(
++
IPPU
.
FrameCount
==
(
uint32
)
Memory
.
ROMFramesPerSecond
)
{
IPPU
.
DisplayedRenderedFrameCount
=
IPPU
.
RenderedFramesCount
;
IPPU
.
RenderedFramesCount
=
0
;
...
...
src/gfx16.c
View file @
53c2aa4d
...
...
@@ -597,7 +597,7 @@ void S9xStartScreenRefresh()
GFX
.
Delta
=
(
GFX
.
SubScreen
-
GFX
.
Screen
)
>>
1
;
}
if
(
++
IPPU
.
FrameCount
%
Memory
.
ROMFramesPerSecond
==
0
)
if
(
++
IPPU
.
FrameCount
==
(
uint32
)
Memory
.
ROMFramesPerSecond
)
{
IPPU
.
DisplayedRenderedFrameCount
=
IPPU
.
RenderedFramesCount
;
IPPU
.
RenderedFramesCount
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment