Compare commits

...

45 commits

Author SHA1 Message Date
Richard Goedeken f6ff3719cb
Merge pull request #63 from Jj0YzL5nvJ/renor
Renormalize osal_dynamiclib_win32.c and more...
2024-05-26 20:00:08 -07:00
Richard Goedeken cab628428a
Merge pull request #62 from Jj0YzL5nvJ/up2024
CI/CD: Update to generic scripts, independent schedule, etc
2024-05-26 19:55:52 -07:00
Jj0YzL5nvJ c1230d85bb Renormalize osal_dynamiclib_win32.c, remove trailing whitespace and fix *.cmd files 2024-05-25 13:58:17 -06:00
Jj0YzL5nvJ 8ef80ad38f CI/CD: Update to generic scripts, independent schedule, etc 2024-05-24 11:16:50 -06:00
Richard Goedeken 0a4e30f560
Merge pull request #61 from Jj0YzL5nvJ/up2023
CI/CD: Add BLAKE2 hashfile
2023-06-11 12:19:02 -07:00
Jj0YzL5nvJ d8c4838977 CI/CD: Add BLAKE2 hashfile 2023-05-22 00:28:15 -06:00
Richard Goedeken b69e7de60c
Merge pull request #60 from Jj0YzL5nvJ/ci-schedule
CI/CD: Integrate scheduled builds and other...
2023-03-02 22:00:10 -08:00
Jj0YzL5nvJ 3e3cfe3296 CI/CD: Integrate scheduled builds and other necessary updates 2023-02-14 23:49:22 -06:00
Richard Goedeken 39f79201ba
Merge pull request #59 from Jj0YzL5nvJ/up2022
CI/CD: Update MSVC
2022-09-30 16:59:31 -07:00
Jj0YzL5nvJ c027650d3b CI/CD: Update MSVC 2022-09-27 23:51:24 -06:00
Richard Goedeken 8d2bd0372f
Merge pull request #58 from Jj0YzL5nvJ/ci-update
CI/CD: Update
2022-07-13 19:30:00 -07:00
Jj0YzL5nvJ 770094f7a0 CI/CD: Update 2022-07-10 18:51:59 -06:00
Richard Goedeken fe4ec7d39f
Merge pull request #57 from Jj0YzL5nvJ/ci-github
CI/CD: Implement GitHub Actions and public nightly builds
2022-04-11 20:55:04 -07:00
Jj0YzL5nvJ 90f96057b8 CI/CD: Implement GitHub Actions and public nightly builds 2021-12-05 09:00:25 -07:00
Richard Goedeken 11edb7a785
Merge pull request #56 from slide/master
Add Aarch64
2021-01-22 19:45:11 -08:00
Alex Earl 60afa914ba
Update Makefile 2021-01-20 02:32:08 +00:00
orbea d4adb3d0ad build: Allow out of tree builds. 2020-12-15 10:17:12 +01:00
Richard Goedeken 094c6642d0 Revert "Allow non-default compilers without resorting to symbolic links"
This reverts commit eea1ef3d06, as it conflicts with GNU make which always defines default values for certain variables
2020-09-16 22:39:13 -07:00
Richard Goedeken 48d57514f9
Merge pull request #51 from Jj0YzL5nvJ/alter_cc_cxx
Allow non-default compilers without resorting to symbolic links
2020-08-30 18:53:41 -07:00
Jj0YzL5nvJ eea1ef3d06 Allow non-default compilers without resorting to symbolic links 2020-08-30 03:50:56 -06:00
Richard Goedeken 75ba219c26
Merge pull request #50 from Jj0YzL5nvJ/alter
Allow to set custom platform toolset from commands
2020-08-19 23:36:29 -07:00
Jj0YzL5nvJ 98163ad8bb Allow to set custom platform toolset from commands 2020-08-13 12:02:15 -06:00
Richard Goedeken a961c711bf fix few more warnings 2020-05-27 21:13:21 -07:00
Richard Goedeken 06601cf6f5 fix GCC10 error 2020-05-26 20:59:30 -07:00
Richard Goedeken e49f1fe448
Merge pull request #46 from belegdol/master
Sync with latest upstream changes
2020-04-21 17:19:09 -07:00
Jj0YzL5nvJ 8cf7da57e3 AppVeyor with artifact packaging 2020-03-02 09:32:05 +01:00
Jj0YzL5nvJ 37dcafdcd2 Changes to have more generic project files + EOL normalization 2020-03-02 09:32:05 +01:00
Gillou68310 7b99972824 Migrate to VS2017 2019-11-13 17:14:06 +01:00
Julian Sikorski ec4bfd62bc Merge remote-tracking branch 'upstream/master' 2019-08-09 20:39:35 +02:00
Iconoclast 3e3034988b re-ordered XOR before AND in DMA bounds check
A sample micro-optimization that saves one instruction.
2019-08-06 23:12:55 -04:00
Julian Sikorski 502460a679 Fix implicit declaration of function 'init_regs' warning and subsequent undefined symbol issue 2019-07-17 20:17:13 +02:00
Julian Sikorski e4ae22295e Merge remote-tracking branch 'upstream/master' 2019-07-15 20:51:11 +02:00
Richard Goedeken 1836a433bb add function attributes so GCC can find bugs in calls to string formatting functions with variadic arguments 2019-03-03 09:25:18 -08:00
Richard Goedeken d8b4fbc806 fix travis CI builds for MXE platform 2019-02-16 22:35:50 -08:00
Iconoclast 2ea5951d80 Regulate undefined and defined states of RSP registers on boot.
Now with the correct file modification date set. :)
2018-12-19 01:12:14 -05:00
Iconoclast b3f3736b54 fixed unused symbol warnings 2018-12-18 19:51:51 -05:00
Iconoclast 143911c8e8 VMOV from VT[de], not VT[e].
Fixes #21.

