Compare commits

...

411 commits

Author SHA1 Message Date
Richard Goedeken
47f8e92e9a
Merge pull request #91 from orbea/strict-aliasing
build: remove -fno-strict-aliasing
2024-11-03 17:44:22 -08:00
orbea
1b7c25cdaa build: remove -fno-strict-aliasing
It compiles with -Werror=strict-aliasing so this is not required.
2024-11-03 12:34:08 -08:00
orbea
5532574896 Remove executable permissions from the Makefile
mode change 100755 => 100644 projects/unix/Makefile
2024-11-03 12:32:20 -08:00
Richard Goedeken
2798e65d6f update version and release info for v2.6.0 release 2024-07-14 17:36:33 -07:00
Richard Goedeken
d972dc5ea1 update minimum macos SDK in makefile 2024-07-14 12:01:02 -07:00
Richard Goedeken
9d13986f76
Merge pull request #90 from Jj0YzL5nvJ/up2024
CI/CD: Update to generic scripts, independent schedule, etc
2024-05-26 19:56:29 -07:00
Jj0YzL5nvJ
1d690fd8a6 CI/CD: Update to generic scripts, independent schedule, etc 2024-05-24 11:17:26 -06:00
Richard Goedeken
f01be76948
Merge pull request #89 from Clownacy/patch-1
Fix check for M64P_BIG_ENDIAN
2024-01-12 20:21:12 -08:00
Clownacy
47f8cee6ce
Fix check for M64P_BIG_ENDIAN
Every check for M64P_BIG_ENDIAN in the emulator core only checks for its definition, not for its value being non-zero.
2024-01-10 17:33:07 +00:00
Richard Goedeken
f22dc14377
Merge pull request #88 from Jj0YzL5nvJ/up2023
CI/CD: Add BLAKE2 hashfile
2023-06-11 12:18:52 -07:00
Jj0YzL5nvJ
6b53db06de CI/CD: Add BLAKE2 hashfile 2023-05-22 00:24:57 -06:00
Richard Goedeken
bbfba920fc
Merge pull request #87 from Jj0YzL5nvJ/ci-schedule
CI/CD: Integrate scheduled builds and other...
2023-03-02 21:59:57 -08:00
Jj0YzL5nvJ
4ff2fe6a19 CI/CD: Integrate scheduled builds and other necessary updates 2023-02-14 23:49:33 -06:00
Richard Goedeken
ca917cec14
Merge pull request #86 from Jj0YzL5nvJ/up2022
CI/CD: Update MSVC
2022-09-30 16:59:21 -07:00
Jj0YzL5nvJ
fdebc89484 CI/CD: Update MSVC 2022-09-27 23:36:03 -06:00
Richard Goedeken
aa0ea78030
Merge pull request #85 from Jj0YzL5nvJ/ci-update
CI/CD: Update
2022-07-13 19:30:22 -07:00
Jj0YzL5nvJ
3cdee61a98 CI/CD: Update 2022-07-10 18:52:10 -06:00
bsmiles32
27580a8c33
Merge pull request #84 from derselbst/cbfd-overload
Added overload distortion effect, used by a few tracks in CBFD
2022-04-24 22:03:47 +02:00
derselbst
21b669e8a3 Add a comment regarding mp3 and cbfd ucode differences 2022-04-24 17:22:50 +02:00
Tom M
9452b4a181 Apply suggestions from code review
Co-authored-by: bsmiles32 <bobby.smiles32@gmail.com>
2022-04-24 17:13:43 +02:00
Richard Goedeken
2ae723c33b
Merge pull request #82 from Jj0YzL5nvJ/ci-github
CI/CD: Implement GitHub Actions and public nightly builds
2022-04-11 20:55:33 -07:00
Josh Ware
37682c2a12 Added overload distortion effect, used by a few tracks in CBFD 2022-02-14 19:46:05 +01:00
bsmiles32
4bac3aeb98
Merge pull request #83 from fzurita/out_of_bounds_access
Fix out of bounds memory access encountered in CBFD
2022-01-16 18:29:31 +01:00
fzurita
53e6c6a143 Fix out of bounds memory access encountered in CBFD 2022-01-16 12:26:06 -05:00
Jj0YzL5nvJ
51345ed0e5 CI/CD: Implement GitHub Actions and public nightly builds 2021-12-05 09:00:32 -07:00
Pierce Andjelkovic
88093cb434 RISC-V Support 2021-09-15 00:02:11 +02:00
Richard Goedeken
88766c6e2d bump up minimum version number so that we can still build this on modern macos 2021-02-10 21:14:23 -08:00
orbea
e653930d75 build: Allow out of tree builds.
Also fixes a case of SRCDIR being used before its set.
2020-12-15 10:17:15 +01:00
Gilles Siberlin
bb56985770
Merge pull request #79 from loganmc10/ub
Fix undefined behavior
2020-10-21 15:49:47 +02:00
Logan McNaughton
2f42716781 Fix undefined behavior 2020-10-19 10:46:51 -07:00
Richard Goedeken
b4155b7004 Revert "Allow non-default compilers without resorting to symbolic links"
This reverts commit 0ff1d46edf, as it conflicts with GNU make which always defines default values for certain variables
2020-09-16 22:31:15 -07:00
Richard Goedeken
72a1deca7d
Merge pull request #77 from Jj0YzL5nvJ/alter_cc_cxx
Allow non-default compilers without resorting to symbolic links
2020-08-31 21:19:30 -07:00
Jj0YzL5nvJ
0ff1d46edf Allow non-default compilers without resorting to symbolic links 2020-08-30 03:46:09 -06:00
Richard Goedeken
4e61df6a25
Merge pull request #76 from Jj0YzL5nvJ/alter
Allow to set custom platform toolset from commands
2020-08-19 23:36:36 -07:00
Jj0YzL5nvJ
d12cd46872 Allow to set custom platform toolset from commands 2020-08-13 11:58:07 -06:00
Jj0YzL5nvJ
2df8038d5f AppVeyor with artifact packaging 2020-03-02 09:38:16 +01:00
Jj0YzL5nvJ
7d9293ad91 Changes to have more generic project files 2020-02-26 12:39:06 +01:00
Gillou68310
f295d34727 Fix HVQM Implementation 2020-02-21 09:14:06 +01:00
Gillou68310
25b83af2f4 Rework task dispatching implementation 2020-02-20 15:49:07 +01:00
Gillou68310
fa00bf82fd Implement HVQM ucode 2020-02-03 20:50:27 +01:00
Gillou68310
c05c5e0fab Preliminary implementation for Yakouchuu II ucode 2020-02-02 12:11:05 +01:00
Gillou68310
7ea802e76e Migrate to VS2017 2019-11-13 17:15:02 +01:00
Richard Goedeken
f01fed082a add function attributes so GCC can find bugs in calls to string formatting functions with variadic arguments 2019-03-03 09:30:19 -08:00
Richard Goedeken
16c31f09c0
Merge pull request #68 from djames1/master
Added ppc64le support
2019-02-21 21:43:52 -08:00
Daniel James
42ffe474b2 Added ppc64le support 2019-02-20 11:29:49 -05:00
Richard Goedeken
7b1a2094a0 update version and release info for v2.5.9 BETA release 2019-02-10 10:13:29 -08:00
Richard Goedeken
e7b0182fb1 fix Travis CI test builds for MXE 32 and 64 bits 2019-01-29 22:13:25 -08:00
Richard Goedeken
e2adb502c6
Merge pull request #67 from bugfood/fix-nosaveoptions
Remove use of ConfigSaveSection
2019-01-23 21:58:30 -08:00
Corey Hickey
5e0c36f188 Remove use of ConfigSaveSection
Known front-ends have been modified to save configuration after plugin
initialization but before running the game. Now it is no longer
necessary for individual plugins to save their config.

Removing calls to ConfigSaveSection from within plugins makes the
mupen64plus-ui-console '--nosaveoptions' parameter work.
2019-01-22 21:05:11 -08:00
Richard Goedeken
1233981129
Merge pull request #66 from bkeys/makefile_aarch64
Makefile aarch64
2018-09-21 20:23:15 -07:00
Brigham Henry Keys
ba228af849 Removed redundant CPU detection 2018-09-21 02:40:39 -05:00
Brigham Henry Keys
f6ef6b076c Added support for aarch64 2018-09-19 12:09:10 -05:00
Brigham Henry Keys
6e9600cc5b Added support for aarch64 2018-09-19 12:05:32 -05:00
Richard Goedeken
bb52e1ad68
Merge pull request #65 from loganmc10/patch-4
Indi and Naboo now have an HLE implementation
2018-05-26 08:30:47 -07:00
Logan
febfc28730
Indi and Naboo now have an HLE implementation 2018-05-26 07:49:23 -06:00
Richard Goedeken
8a5fb80d28
Merge pull request #64 from loganmc10/patch-3
Remove WDC and Stunt Racer from LLE list
2018-02-12 08:14:55 -08:00
Logan
b7da074c41
Remove WDC and Stunt Racer from LLE list 2018-02-12 06:08:43 -07:00
Richard Goedeken
2e4171499c update FSF address in license 2018-02-04 12:58:57 -08:00
bsmiles32
7418dd6a5f
Merge pull request #63 from bentley/master
Update homepage links
2018-01-01 17:47:01 +01:00
Anthony J. Bentley
7178086ff3 Update homepage. 2017-12-28 16:27:32 -07:00
Anthony J. Bentley
9229360df6 Update link to bug tracker. 2017-12-28 16:06:05 -07:00
Richard Goedeken
d9c297ce25
Merge pull request #62 from Gillou68310/mi_intr
Don't set MI_INTR_SP if task is not finished yet
2017-12-15 18:14:25 -08:00
Gillou68310
9d8e4e370e Don't set MI_INTR_SP if task is not finished yet 2017-12-14 16:37:46 +01:00
Gillou68310
4e116a85a1 Don't disable HLE GFX if no fallback available 2017-12-14 16:37:32 +01:00
Gillou68310
b636701967 Use integers instead of float 2017-12-14 09:12:08 +01:00
bsmiles32
b7e1df3f6c
Merge pull request #61 from Gillou68310/re2
Implement RE2 fill video double buffer ucode
2017-12-14 01:56:01 +01:00
Gillou68310
57a20e4c0b Implement RE2 fill video double buffer ucode 2017-12-13 21:28:36 +01:00
Richard Goedeken
8860a7e63d
Merge pull request #60 from StenApp/patch-1
Update jpeg.c
2017-12-04 21:46:15 -08:00
Sten
3042d32ea5
Update jpeg.c
Truncation warning
2017-12-02 22:31:25 +01:00
Richard Goedeken
a3690d9280
Merge pull request #59 from loganmc10/patch-2
If DEBUG not set, set NDEBUG
2017-11-30 19:37:02 -08:00
Logan
06c8ec7c2c
If DEBUG not set, set NDEBUG 2017-11-30 10:59:57 -07:00
Richard Goedeken
421e97ce45 update Makefile method for finding OSX_SDK_PATH 2017-11-14 16:21:30 -08:00
Dorian Fevrier
0806227ce9
Merge pull request #58 from charlemagnelasse/travis-mxe
Build MXE targets as additional tests in travis build matrix
2017-11-06 12:19:35 +01:00
Charlemagne Lasse
9faf92fadf Build MXE targets as additional tests in travis build matrix 2017-11-05 15:35:14 +01:00
bsmiles32
053e99826f
Merge pull request #54 from bsmiles32/lle_fallback
Implement RSP fallback.
2017-11-01 19:12:13 +01:00
Bobby Smiles
db5bce48bd Remove Gauntlet legend settings override. 2017-10-27 23:18:20 +02:00
Bobby Smiles
1b47eea6fa Set TASK_DONE, BROKE, HALT bits before calling ProcessDlistList function 2017-10-13 19:56:41 +02:00
Dorian Fevrier
47de8d2c66 Merge pull request #56 from mupen64plus/revert-55-sdl2
Revert "Update to VS2015"
2017-10-13 09:54:16 +02:00
Dorian Fevrier
935522a54e Revert "Update to VS2015" 2017-10-13 09:53:48 +02:00
Dorian Fevrier
cdd404b7e2 Merge pull request #55 from loganmc10/sdl2
Update to VS2015
2017-10-13 09:53:31 +02:00
Logan McNaughton
15e20ce808 Add AppVeyor script 2017-10-11 10:33:42 -06:00
Logan McNaughton
cbfce2a22c Visual Studio 2015 2017-10-10 14:57:44 -06:00
Bobby Smiles
b94f7bbdf7 Stub 2 new audio ucodes found in 64DD conversions carts. 2017-10-04 18:48:06 +02:00
Bobby Smiles
58f14e391c Fix: task type 7 should not be "discarded" after calling ShowCFB.
This matches the cxd4 plugin behavior and fixes Pokemon Puzzle league.
2017-10-04 18:47:42 +02:00
Bobby Smiles
b53a5d8422 Implement RSP fallback.
This allows to specify an arbitrary RSP plugin to use when an unknown
ucode is encountered. It is particularly usefull when combined with an
LLE RSP plugin.

Sending audio lists or display lists to audio (resp. gfx) plugins can
also be specified through config parameters. A blacklist of known
problematic gfx ucodes is integrated (same as rsp-cxd4) to avoid sending
them to the gfx plugin.
2017-10-04 18:47:42 +02:00
bsmiles32
cb34bbd39c Merge pull request #53 from Gillou68310/re2
Implement RE2 video frame decoding ucode
2017-10-04 18:27:54 +02:00
Gillou68310
0c6c0784f2 Implement RE2 video frame decoding ucode 2017-09-19 11:58:13 +02:00
bsmiles32
0cc2f05460 Merge pull request #51 from bsmiles32/task_done
Let each ucode specify how sp status should be modified.
2017-09-15 00:46:20 +02:00
Bobby Smiles
5437128c67 Let each ucode specify how sp status should be modified.
Most ucodes are executed until task is done (in one go).
However, some ucodes (yet to be implemented such as wdc zsort) may need
to yield thus not setting task done flag.
This should be stricly equivalent to previous code, just with more
flexibility should we add yielding support.
2017-08-09 08:09:09 +02:00
bsmiles32
5252ff28a5 Merge pull request #52 from derselbst/macros
specify audio ucode flags explicitly
2017-08-09 00:42:46 -05:00
derselbst
8576bcdd79 specify audio ucode flags explicitly 2017-08-01 11:14:53 +02:00
Tom M
8ddd361992 specify audio ucode flags explicitly
for increased readability
2017-07-31 17:04:14 +02:00
Bobby Smiles
842d62d41e Revert "Allow using compiler other than gcc"
This reverts commit f5838d8c48.
2017-06-24 13:34:45 -06:00
bsmiles32
9e8644b09b Merge pull request #47 from fzurita/master
Prevent yet one more illegal access to alist_buffer
2017-06-22 20:32:00 -06:00
bsmiles32
54767eff73 Merge pull request #48 from loganmc10/patch-1
Allow using compiler other than gcc
2017-06-22 20:21:15 -06:00
Logan McNaughton
f5838d8c48 Allow using compiler other than gcc 2017-06-20 21:15:38 -06:00
Francisco Zurita
ef6a5a2f6e Prevent yet one more illegal access to alist_buffer 2017-06-05 23:08:15 -04:00
bsmiles32
4023936c63 Merge pull request #46 from bsmiles32/re2
Add support for Re2 bilinear resizing
2017-06-02 07:29:59 -06:00
Bobby Smiles
4f77c93a2f Re2: Add support for other regions 2017-06-02 15:11:27 +02:00
Bobby Smiles
2f9a16cb3c Fix unused variable warning. 2017-06-02 15:11:13 +02:00
Gillou68310
a339dc66b6 Resident evil 2 resize bilinear ucode 2017-06-02 14:55:43 +02:00
bsmiles32
e42940878c Merge pull request #45 from fzurita/fix_more_crashes
Prevent more illegal accesses of alist_buffer
2017-05-23 16:35:22 -06:00
Francisco Zurita
e29dce8f6b Prevent more illegal accesses of alist_buffer 2017-04-28 09:00:09 -04:00
Richard Goedeken
fb15d2040a Merge pull request #44 from fzurita/fix_crash
Prevent CLEARBUFF for naudio and nead from deriving a count too big for alist_buffer
2017-04-05 23:06:14 -07:00
Francisco Zurita
f5818d4fc5 Prevent CLEARBUFF for naudio and nead from deriving a count too big for
alist_buffer.

alist_buffer max size is 0x1000, so using 0xFFF as mask
2017-03-23 08:50:24 -04:00
Richard Goedeken
1f8a4cb7ba Merge pull request #43 from fzurita/master
Backport fixes from Project64
2017-03-16 22:54:22 -07:00
Francisco Zurita
0898913beb Backport fixes from Project64
Specifically
848502e088
5b546a0fcb
2017-03-05 00:14:43 -05:00
Richard Goedeken
f3acff42b8 Merge pull request #42 from charlemagnelasse/travis-container
Use faster container based Travis CI
2017-02-01 22:21:15 -08:00
Charlemagne Lasse
c557db8d9c Use faster container based Travis CI 2016-12-16 22:24:02 +01:00
Richard Goedeken
13770ff899 Merge pull request #41 from charlemagnelasse/master
Use Ubuntu Trusty as base system for Travis CI
2016-09-01 18:04:07 -07:00
Charlemagne Lasse
fa38ab2d8a Use Ubuntu Trusty as base system for Travis CI 2016-09-01 20:23:59 +02:00
Richard Goedeken
3d09ae67d7 change VS2013 project files to build with the XP-compatible vc120 toolset, so the resulting binaries will run on pre-vista machines 2016-07-13 20:04:06 -07:00
Richard Goedeken
526a7bc8e5 Merge pull request #40 from loganmc10/master
Backports from project64
2016-07-12 19:20:54 -07:00
Logan McNaughton
1381ee5f62 Backports from project64, see:
b187ad9b81
210832c618
c06ad3a276
2016-06-14 10:24:51 -06:00
Richard Goedeken
95f3bab72b Merge pull request #38 from Gillou68310/x64
Added x64 configuration to VisualStudio2013 project file
2015-09-12 21:52:27 -07:00
Gillou68310
d7e051b4c9 Added x64 configuration to VisualStudio2013 project file 2015-08-28 16:19:18 +02:00
Richard Goedeken
5d66105bda Merge pull request #37 from bentley/openbsd
Remove unnecessary OpenBSD warning.
2015-06-08 06:31:34 -07:00
Anthony J. Bentley
1e977b16d6 Remove unnecessary OpenBSD warning. 2015-06-08 01:48:45 -06:00
Richard Goedeken
cd9ffb7eb4 update text files and version number for upcoming 2.5 release 2015-04-26 12:31:42 -07:00
Richard Goedeken
21ce7b5131 Merge pull request #36 from conchurnavid/includes
Cleanup includes order and add missing includes
2015-03-21 21:30:53 -07:00
Conchúr Navid
b3328a85d2 Add missing includes and forward declarations 2015-03-21 13:47:40 +01:00
Conchúr Navid
f502edf932 Sort the includes based on type and names 2015-03-21 10:58:40 +01:00
Conchúr Navid
5f3e98f6e1 Fix executable bits of files 2015-03-21 10:53:38 +01:00
Richard Goedeken
f448501d76 Merge pull request #35 from bsmiles32/fix_alist_seg
Discard highest 2 bits for segment selection
2015-03-18 20:36:00 -07:00
Bobby Smiles
494552222f Discard highest 2 bits for segment selection;
This avoids constant spamming in Aidyn Chronicles.
2015-03-18 18:33:29 +01:00
Dorian Fevrier
ee298c8fe0 Merge pull request #34 from rlabrecque/removestdbool
Remove unused stdbool.h
2015-03-13 10:23:52 -04:00
Riley Labrecque
c0e69b2665 Remove unused stdbool.h 2015-03-13 05:12:51 -06:00
Richard Goedeken
3d905a3c93 added project/solution file for Visual Studio 2013. removed older MSVS project files. fix code compatilibity problems with MSVC 2015-02-22 07:13:34 -08:00
bsmiles32
c9bd96a597 Merge pull request #33 from kode54/master
Implemented IIR filter for nAudio RSP HLE
2015-02-13 19:02:55 +01:00
Chris Moeller
7bda432c48 Fixed indenting, and moved vmulf to arithmetics.h 2015-02-07 17:46:01 -08:00
U-Apoc\Josh
bd5ccc6354 Implemented IIR filter for nAudio RSP HLE
Specifically for CBFD
2015-02-05 23:41:05 -08:00
Richard Goedeken
ce2a7e4d63 Merge pull request #32 from Nebuleon/build-changes
Add a MIPS support stanza for the Unix Makefile
2015-02-01 14:32:47 -08:00
Nebuleon Fumika
666f51b2bf unix: Add a Makefile configuration for MIPS 2015-01-26 10:07:17 +00:00
Richard Goedeken
6a961b60d5 Merge pull request #31 from Gillou68310/master
Added project file for MSVC2010
2015-01-07 22:55:10 -08:00
Richard Goedeken
9ebb10e53b Merge pull request #30 from mupen64plus-ae/vanilla
Merge Android Edition history
2015-01-07 22:43:42 -08:00
Gillou68310
6ca9446ab4 Added project file for MSVC2010 2015-01-07 15:11:10 +01:00
littleguy77
8fc144d9c3 build: Remove Android makefile. 2014-12-18 22:05:08 -05:00
Paul Lamb
202263954b Merge from upstream 2014-12-02 19:01:35 -06:00
Richard Goedeken
5c86640a01 Merge pull request #29 from bsmiles32/let_gfx_plugin_clear_freeze
Let the GFX plugin clear FREEZE bit.
2014-11-26 22:58:09 -08:00
Bobby Smiles
56086d20a7 Let the GFX plugin clear FREEZE bit. 2014-11-22 15:07:02 +01:00
Paul Lamb
3c5632dc1d Update Android project 2014-11-08 15:34:51 -06:00
Paul Lamb
e5babbb5da Merge from upstream 2014-11-08 11:18:58 -06:00
Richard Goedeken
98e7e31579 Merge pull request #28 from bsmiles32/fix_x105_detection
Fix ucode CIC x105 detection after reset
2014-10-25 11:46:29 -07:00
Bobby Smiles
61c3364fc7 Fix ucode CIC x105 detection after reset
After reset, IMEM could contain garbage which could interfere with ucode identification.
To avoid that, we reduce the length used to compute the ucode sum.

Furthermore, after fixing PIFBoot ROM emulation in mupen64plus-core, there is no need
for different values for CIC 6105 and CIC 7105.
2014-10-18 01:49:56 +02:00
Richard Goedeken
6158876a21 Merge pull request #27 from fayvel/travisci
Add Travis CI configuration file for automatic build tests
2014-07-07 22:03:54 -07:00
Fayvel Victor
2287b3b79a Add Travis CI configuration file for automatic build tests
Github provides a Travis CI integration which makes it easy to have a quick
check of a patch before a pull request is accepted. It is not enough to prove
the correctness of a contribution but at least helps to avoid some of the worst
build problems.

This feature *must* be enabled by the mupen64plus administrator *before this
commit is merged*:

- https://travis-ci.org/profile/mupen64plus
- Login via your Github account
- Make sure you are on "https://travis-ci.org/profile/mupen64plus"
- Switch repository to "On"
2014-07-06 12:31:53 +02:00
Richard Goedeken
e3c883e1d1 Merge pull request #26 from bsmiles32/fix_dump
Fix: regression introduced in commit be21b61.
2014-07-05 21:49:52 -07:00
Bobby Smiles
c981f68051 Fix: regression introduced in commit be21b61.
2 changes were necessary:
hleErrorMessage -> HleErrorMessage in dump_binary.
Change dump_binary prototype to pass an hle pointer.
2014-07-05 23:46:28 +02:00
Richard Goedeken
e3f83feaa4 Merge pull request #25 from bsmiles32/dont_clear_rspmem
Remove IMEM,DMEM clearing at RomClose.
2014-04-12 08:31:17 -07:00
Bobby Smiles
a8d83cb83f Remove IMEM,DMEM clearing at RomClose.
I think this kind of clearing shouldn't be the responsibility of the RSP plugin.
LLE plugin doesn't perform this cleaning as well.
2014-04-10 20:54:11 +02:00
Richard Goedeken
24be9ace89 Merge pull request #24 from bsmiles32/msvc_fixes
Msvc fixes
2014-04-06 09:47:19 -07:00
Bobby Smiles
a5b4fc443a Fix various warnings. 2014-04-05 12:53:53 +02:00
Bobby Smiles
8ccab927eb Fix: declare variable at top of function. 2014-04-05 12:20:08 +02:00
Bobby Smiles
1010ec23c7 inline is not an available keyword in C for MSVC.
For MSVC, inline is only available in C++, not C.
In C we can use __inline (or __forceinline) instead.
2014-04-05 12:13:24 +02:00
Bobby Smiles
9f2b928503 Add stdbool support for msvc compilers. 2014-04-05 12:04:47 +02:00
Richard Goedeken
889a0707a5 Merge pull request #22 from bsmiles32/oups_ge
Fix: ramps step is 1/8 of rate
2014-04-03 21:41:34 -07:00
Bobby Smiles
497517d70a Fix: ramps step is 1/8 of rate 2014-04-03 08:27:34 +02:00
Richard Goedeken
21f4ce94fc Merge pull request #21 from bsmiles32/fix_ge
Implement GoldenEye envelope mixer audio command.
2014-04-02 22:05:38 -07:00
Bobby Smiles
fc81c1f3c0 Implement GoldenEye envelope mixer audio command.
It should fix issue 596 in our bug tracker.
2014-04-03 00:27:54 +02:00
Richard Goedeken
e723d08684 Merge pull request #20 from bsmiles32/naudio_02b0
Implement NAUDIO_02B0.
2014-03-20 22:12:16 -07:00
Richard Goedeken
274162db3c Merge pull request #19 from bsmiles32/refactorings
Refactorings
2014-03-20 22:08:05 -07:00
Bobby Smiles
6823445ad9 Implement NAUDIO_02B0.
To implement NAUDIO_02B0, we emulate instructions located at 0x12b0 (inside SETVOL), which
overwrite lowest part of right rate.
Indeed, despite its address 0x02b0 (ie DMEM), SP can only execute in IMEM.
2014-03-19 23:16:11 +01:00
Bobby Smiles
ed30f87f4d Refactor simple alist buffer accesses. 2014-03-19 21:13:05 +01:00
Bobby Smiles
8fb2604b80 Refactor memory functions. 2014-03-19 20:11:10 +01:00
Bobby Smiles
71c4f22bf8 Rename alist_internal.h into alist.h 2014-03-19 19:15:18 +01:00
Bobby Smiles
76ca3b014c Regroup all ucode headers into a single header. 2014-03-19 19:14:10 +01:00
Bobby Smiles
2d44dcffb9 Move acmd parsing to alist_naudio 2014-03-19 18:35:10 +01:00
Bobby Smiles
67339fdcee Move MP3 prototype into its own header. 2014-03-19 09:41:45 +01:00
Bobby Smiles
b5472454b0 Fix top comment 2014-03-19 09:35:06 +01:00
Bobby Smiles
b82e298dbf Remove unneeded state variables. 2014-03-19 09:31:39 +01:00
Bobby Smiles
594fce4722 Use clamp_s16 where appropriate. 2014-03-19 09:16:29 +01:00
Richard Goedeken
2d28605585 Merge pull request #18 from bsmiles32/pedantic
Fix most warnings when compiling in pedantic mode.
2014-03-16 21:26:08 -07:00
Bobby Smiles
d751f58b3d Fix most warnings when compiling in pedantic mode. 2014-03-14 17:22:02 +01:00
Richard Goedeken
1dc87131f2 Merge pull request #17 from bsmiles32/wextra_fixes
Wextra fixes
2014-03-11 17:52:49 -07:00
Bobby Smiles
7d0ba23f11 Fix unused parameter warning. 2014-03-10 21:55:54 +01:00
Bobby Smiles
c2c5080c7c Fix: signed/unsigned comparison. 2014-03-10 21:21:56 +01:00
Bobby Smiles
4e82ac6f28 Fix: ignored qualifier warning from memory.h 2014-03-10 21:19:16 +01:00
Richard Goedeken
775522093f Merge pull request #16 from bsmiles32/avoid_global_state
Avoid global state
2014-03-08 22:04:33 -08:00
Bobby Smiles
0be1e551c3 Rename main to hle. 2014-03-06 21:49:30 +01:00
Bobby Smiles
d6718933db Rename plugin.h to hle_external.h 2014-03-06 21:36:51 +01:00
Bobby Smiles
4a3943a9fd Move hle_t definition inside a private header. 2014-03-06 20:41:43 +01:00
Bobby Smiles
be21b61d9a Allow to pass a user-defined object to "external" functions. 2014-03-06 10:19:01 +01:00
Bobby Smiles
9e482edcc9 Use {Verbose,Warn,Error}Message instead of DebugMessage.
By doing so, we can remove the dependency on m64p_type.h because of M64MSG_*.
Now the HLE core should be almost independant with respect to m64p plugin.
2014-03-06 10:19:01 +01:00
Bobby Smiles
0772f2cf42 Move emulator specific functions outside of hle_t. 2014-03-06 10:19:01 +01:00
Bobby Smiles
62e0ef5cfc Remove RSPINFO requirement in hle core. 2014-03-06 10:19:01 +01:00
Bobby Smiles
4a8aad9f74 Remove global mutable variables from hle core.
All global mutable variables of the HLE core were regrouped into struct hle_t.
This allow third party to reuse the HLE core, without limiting them to a single process.
All they have to do is to declare another struct hle_t and pass it to hle_execute.
For mupen64plus plugin, a global hle_t is declared and passed to hle_execute.

I would have expected a small performance hit, because of the added level of indirection,
but it doesn't seem to be really noticeable for me.
2014-03-06 10:19:00 +01:00
Richard Goedeken
92caacffe8 Merge pull request #15 from bsmiles32/ucode1_and_other_refactoring
ucode1 work and other refactorings
2014-02-27 21:34:13 -08:00
Bobby Smiles
49ef4ad7fb Rename NEAD alist based ucodes. 2014-02-23 20:59:38 +01:00
Bobby Smiles
019edad852 Regroup sfx_stage_v{1,2} 2014-02-23 20:32:24 +01:00
Bobby Smiles
e790ed7b4e Regroup update_base_vol_v{1,2} 2014-02-23 19:37:21 +01:00
Bobby Smiles
deadc2507d Fix copyright headers. 2014-02-23 19:29:23 +01:00
Bobby Smiles
4bce49daf9 Remove superfluous masking 2014-02-23 16:53:16 +01:00
Bobby Smiles
58aaf24d1d POLEF count should be aligned to 16 bytes. 2014-02-23 16:53:16 +01:00
Bobby Smiles
f53324ef29 MIXER count should be aligned to 32 bytes. 2014-02-23 16:53:16 +01:00
Bobby Smiles
ae5e259559 INTERLEAVE count should be aligned to 16 bytes. 2014-02-23 16:53:15 +01:00
Bobby Smiles
4699b37e1e LOADADPCM count should be aligned to 8 bytes. 2014-02-23 16:53:15 +01:00
Bobby Smiles
f3b477a6a3 DMEMMOVE process chunks of 16 bytes. 2014-02-23 16:53:15 +01:00
Bobby Smiles
021ccb552a Rework LOADBUFF/SAVEBUFF. 2014-02-23 16:53:15 +01:00
Bobby Smiles
6cb68d6bd7 ADPCM: prefer align function over manual solution. 2014-02-23 16:53:15 +01:00
Bobby Smiles
5ed5042565 Rework RESAMPLE.
Modifications:
-there is an additional flag which can affect processing (not implemented)
-RESAMPLE outputs chunks of 16 bytes.
2014-02-23 16:53:15 +01:00
Bobby Smiles
6d44f153a1 Rework CLEARBUFF / alist_clear.
Three modifications:
-CLEARBUFF check for null sized buffer and exit early in that case
-CLEARBUFF process chunks of 16 bytes
-There should be no constrains on dmem alignment, therefore alist_clear should handle unaligned
accesses.
2014-02-23 16:52:53 +01:00
Bobby Smiles
45af55c656 Implement SEGMENT audio command. 2014-02-23 16:52:44 +01:00
Bobby Smiles
ac6c14f501 Use real dmem address ucode1. 2014-02-23 16:18:39 +01:00
Richard Goedeken
d55c2d91fa Merge pull request #14 from bsmiles32/plugin_refac
Plugin refac
2014-02-19 21:29:52 -08:00
Bobby Smiles
54f817a86d Put hle_execute proto into a proper header file. 2014-02-19 09:04:51 +01:00
Bobby Smiles
0a9e243204 Make unknown task dumping optional at compile time.
This functionality is not needed by the normal user and can introduce unwanted dependencies on
files. It can be enabled at compile time using -DENABLE_TASK_DUMP or Makefile var DUMP=1.
2014-02-19 05:32:33 +01:00
Bobby Smiles
806b0c07ce Use bool where appropriate. 2014-02-17 09:01:20 +01:00
Bobby Smiles
286614a3c1 Rename rsp status flags defines. 2014-02-17 08:53:16 +01:00
Bobby Smiles
ed81030162 Rename ucode*.c files 2014-02-17 08:44:47 +01:00
Bobby Smiles
24de686fb1 Move clamp_s16 to arithmetics.h 2014-02-17 02:27:50 +01:00
Bobby Smiles
94d8f03c85 Remove superfluous headers 2014-02-17 02:19:28 +01:00
Bobby Smiles
0923af8d68 Isolate memory access code. 2014-02-17 02:06:49 +01:00
Bobby Smiles
b680a18fda Rename rsp to g_RspInfo 2014-02-17 01:21:09 +01:00
Bobby Smiles
df010f161b Isolate plugin specific code. 2014-02-17 01:14:31 +01:00
Richard Goedeken
edc7dd7d81 Merge pull request #13 from bsmiles32/musyx_v2
Implement parts of MusyX ucode (v2).
2014-02-09 21:38:45 -08:00
Bobby Smiles
5586e9ca58 Implement parts of MusyX ucode (v2).
The second version of MusyX ucode is only found in IndianaJones and BattleForNaboo.
NOTE: the proposed implementation is not complete but seems enough to improve user experience.
2014-02-09 03:40:21 +01:00
Richard Goedeken
abe172dcf2 Merge pull request #12 from bsmiles32/musyx_temporary_fix
Temporary fix for IndianaJones and BattleForNaboo.
2014-02-06 21:55:42 -08:00
Bobby Smiles
8c022c1bd4 Temporary fix for IndianaJones and BattleForNaboo.
IndianaJones and BattleForNaboo use a different version of musyx ucode.
In this later version, some data structures have changed, which makes it incompatible with the
previous version (and cause the emulator to crash...).
This patch avoid the emulator crash by not handling the task.
Proper fix requires more reverse engineering effort.
2014-02-06 19:40:49 +01:00
Richard Goedeken
0099c91e62 Merge pull request #11 from bsmiles32/small_fixes
Small fixes
2014-02-03 22:14:41 -08:00
Bobby Smiles
151fca618b Fix regression introduced by commit 3921889f3b
adpcm_compute_residuals should honor the count parameter.
2014-02-03 23:58:01 +01:00
Bobby Smiles
51f9dc2dd4 Refactor some mixing routines 2014-02-01 10:57:13 +01:00
Bobby Smiles
6c5a8e2fd8 Fix overflow with ramp value stepping
see bsmiles32/mupen64plus-rsp-hle@032b726#commitcomment-5241631
2014-02-01 10:56:58 +01:00
Bobby Smiles
6aa918ca43 Fix: acmd dispatching discard most significant bit 2014-02-01 10:42:23 +01:00
littleguy77
552bab6f81 build: Add android makefile. 2014-01-28 17:38:54 -05:00
Richard Goedeken
1cc1ceb74a fix windows build problem 2014-01-26 09:55:51 -08:00
Richard Goedeken
f4e723d203 Merge pull request #10 from bsmiles32/audio_improvements
Audio improvements
2014-01-24 22:19:08 -08:00
Bobby Smiles
0004268525 Dehardcode various magic numbers. 2014-01-24 22:37:39 +01:00
Bobby Smiles
75478e6d36 Replace C++ comments with C comments 2014-01-24 22:24:37 +01:00
Bobby Smiles
db692a30c0 Implement RESAMPLE_ZOH audio command.
It fixes the garbled sound when switching from/to headset mode in 1080 Snowboarding.
2014-01-24 22:19:51 +01:00
Bobby Smiles
41f50000bb Implement POLEF audio command.
It fixes the ramping sound during PilotWings intro.
2014-01-24 22:01:00 +01:00
Bobby Smiles
d85e978bb8 Implement audio command #16 for NEAD ucodes.
It fixes some garbled sound at the start of a race in Wave Race for instance.
2014-01-24 21:20:27 +01:00
Bobby Smiles
3837e75ad7 Split ucode2 into 11 different versions. 2014-01-24 20:59:20 +01:00
Bobby Smiles
bdd2059ad8 Split ucode3 into 5 different versions. 2014-01-24 20:59:20 +01:00
Bobby Smiles
8e23cd4ace Split ucode1 into 3 different versions. 2014-01-24 20:59:20 +01:00
Richard Goedeken
fb55d79041 Merge pull request #9 from bsmiles32/alist_refactoring
Alist refactoring
2014-01-23 21:56:00 -08:00
Bobby Smiles
3f7ff35aad Remove dummy assignment. 2014-01-23 20:49:11 +01:00
Bobby Smiles
378f1b4980 BufferSpace doesn't need to be global anymore. 2014-01-23 20:49:11 +01:00
Bobby Smiles
dc65825033 Extract alist_filter logic. 2014-01-23 20:49:11 +01:00
Bobby Smiles
032b726efb Refactor alist_envmix_lin. 2014-01-23 20:49:11 +01:00
Bobby Smiles
4b0378f642 Refactor alist_envmix_nead. 2014-01-23 20:49:11 +01:00
Bobby Smiles
7ed91e5fba Refactor alist_envmix_exp. 2014-01-23 20:48:57 +01:00
Richard Goedeken
7a9d702eaf Merge pull request #8 from bsmiles32/fix_setvol
Fix regression introduced by commit f1707b5
2014-01-20 22:12:31 -08:00
Bobby Smiles
99cd087579 Fix regression introduced by commit f1707b5 2014-01-20 19:56:09 +01:00
Richard Goedeken
9315b9f34d Merge pull request #7 from bsmiles32/ucode_separation
First pass of audio ucodes refactoring.
2014-01-19 09:14:49 -08:00
Bobby Smiles
f519a35e12 Refactor alist duplicate2. 2014-01-18 19:07:11 +01:00
Bobby Smiles
84d69b9ada Refactor alist interl2. 2014-01-18 18:54:35 +01:00
Bobby Smiles
0f24d6dd6f Refactor alist addmixer. 2014-01-18 18:42:58 +01:00
Bobby Smiles
433a570c05 Refactor alist hilogain. 2014-01-18 18:32:12 +01:00
Bobby Smiles
f695303e23 Fix: forgot a header for size_t. 2014-01-18 15:27:03 +01:00
Bobby Smiles
85a994cdc1 Update copyrights. 2014-01-18 15:21:24 +01:00
Bobby Smiles
68dfb41b80 Move align function to hle.h 2014-01-18 15:17:08 +01:00
Bobby Smiles
3921889f3b Share some ADPCM bits as well. 2014-01-18 15:14:46 +01:00
Bobby Smiles
1b713d92a1 Share RESAMPLE_LUT between alist based ucodes and musyx ucodes.
I also corrected the size of RESAMPLE_LUT which was bigger than needed.
2014-01-18 15:04:00 +01:00
Bobby Smiles
350360de46 Remove some comments. 2014-01-18 14:50:22 +01:00
Bobby Smiles
3bd4166cae Refactor alist setbuff commands. 2014-01-18 14:47:05 +01:00
Bobby Smiles
f1707b5d45 Refactor alist setvol commands. 2014-01-18 14:43:34 +01:00
Bobby Smiles
7fdab9701c Refactor alist loadadpcm commands. 2014-01-18 14:35:24 +01:00
Bobby Smiles
9e00afd7e2 Remove uneeded macro. 2014-01-18 14:26:56 +01:00
Bobby Smiles
df518b6317 Refactor alist adpcm commands. 2014-01-18 14:20:49 +01:00
Richard Goedeken
cb8de21803 Merge pull request #6 from bsmiles32/fix_normal_task_dispatching
Fix regression introduced by commit 488e73c
2014-01-17 22:36:49 -08:00
Bobby Smiles
6f2fd295cc Refactor alist resample commands. 2014-01-18 03:31:08 +01:00
Bobby Smiles
3584be1d1c Refactor alist clear commands. 2014-01-18 03:29:02 +01:00
Bobby Smiles
39f854b3e1 Refactor alist load/save commands. 2014-01-18 01:51:07 +01:00
Bobby Smiles
95ca916c49 Refactor alist move commands. 2014-01-18 01:33:40 +01:00
Bobby Smiles
09e166e4f9 Refactor alist mix commands. 2014-01-18 01:19:44 +01:00
Bobby Smiles
6b54565dde Refactor alist interleave commands. 2014-01-18 01:02:27 +01:00
Bobby Smiles
03a5dbce46 Rename inst{1,2} to w{1,2}. 2014-01-17 22:27:52 +01:00
Bobby Smiles
8cc0ddd027 Remove uneeded headers. 2014-01-17 22:23:57 +01:00
Bobby Smiles
d7cd56382d Move MP3 declaration to ucode3. 2014-01-17 22:09:03 +01:00
Bobby Smiles
788f21043a Move each alist_process_* to their respective file. 2014-01-17 22:04:33 +01:00
Bobby Smiles
e54e1cbeaa Pack each ucode state into a local structure. 2014-01-17 21:47:35 +01:00
Bobby Smiles
51d2dd95e6 hleMixerWorkArea doesn't need to be global. 2014-01-17 21:14:24 +01:00
Bobby Smiles
2f7e184038 Move BufferSpace to alist.c and alist_internal.h 2014-01-17 21:08:47 +01:00
Bobby Smiles
c02c0b7af5 Improve audio ucode identification.
Previously, alist based ucodes were classified as either ABI1, ABI2 or ABI3.
This classification is too simple to take into account all versions/revisions
that really exist in the wild. Furthermore, it prevents from implementing some
version/revision specific behaviors.

There are indeed 3 big "families" of alist based ucodes:
-ABI1 (or audio) which seems to be the very first version developed.
It was distributed to 3rd party devs and is the most common.
2 minor revisions were made by Rare for GoldenEye, BlastCorp and DiddyKongRacing.

-ABI3 (or naudio) which is the later revision.
It was as distributed to 3rd party devs as well and is the second most common.
4 revisions were made by Rare for BanjoKazooie, DonkeyKong, BanjoTooie, JetForceGemini,
MickeySpeedway, PerfectDark and ConkerBadFurDay.

-ABI2 (or what I'd call NEAD) which was Nintendo Entertainment Analysis & Development exclusive.
There are many versions/revisions in this category (almost one for each game they developed).

This commit try to better identify audio ucodes.
2014-01-17 19:51:53 +01:00
Bobby Smiles
f910e3b4ee Fix regression introduced by commit 488e73c 2014-01-17 19:18:55 +01:00
Richard Goedeken
4a00ea8fb2 Merge pull request #5 from bsmiles32/master
Consolidate memory accesses
2014-01-16 16:52:35 -08:00
Bobby Smiles
99c46ef83f Prefer memory access primitives over struct OSTask_t.
Structure fields alignment is compiler dependent and therefore can be fragile.
We replace all occurences of OSTask_t structure by memory access primitives.
2014-01-14 23:19:47 +01:00
Bobby Smiles
abad8fca0c Use dram access primitives in alist.c 2014-01-14 23:19:47 +01:00
Bobby Smiles
488e73cf0b Use dram access primitives for remaining cases in main.c 2014-01-14 23:19:47 +01:00
Bobby Smiles
bdb4733f33 Rewrite audio ucode identification using the new RDRAM access primitives. 2014-01-14 23:19:47 +01:00
Bobby Smiles
757a12729f Remove duplication of memory access functions between jpeg and musyx modules. 2014-01-14 23:19:47 +01:00
Richard Goedeken
109ce2817f Merge pull request #4 from ecsv/musyx
Implement SFX stage for musyx ucode (on nocpp branch)
2014-01-05 16:38:48 -08:00
Richard Goedeken
7c28bc8467 Merge pull request #3 from ecsv/nocpp
Add additional cleanup changes
2014-01-05 16:38:06 -08:00
Bobby Smiles
c7bec87096 Implement SFX stage for musyx ucode.
With this patch, delay-based effects should work.
Basically, the SFX stage mixes up to 8 delayed subframes together and add the
resulting subframe to left and right subframes. Furthermore, a filtered version
of this subframe is used to update the sample history.

Games that use the SFX stage include:
The World is not Enough, Tarzan, Resident Evil 2, Polaris SnowCross

Musyx ucode implementation should now be complete !
2014-01-05 23:37:23 +01:00
Sven Eckelmann
8b50f92016 Use clamp_s16 to clamp values to int16_t range 2014-01-05 10:16:35 +01:00
Sven Eckelmann
026a2089c0 Cleanup oneline if statements 2013-12-30 23:13:15 +01:00
Sven Eckelmann
1646550dba Move longer comments to separate line before the code 2013-12-30 22:10:52 +01:00
Sven Eckelmann
53c9d39c7d Fix wrong code alignment on linestart 2013-12-30 21:52:34 +01:00
Sven Eckelmann
c43d08aed9 Replace C++ comments with C comments 2013-12-30 21:52:34 +01:00
Sven Eckelmann
c1519b84d9 Remove code which only exist as comment 2013-12-30 21:52:33 +01:00
Sven Eckelmann
27e1db3691 Remove unused extern declarations 2013-12-30 21:38:20 +01:00
Sven Eckelmann
2eb0061541 Remove dead assignments 2013-12-30 20:31:46 +01:00
Sven Eckelmann
8c7c556248 Only include what each source file needs 2013-12-30 20:31:45 +01:00
Sven Eckelmann
d7cf796208 Always use standard ISO C99 datatypes for sized variables 2013-12-30 20:31:45 +01:00
Sven Eckelmann
ce771d1026 Move shared MP3 symbol definition to header 2013-12-30 20:31:45 +01:00
Sven Eckelmann
1d4cd7db1d Move all extern definitions to the header files 2013-12-30 20:31:45 +01:00
Sven Eckelmann
0437601e5f Mark only locally used symbols as static 2013-12-30 20:31:45 +01:00
Sven Eckelmann
a9cdda0ae3 Add missing includes for global declaration 2013-12-30 20:31:45 +01:00
Sven Eckelmann
3930a84625 Fix function declaration for functions without parameter 2013-12-30 20:31:45 +01:00
Sven Eckelmann
6e12c395f3 Don't mix declaration and code
C90 only supports variable declaration at the beginning of a scope. Not doing
so will break builds in MSVC.
2013-12-30 18:12:28 +01:00
Sven Eckelmann
646ec921ec Compile ucode*.cpp as C source code
The ucodes are basically only C code and don't use C++ features. It is
therefore not necessary to build it with a C++ compiler.
2013-12-30 17:33:34 +01:00
Richard Goedeken
0434aeb741 Merge pull request #1 from ecsv/musyx
Add initial support for MusyX
2013-12-30 06:52:59 -08:00
Bobby Smiles
d31b8ea3ff Add initial support for MusyX 2013-12-30 14:43:47 +01:00
Sven Eckelmann
a2a06db57b Remove executable bit from C source files 2013-12-30 14:40:04 +01:00
Sven Eckelmann
2af0917440 Try to unify formatting of the source code 2013-12-30 14:40:04 +01:00
Sven Eckelmann
2032870995 Force line ending type for specific files
Different operation systems (Unix vs. Windows) use different line ending types.
It can easily happen that users from different systems edit files and replace
all line endings of a file with the system specific version. This screws up
diffs and makes merges harder.

Git can normalize line endings for specific files and avoid this problem.
Binary files should be marked to avoid accidentally normalization.
2013-12-19 14:19:07 +01:00
Sven Eckelmann
44170e4fdb Convert .hgignore to .gitignore 2013-12-19 14:13:38 +01:00
Bobby Smiles
6e2d80e413 Fix: Bottom of the 9th jpeg task dispatching. 2013-12-01 16:30:28 +01:00
Bobby Smiles
8979df7774 Refactor standard macroblock decoder. 2013-12-01 16:26:38 +01:00
Bobby Smiles
7f34cc8101 Avoid dynamic memory allocation for macroblocks. 2013-12-01 16:02:28 +01:00
Bobby Smiles
60ecc0ddfc Fix: macroblock memory allocation was bigger than needed. 2013-12-01 15:58:25 +01:00
Sven Eckelmann
ff2ab7f9ea Don't fail rebuild when header is removed
The *.d depends files for make just list the files used when building an
object file. Removing a file listed in such a dependency file causes make to
search for a way to recreate it. This usually cannot work because these files
aren't autogenerated.

The gcc option -MP can be used to generate empty rule for these files. Removing
a file in a dependency list will then execute this empty rule and continue with
the execution of the creation of the object file. This compilation process will
then automatically correct the dependency file.
2013-09-20 10:31:44 +02:00
richard42
a1edae31a9 simplify OSX platform detection in makefile using xcode-select. based on patch from John Pender 2013-07-08 07:35:00 -07:00
Richard Goedeken
7f24c1a989 Added tag 2.0 for changeset 14d7e6313077 2013-07-04 15:48:00 -07:00
Richard Goedeken
33f761c039 update version number to 2.0 2013-07-03 07:07:45 -07:00
Richard Goedeken
e8145aa598 update LICENSES 2013-06-27 22:46:26 -07:00
Richard Goedeken
18594a3253 update text files for upcoming 2.0 release 2013-06-26 22:47:36 -07:00
Richard Goedeken
630dfad2af tagged v2.0-rc2 2013-06-01 18:00:33 -07:00
richard42
d679f50109 Update msvc11 project file to visual studio 2012 (msvc11) 2013-06-01 07:57:15 -07:00
Richard Goedeken
fdabe2d07e merged heads 2013-05-30 21:55:28 -07:00
Riley Labrecque
239d1a8d8e Fixed compiling with MSVC 2013-05-30 09:33:20 +00:00
Sven Eckelmann
5704d656ae Enable Link-time optimization by default
The GCC introduced Link-time optimization in GCC 4.5 (2010-04-14). This should
be long enough available that interested users have upgraded to a compiler
supporting it.

The MSVC project already enabled WholeProgramOptimization since a long time.
Enabling it by default in GCC seems to be equally valid.
2013-05-11 11:25:53 +02:00
Sven Eckelmann
ba75d3506f Add CXXFLAGS to the linker step
The GCC manual states for different parameters that the options for compilation
must also be used when linking. The options for compilation are stored in
CXXFLAGS and added to LINK.o to fix the behavior.

Option which need this are for example -fPIC/-fPIE or -flto.
2013-05-11 10:56:08 +02:00
Bobby Smiles
82e6d79eaa Private mp3 related variables should be static. 2013-04-01 04:25:36 +02:00
Bobby Smiles
9e7a280cdf Add support for MusyX ucode detection. 2013-04-01 02:47:04 +02:00
Bobby Smiles
53577ef3eb Named some constants. 2013-04-01 02:14:10 +02:00
Bobby Smiles
1e8950ae88 Use static typed value instead of macro for IDCT related constant. 2013-03-21 19:34:32 +01:00
Richard Goedeken
f510b07e1d add msvc11 project file from mudlord 2013-03-20 22:26:27 -07:00
Richard Goedeken
d9bb882463 merged heads 2013-03-14 22:42:20 -07:00
Sven Eckelmann
ea771b3880 Revert "Enable link time garbage collection when link time optimization is enabled"
Some linker on different platforms don't handle the garbage collection
correctly and create extreme bloated binaries. Therefore, leave it to the user
to enable this feature or not.
2013-03-14 08:01:55 +01:00
Bobby Smiles
4945f56876 Refactor common jpeg decoding ucode. 2013-03-12 19:58:57 +01:00
Bobby Smiles
eb911442c2 Remove hack from jpeg code.
When I developped the original implementation of Pokemon Stadium Japan jpeg decoding ucode
I tested it with Rice video plugin and cheated a little bit to get some sensible results
(I changed the UV rescaling a bit and perform erroneous Y1Y2 swapping). Other video plugin
didn't support YUV16 texture format so comparison wasn't possible.
Recently, I played a little bit with Glide64mk2 and noticed that without aformentionned hacks
the jpeg decoding was performing successfully. That's why I think there is a bug in Rice plugin
and that I can delete my hack from jpeg decoding ucode.
2013-03-12 19:41:37 +01:00
Bobby Smiles
95deae759a Made private envmixer related variables static. 2013-03-11 21:59:58 +01:00
Bobby Smiles
827df7cba4 Made ResampleLUT const 2013-03-11 21:57:24 +01:00
Bobby Smiles
8573c1b2de Made DeWindowLUT const. 2013-03-11 21:10:32 +01:00
Bobby Smiles
4ceaf285f7 Make ABI arrays const. 2013-03-11 20:49:45 +01:00
Bobby Smiles
d57a1a5702 Get rid of global variables inst1 and inst2. 2013-03-11 20:42:31 +01:00
Bobby Smiles
1c8211afc3 Renammed acmd_t to acmd_callback_t. 2013-03-11 20:24:38 +01:00
Bobby Smiles
d501c4e38e Rewrite cicx105_ucode to allow better optimisation. Move it outside of main.
Note: During the rewriting I changed the number of line to write from 0xfc to 0x18 because that's
what I saw in the ipl3 disassembly.
2013-03-10 02:45:53 +01:00
Bobby Smiles
2fd59b9492 Add some comments 2013-03-10 01:54:20 +01:00
Bobby Smiles
a6a2ff4a95 FORWARD_* constants are uppercase. 2013-03-10 01:34:45 +01:00
Bobby Smiles
cfcfe45089 enforce const correctness no local helper functions. (+ trailing hitespace cleaning) 2013-03-10 01:32:35 +01:00
Bobby Smiles
1280d7aa00 Use standard memset instead of handcrafted loop. 2013-03-10 01:23:24 +01:00
Bobby Smiles
f6eca7ba4a Refactoring taskdone. 2013-03-10 01:19:11 +01:00
Bobby Smiles
28365d26db Reworked rsp execution to improve readability and performances. 2013-03-10 01:06:46 +01:00
Bobby Smiles
e68b5b833a Extract unknown task/non_task handlers from DoRspCycles. 2013-03-10 00:11:28 +01:00
Bobby Smiles
053dde0674 Some ucodes report a lower ucode_size than their real size, which causes underdump.
We now overdump by default by using the value 0xf80 used by rspboot ucode.
2013-03-10 00:03:05 +01:00
Bobby Smiles
1be2f3fe2e Extract some helper functions. 2013-03-09 23:54:53 +01:00
Bobby Smiles
852505046d Move alist logic into its own module. Corrected ABI1 and ABI3 sizes. 2013-03-09 23:35:08 +01:00
Bobby Smiles
35eec9a019 Use get_task function instead of passing OSTask_t pointer all over the call hierarchy. 2013-03-09 22:59:26 +01:00
Sven Eckelmann
d2d2b1e2c3 Fix non-C99 variable declarations 2013-02-17 17:54:07 +01:00
Sven Eckelmann
485a064c5e Enable link time garbage collection when link time optimization is enabled 2013-02-08 00:31:52 +01:00
Sven Eckelmann
2324ba13d9 Remove always true comparison 2013-02-08 00:30:27 +01:00
Bobby Smiles
7ff1b0620d Add support for Pokemon Stadium (Japan) jpeg decoding task. 2013-01-27 17:22:56 +01:00
Bobby Smiles
027c4cc2d8 Refactor jpeg module. 2013-01-27 17:19:58 +01:00
richard42
7ef526534d OSX build fix 2013-02-02 22:23:17 -08:00
Sven Eckelmann
1b238c5176 Introduce WARNFLAGS for default (removable) compiler warning flags 2013-01-02 16:13:45 +01:00
Sven Eckelmann
2ff7710657 Disable PIC on MinGW to reduce warnings 2013-01-01 00:30:34 +01:00
n pepinpe
a640dd3ac3 Fix path to OSX SDK with XCode >=4.3 2012-12-31 10:43:00 +01:00
Sven Eckelmann
9a922cdc78 Use $(OBJDIR) in clean target instead of hardcoded path 2012-12-13 14:53:05 +01:00
Sven Eckelmann
ea51d4457d Allow to add a postfix for each build
The POSTFIX make option is useful for distributions to compile different
versions of the plugin in parallel. The object files will be stored in a
directory with the postfix appended and the linker result will also have this
postfix appended.
2012-12-13 14:47:30 +01:00
Sven Eckelmann
61708f6588 Add CROSS_COMPILE make option
The CROSS_COMPILE make option can be used to automatically prepend the prefix
to all build relevant tools to seamlessly allow cross compilation without
setting each tool name separately.

Cross compiling for MinGW32 would can be done using
$ make -C projects/unix/ CROSS_COMPILE=i686-pc-mingw32- HOST_CPU=i686 UNAME=MINGW
2012-12-13 12:25:33 +01:00
Sven Eckelmann
8c7c887323 Synchronize usage of environmental variables for UNAME with HOST_CPU 2012-12-13 10:52:49 +01:00
Sven Eckelmann
de60447518 Remove duplicated definition of CC for MinGW 2012-12-13 10:46:17 +01:00
veganaize
06d5023d96 Add support for MingW32 2012-12-04 21:17:52 +01:00
Richard Goedeken
71ad85d3fc merge with no changes 2012-11-12 21:33:36 -08:00
Anthony J. Bentley
3a7a5b435a Detect OpenBSD PowerPC platforms macppc and socppc. 2012-11-12 18:03:16 -07:00
Sven Eckelmann
e19f1138b6 Avoid out of bounds access of audio ABI callback array 2012-11-12 10:52:10 +01:00
Sven Eckelmann
e080396a73 Add configuration for semi-supported architecture armel 2012-11-04 01:26:09 +01:00
Richard Goedeken
406e6f43f0 fix for Twintris PD ROM from Bobby Smiles 2012-07-21 15:19:32 -07:00
Richard Goedeken
ce1a747b95 build fix for windows 2012-06-24 11:33:42 -07:00
Sven Eckelmann
524369cf8c Enable experimental support for link-time optimization 2012-06-09 00:56:33 +02:00
Bobby Smiles
0f1311e95b Made a mistake while rewriting ps_jpg_uncompress resulting in corrupted graphics in Zelda OOT.
Readded jpeg task 278 used during Zelda OOT boot.
2012-03-31 16:37:50 +02:00
Bobby Smiles
9e6782ff2a Slighltly changed the checksum range [it is now min(0x780,task->ucode_size) / 2].
Typo (dump_binray -> dump_binary)
2012-03-18 18:23:43 +01:00
Bobby Smiles
82d579f56c Refactor DoRspCycles to improve clarity.
Improve RSP task dumping process.
Fix Pokemon Stadium missing sound.
2012-03-18 15:11:35 +01:00
Richard Goedeken
3427083f87 makefile change from Auria: add new linker flag in 32-bit build under OSX 2012-03-11 14:23:06 -07:00
Richard Goedeken
7c37099675 Added tag 1.99.5 for changeset 96e3e8cb2691 2012-03-10 10:29:41 -08:00
Richard Goedeken
008a27fe58 updating version and release info for v1.99.5 tag 2012-03-10 09:54:03 -08:00
richard42
b03da51141 1. Added idct.c to MSVC8 project file
2. Removed inline attributes which throw errors in MSVC8.  This is needed for modern compilers; they know when to inline
3. Fixed errors caused by MSVC8's incompatibility with C99 local variable declarations
2012-03-06 20:39:00 -08:00
Bobby Smiles
11d6b4a95b Previous commits about jpg decompression didn't set the SP_STATUS_REG properly 2012-03-04 19:23:26 +01:00
Richard Goedeken
42ead67818 changeset: 74:c9213baac086
tag: tip
user: Bobby Smiles <bobby.smiles32@gmail.com>
date: Sat Mar 03 17:58:14 2012 +0100
files: src/hle.h src/jpeg.c src/main.c
description:

Reformulate jpg decompression, add support for subsampling mode 0.
Use proper indentation
2012-03-04 09:08:03 -08:00
Richard Goedeken
a71af44e9e remove me and Hacktarux from copyright of idct.c 2012-02-26 07:03:14 -08:00
Richard Goedeken
dabd03e12a changed tabs to spaces 2012-02-25 19:49:29 -08:00
Richard Goedeken
a68c319d70 jpeg decompression message should be verbose 2012-02-25 19:48:14 -08:00
Bobby Smiles
250a1c9c53 Fix issue 102: Missing backgrounds in Ogre Battle 2012-02-25 18:39:00 +01:00
Sven Eckelmann
86dbd899c5 Remove additional -O3 on MacOSX 2011-10-14 19:58:42 +02:00
Sven Eckelmann
dbd121297a Explicitly disable PIC in case of PIC=0 2011-10-13 00:01:02 +02:00
Sven Eckelmann
e00df5ead4 Ignore generated files in hg-status 2011-08-29 14:30:47 +02:00
Sven Eckelmann
8acf7284ad Enable ppc(64) as experimental target
nogagplz tested mupen64plus on 32-bit ppc and didn't detect any big show
stoppers with interpreter cores and the mupen64plus example rom. This makes the
PowerPC an interesting target for further tests and may reveal other endianness
problems.
2011-08-05 10:46:15 +02:00
Sven Eckelmann
020eaf23cf Enable PIC depending on architecture instead of bits only
nogagplz noticed on ppc32 that PIC is necessary to compile everything as shared
object. Therefore, it seems to be a better idea to have architecture specific
PIC default settings instead of checking only whether it is a 32 or 64 bit
architecture.
2011-08-05 10:32:06 +02:00
Sven Eckelmann
b7c2b96cf4 Enable big endian mode on ppc and ppc64 2011-08-05 10:19:20 +02:00
Sven Eckelmann
ec0764de4c Strip binaries during install 2011-07-23 21:22:52 +02:00
Sven Eckelmann
922c92d7f7 Allow to force PIC to remove text relocations 2011-07-10 13:37:54 +02:00
Sven Eckelmann
de9ac5d32a Fix linker search for libstdc++.so 2011-07-08 08:24:34 +00:00
Sven Eckelmann
a69ddf44a3 Inform user about the possibility to make the build verbose 2011-07-03 18:04:48 +02:00
Sven Eckelmann
c4bb721803 Set changeable default compiler optimization option 2011-07-03 18:03:15 +02:00
Sven Eckelmann
92299081d7 Synchronize build rules with standard gnu make rules 2011-06-27 13:00:04 +02:00
Sven Eckelmann
cecd7d7aec Don't use _BIG_ENDIAN to check for endianness as it is always set on OpenBSD 2011-06-26 20:18:10 +02:00
Sven Eckelmann
2e78aa62e7 Add OpenBSD as half-supported OS with FreeBSD userspace tools 2011-06-26 18:37:19 +02:00
Sven Eckelmann
b62e8f32e8 Remove -v parameter of install which is not available everywhere 2011-06-26 18:29:25 +02:00
Sven Eckelmann
80c6392a30 Split LIBDIR in LIBDIR and PLUGINDIR for consistency between modules 2011-06-26 02:05:06 +02:00
Sven Eckelmann
669924c423 Mark local only functions as static or fix their definition 2011-06-25 23:25:42 +02:00
Sven Eckelmann
a2c127fa8e Fix compilation with BITS=32 when using gcc-4.6 2011-06-25 21:29:58 +02:00
Sven Eckelmann
fbde184448 Use function prototypes defined by core 2011-06-25 21:23:47 +02:00
Sven Eckelmann
573e459e3d Remove unused variable inpinc 2011-06-25 17:19:52 +02:00
Sven Eckelmann
b4e58f9962 Remove unused function ENVMIXER3(o) 2011-06-25 17:18:53 +02:00
Sven Eckelmann
c64838a72a Add parentheses around arithmetic in operand of ‘^’ 2011-06-25 17:17:31 +02:00
Sven Eckelmann
6e6cd68280 Remove unneccessary define PIC 2011-06-25 15:09:32 +02:00
Sven Eckelmann
7729ebd122 Don't override optimisations set by linux build environment 2011-06-25 14:23:45 +02:00
Richard Goedeken
f6a132b985 updated RSP plugin for new Mupen64plus 2.0 API versioning scheme 2011-05-16 21:48:06 -07:00
Richard Goedeken
078008a77b Added tag 1.99.4 for changeset fe05d2adfbc1 2010-11-22 20:57:53 -05:00
42 changed files with 8214 additions and 4700 deletions

38
.gitattributes vendored Normal file
View file

@ -0,0 +1,38 @@
* text=auto
# normal text files
*.6 text
AUTHORS text
*.c text
*.cfg text
*.cht text
*.conf text
COPYING text
*.cpp text
*.def text
*-license text
*.h text
*.html text
*.ini text
INSTALL text
LICENSES text
Makefile text
*.py text
README text
RELEASE text
*.S text
*.sh text
*.txt text
*.ver text
# windows specific text files
*.sln text eol=crlf
*.vcproj text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
# binary files
*.gz binary
*.ttf binary
cursor.tex binary
font.tex binary

152
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,152 @@
name: HLE RSP
on:
push:
paths-ignore:
- '.{gitattributes,gitignore,travis.yml}'
- '*.md,appveyor.yml,README'
pull_request:
paths-ignore:
- '.{gitattributes,gitignore,travis.yml}'
- '*.md,appveyor.yml,README'
workflow_dispatch:
jobs:
Linux:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
- cc: GCC
arch: x86
- cc: Clang
arch: x64
- cc: Clang
arch: x86
name: Linux / ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get build dependencies and arrange the environment
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
./../mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Build and related stuff, backup binaries
run: |
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
./../mupen64plus-core/.github/workflows/scripts/ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} makepkg
- name: Upload artifact
if: matrix.cc == 'GCC'
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*.tar.gz
MSYS2:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
cross: x86_64
env: MINGW64
- cc: GCC
arch: x86
cross: i686
env: MINGW32
name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: windows-2022
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.env }}
update: true
install: >-
git
libtool
make
mingw-w64-${{ matrix.cross }}-gcc
mingw-w64-${{ matrix.cross }}-toolchain
mingw-w64-${{ matrix.cross }}-ntldd
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
./../mupen64plus-core/.github/workflows/scripts/ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Backup dependencies, etc...
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh ${{ matrix.env }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
MSVC:
strategy:
fail-fast: false
matrix:
include:
- toolset: v143
arch: x64
vs: 2022
- toolset: v141_xp
arch: x86
vs: 2019
name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.arch }}
runs-on: windows-${{ matrix.vs }}
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ..\mupen64plus-core
set TOOLSET=${{ matrix.toolset }}
.\..\mupen64plus-core\.github\workflows\scripts\ci_msvc_build.cmd ${{ matrix.arch }}
- name: Backup dependencies, etc...
run: |
.\..\mupen64plus-core\.github\workflows\scripts\ci_backup_msvc_deps.cmd ${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
Nightly-build:
runs-on: ubuntu-latest
if: github.ref_name == 'master'
needs: [Linux, MSYS2, MSVC]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries
- name: Get some tools
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
sudo apt-get update
sudo apt-get -y install hashdeep
- name: Creating new artifacts and update nightly-build
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh
- name: Nightly-build
uses: ncipollo/release-action@v1
with:
prerelease: true
allowUpdates: true
removeArtifacts: true
replacesArtifacts: false
tag: nightly-build
artifacts: pkg/*

148
.github/workflows/schedule.yml vendored Normal file
View file

@ -0,0 +1,148 @@
name: HLE RSP - Scheduled
on:
schedule:
- cron: '30 14 21 * *'
jobs:
Linux:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
- cc: GCC
arch: x86
- cc: Clang
arch: x64
- cc: Clang
arch: x86
name: Linux / ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: ubuntu-22.04
if: github.repository == 'mupen64plus/mupen64plus-rsp-hle'
steps:
- uses: actions/checkout@v4
- name: Get build dependencies and arrange the environment
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
./../mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Build and related stuff, backup binaries
run: |
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
./../mupen64plus-core/.github/workflows/scripts/ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} makepkg
- name: Upload artifact
if: matrix.cc == 'GCC'
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*.tar.gz
MSYS2:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
cross: x86_64
env: MINGW64
- cc: GCC
arch: x86
cross: i686
env: MINGW32
name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: windows-2022
if: github.repository == 'mupen64plus/mupen64plus-rsp-hle'
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.env }}
update: true
install: >-
git
libtool
make
mingw-w64-${{ matrix.cross }}-gcc
mingw-w64-${{ matrix.cross }}-toolchain
mingw-w64-${{ matrix.cross }}-ntldd
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
./../mupen64plus-core/.github/workflows/scripts/ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Backup dependencies, etc...
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh ${{ matrix.env }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
MSVC:
strategy:
fail-fast: false
matrix:
include:
- toolset: v143
arch: x64
vs: 2022
- toolset: v141_xp
arch: x86
vs: 2019
name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.arch }}
runs-on: windows-${{ matrix.vs }}
if: github.repository == 'mupen64plus/mupen64plus-rsp-hle'
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ..\mupen64plus-core
set TOOLSET=${{ matrix.toolset }}
.\..\mupen64plus-core\.github\workflows\scripts\ci_msvc_build.cmd ${{ matrix.arch }}
- name: Backup dependencies, etc...
run: |
.\..\mupen64plus-core\.github\workflows\scripts\ci_backup_msvc_deps.cmd ${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
Nightly-build:
runs-on: ubuntu-latest
if: github.ref_name == 'master'
needs: [Linux, MSYS2, MSVC]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries
- name: Get some tools
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
sudo apt-get update
sudo apt-get -y install hashdeep
- name: Creating new artifacts and update nightly-build
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh
- name: Nightly-build
uses: ncipollo/release-action@v1
with:
prerelease: true
allowUpdates: true
removeArtifacts: true
replacesArtifacts: false
tag: nightly-build
artifacts: pkg/*

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/projects/unix/_obj*/
/projects/unix/mupen64plus-rsp-hle*.so

46
.travis.yml Normal file
View file

@ -0,0 +1,46 @@
sudo: required
dist: xenial
language: cpp
compiler:
- gcc
- clang
addons:
apt:
packages:
- git
before_install:
- git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core
env:
- DUMP=0
- DUMP=1
script:
- make -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean && LDFLAGS="-Wl,--no-add-needed -Wl,--no-undefined" OPTFLAGS="-O2" make CC="${CC}" CXX="${CXX}" -j$(nproc) -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 all
# extra mxe build entries
matrix:
include:
- env:
- MXE_CPU=i686
- PATH="/usr/lib/mxe/usr/bin/:$PATH"
before_install:
- curl -sSL "https://mirror.mxe.cc/repos/apt/client-conf/mxeapt.gpg" | sudo -E apt-key add -
- echo "deb https://mirror.mxe.cc/repos/apt xenial main" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update -qq
- sudo apt-get -y --allow-unauthenticated install mxe-i686-w64-mingw32.shared-gcc
- git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core
script:
- make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean &&
make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 -j$(nproc) all
- env:
- MXE_CPU=x86_64
- PATH="/usr/lib/mxe/usr/bin/:$PATH"
before_install:
- curl -sSL "https://mirror.mxe.cc/repos/apt/client-conf/mxeapt.gpg" | sudo -E apt-key add -
- echo "deb https://mirror.mxe.cc/repos/apt xenial main" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update -qq
- sudo apt-get -y --allow-unauthenticated install mxe-x86-64-w64-mingw32.shared-gcc
- git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core
script:
- make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean &&
make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 -j$(nproc) all

View file

@ -3,8 +3,10 @@ Mupen64Plus-rsp-hle LICENSE
Mupen64Plus-rsp-hle is licensed under the GNU General Public License version 2.
The authors of Mupen64Plus are:
The authors of Mupen64Plus-rsp-hle are:
* Richard Goedeken (Richard42)
* Bobby Smiles (bsmiles32)
* Sven Eckelmann (ecsv)
* John Chadwick (NMN)
* James Hood (Ebenblues)
* Scott Gorman (okaygo)
@ -28,7 +30,7 @@ Mupen64Plus is based on GPL-licensed source code from Mupen64 v0.5, originally w
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

93
RELEASE
View file

@ -1,6 +1,99 @@
RSP High-Level Emulation plugin for Mupen64Plus
-----------------------------------------------
--------------------------------------------
# Mupen64Plus-rsp-hle v2.6.0 - July 14, 2024
## Merged PRs
* [90](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/90): CI/CD: Update to generic scripts, independent schedule, etc
* [89](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/89): Fix check for M64P_BIG_ENDIAN
* [88](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/88): CI/CD: Add BLAKE2 hashfile
* [87](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/87): CI/CD: Integrate scheduled builds and other...
* [86](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/86): CI/CD: Update MSVC
* [85](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/85): CI/CD: Update
* [84](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/84): Added overload distortion effect, used by a few tracks in CBFD
* [83](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/83): Fix out of bounds memory access encountered in CBFD
* [82](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/82): CI/CD: Implement GitHub Actions and public nightly builds
* [81](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/81): Add RISC-V Support
* [80](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/80): build: Allow out of tree builds.
* [79](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/79): Fix undefined behavior
* [77](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/77): Allow non-default compilers without resorting to symbolic links
* [76](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/76): Allow to set custom platform toolset from commands
* [75](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/75): AppVeyor with artifact packaging
* [74](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/74): Fix HQVM implementation
* [73](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/73): Rework task dispatching implementation
* [72](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/72): Changes to have more generic project files
* [70](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/70): Implement HVQM ucode
* [69](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/69): Integrate Hvqm preliminary work (not fully functional yet)
* [68](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/68): Added ppc64le support
## Top Contributors (2 or more commits)
1. Jj0YzL5nvJ
2. richard42
3. Gillou68310
4. derselbst
------------------------------------------------
# Mupen64Plus-rsp-hle v2.5.9 - February 10, 2019
## Merged PRs
* [67](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/67): Remove use of ConfigSaveSection
* [66](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/66): Makefile aarch64
* [65](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/65): Indi and Naboo now have an HLE implementation
* [64](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/64): Remove WDC and Stunt Racer from LLE list
* [63](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/63): Update homepage links
* [62](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/62): Don't set MI_INTR_SP if task is not finished yet
* [61](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/61): Implement RE2 fill video double buffer ucode
* [60](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/60): Update jpeg.c
* [59](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/59): If DEBUG not set, set NDEBUG
* [58](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/58): Build MXE targets as additional tests in travis build matrix
* [54](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/54): Implement RSP fallback.
* [53](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/53): Implement RE2 video frame decoding ucode
* [52](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/52): specify audio ucode flags explicitly
* [51](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/51): Let each ucode specify how sp status should be modified.
* [47](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/47): Prevent yet one more illegal access to alist_buffer
* [46](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/46): Add support for Re2 bilinear resizing
* [45](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/45): Prevent more illegal accesses of alist_buffer
* [44](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/44): Prevent CLEARBUFF for naudio and nead from deriving a count too big for alist_buffer
* [43](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/43): Backport fixes from Project64
* [42](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/42): Use faster container based Travis CI
* [41](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/41): Use Ubuntu Trusty as base system for Travis CI
* [40](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/40): Backports from project64
* [38](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/38): Added x64 configuration to VisualStudio2013 project file
* [37](https://github.com/mupen64plus/mupen64plus-rsp-hle/pull/37): Remove unnecessary OpenBSD warning.
Mupen64Plus-rsp-hle v2.5 - April 26, 2015
-------------------------------------------------
- Game-specific fixes: Bottom of the 9th, IndianaJones, BattleForNaboo, Conkers Bad Fur Day
- Support for MusyX microcodes
- Improve audio microcode identification
- Huge quantity of code cleanups and refactoring to improve organization
- Add support for additional audio commands: #16, POLEF, RESAMPLE_ZOH
- Multiple bugfixes in audio processing code
- Move global variables into a struct so code is re-entrant
- bugfix: microcode detection could sometimes fail after reset
Mupen64Plus-rsp-hle v2.0 - July 4, 2013
-------------------------------------------------
- Add support for MusyX ucode detection
- support JPEG decoding used in Pokemon Stadium Japan
- lots of refactoring to clean up code
- Project files for Visual Studio 2012
- Makefile changes
- add support for PowerPC and MinGW32 builds
- add cross-compiling support to build Win32 executables (MXE) under Linux
Mupen64Plus-rsp-hle v1.99.5 - March 10, 2012
-------------------------------------------------
- Handle JPEG decompression, used in Ogre Battle 64 and Pokemon Stadium
- updated RSP plugin for new Mupen64plus 2.0 API versioning scheme
- bugfix: #102 - Missing backgrounds in Ogre Battle 64
- many makefile fixes and improvements
Mupen64Plus-rsp-hle v1.99.4 - November 22, 2010
-------------------------------------------------
- merged all big-endian fixes from mupen64gc project

40
appveyor.yml Normal file
View file

@ -0,0 +1,40 @@
version: 1.0.{build}
image: Visual Studio 2022
skip_tags: true
skip_commits:
files:
- '**/*.md'
- .github/
- data/*
- .gitattributes
- .gitignore
- .travis.yml
- README
configuration:
- Release
platform:
- Win32
- x64
before_build:
- git tag --delete nightly-build
- git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ..\mupen64plus-core
build_script:
- msbuild projects\msvc\mupen64plus-rsp-hle.vcxproj /p:Configuration=%configuration%;Platform=%platform%
after_build:
- ps: $env:rev1 = git describe --tags
- set rev2=%platform%
- if "%rev2%"=="Win32" set rev2=x86
- set filepkg=mupen64plus-rsp-hle_v%rev1%_%rev2%
- cd projects\msvc\%platform%\%configuration%
- 7z a -t7z ..\..\..\..\build\%filepkg%.7z *.dll
artifacts:
- path: build\$(filepkg).7z
name: $(filepkg)

View file

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2EC7CEE3-C7A7-4F2E-B2C8-4DF6AFEC3E9A}</ProjectGuid>
<RootNamespace>mupen64plusrsphle</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'=='' and '$(VisualStudioVersion)' != '14.0'">
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
<TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(PlatformToolset)'=='' or '$(PlatformToolset)'=='v100'" Label="Configuration">
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\mupen64plus-core\src\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\mupen64plus-core\src\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\mupen64plus-core\src\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\mupen64plus-core\src\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\alist.c" />
<ClCompile Include="..\..\src\alist_audio.c" />
<ClCompile Include="..\..\src\alist_naudio.c" />
<ClCompile Include="..\..\src\alist_nead.c" />
<ClCompile Include="..\..\src\audio.c" />
<ClCompile Include="..\..\src\cicx105.c" />
<ClCompile Include="..\..\src\hle.c" />
<ClCompile Include="..\..\src\hvqm.c" />
<ClCompile Include="..\..\src\jpeg.c" />
<ClCompile Include="..\..\src\memory.c" />
<ClCompile Include="..\..\src\mp3.c" />
<ClCompile Include="..\..\src\musyx.c" />
<ClCompile Include="..\..\src\osal_dynamiclib_win32.c" />
<ClCompile Include="..\..\src\plugin.c" />
<ClCompile Include="..\..\src\re2.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\alist.h" />
<ClInclude Include="..\..\src\arithmetics.h" />
<ClInclude Include="..\..\src\audio.h" />
<ClInclude Include="..\..\src\common.h" />
<ClInclude Include="..\..\src\hle.h" />
<ClInclude Include="..\..\src\hle_external.h" />
<ClInclude Include="..\..\src\hle_internal.h" />
<ClInclude Include="..\..\src\memory.h" />
<ClInclude Include="..\..\src\osal_dynamiclib.h" />
<ClInclude Include="..\..\src\ucodes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,219 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mupen64plus-rsp-hle"
ProjectGUID="{2EC7CEE3-C7A7-4F2E-B2C8-4DF6AFEC3E9A}"
RootNamespace="mupen64plusrsphle"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\mupen64plus-core\src\api"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\mupen64plus-core\src\api"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\src\jpeg.c"
>
</File>
<File
RelativePath="..\..\src\main.c"
>
</File>
<File
RelativePath="..\..\src\ucode1.cpp"
>
</File>
<File
RelativePath="..\..\src\ucode2.cpp"
>
</File>
<File
RelativePath="..\..\src\ucode3.cpp"
>
</File>
<File
RelativePath="..\..\src\ucode3mp3.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\src\hle.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -1,6 +1,6 @@
#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# * mupen64plus-rsp-hle - Makefile *
# * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
# * Mupen64Plus homepage: https://mupen64plus.org/ *
# * Copyright (C) 2008-2009 Richard Goedeken *
# * Copyright (C) 2007-2008 DarkJeztr Tillin9 *
# * *
@ -22,7 +22,7 @@
# Makefile for Mupen64 HLE RSP plugin in Mupen64plus.
# detect operating system
UNAME = $(shell uname -s)
UNAME ?= $(shell uname -s)
OS := NONE
ifeq ("$(UNAME)","Linux")
OS = LINUX
@ -49,13 +49,24 @@ ifeq ("$(UNAME)","FreeBSD")
SO_EXTENSION = so
SHARED = -shared
endif
ifeq ("$(UNAME)","OpenBSD")
OS = FREEBSD
SO_EXTENSION = so
SHARED = -shared
endif
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
OS = LINUX
SO_EXTENSION = so
SHARED = -shared
endif
ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW")
OS = MINGW
SO_EXTENSION = dll
SHARED = -shared
PIC = 0
endif
ifeq ("$(OS)","NONE")
$(error OS type "$(UNAME)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
$(error OS type "$(UNAME)" not supported. Please file bug report at 'https://github.com/mupen64plus/mupen64plus-core/issues')
endif
# detect system architecture
@ -66,71 +77,130 @@ ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
CPU := X86
ifeq ("$(BITS)", "32")
ARCH_DETECTED := 64BITS_32
PIC ?= 0
else
ARCH_DETECTED := 64BITS
PIC ?= 1
endif
endif
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
CPU := X86
ARCH_DETECTED := 32BITS
PIC ?= 0
endif
ifneq ("$(filter ppc macppc socppc powerpc,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 32BITS
BIG_ENDIAN := 1
PIC ?= 1
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 64BITS
BIG_ENDIAN := 1
PIC ?= 1
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
ifneq ("$(filter ppc64le powerpc64le,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 64BITS
BIG_ENDIAN := 0
PIC ?= 1
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
ifneq ("$(filter arm%,$(HOST_CPU))","")
ifeq ("$(filter arm%b,$(HOST_CPU))","")
CPU := ARM
ARCH_DETECTED := 32BITS
PIC ?= 1
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
endif
ifneq ("$(filter mips,$(HOST_CPU))","")
CPU := MIPS
ARCH_DETECTED := 32BITS
PIC ?= 1
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
ifneq ("$(filter aarch64,$(HOST_CPU))","")
CPU := AARCH
ARCH_DETECTED := 64BITS
PIC ?= 1
NEW_DYNAREC := 1
NO_ASM := 1
endif
ifneq ("$(filter riscv64,$(HOST_CPU))","")
CPU := RISCV64
ARCH_DETECTED := 64BITS
PIC ?= 1
NO_ASM := 1
$(warning Architecture "$(HOST_CPU)" not officially supported.)
endif
# PPC doesn't work yet
#ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
# CPU := PPC
# ARCH_DETECTED := 32BITS
#endif
#ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
# CPU := PPC
# ARCH_DETECTED := 64BITS
#endif
ifeq ("$(CPU)","NONE")
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'https://github.com/mupen64plus/mupen64plus-core/issues')
endif
# base CFLAGS, LIBS, and LDFLAGS
CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -fvisibility=hidden -I../../src
CXXFLAGS += -fvisibility-inlines-hidden
SRCDIR = ../../src
OBJDIR = _obj$(POSTFIX)
# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
# On 32-bit systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -fPIC -DPIC
# base CFLAGS, LDLIBS, and LDFLAGS
OPTFLAGS ?= -O3 -flto
WARNFLAGS ?= -Wall
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fvisibility=hidden -I$(SRCDIR)
LDFLAGS += $(SHARED)
# Since we are building a shared library, we must compile with -fPIC on some architectures
# On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
ifeq ($(PIC), 1)
CFLAGS += -fPIC
else
CFLAGS += -fno-PIC
endif
ifeq ($(BIG_ENDIAN), 1)
CFLAGS += -DM64P_BIG_ENDIAN
endif
# tweak flags for 32-bit build on 64-bit system
ifeq ($(ARCH_DETECTED), 64BITS_32)
ifeq ($(OS), FREEBSD)
$(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
endif
CFLAGS += -m32
LDFLAGS += -m32 -m elf_i386
ifneq ($(OS), OSX)
ifeq ($(OS), MINGW)
LDFLAGS += -Wl,-m,i386pe
else
CFLAGS += -m32
LDFLAGS += -Wl,-m,elf_i386
endif
endif
endif
ifeq ($(ARCH_DETECTED), 64BITS)
ifeq ($(OS), MINGW)
LDFLAGS += -Wl,-m,i386pep
endif
endif
# set special flags per-system
ifeq ($(OS), LINUX)
# only export api symbols
LDFLAGS += -Wl,-version-script,$(SRCDIR)/rsp_api_export.ver
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -pipe -O3 -march=athlon64
else
CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
endif
endif
LDLIBS += -ldl
endif
ifeq ($(OS), OSX)
OSX_SDK_PATH = $(shell xcrun --sdk macosx --show-sdk-path)
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -pipe -O3 -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
LDFLAGS += -arch x86_64
CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=10.9 -isysroot $(OSX_SDK_PATH)
else
CFLAGS += -pipe -O3 -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
LDFLAGS += -arch i686
CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.9 -isysroot $(OSX_SDK_PATH)
LDFLAGS += -read_only_relocs suppress
endif
endif
endif
ifeq ($(CPU), PPC)
CFLAGS += -mcpu=powerpc
endif
# set mupen64plus core API header path
ifneq ("$(APIDIR)","")
@ -154,20 +224,31 @@ else
endif
endif
# set shell function names
CC ?= gcc
CXX ?= g++
INSTALL ?= install
ifeq ($(OS),OSX)
STRIP ?= strip -x
else
STRIP ?= strip -s
# reduced compile output when running make without V=1
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
Q_CC = @echo ' CC '$@;
Q_LD = @echo ' LD '$@;
endif
endif
# set base program pointers and flags
CC = $(CROSS_COMPILE)gcc
RM ?= rm -f
INSTALL ?= install
MKDIR ?= mkdir -p
COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# set special flags for given Makefile parameters
ifeq ($(DEBUG),1)
CFLAGS += -g
STRIP = true # disable binary strip
INSTALL_STRIP_FLAG ?=
else
CFLAGS += -DNDEBUG
ifneq ($(OS),OSX)
INSTALL_STRIP_FLAG ?= -s
endif
endif
# set installation options
@ -175,29 +256,49 @@ ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
ifeq ($(LIBDIR),)
LIBDIR := $(PREFIX)/lib/mupen64plus
LIBDIR := $(PREFIX)/lib
endif
ifeq ($(PLUGINDIR),)
PLUGINDIR := $(LIBDIR)/mupen64plus
endif
SRCDIR = ../../src
OBJDIR = _obj
# enable/disable task dumping support
ifeq ($(DUMP), 1)
CFLAGS += -DENABLE_TASK_DUMP
endif
# list of source files to compile
SOURCE = \
$(SRCDIR)/main.c \
$(SRCDIR)/alist.c \
$(SRCDIR)/alist_audio.c \
$(SRCDIR)/alist_naudio.c \
$(SRCDIR)/alist_nead.c \
$(SRCDIR)/audio.c \
$(SRCDIR)/cicx105.c \
$(SRCDIR)/hle.c \
$(SRCDIR)/hvqm.c \
$(SRCDIR)/jpeg.c \
$(SRCDIR)/ucode3.cpp \
$(SRCDIR)/ucode2.cpp \
$(SRCDIR)/ucode1.cpp \
$(SRCDIR)/ucode3mp3.cpp
$(SRCDIR)/memory.c \
$(SRCDIR)/mp3.c \
$(SRCDIR)/musyx.c \
$(SRCDIR)/re2.c \
$(SRCDIR)/plugin.c
ifeq ($(OS), MINGW)
SOURCE += \
$(SRCDIR)/osal_dynamiclib_win32.c
else
SOURCE += \
$(SRCDIR)/osal_dynamiclib_unix.c
endif
# generate a list of object files build, make a temporary directory for them
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
OBJDIRS = $(dir $(OBJECTS))
$(shell mkdir -p $(OBJDIRS))
$(shell $(MKDIR) $(OBJDIRS))
# build targets
TARGET = mupen64plus-rsp-hle.$(SO_EXTENSION)
TARGET = mupen64plus-rsp-hle$(POSTFIX).$(SO_EXTENSION)
targets:
@echo "Mupen64Plus-rsp-hle makefile. "
@ -210,51 +311,43 @@ targets:
@echo " Options:"
@echo " BITS=32 == build 32-bit binaries on 64-bit machine"
@echo " APIDIR=path == path to find Mupen64Plus Core headers"
@echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)"
@echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)"
@echo " PIC=(1|0) == Force enable/disable of position independent code"
@echo " POSTFIX=name == String added to the name of the the build (default: '')"
@echo " DUMP=(1|0) == Enable/Disable unknown task dumping (default: 0)"
@echo " Install Options:"
@echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
@echo " LIBDIR=path == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
@echo " LIBDIR=path == library prefix (default: PREFIX/lib)"
@echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
@echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
@echo " Debugging Options:"
@echo " DEBUG=1 == add debugging symbols"
@echo " V=1 == show verbose compiler output"
all: $(TARGET)
install: $(TARGET)
$(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
$(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
$(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
$(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
uninstall:
rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
$(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
clean:
rm -rf ./_obj/* $(TARGET)
rmdir ./_obj
$(RM) -r $(OBJDIR) $(TARGET)
rebuild: clean all
# build dependency files
CFLAGS += -MD
CFLAGS += -MD -MP
-include $(OBJECTS:.o=.d)
CXXFLAGS += $(CFLAGS)
# reduced compile output when running make without V=1
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
Q_CC = @echo ' CC '$@;
Q_CXX = @echo ' CXX '$@;
Q_LD = @echo ' LD '$@;
endif
endif
# build rules
# standard build rules
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(COMPILE.c) -o $@ $<
$(TARGET): $(OBJECTS)
$(Q_LD)$(CXX) $(SHARED) $^ $(LDFLAGS) -o $@
$(STRIP) $@
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(Q_CXX)$(CXX) -o $@ $(CXXFLAGS) -c $<
.PHONY: all clean install uninstall targets

1038
src/alist.c Normal file

File diff suppressed because it is too large Load diff

177
src/alist.h Normal file
View file

@ -0,0 +1,177 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - alist.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef ALIST_INTERNAL_H
#define ALIST_INTERNAL_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
struct hle_t;
typedef void (*acmd_callback_t)(struct hle_t* hle, uint32_t w1, uint32_t w2);
void alist_process(struct hle_t* hle, const acmd_callback_t abi[], unsigned int abi_size);
uint32_t alist_get_address(struct hle_t* hle, uint32_t so, const uint32_t *segments, size_t n);
void alist_set_address(struct hle_t* hle, uint32_t so, uint32_t *segments, size_t n);
void alist_clear(struct hle_t* hle, uint16_t dmem, uint16_t count);
void alist_load(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count);
void alist_save(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count);
void alist_move(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_copy_every_other_sample(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_repeat64(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint8_t count);
void alist_copy_blocks(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t block_size, uint8_t count);
void alist_interleave(struct hle_t* hle, uint16_t dmemo, uint16_t left, uint16_t right, uint16_t count);
void alist_envmix_exp(
struct hle_t* hle,
bool init,
bool aux,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_ge(
struct hle_t* hle,
bool init,
bool aux,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_lin(
struct hle_t* hle,
bool init,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_nead(
struct hle_t* hle,
bool swap_wet_LR,
uint16_t dmem_dl,
uint16_t dmem_dr,
uint16_t dmem_wl,
uint16_t dmem_wr,
uint16_t dmemi,
unsigned count,
uint16_t *env_values,
uint16_t *env_steps,
const int16_t *xors);
void alist_mix(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count, int16_t gain);
void alist_multQ44(struct hle_t* hle, uint16_t dmem, uint16_t count, int8_t gain);
void alist_add(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_adpcm(
struct hle_t* hle,
bool init,
bool loop,
bool two_bit_per_sample,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
const int16_t* codebook,
uint32_t loop_address,
uint32_t last_frame_address);
void alist_resample(
struct hle_t* hle,
bool init,
bool flag2,
uint16_t dmemo, uint16_t dmemi, uint16_t count,
uint32_t pitch, uint32_t address);
void alist_resample_zoh(
struct hle_t* hle,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
uint32_t pitch,
uint32_t pitch_accu);
void alist_filter(
struct hle_t* hle,
uint16_t dmem,
uint16_t count,
uint32_t address,
const uint32_t* lut_address);
void alist_polef(
struct hle_t* hle,
bool init,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
uint16_t gain,
int16_t* table,
uint32_t address);
void alist_iirf(
struct hle_t* hle,
bool init,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
int16_t* table,
uint32_t address);
void alist_overload(
struct hle_t* hle,
uint16_t dmem,
int16_t count,
int16_t gain,
uint16_t attenuation);
/*
* Audio flags
*/
#define A_INIT 0x01
#define A_CONTINUE 0x00
#define A_LOOP 0x02
#define A_OUT 0x02
#define A_LEFT 0x02
#define A_RIGHT 0x00
#define A_VOL 0x04
#define A_RATE 0x00
#define A_AUX 0x08
#define A_NOAUX 0x00
#define A_MAIN 0x00
#define A_MIX 0x10
#endif

310
src/alist_audio.c Normal file
View file

@ -0,0 +1,310 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - alist_audio.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "alist.h"
#include "common.h"
#include "hle_internal.h"
#include "memory.h"
#include "ucodes.h"
enum { DMEM_BASE = 0x5c0 };
/* helper functions */
static uint32_t get_address(struct hle_t* hle, uint32_t so)
{
return alist_get_address(hle, so, hle->alist_audio.segments, N_SEGMENTS);
}
static void set_address(struct hle_t* hle, uint32_t so)
{
alist_set_address(hle, so, hle->alist_audio.segments, N_SEGMENTS);
}
static void clear_segments(struct hle_t* hle)
{
memset(hle->alist_audio.segments, 0, N_SEGMENTS*sizeof(hle->alist_audio.segments[0]));
}
/* audio commands definition */
static void SPNOOP(struct hle_t* UNUSED(hle), uint32_t UNUSED(w1), uint32_t UNUSED(w2))
{
}
static void CLEARBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t dmem = w1 + DMEM_BASE;
uint16_t count = w2 & 0xfff;
if (count == 0)
return;
alist_clear(hle, dmem, align(count, 16));
}
static void ENVMIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = get_address(hle, w2);
alist_envmix_exp(
hle,
flags & A_INIT,
flags & A_AUX,
hle->alist_audio.out, hle->alist_audio.dry_right,
hle->alist_audio.wet_left, hle->alist_audio.wet_right,
hle->alist_audio.in, hle->alist_audio.count,
hle->alist_audio.dry, hle->alist_audio.wet,
hle->alist_audio.vol,
hle->alist_audio.target,
hle->alist_audio.rate,
address);
}
static void ENVMIXER_GE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = get_address(hle, w2);
alist_envmix_ge(
hle,
flags & A_INIT,
flags & A_AUX,
hle->alist_audio.out, hle->alist_audio.dry_right,
hle->alist_audio.wet_left, hle->alist_audio.wet_right,
hle->alist_audio.in, hle->alist_audio.count,
hle->alist_audio.dry, hle->alist_audio.wet,
hle->alist_audio.vol,
hle->alist_audio.target,
hle->alist_audio.rate,
address);
}
static void RESAMPLE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint16_t pitch = w1;
uint32_t address = get_address(hle, w2);
alist_resample(
hle,
flags & A_INIT,
flags & 0x2,
hle->alist_audio.out,
hle->alist_audio.in,
align(hle->alist_audio.count, 16),
pitch << 1,
address);
}
static void SETVOL(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
if (flags & A_AUX) {
hle->alist_audio.dry = w1;
hle->alist_audio.wet = w2;
}
else {
unsigned lr = (flags & A_LEFT) ? 0 : 1;
if (flags & A_VOL)
hle->alist_audio.vol[lr] = w1;
else {
hle->alist_audio.target[lr] = w1;
hle->alist_audio.rate[lr] = w2;
}
}
}
static void SETLOOP(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
hle->alist_audio.loop = get_address(hle, w2);
}
static void ADPCM(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = get_address(hle, w2);
alist_adpcm(
hle,
flags & A_INIT,
flags & A_LOOP,
false, /* unsupported in this ucode */
hle->alist_audio.out,
hle->alist_audio.in,
align(hle->alist_audio.count, 32),
hle->alist_audio.table,
hle->alist_audio.loop,
address);
}
static void LOADBUFF(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
uint32_t address = get_address(hle, w2);
if (hle->alist_audio.count == 0)
return;
alist_load(hle, hle->alist_audio.in, address, hle->alist_audio.count);
}
static void SAVEBUFF(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
uint32_t address = get_address(hle, w2);
if (hle->alist_audio.count == 0)
return;
alist_save(hle, hle->alist_audio.out, address, hle->alist_audio.count);
}
static void SETBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
if (flags & A_AUX) {
hle->alist_audio.dry_right = w1 + DMEM_BASE;
hle->alist_audio.wet_left = (w2 >> 16) + DMEM_BASE;
hle->alist_audio.wet_right = w2 + DMEM_BASE;
} else {
hle->alist_audio.in = w1 + DMEM_BASE;
hle->alist_audio.out = (w2 >> 16) + DMEM_BASE;
hle->alist_audio.count = w2;
}
}
static void DMEMMOVE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t dmemi = w1 + DMEM_BASE;
uint16_t dmemo = (w2 >> 16) + DMEM_BASE;
uint16_t count = w2;
if (count == 0)
return;
alist_move(hle, dmemo, dmemi, align(count, 16));
}
static void LOADADPCM(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = w1;
uint32_t address = get_address(hle, w2);
dram_load_u16(hle, (uint16_t*)hle->alist_audio.table, address, align(count, 8) >> 1);
}
static void INTERLEAVE(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
uint16_t left = (w2 >> 16) + DMEM_BASE;
uint16_t right = w2 + DMEM_BASE;
if (hle->alist_audio.count == 0)
return;
alist_interleave(hle, hle->alist_audio.out, left, right, align(hle->alist_audio.count, 16));
}
static void MIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
int16_t gain = w1;
uint16_t dmemi = (w2 >> 16) + DMEM_BASE;
uint16_t dmemo = w2 + DMEM_BASE;
if (hle->alist_audio.count == 0)
return;
alist_mix(hle, dmemo, dmemi, align(hle->alist_audio.count, 32), gain);
}
static void SEGMENT(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
set_address(hle, w2);
}
static void POLEF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint16_t gain = w1;
uint32_t address = get_address(hle, w2);
if (hle->alist_audio.count == 0)
return;
alist_polef(
hle,
flags & A_INIT,
hle->alist_audio.out,
hle->alist_audio.in,
align(hle->alist_audio.count, 16),
gain,
hle->alist_audio.table,
address);
}
/* global functions */
void alist_process_audio(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, SEGMENT,
SETBUFF, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, POLEF, SETLOOP
};
clear_segments(hle);
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_audio_ge(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER_GE,
LOADBUFF, RESAMPLE, SAVEBUFF, SEGMENT,
SETBUFF, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, POLEF, SETLOOP
};
clear_segments(hle);
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_audio_bc(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER_GE,
LOADBUFF, RESAMPLE, SAVEBUFF, SEGMENT,
SETBUFF, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, POLEF, SETLOOP
};
clear_segments(hle);
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}

354
src/alist_naudio.c Normal file
View file

@ -0,0 +1,354 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - alist_naudio.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdbool.h>
#include <stdint.h>
#include "alist.h"
#include "common.h"
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
#include "ucodes.h"
enum { NAUDIO_COUNT = 0x170 }; /* ie 184 samples */
enum {
NAUDIO_MAIN = 0x4f0,
NAUDIO_MAIN2 = 0x660,
NAUDIO_DRY_LEFT = 0x9d0,
NAUDIO_DRY_RIGHT = 0xb40,
NAUDIO_WET_LEFT = 0xcb0,
NAUDIO_WET_RIGHT = 0xe20
};
/* audio commands definition */
static void UNKNOWN(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t acmd = (w1 >> 24);
HleWarnMessage(hle->user_defined,
"Unknown audio command %d: %08x %08x",
acmd, w1, w2);
}
static void SPNOOP(struct hle_t* UNUSED(hle), uint32_t UNUSED(w1), uint32_t UNUSED(w2))
{
}
static void NAUDIO_0000(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
/* ??? */
UNKNOWN(hle, w1, w2);
}
static void NAUDIO_02B0(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
/* emulate code at 0x12b0 (inside SETVOL), because PC always execute in IMEM */
hle->alist_naudio.rate[1] &= ~0xffff;
hle->alist_naudio.rate[1] |= (w2 & 0xffff);
}
static void NAUDIO_14(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint16_t gain = w1;
uint8_t select_main = (w2 >> 24);
uint32_t address = (w2 & 0xffffff);
uint16_t dmem = (select_main == 0) ? NAUDIO_MAIN : NAUDIO_MAIN2;
if (hle->alist_naudio.table[0] == 0 && hle->alist_naudio.table[1] == 0) {
alist_polef(
hle,
flags & A_INIT,
dmem,
dmem,
NAUDIO_COUNT,
gain,
hle->alist_naudio.table,
address);
}
else
{
alist_iirf(
hle,
flags & A_INIT,
dmem,
dmem,
NAUDIO_COUNT,
hle->alist_naudio.table,
address);
}
}
static void SETVOL(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
if (flags & A_VOL) {
if (flags & A_LEFT) {
hle->alist_naudio.vol[0] = w1;
hle->alist_naudio.dry = (w2 >> 16);
hle->alist_naudio.wet = w2;
}
else { /* A_RIGHT */
hle->alist_naudio.target[1] = w1;
hle->alist_naudio.rate[1] = w2;
}
}
else { /* A_RATE */
hle->alist_naudio.target[0] = w1;
hle->alist_naudio.rate[0] = w2;
}
}
static void ENVMIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = (w2 & 0xffffff);
hle->alist_naudio.vol[1] = w1;
alist_envmix_lin(
hle,
flags & A_INIT,
NAUDIO_DRY_LEFT,
NAUDIO_DRY_RIGHT,
NAUDIO_WET_LEFT,
NAUDIO_WET_RIGHT,
NAUDIO_MAIN,
NAUDIO_COUNT,
hle->alist_naudio.dry,
hle->alist_naudio.wet,
hle->alist_naudio.vol,
hle->alist_naudio.target,
hle->alist_naudio.rate,
address);
}
static void CLEARBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t dmem = w1 + NAUDIO_MAIN;
uint16_t count = w2 & 0xfff;
alist_clear(hle, dmem, count);
}
static void MIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
int16_t gain = w1;
uint16_t dmemi = (w2 >> 16) + NAUDIO_MAIN;
uint16_t dmemo = w2 + NAUDIO_MAIN;
alist_mix(hle, dmemo, dmemi, NAUDIO_COUNT, gain);
}
static void LOADBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = (w1 >> 12) & 0xfff;
uint16_t dmem = (w1 & 0xfff) + NAUDIO_MAIN;
uint32_t address = (w2 & 0xffffff);
alist_load(hle, dmem, address, count);
}
static void SAVEBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = (w1 >> 12) & 0xfff;
uint16_t dmem = (w1 & 0xfff) + NAUDIO_MAIN;
uint32_t address = (w2 & 0xffffff);
alist_save(hle, dmem, address, count);
}
static void LOADADPCM(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = w1;
uint32_t address = (w2 & 0xffffff);
dram_load_u16(hle, (uint16_t*)hle->alist_naudio.table, address, count >> 1);
}
static void DMEMMOVE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t dmemi = w1 + NAUDIO_MAIN;
uint16_t dmemo = (w2 >> 16) + NAUDIO_MAIN;
uint16_t count = w2;
alist_move(hle, dmemo, dmemi, (count + 3) & ~3);
}
static void SETLOOP(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
hle->alist_naudio.loop = (w2 & 0xffffff);
}
static void ADPCM(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint32_t address = (w1 & 0xffffff);
uint8_t flags = (w2 >> 28);
uint16_t count = (w2 >> 16) & 0xfff;
uint16_t dmemi = ((w2 >> 12) & 0xf) + NAUDIO_MAIN;
uint16_t dmemo = (w2 & 0xfff) + NAUDIO_MAIN;
alist_adpcm(
hle,
flags & A_INIT,
flags & A_LOOP,
false, /* unsuported by this ucode */
dmemo,
dmemi,
(count + 0x1f) & ~0x1f,
hle->alist_naudio.table,
hle->alist_naudio.loop,
address);
}
static void RESAMPLE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint32_t address = (w1 & 0xffffff);
uint8_t flags = (w2 >> 30);
uint16_t pitch = (w2 >> 14);
uint16_t dmemi = ((w2 >> 2) & 0xfff) + NAUDIO_MAIN;
uint16_t dmemo = (w2 & 0x3) ? NAUDIO_MAIN2 : NAUDIO_MAIN;
alist_resample(
hle,
flags & A_INIT,
false, /* TODO: check which ABI supports it */
dmemo,
dmemi,
NAUDIO_COUNT,
pitch << 1,
address);
}
static void INTERLEAVE(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t UNUSED(w2))
{
alist_interleave(hle, NAUDIO_MAIN, NAUDIO_DRY_LEFT, NAUDIO_DRY_RIGHT, NAUDIO_COUNT);
}
static void MP3ADDY(struct hle_t* UNUSED(hle), uint32_t UNUSED(w1), uint32_t UNUSED(w2))
{
}
static void MP3(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
unsigned index = (w1 & 0x1e);
uint32_t address = (w2 & 0xffffff);
mp3_task(hle, index, address);
}
static void OVERLOAD(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
/* Overload distortion effect for Conker's Bad Fur Day */
uint16_t dmem = (w1 & 0xfff) + NAUDIO_MAIN;
int16_t gain = (int16_t)(uint16_t)w2;
uint16_t attenuation = w2 >> 16;
alist_overload(hle, dmem, NAUDIO_COUNT, gain, attenuation);
}
/* global functions */
void alist_process_naudio(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, NAUDIO_0000,
NAUDIO_0000, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_02B0, SETLOOP
};
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_naudio_bk(struct hle_t* hle)
{
/* TODO: see what differs from alist_process_naudio */
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, NAUDIO_0000,
NAUDIO_0000, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_02B0, SETLOOP
};
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_naudio_dk(struct hle_t* hle)
{
/* TODO: see what differs from alist_process_naudio */
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, MIXER,
MIXER, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_02B0, SETLOOP
};
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_naudio_mp3(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x10] = {
OVERLOAD, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, MP3,
MP3ADDY, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_14, SETLOOP
};
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_naudio_cbfd(struct hle_t* hle)
{
/* What differs from alist_process_naudio_mp3?
*
* JoshW: It appears that despite being a newer game, CBFD appears to have a slightly older ucode version
* compared to JFG, B.T. et al.
* For naudio_mp3, the functions DMEM parameters have an additional protective AND on them
* (basically dmem & 0xffff).
* But there are minor differences are in the RESAMPLE and ENVMIXER functions.
* I don't think it is making any noticeable difference, as it could be just a simplification of the logic.
*
* bsmiles32: The only difference I could remember between mp3 and cbfd variants is in the MP3ADDY command.
* And the MP3 overlay is also different.
*/
static const acmd_callback_t ABI[0x10] = {
OVERLOAD, ADPCM, CLEARBUFF, ENVMIXER,
LOADBUFF, RESAMPLE, SAVEBUFF, MP3,
MP3ADDY, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, NAUDIO_14, SETLOOP
};
alist_process(hle, ABI, 0x10);
rsp_break(hle, SP_STATUS_TASKDONE);
}

556
src/alist_nead.c Normal file
View file

@ -0,0 +1,556 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - alist_nead.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdbool.h>
#include <stdint.h>
#include "alist.h"
#include "common.h"
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
#include "ucodes.h"
/* remove windows define to 0x06 */
#ifdef DUPLICATE
#undef DUPLICATE
#endif
/* audio commands definition */
static void UNKNOWN(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t acmd = (w1 >> 24);
HleWarnMessage(hle->user_defined,
"Unknown audio command %d: %08x %08x",
acmd, w1, w2);
}
static void SPNOOP(struct hle_t* UNUSED(hle), uint32_t UNUSED(w1), uint32_t UNUSED(w2))
{
}
static void LOADADPCM(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = w1;
uint32_t address = (w2 & 0xffffff);
dram_load_u16(hle, (uint16_t*)hle->alist_nead.table, address, count >> 1);
}
static void SETLOOP(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
hle->alist_nead.loop = w2 & 0xffffff;
}
static void SETBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
hle->alist_nead.in = w1;
hle->alist_nead.out = (w2 >> 16);
hle->alist_nead.count = w2;
}
static void ADPCM(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = (w2 & 0xffffff);
alist_adpcm(
hle,
flags & 0x1,
flags & 0x2,
flags & 0x4,
hle->alist_nead.out,
hle->alist_nead.in,
(hle->alist_nead.count + 0x1f) & ~0x1f,
hle->alist_nead.table,
hle->alist_nead.loop,
address);
}
static void CLEARBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t dmem = w1;
uint16_t count = w2 & 0xfff;
if (count == 0)
return;
alist_clear(hle, dmem, count);
}
static void LOADBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = (w1 >> 12) & 0xfff;
uint16_t dmem = (w1 & 0xfff);
uint32_t address = (w2 & 0xffffff);
alist_load(hle, dmem, address, count);
}
static void SAVEBUFF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = (w1 >> 12) & 0xfff;
uint16_t dmem = (w1 & 0xfff);
uint32_t address = (w2 & 0xffffff);
alist_save(hle, dmem, address, count);
}
static void MIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = (w1 >> 12) & 0xff0;
int16_t gain = w1;
uint16_t dmemi = (w2 >> 16);
uint16_t dmemo = w2;
alist_mix(hle, dmemo, dmemi, count, gain);
}
static void RESAMPLE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint16_t pitch = w1;
uint32_t address = (w2 & 0xffffff);
alist_resample(
hle,
flags & 0x1,
false, /* TODO: check which ABI supports it */
hle->alist_nead.out,
hle->alist_nead.in,
(hle->alist_nead.count + 0xf) & ~0xf,
pitch << 1,
address);
}
static void RESAMPLE_ZOH(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t pitch = w1;
uint16_t pitch_accu = w2;
alist_resample_zoh(
hle,
hle->alist_nead.out,
hle->alist_nead.in,
hle->alist_nead.count,
pitch << 1,
pitch_accu);
}
static void DMEMMOVE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t dmemi = w1;
uint16_t dmemo = (w2 >> 16);
uint16_t count = w2;
if (count == 0)
return;
alist_move(hle, dmemo, dmemi, (count + 3) & ~3);
}
static void ENVSETUP1_MK(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
hle->alist_nead.env_values[2] = (w1 >> 8) & 0xff00;
hle->alist_nead.env_steps[2] = 0;
hle->alist_nead.env_steps[0] = (w2 >> 16);
hle->alist_nead.env_steps[1] = w2;
}
static void ENVSETUP1(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
hle->alist_nead.env_values[2] = (w1 >> 8) & 0xff00;
hle->alist_nead.env_steps[2] = w1;
hle->alist_nead.env_steps[0] = (w2 >> 16);
hle->alist_nead.env_steps[1] = w2;
}
static void ENVSETUP2(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
hle->alist_nead.env_values[0] = (w2 >> 16);
hle->alist_nead.env_values[1] = w2;
}
static void ENVMIXER_MK(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
int16_t xors[4];
uint16_t dmemi = (w1 >> 12) & 0xff0;
uint8_t count = (w1 >> 8) & 0xff;
uint16_t dmem_dl = (w2 >> 20) & 0xff0;
uint16_t dmem_dr = (w2 >> 12) & 0xff0;
uint16_t dmem_wl = (w2 >> 4) & 0xff0;
uint16_t dmem_wr = (w2 << 4) & 0xff0;
xors[2] = 0; /* unsupported by this ucode */
xors[3] = 0; /* unsupported by this ucode */
xors[0] = 0 - (int16_t)((w1 & 0x2) >> 1);
xors[1] = 0 - (int16_t)((w1 & 0x1) );
alist_envmix_nead(
hle,
false, /* unsupported by this ucode */
dmem_dl, dmem_dr,
dmem_wl, dmem_wr,
dmemi, count,
hle->alist_nead.env_values,
hle->alist_nead.env_steps,
xors);
}
static void ENVMIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
int16_t xors[4];
uint16_t dmemi = (w1 >> 12) & 0xff0;
uint8_t count = (w1 >> 8) & 0xff;
bool swap_wet_LR = (w1 >> 4) & 0x1;
uint16_t dmem_dl = (w2 >> 20) & 0xff0;
uint16_t dmem_dr = (w2 >> 12) & 0xff0;
uint16_t dmem_wl = (w2 >> 4) & 0xff0;
uint16_t dmem_wr = (w2 << 4) & 0xff0;
xors[2] = 0 - (int16_t)((w1 & 0x8) >> 1);
xors[3] = 0 - (int16_t)((w1 & 0x4) >> 1);
xors[0] = 0 - (int16_t)((w1 & 0x2) >> 1);
xors[1] = 0 - (int16_t)((w1 & 0x1) );
alist_envmix_nead(
hle,
swap_wet_LR,
dmem_dl, dmem_dr,
dmem_wl, dmem_wr,
dmemi, count,
hle->alist_nead.env_values,
hle->alist_nead.env_steps,
xors);
}
static void DUPLICATE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t count = (w1 >> 16);
uint16_t dmemi = w1;
uint16_t dmemo = (w2 >> 16);
alist_repeat64(hle, dmemo, dmemi, count);
}
static void INTERL(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = w1;
uint16_t dmemi = (w2 >> 16);
uint16_t dmemo = w2;
alist_copy_every_other_sample(hle, dmemo, dmemi, count);
}
static void INTERLEAVE_MK(struct hle_t* hle, uint32_t UNUSED(w1), uint32_t w2)
{
uint16_t left = (w2 >> 16);
uint16_t right = w2;
if (hle->alist_nead.count == 0)
return;
alist_interleave(hle, hle->alist_nead.out, left, right, hle->alist_nead.count);
}
static void INTERLEAVE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = ((w1 >> 12) & 0xff0);
uint16_t dmemo = w1;
uint16_t left = (w2 >> 16);
uint16_t right = w2;
alist_interleave(hle, dmemo, left, right, count);
}
static void ADDMIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint16_t count = (w1 >> 12) & 0xff0;
uint16_t dmemi = (w2 >> 16);
uint16_t dmemo = w2;
alist_add(hle, dmemo, dmemi, count);
}
static void HILOGAIN(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
int8_t gain = (w1 >> 16); /* Q4.4 signed */
uint16_t count = w1 & 0xfff;
uint16_t dmem = (w2 >> 16);
alist_multQ44(hle, dmem, count, gain);
}
static void FILTER(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = (w2 & 0xffffff);
if (flags > 1) {
hle->alist_nead.filter_count = w1;
hle->alist_nead.filter_lut_address[0] = address; /* t6 */
}
else {
uint16_t dmem = w1;
hle->alist_nead.filter_lut_address[1] = address + 0x10; /* t5 */
alist_filter(hle, dmem, hle->alist_nead.filter_count, address, hle->alist_nead.filter_lut_address);
}
}
static void SEGMENT(struct hle_t* UNUSED(hle), uint32_t UNUSED(w1), uint32_t UNUSED(w2))
{
}
static void NEAD_16(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t count = (w1 >> 16);
uint16_t dmemi = w1;
uint16_t dmemo = (w2 >> 16);
uint16_t block_size = w2;
alist_copy_blocks(hle, dmemo, dmemi, block_size, count);
}
static void POLEF(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint16_t gain = w1;
uint32_t address = (w2 & 0xffffff);
if (hle->alist_nead.count == 0)
return;
alist_polef(
hle,
flags & A_INIT,
hle->alist_nead.out,
hle->alist_nead.in,
hle->alist_nead.count,
gain,
hle->alist_nead.table,
address);
}
void alist_process_nead_mk(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x20] = {
SPNOOP, ADPCM, CLEARBUFF, SPNOOP,
SPNOOP, RESAMPLE, SPNOOP, SEGMENT,
SETBUFF, SPNOOP, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE_MK, POLEF, SETLOOP,
NEAD_16, INTERL, ENVSETUP1_MK, ENVMIXER_MK,
LOADBUFF, SAVEBUFF, ENVSETUP2, SPNOOP,
SPNOOP, SPNOOP, SPNOOP, SPNOOP,
SPNOOP, SPNOOP, SPNOOP, SPNOOP
};
alist_process(hle, ABI, 0x20);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_sf(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x20] = {
SPNOOP, ADPCM, CLEARBUFF, SPNOOP,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, SPNOOP,
SETBUFF, SPNOOP, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE_MK, POLEF, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, SPNOOP,
HILOGAIN, UNKNOWN, DUPLICATE, SPNOOP,
SPNOOP, SPNOOP, SPNOOP, SPNOOP
};
alist_process(hle, ABI, 0x20);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_sfj(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x20] = {
SPNOOP, ADPCM, CLEARBUFF, SPNOOP,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, SPNOOP,
SETBUFF, SPNOOP, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE_MK, POLEF, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN,
HILOGAIN, UNKNOWN, DUPLICATE, SPNOOP,
SPNOOP, SPNOOP, SPNOOP, SPNOOP
};
alist_process(hle, ABI, 0x20);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_fz(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x20] = {
UNKNOWN, ADPCM, CLEARBUFF, SPNOOP,
ADDMIXER, RESAMPLE, SPNOOP, SPNOOP,
SETBUFF, SPNOOP, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, SPNOOP, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN,
SPNOOP, UNKNOWN, DUPLICATE, SPNOOP,
SPNOOP, SPNOOP, SPNOOP, SPNOOP
};
alist_process(hle, ABI, 0x20);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_wrjb(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x20] = {
SPNOOP, ADPCM, CLEARBUFF, UNKNOWN,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, SPNOOP,
SETBUFF, SPNOOP, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, SPNOOP, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN,
HILOGAIN, UNKNOWN, DUPLICATE, FILTER,
SPNOOP, SPNOOP, SPNOOP, SPNOOP
};
alist_process(hle, ABI, 0x20);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_ys(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x18] = {
UNKNOWN, ADPCM, CLEARBUFF, UNKNOWN,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, FILTER,
SETBUFF, DUPLICATE, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, HILOGAIN, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN
};
alist_process(hle, ABI, 0x18);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_1080(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x18] = {
UNKNOWN, ADPCM, CLEARBUFF, UNKNOWN,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, FILTER,
SETBUFF, DUPLICATE, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, HILOGAIN, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN
};
alist_process(hle, ABI, 0x18);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_oot(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x18] = {
UNKNOWN, ADPCM, CLEARBUFF, UNKNOWN,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, FILTER,
SETBUFF, DUPLICATE, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, HILOGAIN, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN
};
alist_process(hle, ABI, 0x18);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_mm(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x18] = {
UNKNOWN, ADPCM, CLEARBUFF, SPNOOP,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, FILTER,
SETBUFF, DUPLICATE, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, HILOGAIN, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN
};
alist_process(hle, ABI, 0x18);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_mmb(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x18] = {
SPNOOP, ADPCM, CLEARBUFF, SPNOOP,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, FILTER,
SETBUFF, DUPLICATE, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, HILOGAIN, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN
};
alist_process(hle, ABI, 0x18);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_ac(struct hle_t* hle)
{
static const acmd_callback_t ABI[0x18] = {
UNKNOWN, ADPCM, CLEARBUFF, SPNOOP,
ADDMIXER, RESAMPLE, RESAMPLE_ZOH, FILTER,
SETBUFF, DUPLICATE, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, HILOGAIN, SETLOOP,
NEAD_16, INTERL, ENVSETUP1, ENVMIXER,
LOADBUFF, SAVEBUFF, ENVSETUP2, UNKNOWN
};
alist_process(hle, ABI, 0x18);
rsp_break(hle, SP_STATUS_TASKDONE);
}
void alist_process_nead_mats(struct hle_t* hle)
{
/* FIXME: implement proper ucode
* Forward the task if possible,
* otherwise better to have no sound than garbage sound
*/
if (HleForwardTask(hle->user_defined) != 0) {
rsp_break(hle, SP_STATUS_TASKDONE);
}
}
void alist_process_nead_efz(struct hle_t* hle)
{
/* FIXME: implement proper ucode
* Forward the task if possible,
* otherwise use FZero ucode which should be very similar
*/
if (HleForwardTask(hle->user_defined) != 0) {
alist_process_nead_fz(hle);
}
}

43
src/arithmetics.h Normal file
View file

@ -0,0 +1,43 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - arithmetics.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef ARITHMETICS_H
#define ARITHMETICS_H
#include <stdint.h>
#include "common.h"
static inline int16_t clamp_s16(int_fast32_t x)
{
x = (x < INT16_MIN) ? INT16_MIN: x;
x = (x > INT16_MAX) ? INT16_MAX: x;
return x;
}
static inline int32_t vmulf(int16_t x, int16_t y)
{
return (((int32_t)(x))*((int32_t)(y))+0x4000)>>15;
}
#endif

128
src/audio.c Normal file
View file

@ -0,0 +1,128 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - audio.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include "arithmetics.h"
const int16_t RESAMPLE_LUT[64 * 4] = {
(int16_t)0x0c39, (int16_t)0x66ad, (int16_t)0x0d46, (int16_t)0xffdf,
(int16_t)0x0b39, (int16_t)0x6696, (int16_t)0x0e5f, (int16_t)0xffd8,
(int16_t)0x0a44, (int16_t)0x6669, (int16_t)0x0f83, (int16_t)0xffd0,
(int16_t)0x095a, (int16_t)0x6626, (int16_t)0x10b4, (int16_t)0xffc8,
(int16_t)0x087d, (int16_t)0x65cd, (int16_t)0x11f0, (int16_t)0xffbf,
(int16_t)0x07ab, (int16_t)0x655e, (int16_t)0x1338, (int16_t)0xffb6,
(int16_t)0x06e4, (int16_t)0x64d9, (int16_t)0x148c, (int16_t)0xffac,
(int16_t)0x0628, (int16_t)0x643f, (int16_t)0x15eb, (int16_t)0xffa1,
(int16_t)0x0577, (int16_t)0x638f, (int16_t)0x1756, (int16_t)0xff96,
(int16_t)0x04d1, (int16_t)0x62cb, (int16_t)0x18cb, (int16_t)0xff8a,
(int16_t)0x0435, (int16_t)0x61f3, (int16_t)0x1a4c, (int16_t)0xff7e,
(int16_t)0x03a4, (int16_t)0x6106, (int16_t)0x1bd7, (int16_t)0xff71,
(int16_t)0x031c, (int16_t)0x6007, (int16_t)0x1d6c, (int16_t)0xff64,
(int16_t)0x029f, (int16_t)0x5ef5, (int16_t)0x1f0b, (int16_t)0xff56,
(int16_t)0x022a, (int16_t)0x5dd0, (int16_t)0x20b3, (int16_t)0xff48,
(int16_t)0x01be, (int16_t)0x5c9a, (int16_t)0x2264, (int16_t)0xff3a,
(int16_t)0x015b, (int16_t)0x5b53, (int16_t)0x241e, (int16_t)0xff2c,
(int16_t)0x0101, (int16_t)0x59fc, (int16_t)0x25e0, (int16_t)0xff1e,
(int16_t)0x00ae, (int16_t)0x5896, (int16_t)0x27a9, (int16_t)0xff10,
(int16_t)0x0063, (int16_t)0x5720, (int16_t)0x297a, (int16_t)0xff02,
(int16_t)0x001f, (int16_t)0x559d, (int16_t)0x2b50, (int16_t)0xfef4,
(int16_t)0xffe2, (int16_t)0x540d, (int16_t)0x2d2c, (int16_t)0xfee8,
(int16_t)0xffac, (int16_t)0x5270, (int16_t)0x2f0d, (int16_t)0xfedb,
(int16_t)0xff7c, (int16_t)0x50c7, (int16_t)0x30f3, (int16_t)0xfed0,
(int16_t)0xff53, (int16_t)0x4f14, (int16_t)0x32dc, (int16_t)0xfec6,
(int16_t)0xff2e, (int16_t)0x4d57, (int16_t)0x34c8, (int16_t)0xfebd,
(int16_t)0xff0f, (int16_t)0x4b91, (int16_t)0x36b6, (int16_t)0xfeb6,
(int16_t)0xfef5, (int16_t)0x49c2, (int16_t)0x38a5, (int16_t)0xfeb0,
(int16_t)0xfedf, (int16_t)0x47ed, (int16_t)0x3a95, (int16_t)0xfeac,
(int16_t)0xfece, (int16_t)0x4611, (int16_t)0x3c85, (int16_t)0xfeab,
(int16_t)0xfec0, (int16_t)0x4430, (int16_t)0x3e74, (int16_t)0xfeac,
(int16_t)0xfeb6, (int16_t)0x424a, (int16_t)0x4060, (int16_t)0xfeaf,
(int16_t)0xfeaf, (int16_t)0x4060, (int16_t)0x424a, (int16_t)0xfeb6,
(int16_t)0xfeac, (int16_t)0x3e74, (int16_t)0x4430, (int16_t)0xfec0,
(int16_t)0xfeab, (int16_t)0x3c85, (int16_t)0x4611, (int16_t)0xfece,
(int16_t)0xfeac, (int16_t)0x3a95, (int16_t)0x47ed, (int16_t)0xfedf,
(int16_t)0xfeb0, (int16_t)0x38a5, (int16_t)0x49c2, (int16_t)0xfef5,
(int16_t)0xfeb6, (int16_t)0x36b6, (int16_t)0x4b91, (int16_t)0xff0f,
(int16_t)0xfebd, (int16_t)0x34c8, (int16_t)0x4d57, (int16_t)0xff2e,
(int16_t)0xfec6, (int16_t)0x32dc, (int16_t)0x4f14, (int16_t)0xff53,
(int16_t)0xfed0, (int16_t)0x30f3, (int16_t)0x50c7, (int16_t)0xff7c,
(int16_t)0xfedb, (int16_t)0x2f0d, (int16_t)0x5270, (int16_t)0xffac,
(int16_t)0xfee8, (int16_t)0x2d2c, (int16_t)0x540d, (int16_t)0xffe2,
(int16_t)0xfef4, (int16_t)0x2b50, (int16_t)0x559d, (int16_t)0x001f,
(int16_t)0xff02, (int16_t)0x297a, (int16_t)0x5720, (int16_t)0x0063,
(int16_t)0xff10, (int16_t)0x27a9, (int16_t)0x5896, (int16_t)0x00ae,
(int16_t)0xff1e, (int16_t)0x25e0, (int16_t)0x59fc, (int16_t)0x0101,
(int16_t)0xff2c, (int16_t)0x241e, (int16_t)0x5b53, (int16_t)0x015b,
(int16_t)0xff3a, (int16_t)0x2264, (int16_t)0x5c9a, (int16_t)0x01be,
(int16_t)0xff48, (int16_t)0x20b3, (int16_t)0x5dd0, (int16_t)0x022a,
(int16_t)0xff56, (int16_t)0x1f0b, (int16_t)0x5ef5, (int16_t)0x029f,
(int16_t)0xff64, (int16_t)0x1d6c, (int16_t)0x6007, (int16_t)0x031c,
(int16_t)0xff71, (int16_t)0x1bd7, (int16_t)0x6106, (int16_t)0x03a4,
(int16_t)0xff7e, (int16_t)0x1a4c, (int16_t)0x61f3, (int16_t)0x0435,
(int16_t)0xff8a, (int16_t)0x18cb, (int16_t)0x62cb, (int16_t)0x04d1,
(int16_t)0xff96, (int16_t)0x1756, (int16_t)0x638f, (int16_t)0x0577,
(int16_t)0xffa1, (int16_t)0x15eb, (int16_t)0x643f, (int16_t)0x0628,
(int16_t)0xffac, (int16_t)0x148c, (int16_t)0x64d9, (int16_t)0x06e4,
(int16_t)0xffb6, (int16_t)0x1338, (int16_t)0x655e, (int16_t)0x07ab,
(int16_t)0xffbf, (int16_t)0x11f0, (int16_t)0x65cd, (int16_t)0x087d,
(int16_t)0xffc8, (int16_t)0x10b4, (int16_t)0x6626, (int16_t)0x095a,
(int16_t)0xffd0, (int16_t)0x0f83, (int16_t)0x6669, (int16_t)0x0a44,
(int16_t)0xffd8, (int16_t)0x0e5f, (int16_t)0x6696, (int16_t)0x0b39,
(int16_t)0xffdf, (int16_t)0x0d46, (int16_t)0x66ad, (int16_t)0x0c39
};
int32_t rdot(size_t n, const int16_t *x, const int16_t *y)
{
int32_t accu = 0;
y += n;
while (n != 0) {
accu += *(x++) * *(--y);
--n;
}
return accu;
}
void adpcm_compute_residuals(int16_t* dst, const int16_t* src,
const int16_t* cb_entry, const int16_t* last_samples, size_t count)
{
const int16_t* const book1 = cb_entry;
const int16_t* const book2 = cb_entry + 8;
const int16_t l1 = last_samples[0];
const int16_t l2 = last_samples[1];
size_t i;
assert(count <= 8);
for(i = 0; i < count; ++i) {
int32_t accu = (int32_t)src[i] << 11;
accu += book1[i]*l1 + book2[i]*l2 + rdot(i, book2, src);
dst[i] = clamp_s16(accu >> 11);
}
}

45
src/audio.h Normal file
View file

@ -0,0 +1,45 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - audio.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef AUDIO_H
#define AUDIO_H
#include <stddef.h>
#include <stdint.h>
#include "common.h"
extern const int16_t RESAMPLE_LUT[64 * 4];
int32_t rdot(size_t n, const int16_t *x, const int16_t *y);
static inline int16_t adpcm_predict_sample(uint8_t byte, uint8_t mask,
unsigned lshift, unsigned rshift)
{
int16_t sample = (uint16_t)(byte & mask) << lshift;
sample >>= rshift; /* signed */
return sample;
}
void adpcm_compute_residuals(int16_t* dst, const int16_t* src,
const int16_t* cb_entry, const int16_t* last_samples, size_t count);
#endif

56
src/cicx105.c Normal file
View file

@ -0,0 +1,56 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - cicx105.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2012 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string.h>
#include "hle_internal.h"
/**
* During IPL3 stage of CIC x105 games, the RSP performs some checks and transactions
* necessary for booting the game.
*
* We only implement the needed DMA transactions for booting.
*
* Found in Banjo-Tooie, Zelda, Perfect Dark, ...)
**/
void cicx105_ucode(struct hle_t* hle)
{
/* memcpy is okay to use because access constrains are met (alignment, size) */
unsigned int i;
unsigned char *dst = hle->dram + 0x2fb1f0;
unsigned char *src = hle->imem + 0x120;
/* dma_read(0x1120, 0x1e8, 0x1e8) */
memcpy(hle->imem + 0x120, hle->dram + 0x1e8, 0x1f0);
/* dma_write(0x1120, 0x2fb1f0, 0xfe817000) */
for (i = 0; i < 24; ++i) {
memcpy(dst, src, 8);
dst += 0xff0;
src += 0x8;
}
rsp_break(hle, 0);
}

38
src/common.h Normal file
View file

@ -0,0 +1,38 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - common.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef COMMON_H
#define COMMON_H
/* macro for unused variable warning suppression */
#ifdef __GNUC__
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
# define UNUSED(x) UNUSED_ ## x
#endif
/* macro for inline keyword */
#ifdef _MSC_VER
#define inline __inline
#endif
#endif

524
src/hle.c Normal file
View file

@ -0,0 +1,524 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - hle.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2012 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdbool.h>
#include <stdint.h>
#ifdef ENABLE_TASK_DUMP
#include <stdio.h>
#endif
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
#include "ucodes.h"
#define min(a,b) (((a) < (b)) ? (a) : (b))
/* some rdp status flags */
#define DP_STATUS_FREEZE 0x2
/* helper functions prototypes */
static unsigned int sum_bytes(const unsigned char *bytes, unsigned int size);
static bool is_task(struct hle_t* hle);
static void send_dlist_to_gfx_plugin(struct hle_t* hle);
static ucode_func_t try_audio_task_detection(struct hle_t* hle);
static ucode_func_t try_normal_task_detection(struct hle_t* hle);
static ucode_func_t non_task_detection(struct hle_t* hle);
static ucode_func_t task_detection(struct hle_t* hle);
#ifdef ENABLE_TASK_DUMP
static void dump_binary(struct hle_t* hle, const char *const filename,
const unsigned char *const bytes, unsigned int size);
static void dump_task(struct hle_t* hle, const char *const filename);
static void dump_unknown_task(struct hle_t* hle, unsigned int uc_start);
static void dump_unknown_non_task(struct hle_t* hle, unsigned int uc_start);
#endif
/* Global functions */
void hle_init(struct hle_t* hle,
unsigned char* dram,
unsigned char* dmem,
unsigned char* imem,
unsigned int* mi_intr,
unsigned int* sp_mem_addr,
unsigned int* sp_dram_addr,
unsigned int* sp_rd_length,
unsigned int* sp_wr_length,
unsigned int* sp_status,
unsigned int* sp_dma_full,
unsigned int* sp_dma_busy,
unsigned int* sp_pc,
unsigned int* sp_semaphore,
unsigned int* dpc_start,
unsigned int* dpc_end,
unsigned int* dpc_current,
unsigned int* dpc_status,
unsigned int* dpc_clock,
unsigned int* dpc_bufbusy,
unsigned int* dpc_pipebusy,
unsigned int* dpc_tmem,
void* user_defined)
{
hle->dram = dram;
hle->dmem = dmem;
hle->imem = imem;
hle->mi_intr = mi_intr;
hle->sp_mem_addr = sp_mem_addr;
hle->sp_dram_addr = sp_dram_addr;
hle->sp_rd_length = sp_rd_length;
hle->sp_wr_length = sp_wr_length;
hle->sp_status = sp_status;
hle->sp_dma_full = sp_dma_full;
hle->sp_dma_busy = sp_dma_busy;
hle->sp_pc = sp_pc;
hle->sp_semaphore = sp_semaphore;
hle->dpc_start = dpc_start;
hle->dpc_end = dpc_end;
hle->dpc_current = dpc_current;
hle->dpc_status = dpc_status;
hle->dpc_clock = dpc_clock;
hle->dpc_bufbusy = dpc_bufbusy;
hle->dpc_pipebusy = dpc_pipebusy;
hle->dpc_tmem = dpc_tmem;
hle->user_defined = user_defined;
}
void hle_execute(struct hle_t* hle)
{
uint32_t uc_start = *dmem_u32(hle, TASK_UCODE);
uint32_t uc_dstart = *dmem_u32(hle, TASK_UCODE_DATA);
uint32_t uc_dsize = *dmem_u32(hle, TASK_UCODE_DATA_SIZE);
bool match = false;
struct cached_ucodes_t * cached_ucodes = &hle->cached_ucodes;
struct ucode_info_t *info = NULL;
if (cached_ucodes->count > 0)
info = &cached_ucodes->infos[cached_ucodes->count-1];
for (int i = 0; i < cached_ucodes->count; i++)
{
if (info->uc_start == uc_start && info->uc_dstart == uc_dstart && info->uc_dsize == uc_dsize)
{
match = true;
break;
}
info--;
}
if (!match)
{
info = &cached_ucodes->infos[cached_ucodes->count];
info->uc_start = uc_start;
info->uc_dstart = uc_dstart;
info->uc_dsize = uc_dsize;
info->uc_pfunc = task_detection(hle);
cached_ucodes->count++;
assert(cached_ucodes->count <= CACHED_UCODES_MAX_SIZE);
assert(info->uc_pfunc != NULL);
}
info->uc_pfunc(hle);
}
/* local functions */
static unsigned int sum_bytes(const unsigned char *bytes, unsigned int size)
{
unsigned int sum = 0;
const unsigned char *const bytes_end = bytes + size;
while (bytes != bytes_end)
sum += *bytes++;
return sum;
}
/**
* Try to figure if the RSP was launched using osSpTask* functions
* and not run directly (in which case DMEM[0xfc0-0xfff] is meaningless).
*
* Previously, the ucode_size field was used to determine this,
* but it is not robust enough (hi Pokemon Stadium !) because games could write anything
* in this field : most ucode_boot discard the value and just use 0xf7f anyway.
*
* Using ucode_boot_size should be more robust in this regard.
**/
static bool is_task(struct hle_t* hle)
{
return (*dmem_u32(hle, TASK_UCODE_BOOT_SIZE) <= 0x1000);
}
void rsp_break(struct hle_t* hle, unsigned int setbits)
{
*hle->sp_status |= setbits | SP_STATUS_BROKE | SP_STATUS_HALT;
if ((*hle->sp_status & SP_STATUS_INTR_ON_BREAK)) {
*hle->mi_intr |= MI_INTR_SP;
HleCheckInterrupts(hle->user_defined);
}
}
static void send_alist_to_audio_plugin(struct hle_t* hle)
{
HleProcessAlistList(hle->user_defined);
rsp_break(hle, SP_STATUS_TASKDONE);
}
static void send_dlist_to_gfx_plugin(struct hle_t* hle)
{
/* Since GFX_INFO version 2, these bits are set before calling the ProcessDlistList function.
* And the GFX plugin is responsible to unset them if needed.
* For GFX_INFO version < 2, the GFX plugin didn't have access to sp_status so
* it doesn't matter if we set these bits before calling ProcessDlistList function.
*/
*hle->sp_status |= SP_STATUS_TASKDONE | SP_STATUS_BROKE | SP_STATUS_HALT;
HleProcessDlistList(hle->user_defined);
if ((*hle->sp_status & SP_STATUS_INTR_ON_BREAK) && (*hle->sp_status & (SP_STATUS_TASKDONE | SP_STATUS_BROKE | SP_STATUS_HALT))) {
*hle->mi_intr |= MI_INTR_SP;
HleCheckInterrupts(hle->user_defined);
}
}
static void task_done(struct hle_t* hle)
{
rsp_break(hle, SP_STATUS_TASKDONE);
}
static void unknown_ucode(struct hle_t* hle)
{
/* Forward task to RSP Fallback.
* If task is not forwarded, use the regular "unknown ucode" path */
if (HleForwardTask(hle->user_defined) != 0) {
uint32_t uc_start = *dmem_u32(hle, TASK_UCODE);
HleWarnMessage(hle->user_defined, "unknown RSP code: uc_start: %x PC:%x", uc_start, *hle->sp_pc);
#ifdef ENABLE_TASK_DUMP
dump_unknown_non_task(hle, uc_start);
#endif
}
}
static void unknown_task(struct hle_t* hle)
{
/* Forward task to RSP Fallback.
* If task is not forwarded, use the regular "unknown task" path */
if (HleForwardTask(hle->user_defined) != 0) {
/* Send task_done signal for unknown ucodes to allow further processings */
rsp_break(hle, SP_STATUS_TASKDONE);
uint32_t uc_start = *dmem_u32(hle, TASK_UCODE);
HleWarnMessage(hle->user_defined, "unknown OSTask: uc_start: %x PC:%x", uc_start, *hle->sp_pc);
#ifdef ENABLE_TASK_DUMP
dump_unknown_task(hle, uc_start);
#endif
}
}
static ucode_func_t try_audio_task_detection(struct hle_t* hle)
{
/* identify audio ucode by using the content of ucode_data */
uint32_t ucode_data = *dmem_u32(hle, TASK_UCODE_DATA);
uint32_t v;
if (*dram_u32(hle, ucode_data) == 0x00000001) {
if (*dram_u32(hle, ucode_data + 0x30) == 0xf0000f00) {
v = *dram_u32(hle, ucode_data + 0x28);
switch(v)
{
case 0x1e24138c: /* audio ABI (most common) */
return &alist_process_audio;
case 0x1dc8138c: /* GoldenEye */
return &alist_process_audio_ge;
case 0x1e3c1390: /* BlastCorp, DiddyKongRacing */
return &alist_process_audio_bc;
default:
HleWarnMessage(hle->user_defined, "ABI1 identification regression: v=%08x", v);
}
} else {
v = *dram_u32(hle, ucode_data + 0x10);
switch(v)
{
case 0x11181350: /* MarioKart, WaveRace (E) */
return &alist_process_nead_mk;
case 0x111812e0: /* StarFox (J) */
return &alist_process_nead_sfj;
case 0x110412ac: /* WaveRace (J RevB) */
return &alist_process_nead_wrjb;
case 0x110412cc: /* StarFox/LylatWars (except J) */
return &alist_process_nead_sf;
case 0x1cd01250: /* FZeroX */
return &alist_process_nead_fz;
case 0x1f08122c: /* YoshisStory */
return &alist_process_nead_ys;
case 0x1f38122c: /* 1080° Snowboarding */
return &alist_process_nead_1080;
case 0x1f681230: /* Zelda OoT / Zelda MM (J, J RevA) */
return &alist_process_nead_oot;
case 0x1f801250: /* Zelda MM (except J, J RevA, E Beta), PokemonStadium 2 */
return &alist_process_nead_mm;
case 0x109411f8: /* Zelda MM (E Beta) */
return &alist_process_nead_mmb;
case 0x1eac11b8: /* AnimalCrossing */
return &alist_process_nead_ac;
case 0x00010010: /* MusyX v2 (IndianaJones, BattleForNaboo) */
return &musyx_v2_task;
case 0x1f701238: /* Mario Artist Talent Studio */
return &alist_process_nead_mats;
case 0x1f4c1230: /* FZeroX Expansion */
return &alist_process_nead_efz;
default:
HleWarnMessage(hle->user_defined, "ABI2 identification regression: v=%08x", v);
}
}
} else {
v = *dram_u32(hle, ucode_data + 0x10);
switch(v)
{
case 0x00000001: /* MusyX v1
RogueSquadron, ResidentEvil2, PolarisSnoCross,
TheWorldIsNotEnough, RugratsInParis, NBAShowTime,
HydroThunder, Tarzan, GauntletLegend, Rush2049 */
return &musyx_v1_task;
case 0x0000127c: /* naudio (many games) */
return &alist_process_naudio;
case 0x00001280: /* BanjoKazooie */
return &alist_process_naudio_bk;
case 0x1c58126c: /* DonkeyKong */
return &alist_process_naudio_dk;
case 0x1ae8143c: /* BanjoTooie, JetForceGemini, MickeySpeedWayUSA, PerfectDark */
return &alist_process_naudio_mp3;
case 0x1ab0140c: /* ConkerBadFurDay */
return &alist_process_naudio_cbfd;
default:
HleWarnMessage(hle->user_defined, "ABI3 identification regression: v=%08x", v);
}
}
return NULL;
}
static ucode_func_t try_normal_task_detection(struct hle_t* hle)
{
unsigned int sum =
sum_bytes((void*)dram_u32(hle, *dmem_u32(hle, TASK_UCODE)), min(*dmem_u32(hle, TASK_UCODE_SIZE), 0xf80) >> 1);
switch (sum) {
/* StoreVe12: found in Zelda Ocarina of Time [misleading task->type == 4] */
case 0x278:
/* Nothing to emulate */
return &task_done;
/* GFX: Twintris [misleading task->type == 0] */
case 0x212ee:
if (hle->hle_gfx) {
return &send_dlist_to_gfx_plugin;
}
return NULL;
/* JPEG: found in Pokemon Stadium J */
case 0x2c85a:
return &jpeg_decode_PS0;
/* JPEG: found in Zelda Ocarina of Time, Pokemon Stadium 1, Pokemon Stadium 2 */
case 0x2caa6:
return &jpeg_decode_PS;
/* JPEG: found in Ogre Battle, Bottom of the 9th */
case 0x130de:
case 0x278b0:
return &jpeg_decode_OB;
}
/* Resident Evil 2 */
sum = sum_bytes((void*)dram_u32(hle, *dmem_u32(hle, TASK_UCODE)), 256);
switch (sum) {
case 0x450f:
return &resize_bilinear_task;
case 0x3b44:
return &decode_video_frame_task;
case 0x3d84:
return &fill_video_double_buffer_task;
}
/* HVQM */
sum = sum_bytes((void*)dram_u32(hle, *dmem_u32(hle, TASK_UCODE)), 1488);
switch (sum) {
case 0x19495:
return &hvqm2_decode_sp1_task;
case 0x19728:
return &hvqm2_decode_sp2_task;
}
return NULL;
}
static ucode_func_t non_task_detection(struct hle_t* hle)
{
const unsigned int sum = sum_bytes(hle->imem, 44);
if (sum == 0x9e2)
{
/* CIC x105 ucode (used during boot of CIC x105 games) */
return &cicx105_ucode;
}
return &unknown_ucode;
}
static ucode_func_t task_detection(struct hle_t* hle)
{
if (is_task(hle)) {
ucode_func_t uc_pfunc;
uint32_t type = *dmem_u32(hle, TASK_TYPE);
if (type == 2) {
if (hle->hle_aud) {
return &send_alist_to_audio_plugin;
}
uc_pfunc = try_audio_task_detection(hle);
if (uc_pfunc)
return uc_pfunc;
}
uc_pfunc = try_normal_task_detection(hle);
if (uc_pfunc)
return uc_pfunc;
if (type == 1) {
if (hle->hle_gfx) {
return &send_dlist_to_gfx_plugin;
}
}
return &unknown_task;
}
else {
return non_task_detection(hle);
}
}
#ifdef ENABLE_TASK_DUMP
static void dump_unknown_task(struct hle_t* hle, unsigned int uc_start)
{
char filename[256];
uint32_t ucode = *dmem_u32(hle, TASK_UCODE);
uint32_t ucode_data = *dmem_u32(hle, TASK_UCODE_DATA);
uint32_t data_ptr = *dmem_u32(hle, TASK_DATA_PTR);
sprintf(&filename[0], "task_%x.log", uc_start);
dump_task(hle, filename);
/* dump ucode_boot */
sprintf(&filename[0], "ucode_boot_%x.bin", uc_start);
dump_binary(hle, filename, (void*)dram_u32(hle, *dmem_u32(hle, TASK_UCODE_BOOT)), *dmem_u32(hle, TASK_UCODE_BOOT_SIZE));
/* dump ucode */
if (ucode != 0) {
sprintf(&filename[0], "ucode_%x.bin", uc_start);
dump_binary(hle, filename, (void*)dram_u32(hle, ucode), 0xf80);
}
/* dump ucode_data */
if (ucode_data != 0) {
sprintf(&filename[0], "ucode_data_%x.bin", uc_start);
dump_binary(hle, filename, (void*)dram_u32(hle, ucode_data), *dmem_u32(hle, TASK_UCODE_DATA_SIZE));
}
/* dump data */
if (data_ptr != 0) {
sprintf(&filename[0], "data_%x.bin", uc_start);
dump_binary(hle, filename, (void*)dram_u32(hle, data_ptr), *dmem_u32(hle, TASK_DATA_SIZE));
}
}
static void dump_unknown_non_task(struct hle_t* hle, unsigned int uc_start)
{
char filename[256];
/* dump IMEM & DMEM for further analysis */
sprintf(&filename[0], "imem_%x.bin", uc_start);
dump_binary(hle, filename, hle->imem, 0x1000);
sprintf(&filename[0], "dmem_%x.bin", uc_start);
dump_binary(hle, filename, hle->dmem, 0x1000);
}
static void dump_binary(struct hle_t* hle, const char *const filename,
const unsigned char *const bytes, unsigned int size)
{
FILE *f;
/* if file already exists, do nothing */
f = fopen(filename, "r");
if (f == NULL) {
/* else we write bytes to the file */
f = fopen(filename, "wb");
if (f != NULL) {
if (fwrite(bytes, 1, size, f) != size)
HleErrorMessage(hle->user_defined, "Writing error on %s", filename);
fclose(f);
} else
HleErrorMessage(hle->user_defined, "Couldn't open %s for writing !", filename);
} else
fclose(f);
}
static void dump_task(struct hle_t* hle, const char *const filename)
{
FILE *f;
f = fopen(filename, "r");
if (f == NULL) {
f = fopen(filename, "w");
fprintf(f,
"type = %d\n"
"flags = %d\n"
"ucode_boot = %#08x size = %#x\n"
"ucode = %#08x size = %#x\n"
"ucode_data = %#08x size = %#x\n"
"dram_stack = %#08x size = %#x\n"
"output_buff = %#08x *size = %#x\n"
"data = %#08x size = %#x\n"
"yield_data = %#08x size = %#x\n",
*dmem_u32(hle, TASK_TYPE),
*dmem_u32(hle, TASK_FLAGS),
*dmem_u32(hle, TASK_UCODE_BOOT), *dmem_u32(hle, TASK_UCODE_BOOT_SIZE),
*dmem_u32(hle, TASK_UCODE), *dmem_u32(hle, TASK_UCODE_SIZE),
*dmem_u32(hle, TASK_UCODE_DATA), *dmem_u32(hle, TASK_UCODE_DATA_SIZE),
*dmem_u32(hle, TASK_DRAM_STACK), *dmem_u32(hle, TASK_DRAM_STACK_SIZE),
*dmem_u32(hle, TASK_OUTPUT_BUFF), *dmem_u32(hle, TASK_OUTPUT_BUFF_SIZE),
*dmem_u32(hle, TASK_DATA_PTR), *dmem_u32(hle, TASK_DATA_SIZE),
*dmem_u32(hle, TASK_YIELD_DATA_PTR), *dmem_u32(hle, TASK_YIELD_DATA_SIZE));
fclose(f);
} else
fclose(f);
}
#endif

113
src/hle.h
View file

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - hle.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2002 Hacktarux *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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 *
@ -22,92 +22,33 @@
#ifndef HLE_H
#define HLE_H
#include "m64p_plugin.h"
#include "hle_internal.h"
#define RSP_HLE_VERSION 0x016304
void hle_init(struct hle_t* hle,
unsigned char* dram,
unsigned char* dmem,
unsigned char* imem,
unsigned int* mi_intr,
unsigned int* sp_mem_addr,
unsigned int* sp_dram_addr,
unsigned int* sp_rd_length,
unsigned int* sp_wr_length,
unsigned int* sp_status,
unsigned int* sp_dma_full,
unsigned int* sp_dma_busy,
unsigned int* sp_pc,
unsigned int* sp_semaphore,
unsigned int* dpc_start,
unsigned int* dpc_end,
unsigned int* dpc_current,
unsigned int* dpc_status,
unsigned int* dpc_clock,
unsigned int* dpc_bufbusy,
unsigned int* dpc_pipebusy,
unsigned int* dpc_tmem,
void* user_defined);
#ifdef _BIG_ENDIAN
#define S 0
#define S16 0
#define S8 0
#else
#define S 1
#define S16 2
#define S8 3
#endif
// types
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
typedef signed long long s64;
//#define ACMD_SIZE 32
/*
* Audio flags
*/
#define A_INIT 0x01
#define A_CONTINUE 0x00
#define A_LOOP 0x02
#define A_OUT 0x02
#define A_LEFT 0x02
#define A_RIGHT 0x00
#define A_VOL 0x04
#define A_RATE 0x00
#define A_AUX 0x08
#define A_NOAUX 0x00
#define A_MAIN 0x00
#define A_MIX 0x10
extern RSP_INFO rsp;
typedef struct
{
unsigned int type;
unsigned int flags;
unsigned int ucode_boot;
unsigned int ucode_boot_size;
unsigned int ucode;
unsigned int ucode_size;
unsigned int ucode_data;
unsigned int ucode_data_size;
unsigned int dram_stack;
unsigned int dram_stack_size;
unsigned int output_buff;
unsigned int output_buff_size;
unsigned int data_ptr;
unsigned int data_size;
unsigned int yield_data_ptr;
unsigned int yield_data_size;
} OSTask_t;
void DebugMessage(int level, const char *message, ...);
void jpg_uncompress(OSTask_t *task);
/*void ucode1(OSTask_t *task);
void ucode2(OSTask_t *task);
void ucode3(OSTask_t *task);
void init_ucode1();*/
void init_ucode2();
extern u32 inst1, inst2;
extern u16 AudioInBuffer, AudioOutBuffer, AudioCount;
extern u16 AudioAuxA, AudioAuxC, AudioAuxE;
extern u32 loopval; // Value set by A_SETLOOP : Possible conflict with SETVOLUME???
//extern u32 UCData, UDataLen;
void hle_execute(struct hle_t* hle);
#endif

46
src/hle_external.h Normal file
View file

@ -0,0 +1,46 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - hle_external.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef HLE_EXTERNAL_H
#define HLE_EXTERNAL_H
#if defined(__GNUC__)
#define ATTR_FMT(fmtpos, attrpos) __attribute__ ((format (printf, fmtpos, attrpos)))
#else
#define ATTR_FMT(fmtpos, attrpos)
#endif
/* users of the hle core are expected to define these functions */
void HleVerboseMessage(void* user_defined, const char *message, ...) ATTR_FMT(2, 3);
void HleInfoMessage(void* user_defined, const char *message, ...) ATTR_FMT(2, 3);
void HleErrorMessage(void* user_defined, const char *message, ...) ATTR_FMT(2, 3);
void HleWarnMessage(void* user_defined, const char *message, ...) ATTR_FMT(2, 3);
void HleCheckInterrupts(void* user_defined);
void HleProcessDlistList(void* user_defined);
void HleProcessAlistList(void* user_defined);
void HleProcessRdpList(void* user_defined);
void HleShowCFB(void* user_defined);
int HleForwardTask(void* user_defined);
#endif

93
src/hle_internal.h Normal file
View file

@ -0,0 +1,93 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - hle_internal.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef HLE_INTERNAL_H
#define HLE_INTERNAL_H
#include <stdint.h>
#include "ucodes.h"
/* rsp hle internal state - internal usage only */
struct hle_t
{
unsigned char* dram;
unsigned char* dmem;
unsigned char* imem;
unsigned int* mi_intr;
unsigned int* sp_mem_addr;
unsigned int* sp_dram_addr;
unsigned int* sp_rd_length;
unsigned int* sp_wr_length;
unsigned int* sp_status;
unsigned int* sp_dma_full;
unsigned int* sp_dma_busy;
unsigned int* sp_pc;
unsigned int* sp_semaphore;
unsigned int* dpc_start;
unsigned int* dpc_end;
unsigned int* dpc_current;
unsigned int* dpc_status;
unsigned int* dpc_clock;
unsigned int* dpc_bufbusy;
unsigned int* dpc_pipebusy;
unsigned int* dpc_tmem;
/* for user convenience, this will be passed to "external" functions */
void* user_defined;
int hle_gfx;
int hle_aud;
/* alist.c */
uint8_t alist_buffer[0x1000];
/* alist_audio.c */
struct alist_audio_t alist_audio;
/* alist_naudio.c */
struct alist_naudio_t alist_naudio;
/* alist_nead.c */
struct alist_nead_t alist_nead;
/* mp3.c */
uint8_t mp3_buffer[0x1000];
struct cached_ucodes_t cached_ucodes;
};
/* some mips interface interrupt flags */
#define MI_INTR_SP 0x1
/* some rsp status flags */
#define SP_STATUS_HALT 0x1
#define SP_STATUS_BROKE 0x2
#define SP_STATUS_INTR_ON_BREAK 0x40
#define SP_STATUS_TASKDONE 0x200
void rsp_break(struct hle_t* hle, unsigned int setbits);
#endif

354
src/hvqm.c Normal file
View file

@ -0,0 +1,354 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - hvqm.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2020 Gilles Siberlin *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
/* Nest size */
#define HVQM2_NESTSIZE_L 70 /* Number of elements on long side */
#define HVQM2_NESTSIZE_S 38 /* Number of elements on short side */
#define HVQM2_NESTSIZE (HVQM2_NESTSIZE_L * HVQM2_NESTSIZE_S)
struct HVQM2Block {
uint8_t nbase;
uint8_t dc;
uint8_t dc_l;
uint8_t dc_r;
uint8_t dc_u;
uint8_t dc_d;
};
struct HVQM2Basis {
uint8_t sx;
uint8_t sy;
int16_t scale;
uint16_t offset;
uint16_t lineskip;
};
struct HVQM2Arg {
uint32_t info;
uint32_t buf;
uint16_t buf_width;
uint8_t chroma_step_h;
uint8_t chroma_step_v;
uint16_t hmcus;
uint16_t vmcus;
uint8_t alpha;
uint32_t nest;
};
struct RGBA {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
static struct HVQM2Arg arg;
static const int16_t constant[5][16] = {
{0x0006,0x0008,0x0008,0x0006,0x0008,0x000A,0x000A,0x0008,0x0008,0x000A,0x000A,0x0008,0x0006,0x0008,0x0008,0x0006},
{0x0002,0x0000,0xFFFF,0xFFFF,0x0002,0x0000,0xFFFF,0xFFFF,0x0002,0x0000,0xFFFF,0xFFFF,0x0002,0x0000,0xFFFF,0xFFFF},
{0xFFFF,0xFFFF,0x0000,0x0002,0xFFFF,0xFFFF,0x0000,0x0002,0xFFFF,0xFFFF,0x0000,0x0002,0xFFFF,0xFFFF,0x0000,0x0002},
{0x0002,0x0002,0x0002,0x0002,0x0000,0x0000,0x0000,0x0000,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF},
{0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x0000,0x0000,0x0000,0x0000,0x0002,0x0002,0x0002,0x0002}
};
static int process_info(struct hle_t* hle, uint8_t* base, int16_t* out)
{
struct HVQM2Block block;
uint8_t nbase = *base;
dram_load_u8(hle, (uint8_t*)&block, arg.info, sizeof(struct HVQM2Block));
arg.info += 8;
*base = block.nbase & 0x7;
if ((block.nbase & nbase) != 0)
return 0;
if (block.nbase == 0)
{
//LABEL8
for (int i = 0; i < 16; i++)
{
out[i] = constant[0][i] * block.dc;
out[i] += constant[1][i] * block.dc_l;
out[i] += constant[2][i] * block.dc_r;
out[i] += constant[3][i] * block.dc_u;
out[i] += constant[4][i] * block.dc_d;
out[i] += 4;
out[i] >>= 3;
}
}
else if ((block.nbase & 0xf) == 0)
{
//LABEL7
for (int i = 0; i < 16; i++)
{
out[i] = *dram_u8(hle, arg.info);
arg.info++;
}
}
else if (*base == 0)
{
//LABEL6
for (int i = 0; i < 16; i++)
{
out[i] = *(int8_t*)dram_u8(hle, arg.info) + block.dc;
arg.info++;
}
}
else
{
//LABEL5
struct HVQM2Basis basis;
for (int i = 0; i < 16; i++)
out[i] = block.dc;
for (; *base != 0; (*base)--)
{
basis.sx = *dram_u8(hle, arg.info);
arg.info++;
basis.sy = *dram_u8(hle, arg.info);
arg.info++;
basis.scale = *dram_u16(hle, arg.info);
arg.info += 2;
basis.offset = *dram_u16(hle, arg.info);
arg.info += 2;
basis.lineskip = *dram_u16(hle, arg.info);
arg.info += 2;
int16_t vec[16];
uint32_t addr = arg.nest + basis.offset;
int shift = (basis.sx != 0) ? 1 : 0;
//LABEL9
//LABEL10
for (int i = 0; i < 16; i += 4)
{
vec[i] = *dram_u8(hle, addr);
vec[i + 1] = *dram_u8(hle, addr + (1 << shift));
vec[i + 2] = *dram_u8(hle, addr + (2 << shift));
vec[i + 3] = *dram_u8(hle, addr + (3 << shift));
addr += basis.lineskip;
}
//LABEL11
int16_t sum = 0x8;
for (int i = 0; i < 16; i++)
sum += vec[i];
sum >>= 4;
int16_t max = 0;
for (int i = 0; i < 16; i++)
{
vec[i] -= sum;
max = (abs(vec[i]) > max) ? abs(vec[i]) : max;
}
double dmax = 0.0;
if (max > 0)
dmax = (double)(basis.scale << 2) / (double)max;
for (int i = 0; i < 16; i++)
out[i] += (vec[i] < 0) ? (int16_t)((double)vec[i] * dmax - 0.5) : (int16_t)((double)vec[i] * dmax + 0.5);
block.nbase &= 8;
}
assert(block.nbase == 0);
//if(block.nbase != 0)
// LABEL6
}
return 1;
}
#define SATURATE8(x) ((unsigned int) x <= 255 ? x : (x < 0 ? 0: 255))
static struct RGBA YCbCr_to_RGBA(int16_t Y, int16_t Cb, int16_t Cr, uint8_t alpha)
{
struct RGBA color;
//Format S10.6
int r = (int)(((double)Y + 0.5) + (1.765625 * (double)(Cr - 128)));
int g = (int)(((double)Y + 0.5) - (0.34375 * (double)(Cr - 128)) - (0.71875 * (double)(Cb - 128)));
int b = (int)(((double)Y + 0.5) + (1.40625 * (double)(Cb - 128)));
color.r = SATURATE8(r);
color.g = SATURATE8(g);
color.b = SATURATE8(b);
color.a = alpha;
return color;
}
void store_rgba5551(struct hle_t* hle, struct RGBA color, uint32_t * addr)
{
uint16_t pixel = ((color.b >> 3) << 11) | ((color.g >> 3) << 6) | ((color.r >> 3) << 1) | (color.a & 1);
dram_store_u16(hle, &pixel, *addr, 1);
*addr += 2;
}
void store_rgba8888(struct hle_t* hle, struct RGBA color, uint32_t * addr)
{
uint32_t pixel = (color.b << 24) | (color.g << 16) | (color.r << 8) | color.a;
dram_store_u32(hle, &pixel, *addr, 1);
*addr += 4;
}
typedef void(*store_pixel_t)(struct hle_t* hle, struct RGBA color, uint32_t * addr);
static void hvqm2_decode(struct hle_t* hle, int is32)
{
//uint32_t uc_data_ptr = *dmem_u32(hle, TASK_UCODE_DATA);
uint32_t data_ptr = *dmem_u32(hle, TASK_DATA_PTR);
assert((*dmem_u32(hle, TASK_FLAGS) & 0x1) == 0);
/* Fill HVQM2Arg struct */
arg.info = *dram_u32(hle, data_ptr);
data_ptr += 4;
arg.buf = *dram_u32(hle, data_ptr);
data_ptr += 4;
arg.buf_width = *dram_u16(hle, data_ptr);
data_ptr += 2;
arg.chroma_step_h = *dram_u8(hle, data_ptr);
data_ptr++;
arg.chroma_step_v = *dram_u8(hle, data_ptr);
data_ptr++;
arg.hmcus = *dram_u16(hle, data_ptr);
data_ptr += 2;
arg.vmcus = *dram_u16(hle, data_ptr);
data_ptr += 2;
arg.alpha = *dram_u8(hle, data_ptr);
arg.nest = data_ptr + 1;
assert(arg.chroma_step_h == 2);
assert((arg.chroma_step_v == 1) || (arg.chroma_step_v == 2));
assert((*hle->sp_status & 0x80) == 0); //SP_STATUS_YIELD
int length, skip;
store_pixel_t store_pixel;
if (is32)
{
length = 0x20;
skip = arg.buf_width << 2;
arg.buf_width <<= 4;
store_pixel = &store_rgba8888;
}
else
{
length = 0x10;
skip = arg.buf_width << 1;
arg.buf_width <<= 3;
store_pixel = &store_rgba5551;
}
if (arg.chroma_step_v == 2)
arg.buf_width += arg.buf_width;
for (int i = arg.vmcus; i != 0; i--)
{
uint32_t out;
int j;
for (j = arg.hmcus, out = arg.buf; j != 0; j--, out += length)
{
uint8_t base = 0x80;
int16_t Cb[16], Cr[16], Y1[32], Y2[32];
int16_t* pCb = Cb;
int16_t* pCr = Cr;
int16_t* pY1 = Y1;
int16_t* pY2 = Y2;
if (arg.chroma_step_v == 2)
{
if (process_info(hle, &base, pY1) == 0)
continue;
if (process_info(hle, &base, pY2) == 0)
continue;
pY1 = &Y1[16];
pY2 = &Y2[16];
}
if (process_info(hle, &base, pY1) == 0)
continue;
if (process_info(hle, &base, pY2) == 0)
continue;
if (process_info(hle, &base, Cr) == 0)
continue;
if (process_info(hle, &base, Cb) == 0)
continue;
pY1 = Y1;
pY2 = Y2;
uint32_t out_buf = out;
for (int k = 0; k < 4; k++)
{
for (int m = 0; m < arg.chroma_step_v; m++)
{
uint32_t addr = out_buf;
for (int l = 0; l < 4; l++)
{
struct RGBA color = YCbCr_to_RGBA(pY1[l], pCb[l >> 1], pCr[l >> 1], arg.alpha);
store_pixel(hle, color, &addr);
}
for (int l = 0; l < 4; l++)
{
struct RGBA color = YCbCr_to_RGBA(pY2[l], pCb[(l + 4) >> 1], pCr[(l + 4) >> 1], arg.alpha);
store_pixel(hle, color, &addr);
}
out_buf += skip;
pY1 += 4;
pY2 += 4;
}
pCr += 4;
pCb += 4;
}
}
arg.buf += arg.buf_width;
}
rsp_break(hle, SP_STATUS_TASKDONE);
}
void hvqm2_decode_sp1_task(struct hle_t* hle)
{
hvqm2_decode(hle, 0);
}
void hvqm2_decode_sp2_task(struct hle_t* hle)
{
hvqm2_decode(hle, 1);
}

File diff suppressed because it is too large Load diff

View file

@ -1,320 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - main.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include "m64p_types.h"
#include "m64p_plugin.h"
#include "hle.h"
/* global variables */
RSP_INFO rsp;
/* local variables */
static const int AudioHle = 0, GraphicsHle = 1;
static void (*l_DebugCallback)(void *, int, const char *) = NULL;
static void *l_DebugCallContext = NULL;
static int l_PluginInit = 0;
/* local functions */
static int audio_ucode_detect(OSTask_t *task)
{
if (*(unsigned int*)(rsp.RDRAM + task->ucode_data + 0) != 0x1)
{
if (*(rsp.RDRAM + task->ucode_data + (0 ^ (3-S8))) == 0xF)
return 4;
else
return 3;
}
else
{
if (*(unsigned int*)(rsp.RDRAM + task->ucode_data + 0x30) == 0xF0000F00)
return 1;
else
return 2;
}
}
extern void (*ABI1[0x20])();
extern void (*ABI2[0x20])();
extern void (*ABI3[0x20])();
void (*ABI[0x20])();
u32 inst1, inst2;
static int audio_ucode(OSTask_t *task)
{
unsigned int *p_alist = (unsigned int*)(rsp.RDRAM + task->data_ptr);
unsigned int i;
switch(audio_ucode_detect(task))
{
case 1: // mario ucode
memcpy( ABI, ABI1, sizeof(ABI[0])*0x20 );
break;
case 2: // banjo kazooie ucode
memcpy( ABI, ABI2, sizeof(ABI[0])*0x20 );
break;
case 3: // zelda ucode
memcpy( ABI, ABI3, sizeof(ABI[0])*0x20 );
break;
default:
{
DebugMessage(M64MSG_WARNING, "unknown audio ucode");
return -1;
}
}
// data = (short*)(rsp.RDRAM + task->ucode_data);
for (i = 0; i < (task->data_size/4); i += 2)
{
inst1 = p_alist[i];
inst2 = p_alist[i+1];
ABI[inst1 >> 24]();
}
return 0;
}
/* Global functions */
void DebugMessage(int level, const char *message, ...)
{
char msgbuf[1024];
va_list args;
if (l_DebugCallback == NULL)
return;
va_start(args, message);
vsprintf(msgbuf, message, args);
(*l_DebugCallback)(l_DebugCallContext, level, msgbuf);
va_end(args);
}
/* DLL-exported functions */
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
void (*DebugCallback)(void *, int, const char *))
{
if (l_PluginInit)
return M64ERR_ALREADY_INIT;
/* first thing is to set the callback function for debug info */
l_DebugCallback = DebugCallback;
l_DebugCallContext = Context;
/* this plugin doesn't use any Core library functions (ex for Configuration), so no need to keep the CoreLibHandle */
l_PluginInit = 1;
return M64ERR_SUCCESS;
}
EXPORT m64p_error CALL PluginShutdown(void)
{
if (!l_PluginInit)
return M64ERR_NOT_INIT;
/* reset some local variable */
l_DebugCallback = NULL;
l_DebugCallContext = NULL;
l_PluginInit = 0;
return M64ERR_SUCCESS;
}
EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities)
{
/* set version info */
if (PluginType != NULL)
*PluginType = M64PLUGIN_RSP;
if (PluginVersion != NULL)
*PluginVersion = RSP_HLE_VERSION;
if (APIVersion != NULL)
*APIVersion = PLUGIN_API_VERSION;
if (PluginNamePtr != NULL)
*PluginNamePtr = "Hacktarux/Azimer High-Level Emulation RSP Plugin";
if (Capabilities != NULL)
{
*Capabilities = 0;
}
return M64ERR_SUCCESS;
}
EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles)
{
OSTask_t *task = (OSTask_t*)(rsp.DMEM + 0xFC0);
unsigned int i, sum=0;
if( task->type == 1 && task->data_ptr != 0 && GraphicsHle) {
if (rsp.ProcessDlistList != NULL) {
rsp.ProcessDlistList();
}
*rsp.SP_STATUS_REG |= 0x0203;
if ((*rsp.SP_STATUS_REG & 0x40) != 0 ) {
*rsp.MI_INTR_REG |= 0x1;
rsp.CheckInterrupts();
}
*rsp.DPC_STATUS_REG &= ~0x0002;
return Cycles;
} else if (task->type == 2 && AudioHle) {
if (rsp.ProcessAlistList != NULL) {
rsp.ProcessAlistList();
}
*rsp.SP_STATUS_REG |= 0x0203;
if ((*rsp.SP_STATUS_REG & 0x40) != 0 ) {
*rsp.MI_INTR_REG |= 0x1;
rsp.CheckInterrupts();
}
return Cycles;
} else if (task->type == 7) {
rsp.ShowCFB();
}
*rsp.SP_STATUS_REG |= 0x203;
if ((*rsp.SP_STATUS_REG & 0x40) != 0 )
{
*rsp.MI_INTR_REG |= 0x1;
rsp.CheckInterrupts();
}
if (task->ucode_size <= 0x1000)
for (i=0; i<(task->ucode_size/2); i++)
sum += *(rsp.RDRAM + task->ucode + i);
else
for (i=0; i<(0x1000/2); i++)
sum += *(rsp.IMEM + i);
if (task->ucode_size > 0x1000)
{
switch(sum)
{
case 0x9E2: // banjo tooie (U) boot code
{
int i,j;
memcpy(rsp.IMEM + 0x120, rsp.RDRAM + 0x1e8, 0x1e8);
for (j=0; j<0xfc; j++)
for (i=0; i<8; i++)
*(rsp.RDRAM+((0x2fb1f0+j*0xff0+i)^S8))=*(rsp.IMEM+((0x120+j*8+i)^S8));
}
return Cycles;
break;
case 0x9F2: // banjo tooie (E) + zelda oot (E) boot code
{
int i,j;
memcpy(rsp.IMEM + 0x120, rsp.RDRAM + 0x1e8, 0x1e8);
for (j=0; j<0xfc; j++)
for (i=0; i<8; i++)
*(rsp.RDRAM+((0x2fb1f0+j*0xff0+i)^S8))=*(rsp.IMEM+((0x120+j*8+i)^S8));
}
return Cycles;
break;
}
}
else
{
switch(task->type)
{
case 2: // audio
if (audio_ucode(task) == 0)
return Cycles;
break;
case 4: // jpeg
switch(sum)
{
case 0x278: // used by zelda during boot
*rsp.SP_STATUS_REG |= 0x200;
return Cycles;
break;
case 0x2e4fc: // uncompress
jpg_uncompress(task);
return Cycles;
break;
default:
{
DebugMessage(M64MSG_WARNING, "unknown jpeg task: sum:%x", sum);
}
}
break;
}
}
{
FILE *f;
DebugMessage(M64MSG_WARNING, "unknown task: type:%d sum:%x PC:%lx", (int)task->type, sum, (unsigned long) rsp.SP_PC_REG);
if (task->ucode_size <= 0x1000)
{
f = fopen("imem.dat", "wb");
if (f == NULL || fwrite(rsp.RDRAM + task->ucode, 1, task->ucode_size, f) != task->ucode_size)
DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file imem.dat");
fclose(f);
f = fopen("dmem.dat", "wb");
if (f == NULL || fwrite(rsp.RDRAM + task->ucode_data, 1, task->ucode_data_size, f) != task->ucode_data_size)
DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file dmem.dat");
fclose(f);
}
else
{
f = fopen("imem.dat", "wb");
if (f == NULL || fwrite(rsp.IMEM, 1, 0x1000, f) != 0x1000)
DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file imem.dat");
fclose(f);
f = fopen("dmem.dat", "wb");
if (f == NULL || fwrite(rsp.DMEM, 1, 0x1000, f) != 0x1000)
DebugMessage(M64MSG_WARNING, "couldn't write to RSP debugging file dmem.dat");
fclose(f);
}
}
return Cycles;
}
EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, unsigned int *CycleCount)
{
rsp = Rsp_Info;
}
EXPORT void CALL RomClosed(void)
{
int i;
for (i=0; i<0x1000; i++)
{
rsp.DMEM[i] = rsp.IMEM[i] = 0;
}
//init_ucode1();
init_ucode2();
}

74
src/memory.c Normal file
View file

@ -0,0 +1,74 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - memory.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string.h>
#include "memory.h"
/* Global functions */
void load_u8(uint8_t* dst, const unsigned char* buffer, unsigned address, size_t count)
{
while (count != 0) {
*(dst++) = *u8(buffer, address);
address += 1;
--count;
}
}
void load_u16(uint16_t* dst, const unsigned char* buffer, unsigned address, size_t count)
{
while (count != 0) {
*(dst++) = *u16(buffer, address);
address += 2;
--count;
}
}
void load_u32(uint32_t* dst, const unsigned char* buffer, unsigned address, size_t count)
{
/* Optimization for uint32_t */
memcpy(dst, u32(buffer, address), count * sizeof(uint32_t));
}
void store_u8(unsigned char* buffer, unsigned address, const uint8_t* src, size_t count)
{
while (count != 0) {
*u8(buffer, address) = *(src++);
address += 1;
--count;
}
}
void store_u16(unsigned char* buffer, unsigned address, const uint16_t* src, size_t count)
{
while (count != 0) {
*u16(buffer, address) = *(src++);
address += 2;
--count;
}
}
void store_u32(unsigned char* buffer, unsigned address, const uint32_t* src, size_t count)
{
/* Optimization for uint32_t */
memcpy(u32(buffer, address), src, count * sizeof(uint32_t));
}

185
src/memory.h Normal file
View file

@ -0,0 +1,185 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - memory.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef MEMORY_H
#define MEMORY_H
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include "common.h"
#include "hle_internal.h"
#ifdef M64P_BIG_ENDIAN
#define S 0
#define S16 0
#define S8 0
#else
#define S 1
#define S16 2
#define S8 3
#endif
enum {
TASK_TYPE = 0xfc0,
TASK_FLAGS = 0xfc4,
TASK_UCODE_BOOT = 0xfc8,
TASK_UCODE_BOOT_SIZE = 0xfcc,
TASK_UCODE = 0xfd0,
TASK_UCODE_SIZE = 0xfd4,
TASK_UCODE_DATA = 0xfd8,
TASK_UCODE_DATA_SIZE = 0xfdc,
TASK_DRAM_STACK = 0xfe0,
TASK_DRAM_STACK_SIZE = 0xfe4,
TASK_OUTPUT_BUFF = 0xfe8,
TASK_OUTPUT_BUFF_SIZE = 0xfec,
TASK_DATA_PTR = 0xff0,
TASK_DATA_SIZE = 0xff4,
TASK_YIELD_DATA_PTR = 0xff8,
TASK_YIELD_DATA_SIZE = 0xffc
};
static inline unsigned int align(unsigned int x, unsigned amount)
{
--amount;
return (x + amount) & ~amount;
}
static inline uint8_t* u8(const unsigned char* buffer, unsigned address)
{
return (uint8_t*)(buffer + (address ^ S8));
}
static inline uint16_t* u16(const unsigned char* buffer, unsigned address)
{
assert((address & 1) == 0);
return (uint16_t*)(buffer + (address ^ S16));
}
static inline uint32_t* u32(const unsigned char* buffer, unsigned address)
{
assert((address & 3) == 0);
return (uint32_t*)(buffer + address);
}
void load_u8 (uint8_t* dst, const unsigned char* buffer, unsigned address, size_t count);
void load_u16(uint16_t* dst, const unsigned char* buffer, unsigned address, size_t count);
void load_u32(uint32_t* dst, const unsigned char* buffer, unsigned address, size_t count);
void store_u8 (unsigned char* buffer, unsigned address, const uint8_t* src, size_t count);
void store_u16(unsigned char* buffer, unsigned address, const uint16_t* src, size_t count);
void store_u32(unsigned char* buffer, unsigned address, const uint32_t* src, size_t count);
/* convenient functions for DMEM access */
static inline uint8_t* dmem_u8(struct hle_t* hle, uint16_t address)
{
return u8(hle->dmem, address & 0xfff);
}
static inline uint16_t* dmem_u16(struct hle_t* hle, uint16_t address)
{
return u16(hle->dmem, address & 0xfff);
}
static inline uint32_t* dmem_u32(struct hle_t* hle, uint16_t address)
{
return u32(hle->dmem, address & 0xfff);
}
static inline void dmem_load_u8(struct hle_t* hle, uint8_t* dst, uint16_t address, size_t count)
{
load_u8(dst, hle->dmem, address & 0xfff, count);
}
static inline void dmem_load_u16(struct hle_t* hle, uint16_t* dst, uint16_t address, size_t count)
{
load_u16(dst, hle->dmem, address & 0xfff, count);
}
static inline void dmem_load_u32(struct hle_t* hle, uint32_t* dst, uint16_t address, size_t count)
{
load_u32(dst, hle->dmem, address & 0xfff, count);
}
static inline void dmem_store_u8(struct hle_t* hle, const uint8_t* src, uint16_t address, size_t count)
{
store_u8(hle->dmem, address & 0xfff, src, count);
}
static inline void dmem_store_u16(struct hle_t* hle, const uint16_t* src, uint16_t address, size_t count)
{
store_u16(hle->dmem, address & 0xfff, src, count);
}
static inline void dmem_store_u32(struct hle_t* hle, const uint32_t* src, uint16_t address, size_t count)
{
store_u32(hle->dmem, address & 0xfff, src, count);
}
/* convenient functions DRAM access */
static inline uint8_t* dram_u8(struct hle_t* hle, uint32_t address)
{
return u8(hle->dram, address & 0xffffff);
}
static inline uint16_t* dram_u16(struct hle_t* hle, uint32_t address)
{
return u16(hle->dram, address & 0xffffff);
}
static inline uint32_t* dram_u32(struct hle_t* hle, uint32_t address)
{
return u32(hle->dram, address & 0xffffff);
}
static inline void dram_load_u8(struct hle_t* hle, uint8_t* dst, uint32_t address, size_t count)
{
load_u8(dst, hle->dram, address & 0xffffff, count);
}
static inline void dram_load_u16(struct hle_t* hle, uint16_t* dst, uint32_t address, size_t count)
{
load_u16(dst, hle->dram, address & 0xffffff, count);
}
static inline void dram_load_u32(struct hle_t* hle, uint32_t* dst, uint32_t address, size_t count)
{
load_u32(dst, hle->dram, address & 0xffffff, count);
}
static inline void dram_store_u8(struct hle_t* hle, const uint8_t* src, uint32_t address, size_t count)
{
store_u8(hle->dram, address & 0xffffff, src, count);
}
static inline void dram_store_u16(struct hle_t* hle, const uint16_t* src, uint32_t address, size_t count)
{
store_u16(hle->dram, address & 0xffffff, src, count);
}
static inline void dram_store_u32(struct hle_t* hle, const uint32_t* src, uint32_t address, size_t count)
{
store_u32(hle->dram, address & 0xffffff, src, count);
}
#endif

684
src/mp3.c Normal file
View file

@ -0,0 +1,684 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - mp3.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdint.h>
#include <string.h>
#include "arithmetics.h"
#include "hle_internal.h"
#include "memory.h"
static void InnerLoop(struct hle_t* hle,
uint32_t outPtr, uint32_t inPtr,
uint32_t t6, uint32_t t5, uint32_t t4);
static const uint16_t DeWindowLUT [0x420] = {
0x0000, 0xFFF3, 0x005D, 0xFF38, 0x037A, 0xF736, 0x0B37, 0xC00E,
0x7FFF, 0x3FF2, 0x0B37, 0x08CA, 0x037A, 0x00C8, 0x005D, 0x000D,
0x0000, 0xFFF3, 0x005D, 0xFF38, 0x037A, 0xF736, 0x0B37, 0xC00E,
0x7FFF, 0x3FF2, 0x0B37, 0x08CA, 0x037A, 0x00C8, 0x005D, 0x000D,
0x0000, 0xFFF2, 0x005F, 0xFF1D, 0x0369, 0xF697, 0x0A2A, 0xBCE7,
0x7FEB, 0x3CCB, 0x0C2B, 0x082B, 0x0385, 0x00AF, 0x005B, 0x000B,
0x0000, 0xFFF2, 0x005F, 0xFF1D, 0x0369, 0xF697, 0x0A2A, 0xBCE7,
0x7FEB, 0x3CCB, 0x0C2B, 0x082B, 0x0385, 0x00AF, 0x005B, 0x000B,
0x0000, 0xFFF1, 0x0061, 0xFF02, 0x0354, 0xF5F9, 0x0905, 0xB9C4,
0x7FB0, 0x39A4, 0x0D08, 0x078C, 0x038C, 0x0098, 0x0058, 0x000A,
0x0000, 0xFFF1, 0x0061, 0xFF02, 0x0354, 0xF5F9, 0x0905, 0xB9C4,
0x7FB0, 0x39A4, 0x0D08, 0x078C, 0x038C, 0x0098, 0x0058, 0x000A,
0x0000, 0xFFEF, 0x0062, 0xFEE6, 0x033B, 0xF55C, 0x07C8, 0xB6A4,
0x7F4D, 0x367E, 0x0DCE, 0x06EE, 0x038F, 0x0080, 0x0056, 0x0009,
0x0000, 0xFFEF, 0x0062, 0xFEE6, 0x033B, 0xF55C, 0x07C8, 0xB6A4,
0x7F4D, 0x367E, 0x0DCE, 0x06EE, 0x038F, 0x0080, 0x0056, 0x0009,
0x0000, 0xFFEE, 0x0063, 0xFECA, 0x031C, 0xF4C3, 0x0671, 0xB38C,
0x7EC2, 0x335D, 0x0E7C, 0x0652, 0x038E, 0x006B, 0x0053, 0x0008,
0x0000, 0xFFEE, 0x0063, 0xFECA, 0x031C, 0xF4C3, 0x0671, 0xB38C,
0x7EC2, 0x335D, 0x0E7C, 0x0652, 0x038E, 0x006B, 0x0053, 0x0008,
0x0000, 0xFFEC, 0x0064, 0xFEAC, 0x02F7, 0xF42C, 0x0502, 0xB07C,
0x7E12, 0x3041, 0x0F14, 0x05B7, 0x038A, 0x0056, 0x0050, 0x0007,
0x0000, 0xFFEC, 0x0064, 0xFEAC, 0x02F7, 0xF42C, 0x0502, 0xB07C,
0x7E12, 0x3041, 0x0F14, 0x05B7, 0x038A, 0x0056, 0x0050, 0x0007,
0x0000, 0xFFEB, 0x0064, 0xFE8E, 0x02CE, 0xF399, 0x037A, 0xAD75,
0x7D3A, 0x2D2C, 0x0F97, 0x0520, 0x0382, 0x0043, 0x004D, 0x0007,
0x0000, 0xFFEB, 0x0064, 0xFE8E, 0x02CE, 0xF399, 0x037A, 0xAD75,
0x7D3A, 0x2D2C, 0x0F97, 0x0520, 0x0382, 0x0043, 0x004D, 0x0007,
0xFFFF, 0xFFE9, 0x0063, 0xFE6F, 0x029E, 0xF30B, 0x01D8, 0xAA7B,
0x7C3D, 0x2A1F, 0x1004, 0x048B, 0x0377, 0x0030, 0x004A, 0x0006,
0xFFFF, 0xFFE9, 0x0063, 0xFE6F, 0x029E, 0xF30B, 0x01D8, 0xAA7B,
0x7C3D, 0x2A1F, 0x1004, 0x048B, 0x0377, 0x0030, 0x004A, 0x0006,
0xFFFF, 0xFFE7, 0x0062, 0xFE4F, 0x0269, 0xF282, 0x001F, 0xA78D,
0x7B1A, 0x271C, 0x105D, 0x03F9, 0x036A, 0x001F, 0x0046, 0x0006,
0xFFFF, 0xFFE7, 0x0062, 0xFE4F, 0x0269, 0xF282, 0x001F, 0xA78D,
0x7B1A, 0x271C, 0x105D, 0x03F9, 0x036A, 0x001F, 0x0046, 0x0006,
0xFFFF, 0xFFE4, 0x0061, 0xFE2F, 0x022F, 0xF1FF, 0xFE4C, 0xA4AF,
0x79D3, 0x2425, 0x10A2, 0x036C, 0x0359, 0x0010, 0x0043, 0x0005,
0xFFFF, 0xFFE4, 0x0061, 0xFE2F, 0x022F, 0xF1FF, 0xFE4C, 0xA4AF,
0x79D3, 0x2425, 0x10A2, 0x036C, 0x0359, 0x0010, 0x0043, 0x0005,
0xFFFF, 0xFFE2, 0x005E, 0xFE10, 0x01EE, 0xF184, 0xFC61, 0xA1E1,
0x7869, 0x2139, 0x10D3, 0x02E3, 0x0346, 0x0001, 0x0040, 0x0004,
0xFFFF, 0xFFE2, 0x005E, 0xFE10, 0x01EE, 0xF184, 0xFC61, 0xA1E1,
0x7869, 0x2139, 0x10D3, 0x02E3, 0x0346, 0x0001, 0x0040, 0x0004,
0xFFFF, 0xFFE0, 0x005B, 0xFDF0, 0x01A8, 0xF111, 0xFA5F, 0x9F27,
0x76DB, 0x1E5C, 0x10F2, 0x025E, 0x0331, 0xFFF3, 0x003D, 0x0004,
0xFFFF, 0xFFE0, 0x005B, 0xFDF0, 0x01A8, 0xF111, 0xFA5F, 0x9F27,
0x76DB, 0x1E5C, 0x10F2, 0x025E, 0x0331, 0xFFF3, 0x003D, 0x0004,
0xFFFF, 0xFFDE, 0x0057, 0xFDD0, 0x015B, 0xF0A7, 0xF845, 0x9C80,
0x752C, 0x1B8E, 0x1100, 0x01DE, 0x0319, 0xFFE7, 0x003A, 0x0003,
0xFFFF, 0xFFDE, 0x0057, 0xFDD0, 0x015B, 0xF0A7, 0xF845, 0x9C80,
0x752C, 0x1B8E, 0x1100, 0x01DE, 0x0319, 0xFFE7, 0x003A, 0x0003,
0xFFFE, 0xFFDB, 0x0053, 0xFDB0, 0x0108, 0xF046, 0xF613, 0x99EE,
0x735C, 0x18D1, 0x10FD, 0x0163, 0x0300, 0xFFDC, 0x0037, 0x0003,
0xFFFE, 0xFFDB, 0x0053, 0xFDB0, 0x0108, 0xF046, 0xF613, 0x99EE,
0x735C, 0x18D1, 0x10FD, 0x0163, 0x0300, 0xFFDC, 0x0037, 0x0003,
0xFFFE, 0xFFD8, 0x004D, 0xFD90, 0x00B0, 0xEFF0, 0xF3CC, 0x9775,
0x716C, 0x1624, 0x10EA, 0x00EE, 0x02E5, 0xFFD2, 0x0033, 0x0003,
0xFFFE, 0xFFD8, 0x004D, 0xFD90, 0x00B0, 0xEFF0, 0xF3CC, 0x9775,
0x716C, 0x1624, 0x10EA, 0x00EE, 0x02E5, 0xFFD2, 0x0033, 0x0003,
0xFFFE, 0xFFD6, 0x0047, 0xFD72, 0x0051, 0xEFA6, 0xF16F, 0x9514,
0x6F5E, 0x138A, 0x10C8, 0x007E, 0x02CA, 0xFFC9, 0x0030, 0x0003,
0xFFFE, 0xFFD6, 0x0047, 0xFD72, 0x0051, 0xEFA6, 0xF16F, 0x9514,
0x6F5E, 0x138A, 0x10C8, 0x007E, 0x02CA, 0xFFC9, 0x0030, 0x0003,
0xFFFE, 0xFFD3, 0x0040, 0xFD54, 0xFFEC, 0xEF68, 0xEEFC, 0x92CD,
0x6D33, 0x1104, 0x1098, 0x0014, 0x02AC, 0xFFC0, 0x002D, 0x0002,
0xFFFE, 0xFFD3, 0x0040, 0xFD54, 0xFFEC, 0xEF68, 0xEEFC, 0x92CD,
0x6D33, 0x1104, 0x1098, 0x0014, 0x02AC, 0xFFC0, 0x002D, 0x0002,
0x0030, 0xFFC9, 0x02CA, 0x007E, 0x10C8, 0x138A, 0x6F5E, 0x9514,
0xF16F, 0xEFA6, 0x0051, 0xFD72, 0x0047, 0xFFD6, 0xFFFE, 0x0003,
0x0030, 0xFFC9, 0x02CA, 0x007E, 0x10C8, 0x138A, 0x6F5E, 0x9514,
0xF16F, 0xEFA6, 0x0051, 0xFD72, 0x0047, 0xFFD6, 0xFFFE, 0x0003,
0x0033, 0xFFD2, 0x02E5, 0x00EE, 0x10EA, 0x1624, 0x716C, 0x9775,
0xF3CC, 0xEFF0, 0x00B0, 0xFD90, 0x004D, 0xFFD8, 0xFFFE, 0x0003,
0x0033, 0xFFD2, 0x02E5, 0x00EE, 0x10EA, 0x1624, 0x716C, 0x9775,
0xF3CC, 0xEFF0, 0x00B0, 0xFD90, 0x004D, 0xFFD8, 0xFFFE, 0x0003,
0x0037, 0xFFDC, 0x0300, 0x0163, 0x10FD, 0x18D1, 0x735C, 0x99EE,
0xF613, 0xF046, 0x0108, 0xFDB0, 0x0053, 0xFFDB, 0xFFFE, 0x0003,
0x0037, 0xFFDC, 0x0300, 0x0163, 0x10FD, 0x18D1, 0x735C, 0x99EE,
0xF613, 0xF046, 0x0108, 0xFDB0, 0x0053, 0xFFDB, 0xFFFE, 0x0003,
0x003A, 0xFFE7, 0x0319, 0x01DE, 0x1100, 0x1B8E, 0x752C, 0x9C80,
0xF845, 0xF0A7, 0x015B, 0xFDD0, 0x0057, 0xFFDE, 0xFFFF, 0x0003,
0x003A, 0xFFE7, 0x0319, 0x01DE, 0x1100, 0x1B8E, 0x752C, 0x9C80,
0xF845, 0xF0A7, 0x015B, 0xFDD0, 0x0057, 0xFFDE, 0xFFFF, 0x0004,
0x003D, 0xFFF3, 0x0331, 0x025E, 0x10F2, 0x1E5C, 0x76DB, 0x9F27,
0xFA5F, 0xF111, 0x01A8, 0xFDF0, 0x005B, 0xFFE0, 0xFFFF, 0x0004,
0x003D, 0xFFF3, 0x0331, 0x025E, 0x10F2, 0x1E5C, 0x76DB, 0x9F27,
0xFA5F, 0xF111, 0x01A8, 0xFDF0, 0x005B, 0xFFE0, 0xFFFF, 0x0004,
0x0040, 0x0001, 0x0346, 0x02E3, 0x10D3, 0x2139, 0x7869, 0xA1E1,
0xFC61, 0xF184, 0x01EE, 0xFE10, 0x005E, 0xFFE2, 0xFFFF, 0x0004,
0x0040, 0x0001, 0x0346, 0x02E3, 0x10D3, 0x2139, 0x7869, 0xA1E1,
0xFC61, 0xF184, 0x01EE, 0xFE10, 0x005E, 0xFFE2, 0xFFFF, 0x0005,
0x0043, 0x0010, 0x0359, 0x036C, 0x10A2, 0x2425, 0x79D3, 0xA4AF,
0xFE4C, 0xF1FF, 0x022F, 0xFE2F, 0x0061, 0xFFE4, 0xFFFF, 0x0005,
0x0043, 0x0010, 0x0359, 0x036C, 0x10A2, 0x2425, 0x79D3, 0xA4AF,
0xFE4C, 0xF1FF, 0x022F, 0xFE2F, 0x0061, 0xFFE4, 0xFFFF, 0x0006,
0x0046, 0x001F, 0x036A, 0x03F9, 0x105D, 0x271C, 0x7B1A, 0xA78D,
0x001F, 0xF282, 0x0269, 0xFE4F, 0x0062, 0xFFE7, 0xFFFF, 0x0006,
0x0046, 0x001F, 0x036A, 0x03F9, 0x105D, 0x271C, 0x7B1A, 0xA78D,
0x001F, 0xF282, 0x0269, 0xFE4F, 0x0062, 0xFFE7, 0xFFFF, 0x0006,
0x004A, 0x0030, 0x0377, 0x048B, 0x1004, 0x2A1F, 0x7C3D, 0xAA7B,
0x01D8, 0xF30B, 0x029E, 0xFE6F, 0x0063, 0xFFE9, 0xFFFF, 0x0006,
0x004A, 0x0030, 0x0377, 0x048B, 0x1004, 0x2A1F, 0x7C3D, 0xAA7B,
0x01D8, 0xF30B, 0x029E, 0xFE6F, 0x0063, 0xFFE9, 0xFFFF, 0x0007,
0x004D, 0x0043, 0x0382, 0x0520, 0x0F97, 0x2D2C, 0x7D3A, 0xAD75,
0x037A, 0xF399, 0x02CE, 0xFE8E, 0x0064, 0xFFEB, 0x0000, 0x0007,
0x004D, 0x0043, 0x0382, 0x0520, 0x0F97, 0x2D2C, 0x7D3A, 0xAD75,
0x037A, 0xF399, 0x02CE, 0xFE8E, 0x0064, 0xFFEB, 0x0000, 0x0007,
0x0050, 0x0056, 0x038A, 0x05B7, 0x0F14, 0x3041, 0x7E12, 0xB07C,
0x0502, 0xF42C, 0x02F7, 0xFEAC, 0x0064, 0xFFEC, 0x0000, 0x0007,
0x0050, 0x0056, 0x038A, 0x05B7, 0x0F14, 0x3041, 0x7E12, 0xB07C,
0x0502, 0xF42C, 0x02F7, 0xFEAC, 0x0064, 0xFFEC, 0x0000, 0x0008,
0x0053, 0x006B, 0x038E, 0x0652, 0x0E7C, 0x335D, 0x7EC2, 0xB38C,
0x0671, 0xF4C3, 0x031C, 0xFECA, 0x0063, 0xFFEE, 0x0000, 0x0008,
0x0053, 0x006B, 0x038E, 0x0652, 0x0E7C, 0x335D, 0x7EC2, 0xB38C,
0x0671, 0xF4C3, 0x031C, 0xFECA, 0x0063, 0xFFEE, 0x0000, 0x0009,
0x0056, 0x0080, 0x038F, 0x06EE, 0x0DCE, 0x367E, 0x7F4D, 0xB6A4,
0x07C8, 0xF55C, 0x033B, 0xFEE6, 0x0062, 0xFFEF, 0x0000, 0x0009,
0x0056, 0x0080, 0x038F, 0x06EE, 0x0DCE, 0x367E, 0x7F4D, 0xB6A4,
0x07C8, 0xF55C, 0x033B, 0xFEE6, 0x0062, 0xFFEF, 0x0000, 0x000A,
0x0058, 0x0098, 0x038C, 0x078C, 0x0D08, 0x39A4, 0x7FB0, 0xB9C4,
0x0905, 0xF5F9, 0x0354, 0xFF02, 0x0061, 0xFFF1, 0x0000, 0x000A,
0x0058, 0x0098, 0x038C, 0x078C, 0x0D08, 0x39A4, 0x7FB0, 0xB9C4,
0x0905, 0xF5F9, 0x0354, 0xFF02, 0x0061, 0xFFF1, 0x0000, 0x000B,
0x005B, 0x00AF, 0x0385, 0x082B, 0x0C2B, 0x3CCB, 0x7FEB, 0xBCE7,
0x0A2A, 0xF697, 0x0369, 0xFF1D, 0x005F, 0xFFF2, 0x0000, 0x000B,
0x005B, 0x00AF, 0x0385, 0x082B, 0x0C2B, 0x3CCB, 0x7FEB, 0xBCE7,
0x0A2A, 0xF697, 0x0369, 0xFF1D, 0x005F, 0xFFF2, 0x0000, 0x000D,
0x005D, 0x00C8, 0x037A, 0x08CA, 0x0B37, 0x3FF2, 0x7FFF, 0xC00E,
0x0B37, 0xF736, 0x037A, 0xFF38, 0x005D, 0xFFF3, 0x0000, 0x000D,
0x005D, 0x00C8, 0x037A, 0x08CA, 0x0B37, 0x3FF2, 0x7FFF, 0xC00E,
0x0B37, 0xF736, 0x037A, 0xFF38, 0x005D, 0xFFF3, 0x0000, 0x0000
};
static void MP3AB0(int32_t* v)
{
/* Part 2 - 100% Accurate */
static const uint16_t LUT2[8] = {
0xFEC4, 0xF4FA, 0xC5E4, 0xE1C4,
0x1916, 0x4A50, 0xA268, 0x78AE
};
static const uint16_t LUT3[4] = { 0xFB14, 0xD4DC, 0x31F2, 0x8E3A };
int i;
for (i = 0; i < 8; i++) {
v[16 + i] = v[0 + i] + v[8 + i];
v[24 + i] = ((v[0 + i] - v[8 + i]) * LUT2[i]) >> 0x10;
}
/* Part 3: 4-wide butterflies */
for (i = 0; i < 4; i++) {
v[0 + i] = v[16 + i] + v[20 + i];
v[4 + i] = ((v[16 + i] - v[20 + i]) * LUT3[i]) >> 0x10;
v[8 + i] = v[24 + i] + v[28 + i];
v[12 + i] = ((v[24 + i] - v[28 + i]) * LUT3[i]) >> 0x10;
}
/* Part 4: 2-wide butterflies - 100% Accurate */
for (i = 0; i < 16; i += 4) {
v[16 + i] = v[0 + i] + v[2 + i];
v[18 + i] = ((v[0 + i] - v[2 + i]) * 0xEC84) >> 0x10;
v[17 + i] = v[1 + i] + v[3 + i];
v[19 + i] = ((v[1 + i] - v[3 + i]) * 0x61F8) >> 0x10;
}
}
void mp3_task(struct hle_t* hle, unsigned int index, uint32_t address)
{
uint32_t inPtr, outPtr;
uint32_t t6;/* = 0x08A0; - I think these are temporary storage buffers */
uint32_t t5;/* = 0x0AC0; */
uint32_t t4;/* = (w1 & 0x1E); */
/* Initialization Code */
uint32_t readPtr; /* s5 */
uint32_t writePtr; /* s6 */
uint32_t tmp;
int cnt, cnt2;
/* I think these are temporary storage buffers */
t6 = 0x08A0;
t5 = 0x0AC0;
t4 = index;
writePtr = readPtr = address;
/* Just do that for efficiency... may remove and use directly later anyway */
memcpy(hle->mp3_buffer + 0xCE8, hle->dram + readPtr, 8);
/* This must be a header byte or whatnot */
readPtr += 8;
for (cnt = 0; cnt < 0x480; cnt += 0x180) {
/* DMA: 0xCF0 <- RDRAM[s5] : 0x180 */
memcpy(hle->mp3_buffer + 0xCF0, hle->dram + readPtr, 0x180);
inPtr = 0xCF0; /* s7 */
outPtr = 0xE70; /* s3 */
/* --------------- Inner Loop Start -------------------- */
for (cnt2 = 0; cnt2 < 0x180; cnt2 += 0x40) {
t6 &= 0xFFE0;
t5 &= 0xFFE0;
t6 |= t4;
t5 |= t4;
InnerLoop(hle, outPtr, inPtr, t6, t5, t4);
t4 = (t4 - 2) & 0x1E;
tmp = t6;
t6 = t5;
t5 = tmp;
inPtr += 0x40;
outPtr += 0x40;
}
/* --------------- Inner Loop End -------------------- */
memcpy(hle->dram + writePtr, hle->mp3_buffer + 0xe70, 0x180);
writePtr += 0x180;
readPtr += 0x180;
}
}
static void InnerLoop(struct hle_t* hle,
uint32_t outPtr, uint32_t inPtr,
uint32_t t6, uint32_t t5, uint32_t t4)
{
/* Part 1: 100% Accurate */
/* 0, 1, 3, 2, 7, 6, 4, 5, 7, 6, 4, 5, 0, 1, 3, 2 */
static const uint16_t LUT6[16] = {
0xFFB2, 0xFD3A, 0xF10A, 0xF854,
0xBDAE, 0xCDA0, 0xE76C, 0xDB94,
0x1920, 0x4B20, 0xAC7C, 0x7C68,
0xABEC, 0x9880, 0xDAE8, 0x839C
};
int i;
uint32_t t0;
uint32_t t1;
uint32_t t2;
uint32_t t3;
int32_t v2 = 0, v4 = 0, v6 = 0, v8 = 0;
uint32_t offset;
uint32_t addptr;
int x;
int32_t mult6;
int32_t mult4;
int tmp;
int32_t hi0;
int32_t hi1;
int32_t vt;
int32_t v[32];
v[0] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x00 ^ S16));
v[31] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x3E ^ S16));
v[0] += v[31];
v[1] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x02 ^ S16));
v[30] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x3C ^ S16));
v[1] += v[30];
v[2] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x06 ^ S16));
v[28] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x38 ^ S16));
v[2] += v[28];
v[3] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x04 ^ S16));
v[29] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x3A ^ S16));
v[3] += v[29];
v[4] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x0E ^ S16));
v[24] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x30 ^ S16));
v[4] += v[24];
v[5] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x0C ^ S16));
v[25] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x32 ^ S16));
v[5] += v[25];
v[6] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x08 ^ S16));
v[27] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x36 ^ S16));
v[6] += v[27];
v[7] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x0A ^ S16));
v[26] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x34 ^ S16));
v[7] += v[26];
v[8] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x1E ^ S16));
v[16] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x20 ^ S16));
v[8] += v[16];
v[9] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x1C ^ S16));
v[17] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x22 ^ S16));
v[9] += v[17];
v[10] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x18 ^ S16));
v[19] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x26 ^ S16));
v[10] += v[19];
v[11] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x1A ^ S16));
v[18] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x24 ^ S16));
v[11] += v[18];
v[12] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x10 ^ S16));
v[23] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x2E ^ S16));
v[12] += v[23];
v[13] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x12 ^ S16));
v[22] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x2C ^ S16));
v[13] += v[22];
v[14] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x16 ^ S16));
v[20] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x28 ^ S16));
v[14] += v[20];
v[15] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x14 ^ S16));
v[21] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x2A ^ S16));
v[15] += v[21];
/* Part 2-4 */
MP3AB0(v);
/* Part 5 - 1-Wide Butterflies - 100% Accurate but need SSVs!!! */
t0 = t6 + 0x100;
t1 = t6 + 0x200;
t2 = t5 + 0x100;
t3 = t5 + 0x200;
/* 0x13A8 */
v[1] = 0;
v[11] = ((v[16] - v[17]) * 0xB504) >> 0x10;
v[16] = -v[16] - v[17];
v[2] = v[18] + v[19];
/* ** Store v[11] -> (T6 + 0)** */
*(int16_t *)(hle->mp3_buffer + ((t6 + (short)0x0))) = (short)v[11];
v[11] = -v[11];
/* ** Store v[16] -> (T3 + 0)** */
*(int16_t *)(hle->mp3_buffer + ((t3 + (short)0x0))) = (short)v[16];
/* ** Store v[11] -> (T5 + 0)** */
*(int16_t *)(hle->mp3_buffer + ((t5 + (short)0x0))) = (short)v[11];
/* 0x13E8 - Verified.... */
v[2] = -v[2];
/* ** Store v[2] -> (T2 + 0)** */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0x0))) = (short)v[2];
v[3] = (((v[18] - v[19]) * 0x16A09) >> 0x10) + v[2];
/* ** Store v[3] -> (T0 + 0)** */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0x0))) = (short)v[3];
/* 0x1400 - Verified */
v[4] = -v[20] - v[21];
v[6] = v[22] + v[23];
v[5] = ((v[20] - v[21]) * 0x16A09) >> 0x10;
/* ** Store v[4] -> (T3 + 0xFF80) */
*(int16_t *)(hle->mp3_buffer + ((t3 + (short)0xFF80))) = (short)v[4];
v[7] = ((v[22] - v[23]) * 0x2D413) >> 0x10;
v[5] = v[5] - v[4];
v[7] = v[7] - v[5];
v[6] = v[6] + v[6];
v[5] = v[5] - v[6];
v[4] = -v[4] - v[6];
/* *** Store v[7] -> (T1 + 0xFF80) */
*(int16_t *)(hle->mp3_buffer + ((t1 + (short)0xFF80))) = (short)v[7];
/* *** Store v[4] -> (T2 + 0xFF80) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0xFF80))) = (short)v[4];
/* *** Store v[5] -> (T0 + 0xFF80) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0xFF80))) = (short)v[5];
v[8] = v[24] + v[25];
v[9] = ((v[24] - v[25]) * 0x16A09) >> 0x10;
v[2] = v[8] + v[9];
v[11] = ((v[26] - v[27]) * 0x2D413) >> 0x10;
v[13] = ((v[28] - v[29]) * 0x2D413) >> 0x10;
v[10] = v[26] + v[27];
v[10] = v[10] + v[10];
v[12] = v[28] + v[29];
v[12] = v[12] + v[12];
v[14] = v[30] + v[31];
v[3] = v[8] + v[10];
v[14] = v[14] + v[14];
v[13] = (v[13] - v[2]) + v[12];
v[15] = (((v[30] - v[31]) * 0x5A827) >> 0x10) - (v[11] + v[2]);
v[14] = -(v[14] + v[14]) + v[3];
v[17] = v[13] - v[10];
v[9] = v[9] + v[14];
/* ** Store v[9] -> (T6 + 0x40) */
*(int16_t *)(hle->mp3_buffer + ((t6 + (short)0x40))) = (short)v[9];
v[11] = v[11] - v[13];
/* ** Store v[17] -> (T0 + 0xFFC0) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0xFFC0))) = (short)v[17];
v[12] = v[8] - v[12];
/* ** Store v[11] -> (T0 + 0x40) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0x40))) = (short)v[11];
v[8] = -v[8];
/* ** Store v[15] -> (T1 + 0xFFC0) */
*(int16_t *)(hle->mp3_buffer + ((t1 + (short)0xFFC0))) = (short)v[15];
v[10] = -v[10] - v[12];
/* ** Store v[12] -> (T2 + 0x40) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0x40))) = (short)v[12];
/* ** Store v[8] -> (T3 + 0xFFC0) */
*(int16_t *)(hle->mp3_buffer + ((t3 + (short)0xFFC0))) = (short)v[8];
/* ** Store v[14] -> (T5 + 0x40) */
*(int16_t *)(hle->mp3_buffer + ((t5 + (short)0x40))) = (short)v[14];
/* ** Store v[10] -> (T2 + 0xFFC0) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0xFFC0))) = (short)v[10];
/* 0x14FC - Verified... */
/* Part 6 - 100% Accurate */
v[0] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x00 ^ S16));
v[31] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x3E ^ S16));
v[0] -= v[31];
v[1] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x02 ^ S16));
v[30] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x3C ^ S16));
v[1] -= v[30];
v[2] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x06 ^ S16));
v[28] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x38 ^ S16));
v[2] -= v[28];
v[3] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x04 ^ S16));
v[29] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x3A ^ S16));
v[3] -= v[29];
v[4] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x0E ^ S16));
v[24] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x30 ^ S16));
v[4] -= v[24];
v[5] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x0C ^ S16));
v[25] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x32 ^ S16));
v[5] -= v[25];
v[6] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x08 ^ S16));
v[27] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x36 ^ S16));
v[6] -= v[27];
v[7] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x0A ^ S16));
v[26] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x34 ^ S16));
v[7] -= v[26];
v[8] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x1E ^ S16));
v[16] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x20 ^ S16));
v[8] -= v[16];
v[9] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x1C ^ S16));
v[17] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x22 ^ S16));
v[9] -= v[17];
v[10] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x18 ^ S16));
v[19] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x26 ^ S16));
v[10] -= v[19];
v[11] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x1A ^ S16));
v[18] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x24 ^ S16));
v[11] -= v[18];
v[12] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x10 ^ S16));
v[23] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x2E ^ S16));
v[12] -= v[23];
v[13] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x12 ^ S16));
v[22] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x2C ^ S16));
v[13] -= v[22];
v[14] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x16 ^ S16));
v[20] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x28 ^ S16));
v[14] -= v[20];
v[15] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x14 ^ S16));
v[21] = *(int16_t *)(hle->mp3_buffer + inPtr + (0x2A ^ S16));
v[15] -= v[21];
for (i = 0; i < 16; i++)
v[0 + i] = (v[0 + i] * LUT6[i]) >> 0x10;
v[0] = v[0] + v[0];
v[1] = v[1] + v[1];
v[2] = v[2] + v[2];
v[3] = v[3] + v[3];
v[4] = v[4] + v[4];
v[5] = v[5] + v[5];
v[6] = v[6] + v[6];
v[7] = v[7] + v[7];
v[12] = v[12] + v[12];
v[13] = v[13] + v[13];
v[15] = v[15] + v[15];
MP3AB0(v);
/* Part 7: - 100% Accurate + SSV - Unoptimized */
v[0] = (v[17] + v[16]) >> 1;
v[1] = ((v[17] * (int)((short)0xA57E * 2)) + (v[16] * 0xB504)) >> 0x10;
v[2] = -v[18] - v[19];
v[3] = ((v[18] - v[19]) * 0x16A09) >> 0x10;
v[4] = v[20] + v[21] + v[0];
v[5] = (((v[20] - v[21]) * 0x16A09) >> 0x10) + v[1];
v[6] = (((v[22] + v[23]) << 1) + v[0]) - v[2];
v[7] = (((v[22] - v[23]) * 0x2D413) >> 0x10) + v[0] + v[1] + v[3];
/* 0x16A8 */
/* Save v[0] -> (T3 + 0xFFE0) */
*(int16_t *)(hle->mp3_buffer + ((t3 + (short)0xFFE0))) = (short) - v[0];
v[8] = v[24] + v[25];
v[9] = ((v[24] - v[25]) * 0x16A09) >> 0x10;
v[10] = ((v[26] + v[27]) << 1) + v[8];
v[11] = (((v[26] - v[27]) * 0x2D413) >> 0x10) + v[8] + v[9];
v[12] = v[4] - ((v[28] + v[29]) << 1);
/* ** Store v12 -> (T2 + 0x20) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0x20))) = (short)v[12];
v[13] = (((v[28] - v[29]) * 0x2D413) >> 0x10) - v[12] - v[5];
v[14] = v[30] + v[31];
v[14] = v[14] + v[14];
v[14] = v[14] + v[14];
v[14] = v[6] - v[14];
v[15] = (((v[30] - v[31]) * 0x5A827) >> 0x10) - v[7];
/* Store v14 -> (T5 + 0x20) */
*(int16_t *)(hle->mp3_buffer + ((t5 + (short)0x20))) = (short)v[14];
v[14] = v[14] + v[1];
/* Store v[14] -> (T6 + 0x20) */
*(int16_t *)(hle->mp3_buffer + ((t6 + (short)0x20))) = (short)v[14];
/* Store v[15] -> (T1 + 0xFFE0) */
*(int16_t *)(hle->mp3_buffer + ((t1 + (short)0xFFE0))) = (short)v[15];
v[9] = v[9] + v[10];
v[1] = v[1] + v[6];
v[6] = v[10] - v[6];
v[1] = v[9] - v[1];
/* Store v[6] -> (T5 + 0x60) */
*(int16_t *)(hle->mp3_buffer + ((t5 + (short)0x60))) = (short)v[6];
v[10] = v[10] + v[2];
v[10] = v[4] - v[10];
/* Store v[10] -> (T2 + 0xFFA0) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0xFFA0))) = (short)v[10];
v[12] = v[2] - v[12];
/* Store v[12] -> (T2 + 0xFFE0) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0xFFE0))) = (short)v[12];
v[5] = v[4] + v[5];
v[4] = v[8] - v[4];
/* Store v[4] -> (T2 + 0x60) */
*(int16_t *)(hle->mp3_buffer + ((t2 + (short)0x60))) = (short)v[4];
v[0] = v[0] - v[8];
/* Store v[0] -> (T3 + 0xFFA0) */
*(int16_t *)(hle->mp3_buffer + ((t3 + (short)0xFFA0))) = (short)v[0];
v[7] = v[7] - v[11];
/* Store v[7] -> (T1 + 0xFFA0) */
*(int16_t *)(hle->mp3_buffer + ((t1 + (short)0xFFA0))) = (short)v[7];
v[11] = v[11] - v[3];
/* Store v[1] -> (T6 + 0x60) */
*(int16_t *)(hle->mp3_buffer + ((t6 + (short)0x60))) = (short)v[1];
v[11] = v[11] - v[5];
/* Store v[11] -> (T0 + 0x60) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0x60))) = (short)v[11];
v[3] = v[3] - v[13];
/* Store v[3] -> (T0 + 0x20) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0x20))) = (short)v[3];
v[13] = v[13] + v[2];
/* Store v[13] -> (T0 + 0xFFE0) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0xFFE0))) = (short)v[13];
v[2] = (v[5] - v[2]) - v[9];
/* Store v[2] -> (T0 + 0xFFA0) */
*(int16_t *)(hle->mp3_buffer + ((t0 + (short)0xFFA0))) = (short)v[2];
/* 0x7A8 - Verified... */
/* Step 8 - Dewindowing */
addptr = t6 & 0xFFE0;
offset = 0x10 - (t4 >> 1);
for (x = 0; x < 8; x++) {
int32_t v0;
int32_t v18;
v2 = v4 = v6 = v8 = 0;
for (i = 7; i >= 0; i--) {
v2 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x00) * (short)DeWindowLUT[offset + 0x00] + 0x4000) >> 0xF;
v4 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x10) * (short)DeWindowLUT[offset + 0x08] + 0x4000) >> 0xF;
v6 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x20) * (short)DeWindowLUT[offset + 0x20] + 0x4000) >> 0xF;
v8 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x30) * (short)DeWindowLUT[offset + 0x28] + 0x4000) >> 0xF;
addptr += 2;
offset++;
}
v0 = v2 + v4;
v18 = v6 + v8;
/* Clamp(v0); */
/* Clamp(v18); */
/* clamp??? */
*(int16_t *)(hle->mp3_buffer + (outPtr ^ S16)) = v0;
*(int16_t *)(hle->mp3_buffer + ((outPtr + 2)^S16)) = v18;
outPtr += 4;
addptr += 0x30;
offset += 0x38;
}
offset = 0x10 - (t4 >> 1) + 8 * 0x40;
v2 = v4 = 0;
for (i = 0; i < 4; i++) {
v2 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x00) * (short)DeWindowLUT[offset + 0x00] + 0x4000) >> 0xF;
v2 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x10) * (short)DeWindowLUT[offset + 0x08] + 0x4000) >> 0xF;
addptr += 2;
offset++;
v4 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x00) * (short)DeWindowLUT[offset + 0x00] + 0x4000) >> 0xF;
v4 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x10) * (short)DeWindowLUT[offset + 0x08] + 0x4000) >> 0xF;
addptr += 2;
offset++;
}
mult6 = *(int32_t *)(hle->mp3_buffer + 0xCE8);
mult4 = *(int32_t *)(hle->mp3_buffer + 0xCEC);
if (t4 & 0x2) {
v2 = (v2 **(uint32_t *)(hle->mp3_buffer + 0xCE8)) >> 0x10;
*(int16_t *)(hle->mp3_buffer + (outPtr ^ S16)) = v2;
} else {
v4 = (v4 **(uint32_t *)(hle->mp3_buffer + 0xCE8)) >> 0x10;
*(int16_t *)(hle->mp3_buffer + (outPtr ^ S16)) = v4;
mult4 = *(uint32_t *)(hle->mp3_buffer + 0xCE8);
}
addptr -= 0x50;
for (x = 0; x < 8; x++) {
int32_t v0;
int32_t v18;
v2 = v4 = v6 = v8 = 0;
offset = (0x22F - (t4 >> 1) + x * 0x40);
for (i = 0; i < 4; i++) {
v2 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x20) * (short)DeWindowLUT[offset + 0x00] + 0x4000) >> 0xF;
v2 -= ((int) * (int16_t *)(hle->mp3_buffer + ((addptr + 2)) + 0x20) * (short)DeWindowLUT[offset + 0x01] + 0x4000) >> 0xF;
v4 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x30) * (short)DeWindowLUT[offset + 0x08] + 0x4000) >> 0xF;
v4 -= ((int) * (int16_t *)(hle->mp3_buffer + ((addptr + 2)) + 0x30) * (short)DeWindowLUT[offset + 0x09] + 0x4000) >> 0xF;
v6 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x00) * (short)DeWindowLUT[offset + 0x20] + 0x4000) >> 0xF;
v6 -= ((int) * (int16_t *)(hle->mp3_buffer + ((addptr + 2)) + 0x00) * (short)DeWindowLUT[offset + 0x21] + 0x4000) >> 0xF;
v8 += ((int) * (int16_t *)(hle->mp3_buffer + (addptr) + 0x10) * (short)DeWindowLUT[offset + 0x28] + 0x4000) >> 0xF;
v8 -= ((int) * (int16_t *)(hle->mp3_buffer + ((addptr + 2)) + 0x10) * (short)DeWindowLUT[offset + 0x29] + 0x4000) >> 0xF;
addptr += 4;
offset += 2;
}
v0 = v2 + v4;
v18 = v6 + v8;
/* Clamp(v0); */
/* Clamp(v18); */
/* clamp??? */
*(int16_t *)(hle->mp3_buffer + ((outPtr + 2)^S16)) = v0;
*(int16_t *)(hle->mp3_buffer + ((outPtr + 4)^S16)) = v18;
outPtr += 4;
addptr -= 0x50;
}
tmp = outPtr;
hi0 = mult6;
hi1 = mult4;
hi0 = (int)hi0 >> 0x10;
hi1 = (int)hi1 >> 0x10;
for (i = 0; i < 8; i++) {
/* v0 */
vt = (*(int16_t *)(hle->mp3_buffer + ((tmp - 0x40)^S16)) * hi0);
*(int16_t *)((uint8_t *)hle->mp3_buffer + ((tmp - 0x40)^S16)) = clamp_s16(vt);
/* v17 */
vt = (*(int16_t *)(hle->mp3_buffer + ((tmp - 0x30)^S16)) * hi0);
*(int16_t *)((uint8_t *)hle->mp3_buffer + ((tmp - 0x30)^S16)) = clamp_s16(vt);
/* v2 */
vt = (*(int16_t *)(hle->mp3_buffer + ((tmp - 0x1E)^S16)) * hi1);
*(int16_t *)((uint8_t *)hle->mp3_buffer + ((tmp - 0x1E)^S16)) = clamp_s16(vt);
/* v4 */
vt = (*(int16_t *)(hle->mp3_buffer + ((tmp - 0xE)^S16)) * hi1);
*(int16_t *)((uint8_t *)hle->mp3_buffer + ((tmp - 0xE)^S16)) = clamp_s16(vt);
tmp += 2;
}
}

988
src/musyx.c Normal file
View file

@ -0,0 +1,988 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - musyx.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2013 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "arithmetics.h"
#include "audio.h"
#include "common.h"
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
/* various constants */
enum { SUBFRAME_SIZE = 192 };
enum { MAX_VOICES = 32 };
enum { SAMPLE_BUFFER_SIZE = 0x200 };
enum {
SFD_VOICE_COUNT = 0x0,
SFD_SFX_INDEX = 0x2,
SFD_VOICE_BITMASK = 0x4,
SFD_STATE_PTR = 0x8,
SFD_SFX_PTR = 0xc,
SFD_VOICES = 0x10,
/* v2 only */
SFD2_10_PTR = 0x10,
SFD2_14_BITMASK = 0x14,
SFD2_15_BITMASK = 0x15,
SFD2_16_BITMASK = 0x16,
SFD2_18_PTR = 0x18,
SFD2_1C_PTR = 0x1c,
SFD2_20_PTR = 0x20,
SFD2_24_PTR = 0x24,
SFD2_VOICES = 0x28
};
enum {
VOICE_ENV_BEGIN = 0x00,
VOICE_ENV_STEP = 0x10,
VOICE_PITCH_Q16 = 0x20,
VOICE_PITCH_SHIFT = 0x22,
VOICE_CATSRC_0 = 0x24,
VOICE_CATSRC_1 = 0x30,
VOICE_ADPCM_FRAMES = 0x3c,
VOICE_SKIP_SAMPLES = 0x3e,
/* for PCM16 */
VOICE_U16_40 = 0x40,
VOICE_U16_42 = 0x42,
/* for ADPCM */
VOICE_ADPCM_TABLE_PTR = 0x40,
VOICE_INTERLEAVED_PTR = 0x44,
VOICE_END_POINT = 0x48,
VOICE_RESTART_POINT = 0x4a,
VOICE_U16_4C = 0x4c,
VOICE_U16_4E = 0x4e,
VOICE_SIZE = 0x50
};
enum {
CATSRC_PTR1 = 0x00,
CATSRC_PTR2 = 0x04,
CATSRC_SIZE1 = 0x08,
CATSRC_SIZE2 = 0x0a
};
enum {
STATE_LAST_SAMPLE = 0x0,
STATE_BASE_VOL = 0x100,
STATE_CC0 = 0x110,
STATE_740_LAST4_V1 = 0x290,
STATE_740_LAST4_V2 = 0x110
};
enum {
SFX_CBUFFER_PTR = 0x00,
SFX_CBUFFER_LENGTH = 0x04,
SFX_TAP_COUNT = 0x08,
SFX_FIR4_HGAIN = 0x0a,
SFX_TAP_DELAYS = 0x0c,
SFX_TAP_GAINS = 0x2c,
SFX_U16_3C = 0x3c,
SFX_U16_3E = 0x3e,
SFX_FIR4_HCOEFFS = 0x40
};
/* struct definition */
typedef struct {
/* internal subframes */
int16_t left[SUBFRAME_SIZE];
int16_t right[SUBFRAME_SIZE];
int16_t cc0[SUBFRAME_SIZE];
int16_t e50[SUBFRAME_SIZE];
/* internal subframes base volumes */
int32_t base_vol[4];
/* */
int16_t subframe_740_last4[4];
} musyx_t;
typedef void (*mix_sfx_with_main_subframes_t)(musyx_t *musyx, const int16_t *subframe,
const uint16_t* gains);
/* helper functions prototypes */
static void load_base_vol(struct hle_t* hle, int32_t *base_vol, uint32_t address);
static void save_base_vol(struct hle_t* hle, const int32_t *base_vol, uint32_t address);
static void update_base_vol(struct hle_t* hle, int32_t *base_vol,
uint32_t voice_mask, uint32_t last_sample_ptr,
uint8_t mask_15, uint32_t ptr_24);
static void init_subframes_v1(musyx_t *musyx);
static void init_subframes_v2(musyx_t *musyx);
static uint32_t voice_stage(struct hle_t* hle, musyx_t *musyx,
uint32_t voice_ptr, uint32_t last_sample_ptr);
static void dma_cat8(struct hle_t* hle, uint8_t *dst, uint32_t catsrc_ptr);
static void dma_cat16(struct hle_t* hle, uint16_t *dst, uint32_t catsrc_ptr);
static void load_samples_PCM16(struct hle_t* hle, uint32_t voice_ptr, int16_t *samples,
unsigned *segbase, unsigned *offset);
static void load_samples_ADPCM(struct hle_t* hle, uint32_t voice_ptr, int16_t *samples,
unsigned *segbase, unsigned *offset);
static void adpcm_decode_frames(struct hle_t* hle,
int16_t *dst, const uint8_t *src,
const int16_t *table, uint8_t count,
uint8_t skip_samples);
static void adpcm_predict_frame(int16_t *dst, const uint8_t *src,
const uint8_t *nibbles,
unsigned int rshift);
static void mix_voice_samples(struct hle_t* hle, musyx_t *musyx,
uint32_t voice_ptr, const int16_t *samples,
unsigned segbase, unsigned offset, uint32_t last_sample_ptr);
static void sfx_stage(struct hle_t* hle,
mix_sfx_with_main_subframes_t mix_sfx_with_main_subframes,
musyx_t *musyx, uint32_t sfx_ptr, uint16_t idx);
static void mix_sfx_with_main_subframes_v1(musyx_t *musyx, const int16_t *subframe,
const uint16_t* gains);
static void mix_sfx_with_main_subframes_v2(musyx_t *musyx, const int16_t *subframe,
const uint16_t* gains);
static void mix_samples(int16_t *y, int16_t x, int16_t hgain);
static void mix_subframes(int16_t *y, const int16_t *x, int16_t hgain);
static void mix_fir4(int16_t *y, const int16_t *x, int16_t hgain, const int16_t *hcoeffs);
static void interleave_stage_v1(struct hle_t* hle, musyx_t *musyx,
uint32_t output_ptr);
static void interleave_stage_v2(struct hle_t* hle, musyx_t *musyx,
uint16_t mask_16, uint32_t ptr_18,
uint32_t ptr_1c, uint32_t output_ptr);
static int32_t dot4(const int16_t *x, const int16_t *y)
{
size_t i;
int32_t accu = 0;
for (i = 0; i < 4; ++i)
accu = clamp_s16(accu + (((int32_t)x[i] * (int32_t)y[i]) >> 15));
return accu;
}
/**************************************************************************
* MusyX v1 audio ucode
**************************************************************************/
void musyx_v1_task(struct hle_t* hle)
{
uint32_t sfd_ptr = *dmem_u32(hle, TASK_DATA_PTR);
uint32_t sfd_count = *dmem_u32(hle, TASK_DATA_SIZE);
uint32_t state_ptr;
musyx_t musyx;
HleVerboseMessage(hle->user_defined,
"musyx_v1_task: *data=%x, #SF=%d",
sfd_ptr,
sfd_count);
state_ptr = *dram_u32(hle, sfd_ptr + SFD_STATE_PTR);
/* load initial state */
load_base_vol(hle, musyx.base_vol, state_ptr + STATE_BASE_VOL);
dram_load_u16(hle, (uint16_t *)musyx.cc0, state_ptr + STATE_CC0, SUBFRAME_SIZE);
dram_load_u16(hle, (uint16_t *)musyx.subframe_740_last4, state_ptr + STATE_740_LAST4_V1,
4);
for (;;) {
/* parse SFD structure */
uint16_t sfx_index = *dram_u16(hle, sfd_ptr + SFD_SFX_INDEX);
uint32_t voice_mask = *dram_u32(hle, sfd_ptr + SFD_VOICE_BITMASK);
uint32_t sfx_ptr = *dram_u32(hle, sfd_ptr + SFD_SFX_PTR);
uint32_t voice_ptr = sfd_ptr + SFD_VOICES;
uint32_t last_sample_ptr = state_ptr + STATE_LAST_SAMPLE;
uint32_t output_ptr;
/* initialize internal subframes using updated base volumes */
update_base_vol(hle, musyx.base_vol, voice_mask, last_sample_ptr, 0, 0);
init_subframes_v1(&musyx);
/* active voices get mixed into L,R,cc0,e50 subframes (optional) */
output_ptr = voice_stage(hle, &musyx, voice_ptr, last_sample_ptr);
/* apply delay-based effects (optional) */
sfx_stage(hle, mix_sfx_with_main_subframes_v1,
&musyx, sfx_ptr, sfx_index);
/* emit interleaved L,R subframes */
interleave_stage_v1(hle, &musyx, output_ptr);
--sfd_count;
if (sfd_count == 0)
break;
sfd_ptr += SFD_VOICES + MAX_VOICES * VOICE_SIZE;
state_ptr = *dram_u32(hle, sfd_ptr + SFD_STATE_PTR);
}
/* writeback updated state */
save_base_vol(hle, musyx.base_vol, state_ptr + STATE_BASE_VOL);
dram_store_u16(hle, (uint16_t *)musyx.cc0, state_ptr + STATE_CC0, SUBFRAME_SIZE);
dram_store_u16(hle, (uint16_t *)musyx.subframe_740_last4, state_ptr + STATE_740_LAST4_V1,
4);
rsp_break(hle, SP_STATUS_TASKDONE);
}
/**************************************************************************
* MusyX v2 audio ucode
**************************************************************************/
void musyx_v2_task(struct hle_t* hle)
{
uint32_t sfd_ptr = *dmem_u32(hle, TASK_DATA_PTR);
uint32_t sfd_count = *dmem_u32(hle, TASK_DATA_SIZE);
musyx_t musyx;
HleVerboseMessage(hle->user_defined,
"musyx_v2_task: *data=%x, #SF=%d",
sfd_ptr,
sfd_count);
for (;;) {
/* parse SFD structure */
uint16_t sfx_index = *dram_u16(hle, sfd_ptr + SFD_SFX_INDEX);
uint32_t voice_mask = *dram_u32(hle, sfd_ptr + SFD_VOICE_BITMASK);
uint32_t state_ptr = *dram_u32(hle, sfd_ptr + SFD_STATE_PTR);
uint32_t sfx_ptr = *dram_u32(hle, sfd_ptr + SFD_SFX_PTR);
uint32_t voice_ptr = sfd_ptr + SFD2_VOICES;
uint32_t ptr_10 = *dram_u32(hle, sfd_ptr + SFD2_10_PTR);
uint8_t mask_14 = *dram_u8 (hle, sfd_ptr + SFD2_14_BITMASK);
uint8_t mask_15 = *dram_u8 (hle, sfd_ptr + SFD2_15_BITMASK);
uint16_t mask_16 = *dram_u16(hle, sfd_ptr + SFD2_16_BITMASK);
uint32_t ptr_18 = *dram_u32(hle, sfd_ptr + SFD2_18_PTR);
uint32_t ptr_1c = *dram_u32(hle, sfd_ptr + SFD2_1C_PTR);
uint32_t ptr_20 = *dram_u32(hle, sfd_ptr + SFD2_20_PTR);
uint32_t ptr_24 = *dram_u32(hle, sfd_ptr + SFD2_24_PTR);
uint32_t last_sample_ptr = state_ptr + STATE_LAST_SAMPLE;
uint32_t output_ptr;
/* load state */
load_base_vol(hle, musyx.base_vol, state_ptr + STATE_BASE_VOL);
dram_load_u16(hle, (uint16_t *)musyx.subframe_740_last4,
state_ptr + STATE_740_LAST4_V2, 4);
/* initialize internal subframes using updated base volumes */
update_base_vol(hle, musyx.base_vol, voice_mask, last_sample_ptr, mask_15, ptr_24);
init_subframes_v2(&musyx);
if (ptr_10) {
/* TODO */
HleWarnMessage(hle->user_defined,
"ptr_10=%08x mask_14=%02x ptr_24=%08x",
ptr_10, mask_14, ptr_24);
}
/* active voices get mixed into L,R,cc0,e50 subframes (optional) */
output_ptr = voice_stage(hle, &musyx, voice_ptr, last_sample_ptr);
/* apply delay-based effects (optional) */
sfx_stage(hle, mix_sfx_with_main_subframes_v2,
&musyx, sfx_ptr, sfx_index);
dram_store_u16(hle, (uint16_t*)musyx.left, output_ptr , SUBFRAME_SIZE);
dram_store_u16(hle, (uint16_t*)musyx.right, output_ptr + 2*SUBFRAME_SIZE, SUBFRAME_SIZE);
dram_store_u16(hle, (uint16_t*)musyx.cc0, output_ptr + 4*SUBFRAME_SIZE, SUBFRAME_SIZE);
/* store state */
save_base_vol(hle, musyx.base_vol, state_ptr + STATE_BASE_VOL);
dram_store_u16(hle, (uint16_t*)musyx.subframe_740_last4,
state_ptr + STATE_740_LAST4_V2, 4);
if (mask_16)
interleave_stage_v2(hle, &musyx, mask_16, ptr_18, ptr_1c, ptr_20);
--sfd_count;
if (sfd_count == 0)
break;
sfd_ptr += SFD2_VOICES + MAX_VOICES * VOICE_SIZE;
}
rsp_break(hle, SP_STATUS_TASKDONE);
}
static void load_base_vol(struct hle_t* hle, int32_t *base_vol, uint32_t address)
{
base_vol[0] = ((uint32_t)(*dram_u16(hle, address)) << 16) | (*dram_u16(hle, address + 8));
base_vol[1] = ((uint32_t)(*dram_u16(hle, address + 2)) << 16) | (*dram_u16(hle, address + 10));
base_vol[2] = ((uint32_t)(*dram_u16(hle, address + 4)) << 16) | (*dram_u16(hle, address + 12));
base_vol[3] = ((uint32_t)(*dram_u16(hle, address + 6)) << 16) | (*dram_u16(hle, address + 14));
}
static void save_base_vol(struct hle_t* hle, const int32_t *base_vol, uint32_t address)
{
unsigned k;
for (k = 0; k < 4; ++k) {
*dram_u16(hle, address) = (uint16_t)(base_vol[k] >> 16);
address += 2;
}
for (k = 0; k < 4; ++k) {
*dram_u16(hle, address) = (uint16_t)(base_vol[k]);
address += 2;
}
}
static void update_base_vol(struct hle_t* hle, int32_t *base_vol,
uint32_t voice_mask, uint32_t last_sample_ptr,
uint8_t mask_15, uint32_t ptr_24)
{
unsigned i, k;
uint32_t mask;
HleVerboseMessage(hle->user_defined, "base_vol voice_mask = %08x", voice_mask);
HleVerboseMessage(hle->user_defined,
"BEFORE: base_vol = %08x %08x %08x %08x",
base_vol[0], base_vol[1], base_vol[2], base_vol[3]);
/* optim: skip voices contributions entirely if voice_mask is empty */
if (voice_mask != 0) {
for (i = 0, mask = 1; i < MAX_VOICES;
++i, mask <<= 1, last_sample_ptr += 8) {
if ((voice_mask & mask) == 0)
continue;
for (k = 0; k < 4; ++k)
base_vol[k] += (int16_t)*dram_u16(hle, last_sample_ptr + k * 2);
}
}
/* optim: skip contributions entirely if mask_15 is empty */
if (mask_15 != 0) {
for(i = 0, mask = 1; i < 4;
++i, mask <<= 1, ptr_24 += 8) {
if ((mask_15 & mask) == 0)
continue;
for(k = 0; k < 4; ++k)
base_vol[k] += (int16_t)*dram_u16(hle, ptr_24 + k * 2);
}
}
/* apply 3% decay */
for (k = 0; k < 4; ++k)
base_vol[k] = (base_vol[k] * 0x0000f850) >> 16;
HleVerboseMessage(hle->user_defined,
"AFTER: base_vol = %08x %08x %08x %08x",
base_vol[0], base_vol[1], base_vol[2], base_vol[3]);
}
static void init_subframes_v1(musyx_t *musyx)
{
unsigned i;
int16_t base_cc0 = clamp_s16(musyx->base_vol[2]);
int16_t base_e50 = clamp_s16(musyx->base_vol[3]);
int16_t *left = musyx->left;
int16_t *right = musyx->right;
int16_t *cc0 = musyx->cc0;
int16_t *e50 = musyx->e50;
for (i = 0; i < SUBFRAME_SIZE; ++i) {
*(e50++) = base_e50;
*(left++) = clamp_s16(*cc0 + base_cc0);
*(right++) = clamp_s16(-*cc0 - base_cc0);
*(cc0++) = 0;
}
}
static void init_subframes_v2(musyx_t *musyx)
{
unsigned i,k;
int16_t values[4];
int16_t* subframes[4];
for(k = 0; k < 4; ++k)
values[k] = clamp_s16(musyx->base_vol[k]);
subframes[0] = musyx->left;
subframes[1] = musyx->right;
subframes[2] = musyx->cc0;
subframes[3] = musyx->e50;
for (i = 0; i < SUBFRAME_SIZE; ++i) {
for(k = 0; k < 4; ++k)
*(subframes[k]++) = values[k];
}
}
/* Process voices, and returns interleaved subframe destination address */
static uint32_t voice_stage(struct hle_t* hle, musyx_t *musyx,
uint32_t voice_ptr, uint32_t last_sample_ptr)
{
uint32_t output_ptr;
int i = 0;
/* voice stage can be skipped if first voice has no samples */
if (*dram_u16(hle, voice_ptr + VOICE_CATSRC_0 + CATSRC_SIZE1) == 0) {
HleVerboseMessage(hle->user_defined, "Skipping Voice stage");
output_ptr = *dram_u32(hle, voice_ptr + VOICE_INTERLEAVED_PTR);
} else {
/* otherwise process voices until a non null output_ptr is encountered */
for (;;) {
/* load voice samples (PCM16 or APDCM) */
int16_t samples[SAMPLE_BUFFER_SIZE];
unsigned segbase;
unsigned offset;
HleVerboseMessage(hle->user_defined, "Processing Voice #%d", i);
if (*dram_u8(hle, voice_ptr + VOICE_ADPCM_FRAMES) == 0)
load_samples_PCM16(hle, voice_ptr, samples, &segbase, &offset);
else
load_samples_ADPCM(hle, voice_ptr, samples, &segbase, &offset);
/* mix them with each internal subframes */
mix_voice_samples(hle, musyx, voice_ptr, samples, segbase, offset,
last_sample_ptr + i * 8);
/* check break condition */
output_ptr = *dram_u32(hle, voice_ptr + VOICE_INTERLEAVED_PTR);
if (output_ptr != 0)
break;
/* next voice */
++i;
voice_ptr += VOICE_SIZE;
}
}
return output_ptr;
}
static void dma_cat8(struct hle_t* hle, uint8_t *dst, uint32_t catsrc_ptr)
{
uint32_t ptr1 = *dram_u32(hle, catsrc_ptr + CATSRC_PTR1);
uint32_t ptr2 = *dram_u32(hle, catsrc_ptr + CATSRC_PTR2);
uint16_t size1 = *dram_u16(hle, catsrc_ptr + CATSRC_SIZE1);
uint16_t size2 = *dram_u16(hle, catsrc_ptr + CATSRC_SIZE2);
size_t count1 = size1;
size_t count2 = size2;
HleVerboseMessage(hle->user_defined,
"dma_cat: %08x %08x %04x %04x",
ptr1,
ptr2,
size1,
size2);
dram_load_u8(hle, dst, ptr1, count1);
if (size2 == 0)
return;
dram_load_u8(hle, dst + count1, ptr2, count2);
}
static void dma_cat16(struct hle_t* hle, uint16_t *dst, uint32_t catsrc_ptr)
{
uint32_t ptr1 = *dram_u32(hle, catsrc_ptr + CATSRC_PTR1);
uint32_t ptr2 = *dram_u32(hle, catsrc_ptr + CATSRC_PTR2);
uint16_t size1 = *dram_u16(hle, catsrc_ptr + CATSRC_SIZE1);
uint16_t size2 = *dram_u16(hle, catsrc_ptr + CATSRC_SIZE2);
size_t count1 = size1 >> 1;
size_t count2 = size2 >> 1;
HleVerboseMessage(hle->user_defined,
"dma_cat: %08x %08x %04x %04x",
ptr1,
ptr2,
size1,
size2);
dram_load_u16(hle, dst, ptr1, count1);
if (size2 == 0)
return;
dram_load_u16(hle, dst + count1, ptr2, count2);
}
static void load_samples_PCM16(struct hle_t* hle, uint32_t voice_ptr, int16_t *samples,
unsigned *segbase, unsigned *offset)
{
uint8_t u8_3e = *dram_u8(hle, voice_ptr + VOICE_SKIP_SAMPLES);
uint16_t u16_40 = *dram_u16(hle, voice_ptr + VOICE_U16_40);
uint16_t u16_42 = *dram_u16(hle, voice_ptr + VOICE_U16_42);
unsigned count = align(u16_40 + u8_3e, 4);
HleVerboseMessage(hle->user_defined, "Format: PCM16");
*segbase = SAMPLE_BUFFER_SIZE - count;
*offset = u8_3e;
dma_cat16(hle, (uint16_t *)samples + *segbase, voice_ptr + VOICE_CATSRC_0);
if (u16_42 != 0)
dma_cat16(hle, (uint16_t *)samples, voice_ptr + VOICE_CATSRC_1);
}
static void load_samples_ADPCM(struct hle_t* hle, uint32_t voice_ptr, int16_t *samples,
unsigned *segbase, unsigned *offset)
{
/* decompressed samples cannot exceed 0x400 bytes;
* ADPCM has a compression ratio of 5/16 */
uint8_t buffer[SAMPLE_BUFFER_SIZE * 2 * 5 / 16];
int16_t adpcm_table[128];
uint8_t u8_3c = *dram_u8(hle, voice_ptr + VOICE_ADPCM_FRAMES );
uint8_t u8_3d = *dram_u8(hle, voice_ptr + VOICE_ADPCM_FRAMES + 1);
uint8_t u8_3e = *dram_u8(hle, voice_ptr + VOICE_SKIP_SAMPLES );
uint8_t u8_3f = *dram_u8(hle, voice_ptr + VOICE_SKIP_SAMPLES + 1);
uint32_t adpcm_table_ptr = *dram_u32(hle, voice_ptr + VOICE_ADPCM_TABLE_PTR);
unsigned count;
HleVerboseMessage(hle->user_defined, "Format: ADPCM");
HleVerboseMessage(hle->user_defined, "Loading ADPCM table: %08x", adpcm_table_ptr);
dram_load_u16(hle, (uint16_t *)adpcm_table, adpcm_table_ptr, 128);
count = u8_3c << 5;
*segbase = SAMPLE_BUFFER_SIZE - count;
*offset = u8_3e & 0x1f;
dma_cat8(hle, buffer, voice_ptr + VOICE_CATSRC_0);
adpcm_decode_frames(hle, samples + *segbase, buffer, adpcm_table, u8_3c, u8_3e);
if (u8_3d != 0) {
dma_cat8(hle, buffer, voice_ptr + VOICE_CATSRC_1);
adpcm_decode_frames(hle, samples, buffer, adpcm_table, u8_3d, u8_3f);
}
}
static void adpcm_decode_frames(struct hle_t* hle,
int16_t *dst, const uint8_t *src,
const int16_t *table, uint8_t count,
uint8_t skip_samples)
{
int16_t frame[32];
const uint8_t *nibbles = src + 8;
unsigned i;
bool jump_gap = false;
HleVerboseMessage(hle->user_defined,
"ADPCM decode: count=%d, skip=%d",
count, skip_samples);
if (skip_samples >= 32) {
jump_gap = true;
nibbles += 16;
src += 4;
}
for (i = 0; i < count; ++i) {
uint8_t c2 = nibbles[0];
const int16_t *book = (c2 & 0xf0) + table;
unsigned int rshift = (c2 & 0x0f);
adpcm_predict_frame(frame, src, nibbles, rshift);
memcpy(dst, frame, 2 * sizeof(frame[0]));
adpcm_compute_residuals(dst + 2, frame + 2, book, dst , 6);
adpcm_compute_residuals(dst + 8, frame + 8, book, dst + 6, 8);
adpcm_compute_residuals(dst + 16, frame + 16, book, dst + 14, 8);
adpcm_compute_residuals(dst + 24, frame + 24, book, dst + 22, 8);
if (jump_gap) {
nibbles += 8;
src += 32;
}
jump_gap = !jump_gap;
nibbles += 16;
src += 4;
dst += 32;
}
}
static void adpcm_predict_frame(int16_t *dst, const uint8_t *src,
const uint8_t *nibbles,
unsigned int rshift)
{
unsigned int i;
*(dst++) = (src[0] << 8) | src[1];
*(dst++) = (src[2] << 8) | src[3];
for (i = 1; i < 16; ++i) {
uint8_t byte = nibbles[i];
*(dst++) = adpcm_predict_sample(byte, 0xf0, 8, rshift);
*(dst++) = adpcm_predict_sample(byte, 0x0f, 12, rshift);
}
}
static void mix_voice_samples(struct hle_t* hle, musyx_t *musyx,
uint32_t voice_ptr, const int16_t *samples,
unsigned segbase, unsigned offset, uint32_t last_sample_ptr)
{
int i, k;
/* parse VOICE structure */
const uint16_t pitch_q16 = *dram_u16(hle, voice_ptr + VOICE_PITCH_Q16);
const uint16_t pitch_shift = *dram_u16(hle, voice_ptr + VOICE_PITCH_SHIFT); /* Q4.12 */
const uint16_t end_point = *dram_u16(hle, voice_ptr + VOICE_END_POINT);
const uint16_t restart_point = *dram_u16(hle, voice_ptr + VOICE_RESTART_POINT);
const uint16_t u16_4e = *dram_u16(hle, voice_ptr + VOICE_U16_4E);
/* init values and pointers */
const int16_t *sample = samples + segbase + offset + u16_4e;
const int16_t *const sample_end = samples + segbase + end_point;
const int16_t *const sample_restart = samples + (restart_point & 0x7fff) +
(((restart_point & 0x8000) != 0) ? 0x000 : segbase);
uint32_t pitch_accu = pitch_q16;
uint32_t pitch_step = pitch_shift << 4;
int32_t v4_env[4];
int32_t v4_env_step[4];
int16_t *v4_dst[4];
int16_t v4[4];
dram_load_u32(hle, (uint32_t *)v4_env, voice_ptr + VOICE_ENV_BEGIN, 4);
dram_load_u32(hle, (uint32_t *)v4_env_step, voice_ptr + VOICE_ENV_STEP, 4);
v4_dst[0] = musyx->left;
v4_dst[1] = musyx->right;
v4_dst[2] = musyx->cc0;
v4_dst[3] = musyx->e50;
HleVerboseMessage(hle->user_defined,
"Voice debug: segbase=%d"
"\tu16_4e=%04x\n"
"\tpitch: frac0=%04x shift=%04x\n"
"\tend_point=%04x restart_point=%04x\n"
"\tenv = %08x %08x %08x %08x\n"
"\tenv_step = %08x %08x %08x %08x\n",
segbase,
u16_4e,
pitch_q16, pitch_shift,
end_point, restart_point,
v4_env[0], v4_env[1], v4_env[2], v4_env[3],
v4_env_step[0], v4_env_step[1], v4_env_step[2], v4_env_step[3]);
for (i = 0; i < SUBFRAME_SIZE; ++i) {
/* update sample and lut pointers and then pitch_accu */
const int16_t *lut = (RESAMPLE_LUT + ((pitch_accu & 0xfc00) >> 8));
int dist;
int16_t v;
sample += (pitch_accu >> 16);
pitch_accu &= 0xffff;
pitch_accu += pitch_step;
/* handle end/restart points */
dist = sample - sample_end;
if (dist >= 0)
sample = sample_restart + dist;
/* apply resample filter */
v = clamp_s16(dot4(sample, lut));
for (k = 0; k < 4; ++k) {
/* envmix */
int32_t accu = (v * (v4_env[k] >> 16)) >> 15;
v4[k] = clamp_s16(accu);
*(v4_dst[k]) = clamp_s16(accu + *(v4_dst[k]));
/* update envelopes and dst pointers */
++(v4_dst[k]);
v4_env[k] += v4_env_step[k];
}
}
/* save last resampled sample */
dram_store_u16(hle, (uint16_t *)v4, last_sample_ptr, 4);
HleVerboseMessage(hle->user_defined,
"last_sample = %04x %04x %04x %04x",
v4[0], v4[1], v4[2], v4[3]);
}
static void sfx_stage(struct hle_t* hle, mix_sfx_with_main_subframes_t mix_sfx_with_main_subframes,
musyx_t *musyx, uint32_t sfx_ptr, uint16_t idx)
{
unsigned int i;
int16_t buffer[SUBFRAME_SIZE + 4];
int16_t *subframe = buffer + 4;
uint32_t tap_delays[8];
int16_t tap_gains[8];
int16_t fir4_hcoeffs[4];
int16_t delayed[SUBFRAME_SIZE];
int dpos, dlength;
const uint32_t pos = idx * SUBFRAME_SIZE;
uint32_t cbuffer_ptr;
uint32_t cbuffer_length;
uint16_t tap_count;
int16_t fir4_hgain;
uint16_t sfx_gains[2];
HleVerboseMessage(hle->user_defined, "SFX: %08x, idx=%d", sfx_ptr, idx);
if (sfx_ptr == 0)
return;
/* load sfx parameters */
cbuffer_ptr = *dram_u32(hle, sfx_ptr + SFX_CBUFFER_PTR);
cbuffer_length = *dram_u32(hle, sfx_ptr + SFX_CBUFFER_LENGTH);
tap_count = *dram_u16(hle, sfx_ptr + SFX_TAP_COUNT);
dram_load_u32(hle, tap_delays, sfx_ptr + SFX_TAP_DELAYS, 8);
dram_load_u16(hle, (uint16_t *)tap_gains, sfx_ptr + SFX_TAP_GAINS, 8);
fir4_hgain = *dram_u16(hle, sfx_ptr + SFX_FIR4_HGAIN);
dram_load_u16(hle, (uint16_t *)fir4_hcoeffs, sfx_ptr + SFX_FIR4_HCOEFFS, 4);
sfx_gains[0] = *dram_u16(hle, sfx_ptr + SFX_U16_3C);
sfx_gains[1] = *dram_u16(hle, sfx_ptr + SFX_U16_3E);
HleVerboseMessage(hle->user_defined,
"cbuffer: ptr=%08x length=%x", cbuffer_ptr,
cbuffer_length);
HleVerboseMessage(hle->user_defined,
"fir4: hgain=%04x hcoeff=%04x %04x %04x %04x",
fir4_hgain,
fir4_hcoeffs[0], fir4_hcoeffs[1], fir4_hcoeffs[2], fir4_hcoeffs[3]);
HleVerboseMessage(hle->user_defined,
"tap count=%d\n"
"delays: %08x %08x %08x %08x %08x %08x %08x %08x\n"
"gains: %04x %04x %04x %04x %04x %04x %04x %04x",
tap_count,
tap_delays[0], tap_delays[1], tap_delays[2], tap_delays[3],
tap_delays[4], tap_delays[5], tap_delays[6], tap_delays[7],
tap_gains[0], tap_gains[1], tap_gains[2], tap_gains[3],
tap_gains[4], tap_gains[5], tap_gains[6], tap_gains[7]);
HleVerboseMessage(hle->user_defined, "sfx_gains=%04x %04x", sfx_gains[0], sfx_gains[1]);
/* mix up to 8 delayed subframes */
memset(subframe, 0, SUBFRAME_SIZE * sizeof(subframe[0]));
for (i = 0; i < tap_count; ++i) {
dpos = pos - tap_delays[i];
if (dpos <= 0)
dpos += cbuffer_length;
dlength = SUBFRAME_SIZE;
if ((uint32_t)(dpos + SUBFRAME_SIZE) > cbuffer_length) {
dlength = cbuffer_length - dpos;
dram_load_u16(hle, (uint16_t *)delayed + dlength, cbuffer_ptr, SUBFRAME_SIZE - dlength);
}
dram_load_u16(hle, (uint16_t *)delayed, cbuffer_ptr + dpos * 2, dlength);
mix_subframes(subframe, delayed, tap_gains[i]);
}
/* add resulting subframe to main subframes */
mix_sfx_with_main_subframes(musyx, subframe, sfx_gains);
/* apply FIR4 filter and writeback filtered result */
memcpy(buffer, musyx->subframe_740_last4, 4 * sizeof(int16_t));
memcpy(musyx->subframe_740_last4, subframe + SUBFRAME_SIZE - 4, 4 * sizeof(int16_t));
mix_fir4(musyx->e50, buffer + 1, fir4_hgain, fir4_hcoeffs);
dram_store_u16(hle, (uint16_t *)musyx->e50, cbuffer_ptr + pos * 2, SUBFRAME_SIZE);
}
static void mix_sfx_with_main_subframes_v1(musyx_t *musyx, const int16_t *subframe,
const uint16_t* UNUSED(gains))
{
unsigned i;
for (i = 0; i < SUBFRAME_SIZE; ++i) {
int16_t v = subframe[i];
musyx->left[i] = clamp_s16(musyx->left[i] + v);
musyx->right[i] = clamp_s16(musyx->right[i] + v);
}
}
static void mix_sfx_with_main_subframes_v2(musyx_t *musyx, const int16_t *subframe,
const uint16_t* gains)
{
unsigned i;
for (i = 0; i < SUBFRAME_SIZE; ++i) {
int16_t v = subframe[i];
int16_t v1 = (int32_t)(v * gains[0]) >> 16;
int16_t v2 = (int32_t)(v * gains[1]) >> 16;
musyx->left[i] = clamp_s16(musyx->left[i] + v1);
musyx->right[i] = clamp_s16(musyx->right[i] + v1);
musyx->cc0[i] = clamp_s16(musyx->cc0[i] + v2);
}
}
static void mix_samples(int16_t *y, int16_t x, int16_t hgain)
{
*y = clamp_s16(*y + ((x * hgain + 0x4000) >> 15));
}
static void mix_subframes(int16_t *y, const int16_t *x, int16_t hgain)
{
unsigned int i;
for (i = 0; i < SUBFRAME_SIZE; ++i)
mix_samples(&y[i], x[i], hgain);
}
static void mix_fir4(int16_t *y, const int16_t *x, int16_t hgain, const int16_t *hcoeffs)
{
unsigned int i;
int32_t h[4];
h[0] = (hgain * hcoeffs[0]) >> 15;
h[1] = (hgain * hcoeffs[1]) >> 15;
h[2] = (hgain * hcoeffs[2]) >> 15;
h[3] = (hgain * hcoeffs[3]) >> 15;
for (i = 0; i < SUBFRAME_SIZE; ++i) {
int32_t v = (h[0] * x[i] + h[1] * x[i + 1] + h[2] * x[i + 2] + h[3] * x[i + 3]) >> 15;
y[i] = clamp_s16(y[i] + v);
}
}
static void interleave_stage_v1(struct hle_t* hle, musyx_t *musyx, uint32_t output_ptr)
{
size_t i;
int16_t base_left;
int16_t base_right;
int16_t *left;
int16_t *right;
uint32_t *dst;
HleVerboseMessage(hle->user_defined, "interleave: %08x", output_ptr);
base_left = clamp_s16(musyx->base_vol[0]);
base_right = clamp_s16(musyx->base_vol[1]);
left = musyx->left;
right = musyx->right;
dst = dram_u32(hle, output_ptr);
for (i = 0; i < SUBFRAME_SIZE; ++i) {
uint16_t l = clamp_s16(*(left++) + base_left);
uint16_t r = clamp_s16(*(right++) + base_right);
*(dst++) = (l << 16) | r;
}
}
static void interleave_stage_v2(struct hle_t* hle, musyx_t *musyx,
uint16_t mask_16, uint32_t ptr_18,
uint32_t ptr_1c, uint32_t output_ptr)
{
unsigned i, k;
int16_t subframe[SUBFRAME_SIZE];
uint32_t *dst;
uint16_t mask;
HleVerboseMessage(hle->user_defined,
"mask_16=%04x ptr_18=%08x ptr_1c=%08x output_ptr=%08x",
mask_16, ptr_18, ptr_1c, output_ptr);
/* compute L_total, R_total and update subframe @ptr_1c */
memset(subframe, 0, SUBFRAME_SIZE*sizeof(subframe[0]));
for(i = 0; i < SUBFRAME_SIZE; ++i) {
int16_t v = *dram_u16(hle, ptr_1c + i*2);
musyx->left[i] = v;
musyx->right[i] = clamp_s16(-v);
}
for (k = 0, mask = 1; k < 8; ++k, mask <<= 1, ptr_18 += 8) {
int16_t hgain;
uint32_t address;
if ((mask_16 & mask) == 0)
continue;
address = *dram_u32(hle, ptr_18);
hgain = *dram_u16(hle, ptr_18 + 4);
for(i = 0; i < SUBFRAME_SIZE; ++i, address += 2) {
mix_samples(&musyx->left[i], *dram_u16(hle, address), hgain);
mix_samples(&musyx->right[i], *dram_u16(hle, address + 2*SUBFRAME_SIZE), hgain);
mix_samples(&subframe[i], *dram_u16(hle, address + 4*SUBFRAME_SIZE), hgain);
}
}
/* interleave L_total and R_total */
dst = dram_u32(hle, output_ptr);
for(i = 0; i < SUBFRAME_SIZE; ++i) {
uint16_t l = musyx->left[i];
uint16_t r = musyx->right[i];
*(dst++) = (l << 16) | r;
}
/* writeback subframe @ptr_1c */
dram_store_u16(hle, (uint16_t*)subframe, ptr_1c, SUBFRAME_SIZE);
}

34
src/osal_dynamiclib.h Normal file
View file

@ -0,0 +1,34 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_dynamiclib.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if !defined(OSAL_DYNAMICLIB_H)
#define OSAL_DYNAMICLIB_H
#include "m64p_types.h"
m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath);
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName);
m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle);
#endif /* #define OSAL_DYNAMICLIB_H */

View file

@ -0,0 +1,71 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_dynamiclib_unix.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "m64p_types.h"
#include "hle_external.h"
#include "osal_dynamiclib.h"
m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)
{
if (pLibHandle == NULL || pccLibraryPath == NULL)
return M64ERR_INPUT_ASSERT;
*pLibHandle = dlopen(pccLibraryPath, RTLD_NOW);
if (*pLibHandle == NULL)
{
/* only print an error message if there is a directory separator (/) in the pathname */
/* this prevents us from throwing an error for the use case where Mupen64Plus is not installed */
if (strchr(pccLibraryPath, '/') != NULL)
HleErrorMessage(NULL, "dlopen('%s') failed: %s", pccLibraryPath, dlerror());
return M64ERR_INPUT_NOT_FOUND;
}
return M64ERR_SUCCESS;
}
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
{
if (pccProcedureName == NULL)
return NULL;
return dlsym(LibHandle, pccProcedureName);
}
m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
{
int rval = dlclose(LibHandle);
if (rval != 0)
{
HleErrorMessage(NULL, "dlclose() failed: %s", dlerror());
return M64ERR_INTERNAL;
}
return M64ERR_SUCCESS;
}

View file

@ -0,0 +1,75 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_dynamiclib_win32.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "m64p_types.h"
#include "hle_external.h"
#include "osal_dynamiclib.h"
m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)
{
if (pLibHandle == NULL || pccLibraryPath == NULL)
return M64ERR_INPUT_ASSERT;
*pLibHandle = LoadLibrary(pccLibraryPath);
if (*pLibHandle == NULL)
{
char *pchErrMsg;
DWORD dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
HleErrorMessage(NULL, "LoadLibrary('%s') error: %s", pccLibraryPath, pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INPUT_NOT_FOUND;
}
return M64ERR_SUCCESS;
}
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
{
if (pccProcedureName == NULL)
return NULL;
return GetProcAddress(LibHandle, pccProcedureName);
}
m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
{
int rval = FreeLibrary(LibHandle);
if (rval == 0)
{
char *pchErrMsg;
DWORD dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
HleErrorMessage(NULL, "FreeLibrary() error: %s", pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INTERNAL;
}
return M64ERR_SUCCESS;
}

481
src/plugin.c Normal file
View file

@ -0,0 +1,481 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - plugin.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "hle.h"
#include "hle_internal.h"
#include "hle_external.h"
#define M64P_PLUGIN_PROTOTYPES 1
#include "m64p_common.h"
#include "m64p_config.h"
#include "m64p_frontend.h"
#include "m64p_plugin.h"
#include "m64p_types.h"
#include "osal_dynamiclib.h"
#define CONFIG_API_VERSION 0x020100
#define CONFIG_PARAM_VERSION 1.00
#define RSP_API_VERSION 0x20000
#define RSP_HLE_VERSION 0x020600
#define RSP_PLUGIN_API_VERSION 0x020000
#define RSP_HLE_CONFIG_SECTION "Rsp-HLE"
#define RSP_HLE_CONFIG_VERSION "Version"
#define RSP_HLE_CONFIG_FALLBACK "RspFallback"
#define RSP_HLE_CONFIG_HLE_GFX "DisplayListToGraphicsPlugin"
#define RSP_HLE_CONFIG_HLE_AUD "AudioListToAudioPlugin"
#define VERSION_PRINTF_SPLIT(x) (((x) >> 16) & 0xffff), (((x) >> 8) & 0xff), ((x) & 0xff)
/* Handy macro to avoid code bloat when loading symbols */
#define GET_FUNC(type, field, name) \
((field = (type)osal_dynlib_getproc(handle, name)) != NULL)
/* local variables */
static struct hle_t g_hle;
static void (*l_CheckInterrupts)(void) = NULL;
static void (*l_ProcessDlistList)(void) = NULL;
static void (*l_ProcessAlistList)(void) = NULL;
static void (*l_ProcessRdpList)(void) = NULL;
static void (*l_ShowCFB)(void) = NULL;
static void (*l_DebugCallback)(void *, int, const char *) = NULL;
static void *l_DebugCallContext = NULL;
static m64p_dynlib_handle l_CoreHandle = NULL;
static int l_PluginInit = 0;
static m64p_handle l_ConfigRspHle;
static m64p_dynlib_handle l_RspFallback;
static ptr_InitiateRSP l_InitiateRSP = NULL;
static ptr_DoRspCycles l_DoRspCycles = NULL;
static ptr_RomClosed l_RomClosed = NULL;
static ptr_PluginShutdown l_PluginShutdown = NULL;
/* definitions of pointers to Core functions */
static ptr_ConfigOpenSection ConfigOpenSection = NULL;
static ptr_ConfigDeleteSection ConfigDeleteSection = NULL;
static ptr_ConfigSetParameter ConfigSetParameter = NULL;
static ptr_ConfigGetParameter ConfigGetParameter = NULL;
static ptr_ConfigSetDefaultInt ConfigSetDefaultInt = NULL;
static ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat = NULL;
static ptr_ConfigSetDefaultBool ConfigSetDefaultBool = NULL;
static ptr_ConfigSetDefaultString ConfigSetDefaultString = NULL;
static ptr_ConfigGetParamInt ConfigGetParamInt = NULL;
static ptr_ConfigGetParamFloat ConfigGetParamFloat = NULL;
static ptr_ConfigGetParamBool ConfigGetParamBool = NULL;
static ptr_ConfigGetParamString ConfigGetParamString = NULL;
static ptr_CoreDoCommand CoreDoCommand = NULL;
/* local function */
static void teardown_rsp_fallback()
{
if (l_RspFallback != NULL) {
(*l_PluginShutdown)();
osal_dynlib_close(l_RspFallback);
}
l_RspFallback = NULL;
l_DoRspCycles = NULL;
l_InitiateRSP = NULL;
l_RomClosed = NULL;
l_PluginShutdown = NULL;
}
static void setup_rsp_fallback(const char* rsp_fallback_path)
{
m64p_dynlib_handle handle = NULL;
/* reset rsp fallback */
teardown_rsp_fallback();
if (rsp_fallback_path == NULL || strlen(rsp_fallback_path) == 0) {
HleInfoMessage(NULL, "RSP Fallback disabled !");
return;
}
/* load plugin */
if (osal_dynlib_open(&handle, rsp_fallback_path) != M64ERR_SUCCESS) {
HleErrorMessage(NULL, "Can't load library: %s", rsp_fallback_path);
return;
}
/* call the GetVersion function for the plugin and check compatibility */
ptr_PluginGetVersion PluginGetVersion = (ptr_PluginGetVersion) osal_dynlib_getproc(handle, "PluginGetVersion");
if (PluginGetVersion == NULL)
{
HleErrorMessage(NULL, "library '%s' is not a Mupen64Plus library.", rsp_fallback_path);
goto close_handle;
}
m64p_plugin_type plugin_type = (m64p_plugin_type)0;
int plugin_version = 0;
const char *plugin_name = NULL;
int api_version = 0;
(*PluginGetVersion)(&plugin_type, &plugin_version, &api_version, &plugin_name, NULL);
if (plugin_type != M64PLUGIN_RSP) {
HleErrorMessage(NULL, "plugin %s is not an RSP plugin (%u)", plugin_name, plugin_type);
goto close_handle;
}
if ((api_version & 0xffff0000) != (RSP_API_VERSION & 0xffff0000)) {
HleErrorMessage(NULL, "plugin %s. Version mismatch: %u.%u. Expected >= %u.0",
plugin_name,
(uint16_t)(api_version >> 16),
(uint16_t)(api_version),
(uint16_t)(RSP_API_VERSION >> 16));
goto close_handle;
}
/* load functions */
ptr_PluginStartup PluginStartup;
if (!GET_FUNC(ptr_PluginStartup, PluginStartup, "PluginStartup") ||
!GET_FUNC(ptr_PluginShutdown, l_PluginShutdown, "PluginShutdown") ||
!GET_FUNC(ptr_DoRspCycles, l_DoRspCycles, "DoRspCycles") ||
!GET_FUNC(ptr_InitiateRSP, l_InitiateRSP, "InitiateRSP") ||
!GET_FUNC(ptr_RomClosed, l_RomClosed, "RomClosed"))
{
HleErrorMessage(NULL, "broken RSP plugin; function(s) not found.");
l_PluginShutdown = NULL;
l_DoRspCycles = NULL;
l_InitiateRSP = NULL;
l_RomClosed = NULL;
goto close_handle;
}
/* call the plugin's initialization function and make sure it starts okay */
if ((*PluginStartup)(l_CoreHandle, l_DebugCallContext, l_DebugCallback) != M64ERR_SUCCESS) {
HleErrorMessage(NULL, "Error: %s plugin library '%s' failed to start.", plugin_name, rsp_fallback_path);
goto close_handle;
}
/* OK we're done ! */
l_RspFallback = handle;
HleInfoMessage(NULL, "RSP Fallback '%s' loaded successfully !", rsp_fallback_path);
return;
close_handle:
osal_dynlib_close(handle);
}
static void DebugMessage(int level, const char *message, va_list args)
{
char msgbuf[1024];
if (l_DebugCallback == NULL)
return;
vsprintf(msgbuf, message, args);
(*l_DebugCallback)(l_DebugCallContext, level, msgbuf);
}
/* Global functions needed by HLE core */
void HleVerboseMessage(void* UNUSED(user_defined), const char *message, ...)
{
va_list args;
va_start(args, message);
DebugMessage(M64MSG_VERBOSE, message, args);
va_end(args);
}
void HleInfoMessage(void* UNUSED(user_defined), const char *message, ...)
{
va_list args;
va_start(args, message);
DebugMessage(M64MSG_INFO, message, args);
va_end(args);
}
void HleErrorMessage(void* UNUSED(user_defined), const char *message, ...)
{
va_list args;
va_start(args, message);
DebugMessage(M64MSG_ERROR, message, args);
va_end(args);
}
void HleWarnMessage(void* UNUSED(user_defined), const char *message, ...)
{
va_list args;
va_start(args, message);
DebugMessage(M64MSG_WARNING, message, args);
va_end(args);
}
void HleCheckInterrupts(void* UNUSED(user_defined))
{
if (l_CheckInterrupts == NULL)
return;
(*l_CheckInterrupts)();
}
void HleProcessDlistList(void* UNUSED(user_defined))
{
if (l_ProcessDlistList == NULL)
return;
(*l_ProcessDlistList)();
}
void HleProcessAlistList(void* UNUSED(user_defined))
{
if (l_ProcessAlistList == NULL)
return;
(*l_ProcessAlistList)();
}
void HleProcessRdpList(void* UNUSED(user_defined))
{
if (l_ProcessRdpList == NULL)
return;
(*l_ProcessRdpList)();
}
void HleShowCFB(void* UNUSED(user_defined))
{
if (l_ShowCFB == NULL)
return;
(*l_ShowCFB)();
}
int HleForwardTask(void* user_defined)
{
if (l_DoRspCycles == NULL)
return -1;
(*l_DoRspCycles)(-1);
return 0;
}
/* DLL-exported functions */
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
void (*DebugCallback)(void *, int, const char *))
{
ptr_CoreGetAPIVersions CoreAPIVersionFunc;
int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion;
float fConfigParamsVersion = 0.0f;
if (l_PluginInit)
return M64ERR_ALREADY_INIT;
/* first thing is to set the callback function for debug info */
l_DebugCallback = DebugCallback;
l_DebugCallContext = Context;
/* attach and call the CoreGetAPIVersions function, check Config API version for compatibility */
CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreLibHandle, "CoreGetAPIVersions");
if (CoreAPIVersionFunc == NULL)
{
HleErrorMessage(NULL, "Core emulator broken; no CoreAPIVersionFunc() function found.");
return M64ERR_INCOMPATIBLE;
}
(*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL);
if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000))
{
HleErrorMessage(NULL, "Emulator core Config API (v%i.%i.%i) incompatible with plugin (v%i.%i.%i)",
VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION));
return M64ERR_INCOMPATIBLE;
}
/* Get the core config function pointers from the library handle */
ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection");
ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(CoreLibHandle, "ConfigDeleteSection");
ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigSetParameter");
ConfigGetParameter = (ptr_ConfigGetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParameter");
ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultInt");
ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultFloat");
ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultBool");
ConfigSetDefaultString = (ptr_ConfigSetDefaultString) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultString");
ConfigGetParamInt = (ptr_ConfigGetParamInt) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamInt");
ConfigGetParamFloat = (ptr_ConfigGetParamFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamFloat");
ConfigGetParamBool = (ptr_ConfigGetParamBool) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamBool");
ConfigGetParamString = (ptr_ConfigGetParamString) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamString");
if (!ConfigOpenSection || !ConfigDeleteSection || !ConfigSetParameter || !ConfigGetParameter ||
!ConfigSetDefaultInt || !ConfigSetDefaultFloat || !ConfigSetDefaultBool || !ConfigSetDefaultString ||
!ConfigGetParamInt || !ConfigGetParamFloat || !ConfigGetParamBool || !ConfigGetParamString)
return M64ERR_INCOMPATIBLE;
/* Get core DoCommand function */
CoreDoCommand = (ptr_CoreDoCommand) osal_dynlib_getproc(CoreLibHandle, "CoreDoCommand");
if (!CoreDoCommand) {
return M64ERR_INCOMPATIBLE;
}
/* get a configuration section handle */
if (ConfigOpenSection(RSP_HLE_CONFIG_SECTION, &l_ConfigRspHle) != M64ERR_SUCCESS)
{
HleErrorMessage(NULL, "Couldn't open config section '" RSP_HLE_CONFIG_SECTION "'");
return M64ERR_INPUT_NOT_FOUND;
}
/* check the section version number */
if (ConfigGetParameter(l_ConfigRspHle, RSP_HLE_CONFIG_VERSION, M64TYPE_FLOAT, &fConfigParamsVersion, sizeof(float)) != M64ERR_SUCCESS)
{
HleWarnMessage(NULL, "No version number in '" RSP_HLE_CONFIG_SECTION "' config section. Setting defaults.");
ConfigDeleteSection(RSP_HLE_CONFIG_SECTION);
ConfigOpenSection(RSP_HLE_CONFIG_SECTION, &l_ConfigRspHle);
}
else if (((int) fConfigParamsVersion) != ((int) CONFIG_PARAM_VERSION))
{
HleWarnMessage(NULL, "Incompatible version %.2f in '" RSP_HLE_CONFIG_SECTION "' config section: current is %.2f. Setting defaults.", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION);
ConfigDeleteSection(RSP_HLE_CONFIG_SECTION);
ConfigOpenSection(RSP_HLE_CONFIG_SECTION, &l_ConfigRspHle);
}
else if ((CONFIG_PARAM_VERSION - fConfigParamsVersion) >= 0.0001f)
{
/* handle upgrades */
float fVersion = CONFIG_PARAM_VERSION;
ConfigSetParameter(l_ConfigRspHle, "Version", M64TYPE_FLOAT, &fVersion);
HleInfoMessage(NULL, "Updating parameter set version in '" RSP_HLE_CONFIG_SECTION "' config section to %.2f", fVersion);
}
/* set the default values for this plugin */
ConfigSetDefaultFloat(l_ConfigRspHle, RSP_HLE_CONFIG_VERSION, CONFIG_PARAM_VERSION,
"Mupen64Plus RSP HLE Plugin config parameter version number");
ConfigSetDefaultString(l_ConfigRspHle, RSP_HLE_CONFIG_FALLBACK, "",
"Path to a RSP plugin which will be used when encountering an unknown ucode."
"You can disable this by letting an empty string.");
ConfigSetDefaultBool(l_ConfigRspHle, RSP_HLE_CONFIG_HLE_GFX, 1,
"Send display lists to the graphics plugin");
ConfigSetDefaultBool(l_ConfigRspHle, RSP_HLE_CONFIG_HLE_AUD, 0,
"Send audio lists to the audio plugin");
l_CoreHandle = CoreLibHandle;
l_PluginInit = 1;
return M64ERR_SUCCESS;
}
EXPORT m64p_error CALL PluginShutdown(void)
{
if (!l_PluginInit)
return M64ERR_NOT_INIT;
/* reset some local variable */
l_DebugCallback = NULL;
l_DebugCallContext = NULL;
l_CoreHandle = NULL;
teardown_rsp_fallback();
l_PluginInit = 0;
return M64ERR_SUCCESS;
}
EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities)
{
/* set version info */
if (PluginType != NULL)
*PluginType = M64PLUGIN_RSP;
if (PluginVersion != NULL)
*PluginVersion = RSP_HLE_VERSION;
if (APIVersion != NULL)
*APIVersion = RSP_PLUGIN_API_VERSION;
if (PluginNamePtr != NULL)
*PluginNamePtr = "Hacktarux/Azimer High-Level Emulation RSP Plugin";
if (Capabilities != NULL)
*Capabilities = 0;
return M64ERR_SUCCESS;
}
EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles)
{
hle_execute(&g_hle);
return Cycles;
}
EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, unsigned int* CycleCount)
{
hle_init(&g_hle,
Rsp_Info.RDRAM,
Rsp_Info.DMEM,
Rsp_Info.IMEM,
Rsp_Info.MI_INTR_REG,
Rsp_Info.SP_MEM_ADDR_REG,
Rsp_Info.SP_DRAM_ADDR_REG,
Rsp_Info.SP_RD_LEN_REG,
Rsp_Info.SP_WR_LEN_REG,
Rsp_Info.SP_STATUS_REG,
Rsp_Info.SP_DMA_FULL_REG,
Rsp_Info.SP_DMA_BUSY_REG,
Rsp_Info.SP_PC_REG,
Rsp_Info.SP_SEMAPHORE_REG,
Rsp_Info.DPC_START_REG,
Rsp_Info.DPC_END_REG,
Rsp_Info.DPC_CURRENT_REG,
Rsp_Info.DPC_STATUS_REG,
Rsp_Info.DPC_CLOCK_REG,
Rsp_Info.DPC_BUFBUSY_REG,
Rsp_Info.DPC_PIPEBUSY_REG,
Rsp_Info.DPC_TMEM_REG,
NULL);
l_CheckInterrupts = Rsp_Info.CheckInterrupts;
l_ProcessDlistList = Rsp_Info.ProcessDlistList;
l_ProcessAlistList = Rsp_Info.ProcessAlistList;
l_ProcessRdpList = Rsp_Info.ProcessRdpList;
l_ShowCFB = Rsp_Info.ShowCFB;
setup_rsp_fallback(ConfigGetParamString(l_ConfigRspHle, RSP_HLE_CONFIG_FALLBACK));
g_hle.hle_gfx = ConfigGetParamBool(l_ConfigRspHle, RSP_HLE_CONFIG_HLE_GFX);
g_hle.hle_aud = ConfigGetParamBool(l_ConfigRspHle, RSP_HLE_CONFIG_HLE_AUD);
/* notify fallback plugin */
if (l_InitiateRSP) {
l_InitiateRSP(Rsp_Info, CycleCount);
}
}
EXPORT void CALL RomClosed(void)
{
g_hle.cached_ucodes.count = 0;
/* notify fallback plugin */
if (l_RomClosed) {
l_RomClosed();
}
}

224
src/re2.c Normal file
View file

@ -0,0 +1,224 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - re2.c *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2016 Gilles Siberlin *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
#define SATURATE8(x) ((unsigned int) x <= 255 ? x : (x < 0 ? 0: 255))
/**************************************************************************
* Resident evil 2 ucodes
**************************************************************************/
void resize_bilinear_task(struct hle_t* hle)
{
int data_ptr = *dmem_u32(hle, TASK_UCODE_DATA);
int src_addr = *dram_u32(hle, data_ptr);
int dst_addr = *dram_u32(hle, data_ptr + 4);
int dst_width = *dram_u32(hle, data_ptr + 8);
int dst_height = *dram_u32(hle, data_ptr + 12);
int x_ratio = *dram_u32(hle, data_ptr + 16);
int y_ratio = *dram_u32(hle, data_ptr + 20);
#if 0 /* unused, but keep it for documentation purpose */
int dst_stride = *dram_u32(hle, data_ptr + 24);
#endif
int src_offset = *dram_u32(hle, data_ptr + 36);
int a, b, c ,d, index, y_index, xr, yr, blue, green, red, addr, i, j;
long long x, y, x_diff, y_diff, one_min_x_diff, one_min_y_diff;
unsigned short pixel;
src_addr += (src_offset >> 16) * (320 * 3);
x = y = 0;
for(i = 0; i < dst_height; i++)
{
yr = (int)(y >> 16);
y_diff = y - (yr << 16);
one_min_y_diff = 65536 - y_diff;
y_index = yr * 320;
x = 0;
for(j = 0; j < dst_width; j++)
{
xr = (int)(x >> 16);
x_diff = x - (xr << 16);
one_min_x_diff = 65536 - x_diff;
index = y_index + xr;
addr = src_addr + (index * 3);
dram_load_u8(hle, (uint8_t*)&a, addr, 3);
dram_load_u8(hle, (uint8_t*)&b, (addr + 3), 3);
dram_load_u8(hle, (uint8_t*)&c, (addr + (320 * 3)), 3);
dram_load_u8(hle, (uint8_t*)&d, (addr + (320 * 3) + 3), 3);
blue = (int)(((a&0xff)*one_min_x_diff*one_min_y_diff + (b&0xff)*x_diff*one_min_y_diff +
(c&0xff)*y_diff*one_min_x_diff + (d&0xff)*x_diff*y_diff) >> 32);
green = (int)((((a>>8)&0xff)*one_min_x_diff*one_min_y_diff + ((b>>8)&0xff)*x_diff*one_min_y_diff +
((c>>8)&0xff)*y_diff*one_min_x_diff + ((d>>8)&0xff)*x_diff*y_diff) >> 32);
red = (int)((((a>>16)&0xff)*one_min_x_diff*one_min_y_diff + ((b>>16)&0xff)*x_diff*one_min_y_diff +
((c>>16)&0xff)*y_diff*one_min_x_diff + ((d>>16)&0xff)*x_diff*y_diff) >> 32);
blue = (blue >> 3) & 0x001f;
green = (green >> 3) & 0x001f;
red = (red >> 3) & 0x001f;
pixel = (red << 11) | (green << 6) | (blue << 1) | 1;
dram_store_u16(hle, &pixel, dst_addr, 1);
dst_addr += 2;
x += x_ratio;
}
y += y_ratio;
}
rsp_break(hle, SP_STATUS_TASKDONE);
}
static uint32_t YCbCr_to_RGBA(uint8_t Y, uint8_t Cb, uint8_t Cr)
{
int r, g, b;
r = (int)(((double)Y * 0.582199097) + (0.701004028 * (double)(Cr - 128)));
g = (int)(((double)Y * 0.582199097) - (0.357070923 * (double)(Cr - 128)) - (0.172073364 * (double)(Cb - 128)));
b = (int)(((double)Y * 0.582199097) + (0.886001587 * (double)(Cb - 128)));
r = SATURATE8(r);
g = SATURATE8(g);
b = SATURATE8(b);
return (r << 24) | (g << 16) | (b << 8) | 0;
}
void decode_video_frame_task(struct hle_t* hle)
{
int data_ptr = *dmem_u32(hle, TASK_UCODE_DATA);
int pLuminance = *dram_u32(hle, data_ptr);
int pCb = *dram_u32(hle, data_ptr + 4);
int pCr = *dram_u32(hle, data_ptr + 8);
int pDestination = *dram_u32(hle, data_ptr + 12);
int nMovieWidth = *dram_u32(hle, data_ptr + 16);
int nMovieHeight = *dram_u32(hle, data_ptr + 20);
#if 0 /* unused, but keep it for documentation purpose */
int nRowsPerDMEM = *dram_u32(hle, data_ptr + 24);
int nDMEMPerFrame = *dram_u32(hle, data_ptr + 28);
int nLengthSkipCount = *dram_u32(hle, data_ptr + 32);
#endif
int nScreenDMAIncrement = *dram_u32(hle, data_ptr + 36);
int i, j;
uint8_t Y, Cb, Cr;
uint32_t pixel;
int pY_1st_row, pY_2nd_row, pDest_1st_row, pDest_2nd_row;
for (i = 0; i < nMovieHeight; i += 2)
{
pY_1st_row = pLuminance;
pY_2nd_row = pLuminance + nMovieWidth;
pDest_1st_row = pDestination;
pDest_2nd_row = pDestination + (nScreenDMAIncrement >> 1);
for (j = 0; j < nMovieWidth; j += 2)
{
dram_load_u8(hle, (uint8_t*)&Cb, pCb++, 1);
dram_load_u8(hle, (uint8_t*)&Cr, pCr++, 1);
/*1st row*/
dram_load_u8(hle, (uint8_t*)&Y, pY_1st_row++, 1);
pixel = YCbCr_to_RGBA(Y, Cb, Cr);
dram_store_u32(hle, &pixel, pDest_1st_row, 1);
pDest_1st_row += 4;
dram_load_u8(hle, (uint8_t*)&Y, pY_1st_row++, 1);
pixel = YCbCr_to_RGBA(Y, Cb, Cr);
dram_store_u32(hle, &pixel, pDest_1st_row, 1);
pDest_1st_row += 4;
/*2nd row*/
dram_load_u8(hle, (uint8_t*)&Y, pY_2nd_row++, 1);
pixel = YCbCr_to_RGBA(Y, Cb, Cr);
dram_store_u32(hle, &pixel, pDest_2nd_row, 1);
pDest_2nd_row += 4;
dram_load_u8(hle, (uint8_t*)&Y, pY_2nd_row++, 1);
pixel = YCbCr_to_RGBA(Y, Cb, Cr);
dram_store_u32(hle, &pixel, pDest_2nd_row, 1);
pDest_2nd_row += 4;
}
pLuminance += (nMovieWidth << 1);
pDestination += nScreenDMAIncrement;
}
rsp_break(hle, SP_STATUS_TASKDONE);
}
void fill_video_double_buffer_task(struct hle_t* hle)
{
int data_ptr = *dmem_u32(hle, TASK_UCODE_DATA);
int pSrc = *dram_u32(hle, data_ptr);
int pDest = *dram_u32(hle, data_ptr + 0x4);
int width = *dram_u32(hle, data_ptr + 0x8) >> 1;
int height = *dram_u32(hle, data_ptr + 0x10) << 1;
int stride = *dram_u32(hle, data_ptr + 0x1c) >> 1;
assert((*dram_u32(hle, data_ptr + 0x28) >> 16) == 0x8000);
#if 0 /* unused, but keep it for documentation purpose */
int arg3 = *dram_u32(hle, data_ptr + 0xc);
int arg5 = *dram_u32(hle, data_ptr + 0x14);
int arg6 = *dram_u32(hle, data_ptr + 0x18);
#endif
int i, j;
int r, g, b;
uint32_t pixel, pixel1, pixel2;
for(i = 0; i < height; i++)
{
for(j = 0; j < width; j=j+4)
{
pixel1 = *dram_u32(hle, pSrc+j);
pixel2 = *dram_u32(hle, pDest+j);
r = (((pixel1 >> 24) & 0xff) + ((pixel2 >> 24) & 0xff)) >> 1;
g = (((pixel1 >> 16) & 0xff) + ((pixel2 >> 16) & 0xff)) >> 1;
b = (((pixel1 >> 8) & 0xff) + ((pixel2 >> 8) & 0xff)) >> 1;
pixel = (r << 24) | (g << 16) | (b << 8) | 0;
dram_store_u32(hle, &pixel, pDest+j, 1);
}
pSrc += stride;
pDest += stride;
}
rsp_break(hle, SP_STATUS_TASKDONE);
}

View file

@ -1,954 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - ucode1.cpp *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <string.h>
extern "C" {
#include "hle.h"
}
extern "C" void (*ABI1[])(void);
//#include "rsp.h"
//#define SAFE_MEMORY
/*
#ifndef SAFE_MEMORY
# define wr8 (src , address);
# define rd8 (dest, address);
# define wr16 (src, address);
# define rd16 (dest, address);
# define wr32 (src, address);
# define rd32 (dest, address);
# define wr64 (src, address);
# define rd64 (dest, address);
# define dmamem (dest, src, size) memcpy (dest, src, size);
# define clrmem (dest, size) memset (dest, 0, size);
#else
void wr8 (u8 src, void *address);
void rd8 (u8 dest, void *address);
void wr16 (u16 src, void *address);
void rd16 (u16 dest, void *address);
void wr32 (u16 src, void *address);
void rd32 (u16 dest, void *address);
void wr64 (u16 src, void *address);
void rd64 (u16 dest, void *address);
void dmamem (void *dest, void *src, int size);
void clrmem (void *dest, int size);
#endif
*/
/******** DMEM Memory Map for ABI 1 ***************
Address/Range Description
------------- -------------------------------
0x000..0x2BF UCodeData
0x000-0x00F Constants - 0000 0001 0002 FFFF 0020 0800 7FFF 4000
0x010-0x02F Function Jump Table (16 Functions * 2 bytes each = 32) 0x20
0x030-0x03F Constants - F000 0F00 00F0 000F 0001 0010 0100 1000
0x040-0x03F Used by the Envelope Mixer (But what for?)
0x070-0x07F Used by the Envelope Mixer (But what for?)
0x2C0..0x31F <Unknown>
0x320..0x35F Segments
0x360 Audio In Buffer (Location)
0x362 Audio Out Buffer (Location)
0x364 Audio Buffer Size (Location)
0x366 Initial Volume for Left Channel
0x368 Initial Volume for Right Channel
0x36A Auxillary Buffer #1 (Location)
0x36C Auxillary Buffer #2 (Location)
0x36E Auxillary Buffer #3 (Location)
0x370 Loop Value (shared location)
0x370 Target Volume (Left)
0x372 Ramp?? (Left)
0x374 Rate?? (Left)
0x376 Target Volume (Right)
0x378 Ramp?? (Right)
0x37A Rate?? (Right)
0x37C Dry??
0x37E Wet??
0x380..0x4BF Alist data
0x4C0..0x4FF ADPCM CodeBook
0x500..0x5BF <Unknown>
0x5C0..0xF7F Buffers...
0xF80..0xFFF <Unknown>
***************************************************/
#ifdef USE_EXPANSION
#define MEMMASK 0x7FFFFF
#else
#define MEMMASK 0x3FFFFF
#endif
static void SPNOOP (void) {
//MessageBox (NULL, "Unknown Audio Command in ABI 1", "Audio HLE Error", MB_OK);
}
u32 SEGMENTS[0x10]; // 0x0320
// T8 = 0x360
u16 AudioInBuffer; // 0x0000(T8)
u16 AudioOutBuffer; // 0x0002(T8)
u16 AudioCount; // 0x0004(T8)
s16 Vol_Left; // 0x0006(T8)
s16 Vol_Right; // 0x0008(T8)
u16 AudioAuxA; // 0x000A(T8)
u16 AudioAuxC; // 0x000C(T8)
u16 AudioAuxE; // 0x000E(T8)
u32 loopval; // 0x0010(T8) // Value set by A_SETLOOP : Possible conflict with SETVOLUME???
s16 VolTrg_Left; // 0x0010(T8)
s32 VolRamp_Left; // m_LeftVolTarget
//u16 VolRate_Left; // m_LeftVolRate
s16 VolTrg_Right; // m_RightVol
s32 VolRamp_Right; // m_RightVolTarget
//u16 VolRate_Right; // m_RightVolRate
s16 Env_Dry; // 0x001C(T8)
s16 Env_Wet; // 0x001E(T8)
u8 BufferSpace[0x10000];
short hleMixerWorkArea[256];
u16 adpcmtable[0x88];
u16 ResampleLUT [0x200] = {
0x0C39, 0x66AD, 0x0D46, 0xFFDF, 0x0B39, 0x6696, 0x0E5F, 0xFFD8,
0x0A44, 0x6669, 0x0F83, 0xFFD0, 0x095A, 0x6626, 0x10B4, 0xFFC8,
0x087D, 0x65CD, 0x11F0, 0xFFBF, 0x07AB, 0x655E, 0x1338, 0xFFB6,
0x06E4, 0x64D9, 0x148C, 0xFFAC, 0x0628, 0x643F, 0x15EB, 0xFFA1,
0x0577, 0x638F, 0x1756, 0xFF96, 0x04D1, 0x62CB, 0x18CB, 0xFF8A,
0x0435, 0x61F3, 0x1A4C, 0xFF7E, 0x03A4, 0x6106, 0x1BD7, 0xFF71,
0x031C, 0x6007, 0x1D6C, 0xFF64, 0x029F, 0x5EF5, 0x1F0B, 0xFF56,
0x022A, 0x5DD0, 0x20B3, 0xFF48, 0x01BE, 0x5C9A, 0x2264, 0xFF3A,
0x015B, 0x5B53, 0x241E, 0xFF2C, 0x0101, 0x59FC, 0x25E0, 0xFF1E,
0x00AE, 0x5896, 0x27A9, 0xFF10, 0x0063, 0x5720, 0x297A, 0xFF02,
0x001F, 0x559D, 0x2B50, 0xFEF4, 0xFFE2, 0x540D, 0x2D2C, 0xFEE8,
0xFFAC, 0x5270, 0x2F0D, 0xFEDB, 0xFF7C, 0x50C7, 0x30F3, 0xFED0,
0xFF53, 0x4F14, 0x32DC, 0xFEC6, 0xFF2E, 0x4D57, 0x34C8, 0xFEBD,
0xFF0F, 0x4B91, 0x36B6, 0xFEB6, 0xFEF5, 0x49C2, 0x38A5, 0xFEB0,
0xFEDF, 0x47ED, 0x3A95, 0xFEAC, 0xFECE, 0x4611, 0x3C85, 0xFEAB,
0xFEC0, 0x4430, 0x3E74, 0xFEAC, 0xFEB6, 0x424A, 0x4060, 0xFEAF,
0xFEAF, 0x4060, 0x424A, 0xFEB6, 0xFEAC, 0x3E74, 0x4430, 0xFEC0,
0xFEAB, 0x3C85, 0x4611, 0xFECE, 0xFEAC, 0x3A95, 0x47ED, 0xFEDF,
0xFEB0, 0x38A5, 0x49C2, 0xFEF5, 0xFEB6, 0x36B6, 0x4B91, 0xFF0F,
0xFEBD, 0x34C8, 0x4D57, 0xFF2E, 0xFEC6, 0x32DC, 0x4F14, 0xFF53,
0xFED0, 0x30F3, 0x50C7, 0xFF7C, 0xFEDB, 0x2F0D, 0x5270, 0xFFAC,
0xFEE8, 0x2D2C, 0x540D, 0xFFE2, 0xFEF4, 0x2B50, 0x559D, 0x001F,
0xFF02, 0x297A, 0x5720, 0x0063, 0xFF10, 0x27A9, 0x5896, 0x00AE,
0xFF1E, 0x25E0, 0x59FC, 0x0101, 0xFF2C, 0x241E, 0x5B53, 0x015B,
0xFF3A, 0x2264, 0x5C9A, 0x01BE, 0xFF48, 0x20B3, 0x5DD0, 0x022A,
0xFF56, 0x1F0B, 0x5EF5, 0x029F, 0xFF64, 0x1D6C, 0x6007, 0x031C,
0xFF71, 0x1BD7, 0x6106, 0x03A4, 0xFF7E, 0x1A4C, 0x61F3, 0x0435,
0xFF8A, 0x18CB, 0x62CB, 0x04D1, 0xFF96, 0x1756, 0x638F, 0x0577,
0xFFA1, 0x15EB, 0x643F, 0x0628, 0xFFAC, 0x148C, 0x64D9, 0x06E4,
0xFFB6, 0x1338, 0x655E, 0x07AB, 0xFFBF, 0x11F0, 0x65CD, 0x087D,
0xFFC8, 0x10B4, 0x6626, 0x095A, 0xFFD0, 0x0F83, 0x6669, 0x0A44,
0xFFD8, 0x0E5F, 0x6696, 0x0B39, 0xFFDF, 0x0D46, 0x66AD, 0x0C39
};
static void CLEARBUFF (void) {
u32 addr = (u32)(inst1 & 0xffff);
u32 count = (u32)(inst2 & 0xffff);
addr &= 0xFFFC;
memset(BufferSpace+addr, 0, (count+3)&0xFFFC);
}
//FILE *dfile = fopen ("d:\\envmix.txt", "wt");
static void ENVMIXER (void) {
//static int envmixcnt = 0;
u8 flags = (u8)((inst1 >> 16) & 0xff);
u32 addy = (inst2 & 0xFFFFFF);// + SEGMENTS[(inst2>>24)&0xf];
//static
// ********* Make sure these conditions are met... ***********
/*if ((AudioInBuffer | AudioOutBuffer | AudioAuxA | AudioAuxC | AudioAuxE | AudioCount) & 0x3) {
MessageBox (NULL, "Unaligned EnvMixer... please report this to Azimer with the following information: RomTitle, Place in the rom it occurred, and any save state just before the error", "AudioHLE Error", MB_OK);
}*/
// ------------------------------------------------------------
short *inp=(short *)(BufferSpace+AudioInBuffer);
short *out=(short *)(BufferSpace+AudioOutBuffer);
short *aux1=(short *)(BufferSpace+AudioAuxA);
short *aux2=(short *)(BufferSpace+AudioAuxC);
short *aux3=(short *)(BufferSpace+AudioAuxE);
s32 MainR;
s32 MainL;
s32 AuxR;
s32 AuxL;
int i1,o1,a1,a2=0,a3=0;
unsigned short AuxIncRate=1;
short zero[8];
memset(zero,0,16);
s32 LVol, RVol;
s32 LAcc, RAcc;
s32 LTrg, RTrg;
s16 Wet, Dry;
u32 ptr = 0;
s32 RRamp, LRamp;
s32 LAdderStart, RAdderStart, LAdderEnd, RAdderEnd;
s32 oMainR, oMainL, oAuxR, oAuxL;
//envmixcnt++;
//fprintf (dfile, "\n----------------------------------------------------\n");
if (flags & A_INIT) {
LVol = ((Vol_Left * (s32)VolRamp_Left));
RVol = ((Vol_Right * (s32)VolRamp_Right));
Wet = (s16)Env_Wet; Dry = (s16)Env_Dry; // Save Wet/Dry values
LTrg = (VolTrg_Left << 16); RTrg = (VolTrg_Right << 16); // Save Current Left/Right Targets
LAdderStart = Vol_Left << 16;
RAdderStart = Vol_Right << 16;
LAdderEnd = LVol;
RAdderEnd = RVol;
RRamp = VolRamp_Right;
LRamp = VolRamp_Left;
} else {
// Load LVol, RVol, LAcc, and RAcc (all 32bit)
// Load Wet, Dry, LTrg, RTrg
memcpy((u8 *)hleMixerWorkArea, (rsp.RDRAM+addy), 80);
Wet = *(s16 *)(hleMixerWorkArea + 0); // 0-1
Dry = *(s16 *)(hleMixerWorkArea + 2); // 2-3
LTrg = *(s32 *)(hleMixerWorkArea + 4); // 4-5
RTrg = *(s32 *)(hleMixerWorkArea + 6); // 6-7
LRamp= *(s32 *)(hleMixerWorkArea + 8); // 8-9 (hleMixerWorkArea is a 16bit pointer)
RRamp= *(s32 *)(hleMixerWorkArea + 10); // 10-11
LAdderEnd = *(s32 *)(hleMixerWorkArea + 12); // 12-13
RAdderEnd = *(s32 *)(hleMixerWorkArea + 14); // 14-15
LAdderStart = *(s32 *)(hleMixerWorkArea + 16); // 12-13
RAdderStart = *(s32 *)(hleMixerWorkArea + 18); // 14-15
}
if(!(flags&A_AUX)) {
AuxIncRate=0;
aux2=aux3=zero;
}
oMainL = (Dry * (LTrg>>16) + 0x4000) >> 15;
oAuxL = (Wet * (LTrg>>16) + 0x4000) >> 15;
oMainR = (Dry * (RTrg>>16) + 0x4000) >> 15;
oAuxR = (Wet * (RTrg>>16) + 0x4000) >> 15;
for (int y = 0; y < AudioCount; y += 0x10) {
if (LAdderStart != LTrg) {
LAcc = LAdderStart;
LVol = (LAdderEnd - LAdderStart) >> 3;
LAdderEnd = (s32) (((s64)LAdderEnd * (s64)LRamp) >> 16);
LAdderStart = (s32) (((s64)LAcc * (s64)LRamp) >> 16);
} else {
LAcc = LTrg;
LVol = 0;
}
if (RAdderStart != RTrg) {
RAcc = RAdderStart;
RVol = (RAdderEnd - RAdderStart) >> 3;
RAdderEnd = (s32) (((s64)RAdderEnd * (s64)RRamp) >> 16);
RAdderStart = (s32) (((s64)RAcc * (s64)RRamp) >> 16);
} else {
RAcc = RTrg;
RVol = 0;
}
for (int x = 0; x < 8; x++) {
i1=(int)inp[ptr^S];
o1=(int)out[ptr^S];
a1=(int)aux1[ptr^S];
if (AuxIncRate) {
a2=(int)aux2[ptr^S];
a3=(int)aux3[ptr^S];
}
// TODO: here...
//LAcc = LTrg;
//RAcc = RTrg;
LAcc += LVol;
RAcc += RVol;
if (LVol <= 0) { // Decrementing
if (LAcc < LTrg) {
LAcc = LTrg;
LAdderStart = LTrg;
MainL = oMainL;
AuxL = oAuxL;
} else {
MainL = (Dry * ((s32)LAcc>>16) + 0x4000) >> 15;
AuxL = (Wet * ((s32)LAcc>>16) + 0x4000) >> 15;
}
} else {
if (LAcc > LTrg) {
LAcc = LTrg;
LAdderStart = LTrg;
MainL = oMainL;
AuxL = oAuxL;
} else {
MainL = (Dry * ((s32)LAcc>>16) + 0x4000) >> 15;
AuxL = (Wet * ((s32)LAcc>>16) + 0x4000) >> 15;
}
}
if (RVol <= 0) { // Decrementing
if (RAcc < RTrg) {
RAcc = RTrg;
RAdderStart = RTrg;
MainR = oMainR;
AuxR = oAuxR;
} else {
MainR = (Dry * ((s32)RAcc>>16) + 0x4000) >> 15;
AuxR = (Wet * ((s32)RAcc>>16) + 0x4000) >> 15;
}
} else {
if (RAcc > RTrg) {
RAcc = RTrg;
RAdderStart = RTrg;
MainR = oMainR;
AuxR = oAuxR;
} else {
MainR = (Dry * ((s32)RAcc>>16) + 0x4000) >> 15;
AuxR = (Wet * ((s32)RAcc>>16) + 0x4000) >> 15;
}
}
//fprintf (dfile, "%04X ", (LAcc>>16));
/*MainL = (((s64)Dry*2 * (s64)(LAcc>>16)) + 0x8000) >> 16;
MainR = (((s64)Dry*2 * (s64)(RAcc>>16)) + 0x8000) >> 16;
AuxL = (((s64)Wet*2 * (s64)(LAcc>>16)) + 0x8000) >> 16;
AuxR = (((s64)Wet*2 * (s64)(RAcc>>16)) + 0x8000) >> 16;*/
/*
if (MainL>32767) MainL = 32767;
else if (MainL<-32768) MainL = -32768;
if (MainR>32767) MainR = 32767;
else if (MainR<-32768) MainR = -32768;
if (AuxL>32767) AuxL = 32767;
else if (AuxL<-32768) AuxR = -32768;
if (AuxR>32767) AuxR = 32767;
else if (AuxR<-32768) AuxR = -32768;*/
/*
MainR = (Dry * RTrg + 0x10000) >> 15;
MainL = (Dry * LTrg + 0x10000) >> 15;
AuxR = (Wet * RTrg + 0x8000) >> 16;
AuxL = (Wet * LTrg + 0x8000) >> 16;*/
o1+=(/*(o1*0x7fff)+*/(i1*MainR)+0x4000)>>15;
a1+=(/*(a1*0x7fff)+*/(i1*MainL)+0x4000)>>15;
/* o1=((s64)(((s64)o1*0xfffe)+((s64)i1*MainR*2)+0x8000)>>16);
a1=((s64)(((s64)a1*0xfffe)+((s64)i1*MainL*2)+0x8000)>>16);*/
if(o1>32767) o1=32767;
else if(o1<-32768) o1=-32768;
if(a1>32767) a1=32767;
else if(a1<-32768) a1=-32768;
out[ptr^S]=o1;
aux1[ptr^S]=a1;
if (AuxIncRate) {
//a2=((s64)(((s64)a2*0xfffe)+((s64)i1*AuxR*2)+0x8000)>>16);
//a3=((s64)(((s64)a3*0xfffe)+((s64)i1*AuxL*2)+0x8000)>>16);
a2+=(/*(a2*0x7fff)+*/(i1*AuxR)+0x4000)>>15;
a3+=(/*(a3*0x7fff)+*/(i1*AuxL)+0x4000)>>15;
if(a2>32767) a2=32767;
else if(a2<-32768) a2=-32768;
if(a3>32767) a3=32767;
else if(a3<-32768) a3=-32768;
aux2[ptr^S]=a2;
aux3[ptr^S]=a3;
}
ptr++;
}
}
/*LAcc = LAdderEnd;
RAcc = RAdderEnd;*/
*(s16 *)(hleMixerWorkArea + 0) = Wet; // 0-1
*(s16 *)(hleMixerWorkArea + 2) = Dry; // 2-3
*(s32 *)(hleMixerWorkArea + 4) = LTrg; // 4-5
*(s32 *)(hleMixerWorkArea + 6) = RTrg; // 6-7
*(s32 *)(hleMixerWorkArea + 8) = LRamp; // 8-9 (hleMixerWorkArea is a 16bit pointer)
*(s32 *)(hleMixerWorkArea + 10) = RRamp; // 10-11
*(s32 *)(hleMixerWorkArea + 12) = LAdderEnd; // 12-13
*(s32 *)(hleMixerWorkArea + 14) = RAdderEnd; // 14-15
*(s32 *)(hleMixerWorkArea + 16) = LAdderStart; // 12-13
*(s32 *)(hleMixerWorkArea + 18) = RAdderStart; // 14-15
memcpy(rsp.RDRAM+addy, (u8 *)hleMixerWorkArea,80);
}
static void RESAMPLE (void) {
unsigned char Flags=(u8)((inst1>>16)&0xff);
unsigned int Pitch=((inst1&0xffff))<<1;
u32 addy = (inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
unsigned int Accum=0;
unsigned int location;
s16 *lut/*, *lut2*/;
short *dst;
s16 *src;
dst=(short *)(BufferSpace);
src=(s16 *)(BufferSpace);
u32 srcPtr=(AudioInBuffer/2);
u32 dstPtr=(AudioOutBuffer/2);
s32 temp;
s32 accum;
/*
if (addy > (1024*1024*8))
addy = (inst2 & 0xffffff);
*/
srcPtr -= 4;
if ((Flags & 0x1) == 0) {
//memcpy (src+srcPtr, rsp.RDRAM+addy, 0x8);
for (int x=0; x < 4; x++)
src[(srcPtr+x)^S] = ((u16 *)rsp.RDRAM)[((addy/2)+x)^S];
Accum = *(u16 *)(rsp.RDRAM+addy+10);
} else {
for (int x=0; x < 4; x++)
src[(srcPtr+x)^S] = 0;//*(u16 *)(rsp.RDRAM+((addy+x)^2));
}
for(int i=0;i < ((AudioCount+0xf)&0xFFF0)/2;i++) {
//location = (((Accum * 0x40) >> 0x10) * 8);
// location is the fractional position between two samples
location = (Accum >> 0xa) * 4;
lut = (s16*)ResampleLUT + location;
// mov eax, dword ptr [src+srcPtr];
// movsx edx, word ptr [lut];
// shl edx, 1
// imul edx
// test eax, 08000h
// setz ecx
// shl ecx, 16
// xor eax, 08000h
// add eax, ecx
// and edx, 0f000h
// imul
temp = ((s32)*(s16*)(src+((srcPtr+0)^S))*((s32)((s16)lut[0])));
accum = (s32)(temp >> 15);
temp = ((s32)*(s16*)(src+((srcPtr+1)^S))*((s32)((s16)lut[1])));
accum += (s32)(temp >> 15);
temp = ((s32)*(s16*)(src+((srcPtr+2)^S))*((s32)((s16)lut[2])));
accum += (s32)(temp >> 15);
temp = ((s32)*(s16*)(src+((srcPtr+3)^S))*((s32)((s16)lut[3])));
accum += (s32)(temp >> 15);
if (accum > 32767) accum = 32767;
if (accum < -32768) accum = -32768;
dst[dstPtr^S] = (accum);
dstPtr++;
Accum += Pitch;
srcPtr += (Accum>>16);
Accum&=0xffff;
}
for (int x=0; x < 4; x++)
((u16 *)rsp.RDRAM)[((addy/2)+x)^S] = src[(srcPtr+x)^S];
//memcpy (RSWORK, src+srcPtr, 0x8);
*(u16 *)(rsp.RDRAM+addy+10) = Accum;
}
static void SETVOL (void) {
// Might be better to unpack these depending on the flags...
u8 flags = (u8)((inst1 >> 16) & 0xff);
u16 vol = (s16)(inst1 & 0xffff);
//u16 voltarg =(u16)((inst2 >> 16)&0xffff);
u16 volrate = (u16)((inst2 & 0xffff));
if (flags & A_AUX) {
Env_Dry = (s16)vol; // m_MainVol
Env_Wet = (s16)volrate; // m_AuxVol
return;
}
if(flags & A_VOL) { // Set the Source(start) Volumes
if(flags & A_LEFT) {
Vol_Left = (s16)vol; // m_LeftVolume
} else { // A_RIGHT
Vol_Right = (s16)vol; // m_RightVolume
}
return;
}
//0x370 Loop Value (shared location)
//0x370 Target Volume (Left)
//u16 VolRamp_Left; // 0x0012(T8)
if(flags & A_LEFT) { // Set the Ramping values Target, Ramp
//loopval = (((u32)vol << 0x10) | (u32)voltarg);
VolTrg_Left = (s16)inst1; // m_LeftVol
//VolRamp_Left = (s32)inst2;
VolRamp_Left = (s32)inst2;//(u16)(inst2) | (s32)(s16)(inst2 << 0x10);
//fprintf (dfile, "Ramp Left: %f\n", (float)VolRamp_Left/65536.0);
//fprintf (dfile, "Ramp Left: %08X\n", inst2);
//VolRamp_Left = (s16)voltarg; // m_LeftVolTarget
//VolRate_Left = (s16)volrate; // m_LeftVolRate
} else { // A_RIGHT
VolTrg_Right = (s16)inst1; // m_RightVol
//VolRamp_Right = (s32)inst2;
VolRamp_Right = (s32)inst2;//(u16)(inst2 >> 0x10) | (s32)(s16)(inst2 << 0x10);
//fprintf (dfile, "Ramp Right: %f\n", (float)VolRamp_Right/65536.0);
//fprintf (dfile, "Ramp Right: %08X\n", inst2);
//VolRamp_Right = (s16)voltarg; // m_RightVolTarget
//VolRate_Right = (s16)volrate; // m_RightVolRate
}
}
static void UNKNOWN (void) {}
static void SETLOOP (void) {
loopval = (inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
//VolTrg_Left = (s16)(loopval>>16); // m_LeftVol
//VolRamp_Left = (s16)(loopval); // m_LeftVolTarget
}
static void ADPCM (void) { // Work in progress! :)
unsigned char Flags=(u8)(inst1>>16)&0xff;
//unsigned short Gain=(u16)(inst1&0xffff);
unsigned int Address=(inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
unsigned short inPtr=0;
//short *out=(s16 *)(testbuff+(AudioOutBuffer>>2));
short *out=(short *)(BufferSpace+AudioOutBuffer);
//unsigned char *in=(unsigned char *)(BufferSpace+AudioInBuffer);
short count=(short)AudioCount;
unsigned char icode;
unsigned char code;
int vscale;
unsigned short index;
unsigned short j;
int a[8];
short *book1,*book2;
/*
if (Address > (1024*1024*8))
Address = (inst2 & 0xffffff);
*/
memset(out,0,32);
if(!(Flags&0x1))
{
if(Flags&0x2) {
memcpy(out,&rsp.RDRAM[loopval&MEMMASK],32);
} else {
memcpy(out,&rsp.RDRAM[Address],32);
}
}
int l1=out[14^S];
int l2=out[15^S];
int inp1[8];
int inp2[8];
out+=16;
while(count>0)
{
// the first interation through, these values are
// either 0 in the case of A_INIT, from a special
// area of memory in the case of A_LOOP or just
// the values we calculated the last time
code=BufferSpace[(AudioInBuffer+inPtr)^S8];
index=code&0xf;
index<<=4; // index into the adpcm code table
book1=(short *)&adpcmtable[index];
book2=book1+8;
code>>=4; // upper nibble is scale
vscale=(0x8000>>((12-code)-1)); // very strange. 0x8000 would be .5 in 16:16 format
// so this appears to be a fractional scale based
// on the 12 based inverse of the scale value. note
// that this could be negative, in which case we do
// not use the calculated vscale value... see the
// if(code>12) check below
inPtr++; // coded adpcm data lies next
j=0;
while(j<8) // loop of 8, for 8 coded nibbles from 4 bytes
// which yields 8 short pcm values
{
icode=BufferSpace[(AudioInBuffer+inPtr)^S8];
inPtr++;
inp1[j]=(s16)((icode&0xf0)<<8); // this will in effect be signed
if(code<12)
inp1[j]=((int)((int)inp1[j]*(int)vscale)>>16);
/*else
int catchme=1;*/
j++;
inp1[j]=(s16)((icode&0xf)<<12);
if(code<12)
inp1[j]=((int)((int)inp1[j]*(int)vscale)>>16);
/*else
int catchme=1;*/
j++;
}
j=0;
while(j<8)
{
icode=BufferSpace[(AudioInBuffer+inPtr)^S8];
inPtr++;
inp2[j]=(short)((icode&0xf0)<<8); // this will in effect be signed
if(code<12)
inp2[j]=((int)((int)inp2[j]*(int)vscale)>>16);
/*else
int catchme=1;*/
j++;
inp2[j]=(short)((icode&0xf)<<12);
if(code<12)
inp2[j]=((int)((int)inp2[j]*(int)vscale)>>16);
/*else
int catchme=1;*/
j++;
}
a[0]= (int)book1[0]*(int)l1;
a[0]+=(int)book2[0]*(int)l2;
a[0]+=(int)inp1[0]*(int)2048;
a[1] =(int)book1[1]*(int)l1;
a[1]+=(int)book2[1]*(int)l2;
a[1]+=(int)book2[0]*inp1[0];
a[1]+=(int)inp1[1]*(int)2048;
a[2] =(int)book1[2]*(int)l1;
a[2]+=(int)book2[2]*(int)l2;
a[2]+=(int)book2[1]*inp1[0];
a[2]+=(int)book2[0]*inp1[1];
a[2]+=(int)inp1[2]*(int)2048;
a[3] =(int)book1[3]*(int)l1;
a[3]+=(int)book2[3]*(int)l2;
a[3]+=(int)book2[2]*inp1[0];
a[3]+=(int)book2[1]*inp1[1];
a[3]+=(int)book2[0]*inp1[2];
a[3]+=(int)inp1[3]*(int)2048;
a[4] =(int)book1[4]*(int)l1;
a[4]+=(int)book2[4]*(int)l2;
a[4]+=(int)book2[3]*inp1[0];
a[4]+=(int)book2[2]*inp1[1];
a[4]+=(int)book2[1]*inp1[2];
a[4]+=(int)book2[0]*inp1[3];
a[4]+=(int)inp1[4]*(int)2048;
a[5] =(int)book1[5]*(int)l1;
a[5]+=(int)book2[5]*(int)l2;
a[5]+=(int)book2[4]*inp1[0];
a[5]+=(int)book2[3]*inp1[1];
a[5]+=(int)book2[2]*inp1[2];
a[5]+=(int)book2[1]*inp1[3];
a[5]+=(int)book2[0]*inp1[4];
a[5]+=(int)inp1[5]*(int)2048;
a[6] =(int)book1[6]*(int)l1;
a[6]+=(int)book2[6]*(int)l2;
a[6]+=(int)book2[5]*inp1[0];
a[6]+=(int)book2[4]*inp1[1];
a[6]+=(int)book2[3]*inp1[2];
a[6]+=(int)book2[2]*inp1[3];
a[6]+=(int)book2[1]*inp1[4];
a[6]+=(int)book2[0]*inp1[5];
a[6]+=(int)inp1[6]*(int)2048;
a[7] =(int)book1[7]*(int)l1;
a[7]+=(int)book2[7]*(int)l2;
a[7]+=(int)book2[6]*inp1[0];
a[7]+=(int)book2[5]*inp1[1];
a[7]+=(int)book2[4]*inp1[2];
a[7]+=(int)book2[3]*inp1[3];
a[7]+=(int)book2[2]*inp1[4];
a[7]+=(int)book2[1]*inp1[5];
a[7]+=(int)book2[0]*inp1[6];
a[7]+=(int)inp1[7]*(int)2048;
for(j=0;j<8;j++)
{
a[j^S]>>=11;
if(a[j^S]>32767) a[j^S]=32767;
else if(a[j^S]<-32768) a[j^S]=-32768;
*(out++)=a[j^S];
}
l1=a[6];
l2=a[7];
a[0]= (int)book1[0]*(int)l1;
a[0]+=(int)book2[0]*(int)l2;
a[0]+=(int)inp2[0]*(int)2048;
a[1] =(int)book1[1]*(int)l1;
a[1]+=(int)book2[1]*(int)l2;
a[1]+=(int)book2[0]*inp2[0];
a[1]+=(int)inp2[1]*(int)2048;
a[2] =(int)book1[2]*(int)l1;
a[2]+=(int)book2[2]*(int)l2;
a[2]+=(int)book2[1]*inp2[0];
a[2]+=(int)book2[0]*inp2[1];
a[2]+=(int)inp2[2]*(int)2048;
a[3] =(int)book1[3]*(int)l1;
a[3]+=(int)book2[3]*(int)l2;
a[3]+=(int)book2[2]*inp2[0];
a[3]+=(int)book2[1]*inp2[1];
a[3]+=(int)book2[0]*inp2[2];
a[3]+=(int)inp2[3]*(int)2048;
a[4] =(int)book1[4]*(int)l1;
a[4]+=(int)book2[4]*(int)l2;
a[4]+=(int)book2[3]*inp2[0];
a[4]+=(int)book2[2]*inp2[1];
a[4]+=(int)book2[1]*inp2[2];
a[4]+=(int)book2[0]*inp2[3];
a[4]+=(int)inp2[4]*(int)2048;
a[5] =(int)book1[5]*(int)l1;
a[5]+=(int)book2[5]*(int)l2;
a[5]+=(int)book2[4]*inp2[0];
a[5]+=(int)book2[3]*inp2[1];
a[5]+=(int)book2[2]*inp2[2];
a[5]+=(int)book2[1]*inp2[3];
a[5]+=(int)book2[0]*inp2[4];
a[5]+=(int)inp2[5]*(int)2048;
a[6] =(int)book1[6]*(int)l1;
a[6]+=(int)book2[6]*(int)l2;
a[6]+=(int)book2[5]*inp2[0];
a[6]+=(int)book2[4]*inp2[1];
a[6]+=(int)book2[3]*inp2[2];
a[6]+=(int)book2[2]*inp2[3];
a[6]+=(int)book2[1]*inp2[4];
a[6]+=(int)book2[0]*inp2[5];
a[6]+=(int)inp2[6]*(int)2048;
a[7] =(int)book1[7]*(int)l1;
a[7]+=(int)book2[7]*(int)l2;
a[7]+=(int)book2[6]*inp2[0];
a[7]+=(int)book2[5]*inp2[1];
a[7]+=(int)book2[4]*inp2[2];
a[7]+=(int)book2[3]*inp2[3];
a[7]+=(int)book2[2]*inp2[4];
a[7]+=(int)book2[1]*inp2[5];
a[7]+=(int)book2[0]*inp2[6];
a[7]+=(int)inp2[7]*(int)2048;
for(j=0;j<8;j++)
{
a[j^S]>>=11;
if(a[j^S]>32767) a[j^S]=32767;
else if(a[j^S]<-32768) a[j^S]=-32768;
*(out++)=a[j^S];
}
l1=a[6];
l2=a[7];
count-=32;
}
out-=16;
memcpy(&rsp.RDRAM[Address],out,32);
}
static void LOADBUFF (void) { // memcpy causes static... endianess issue :(
u32 v0;
//u32 cnt;
if (AudioCount == 0)
return;
v0 = (inst2 & 0xfffffc);// + SEGMENTS[(inst2>>24)&0xf];
memcpy (BufferSpace+(AudioInBuffer&0xFFFC), rsp.RDRAM+v0, (AudioCount+3)&0xFFFC);
}
static void SAVEBUFF (void) { // memcpy causes static... endianess issue :(
u32 v0;
//u32 cnt;
if (AudioCount == 0)
return;
v0 = (inst2 & 0xfffffc);// + SEGMENTS[(inst2>>24)&0xf];
memcpy (rsp.RDRAM+v0, BufferSpace+(AudioOutBuffer&0xFFFC), (AudioCount+3)&0xFFFC);
}
static void SETBUFF (void) { // Should work ;-)
if ((inst1 >> 0x10) & 0x8) { // A_AUX - Auxillary Sound Buffer Settings
AudioAuxA = u16(inst1);
AudioAuxC = u16((inst2 >> 0x10));
AudioAuxE = u16(inst2);
} else { // A_MAIN - Main Sound Buffer Settings
AudioInBuffer = u16(inst1); // 0x00
AudioOutBuffer = u16((inst2 >> 0x10)); // 0x02
AudioCount = u16(inst2); // 0x04
}
}
static void DMEMMOVE (void) { // Doesn't sound just right?... will fix when HLE is ready - 03-11-01
u32 v0, v1;
u32 cnt;
if ((inst2 & 0xffff)==0)
return;
v0 = (inst1 & 0xFFFF);
v1 = (inst2 >> 0x10);
//assert ((v1 & 0x3) == 0);
//assert ((v0 & 0x3) == 0);
u32 count = ((inst2+3) & 0xfffc);
//v0 = (v0) & 0xfffc;
//v1 = (v1) & 0xfffc;
//memcpy (BufferSpace+v1, BufferSpace+v0, count-1);
for (cnt = 0; cnt < count; cnt++) {
*(u8 *)(BufferSpace+((cnt+v1)^S8)) = *(u8 *)(BufferSpace+((cnt+v0)^S8));
}
}
static void LOADADPCM (void) { // Loads an ADPCM table - Works 100% Now 03-13-01
u32 v0;
v0 = (inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
/* if (v0 > (1024*1024*8))
v0 = (inst2 & 0xffffff);*/
//memcpy (dmem+0x4c0, rsp.RDRAM+v0, inst1&0xffff); // Could prolly get away with not putting this in dmem
//assert ((inst1&0xffff) <= 0x80);
u16 *table = (u16 *)(rsp.RDRAM+v0);
for (u32 x = 0; x < ((inst1&0xffff)>>0x4); x++) {
adpcmtable[0x0+(x<<3)^S] = table[0];
adpcmtable[0x1+(x<<3)^S] = table[1];
adpcmtable[0x2+(x<<3)^S] = table[2];
adpcmtable[0x3+(x<<3)^S] = table[3];
adpcmtable[0x4+(x<<3)^S] = table[4];
adpcmtable[0x5+(x<<3)^S] = table[5];
adpcmtable[0x6+(x<<3)^S] = table[6];
adpcmtable[0x7+(x<<3)^S] = table[7];
table += 8;
}
}
static void INTERLEAVE (void) { // Works... - 3-11-01
u32 inL, inR;
u16 *outbuff = (u16 *)(AudioOutBuffer+BufferSpace);
u16 *inSrcR;
u16 *inSrcL;
u16 Left, Right, Left2, Right2;
inL = inst2 & 0xFFFF;
inR = (inst2 >> 16) & 0xFFFF;
inSrcR = (u16 *)(BufferSpace+inR);
inSrcL = (u16 *)(BufferSpace+inL);
for (int x = 0; x < (AudioCount/4); x++) {
Left=*(inSrcL++);
Right=*(inSrcR++);
Left2=*(inSrcL++);
Right2=*(inSrcR++);
#ifdef _BIG_ENDIAN
*(outbuff++)=Right;
*(outbuff++)=Left;
*(outbuff++)=Right2;
*(outbuff++)=Left2;
#else
*(outbuff++)=Right2;
*(outbuff++)=Left2;
*(outbuff++)=Right;
*(outbuff++)=Left;
#endif
}
}
static void MIXER (void) { // Fixed a sign issue... 03-14-01
u32 dmemin = (u16)(inst2 >> 0x10);
u32 dmemout = (u16)(inst2 & 0xFFFF);
//u8 flags = (u8)((inst1 >> 16) & 0xff);
s32 gain = (s16)(inst1 & 0xFFFF);
s32 temp;
if (AudioCount == 0)
return;
for (int x=0; x < AudioCount; x+=2) { // I think I can do this a lot easier
temp = (*(s16 *)(BufferSpace+dmemin+x) * gain) >> 15;
temp += *(s16 *)(BufferSpace+dmemout+x);
if ((s32)temp > 32767)
temp = 32767;
if ((s32)temp < -32768)
temp = -32768;
*(u16 *)(BufferSpace+dmemout+x) = (u16)(temp & 0xFFFF);
}
}
// TOP Performance Hogs:
//Command: ADPCM - Calls: 48 - Total Time: 331226 - Avg Time: 6900.54 - Percent: 31.53%
//Command: ENVMIXER - Calls: 48 - Total Time: 408563 - Avg Time: 8511.73 - Percent: 38.90%
//Command: LOADBUFF - Calls: 56 - Total Time: 21551 - Avg Time: 384.84 - Percent: 2.05%
//Command: RESAMPLE - Calls: 48 - Total Time: 225922 - Avg Time: 4706.71 - Percent: 21.51%
//Command: ADPCM - Calls: 48 - Total Time: 391600 - Avg Time: 8158.33 - Percent: 32.52%
//Command: ENVMIXER - Calls: 48 - Total Time: 444091 - Avg Time: 9251.90 - Percent: 36.88%
//Command: LOADBUFF - Calls: 58 - Total Time: 29945 - Avg Time: 516.29 - Percent: 2.49%
//Command: RESAMPLE - Calls: 48 - Total Time: 276354 - Avg Time: 5757.38 - Percent: 22.95%
void (*ABI1[0x20])(void) = { // TOP Performace Hogs: MIXER, RESAMPLE, ENVMIXER
SPNOOP , ADPCM , CLEARBUFF, ENVMIXER , LOADBUFF, RESAMPLE , SAVEBUFF, UNKNOWN,
SETBUFF, SETVOL, DMEMMOVE , LOADADPCM , MIXER , INTERLEAVE, UNKNOWN , SETLOOP,
SPNOOP , SPNOOP, SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP,
SPNOOP , SPNOOP, SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP
};
/* BACKUPS
void MIXER (void) { // Fixed a sign issue... 03-14-01
u16 dmemin = (u16)(inst2 >> 0x10);
u16 dmemout = (u16)(inst2 & 0xFFFF);
u16 gain = (u16)(inst1 & 0xFFFF);
u8 flags = (u8)((inst1 >> 16) & 0xff);
u64 temp;
if (AudioCount == 0)
return;
for (int x=0; x < AudioCount; x+=2) { // I think I can do this a lot easier
temp = (s64)(*(s16 *)(BufferSpace+dmemout+x)) * (s64)((s16)(0x7FFF)*2);
if (temp & 0x8000)
temp = (temp^0x8000) + 0x10000;
else
temp = (temp^0x8000);
temp = (temp & 0xFFFFFFFFFFFF);
temp += ((*(s16 *)(BufferSpace+dmemin+x) * (s64)((s16)gain*2))) & 0xFFFFFFFFFFFF;
temp = (s32)(temp >> 16);
if ((s32)temp > 32767)
temp = 32767;
if ((s32)temp < -32768)
temp = -32768;
*(u16 *)(BufferSpace+dmemout+x) = (u16)(temp & 0xFFFF);
}
}
*/

View file

@ -1,934 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - ucode2.cpp *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <string.h>
# include <stdio.h>
extern "C" {
#include "m64p_types.h"
#include "hle.h"
}
extern "C" void (*ABI2[])(void);
extern u8 BufferSpace[0x10000];
static void SPNOOP (void) {
DebugMessage(M64MSG_ERROR, "Unknown/Unimplemented Audio Command %i in ABI 2", (int)(inst1 >> 24));
}
extern u16 AudioInBuffer; // 0x0000(T8)
extern u16 AudioOutBuffer; // 0x0002(T8)
extern u16 AudioCount; // 0x0004(T8)
extern u32 loopval; // 0x0010(T8)
extern u32 SEGMENTS[0x10];
extern u16 adpcmtable[0x88];
extern u16 ResampleLUT [0x200];
bool isMKABI = false;
bool isZeldaABI = false;
void init_ucode2() { isMKABI = isZeldaABI = false; }
static void LOADADPCM2 (void) { // Loads an ADPCM table - Works 100% Now 03-13-01
u32 v0;
v0 = (inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
u16 *table = (u16 *)(rsp.RDRAM+v0); // Zelda2 Specific...
for (u32 x = 0; x < ((inst1&0xffff)>>0x4); x++) {
adpcmtable[0x0+(x<<3)^S] = table[0];
adpcmtable[0x1+(x<<3)^S] = table[1];
adpcmtable[0x2+(x<<3)^S] = table[2];
adpcmtable[0x3+(x<<3)^S] = table[3];
adpcmtable[0x4+(x<<3)^S] = table[4];
adpcmtable[0x5+(x<<3)^S] = table[5];
adpcmtable[0x6+(x<<3)^S] = table[6];
adpcmtable[0x7+(x<<3)^S] = table[7];
table += 8;
}
}
static void SETLOOP2 (void) {
loopval = inst2 & 0xffffff; // No segment?
}
static void SETBUFF2 (void) {
AudioInBuffer = u16(inst1); // 0x00
AudioOutBuffer = u16((inst2 >> 0x10)); // 0x02
AudioCount = u16(inst2); // 0x04
}
static void ADPCM2 (void) { // Verified to be 100% Accurate...
unsigned char Flags=(u8)(inst1>>16)&0xff;
//unsigned short Gain=(u16)(inst1&0xffff);
unsigned int Address=(inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
unsigned short inPtr=0;
//short *out=(s16 *)(testbuff+(AudioOutBuffer>>2));
short *out=(short *)(BufferSpace+AudioOutBuffer);
//unsigned char *in=(unsigned char *)(BufferSpace+AudioInBuffer);
short count=(short)AudioCount;
unsigned char icode;
unsigned char code;
int vscale;
unsigned short index;
unsigned short j;
int a[8];
short *book1,*book2;
u8 srange;
u8 inpinc;
u8 mask1;
u8 mask2;
u8 shifter;
memset(out,0,32);
if (Flags & 0x4) { // Tricky lil Zelda MM and ABI2!!! hahaha I know your secrets! :DDD
srange = 0xE;
inpinc = 0x5;
mask1 = 0xC0;
mask2 = 0x30;
shifter = 10;
} else {
srange = 0xC;
inpinc = 0x9;
mask1 = 0xf0;
mask2 = 0x0f;
shifter = 12;
}
if(!(Flags&0x1))
{
if(Flags&0x2)
{/*
for(int i=0;i<16;i++)
{
out[i]=*(short *)&rsp.RDRAM[(loopval+i*2)^2];
}*/
memcpy(out,&rsp.RDRAM[loopval],32);
}
else
{/*
for(int i=0;i<16;i++)
{
out[i]=*(short *)&rsp.RDRAM[(Address+i*2)^2];
}*/
memcpy(out,&rsp.RDRAM[Address],32);
}
}
int l1=out[14^S];
int l2=out[15^S];
int inp1[8];
int inp2[8];
out+=16;
while(count>0) {
code=BufferSpace[(AudioInBuffer+inPtr)^S8];
index=code&0xf;
index<<=4;
book1=(short *)&adpcmtable[index];
book2=book1+8;
code>>=4;
vscale=(0x8000>>((srange-code)-1));
inPtr++;
j=0;
while(j<8) {
icode=BufferSpace[(AudioInBuffer+inPtr)^S8];
inPtr++;
inp1[j]=(s16)((icode&mask1) << 8); // this will in effect be signed
if(code<srange) inp1[j]=((int)((int)inp1[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
inp1[j]=(s16)((icode&mask2)<<shifter);
if(code<srange) inp1[j]=((int)((int)inp1[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
if (Flags & 4) {
inp1[j]=(s16)((icode&0xC) << 12); // this will in effect be signed
if(code < 0xE) inp1[j]=((int)((int)inp1[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
inp1[j]=(s16)((icode&0x3) << 14);
if(code < 0xE) inp1[j]=((int)((int)inp1[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
} // end flags
} // end while
j=0;
while(j<8) {
icode=BufferSpace[(AudioInBuffer+inPtr)^S8];
inPtr++;
inp2[j]=(s16)((icode&mask1) << 8);
if(code<srange) inp2[j]=((int)((int)inp2[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
inp2[j]=(s16)((icode&mask2)<<shifter);
if(code<srange) inp2[j]=((int)((int)inp2[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
if (Flags & 4) {
inp2[j]=(s16)((icode&0xC) << 12);
if(code < 0xE) inp2[j]=((int)((int)inp2[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
inp2[j]=(s16)((icode&0x3) << 14);
if(code < 0xE) inp2[j]=((int)((int)inp2[j]*(int)vscale)>>16);
//else int catchme=1;
j++;
} // end flags
}
a[0]= (int)book1[0]*(int)l1;
a[0]+=(int)book2[0]*(int)l2;
a[0]+=(int)inp1[0]*(int)2048;
a[1] =(int)book1[1]*(int)l1;
a[1]+=(int)book2[1]*(int)l2;
a[1]+=(int)book2[0]*inp1[0];
a[1]+=(int)inp1[1]*(int)2048;
a[2] =(int)book1[2]*(int)l1;
a[2]+=(int)book2[2]*(int)l2;
a[2]+=(int)book2[1]*inp1[0];
a[2]+=(int)book2[0]*inp1[1];
a[2]+=(int)inp1[2]*(int)2048;
a[3] =(int)book1[3]*(int)l1;
a[3]+=(int)book2[3]*(int)l2;
a[3]+=(int)book2[2]*inp1[0];
a[3]+=(int)book2[1]*inp1[1];
a[3]+=(int)book2[0]*inp1[2];
a[3]+=(int)inp1[3]*(int)2048;
a[4] =(int)book1[4]*(int)l1;
a[4]+=(int)book2[4]*(int)l2;
a[4]+=(int)book2[3]*inp1[0];
a[4]+=(int)book2[2]*inp1[1];
a[4]+=(int)book2[1]*inp1[2];
a[4]+=(int)book2[0]*inp1[3];
a[4]+=(int)inp1[4]*(int)2048;
a[5] =(int)book1[5]*(int)l1;
a[5]+=(int)book2[5]*(int)l2;
a[5]+=(int)book2[4]*inp1[0];
a[5]+=(int)book2[3]*inp1[1];
a[5]+=(int)book2[2]*inp1[2];
a[5]+=(int)book2[1]*inp1[3];
a[5]+=(int)book2[0]*inp1[4];
a[5]+=(int)inp1[5]*(int)2048;
a[6] =(int)book1[6]*(int)l1;
a[6]+=(int)book2[6]*(int)l2;
a[6]+=(int)book2[5]*inp1[0];
a[6]+=(int)book2[4]*inp1[1];
a[6]+=(int)book2[3]*inp1[2];
a[6]+=(int)book2[2]*inp1[3];
a[6]+=(int)book2[1]*inp1[4];
a[6]+=(int)book2[0]*inp1[5];
a[6]+=(int)inp1[6]*(int)2048;
a[7] =(int)book1[7]*(int)l1;
a[7]+=(int)book2[7]*(int)l2;
a[7]+=(int)book2[6]*inp1[0];
a[7]+=(int)book2[5]*inp1[1];
a[7]+=(int)book2[4]*inp1[2];
a[7]+=(int)book2[3]*inp1[3];
a[7]+=(int)book2[2]*inp1[4];
a[7]+=(int)book2[1]*inp1[5];
a[7]+=(int)book2[0]*inp1[6];
a[7]+=(int)inp1[7]*(int)2048;
for(j=0;j<8;j++)
{
a[j^S]>>=11;
if(a[j^S]>32767) a[j^S]=32767;
else if(a[j^S]<-32768) a[j^S]=-32768;
*(out++)=a[j^S];
}
l1=a[6];
l2=a[7];
a[0]= (int)book1[0]*(int)l1;
a[0]+=(int)book2[0]*(int)l2;
a[0]+=(int)inp2[0]*(int)2048;
a[1] =(int)book1[1]*(int)l1;
a[1]+=(int)book2[1]*(int)l2;
a[1]+=(int)book2[0]*inp2[0];
a[1]+=(int)inp2[1]*(int)2048;
a[2] =(int)book1[2]*(int)l1;
a[2]+=(int)book2[2]*(int)l2;
a[2]+=(int)book2[1]*inp2[0];
a[2]+=(int)book2[0]*inp2[1];
a[2]+=(int)inp2[2]*(int)2048;
a[3] =(int)book1[3]*(int)l1;
a[3]+=(int)book2[3]*(int)l2;
a[3]+=(int)book2[2]*inp2[0];
a[3]+=(int)book2[1]*inp2[1];
a[3]+=(int)book2[0]*inp2[2];
a[3]+=(int)inp2[3]*(int)2048;
a[4] =(int)book1[4]*(int)l1;
a[4]+=(int)book2[4]*(int)l2;
a[4]+=(int)book2[3]*inp2[0];
a[4]+=(int)book2[2]*inp2[1];
a[4]+=(int)book2[1]*inp2[2];
a[4]+=(int)book2[0]*inp2[3];
a[4]+=(int)inp2[4]*(int)2048;
a[5] =(int)book1[5]*(int)l1;
a[5]+=(int)book2[5]*(int)l2;
a[5]+=(int)book2[4]*inp2[0];
a[5]+=(int)book2[3]*inp2[1];
a[5]+=(int)book2[2]*inp2[2];
a[5]+=(int)book2[1]*inp2[3];
a[5]+=(int)book2[0]*inp2[4];
a[5]+=(int)inp2[5]*(int)2048;
a[6] =(int)book1[6]*(int)l1;
a[6]+=(int)book2[6]*(int)l2;
a[6]+=(int)book2[5]*inp2[0];
a[6]+=(int)book2[4]*inp2[1];
a[6]+=(int)book2[3]*inp2[2];
a[6]+=(int)book2[2]*inp2[3];
a[6]+=(int)book2[1]*inp2[4];
a[6]+=(int)book2[0]*inp2[5];
a[6]+=(int)inp2[6]*(int)2048;
a[7] =(int)book1[7]*(int)l1;
a[7]+=(int)book2[7]*(int)l2;
a[7]+=(int)book2[6]*inp2[0];
a[7]+=(int)book2[5]*inp2[1];
a[7]+=(int)book2[4]*inp2[2];
a[7]+=(int)book2[3]*inp2[3];
a[7]+=(int)book2[2]*inp2[4];
a[7]+=(int)book2[1]*inp2[5];
a[7]+=(int)book2[0]*inp2[6];
a[7]+=(int)inp2[7]*(int)2048;
for(j=0;j<8;j++)
{
a[j^S]>>=11;
if(a[j^S]>32767) a[j^S]=32767;
else if(a[j^S]<-32768) a[j^S]=-32768;
*(out++)=a[j^S];
}
l1=a[6];
l2=a[7];
count-=32;
}
out-=16;
memcpy(&rsp.RDRAM[Address],out,32);
}
static void CLEARBUFF2 (void) {
u16 addr = (u16)(inst1 & 0xffff);
u16 count = (u16)(inst2 & 0xffff);
if (count > 0)
memset(BufferSpace+addr, 0, count);
}
static void LOADBUFF2 (void) { // Needs accuracy verification...
u32 v0;
u32 cnt = (((inst1 >> 0xC)+3)&0xFFC);
v0 = (inst2 & 0xfffffc);// + SEGMENTS[(inst2>>24)&0xf];
memcpy (BufferSpace+(inst1&0xfffc), rsp.RDRAM+v0, (cnt+3)&0xFFFC);
}
static void SAVEBUFF2 (void) { // Needs accuracy verification...
u32 v0;
u32 cnt = (((inst1 >> 0xC)+3)&0xFFC);
v0 = (inst2 & 0xfffffc);// + SEGMENTS[(inst2>>24)&0xf];
memcpy (rsp.RDRAM+v0, BufferSpace+(inst1&0xfffc), (cnt+3)&0xFFFC);
}
static void MIXER2 (void) { // Needs accuracy verification...
u16 dmemin = (u16)(inst2 >> 0x10);
u16 dmemout = (u16)(inst2 & 0xFFFF);
u32 count = ((inst1 >> 12) & 0xFF0);
s32 gain = (s16)(inst1 & 0xFFFF);
s32 temp;
for (unsigned int x=0; x < count; x+=2) { // I think I can do this a lot easier
temp = (*(s16 *)(BufferSpace+dmemin+x) * gain) >> 15;
temp += *(s16 *)(BufferSpace+dmemout+x);
if ((s32)temp > 32767)
temp = 32767;
if ((s32)temp < -32768)
temp = -32768;
*(u16 *)(BufferSpace+dmemout+x) = (u16)(temp & 0xFFFF);
}
}
static void RESAMPLE2 (void) {
unsigned char Flags=(u8)((inst1>>16)&0xff);
unsigned int Pitch=((inst1&0xffff))<<1;
u32 addy = (inst2 & 0xffffff);// + SEGMENTS[(inst2>>24)&0xf];
unsigned int Accum=0;
unsigned int location;
s16 *lut;
short *dst;
s16 *src;
dst=(short *)(BufferSpace);
src=(s16 *)(BufferSpace);
u32 srcPtr=(AudioInBuffer/2);
u32 dstPtr=(AudioOutBuffer/2);
s32 temp;
s32 accum;
if (addy > (1024*1024*8))
addy = (inst2 & 0xffffff);
srcPtr -= 4;
if ((Flags & 0x1) == 0) {
for (int x=0; x < 4; x++) //memcpy (src+srcPtr, rsp.RDRAM+addy, 0x8);
src[(srcPtr+x)^S] = ((u16 *)rsp.RDRAM)[((addy/2)+x)^S];
Accum = *(u16 *)(rsp.RDRAM+addy+10);
} else {
for (int x=0; x < 4; x++)
src[(srcPtr+x)^S] = 0;//*(u16 *)(rsp.RDRAM+((addy+x)^2));
}
for(int i=0;i < ((AudioCount+0xf)&0xFFF0)/2;i++) {
location = (((Accum * 0x40) >> 0x10) * 8);
//location = (Accum >> 0xa) << 0x3;
lut = (s16 *)(((u8 *)ResampleLUT) + location);
temp = ((s32)*(s16*)(src+((srcPtr+0)^S))*((s32)((s16)lut[0])));
accum = (s32)(temp >> 15);
temp = ((s32)*(s16*)(src+((srcPtr+1)^S))*((s32)((s16)lut[1])));
accum += (s32)(temp >> 15);
temp = ((s32)*(s16*)(src+((srcPtr+2)^S))*((s32)((s16)lut[2])));
accum += (s32)(temp >> 15);
temp = ((s32)*(s16*)(src+((srcPtr+3)^S))*((s32)((s16)lut[3])));
accum += (s32)(temp >> 15);
if (accum > 32767) accum = 32767;
if (accum < -32768) accum = -32768;
dst[dstPtr^S] = (s16)(accum);
dstPtr++;
Accum += Pitch;
srcPtr += (Accum>>16);
Accum&=0xffff;
}
for (int x=0; x < 4; x++)
((u16 *)rsp.RDRAM)[((addy/2)+x)^S] = src[(srcPtr+x)^S];
*(u16 *)(rsp.RDRAM+addy+10) = (u16)Accum;
//memcpy (RSWORK, src+srcPtr, 0x8);
}
static void DMEMMOVE2 (void) { // Needs accuracy verification...
u32 v0, v1;
u32 cnt;
if ((inst2 & 0xffff)==0)
return;
v0 = (inst1 & 0xFFFF);
v1 = (inst2 >> 0x10);
//assert ((v1 & 0x3) == 0);
//assert ((v0 & 0x3) == 0);
u32 count = ((inst2+3) & 0xfffc);
//v0 = (v0) & 0xfffc;
//v1 = (v1) & 0xfffc;
//memcpy (dmem+v1, dmem+v0, count-1);
for (cnt = 0; cnt < count; cnt++) {
*(u8 *)(BufferSpace+((cnt+v1)^S8)) = *(u8 *)(BufferSpace+((cnt+v0)^S8));
}
}
u32 t3, s5, s6;
u16 env[8];
static void ENVSETUP1 (void) {
u32 tmp;
//fprintf (dfile, "ENVSETUP1: inst1 = %08X, inst2 = %08X\n", inst1, inst2);
t3 = inst1 & 0xFFFF;
tmp = (inst1 >> 0x8) & 0xFF00;
env[4] = (u16)tmp;
tmp += t3;
env[5] = (u16)tmp;
s5 = inst2 >> 0x10;
s6 = inst2 & 0xFFFF;
//fprintf (dfile, " t3 = %X / s5 = %X / s6 = %X / env[4] = %X / env[5] = %X\n", t3, s5, s6, env[4], env[5]);
}
static void ENVSETUP2 (void) {
u32 tmp;
//fprintf (dfile, "ENVSETUP2: inst1 = %08X, inst2 = %08X\n", inst1, inst2);
tmp = (inst2 >> 0x10);
env[0] = (u16)tmp;
tmp += s5;
env[1] = (u16)tmp;
tmp = inst2 & 0xffff;
env[2] = (u16)tmp;
tmp += s6;
env[3] = (u16)tmp;
//fprintf (dfile, " env[0] = %X / env[1] = %X / env[2] = %X / env[3] = %X\n", env[0], env[1], env[2], env[3]);
}
static void ENVMIXER2 (void) {
//fprintf (dfile, "ENVMIXER: inst1 = %08X, inst2 = %08X\n", inst1, inst2);
s16 *bufft6, *bufft7, *buffs0, *buffs1;
s16 *buffs3;
s32 count;
u32 adder;
s16 vec9, vec10;
s16 v2[8];
buffs3 = (s16 *)(BufferSpace + ((inst1 >> 0x0c)&0x0ff0));
bufft6 = (s16 *)(BufferSpace + ((inst2 >> 0x14)&0x0ff0));
bufft7 = (s16 *)(BufferSpace + ((inst2 >> 0x0c)&0x0ff0));
buffs0 = (s16 *)(BufferSpace + ((inst2 >> 0x04)&0x0ff0));
buffs1 = (s16 *)(BufferSpace + ((inst2 << 0x04)&0x0ff0));
v2[0] = 0 - (s16)((inst1 & 0x2) >> 1);
v2[1] = 0 - (s16)((inst1 & 0x1));
v2[2] = 0 - (s16)((inst1 & 0x8) >> 1);
v2[3] = 0 - (s16)((inst1 & 0x4) >> 1);
count = (inst1 >> 8) & 0xff;
if (!isMKABI) {
s5 *= 2; s6 *= 2; t3 *= 2;
adder = 0x10;
} else {
inst1 = 0;
adder = 0x8;
t3 = 0;
}
while (count > 0) {
int temp, x;
for (x=0; x < 0x8; x++) {
vec9 = (s16)(((s32)buffs3[x^S] * (u32)env[0]) >> 0x10) ^ v2[0];
vec10 = (s16)(((s32)buffs3[x^S] * (u32)env[2]) >> 0x10) ^ v2[1];
temp = bufft6[x^S] + vec9;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
bufft6[x^S] = temp;
temp = bufft7[x^S] + vec10;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
bufft7[x^S] = temp;
vec9 = (s16)(((s32)vec9 * (u32)env[4]) >> 0x10) ^ v2[2];
vec10 = (s16)(((s32)vec10 * (u32)env[4]) >> 0x10) ^ v2[3];
if (inst1 & 0x10) {
temp = buffs0[x^S] + vec10;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs0[x^S] = temp;
temp = buffs1[x^S] + vec9;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs1[x^S] = temp;
} else {
temp = buffs0[x^S] + vec9;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs0[x^S] = temp;
temp = buffs1[x^S] + vec10;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs1[x^S] = temp;
}
}
if (!isMKABI)
for (x=0x8; x < 0x10; x++) {
vec9 = (s16)(((s32)buffs3[x^S] * (u32)env[1]) >> 0x10) ^ v2[0];
vec10 = (s16)(((s32)buffs3[x^S] * (u32)env[3]) >> 0x10) ^ v2[1];
temp = bufft6[x^S] + vec9;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
bufft6[x^S] = temp;
temp = bufft7[x^S] + vec10;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
bufft7[x^S] = temp;
vec9 = (s16)(((s32)vec9 * (u32)env[5]) >> 0x10) ^ v2[2];
vec10 = (s16)(((s32)vec10 * (u32)env[5]) >> 0x10) ^ v2[3];
if (inst1 & 0x10) {
temp = buffs0[x^S] + vec10;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs0[x^S] = temp;
temp = buffs1[x^S] + vec9;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs1[x^S] = temp;
} else {
temp = buffs0[x^S] + vec9;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs0[x^S] = temp;
temp = buffs1[x^S] + vec10;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
buffs1[x^S] = temp;
}
}
bufft6 += adder; bufft7 += adder;
buffs0 += adder; buffs1 += adder;
buffs3 += adder; count -= adder;
env[0] += (u16)s5; env[1] += (u16)s5;
env[2] += (u16)s6; env[3] += (u16)s6;
env[4] += (u16)t3; env[5] += (u16)t3;
}
}
static void DUPLICATE2(void) {
unsigned short Count = (inst1 >> 16) & 0xff;
unsigned short In = inst1&0xffff;
unsigned short Out = (inst2>>16);
unsigned short buff[64];
memcpy(buff,BufferSpace+In,128);
while(Count) {
memcpy(BufferSpace+Out,buff,128);
Out+=128;
Count--;
}
}
/*
static void INTERL2 (void) { // Make your own...
short Count = inst1 & 0xffff;
unsigned short Out = inst2 & 0xffff;
unsigned short In = (inst2 >> 16);
short *src,*dst,tmp;
src=(short *)&BufferSpace[In];
dst=(short *)&BufferSpace[Out];
while(Count)
{
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
*(dst++)=*(src++);
src++;
Count-=8;
}
}
*/
static void INTERL2 (void) {
short Count = inst1 & 0xffff;
unsigned short Out = inst2 & 0xffff;
unsigned short In = (inst2 >> 16);
unsigned char *src,*dst/*,tmp*/;
src=(unsigned char *)(BufferSpace);//[In];
dst=(unsigned char *)(BufferSpace);//[Out];
while(Count) {
*(short *)(dst+(Out^S8)) = *(short *)(src+(In^S8));
Out += 2;
In += 4;
Count--;
}
}
static void INTERLEAVE2 (void) { // Needs accuracy verification...
u32 inL, inR;
u16 *outbuff;
u16 *inSrcR;
u16 *inSrcL;
u16 Left, Right, Left2, Right2;
u32 count;
count = ((inst1 >> 12) & 0xFF0);
if (count == 0) {
outbuff = (u16 *)(AudioOutBuffer+BufferSpace);
count = AudioCount;
} else {
outbuff = (u16 *)((inst1&0xFFFF)+BufferSpace);
}
inR = inst2 & 0xFFFF;
inL = (inst2 >> 16) & 0xFFFF;
inSrcR = (u16 *)(BufferSpace+inR);
inSrcL = (u16 *)(BufferSpace+inL);
for (u32 x = 0; x < (count/4); x++) {
Left=*(inSrcL++);
Right=*(inSrcR++);
Left2=*(inSrcL++);
Right2=*(inSrcR++);
#ifdef _BIG_ENDIAN
*(outbuff++)=Right;
*(outbuff++)=Left;
*(outbuff++)=Right2;
*(outbuff++)=Left2;
#else
*(outbuff++)=Right2;
*(outbuff++)=Left2;
*(outbuff++)=Right;
*(outbuff++)=Left;
#endif
}
}
static void ADDMIXER (void) {
short Count = (inst1 >> 12) & 0x00ff0;
u16 InBuffer = (inst2 >> 16);
u16 OutBuffer = inst2 & 0xffff;
s16 *inp, *outp;
s32 temp;
inp = (s16 *)(BufferSpace + InBuffer);
outp = (s16 *)(BufferSpace + OutBuffer);
for (int cntr = 0; cntr < Count; cntr+=2) {
temp = *outp + *inp;
if (temp > 32767) temp = 32767; if (temp < -32768) temp = -32768;
*(outp++) = temp;
inp++;
}
}
static void HILOGAIN (void) {
u16 cnt = inst1 & 0xffff;
u16 out = (inst2 >> 16) & 0xffff;
s16 hi = (s16)((inst1 >> 4) & 0xf000);
u16 lo = (inst1 >> 20) & 0xf;
s16 *src;
src = (s16 *)(BufferSpace+out);
s32 tmp, val;
while(cnt) {
val = (s32)*src;
//tmp = ((val * (s32)hi) + ((u64)(val * lo) << 16) >> 16);
tmp = ((val * (s32)hi) >> 16) + (u32)(val * lo);
if ((s32)tmp > 32767) tmp = 32767;
else if ((s32)tmp < -32768) tmp = -32768;
*src = tmp;
src++;
cnt -= 2;
}
}
static void FILTER2 (void) {
static int cnt = 0;
static s16 *lutt6;
static s16 *lutt5;
u8 *save = (rsp.RDRAM+(inst2&0xFFFFFF));
u8 t4 = (u8)((inst1 >> 0x10) & 0xFF);
int x;
if (t4 > 1) { // Then set the cnt variable
cnt = (inst1 & 0xFFFF);
lutt6 = (s16 *)save;
// memcpy (dmem+0xFE0, rsp.RDRAM+(inst2&0xFFFFFF), 0x10);
return;
}
if (t4 == 0) {
// memcpy (dmem+0xFB0, rsp.RDRAM+(inst2&0xFFFFFF), 0x20);
lutt5 = (short *)(save+0x10);
}
lutt5 = (short *)(save+0x10);
// lutt5 = (short *)(dmem + 0xFC0);
// lutt6 = (short *)(dmem + 0xFE0);
for (x = 0; x < 8; x++) {
s32 a;
a = (lutt5[x] + lutt6[x]) >> 1;
lutt5[x] = lutt6[x] = (short)a;
}
short *inp1, *inp2;
s32 out1[8];
s16 outbuff[0x3c0], *outp;
u32 inPtr = (u32)(inst1&0xffff);
inp1 = (short *)(save);
outp = outbuff;
inp2 = (short *)(BufferSpace+inPtr);
for (x = 0; x < cnt; x+=0x10) {
out1[1] = inp1[0]*lutt6[6];
out1[1] += inp1[3]*lutt6[7];
out1[1] += inp1[2]*lutt6[4];
out1[1] += inp1[5]*lutt6[5];
out1[1] += inp1[4]*lutt6[2];
out1[1] += inp1[7]*lutt6[3];
out1[1] += inp1[6]*lutt6[0];
out1[1] += inp2[1]*lutt6[1]; // 1
out1[0] = inp1[3]*lutt6[6];
out1[0] += inp1[2]*lutt6[7];
out1[0] += inp1[5]*lutt6[4];
out1[0] += inp1[4]*lutt6[5];
out1[0] += inp1[7]*lutt6[2];
out1[0] += inp1[6]*lutt6[3];
out1[0] += inp2[1]*lutt6[0];
out1[0] += inp2[0]*lutt6[1];
out1[3] = inp1[2]*lutt6[6];
out1[3] += inp1[5]*lutt6[7];
out1[3] += inp1[4]*lutt6[4];
out1[3] += inp1[7]*lutt6[5];
out1[3] += inp1[6]*lutt6[2];
out1[3] += inp2[1]*lutt6[3];
out1[3] += inp2[0]*lutt6[0];
out1[3] += inp2[3]*lutt6[1];
out1[2] = inp1[5]*lutt6[6];
out1[2] += inp1[4]*lutt6[7];
out1[2] += inp1[7]*lutt6[4];
out1[2] += inp1[6]*lutt6[5];
out1[2] += inp2[1]*lutt6[2];
out1[2] += inp2[0]*lutt6[3];
out1[2] += inp2[3]*lutt6[0];
out1[2] += inp2[2]*lutt6[1];
out1[5] = inp1[4]*lutt6[6];
out1[5] += inp1[7]*lutt6[7];
out1[5] += inp1[6]*lutt6[4];
out1[5] += inp2[1]*lutt6[5];
out1[5] += inp2[0]*lutt6[2];
out1[5] += inp2[3]*lutt6[3];
out1[5] += inp2[2]*lutt6[0];
out1[5] += inp2[5]*lutt6[1];
out1[4] = inp1[7]*lutt6[6];
out1[4] += inp1[6]*lutt6[7];
out1[4] += inp2[1]*lutt6[4];
out1[4] += inp2[0]*lutt6[5];
out1[4] += inp2[3]*lutt6[2];
out1[4] += inp2[2]*lutt6[3];
out1[4] += inp2[5]*lutt6[0];
out1[4] += inp2[4]*lutt6[1];
out1[7] = inp1[6]*lutt6[6];
out1[7] += inp2[1]*lutt6[7];
out1[7] += inp2[0]*lutt6[4];
out1[7] += inp2[3]*lutt6[5];
out1[7] += inp2[2]*lutt6[2];
out1[7] += inp2[5]*lutt6[3];
out1[7] += inp2[4]*lutt6[0];
out1[7] += inp2[7]*lutt6[1];
out1[6] = inp2[1]*lutt6[6];
out1[6] += inp2[0]*lutt6[7];
out1[6] += inp2[3]*lutt6[4];
out1[6] += inp2[2]*lutt6[5];
out1[6] += inp2[5]*lutt6[2];
out1[6] += inp2[4]*lutt6[3];
out1[6] += inp2[7]*lutt6[0];
out1[6] += inp2[6]*lutt6[1];
outp[1] = /*CLAMP*/((out1[1]+0x4000) >> 0xF);
outp[0] = /*CLAMP*/((out1[0]+0x4000) >> 0xF);
outp[3] = /*CLAMP*/((out1[3]+0x4000) >> 0xF);
outp[2] = /*CLAMP*/((out1[2]+0x4000) >> 0xF);
outp[5] = /*CLAMP*/((out1[5]+0x4000) >> 0xF);
outp[4] = /*CLAMP*/((out1[4]+0x4000) >> 0xF);
outp[7] = /*CLAMP*/((out1[7]+0x4000) >> 0xF);
outp[6] = /*CLAMP*/((out1[6]+0x4000) >> 0xF);
inp1 = inp2;
inp2 += 8;
outp += 8;
}
// memcpy (rsp.RDRAM+(inst2&0xFFFFFF), dmem+0xFB0, 0x20);
memcpy (save, inp2-8, 0x10);
memcpy (BufferSpace+(inst1&0xffff), outbuff, cnt);
}
static void SEGMENT2 (void) {
if (isZeldaABI) {
FILTER2 ();
return;
}
if ((inst1 & 0xffffff) == 0) {
isMKABI = true;
//SEGMENTS[(inst2>>24)&0xf] = (inst2 & 0xffffff);
} else {
isMKABI = false;
isZeldaABI = true;
FILTER2 ();
}
}
static void UNKNOWN (void) {
}
/*
void (*ABI2[0x20])(void) = {
SPNOOP, ADPCM2, CLEARBUFF2, SPNOOP, SPNOOP, RESAMPLE2, SPNOOP, SEGMENT2,
SETBUFF2, SPNOOP, DMEMMOVE2, LOADADPCM2, MIXER2, INTERLEAVE2, HILOGAIN, SETLOOP2,
SPNOOP, INTERL2, ENVSETUP1, ENVMIXER2, LOADBUFF2, SAVEBUFF2, ENVSETUP2, SPNOOP,
SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP
};*/
void (*ABI2[0x20])(void) = {
SPNOOP , ADPCM2, CLEARBUFF2, UNKNOWN, ADDMIXER, RESAMPLE2, UNKNOWN, SEGMENT2,
SETBUFF2 , DUPLICATE2, DMEMMOVE2, LOADADPCM2, MIXER2, INTERLEAVE2, HILOGAIN, SETLOOP2,
SPNOOP, INTERL2 , ENVSETUP1, ENVMIXER2, LOADBUFF2, SAVEBUFF2, ENVSETUP2, SPNOOP,
HILOGAIN , SPNOOP, DUPLICATE2 , UNKNOWN , SPNOOP , SPNOOP , SPNOOP , SPNOOP
};
/*
void (*ABI2[0x20])(void) = {
SPNOOP , ADPCM2, CLEARBUFF2, SPNOOP, SPNOOP, RESAMPLE2 , SPNOOP , SEGMENT2,
SETBUFF2 , DUPLICATE2, DMEMMOVE2, LOADADPCM2, MIXER2, INTERLEAVE2, SPNOOP, SETLOOP2,
SPNOOP, INTERL2 , ENVSETUP1, ENVMIXER2, LOADBUFF2, SAVEBUFF2, ENVSETUP2, SPNOOP,
SPNOOP , SPNOOP, SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP
};*/
/* NOTES:
FILTER/SEGMENT - Still needs to be finished up... add FILTER?
UNKNOWWN #27 - Is this worth doing? Looks like a pain in the ass just for WaveRace64
*/

File diff suppressed because it is too large Load diff

View file

@ -1,603 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - ucode3mp3.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* Copyright (C) 2002 Hacktarux *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <string.h>
# include <stdio.h>
extern "C" {
#include "hle.h"
}
static u16 DeWindowLUT [0x420] = {
0x0000, 0xFFF3, 0x005D, 0xFF38, 0x037A, 0xF736, 0x0B37, 0xC00E,
0x7FFF, 0x3FF2, 0x0B37, 0x08CA, 0x037A, 0x00C8, 0x005D, 0x000D,
0x0000, 0xFFF3, 0x005D, 0xFF38, 0x037A, 0xF736, 0x0B37, 0xC00E,
0x7FFF, 0x3FF2, 0x0B37, 0x08CA, 0x037A, 0x00C8, 0x005D, 0x000D,
0x0000, 0xFFF2, 0x005F, 0xFF1D, 0x0369, 0xF697, 0x0A2A, 0xBCE7,
0x7FEB, 0x3CCB, 0x0C2B, 0x082B, 0x0385, 0x00AF, 0x005B, 0x000B,
0x0000, 0xFFF2, 0x005F, 0xFF1D, 0x0369, 0xF697, 0x0A2A, 0xBCE7,
0x7FEB, 0x3CCB, 0x0C2B, 0x082B, 0x0385, 0x00AF, 0x005B, 0x000B,
0x0000, 0xFFF1, 0x0061, 0xFF02, 0x0354, 0xF5F9, 0x0905, 0xB9C4,
0x7FB0, 0x39A4, 0x0D08, 0x078C, 0x038C, 0x0098, 0x0058, 0x000A,
0x0000, 0xFFF1, 0x0061, 0xFF02, 0x0354, 0xF5F9, 0x0905, 0xB9C4,
0x7FB0, 0x39A4, 0x0D08, 0x078C, 0x038C, 0x0098, 0x0058, 0x000A,
0x0000, 0xFFEF, 0x0062, 0xFEE6, 0x033B, 0xF55C, 0x07C8, 0xB6A4,
0x7F4D, 0x367E, 0x0DCE, 0x06EE, 0x038F, 0x0080, 0x0056, 0x0009,
0x0000, 0xFFEF, 0x0062, 0xFEE6, 0x033B, 0xF55C, 0x07C8, 0xB6A4,
0x7F4D, 0x367E, 0x0DCE, 0x06EE, 0x038F, 0x0080, 0x0056, 0x0009,
0x0000, 0xFFEE, 0x0063, 0xFECA, 0x031C, 0xF4C3, 0x0671, 0xB38C,
0x7EC2, 0x335D, 0x0E7C, 0x0652, 0x038E, 0x006B, 0x0053, 0x0008,
0x0000, 0xFFEE, 0x0063, 0xFECA, 0x031C, 0xF4C3, 0x0671, 0xB38C,
0x7EC2, 0x335D, 0x0E7C, 0x0652, 0x038E, 0x006B, 0x0053, 0x0008,
0x0000, 0xFFEC, 0x0064, 0xFEAC, 0x02F7, 0xF42C, 0x0502, 0xB07C,
0x7E12, 0x3041, 0x0F14, 0x05B7, 0x038A, 0x0056, 0x0050, 0x0007,
0x0000, 0xFFEC, 0x0064, 0xFEAC, 0x02F7, 0xF42C, 0x0502, 0xB07C,
0x7E12, 0x3041, 0x0F14, 0x05B7, 0x038A, 0x0056, 0x0050, 0x0007,
0x0000, 0xFFEB, 0x0064, 0xFE8E, 0x02CE, 0xF399, 0x037A, 0xAD75,
0x7D3A, 0x2D2C, 0x0F97, 0x0520, 0x0382, 0x0043, 0x004D, 0x0007,
0x0000, 0xFFEB, 0x0064, 0xFE8E, 0x02CE, 0xF399, 0x037A, 0xAD75,
0x7D3A, 0x2D2C, 0x0F97, 0x0520, 0x0382, 0x0043, 0x004D, 0x0007,
0xFFFF, 0xFFE9, 0x0063, 0xFE6F, 0x029E, 0xF30B, 0x01D8, 0xAA7B,
0x7C3D, 0x2A1F, 0x1004, 0x048B, 0x0377, 0x0030, 0x004A, 0x0006,
0xFFFF, 0xFFE9, 0x0063, 0xFE6F, 0x029E, 0xF30B, 0x01D8, 0xAA7B,
0x7C3D, 0x2A1F, 0x1004, 0x048B, 0x0377, 0x0030, 0x004A, 0x0006,
0xFFFF, 0xFFE7, 0x0062, 0xFE4F, 0x0269, 0xF282, 0x001F, 0xA78D,
0x7B1A, 0x271C, 0x105D, 0x03F9, 0x036A, 0x001F, 0x0046, 0x0006,
0xFFFF, 0xFFE7, 0x0062, 0xFE4F, 0x0269, 0xF282, 0x001F, 0xA78D,
0x7B1A, 0x271C, 0x105D, 0x03F9, 0x036A, 0x001F, 0x0046, 0x0006,
0xFFFF, 0xFFE4, 0x0061, 0xFE2F, 0x022F, 0xF1FF, 0xFE4C, 0xA4AF,
0x79D3, 0x2425, 0x10A2, 0x036C, 0x0359, 0x0010, 0x0043, 0x0005,
0xFFFF, 0xFFE4, 0x0061, 0xFE2F, 0x022F, 0xF1FF, 0xFE4C, 0xA4AF,
0x79D3, 0x2425, 0x10A2, 0x036C, 0x0359, 0x0010, 0x0043, 0x0005,
0xFFFF, 0xFFE2, 0x005E, 0xFE10, 0x01EE, 0xF184, 0xFC61, 0xA1E1,
0x7869, 0x2139, 0x10D3, 0x02E3, 0x0346, 0x0001, 0x0040, 0x0004,
0xFFFF, 0xFFE2, 0x005E, 0xFE10, 0x01EE, 0xF184, 0xFC61, 0xA1E1,
0x7869, 0x2139, 0x10D3, 0x02E3, 0x0346, 0x0001, 0x0040, 0x0004,
0xFFFF, 0xFFE0, 0x005B, 0xFDF0, 0x01A8, 0xF111, 0xFA5F, 0x9F27,
0x76DB, 0x1E5C, 0x10F2, 0x025E, 0x0331, 0xFFF3, 0x003D, 0x0004,
0xFFFF, 0xFFE0, 0x005B, 0xFDF0, 0x01A8, 0xF111, 0xFA5F, 0x9F27,
0x76DB, 0x1E5C, 0x10F2, 0x025E, 0x0331, 0xFFF3, 0x003D, 0x0004,
0xFFFF, 0xFFDE, 0x0057, 0xFDD0, 0x015B, 0xF0A7, 0xF845, 0x9C80,
0x752C, 0x1B8E, 0x1100, 0x01DE, 0x0319, 0xFFE7, 0x003A, 0x0003,
0xFFFF, 0xFFDE, 0x0057, 0xFDD0, 0x015B, 0xF0A7, 0xF845, 0x9C80,
0x752C, 0x1B8E, 0x1100, 0x01DE, 0x0319, 0xFFE7, 0x003A, 0x0003,
0xFFFE, 0xFFDB, 0x0053, 0xFDB0, 0x0108, 0xF046, 0xF613, 0x99EE,
0x735C, 0x18D1, 0x10FD, 0x0163, 0x0300, 0xFFDC, 0x0037, 0x0003,
0xFFFE, 0xFFDB, 0x0053, 0xFDB0, 0x0108, 0xF046, 0xF613, 0x99EE,
0x735C, 0x18D1, 0x10FD, 0x0163, 0x0300, 0xFFDC, 0x0037, 0x0003,
0xFFFE, 0xFFD8, 0x004D, 0xFD90, 0x00B0, 0xEFF0, 0xF3CC, 0x9775,
0x716C, 0x1624, 0x10EA, 0x00EE, 0x02E5, 0xFFD2, 0x0033, 0x0003,
0xFFFE, 0xFFD8, 0x004D, 0xFD90, 0x00B0, 0xEFF0, 0xF3CC, 0x9775,
0x716C, 0x1624, 0x10EA, 0x00EE, 0x02E5, 0xFFD2, 0x0033, 0x0003,
0xFFFE, 0xFFD6, 0x0047, 0xFD72, 0x0051, 0xEFA6, 0xF16F, 0x9514,
0x6F5E, 0x138A, 0x10C8, 0x007E, 0x02CA, 0xFFC9, 0x0030, 0x0003,
0xFFFE, 0xFFD6, 0x0047, 0xFD72, 0x0051, 0xEFA6, 0xF16F, 0x9514,
0x6F5E, 0x138A, 0x10C8, 0x007E, 0x02CA, 0xFFC9, 0x0030, 0x0003,
0xFFFE, 0xFFD3, 0x0040, 0xFD54, 0xFFEC, 0xEF68, 0xEEFC, 0x92CD,
0x6D33, 0x1104, 0x1098, 0x0014, 0x02AC, 0xFFC0, 0x002D, 0x0002,
0xFFFE, 0xFFD3, 0x0040, 0xFD54, 0xFFEC, 0xEF68, 0xEEFC, 0x92CD,
0x6D33, 0x1104, 0x1098, 0x0014, 0x02AC, 0xFFC0, 0x002D, 0x0002,
0x0030, 0xFFC9, 0x02CA, 0x007E, 0x10C8, 0x138A, 0x6F5E, 0x9514,
0xF16F, 0xEFA6, 0x0051, 0xFD72, 0x0047, 0xFFD6, 0xFFFE, 0x0003,
0x0030, 0xFFC9, 0x02CA, 0x007E, 0x10C8, 0x138A, 0x6F5E, 0x9514,
0xF16F, 0xEFA6, 0x0051, 0xFD72, 0x0047, 0xFFD6, 0xFFFE, 0x0003,
0x0033, 0xFFD2, 0x02E5, 0x00EE, 0x10EA, 0x1624, 0x716C, 0x9775,
0xF3CC, 0xEFF0, 0x00B0, 0xFD90, 0x004D, 0xFFD8, 0xFFFE, 0x0003,
0x0033, 0xFFD2, 0x02E5, 0x00EE, 0x10EA, 0x1624, 0x716C, 0x9775,
0xF3CC, 0xEFF0, 0x00B0, 0xFD90, 0x004D, 0xFFD8, 0xFFFE, 0x0003,
0x0037, 0xFFDC, 0x0300, 0x0163, 0x10FD, 0x18D1, 0x735C, 0x99EE,
0xF613, 0xF046, 0x0108, 0xFDB0, 0x0053, 0xFFDB, 0xFFFE, 0x0003,
0x0037, 0xFFDC, 0x0300, 0x0163, 0x10FD, 0x18D1, 0x735C, 0x99EE,
0xF613, 0xF046, 0x0108, 0xFDB0, 0x0053, 0xFFDB, 0xFFFE, 0x0003,
0x003A, 0xFFE7, 0x0319, 0x01DE, 0x1100, 0x1B8E, 0x752C, 0x9C80,
0xF845, 0xF0A7, 0x015B, 0xFDD0, 0x0057, 0xFFDE, 0xFFFF, 0x0003,
0x003A, 0xFFE7, 0x0319, 0x01DE, 0x1100, 0x1B8E, 0x752C, 0x9C80,
0xF845, 0xF0A7, 0x015B, 0xFDD0, 0x0057, 0xFFDE, 0xFFFF, 0x0004,
0x003D, 0xFFF3, 0x0331, 0x025E, 0x10F2, 0x1E5C, 0x76DB, 0x9F27,
0xFA5F, 0xF111, 0x01A8, 0xFDF0, 0x005B, 0xFFE0, 0xFFFF, 0x0004,
0x003D, 0xFFF3, 0x0331, 0x025E, 0x10F2, 0x1E5C, 0x76DB, 0x9F27,
0xFA5F, 0xF111, 0x01A8, 0xFDF0, 0x005B, 0xFFE0, 0xFFFF, 0x0004,
0x0040, 0x0001, 0x0346, 0x02E3, 0x10D3, 0x2139, 0x7869, 0xA1E1,
0xFC61, 0xF184, 0x01EE, 0xFE10, 0x005E, 0xFFE2, 0xFFFF, 0x0004,
0x0040, 0x0001, 0x0346, 0x02E3, 0x10D3, 0x2139, 0x7869, 0xA1E1,
0xFC61, 0xF184, 0x01EE, 0xFE10, 0x005E, 0xFFE2, 0xFFFF, 0x0005,
0x0043, 0x0010, 0x0359, 0x036C, 0x10A2, 0x2425, 0x79D3, 0xA4AF,
0xFE4C, 0xF1FF, 0x022F, 0xFE2F, 0x0061, 0xFFE4, 0xFFFF, 0x0005,
0x0043, 0x0010, 0x0359, 0x036C, 0x10A2, 0x2425, 0x79D3, 0xA4AF,
0xFE4C, 0xF1FF, 0x022F, 0xFE2F, 0x0061, 0xFFE4, 0xFFFF, 0x0006,
0x0046, 0x001F, 0x036A, 0x03F9, 0x105D, 0x271C, 0x7B1A, 0xA78D,
0x001F, 0xF282, 0x0269, 0xFE4F, 0x0062, 0xFFE7, 0xFFFF, 0x0006,
0x0046, 0x001F, 0x036A, 0x03F9, 0x105D, 0x271C, 0x7B1A, 0xA78D,
0x001F, 0xF282, 0x0269, 0xFE4F, 0x0062, 0xFFE7, 0xFFFF, 0x0006,
0x004A, 0x0030, 0x0377, 0x048B, 0x1004, 0x2A1F, 0x7C3D, 0xAA7B,
0x01D8, 0xF30B, 0x029E, 0xFE6F, 0x0063, 0xFFE9, 0xFFFF, 0x0006,
0x004A, 0x0030, 0x0377, 0x048B, 0x1004, 0x2A1F, 0x7C3D, 0xAA7B,
0x01D8, 0xF30B, 0x029E, 0xFE6F, 0x0063, 0xFFE9, 0xFFFF, 0x0007,
0x004D, 0x0043, 0x0382, 0x0520, 0x0F97, 0x2D2C, 0x7D3A, 0xAD75,
0x037A, 0xF399, 0x02CE, 0xFE8E, 0x0064, 0xFFEB, 0x0000, 0x0007,
0x004D, 0x0043, 0x0382, 0x0520, 0x0F97, 0x2D2C, 0x7D3A, 0xAD75,
0x037A, 0xF399, 0x02CE, 0xFE8E, 0x0064, 0xFFEB, 0x0000, 0x0007,
0x0050, 0x0056, 0x038A, 0x05B7, 0x0F14, 0x3041, 0x7E12, 0xB07C,
0x0502, 0xF42C, 0x02F7, 0xFEAC, 0x0064, 0xFFEC, 0x0000, 0x0007,
0x0050, 0x0056, 0x038A, 0x05B7, 0x0F14, 0x3041, 0x7E12, 0xB07C,
0x0502, 0xF42C, 0x02F7, 0xFEAC, 0x0064, 0xFFEC, 0x0000, 0x0008,
0x0053, 0x006B, 0x038E, 0x0652, 0x0E7C, 0x335D, 0x7EC2, 0xB38C,
0x0671, 0xF4C3, 0x031C, 0xFECA, 0x0063, 0xFFEE, 0x0000, 0x0008,
0x0053, 0x006B, 0x038E, 0x0652, 0x0E7C, 0x335D, 0x7EC2, 0xB38C,
0x0671, 0xF4C3, 0x031C, 0xFECA, 0x0063, 0xFFEE, 0x0000, 0x0009,
0x0056, 0x0080, 0x038F, 0x06EE, 0x0DCE, 0x367E, 0x7F4D, 0xB6A4,
0x07C8, 0xF55C, 0x033B, 0xFEE6, 0x0062, 0xFFEF, 0x0000, 0x0009,
0x0056, 0x0080, 0x038F, 0x06EE, 0x0DCE, 0x367E, 0x7F4D, 0xB6A4,
0x07C8, 0xF55C, 0x033B, 0xFEE6, 0x0062, 0xFFEF, 0x0000, 0x000A,
0x0058, 0x0098, 0x038C, 0x078C, 0x0D08, 0x39A4, 0x7FB0, 0xB9C4,
0x0905, 0xF5F9, 0x0354, 0xFF02, 0x0061, 0xFFF1, 0x0000, 0x000A,
0x0058, 0x0098, 0x038C, 0x078C, 0x0D08, 0x39A4, 0x7FB0, 0xB9C4,
0x0905, 0xF5F9, 0x0354, 0xFF02, 0x0061, 0xFFF1, 0x0000, 0x000B,
0x005B, 0x00AF, 0x0385, 0x082B, 0x0C2B, 0x3CCB, 0x7FEB, 0xBCE7,
0x0A2A, 0xF697, 0x0369, 0xFF1D, 0x005F, 0xFFF2, 0x0000, 0x000B,
0x005B, 0x00AF, 0x0385, 0x082B, 0x0C2B, 0x3CCB, 0x7FEB, 0xBCE7,
0x0A2A, 0xF697, 0x0369, 0xFF1D, 0x005F, 0xFFF2, 0x0000, 0x000D,
0x005D, 0x00C8, 0x037A, 0x08CA, 0x0B37, 0x3FF2, 0x7FFF, 0xC00E,
0x0B37, 0xF736, 0x037A, 0xFF38, 0x005D, 0xFFF3, 0x0000, 0x000D,
0x005D, 0x00C8, 0x037A, 0x08CA, 0x0B37, 0x3FF2, 0x7FFF, 0xC00E,
0x0B37, 0xF736, 0x037A, 0xFF38, 0x005D, 0xFFF3, 0x0000, 0x0000
};
//static u16 myVector[32][8];
static u8 mp3data[0x1000];
static s32 v[32];
static void MP3AB0 () {
// Part 2 - 100% Accurate
const u16 LUT2[8] = { 0xFEC4, 0xF4FA, 0xC5E4, 0xE1C4,
0x1916, 0x4A50, 0xA268, 0x78AE };
const u16 LUT3[4] = { 0xFB14, 0xD4DC, 0x31F2, 0x8E3A };
int i;
for (i = 0; i < 8; i++) {
v[16+i] = v[0+i] + v[8+i];
v[24+i] = ((v[0+i] - v[8+i]) * LUT2[i]) >> 0x10;
}
// Part 3: 4-wide butterflies
for (i=0; i < 4; i++) {
v[0+i] = v[16+i] + v[20+i];
v[4+i] = ((v[16+i] - v[20+i]) * LUT3[i]) >> 0x10;
v[8+i] = v[24+i] + v[28+i];
v[12+i] = ((v[24+i] - v[28+i]) * LUT3[i]) >> 0x10;
}
// Part 4: 2-wide butterflies - 100% Accurate
for (i = 0; i < 16; i+=4) {
v[16+i] = v[0+i] + v[2+i];
v[18+i] = ((v[0+i] - v[2+i]) * 0xEC84) >> 0x10;
v[17+i] = v[1+i] + v[3+i];
v[19+i] = ((v[1+i] - v[3+i]) * 0x61F8) >> 0x10;
}
}
static void InnerLoop ();
u32 inPtr, outPtr;
u32 t6;// = 0x08A0; // I think these are temporary storage buffers
u32 t5;// = 0x0AC0;
u32 t4;// = (inst1 & 0x1E);
void MP3 () {
// Initialization Code
u32 readPtr; // s5
u32 writePtr; // s6
//u32 Count = 0x0480; // s4
u32 tmp;
//u32 inPtr, outPtr;
t6 = 0x08A0; // I think these are temporary storage buffers
t5 = 0x0AC0;
t4 = (inst1 & 0x1E);
writePtr = inst2 & 0xFFFFFF;
readPtr = writePtr;
memcpy (mp3data+0xCE8, rsp.RDRAM+readPtr, 8); // Just do that for efficiency... may remove and use directly later anyway
readPtr += 8; // This must be a header byte or whatnot
for (int cnt = 0; cnt < 0x480; cnt += 0x180) {
memcpy (mp3data+0xCF0, rsp.RDRAM+readPtr, 0x180); // DMA: 0xCF0 <- RDRAM[s5] : 0x180
inPtr = 0xCF0; // s7
outPtr = 0xE70; // s3
// --------------- Inner Loop Start --------------------
for (int cnt2 = 0; cnt2 < 0x180; cnt2 += 0x40) {
t6 &= 0xFFE0;
t5 &= 0xFFE0;
t6 |= t4;
t5 |= t4;
InnerLoop ();
t4 = (t4-2)&0x1E;
tmp = t6;
t6 = t5;
t5 = tmp;
//outPtr += 0x40;
inPtr += 0x40;
}
// --------------- Inner Loop End --------------------
memcpy (rsp.RDRAM+writePtr, mp3data+0xe70, 0x180);
writePtr += 0x180;
readPtr += 0x180;
}
}
static void InnerLoop () {
// Part 1: 100% Accurate
int i;
v[0] = *(s16 *)(mp3data+inPtr+(0x00^S16)); v[31] = *(s16 *)(mp3data+inPtr+(0x3E^S16)); v[0] += v[31];
v[1] = *(s16 *)(mp3data+inPtr+(0x02^S16)); v[30] = *(s16 *)(mp3data+inPtr+(0x3C^S16)); v[1] += v[30];
v[2] = *(s16 *)(mp3data+inPtr+(0x06^S16)); v[28] = *(s16 *)(mp3data+inPtr+(0x38^S16)); v[2] += v[28];
v[3] = *(s16 *)(mp3data+inPtr+(0x04^S16)); v[29] = *(s16 *)(mp3data+inPtr+(0x3A^S16)); v[3] += v[29];
v[4] = *(s16 *)(mp3data+inPtr+(0x0E^S16)); v[24] = *(s16 *)(mp3data+inPtr+(0x30^S16)); v[4] += v[24];
v[5] = *(s16 *)(mp3data+inPtr+(0x0C^S16)); v[25] = *(s16 *)(mp3data+inPtr+(0x32^S16)); v[5] += v[25];
v[6] = *(s16 *)(mp3data+inPtr+(0x08^S16)); v[27] = *(s16 *)(mp3data+inPtr+(0x36^S16)); v[6] += v[27];
v[7] = *(s16 *)(mp3data+inPtr+(0x0A^S16)); v[26] = *(s16 *)(mp3data+inPtr+(0x34^S16)); v[7] += v[26];
v[8] = *(s16 *)(mp3data+inPtr+(0x1E^S16)); v[16] = *(s16 *)(mp3data+inPtr+(0x20^S16)); v[8] += v[16];
v[9] = *(s16 *)(mp3data+inPtr+(0x1C^S16)); v[17] = *(s16 *)(mp3data+inPtr+(0x22^S16)); v[9] += v[17];
v[10]= *(s16 *)(mp3data+inPtr+(0x18^S16)); v[19] = *(s16 *)(mp3data+inPtr+(0x26^S16)); v[10]+= v[19];
v[11]= *(s16 *)(mp3data+inPtr+(0x1A^S16)); v[18] = *(s16 *)(mp3data+inPtr+(0x24^S16)); v[11]+= v[18];
v[12]= *(s16 *)(mp3data+inPtr+(0x10^S16)); v[23] = *(s16 *)(mp3data+inPtr+(0x2E^S16)); v[12]+= v[23];
v[13]= *(s16 *)(mp3data+inPtr+(0x12^S16)); v[22] = *(s16 *)(mp3data+inPtr+(0x2C^S16)); v[13]+= v[22];
v[14]= *(s16 *)(mp3data+inPtr+(0x16^S16)); v[20] = *(s16 *)(mp3data+inPtr+(0x28^S16)); v[14]+= v[20];
v[15]= *(s16 *)(mp3data+inPtr+(0x14^S16)); v[21] = *(s16 *)(mp3data+inPtr+(0x2A^S16)); v[15]+= v[21];
// Part 2-4
MP3AB0 ();
// Part 5 - 1-Wide Butterflies - 100% Accurate but need SSVs!!!
u32 t0 = t6 + 0x100;
u32 t1 = t6 + 0x200;
u32 t2 = t5 + 0x100;
u32 t3 = t5 + 0x200;
/*RSP_GPR[0x8].W = t0;
RSP_GPR[0x9].W = t1;
RSP_GPR[0xA].W = t2;
RSP_GPR[0xB].W = t3;
RSP_Vect[0].DW[1] = 0xB504A57E00016A09;
RSP_Vect[0].DW[0] = 0x0002D4130005A827;
*/
// 0x13A8
v[1] = 0;
v[11] = ((v[16] - v[17]) * 0xB504) >> 0x10;
v[16] = -v[16] -v[17];
v[2] = v[18] + v[19];
// ** Store v[11] -> (T6 + 0)**
*(s16 *)(mp3data+((t6+(short)0x0))) = (short)v[11];
v[11] = -v[11];
// ** Store v[16] -> (T3 + 0)**
*(s16 *)(mp3data+((t3+(short)0x0))) = (short)v[16];
// ** Store v[11] -> (T5 + 0)**
*(s16 *)(mp3data+((t5+(short)0x0))) = (short)v[11];
// 0x13E8 - Verified....
v[2] = -v[2];
// ** Store v[2] -> (T2 + 0)**
*(s16 *)(mp3data+((t2+(short)0x0))) = (short)v[2];
v[3] = (((v[18] - v[19]) * 0x16A09) >> 0x10) + v[2];
// ** Store v[3] -> (T0 + 0)**
*(s16 *)(mp3data+((t0+(short)0x0))) = (short)v[3];
// 0x1400 - Verified
v[4] = -v[20] -v[21];
v[6] = v[22] + v[23];
v[5] = ((v[20] - v[21]) * 0x16A09) >> 0x10;
// ** Store v[4] -> (T3 + 0xFF80)
*(s16 *)(mp3data+((t3+(short)0xFF80))) = (short)v[4];
v[7] = ((v[22] - v[23]) * 0x2D413) >> 0x10;
v[5] = v[5] - v[4];
v[7] = v[7] - v[5];
v[6] = v[6] + v[6];
v[5] = v[5] - v[6];
v[4] = -v[4] - v[6];
// *** Store v[7] -> (T1 + 0xFF80)
*(s16 *)(mp3data+((t1+(short)0xFF80))) = (short)v[7];
// *** Store v[4] -> (T2 + 0xFF80)
*(s16 *)(mp3data+((t2+(short)0xFF80))) = (short)v[4];
// *** Store v[5] -> (T0 + 0xFF80)
*(s16 *)(mp3data+((t0+(short)0xFF80))) = (short)v[5];
v[8] = v[24] + v[25];
v[9] = ((v[24] - v[25]) * 0x16A09) >> 0x10;
v[2] = v[8] + v[9];
v[11] = ((v[26] - v[27]) * 0x2D413) >> 0x10;
v[13] = ((v[28] - v[29]) * 0x2D413) >> 0x10;
v[10] = v[26] + v[27]; v[10] = v[10] + v[10];
v[12] = v[28] + v[29]; v[12] = v[12] + v[12];
v[14] = v[30] + v[31];
v[3] = v[8] + v[10];
v[14] = v[14] + v[14];
v[13] = (v[13] - v[2]) + v[12];
v[15] = (((v[30] - v[31]) * 0x5A827) >> 0x10) - (v[11] + v[2]);
v[14] = -(v[14] + v[14]) + v[3];
v[17] = v[13] - v[10];
v[9] = v[9] + v[14];
// ** Store v[9] -> (T6 + 0x40)
*(s16 *)(mp3data+((t6+(short)0x40))) = (short)v[9];
v[11] = v[11] - v[13];
// ** Store v[17] -> (T0 + 0xFFC0)
*(s16 *)(mp3data+((t0+(short)0xFFC0))) = (short)v[17];
v[12] = v[8] - v[12];
// ** Store v[11] -> (T0 + 0x40)
*(s16 *)(mp3data+((t0+(short)0x40))) = (short)v[11];
v[8] = -v[8];
// ** Store v[15] -> (T1 + 0xFFC0)
*(s16 *)(mp3data+((t1+(short)0xFFC0))) = (short)v[15];
v[10] = -v[10] -v[12];
// ** Store v[12] -> (T2 + 0x40)
*(s16 *)(mp3data+((t2+(short)0x40))) = (short)v[12];
// ** Store v[8] -> (T3 + 0xFFC0)
*(s16 *)(mp3data+((t3+(short)0xFFC0))) = (short)v[8];
// ** Store v[14] -> (T5 + 0x40)
*(s16 *)(mp3data+((t5+(short)0x40))) = (short)v[14];
// ** Store v[10] -> (T2 + 0xFFC0)
*(s16 *)(mp3data+((t2+(short)0xFFC0))) = (short)v[10];
// 0x14FC - Verified...
// Part 6 - 100% Accurate
v[0] = *(s16 *)(mp3data+inPtr+(0x00^S16)); v[31] = *(s16 *)(mp3data+inPtr+(0x3E^S16)); v[0] -= v[31];
v[1] = *(s16 *)(mp3data+inPtr+(0x02^S16)); v[30] = *(s16 *)(mp3data+inPtr+(0x3C^S16)); v[1] -= v[30];
v[2] = *(s16 *)(mp3data+inPtr+(0x06^S16)); v[28] = *(s16 *)(mp3data+inPtr+(0x38^S16)); v[2] -= v[28];
v[3] = *(s16 *)(mp3data+inPtr+(0x04^S16)); v[29] = *(s16 *)(mp3data+inPtr+(0x3A^S16)); v[3] -= v[29];
v[4] = *(s16 *)(mp3data+inPtr+(0x0E^S16)); v[24] = *(s16 *)(mp3data+inPtr+(0x30^S16)); v[4] -= v[24];
v[5] = *(s16 *)(mp3data+inPtr+(0x0C^S16)); v[25] = *(s16 *)(mp3data+inPtr+(0x32^S16)); v[5] -= v[25];
v[6] = *(s16 *)(mp3data+inPtr+(0x08^S16)); v[27] = *(s16 *)(mp3data+inPtr+(0x36^S16)); v[6] -= v[27];
v[7] = *(s16 *)(mp3data+inPtr+(0x0A^S16)); v[26] = *(s16 *)(mp3data+inPtr+(0x34^S16)); v[7] -= v[26];
v[8] = *(s16 *)(mp3data+inPtr+(0x1E^S16)); v[16] = *(s16 *)(mp3data+inPtr+(0x20^S16)); v[8] -= v[16];
v[9] = *(s16 *)(mp3data+inPtr+(0x1C^S16)); v[17] = *(s16 *)(mp3data+inPtr+(0x22^S16)); v[9] -= v[17];
v[10]= *(s16 *)(mp3data+inPtr+(0x18^S16)); v[19] = *(s16 *)(mp3data+inPtr+(0x26^S16)); v[10]-= v[19];
v[11]= *(s16 *)(mp3data+inPtr+(0x1A^S16)); v[18] = *(s16 *)(mp3data+inPtr+(0x24^S16)); v[11]-= v[18];
v[12]= *(s16 *)(mp3data+inPtr+(0x10^S16)); v[23] = *(s16 *)(mp3data+inPtr+(0x2E^S16)); v[12]-= v[23];
v[13]= *(s16 *)(mp3data+inPtr+(0x12^S16)); v[22] = *(s16 *)(mp3data+inPtr+(0x2C^S16)); v[13]-= v[22];
v[14]= *(s16 *)(mp3data+inPtr+(0x16^S16)); v[20] = *(s16 *)(mp3data+inPtr+(0x28^S16)); v[14]-= v[20];
v[15]= *(s16 *)(mp3data+inPtr+(0x14^S16)); v[21] = *(s16 *)(mp3data+inPtr+(0x2A^S16)); v[15]-= v[21];
//0, 1, 3, 2, 7, 6, 4, 5, 7, 6, 4, 5, 0, 1, 3, 2
const u16 LUT6[16] = { 0xFFB2, 0xFD3A, 0xF10A, 0xF854,
0xBDAE, 0xCDA0, 0xE76C, 0xDB94,
0x1920, 0x4B20, 0xAC7C, 0x7C68,
0xABEC, 0x9880, 0xDAE8, 0x839C };
for (i = 0; i < 16; i++) {
v[0+i] = (v[0+i] * LUT6[i]) >> 0x10;
}
v[0] = v[0] + v[0]; v[1] = v[1] + v[1];
v[2] = v[2] + v[2]; v[3] = v[3] + v[3]; v[4] = v[4] + v[4];
v[5] = v[5] + v[5]; v[6] = v[6] + v[6]; v[7] = v[7] + v[7];
v[12] = v[12] + v[12]; v[13] = v[13] + v[13]; v[15] = v[15] + v[15];
MP3AB0 ();
// Part 7: - 100% Accurate + SSV - Unoptimized
v[0] = ( v[17] + v[16] ) >> 1;
v[1] = ((v[17] * (int)((short)0xA57E * 2)) + (v[16] * 0xB504)) >> 0x10;
v[2] = -v[18] -v[19];
v[3] = ((v[18] - v[19]) * 0x16A09) >> 0x10;
v[4] = v[20] + v[21] + v[0];
v[5] = (((v[20] - v[21]) * 0x16A09) >> 0x10) + v[1];
v[6] = (((v[22] + v[23]) << 1) + v[0]) - v[2];
v[7] = (((v[22] - v[23]) * 0x2D413) >> 0x10) + v[0] + v[1] + v[3];
// 0x16A8
// Save v[0] -> (T3 + 0xFFE0)
*(s16 *)(mp3data+((t3+(short)0xFFE0))) = (short)-v[0];
v[8] = v[24] + v[25];
v[9] = ((v[24] - v[25]) * 0x16A09) >> 0x10;
v[10] = ((v[26] + v[27]) << 1) + v[8];
v[11] = (((v[26] - v[27]) * 0x2D413) >> 0x10) + v[8] + v[9];
v[12] = v[4] - ((v[28] + v[29]) << 1);
// ** Store v12 -> (T2 + 0x20)
*(s16 *)(mp3data+((t2+(short)0x20))) = (short)v[12];
v[13] = (((v[28] - v[29]) * 0x2D413) >> 0x10) - v[12] - v[5];
v[14] = v[30] + v[31];
v[14] = v[14] + v[14];
v[14] = v[14] + v[14];
v[14] = v[6] - v[14];
v[15] = (((v[30] - v[31]) * 0x5A827) >> 0x10) - v[7];
// Store v14 -> (T5 + 0x20)
*(s16 *)(mp3data+((t5+(short)0x20))) = (short)v[14];
v[14] = v[14] + v[1];
// Store v[14] -> (T6 + 0x20)
*(s16 *)(mp3data+((t6+(short)0x20))) = (short)v[14];
// Store v[15] -> (T1 + 0xFFE0)
*(s16 *)(mp3data+((t1+(short)0xFFE0))) = (short)v[15];
v[9] = v[9] + v[10];
v[1] = v[1] + v[6];
v[6] = v[10] - v[6];
v[1] = v[9] - v[1];
// Store v[6] -> (T5 + 0x60)
*(s16 *)(mp3data+((t5+(short)0x60))) = (short)v[6];
v[10] = v[10] + v[2];
v[10] = v[4] - v[10];
// Store v[10] -> (T2 + 0xFFA0)
*(s16 *)(mp3data+((t2+(short)0xFFA0))) = (short)v[10];
v[12] = v[2] - v[12];
// Store v[12] -> (T2 + 0xFFE0)
*(s16 *)(mp3data+((t2+(short)0xFFE0))) = (short)v[12];
v[5] = v[4] + v[5];
v[4] = v[8] - v[4];
// Store v[4] -> (T2 + 0x60)
*(s16 *)(mp3data+((t2+(short)0x60))) = (short)v[4];
v[0] = v[0] - v[8];
// Store v[0] -> (T3 + 0xFFA0)
*(s16 *)(mp3data+((t3+(short)0xFFA0))) = (short)v[0];
v[7] = v[7] - v[11];
// Store v[7] -> (T1 + 0xFFA0)
*(s16 *)(mp3data+((t1+(short)0xFFA0))) = (short)v[7];
v[11] = v[11] - v[3];
// Store v[1] -> (T6 + 0x60)
*(s16 *)(mp3data+((t6+(short)0x60))) = (short)v[1];
v[11] = v[11] - v[5];
// Store v[11] -> (T0 + 0x60)
*(s16 *)(mp3data+((t0+(short)0x60))) = (short)v[11];
v[3] = v[3] - v[13];
// Store v[3] -> (T0 + 0x20)
*(s16 *)(mp3data+((t0+(short)0x20))) = (short)v[3];
v[13] = v[13] + v[2];
// Store v[13] -> (T0 + 0xFFE0)
*(s16 *)(mp3data+((t0+(short)0xFFE0))) = (short)v[13];
//v[2] = ;
v[2] = (v[5] - v[2]) - v[9];
// Store v[2] -> (T0 + 0xFFA0)
*(s16 *)(mp3data+((t0+(short)0xFFA0))) = (short)v[2];
// 0x7A8 - Verified...
// Step 8 - Dewindowing
//u64 *DW = (u64 *)&DeWindowLUT[0x10-(t4>>1)];
u32 offset = 0x10-(t4>>1);
u32 addptr = t6 & 0xFFE0;
offset = 0x10-(t4>>1);
s32 v2=0, v4=0, v6=0, v8=0;
//s32 z2=0, z4=0, z6=0, z8=0;
offset = 0x10-(t4>>1);// + x*0x40;
int x;
for (x = 0; x < 8; x++) {
v2 = v4 = v6 = v8 = 0;
//addptr = t1;
for (i = 7; i >= 0; i--) {
v2 += ((int)*(s16 *)(mp3data+(addptr)+0x00) * (short)DeWindowLUT[offset+0x00] + 0x4000) >> 0xF;
v4 += ((int)*(s16 *)(mp3data+(addptr)+0x10) * (short)DeWindowLUT[offset+0x08] + 0x4000) >> 0xF;
v6 += ((int)*(s16 *)(mp3data+(addptr)+0x20) * (short)DeWindowLUT[offset+0x20] + 0x4000) >> 0xF;
v8 += ((int)*(s16 *)(mp3data+(addptr)+0x30) * (short)DeWindowLUT[offset+0x28] + 0x4000) >> 0xF;
addptr+=2; offset++;
}
s32 v0 = v2 + v4;
s32 v18 = v6 + v8;
//Clamp(v0);
//Clamp(v18);
// clamp???
*(s16 *)(mp3data+(outPtr^S16)) = v0;
*(s16 *)(mp3data+((outPtr+2)^S16)) = v18;
outPtr+=4;
addptr += 0x30;
offset += 0x38;
}
offset = 0x10-(t4>>1) + 8*0x40;
v2 = v4 = 0;
for (i = 0; i < 4; i++) {
v2 += ((int)*(s16 *)(mp3data+(addptr)+0x00) * (short)DeWindowLUT[offset+0x00] + 0x4000) >> 0xF;
v2 += ((int)*(s16 *)(mp3data+(addptr)+0x10) * (short)DeWindowLUT[offset+0x08] + 0x4000) >> 0xF;
addptr+=2; offset++;
v4 += ((int)*(s16 *)(mp3data+(addptr)+0x00) * (short)DeWindowLUT[offset+0x00] + 0x4000) >> 0xF;
v4 += ((int)*(s16 *)(mp3data+(addptr)+0x10) * (short)DeWindowLUT[offset+0x08] + 0x4000) >> 0xF;
addptr+=2; offset++;
}
s32 mult6 = *(s32 *)(mp3data+0xCE8);
s32 mult4 = *(s32 *)(mp3data+0xCEC);
if (t4 & 0x2) {
v2 = (v2 * *(u32 *)(mp3data+0xCE8)) >> 0x10;
*(s16 *)(mp3data+(outPtr^S16)) = v2;
} else {
v4 = (v4 * *(u32 *)(mp3data+0xCE8)) >> 0x10;
*(s16 *)(mp3data+(outPtr^S16)) = v4;
mult4 = *(u32 *)(mp3data+0xCE8);
}
addptr -= 0x50;
for (x = 0; x < 8; x++) {
v2 = v4 = v6 = v8 = 0;
offset = (0x22F-(t4>>1) + x*0x40);
for (i = 0; i < 4; i++) {
v2 += ((int)*(s16 *)(mp3data+(addptr )+0x20) * (short)DeWindowLUT[offset+0x00] + 0x4000) >> 0xF;
v2 -= ((int)*(s16 *)(mp3data+((addptr+2))+0x20) * (short)DeWindowLUT[offset+0x01] + 0x4000) >> 0xF;
v4 += ((int)*(s16 *)(mp3data+(addptr )+0x30) * (short)DeWindowLUT[offset+0x08] + 0x4000) >> 0xF;
v4 -= ((int)*(s16 *)(mp3data+((addptr+2))+0x30) * (short)DeWindowLUT[offset+0x09] + 0x4000) >> 0xF;
v6 += ((int)*(s16 *)(mp3data+(addptr )+0x00) * (short)DeWindowLUT[offset+0x20] + 0x4000) >> 0xF;
v6 -= ((int)*(s16 *)(mp3data+((addptr+2))+0x00) * (short)DeWindowLUT[offset+0x21] + 0x4000) >> 0xF;
v8 += ((int)*(s16 *)(mp3data+(addptr )+0x10) * (short)DeWindowLUT[offset+0x28] + 0x4000) >> 0xF;
v8 -= ((int)*(s16 *)(mp3data+((addptr+2))+0x10) * (short)DeWindowLUT[offset+0x29] + 0x4000) >> 0xF;
addptr+=4; offset+=2;
}
s32 v0 = v2 + v4;
s32 v18 = v6 + v8;
//Clamp(v0);
//Clamp(v18);
// clamp???
*(s16 *)(mp3data+((outPtr+2)^S16)) = v0;
*(s16 *)(mp3data+((outPtr+4)^S16)) = v18;
outPtr+=4;
addptr -= 0x50;
}
int tmp = outPtr;
s32 hi0 = mult6;
s32 hi1 = mult4;
s32 v;
hi0 = (int)hi0 >> 0x10;
hi1 = (int)hi1 >> 0x10;
for (i = 0; i < 8; i++) {
// v0
v = (*(s16 *)(mp3data+((tmp-0x40)^S16)) * hi0);
if (v > 32767) v = 32767; else if (v < -32767) v = -32767;
*(s16 *)((u8 *)mp3data+((tmp-0x40)^S16)) = (s16)v;
// v17
v = (*(s16 *)(mp3data+((tmp-0x30)^S16)) * hi0);
if (v > 32767) v = 32767; else if (v < -32767) v = -32767;
*(s16 *)((u8 *)mp3data+((tmp-0x30)^S16)) = v;
// v2
v = (*(s16 *)(mp3data+((tmp-0x1E)^S16)) * hi1);
if (v > 32767) v = 32767; else if (v < -32767) v = -32767;
*(s16 *)((u8 *)mp3data+((tmp-0x1E)^S16)) = v;
// v4
v = (*(s16 *)(mp3data+((tmp-0xE)^S16)) * hi1);
if (v > 32767) v = 32767; else if (v < -32767) v = -32767;
*(s16 *)((u8 *)mp3data+((tmp-0xE)^S16)) = v;
tmp += 2;
}
}

171
src/ucodes.h Normal file
View file

@ -0,0 +1,171 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - ucodes.h *
* Mupen64Plus homepage: https://mupen64plus.org/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef UCODES_H
#define UCODES_H
#include <stdint.h>
#define CACHED_UCODES_MAX_SIZE 16
struct hle_t;
typedef void(*ucode_func_t)(struct hle_t* hle);
struct ucode_info_t {
uint32_t uc_start;
uint32_t uc_dstart;
uint16_t uc_dsize;
ucode_func_t uc_pfunc;
};
struct cached_ucodes_t {
struct ucode_info_t infos[CACHED_UCODES_MAX_SIZE];
int count;
};
/* cic_x105 ucode */
void cicx105_ucode(struct hle_t* hle);
/* audio list ucodes - audio */
enum { N_SEGMENTS = 16 };
struct alist_audio_t {
/* segments */
uint32_t segments[N_SEGMENTS];
/* main buffers */
uint16_t in;
uint16_t out;
uint16_t count;
/* auxiliary buffers */
uint16_t dry_right;
uint16_t wet_left;
uint16_t wet_right;
/* gains */
int16_t dry;
int16_t wet;
/* envelopes (0:left, 1:right) */
int16_t vol[2];
int16_t target[2];
int32_t rate[2];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
};
void alist_process_audio (struct hle_t* hle);
void alist_process_audio_ge(struct hle_t* hle);
void alist_process_audio_bc(struct hle_t* hle);
/* audio list ucodes - naudio */
struct alist_naudio_t {
/* gains */
int16_t dry;
int16_t wet;
/* envelopes (0:left, 1:right) */
int16_t vol[2];
int16_t target[2];
int32_t rate[2];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
};
void alist_process_naudio (struct hle_t* hle);
void alist_process_naudio_bk (struct hle_t* hle);
void alist_process_naudio_dk (struct hle_t* hle);
void alist_process_naudio_mp3 (struct hle_t* hle);
void alist_process_naudio_cbfd(struct hle_t* hle);
/* audio list ucodes - nead */
struct alist_nead_t {
/* main buffers */
uint16_t in;
uint16_t out;
uint16_t count;
/* envmixer ramps */
uint16_t env_values[3];
uint16_t env_steps[3];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
/* filter audio command state */
uint16_t filter_count;
uint32_t filter_lut_address[2];
};
void alist_process_nead_mk (struct hle_t* hle);
void alist_process_nead_sfj (struct hle_t* hle);
void alist_process_nead_sf (struct hle_t* hle);
void alist_process_nead_fz (struct hle_t* hle);
void alist_process_nead_wrjb(struct hle_t* hle);
void alist_process_nead_ys (struct hle_t* hle);
void alist_process_nead_1080(struct hle_t* hle);
void alist_process_nead_oot (struct hle_t* hle);
void alist_process_nead_mm (struct hle_t* hle);
void alist_process_nead_mmb (struct hle_t* hle);
void alist_process_nead_ac (struct hle_t* hle);
void alist_process_nead_mats(struct hle_t* hle);
void alist_process_nead_efz (struct hle_t* hle);
/* mp3 ucode */
void mp3_task(struct hle_t* hle, unsigned int index, uint32_t address);
/* musyx ucodes */
void musyx_v1_task(struct hle_t* hle);
void musyx_v2_task(struct hle_t* hle);
/* jpeg ucodes */
void jpeg_decode_PS0(struct hle_t* hle);
void jpeg_decode_PS(struct hle_t* hle);
void jpeg_decode_OB(struct hle_t* hle);
/* Resident evil 2 ucode */
void resize_bilinear_task(struct hle_t* hle);
void decode_video_frame_task(struct hle_t* hle);
void fill_video_double_buffer_task(struct hle_t* hle);
/* hvqm2 ucode */
void hvqm2_decode_sp1_task(struct hle_t* hle);
void hvqm2_decode_sp2_task(struct hle_t* hle);
#endif