In the face of all adversity to other sources indicating that the four-bit shuffling element specifier is recycled as a selector for the source element from VT, the only way to pass krom's hardware tests on the VMOV operation with operands illegal to standard RSP assembler was to replace this notion with the seemingly oversimplified read from `de` instead of `e`, even though that specifier is already in use as the selector for which destination slice to write to and not just read from.

Despite being removed from any references in the corresponding translation unit's functional implementation, the four-bit element shuffling mask is still in use as with all other vector operations for pre-shuffling VT[] before jumping into the vector operation interpreter function pointer table.

In addition, the MovIn register is also half-emulated.  It is not maintained as a global state machine attribute and only stores the final, hardware-accurate result that was already going to be copied into VD[] anyway rather than the preconceived result of a direct copy from VT[e].
2018-12-18 19:16:34 -05:00
Iconoclast e3c7f46090 refined optimization from bf7c98f to account for very high dividends
Fixes #19.

Disabling the optimized code is perhaps a temporary measure, but the more readable code under the #else clause should absolutely be kept.  The optimized version for 2's complement machines has however also been patched with a fix in case it becomes desirable to go back to enabling it for substantial speed gains.
2018-11-27 11:34:38 -05:00
Iconoclast 24195d94bf fixed a typo from c42ac84 in VCH's complements conversion
Resolves #18.
2018-11-26 23:34:56 -05:00
Iconoclast e4d3dc5031 fixed warning message spamming from running krom's test ROMs 2018-11-26 13:50:52 -05:00
Iconoclast 1f7c9fdc0f fixed regression from fixing VRCPL and VRSQL
Sign-extension is correct but only for single-precision reciprocal calculations.  Double-precision divides should still continue to mask in the zero-extended low 16 bits of the determined vector register slice if the previously executed divide instruction prepared a double-precision result rather than defining a single-precision one.
2018-11-25 17:35:40 -05:00
cxd4 cbfbe1a667
Merge pull request #17 from Zapeth/PR-opcodes-VRCPL-VRSQL
Fix VRCPL and VRSQL ops
2018-11-24 18:46:19 -05:00
cxd4 a08d5fac2f
Merge pull request #16 from Zapeth/PR-mingw-scripts
Add quotes to paths in MinGW build scripts (for paths with spaces)
2018-11-24 17:58:27 -05:00
Zapeth 11acc78f6e Fix VRCPL and VRSQL ops
Removed the unsigned cast for DivIn, now passes all tests of this test rom -> https://github.com/PeterLemon/N64/tree/master/RSPTest/CP2/VRCPL
2018-11-24 22:16:53 +01:00
Zapeth b06f3c5013 Add quotes to paths in MinGW build scripts (for paths with spaces) 2018-11-24 22:10:13 +01:00
17 changed files with 747 additions and 270 deletions

39
.gitattributes vendored Normal file
View file

@ -0,0 +1,39 @@
* 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
*.cmd text eol=crlf
*.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

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

@ -0,0 +1,162 @@
name: CXD4 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"
export PATH="$(pwd)/../mupen64plus-core/.github/workflows/scripts:${PATH}"
export CONFIG_OVERRIDE="SSE="SSE2""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
export OPTFLAGS="-O3 -flto"
export CONFIG_OVERRIDE="SSE="none""
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
export PATH="$(pwd)/../mupen64plus-core/.github/workflows/scripts:${PATH}"
export CONFIG_OVERRIDE="SSE="SSE2""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
export OPTFLAGS="-O3 -flto"
export CONFIG_OVERRIDE="SSE="none""
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/*

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

@ -0,0 +1,158 @@
name: CXD4 RSP - Scheduled
on:
schedule:
- cron: '35 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-cxd4'
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"
export PATH="$(pwd)/../mupen64plus-core/.github/workflows/scripts:${PATH}"
export CONFIG_OVERRIDE="SSE="SSE2""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
export OPTFLAGS="-O3 -flto"
export CONFIG_OVERRIDE="SSE="none""
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-cxd4'
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
export PATH="$(pwd)/../mupen64plus-core/.github/workflows/scripts:${PATH}"
export CONFIG_OVERRIDE="SSE="SSE2""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
export OPTFLAGS="-O3 -flto"
export CONFIG_OVERRIDE="SSE="none""
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-cxd4'
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/*

View file

@ -1,5 +1,5 @@
sudo: false
dist: trusty
dist: xenial
language: cpp
compiler:
- gcc
@ -23,15 +23,12 @@ matrix:
- env:
- MXE_CPU=i686
- PATH="/usr/lib/mxe/usr/bin/:$PATH"
addons:
apt:
sources:
- sourceline: 'deb http://pkg.mxe.cc/repos/apt/debian jessie main'
key_url: 'http://pkg.mxe.cc/repos/apt/conf/mxeapt.gpg'
packages:
- mxe-i686-w64-mingw32.shared-gcc
before_install:
- git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core
- 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
@ -39,14 +36,11 @@ matrix:
- env:
- MXE_CPU=x86_64
- PATH="/usr/lib/mxe/usr/bin/:$PATH"
addons:
apt:
sources:
- sourceline: 'deb http://pkg.mxe.cc/repos/apt/debian jessie main'
key_url: 'http://pkg.mxe.cc/repos/apt/conf/mxeapt.gpg'
packages:
- mxe-x86-64-w64-mingw32.shared-gcc
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 &&

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-cxd4.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-cxd4_v%rev1%_%rev2%
- cd projects\msvc\%platform%\%configuration%
- 7z a -t7z ..\..\..\..\build\%filepkg%.7z *.dll
artifacts:
- path: build\$(filepkg).7z
name: $(filepkg)

View file

@ -18,14 +18,14 @@ set rsp=%CD%
set obj=%rsp%\obj
set OBJ_LIST=^
%obj%\module.o ^
%obj%\su.o ^
%obj%\vu\vu.o ^
%obj%\vu\multiply.o ^
%obj%\vu\add.o ^
%obj%\vu\select.o ^
%obj%\vu\logical.o ^
%obj%\vu\divide.o
"%obj%\module.o"^
"%obj%\su.o"^
"%obj%\vu\vu.o"^
"%obj%\vu\multiply.o"^
"%obj%\vu\add.o"^
"%obj%\vu\select.o"^
"%obj%\vu\logical.o"^
"%obj%\vu\divide.o"
set FLAGS_ANSI=-Wall -pedantic^
-DPLUGIN_API_VERSION=0x0101^
@ -48,29 +48,29 @@ cd /D %bin%
ECHO Compiling C source code...
@ECHO ON
gcc -Os -S %C_FLAGS% -o %obj%\module.asm %rsp%\module.c
gcc -O3 -S %C_FLAGS% -o %obj%\su.asm %rsp%\su.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\vu.asm %rsp%\vu\vu.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\multiply.asm %rsp%\vu\multiply.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\add.asm %rsp%\vu\add.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\select.asm %rsp%\vu\select.c
gcc -O3 -S %C_FLAGS% -o %obj%\vu\logical.asm %rsp%\vu\logical.c
gcc -O2 -S %C_FLAGS% -o %obj%\vu\divide.asm %rsp%\vu\divide.c
gcc -Os -S %C_FLAGS% -o "%obj%\module.asm" "%rsp%\module.c"
gcc -O3 -S %C_FLAGS% -o "%obj%\su.asm" "%rsp%\su.c"
gcc -O3 -S %C_FLAGS% -o "%obj%\vu\vu.asm" "%rsp%\vu\vu.c"
gcc -O3 -S %C_FLAGS% -o "%obj%\vu\multiply.asm" "%rsp%\vu\multiply.c"
gcc -O3 -S %C_FLAGS% -o "%obj%\vu\add.asm" "%rsp%\vu\add.c"
gcc -O3 -S %C_FLAGS% -o "%obj%\vu\select.asm" "%rsp%\vu\select.c"
gcc -O3 -S %C_FLAGS% -o "%obj%\vu\logical.asm" "%rsp%\vu\logical.c"
gcc -O2 -S %C_FLAGS% -o "%obj%\vu\divide.asm" "%rsp%\vu\divide.c"
@ECHO OFF
ECHO.
ECHO Assembling compiled sources...
as -o %obj%\module.o %obj%\module.asm
as -o %obj%\su.o %obj%\su.asm
as -o %obj%\vu\vu.o %obj%\vu\vu.asm
as -o %obj%\vu\multiply.o %obj%\vu\multiply.asm
as -o %obj%\vu\add.o %obj%\vu\add.asm
as -o %obj%\vu\select.o %obj%\vu\select.asm
as -o %obj%\vu\logical.o %obj%\vu\logical.asm
as -o %obj%\vu\divide.o %obj%\vu\divide.asm
as -o "%obj%\module.o" "%obj%\module.asm"
as -o "%obj%\su.o" "%obj%\su.asm"
as -o "%obj%\vu\vu.o" "%obj%\vu\vu.asm"
as -o "%obj%\vu\multiply.o" "%obj%\vu\multiply.asm"
as -o "%obj%\vu\add.o" "%obj%\vu\add.asm"
as -o "%obj%\vu\select.o" "%obj%\vu\select.asm"
as -o "%obj%\vu\logical.o" "%obj%\vu\logical.asm"
as -o "%obj%\vu\divide.o" "%obj%\vu\divide.asm"
ECHO.
ECHO Linking assembled object files...
ld --shared -e _DllMain@12 -o %obj%\rspdebug.dll -L %lib% %OBJ_LIST% -lmsvcrt
strip -o %obj%\rsp.dll %obj%\rspdebug.dll --strip-all
ld --shared -e _DllMain@12 -o "%obj%\rspdebug.dll" -L %lib% %OBJ_LIST% -lmsvcrt
strip -o "%obj%\rsp.dll" "%obj%\rspdebug.dll" --strip-all
PAUSE

View file

@ -22,14 +22,14 @@ set rsp=%CD%
set obj=%rsp%\obj
set OBJ_LIST=^
%obj%\module.o ^
%obj%\su.o ^
%obj%\vu\vu.o ^
%obj%\vu\multiply.o ^
%obj%\vu\add.o ^
%obj%\vu\select.o ^
%obj%\vu\logical.o ^
%obj%\vu\divide.o
"%obj%\module.o"^
"%obj%\su.o"^
"%obj%\vu\vu.o"^
"%obj%\vu\multiply.o"^
"%obj%\vu\add.o"^
"%obj%\vu\select.o"^
"%obj%\vu\logical.o"^
"%obj%\vu\divide.o"
set FLAGS_ANSI=-Wall -pedantic^
-DPLUGIN_API_VERSION=0x0101^
@ -52,29 +52,29 @@ cd /D %bin%
ECHO Compiling C source code...
@ECHO ON
gcc -S -Os %C_FLAGS% -o %obj%\module.asm %rsp%\module.c
gcc -S -O3 %C_FLAGS% -o %obj%\su.asm %rsp%\su.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\vu.asm %rsp%\vu\vu.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\multiply.asm %rsp%\vu\multiply.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\add.asm %rsp%\vu\add.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\select.asm %rsp%\vu\select.c
gcc -S -O3 %C_FLAGS% -o %obj%\vu\logical.asm %rsp%\vu\logical.c
gcc -S -O2 %C_FLAGS% -o %obj%\vu\divide.asm %rsp%\vu\divide.c
gcc -S -Os %C_FLAGS% -o "%obj%\module.asm" "%rsp%\module.c"
gcc -S -O3 %C_FLAGS% -o "%obj%\su.asm" "%rsp%\su.c"
gcc -S -O3 %C_FLAGS% -o "%obj%\vu\vu.asm" "%rsp%\vu\vu.c"
gcc -S -O3 %C_FLAGS% -o "%obj%\vu\multiply.asm" "%rsp%\vu\multiply.c"
gcc -S -O3 %C_FLAGS% -o "%obj%\vu\add.asm" "%rsp%\vu\add.c"
gcc -S -O3 %C_FLAGS% -o "%obj%\vu\select.asm" "%rsp%\vu\select.c"
gcc -S -O3 %C_FLAGS% -o "%obj%\vu\logical.asm" "%rsp%\vu\logical.c"
gcc -S -O2 %C_FLAGS% -o "%obj%\vu\divide.asm" "%rsp%\vu\divide.c"
@ECHO OFF
ECHO.
ECHO Assembling compiled sources...
as -o %obj%\module.o %obj%\module.asm
as -o %obj%\su.o %obj%\su.asm
as -o %obj%\vu\vu.o %obj%\vu\vu.asm
as -o %obj%\vu\multiply.o %obj%\vu\multiply.asm
as -o %obj%\vu\add.o %obj%\vu\add.asm
as -o %obj%\vu\select.o %obj%\vu\select.asm
as -o %obj%\vu\logical.o %obj%\vu\logical.asm
as -o %obj%\vu\divide.o %obj%\vu\divide.asm
as -o "%obj%\module.o" "%obj%\module.asm"
as -o "%obj%\su.o" "%obj%\su.asm"
as -o "%obj%\vu\vu.o" "%obj%\vu\vu.asm"
as -o "%obj%\vu\multiply.o" "%obj%\vu\multiply.asm"
as -o "%obj%\vu\add.o" "%obj%\vu\add.asm"
as -o "%obj%\vu\select.o" "%obj%\vu\select.asm"
as -o "%obj%\vu\logical.o" "%obj%\vu\logical.asm"
as -o "%obj%\vu\divide.o" "%obj%\vu\divide.asm"
ECHO.
ECHO Linking assembled object files...
ld --shared -e DllMain -o %obj%\rspdebug.dll -L%lib64% %OBJ_LIST% -lmsvcrt
strip -o %obj%\rsp.dll %obj%\rspdebug.dll --strip-all
ld --shared -e DllMain -o "%obj%\rspdebug.dll" -L%lib64% %OBJ_LIST% -lmsvcrt
strip -o "%obj%\rsp.dll" "%obj%\rspdebug.dll" --strip-all
PAUSE

109
module.c
View file

@ -1,7 +1,7 @@
/******************************************************************************\
* Project: Module Subsystem Interface to SP Interpreter Core *
* Authors: Iconoclast *
* Release: 2018.03.21 *
* Release: 2018.12.18 *
* License: CC0 Public Domain Dedication *
* *
* To the extent possible under law, the author(s) have dedicated all copyright *
@ -17,6 +17,9 @@
#include <stdlib.h>
#include <string.h>
/* time() (for helping srand()) */
#include <time.h>
#ifdef WIN32
#include <windows.h>
#endif
@ -28,9 +31,17 @@
#include "module.h"
#include "su.h"
#include "m64p_common.h"
#include <signal.h>
#include <setjmp.h>
#if defined(__GNUC__)
#define ATTR_FMT(fmtpos, attrpos) __attribute__ ((format (printf, fmtpos, attrpos)))
#else
#define ATTR_FMT(fmtpos, attrpos)
#endif
static jmp_buf CPU_state;
static void seg_av_handler(int signal_code)
{
@ -83,7 +94,9 @@ NOINLINE void update_conf(const char* source)
CFG_MEND_SEMAPHORE_LOCK = ConfigGetParamBool(l_ConfigRsp, "SupportCPUSemaphoreLock");
}
static void DebugMessage(int level, const char *message, ...)
static void DebugMessage(int level, const char *message, ...) ATTR_FMT(2, 3);
void DebugMessage(int level, const char *message, ...)
{
char msgbuf[1024];
va_list args;
@ -236,6 +249,88 @@ static const char DLL_about[] =
"Thanks for test RDP: Jabo, ziggy, angrylion\n"\
"RSP driver examples: bpoint, zilmar, Ville Linde";
#endif
static void init_regs(void)
{
register size_t i, j;
for (i = 0; i < 16; i++)
if (CR[i] == NULL)
raise(SIGTERM); /* Don't proceed if plugin hasn't initialized. */
srand(time(NULL));
for (i = 0; i < N; i++) {
VACC_H[i] = ((u64)0xFFFF00000000 >> 32) & 0x0000;
VACC_M[i] = ((u64)0x0000FFFF0000 >> 16) & 0x0000;
VACC_L[i] = ((u64)0x00000000FFFF >> 0) & 0x0000;
}
#if 0
DPH = SP_DIV_PRECISION_SINGLE; /* static global maintained in vu/divide.o */
#endif
/*
* Based on krom's experiences at testing the RSP hardware with homebrew, it
* has become apparent that the bits in $vco, $vcc and $vce do NOT become
* random upon powering on the console. However, this does not say that
* previous values of these flags aren't momentarily preserved before any
* bit rot loses them overtime. Since it's not clear whether these flags are
* explicitly initialized to 0 at power-on or if they temporarily retain old
* decaying bits, we'll just make them 0 to hush krom's RSP test FAIL yells.
*/
for (i = 0; i < N; i++) {
cf_ne[i] = (rand() & (1 << 15)) ? 0*TRUE : FALSE;
cf_co[i] = (rand() & (1 << 12)) ? 0*TRUE : FALSE;
cf_clip[i] = (rand() & (1 << 9)) ? 0*TRUE : FALSE;
cf_comp[i] = (rand() & (1 << 6)) ? 0*TRUE : FALSE;
cf_vce[i] = (rand() & (1 << 0)) ? 0*TRUE : FALSE;
}
for (i = 0; i < 32; i++)
SR[i] = (u32)rand();
SR[0] = 0x00000000;
for (i = 0; i < 32; i++)
for (j = 0; j < N; j++)
VR[i][j] = (u16)((u32)rand() & 0xFFFFu);
*(RSP_INFO_NAME.SP_PC_REG) = 0x04001000;
*CR[0x0] = 0x00000000; /* DMA transfer address for SP memory cache */
*CR[0x1] = 0x00000000; /* DMA transfer address for host DRAM */
*CR[0x2] = 0x00000000; /* DMA read transfer period */
*CR[0x3] = 0x00000000; /* DMA write transfer period */
*CR[0x4] = 0x00000001; /* SP status flags */
*CR[0x5] = 0x00000000; /* read-only DMA full indicator */
*CR[0x6] = 0x00000000; /* read-only DMA busy indicator */
*CR[0x7] = 0x00000000; /* CPU-RSP synchronicity semaphore */
*CR[0x8] = (u32)rand(); /* start address of RDP command buffer */
*CR[0x9] = (u32)rand(); /* end address of RDP command buffer */
*CR[0xA] = 0x00000000; /* read-only current RDP command buffer address */
*CR[0xB] &= 0x100; /* DP status flags: DMA_BUSY flag is undefined. */
*CR[0xC] = 0x0000FFFF; /* RDP clock cycle counter */
/*
* Technically these are random at startup on the hardware, but most emulators
* fail to ever clear these locks if randomly set, causing constant warnings.
*/
#if 0
*CR[0xD] = (u32)rand(); /* read-only RDP contiguous busy buffer cycles */
*CR[0xE] = (u32)rand(); /* read-only RDP contiguous busy pipe cycles */
#endif
*CR[0xF] = (u32)rand(); /* read-only RDP contiguous TMEM import cycles */
*CR[0xB] |= 0x000000A8; /* GCLK, PIPE_BUSY and CMD_BUF_READY always set */
#if 0
*CR[0xB] |= (irand() & 1) << 8; /* DP DMA busy status bit is undefined. */
#endif
*CR[0xC] += *CR[0xD] + *CR[0xE] + *CR[0xF]; /* random total clock cycles */
}
#if !defined(M64P_PLUGIN_API)
EXPORT void CALL CloseDLL(void)
{
DRAM = NULL; /* so DllTest benchmark doesn't think ROM is still open */
@ -360,6 +455,8 @@ EXPORT unsigned int CALL DoRspCycles(unsigned int cycles)
GET_RSP_INFO(ShowCFB)(); /* forced FB refresh in case gfx plugin skip */
break;
default:
if (task_type == 0x00000000)
break; /* generic or invoked without CPU filling in OSTask struct */
if (task_type == 0x8BC43B5D)
break; /* CIC boot code sent to the RSP */
sprintf(task_debug_type, "%08lX", (unsigned long)task_type);
@ -379,7 +476,7 @@ EXPORT unsigned int CALL DoRspCycles(unsigned int cycles)
* to finally empty the MM state, at the end of a long interpreter loop.
*/
#ifdef ARCH_MIN_SSE2
_mm_empty();
//_mm_empty();
#endif
if (*CR[0x4] & SP_STATUS_BROKE) /* normal exit, from executing BREAK */
@ -403,7 +500,7 @@ EXPORT unsigned int CALL DoRspCycles(unsigned int cycles)
EXPORT void CALL GetDllInfo(PLUGIN_INFO *PluginInfo)
{
PluginInfo -> Version = PLUGIN_API_VERSION;
PluginInfo -> Version = (u16) PLUGIN_API_VERSION;
PluginInfo -> Type = PLUGIN_TYPE_RSP;
strcpy(PluginInfo -> Name, "Static Interpreter");
PluginInfo -> NormalMemory = 0;
@ -445,7 +542,6 @@ EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, pu32 CycleCount)
CR[0x5] = &GET_RCP_REG(SP_DMA_FULL_REG);
CR[0x6] = &GET_RCP_REG(SP_DMA_BUSY_REG);
CR[0x7] = &GET_RCP_REG(SP_SEMAPHORE_REG);
*(RSP_INFO_NAME.SP_PC_REG) = 0x04001000;
CR[0x8] = &GET_RCP_REG(DPC_START_REG);
CR[0x9] = &GET_RCP_REG(DPC_END_REG);
CR[0xA] = &GET_RCP_REG(DPC_CURRENT_REG);
@ -454,6 +550,7 @@ EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, pu32 CycleCount)
CR[0xD] = &GET_RCP_REG(DPC_BUFBUSY_REG);
CR[0xE] = &GET_RCP_REG(DPC_PIPEBUSY_REG);
CR[0xF] = &GET_RCP_REG(DPC_TMEM_REG);
init_regs();
MF_SP_STATUS_TIMEOUT = 32767;
#if 1
@ -540,7 +637,7 @@ NOINLINE void message(const char* body)
NOINLINE void message(const char* body)
{
#if defined(M64P_PLUGIN_API)
DebugMessage(M64MSG_ERROR, body);
DebugMessage(M64MSG_ERROR, "%s", body);
#else
printf("%s\n", body);
#endif

View file

@ -1,74 +1,74 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 "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);
fprintf(stderr, "LoadLibrary('%s') error: %s\n", 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);
fprintf(stderr, "FreeLibrary() error: %s\n", pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INTERNAL;
}
return M64ERR_SUCCESS;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 "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);
fprintf(stderr, "LoadLibrary('%s') error: %s\n", 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);
fprintf(stderr, "FreeLibrary() error: %s\n", pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INTERNAL;
}
return M64ERR_SUCCESS;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -46,30 +46,41 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{F597CC21-12F9-459F-A257-38BD7F102BC8}</ProjectGuid>
<RootNamespace>mupen64plusrspcxd4</RootNamespace>
<Keyword>Win32Proj</Keyword>
</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>
<PlatformToolset>v120</PlatformToolset>
<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>
<PlatformToolset>v120</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -87,47 +98,18 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<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;ARCH_MIN_SSE2;M64P_PLUGIN_API;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -137,11 +119,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;ARCH_MIN_SSE2;M64P_PLUGIN_API;__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -153,18 +131,16 @@
<AdditionalIncludeDirectories>..\..\..\mupen64plus-core\src\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;ARCH_MIN_SSE2;M64P_PLUGIN_API;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -172,11 +148,10 @@
<AdditionalIncludeDirectories>..\..\..\mupen64plus-core\src\api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;inline=__inline;ARCH_MIN_SSE2;M64P_PLUGIN_API;__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View file

@ -111,20 +111,19 @@ ifneq ("$(filter arm%,$(HOST_CPU))","")
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
endif
ifneq ("$(filter arm64 aarch64,$(HOST_CPU))","")
CPU := AARCH64
ARCH_DETECTED := 64BITS
PIC ?= 1
$(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
ifeq ("$(CPU)","NONE")
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'https://github.com/mupen64plus/mupen64plus-core/issues')
endif
# base CFLAGS, LDLIBS, and LDFLAGS
OPTFLAGS ?= -O3 -flto
WARNFLAGS ?= -Wall
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -fvisibility=hidden -I../../
CPPFLAGS += -DM64P_PLUGIN_API
LDFLAGS += $(SHARED)
ifeq ($(CPU), X86)
SSE ?= SSE2
ifeq ($(SSE), SSE2)
ifeq ("$(SSE)", "SSE2")
CFLAGS += -msse2
CPPFLAGS += -DARCH_MIN_SSE2
POSTFIX = -sse2
@ -132,6 +131,16 @@ ifeq ($(CPU), X86)
CFLAGS += -mstackrealign
endif
SRCDIR = ../../
OBJDIR = _obj$(POSTFIX)
# base CFLAGS, LDLIBS, and LDFLAGS
OPTFLAGS ?= -O3 -flto
WARNFLAGS ?= -Wall
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -fvisibility=hidden -I$(SRCDIR)
CPPFLAGS += -DM64P_PLUGIN_API
LDFLAGS += $(SHARED)
ifeq ($(NEON), 1)
CFLAGS += -mfpu=neon
CPPFLAGS += -DUSE_SSE2NEON
@ -161,8 +170,20 @@ 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 -Wl,-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
@ -247,9 +268,6 @@ ifeq ($(PLUGINDIR),)
PLUGINDIR := $(LIBDIR)/mupen64plus
endif
SRCDIR = ../../
OBJDIR = _obj$(POSTFIX)
# list of source files to compile
SOURCE = \
$(SRCDIR)/su.c \
@ -279,11 +297,11 @@ TARGET = mupen64plus-rsp-cxd4$(POSTFIX).$(SO_EXTENSION)
targets:
@echo "Mupen64Plus-rsp-cxd4 makefile. "
@echo " Targets:"
@echo " all == Build Mupen64Plus rsp-hle plugin"
@echo " all == Build Mupen64Plus rsp-cxd4 plugin"
@echo " clean == remove object files"
@echo " rebuild == clean and re-build all"
@echo " install == Install Mupen64Plus rsp-hle plugin"
@echo " uninstall == Uninstall Mupen64Plus rsp-hle plugin"
@echo " install == Install Mupen64Plus rsp-cxd4 plugin"
@echo " uninstall == Uninstall Mupen64Plus rsp-cxd4 plugin"
@echo " Options:"
@echo " BITS=32 == build 32-bit binaries on 64-bit machine"
@echo " APIDIR=path == path to find Mupen64Plus Core headers"
@ -314,7 +332,7 @@ uninstall:
$(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
clean:
$(RM) -r $(OBJDIR) $(TARGET)
$(RM) -r _obj _obj-sse2 $(OBJDIR) mupen64plus-rsp-cxd4*.$(SO_EXTENSION) $(TARGET)
rebuild: clean all

31
su.c
View file

@ -1,7 +1,7 @@
/******************************************************************************\
* Project: MSP Simulation Layer for Scalar Unit Operations *
* Authors: Iconoclast *
* Release: 2018.03.17 *
* Release: 2019.08.06 *
* License: CC0 Public Domain Dedication *
* *
* To the extent possible under law, the author(s) have dedicated all copyright *
@ -34,6 +34,8 @@ pu8 DMEM;
pu8 IMEM;
unsigned long su_max_address = 0x007FFFFFul;
static int temp_PC;
NOINLINE void res_S(void)
{
message("RESERVED.");
@ -243,7 +245,7 @@ void SP_DMA_READ(void)
} while (i < length);
} while (count);
if ((*CR[0x0] & 0x1000) ^ (offC & 0x1000))
if ((*CR[0x0] ^ offC) & 0x1000)
message("DMA over the DMEM-to-IMEM gap.");
GET_RCP_REG(SP_DMA_BUSY_REG) = 0x00000000;
GET_RCP_REG(SP_STATUS_REG) &= ~SP_STATUS_DMA_BUSY;
@ -281,7 +283,7 @@ void SP_DMA_WRITE(void)
} while (i < length);
} while (count);
if ((*CR[0x0] & 0x1000) ^ (offC & 0x1000))
if ((*CR[0x0] ^ offC) & 0x1000)
message("DMA over the DMEM-to-IMEM gap.");
GET_RCP_REG(SP_DMA_BUSY_REG) = 0x00000000;
GET_RCP_REG(SP_STATUS_REG) &= ~SP_STATUS_DMA_BUSY;
@ -1644,7 +1646,6 @@ void STV(unsigned vt, unsigned element, signed offset, unsigned base)
return;
}
int temp_PC;
#ifdef WAIT_FOR_CPU_HOST
short MFC0_count[NUMBER_OF_SCALAR_REGISTERS];
#endif
@ -1662,27 +1663,6 @@ mwc2_func SWC2[2 * 8*2] = {
res_lsw,res_lsw,res_lsw,res_lsw,res_lsw,res_lsw,res_lsw,res_lsw,
};
static ALIGNED i16 shuffle_temporary[N];
#ifndef ARCH_MIN_SSE2
static const unsigned char ei[1 << 4][N] = {
{ 00, 01, 02, 03, 04, 05, 06, 07 }, /* none (vector-only operand) */
{ 00, 01, 02, 03, 04, 05, 06, 07 },
{ 00, 00, 02, 02, 04, 04, 06, 06 }, /* 0Q */
{ 01, 01, 03, 03, 05, 05, 07, 07 }, /* 1Q */
{ 00, 00, 00, 00, 04, 04, 04, 04 }, /* 0H */
{ 01, 01, 01, 01, 05, 05, 05, 05 }, /* 1H */
{ 02, 02, 02, 02, 06, 06, 06, 06 }, /* 2H */
{ 03, 03, 03, 03, 07, 07, 07, 07 }, /* 3H */
{ 00, 00, 00, 00, 00, 00, 00, 00 }, /* 0W */
{ 01, 01, 01, 01, 01, 01, 01, 01 }, /* 1W */
{ 02, 02, 02, 02, 02, 02, 02, 02 }, /* 2W */
{ 03, 03, 03, 03, 03, 03, 03, 03 }, /* 3W */
{ 04, 04, 04, 04, 04, 04, 04, 04 }, /* 4W */
{ 05, 05, 05, 05, 05, 05, 05, 05 }, /* 5W */
{ 06, 06, 06, 06, 06, 06, 06, 06 }, /* 6W */
{ 07, 07, 07, 07, 07, 07, 07, 07 }, /* 7W */
};
#endif
PROFILE_MODE int SPECIAL(u32 inst, u32 PC)
{
@ -1873,6 +1853,7 @@ PROFILE_MODE void COP2(u32 inst)
#endif
switch (op) {
static ALIGNED i16 shuffle_temporary[N];
#ifdef ARCH_MIN_SSE2
v16 target;
#else

3
su.h
View file

@ -155,7 +155,6 @@ extern u32 SR[];
int stage;
#endif
extern int temp_PC;
#ifdef WAIT_FOR_CPU_HOST
extern short MFC0_count[];
/* Keep one C0 MF status read count for each scalar register. */
@ -268,7 +267,7 @@ extern void set_PC(unsigned int address);
#define SP_STATUS_SIG6 (0x00000001ul << 13)
#define SP_STATUS_SIG7 (0x00000001ul << 14)
enum {
typedef enum {
RCP_SP_MEM_ADDR_REG,
RCP_SP_DRAM_ADDR_REG,
RCP_SP_RD_LEN_REG,

View file

@ -13,6 +13,8 @@
* If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. *
\******************************************************************************/
#include <string.h>
#include "add.h"
#ifdef ARCH_MIN_SSE2
@ -161,7 +163,8 @@ INLINE static void do_abs(pi16 VD, pi16 VS, pi16 VT)
neg[i] = (VS[i] < 0x0000);
for (i = 0; i < N; i++)
pos[i] = (VS[i] > 0x0000);
vector_wipe(nez);
//vector_wipe(nez);
memset(&nez, 0, sizeof(nez));
for (i = 0; i < N; i++)
nez[i] -= neg[i];

View file

@ -1,7 +1,7 @@
/******************************************************************************\
* Project: MSP Simulation Layer for Vector Unit Computational Divides *
* Authors: Iconoclast *
* Release: 2016.03.23 *
* Release: 2018.12.18 *
* License: CC0 Public Domain Dedication *
* *
* To the extent possible under law, the author(s) have dedicated all copyright *
@ -17,9 +17,15 @@
static s32 DivIn = 0; /* buffered numerator of division read from vector file */
static s32 DivOut = 0; /* global division result set by VRCP/VRCPL/VRSQ/VRSQL */
#if (0 != 0)
static s32 MovIn; /* We do not emulate this register (obsolete, for VMOV). */
#endif
enum {
SP_DIV_SQRT_NO,
SP_DIV_SQRT_YES
};
enum {
SP_DIV_PRECISION_SINGLE = 0,
SP_DIV_PRECISION_DOUBLE = ~0
};
/*
* Boolean flag: Double-precision high was the last vector divide op?
@ -31,7 +37,7 @@ static s32 MovIn; /* We do not emulate this register (obsolete, for VMOV). */
* else if (lastDivideOp == VMOV, VNOP)
* DPH = DPH; // no change--divide-group ops but not real divides
*/
static int DPH = 0;
static int DPH = SP_DIV_PRECISION_SINGLE;
/*
* 11-bit vector divide result look-up table
@ -1064,30 +1070,21 @@ static const u16 div_ROM[1 << 10] = {
0x6A64u,
};
enum {
SP_DIV_SQRT_NO,
SP_DIV_SQRT_YES
};
enum {
SP_DIV_PRECISION_SINGLE = 0,
SP_DIV_PRECISION_DOUBLE = ~0
/*, SP_DIV_PRECISION_CURRENT */
};
NOINLINE static void do_div(i32 data, int sqrt, int precision)
{
i32 addr;
int fetch;
int shift;
#if (~0 >> 1 == -1)
data ^= (s32)(data + 32768) >> 31; /* DP only: (data < -32768) */
fetch = (s32)(data + 0) >> 31;
#if ((~0 >> 1 == -1) && (0))
int fetch;
data ^= (s32)(((s64)data + 32768) >> 63); /* DP only: (data < -32768) */
fetch = (s32)(((s32)data + 0) >> 31);
data ^= fetch;
data -= fetch; /* two's complement: -x == ~x - (~0) on wrap-around */
#else
if (precision == SP_DIV_PRECISION_SINGLE)
data = (data < 0) ? -data : +data;
data = (data < 0) ? -data : +data;
if (precision == SP_DIV_PRECISION_DOUBLE && data < 0)
data = (data >= -32768) ? -data : ~data;
#endif
@ -1156,8 +1153,10 @@ VECTOR_OPERATION VRCPL(v16 vs, v16 vt)
const int target = (inst_word >> 16) & 31;
const unsigned int element = (inst_word >> 21) & 0x7;
DivIn &= DPH;
DivIn |= (u16)VR[target][element];
if (DPH == SP_DIV_PRECISION_SINGLE)
DivIn = (s32)(s16)(VR[target][element]);
else
DivIn |= (s32)(u16)(VR[target][element] & 0xFFFFu);
do_div(DivIn, SP_DIV_SQRT_NO, DPH);
#ifdef ARCH_MIN_SSE2
*(v16 *)VACC_L = vt;
@ -1205,16 +1204,20 @@ VECTOR_OPERATION VRCPH(v16 vs, v16 vt)
VECTOR_OPERATION VMOV(v16 vs, v16 vt)
{
i32 MovIn;
const int result = (inst_word & 0x000007FF) >> 6;
const int source = (inst_word & 0x0000FFFF) >> 11;
const unsigned int element = (inst_word >> 21) & 0x7;
#ifdef ARCH_MIN_SSE2
*(v16 *)VACC_L = vt;
MovIn = VACC_L[source & 07]; /* _mm_extract_epi16(vt, source & 0x07); */
#else
MovIn = vt[source & 07];
vector_copy(VACC_L, vt);
#endif
VR[result][source & 07] = VACC_L[element];
VR[result][source & 07] = (i16)(MovIn & 0x0000FFFF);
#ifdef ARCH_MIN_SSE2
COMPILER_FENCE();
vs = *(v16 *)VR[result];
@ -1260,8 +1263,10 @@ VECTOR_OPERATION VRSQL(v16 vs, v16 vt)
const int target = (inst_word >> 16) & 31;
const unsigned int element = (inst_word >> 21) & 0x7;
DivIn &= DPH;
DivIn |= (u16)VR[target][element];
if (DPH == SP_DIV_PRECISION_SINGLE)
DivIn = (s32)(s16)(VR[target][element]);
else
DivIn |= (s32)(u16)(VR[target][element] & 0xFFFFu);
do_div(DivIn, SP_DIV_SQRT_YES, DPH);
#ifdef ARCH_MIN_SSE2
*(v16 *)VACC_L = vt;

View file

@ -1,7 +1,7 @@
/******************************************************************************\
* Project: MSP Simulation Layer for Vector Unit Computational Test Selects *
* Authors: Iconoclast *
* Release: 2018.03.18 *
* Release: 2018.11.26 *
* License: CC0 Public Domain Dedication *
* *
* To the extent possible under law, the author(s) have dedicated all copyright *
@ -245,10 +245,16 @@ INLINE static void do_ch(pi16 VD, pi16 VS, pi16 VT)
cf_vce[i] = (VS[i] == VC[i]); /* 2's complement: VC = -VT - 1 = ~VT */
for (i = 0; i < N; i++)
cf_vce[i] &= sn[i];
/*
* if (sign flag), then converts ~(VT) into -(VT) a.k.a. ~(VT) - (-1)
* Note that if (VT == INT16_MIN) a.k.a. cch[i], -(-32768) is undefined.
*/
for (i = 0; i < N; i++)
VC[i] -= sn[i] & cch[i]; /* converts ~(VT) into -(VT) if (sign) */
VC[i] -= sn[i] & ~cch[i]; /* cch[i] causes -(-32768) to stay ~-32768. */
for (i = 0; i < N; i++)
eq[i] = (VS[i] == VC[i]) & ~cch[i]; /* (VS == +32768) is never true. */
eq[i] = (VS[i] == VC[i]) & ~cch[i]; /* VS = -(-32768) never happens. */
for (i = 0; i < N; i++)
eq[i] |= cf_vce[i];