mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-30 08:23:01 +00:00
Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt
* 'master' of https://github.com/tildearrow/furnace: (58 commits) SMS: early Nuked-PSG modding SMS: add modified Nuked-PSG core build release and don't strip strip MinGW builds FDS: a bit more FDS: set a post-amp value FDS: fix NSFplay core low pass filter precision fix .dmf saving fix compilation on GCC 12 Fix multithreading on CI Lynx: why did I not commit this Lynx: more sample improvements Lynx: sample improvements Lynx: add sample support! GUI: fix wavetable list oversight WaveSynth: fix phase modulation - again GUI: fix possible wave editor crash WaveSynth: fix phase modulation Lynx: add phase reset macro fix another fucking IGFD crash bug ... # Conflicts: # src/gui/insEdit.cpp # src/gui/presets.cpp
This commit is contained in:
commit
cbf20c6320
116 changed files with 8748 additions and 857 deletions
35
.github/workflows/build.yml
vendored
35
.github/workflows/build.yml
vendored
|
@ -93,14 +93,10 @@ jobs:
|
||||||
id: build-cores
|
id: build-cores
|
||||||
run: |
|
run: |
|
||||||
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
|
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
|
||||||
set amount=2
|
amount=2
|
||||||
if [ '${{ runner.os }}' == 'macOS' ]; then
|
if [ '${{ runner.os }}' == 'macOS' ]; then
|
||||||
amount=3
|
amount=3
|
||||||
fi
|
fi
|
||||||
# the Actions runner does not seem to be happy with two jobs at once on MinGW
|
|
||||||
if [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
|
|
||||||
amount=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Amount of cores we can build with: ${amount}"
|
echo "Amount of cores we can build with: ${amount}"
|
||||||
|
|
||||||
|
@ -229,17 +225,18 @@ jobs:
|
||||||
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
|
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
|
||||||
binPath="${binPath}/${{ env.BUILD_TYPE }}"
|
binPath="${binPath}/${{ env.BUILD_TYPE }}"
|
||||||
fi
|
fi
|
||||||
if [ '${{ matrix.config.compiler }}' == 'mingw' ] && [ '${{ env.BUILD_TYPE }}' == 'Release' ]; then
|
# always strip on MinGW as it generate massive artifacts
|
||||||
# arch-specific strip prefix
|
#if [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
|
||||||
# TODO maybe extract from cross toolchain files?
|
# # arch-specific strip prefix
|
||||||
toolPrefix="-w64-mingw32-"
|
# # TODO maybe extract from cross toolchain files?
|
||||||
if [ '${{ matrix.config.arch }}' == 'x86_64' ]; then
|
# toolPrefix="-w64-mingw32-"
|
||||||
toolPrefix="x86_64${toolPrefix}"
|
# if [ '${{ matrix.config.arch }}' == 'x86_64' ]; then
|
||||||
else
|
# toolPrefix="x86_64${toolPrefix}"
|
||||||
toolPrefix="i686${toolPrefix}"
|
# else
|
||||||
fi
|
# toolPrefix="i686${toolPrefix}"
|
||||||
${toolPrefix}strip -s "${binPath}/furnace.exe"
|
# fi
|
||||||
fi
|
# ${toolPrefix}strip -s "${binPath}/furnace.exe"
|
||||||
|
#fi
|
||||||
|
|
||||||
mkdir ${{ steps.package-identify.outputs.filename }}
|
mkdir ${{ steps.package-identify.outputs.filename }}
|
||||||
pushd ${{ steps.package-identify.outputs.filename }}
|
pushd ${{ steps.package-identify.outputs.filename }}
|
||||||
|
@ -261,9 +258,9 @@ jobs:
|
||||||
- name: Package [Ubuntu]
|
- name: Package [Ubuntu]
|
||||||
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
|
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
|
||||||
run: |
|
run: |
|
||||||
if [ '${{ env.BUILD_TYPE }}' == 'Release' ]; then
|
#if [ '${{ env.BUILD_TYPE }}' == 'Release' ]; then
|
||||||
strip -s build/furnace
|
# strip -s build/furnace
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
mkdir -p target/furnace.AppDir
|
mkdir -p target/furnace.AppDir
|
||||||
make -C ${PWD}/build DESTDIR=${PWD}/target/furnace.AppDir install
|
make -C ${PWD}/build DESTDIR=${PWD}/target/furnace.AppDir install
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
.vscode/
|
.vscode/
|
||||||
build/
|
build/
|
||||||
|
nosdl/
|
||||||
release/
|
release/
|
||||||
t/
|
t/
|
||||||
winbuild/
|
winbuild/
|
||||||
|
|
|
@ -18,12 +18,16 @@ set(CMAKE_PROJECT_VERSION_MINOR 6)
|
||||||
set(CMAKE_PROJECT_VERSION_PATCH 0)
|
set(CMAKE_PROJECT_VERSION_PATCH 0)
|
||||||
|
|
||||||
set(BUILD_GUI_DEFAULT ON)
|
set(BUILD_GUI_DEFAULT ON)
|
||||||
|
set(USE_SDL2_DEFAULT ON)
|
||||||
|
set(USE_SNDFILE_DEFAULT ON)
|
||||||
set(SYSTEM_SDL2_DEFAULT OFF)
|
set(SYSTEM_SDL2_DEFAULT OFF)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(USE_RTMIDI_DEFAULT OFF)
|
set(USE_RTMIDI_DEFAULT OFF)
|
||||||
|
set(USE_BACKWARD_DEFAULT OFF)
|
||||||
else()
|
else()
|
||||||
set(USE_RTMIDI_DEFAULT ON)
|
set(USE_RTMIDI_DEFAULT ON)
|
||||||
|
set(USE_BACKWARD_DEFAULT ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
|
@ -35,7 +39,10 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(BUILD_GUI "Build the tracker (disable to build only a headless player)" ${BUILD_GUI_DEFAULT})
|
option(BUILD_GUI "Build the tracker (disable to build only a headless player)" ${BUILD_GUI_DEFAULT})
|
||||||
option(USE_RTMIDI "Build with MIDI support using RtMidi. Currently unfinished." ${USE_RTMIDI_DEFAULT})
|
option(USE_RTMIDI "Build with MIDI support using RtMidi." ${USE_RTMIDI_DEFAULT})
|
||||||
|
option(USE_SDL2 "Build with SDL2. Required to build with GUI." ${USE_SDL2_DEFAULT})
|
||||||
|
option(USE_SNDFILE "Build with libsndfile. Required in order to work with audio files." ${USE_SNDFILE_DEFAULT})
|
||||||
|
option(USE_BACKWARD "Use backward-cpp to print a backtrace on crash/abort." ${USE_BACKWARD_DEFAULT})
|
||||||
option(WITH_JACK "Whether to build with JACK support. Auto-detects if JACK is available" ${WITH_JACK_DEFAULT})
|
option(WITH_JACK "Whether to build with JACK support. Auto-detects if JACK is available" ${WITH_JACK_DEFAULT})
|
||||||
option(SYSTEM_FMT "Use a system-installed version of fmt instead of the vendored one" OFF)
|
option(SYSTEM_FMT "Use a system-installed version of fmt instead of the vendored one" OFF)
|
||||||
option(SYSTEM_LIBSNDFILE "Use a system-installed version of libsndfile instead of the vendored one" OFF)
|
option(SYSTEM_LIBSNDFILE "Use a system-installed version of libsndfile instead of the vendored one" OFF)
|
||||||
|
@ -93,7 +100,9 @@ else()
|
||||||
message(STATUS "Using vendored fmt")
|
message(STATUS "Using vendored fmt")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (SYSTEM_LIBSNDFILE)
|
if (USE_SNDFILE)
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_SNDFILE)
|
||||||
|
if (SYSTEM_LIBSNDFILE)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(LIBSNDFILE REQUIRED sndfile)
|
pkg_check_modules(LIBSNDFILE REQUIRED sndfile)
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIRS})
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIRS})
|
||||||
|
@ -103,7 +112,7 @@ if (SYSTEM_LIBSNDFILE)
|
||||||
list(APPEND DEPENDENCIES_LINK_OPTIONS ${LIBSNDFILE_LDFLAGS_OTHER})
|
list(APPEND DEPENDENCIES_LINK_OPTIONS ${LIBSNDFILE_LDFLAGS_OTHER})
|
||||||
list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${LIBSNDFILE_LDFLAGS})
|
list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${LIBSNDFILE_LDFLAGS})
|
||||||
message(STATUS "Using system-installed libsndfile")
|
message(STATUS "Using system-installed libsndfile")
|
||||||
else()
|
else()
|
||||||
set(BUILD_TESTING OFF CACHE BOOL "aaaaaa" FORCE)
|
set(BUILD_TESTING OFF CACHE BOOL "aaaaaa" FORCE)
|
||||||
set(BUILD_PROGRAMS OFF CACHE BOOL "aaa" FORCE)
|
set(BUILD_PROGRAMS OFF CACHE BOOL "aaa" FORCE)
|
||||||
set(BUILD_EXAMPLES OFF CACHE BOOL "a" FORCE)
|
set(BUILD_EXAMPLES OFF CACHE BOOL "a" FORCE)
|
||||||
|
@ -112,6 +121,9 @@ else()
|
||||||
add_subdirectory(extern/libsndfile EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/libsndfile EXCLUDE_FROM_ALL)
|
||||||
list(APPEND DEPENDENCIES_LIBRARIES sndfile)
|
list(APPEND DEPENDENCIES_LIBRARIES sndfile)
|
||||||
message(STATUS "Using vendored libsndfile")
|
message(STATUS "Using vendored libsndfile")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "Not using libsndfile")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_RTMIDI)
|
if (USE_RTMIDI)
|
||||||
|
@ -154,10 +166,12 @@ else()
|
||||||
message(STATUS "Using vendored zlib")
|
message(STATUS "Using vendored zlib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (SYSTEM_SDL2)
|
if (USE_SDL2)
|
||||||
|
if (SYSTEM_SDL2)
|
||||||
if (PKG_CONFIG_FOUND)
|
if (PKG_CONFIG_FOUND)
|
||||||
pkg_check_modules(SDL2 sdl2>=${SYSTEM_SDL_MIN_VER})
|
pkg_check_modules(SDL2 sdl2>=${SYSTEM_SDL_MIN_VER})
|
||||||
if (SDL2_FOUND)
|
if (SDL2_FOUND)
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_SDL2)
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
|
||||||
list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${SDL2_CFLAGS_OTHER})
|
list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${SDL2_CFLAGS_OTHER})
|
||||||
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARIES})
|
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARIES})
|
||||||
|
@ -168,11 +182,12 @@ if (SYSTEM_SDL2)
|
||||||
endif()
|
endif()
|
||||||
if (NOT SDL2_FOUND)
|
if (NOT SDL2_FOUND)
|
||||||
find_package(SDL2 ${SYSTEM_SDL_MIN_VER} REQUIRED)
|
find_package(SDL2 ${SYSTEM_SDL_MIN_VER} REQUIRED)
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_SDL2)
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||||
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARY})
|
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "Using system-installed SDL2")
|
message(STATUS "Using system-installed SDL2")
|
||||||
else()
|
else()
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(SDL_SHARED ON CACHE BOOL "Force no dynamically-linked SDL" FORCE)
|
set(SDL_SHARED ON CACHE BOOL "Force no dynamically-linked SDL" FORCE)
|
||||||
set(SDL_STATIC OFF CACHE BOOL "Force statically-linked SDL" FORCE)
|
set(SDL_STATIC OFF CACHE BOOL "Force statically-linked SDL" FORCE)
|
||||||
|
@ -186,6 +201,7 @@ else()
|
||||||
# This should probably go in a FAQ.
|
# This should probably go in a FAQ.
|
||||||
set(SDL_LIBC ON CACHE BOOL "Tell SDL that we want it to use our C runtime (required for proper static linking)" FORCE)
|
set(SDL_LIBC ON CACHE BOOL "Tell SDL that we want it to use our C runtime (required for proper static linking)" FORCE)
|
||||||
add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
|
||||||
|
list(APPEND DEPENDENCIES_DEFINES HAVE_SDL2)
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/SDL/include)
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/SDL/include)
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
list(APPEND DEPENDENCIES_LIBRARIES SDL2)
|
list(APPEND DEPENDENCIES_LIBRARIES SDL2)
|
||||||
|
@ -197,15 +213,24 @@ else()
|
||||||
list(APPEND DEPENDENCIES_COMPILE_OPTIONS "/DHAVE_LIBC")
|
list(APPEND DEPENDENCIES_COMPILE_OPTIONS "/DHAVE_LIBC")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "Using vendored SDL2")
|
message(STATUS "Using vendored SDL2")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "Not using SDL2")
|
||||||
|
if (BUILD_GUI)
|
||||||
|
message(FATAL_ERROR "SDL2 is required in order to build with GUI! Disable BUILD_GUI otherwise.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(AUDIO_SOURCES
|
set(AUDIO_SOURCES
|
||||||
src/audio/abstract.cpp
|
src/audio/abstract.cpp
|
||||||
src/audio/midi.cpp
|
src/audio/midi.cpp
|
||||||
src/audio/sdl.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WITH_JACK)
|
if (USE_SDL2)
|
||||||
|
list(APPEND AUDIO_SOURCES src/audio/sdl.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WITH_JACK)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(JACK REQUIRED jack)
|
pkg_check_modules(JACK REQUIRED jack)
|
||||||
list(APPEND AUDIO_SOURCES src/audio/jack.cpp)
|
list(APPEND AUDIO_SOURCES src/audio/jack.cpp)
|
||||||
|
@ -250,6 +275,7 @@ extern/adpcm/ymb_codec.c
|
||||||
extern/adpcm/ymz_codec.c
|
extern/adpcm/ymz_codec.c
|
||||||
|
|
||||||
extern/Nuked-OPN2/ym3438.c
|
extern/Nuked-OPN2/ym3438.c
|
||||||
|
extern/Nuked-PSG/ympsg.c
|
||||||
extern/opm/opm.c
|
extern/opm/opm.c
|
||||||
extern/Nuked-OPLL/opll.c
|
extern/Nuked-OPLL/opll.c
|
||||||
extern/opl/opl3.c
|
extern/opl/opl3.c
|
||||||
|
@ -330,6 +356,9 @@ src/engine/platform/sound/ymz280b.cpp
|
||||||
|
|
||||||
src/engine/platform/sound/rf5c68.cpp
|
src/engine/platform/sound/rf5c68.cpp
|
||||||
|
|
||||||
|
src/engine/platform/sound/oki/okim6258.cpp
|
||||||
|
src/engine/platform/sound/oki/msm6295.cpp
|
||||||
|
|
||||||
src/engine/platform/oplAInterface.cpp
|
src/engine/platform/oplAInterface.cpp
|
||||||
src/engine/platform/ym2608Interface.cpp
|
src/engine/platform/ym2608Interface.cpp
|
||||||
src/engine/platform/ym2610Interface.cpp
|
src/engine/platform/ym2610Interface.cpp
|
||||||
|
@ -380,6 +409,8 @@ src/engine/platform/fds.cpp
|
||||||
src/engine/platform/tia.cpp
|
src/engine/platform/tia.cpp
|
||||||
src/engine/platform/saa.cpp
|
src/engine/platform/saa.cpp
|
||||||
src/engine/platform/amiga.cpp
|
src/engine/platform/amiga.cpp
|
||||||
|
src/engine/platform/msm6258.cpp
|
||||||
|
src/engine/platform/msm6295.cpp
|
||||||
src/engine/platform/pcspkr.cpp
|
src/engine/platform/pcspkr.cpp
|
||||||
src/engine/platform/segapcm.cpp
|
src/engine/platform/segapcm.cpp
|
||||||
src/engine/platform/qsound.cpp
|
src/engine/platform/qsound.cpp
|
||||||
|
@ -481,6 +512,13 @@ endif()
|
||||||
|
|
||||||
set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} src/main.cpp)
|
set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} src/main.cpp)
|
||||||
|
|
||||||
|
if (USE_BACKWARD)
|
||||||
|
list(APPEND USED_SOURCES src/backtrace.cpp)
|
||||||
|
if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
list(APPEND DEPENDENCIES_LIBRARIES dbghelp psapi)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI)
|
||||||
list(APPEND USED_SOURCES ${GUI_SOURCES})
|
list(APPEND USED_SOURCES ${GUI_SOURCES})
|
||||||
list(APPEND DEPENDENCIES_INCLUDE_DIRS
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS
|
||||||
|
|
1
TODO.md
1
TODO.md
|
@ -20,7 +20,6 @@
|
||||||
- volume commands should work on Game Boy
|
- volume commands should work on Game Boy
|
||||||
- add another FM editor layout
|
- add another FM editor layout
|
||||||
- try to find out why does VSlider not accept keyboard input
|
- try to find out why does VSlider not accept keyboard input
|
||||||
- finish lock layout
|
|
||||||
- if macros have release, note off should release them
|
- if macros have release, note off should release them
|
||||||
- add ability to select a column by double clicking
|
- add ability to select a column by double clicking
|
||||||
- add ability to move selection by dragging
|
- add ability to move selection by dragging
|
||||||
|
|
339
extern/Nuked-PSG/LICENSE
vendored
Normal file
339
extern/Nuked-PSG/LICENSE
vendored
Normal file
|
@ -0,0 +1,339 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
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.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
6
extern/Nuked-PSG/README.md
vendored
Normal file
6
extern/Nuked-PSG/README.md
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Nuked-PSG
|
||||||
|
Yamaha YM7101 PSG emulator
|
||||||
|
|
||||||
|
# modification disclaimer
|
||||||
|
|
||||||
|
this is a modified version of Nuked-PSG which adds support for changing the noise LFSR size and taps.
|
405
extern/Nuked-PSG/ympsg.c
vendored
Normal file
405
extern/Nuked-PSG/ympsg.c
vendored
Normal file
|
@ -0,0 +1,405 @@
|
||||||
|
// Copyright (C) 2021 Nuke.YKT
|
||||||
|
// License: GPLv2+
|
||||||
|
// Version 1.0.1
|
||||||
|
#include <string.h>
|
||||||
|
#include "ympsg.h"
|
||||||
|
|
||||||
|
const float ympsg_vol[17] = {
|
||||||
|
1.0, 0.772, 0.622, 0.485, 0.382, 0.29, 0.229, 0.174, 0.132, 0.096, 0.072, 0.051, 0.034, 0.019, 0.009, 0.0, -1.059
|
||||||
|
};
|
||||||
|
|
||||||
|
static void YMPSG_WriteLatch(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
uint8_t data = chip->data;
|
||||||
|
if (chip->data_mask)
|
||||||
|
{
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
if (data & 128)
|
||||||
|
{
|
||||||
|
chip->latch = (data >> 4) & 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YMPSG_UpdateRegisters(ympsg_t* chip)
|
||||||
|
{
|
||||||
|
uint8_t data = chip->data;
|
||||||
|
if (chip->data_mask)
|
||||||
|
{
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 1))
|
||||||
|
{
|
||||||
|
chip->volume[0] = data & 15;
|
||||||
|
if (chip->data_mask)
|
||||||
|
{
|
||||||
|
chip->volume[0] = 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 3))
|
||||||
|
{
|
||||||
|
chip->volume[1] = data & 15;
|
||||||
|
if (chip->data_mask)
|
||||||
|
{
|
||||||
|
chip->volume[1] = 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 4))
|
||||||
|
{
|
||||||
|
if ((data & 128) || chip->reg_reset)
|
||||||
|
{
|
||||||
|
chip->freq[2] &= 1008;
|
||||||
|
chip->freq[2] |= data & 15;
|
||||||
|
}
|
||||||
|
if (!(data & 128))
|
||||||
|
{
|
||||||
|
chip->freq[2] &= 15;
|
||||||
|
chip->freq[2] |= (data << 4) & 1008;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 2))
|
||||||
|
{
|
||||||
|
if ((data & 128) || chip->reg_reset)
|
||||||
|
{
|
||||||
|
chip->freq[1] &= 1008;
|
||||||
|
chip->freq[1] |= data & 15;
|
||||||
|
}
|
||||||
|
if (!(data & 128))
|
||||||
|
{
|
||||||
|
chip->freq[1] &= 15;
|
||||||
|
chip->freq[1] |= (data << 4) & 1008;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 5))
|
||||||
|
{
|
||||||
|
chip->volume[2] = data & 15;
|
||||||
|
if (chip->data_mask)
|
||||||
|
{
|
||||||
|
chip->volume[2] = 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 0))
|
||||||
|
{
|
||||||
|
if ((data & 128) || chip->reg_reset)
|
||||||
|
{
|
||||||
|
chip->freq[0] &= 1008;
|
||||||
|
chip->freq[0] |= data & 15;
|
||||||
|
}
|
||||||
|
if (!(data & 128))
|
||||||
|
{
|
||||||
|
chip->freq[0] &= 15;
|
||||||
|
chip->freq[0] |= (data << 4) & 1008;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 7))
|
||||||
|
{
|
||||||
|
chip->volume[3] = data & 15;
|
||||||
|
if (chip->data_mask)
|
||||||
|
{
|
||||||
|
chip->volume[3] = 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->reg_reset || (chip->write_flag_l && chip->latch == 6))
|
||||||
|
{
|
||||||
|
chip->noise_data = data & 7;
|
||||||
|
chip->noise_trig = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YMPSG_ClockInternal1(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
uint16_t freq = 0;
|
||||||
|
uint8_t chan_sel = chip->chan_sel;
|
||||||
|
uint8_t noise_of, noise_bit1, noise_bit2, noise_next;
|
||||||
|
if ((chip->noise_data & 3) == 3)
|
||||||
|
{
|
||||||
|
noise_of = (chip->sign >> 1) & 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
noise_of = chip->sign & 1;
|
||||||
|
}
|
||||||
|
if (chip->noise_trig_l || (chip->ic_latch2 & 1))
|
||||||
|
{
|
||||||
|
chip->noise = 0;
|
||||||
|
}
|
||||||
|
else if (noise_of && !chip->noise_of)
|
||||||
|
{
|
||||||
|
noise_bit1 = (chip->noise >> chip->noise_tap2) & 1;
|
||||||
|
noise_bit2 = (chip->noise >> 12) & 1;
|
||||||
|
noise_bit1 ^= noise_bit2;
|
||||||
|
noise_next = ((noise_bit1 && ((chip->noise_data >> 2) & 1)) || ((chip->noise & chip->noise_size) == 0));
|
||||||
|
chip->noise <<= 1;
|
||||||
|
chip->noise |= noise_next;
|
||||||
|
}
|
||||||
|
chip->noise_of = noise_of;
|
||||||
|
if (chip->ic_latch2 & 2)
|
||||||
|
{
|
||||||
|
chan_sel = 0;
|
||||||
|
}
|
||||||
|
if (chip->chan_sel & 1)
|
||||||
|
{
|
||||||
|
freq |= chip->freq[0];
|
||||||
|
}
|
||||||
|
if (chip->chan_sel & 2)
|
||||||
|
{
|
||||||
|
freq |= chip->freq[1];
|
||||||
|
}
|
||||||
|
if (chip->chan_sel & 4)
|
||||||
|
{
|
||||||
|
freq |= chip->freq[2];
|
||||||
|
}
|
||||||
|
if (chip->chan_sel & 8)
|
||||||
|
{
|
||||||
|
if ((chip->noise_data & 3) == 0)
|
||||||
|
{
|
||||||
|
freq |= 16;
|
||||||
|
}
|
||||||
|
if ((chip->noise_data & 3) == 1)
|
||||||
|
{
|
||||||
|
freq |= 32;
|
||||||
|
}
|
||||||
|
if ((chip->noise_data & 3) == 2)
|
||||||
|
{
|
||||||
|
freq |= 64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chip->chan_sel & 1)
|
||||||
|
{
|
||||||
|
chip->sign ^= chip->counter_of & 15;
|
||||||
|
}
|
||||||
|
if (chip->ic_latch2 & 2)
|
||||||
|
{
|
||||||
|
chip->sign = 0;
|
||||||
|
}
|
||||||
|
chip->counter_of <<= 1;
|
||||||
|
if (chip->counter[chip->rot] >= freq)
|
||||||
|
{
|
||||||
|
chip->counter_of |= 1;
|
||||||
|
chip->counter[chip->rot] = 0;
|
||||||
|
}
|
||||||
|
if (chip->ic_latch2 & 2)
|
||||||
|
{
|
||||||
|
chip->counter[chip->rot] = 0;
|
||||||
|
}
|
||||||
|
chip->counter[chip->rot]++;
|
||||||
|
chip->counter[chip->rot] &= 1023;
|
||||||
|
if ((chip->ic_latch2 & 1) || (chip->chan_sel & 7) != 0)
|
||||||
|
{
|
||||||
|
chip->chan_sel <<= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chip->chan_sel <<= 1;
|
||||||
|
chip->chan_sel |= 1;
|
||||||
|
}
|
||||||
|
chip->ic_latch2 <<= 1;
|
||||||
|
chip->ic_latch2 |= chip->ic & 1;
|
||||||
|
chip->noise_trig_l = chip->noise_trig;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YMPSG_ClockInternal2(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
chip->data_mask = (chip->ic_latch2 >> 1) & 1;
|
||||||
|
chip->reg_reset = (chip->ic_latch2 >> 0) & 1;
|
||||||
|
if (chip->noise_trig_l)
|
||||||
|
{
|
||||||
|
chip->noise_trig = 0;
|
||||||
|
}
|
||||||
|
YMPSG_UpdateRegisters(chip);
|
||||||
|
|
||||||
|
chip->rot = (chip->rot + 1) & 3;
|
||||||
|
chip->sign_l = chip->sign;
|
||||||
|
chip->noise_sign_l = (chip->noise >> 14) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void YMPSG_UpdateSample(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t sign = chip->sign & 14;
|
||||||
|
sign |= chip->noise_sign_l;
|
||||||
|
if (chip->test & 1)
|
||||||
|
{
|
||||||
|
sign |= 15;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if ((sign >> (3 - i)) & 1)
|
||||||
|
{
|
||||||
|
chip->volume_out[i] = chip->volume[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chip->volume_out[i] = 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_Write(ympsg_t *chip, uint8_t data)
|
||||||
|
{
|
||||||
|
chip->data = data;
|
||||||
|
chip->write_flag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t YMPSG_Read(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
uint16_t data = 0;
|
||||||
|
uint32_t i;
|
||||||
|
YMPSG_UpdateSample(chip);
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
data |= chip->volume_out[i] << ((3 - i) * 4);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_Init(ympsg_t *chip, uint8_t real_sn)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
memset(chip, 0, sizeof(ympsg_t));
|
||||||
|
YMPSG_SetIC(chip, 1);
|
||||||
|
chip->noise_tap2 = real_sn ? 13 : 15;
|
||||||
|
chip->noise_size = real_sn ? 16383 : 32767;
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
YMPSG_Clock(chip);
|
||||||
|
}
|
||||||
|
YMPSG_SetIC(chip, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_SetIC(ympsg_t *chip, uint32_t ic)
|
||||||
|
{
|
||||||
|
chip->ic = (uint8_t)ic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_Clock(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
uint8_t prescaler2_latch;
|
||||||
|
prescaler2_latch = chip->prescaler_2;
|
||||||
|
chip->prescaler_2 += chip->prescaler_1;
|
||||||
|
chip->prescaler_2 &= 1;
|
||||||
|
chip->prescaler_1 ^= 1;
|
||||||
|
if ((chip->ic_latch1 & 3) == 2)
|
||||||
|
{
|
||||||
|
chip->prescaler_1 = 0;
|
||||||
|
chip->prescaler_2 = 0;
|
||||||
|
}
|
||||||
|
chip->ic_latch1 <<= 1;
|
||||||
|
chip->ic_latch1 |= chip->ic & 1;
|
||||||
|
YMPSG_UpdateRegisters(chip);
|
||||||
|
chip->write_flag_l = 0;
|
||||||
|
if (chip->write_flag)
|
||||||
|
{
|
||||||
|
YMPSG_WriteLatch(chip);
|
||||||
|
chip->write_flag = 0;
|
||||||
|
chip->write_flag_l = 1;
|
||||||
|
}
|
||||||
|
if (chip->prescaler_1)
|
||||||
|
{
|
||||||
|
if (!prescaler2_latch)
|
||||||
|
{
|
||||||
|
YMPSG_ClockInternal1(chip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YMPSG_ClockInternal2(chip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float YMPSG_GetOutput(ympsg_t *chip)
|
||||||
|
{
|
||||||
|
float sample = 0.f;
|
||||||
|
uint32_t i;
|
||||||
|
YMPSG_UpdateSample(chip);
|
||||||
|
if (chip->test & 1)
|
||||||
|
{
|
||||||
|
sample += ympsg_vol[chip->volume_out[chip->test >> 1]];
|
||||||
|
sample += ympsg_vol[16] * 3.f;
|
||||||
|
}
|
||||||
|
else if (!chip->mute)
|
||||||
|
{
|
||||||
|
sample += ympsg_vol[chip->volume_out[0]];
|
||||||
|
sample += ympsg_vol[chip->volume_out[1]];
|
||||||
|
sample += ympsg_vol[chip->volume_out[2]];
|
||||||
|
sample += ympsg_vol[chip->volume_out[3]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (!((chip->mute>>i) & 1))
|
||||||
|
sample += ympsg_vol[chip->volume_out[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_Test(ympsg_t *chip, uint16_t test)
|
||||||
|
{
|
||||||
|
chip->test = (test >> 9) & 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void YMPSG_Generate(ympsg_t *chip, int32_t *buf)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
float out;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
YMPSG_Clock(chip);
|
||||||
|
|
||||||
|
while (chip->writebuf[chip->writebuf_cur].time <= chip->writebuf_samplecnt)
|
||||||
|
{
|
||||||
|
if (!chip->writebuf[chip->writebuf_cur].stat)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chip->writebuf[chip->writebuf_cur].stat = 0;
|
||||||
|
YMPSG_Write(chip, chip->writebuf[chip->writebuf_cur].data);
|
||||||
|
chip->writebuf_cur = (chip->writebuf_cur + 1) % YMPSG_WRITEBUF_SIZE;
|
||||||
|
}
|
||||||
|
chip->writebuf_samplecnt++;
|
||||||
|
}
|
||||||
|
out = YMPSG_GetOutput(chip);
|
||||||
|
*buf = (int32_t)(out * 8192.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data)
|
||||||
|
{
|
||||||
|
uint64_t time1, time2;
|
||||||
|
uint64_t skip;
|
||||||
|
|
||||||
|
if (chip->writebuf[chip->writebuf_last].stat)
|
||||||
|
{
|
||||||
|
YMPSG_Write(chip, chip->writebuf[chip->writebuf_last].data);
|
||||||
|
|
||||||
|
chip->writebuf_cur = (chip->writebuf_last + 1) % YMPSG_WRITEBUF_SIZE;
|
||||||
|
skip = chip->writebuf[chip->writebuf_last].time - chip->writebuf_samplecnt;
|
||||||
|
chip->writebuf_samplecnt = chip->writebuf[chip->writebuf_last].time;
|
||||||
|
while (skip--)
|
||||||
|
{
|
||||||
|
YMPSG_Clock(chip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chip->writebuf[chip->writebuf_last].stat = 1;
|
||||||
|
chip->writebuf[chip->writebuf_last].data = data;
|
||||||
|
time1 = chip->writebuf_lasttime + YMPSG_WRITEBUF_DELAY;
|
||||||
|
time2 = chip->writebuf_samplecnt;
|
||||||
|
|
||||||
|
if (time1 < time2)
|
||||||
|
{
|
||||||
|
time1 = time2;
|
||||||
|
}
|
||||||
|
|
||||||
|
chip->writebuf[chip->writebuf_last].time = time1;
|
||||||
|
chip->writebuf_lasttime = time1;
|
||||||
|
chip->writebuf_last = (chip->writebuf_last + 1) % YMPSG_WRITEBUF_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YMPSG_SetMute(ympsg_t *chip, uint8_t mute)
|
||||||
|
{
|
||||||
|
chip->mute = mute;
|
||||||
|
}
|
79
extern/Nuked-PSG/ympsg.h
vendored
Normal file
79
extern/Nuked-PSG/ympsg.h
vendored
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
// Copyright (C) 2021 Nuke.YKT
|
||||||
|
// License: GPLv2+
|
||||||
|
// Version 1.0.1
|
||||||
|
#ifndef _YMPSG_H_
|
||||||
|
#define _YMPSG_H_
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define YMPSG_WRITEBUF_SIZE 2048
|
||||||
|
#define YMPSG_WRITEBUF_DELAY 8
|
||||||
|
|
||||||
|
typedef struct _ympsg_writebuf {
|
||||||
|
uint64_t time;
|
||||||
|
uint8_t stat;
|
||||||
|
uint8_t data;
|
||||||
|
} ympsg_writebuf;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// IO
|
||||||
|
uint8_t data;
|
||||||
|
uint8_t latch;
|
||||||
|
uint8_t write_flag;
|
||||||
|
uint8_t write_flag_l;
|
||||||
|
|
||||||
|
uint8_t prescaler_1;
|
||||||
|
uint8_t prescaler_2;
|
||||||
|
uint8_t prescaler_2_l;
|
||||||
|
uint8_t reset_latch;
|
||||||
|
uint8_t ic;
|
||||||
|
uint8_t ic_latch1;
|
||||||
|
uint8_t ic_latch2;
|
||||||
|
uint8_t data_mask;
|
||||||
|
uint8_t reg_reset;
|
||||||
|
uint8_t volume[4];
|
||||||
|
uint16_t freq[3];
|
||||||
|
uint8_t noise_data;
|
||||||
|
uint8_t noise_of;
|
||||||
|
uint8_t noise_trig;
|
||||||
|
uint8_t noise_trig_l;
|
||||||
|
uint8_t rot;
|
||||||
|
|
||||||
|
uint8_t chan_sel;
|
||||||
|
|
||||||
|
uint16_t counter[4];
|
||||||
|
uint8_t counter_of;
|
||||||
|
uint8_t sign;
|
||||||
|
uint8_t sign_l;
|
||||||
|
uint8_t noise_sign_l;
|
||||||
|
uint16_t noise;
|
||||||
|
uint8_t noise_tap2;
|
||||||
|
uint16_t noise_size;
|
||||||
|
uint8_t test;
|
||||||
|
uint8_t volume_out[4];
|
||||||
|
|
||||||
|
//
|
||||||
|
uint64_t writebuf_samplecnt;
|
||||||
|
uint32_t writebuf_cur;
|
||||||
|
uint32_t writebuf_last;
|
||||||
|
uint64_t writebuf_lasttime;
|
||||||
|
ympsg_writebuf writebuf[YMPSG_WRITEBUF_SIZE];
|
||||||
|
|
||||||
|
uint8_t mute;
|
||||||
|
} ympsg_t;
|
||||||
|
|
||||||
|
|
||||||
|
void YMPSG_Write(ympsg_t *chip, uint8_t data);
|
||||||
|
uint16_t YMPSG_Read(ympsg_t *chip);
|
||||||
|
void YMPSG_Init(ympsg_t *chip, uint8_t real_sn);
|
||||||
|
void YMPSG_SetIC(ympsg_t *chip, uint32_t ic);
|
||||||
|
void YMPSG_Clock(ympsg_t *chip);
|
||||||
|
float YMPSG_GetOutput(ympsg_t *chip);
|
||||||
|
void YMPSG_Test(ympsg_t *chip, uint16_t test);
|
||||||
|
|
||||||
|
|
||||||
|
void YMPSG_Generate(ympsg_t *chip, int32_t *buf);
|
||||||
|
void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data);
|
||||||
|
|
||||||
|
void YMPSG_SetMute(ympsg_t *chip, uint8_t mute);
|
||||||
|
|
||||||
|
#endif
|
265
extern/backward/BackwardConfig.cmake
vendored
Normal file
265
extern/backward/BackwardConfig.cmake
vendored
Normal file
|
@ -0,0 +1,265 @@
|
||||||
|
#
|
||||||
|
# BackwardMacros.cmake
|
||||||
|
# Copyright 2013 Google Inc. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OPTIONS
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
set(STACK_WALKING_UNWIND TRUE CACHE BOOL
|
||||||
|
"Use compiler's unwind API")
|
||||||
|
set(STACK_WALKING_BACKTRACE FALSE CACHE BOOL
|
||||||
|
"Use backtrace from (e)glibc for stack walking")
|
||||||
|
set(STACK_WALKING_LIBUNWIND FALSE CACHE BOOL
|
||||||
|
"Use libunwind for stack walking")
|
||||||
|
|
||||||
|
set(STACK_DETAILS_AUTO_DETECT TRUE CACHE BOOL
|
||||||
|
"Auto detect backward's stack details dependencies")
|
||||||
|
|
||||||
|
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE CACHE BOOL
|
||||||
|
"Use backtrace from (e)glibc for symbols resolution")
|
||||||
|
set(STACK_DETAILS_DW FALSE CACHE BOOL
|
||||||
|
"Use libdw to read debug info")
|
||||||
|
set(STACK_DETAILS_BFD FALSE CACHE BOOL
|
||||||
|
"Use libbfd to read debug info")
|
||||||
|
set(STACK_DETAILS_DWARF FALSE CACHE BOOL
|
||||||
|
"Use libdwarf/libelf to read debug info")
|
||||||
|
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT DEFINED BACKWARD_TESTS)
|
||||||
|
# If this is a top level CMake project, we most lixely want the tests
|
||||||
|
set(BACKWARD_TESTS ON CACHE BOOL "Enable tests")
|
||||||
|
else()
|
||||||
|
set(BACKWARD_TESTS OFF CACHE BOOL "Enable tests")
|
||||||
|
endif()
|
||||||
|
###############################################################################
|
||||||
|
# CONFIGS
|
||||||
|
###############################################################################
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
if (STACK_WALKING_LIBUNWIND)
|
||||||
|
# libunwind works on the macOS without having to add special include
|
||||||
|
# paths or libraries
|
||||||
|
if (NOT APPLE)
|
||||||
|
find_path(LIBUNWIND_INCLUDE_DIR NAMES "libunwind.h")
|
||||||
|
find_library(LIBUNWIND_LIBRARY unwind)
|
||||||
|
|
||||||
|
if (LIBUNWIND_LIBRARY)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
check_symbol_exists(UNW_INIT_SIGNAL_FRAME libunwind.h HAVE_UNW_INIT_SIGNAL_FRAME)
|
||||||
|
if (NOT HAVE_UNW_INIT_SIGNAL_FRAME)
|
||||||
|
message(STATUS "libunwind does not support unwinding from signal handler frames")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LIBUNWIND_INCLUDE_DIRS ${LIBUNWIND_INCLUDE_DIR})
|
||||||
|
set(LIBDWARF_LIBRARIES ${LIBUNWIND_LIBRARY})
|
||||||
|
find_package_handle_standard_args(libunwind DEFAULT_MSG
|
||||||
|
LIBUNWIND_LIBRARY LIBUNWIND_INCLUDE_DIR)
|
||||||
|
mark_as_advanced(LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARY)
|
||||||
|
list(APPEND _BACKWARD_LIBRARIES ${LIBUNWIND_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Disable other unwinders if libunwind is found
|
||||||
|
set(STACK_WALKING_UNWIND FALSE)
|
||||||
|
set(STACK_WALKING_BACKTRACE FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${STACK_DETAILS_AUTO_DETECT})
|
||||||
|
if(NOT CMAKE_VERSION VERSION_LESS 3.17)
|
||||||
|
set(_name_mismatched_arg NAME_MISMATCHED)
|
||||||
|
endif()
|
||||||
|
# find libdw
|
||||||
|
find_path(LIBDW_INCLUDE_DIR NAMES "elfutils/libdw.h" "elfutils/libdwfl.h")
|
||||||
|
find_library(LIBDW_LIBRARY dw)
|
||||||
|
# in case it's statically linked, look for all the possible dependencies
|
||||||
|
find_library(LIBELF_LIBRARY elf)
|
||||||
|
find_library(LIBPTHREAD_LIBRARY pthread)
|
||||||
|
find_library(LIBZ_LIBRARY z)
|
||||||
|
find_library(LIBBZ2_LIBRARY bz2)
|
||||||
|
find_library(LIBLZMA_LIBRARY lzma)
|
||||||
|
find_library(LIBZSTD_LIBRARY zstd)
|
||||||
|
set(LIBDW_INCLUDE_DIRS ${LIBDW_INCLUDE_DIR} )
|
||||||
|
set(LIBDW_LIBRARIES ${LIBDW_LIBRARY}
|
||||||
|
$<$<BOOL:${LIBELF_LIBRARY}>:${LIBELF_LIBRARY}>
|
||||||
|
$<$<BOOL:${LIBPTHREAD_LIBRARY}>:${LIBPTHREAD_LIBRARY}>
|
||||||
|
$<$<BOOL:${LIBZ_LIBRARY}>:${LIBZ_LIBRARY}>
|
||||||
|
$<$<BOOL:${LIBBZ2_LIBRARY}>:${LIBBZ2_LIBRARY}>
|
||||||
|
$<$<BOOL:${LIBLZMA_LIBRARY}>:${LIBLZMA_LIBRARY}>
|
||||||
|
$<$<BOOL:${LIBZSTD_LIBRARY}>:${LIBZSTD_LIBRARY}>)
|
||||||
|
find_package_handle_standard_args(libdw ${_name_mismatched_arg}
|
||||||
|
REQUIRED_VARS LIBDW_LIBRARY LIBDW_INCLUDE_DIR)
|
||||||
|
mark_as_advanced(LIBDW_INCLUDE_DIR LIBDW_LIBRARY)
|
||||||
|
|
||||||
|
# find libbfd
|
||||||
|
find_path(LIBBFD_INCLUDE_DIR NAMES "bfd.h")
|
||||||
|
find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h")
|
||||||
|
find_library(LIBBFD_LIBRARY bfd)
|
||||||
|
find_library(LIBDL_LIBRARY dl)
|
||||||
|
set(LIBBFD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR})
|
||||||
|
set(LIBBFD_LIBRARIES ${LIBBFD_LIBRARY} ${LIBDL_LIBRARY})
|
||||||
|
find_package_handle_standard_args(libbfd ${_name_mismatched_arg}
|
||||||
|
REQUIRED_VARS LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR
|
||||||
|
LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
|
||||||
|
mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY
|
||||||
|
LIBDL_INCLUDE_DIR LIBDL_LIBRARY)
|
||||||
|
|
||||||
|
# find libdwarf
|
||||||
|
find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h" PATH_SUFFIXES libdwarf)
|
||||||
|
find_path(LIBELF_INCLUDE_DIR NAMES "libelf.h")
|
||||||
|
find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h")
|
||||||
|
find_library(LIBDWARF_LIBRARY dwarf)
|
||||||
|
find_library(LIBELF_LIBRARY elf)
|
||||||
|
find_library(LIBDL_LIBRARY dl)
|
||||||
|
set(LIBDWARF_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIR} ${LIBELF_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR})
|
||||||
|
set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARY} ${LIBELF_LIBRARY} ${LIBDL_LIBRARY})
|
||||||
|
find_package_handle_standard_args(libdwarf ${_name_mismatched_arg}
|
||||||
|
REQUIRED_VARS LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR
|
||||||
|
LIBELF_LIBRARY LIBELF_INCLUDE_DIR
|
||||||
|
LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
|
||||||
|
mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY
|
||||||
|
LIBELF_INCLUDE_DIR LIBELF_LIBRARY
|
||||||
|
LIBDL_INCLUDE_DIR LIBDL_LIBRARY)
|
||||||
|
|
||||||
|
if (LIBDW_FOUND)
|
||||||
|
LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDW_INCLUDE_DIRS})
|
||||||
|
LIST(APPEND _BACKWARD_LIBRARIES ${LIBDW_LIBRARIES})
|
||||||
|
set(STACK_DETAILS_DW TRUE)
|
||||||
|
set(STACK_DETAILS_BFD FALSE)
|
||||||
|
set(STACK_DETAILS_DWARF FALSE)
|
||||||
|
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE)
|
||||||
|
elseif(LIBBFD_FOUND)
|
||||||
|
LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIRS})
|
||||||
|
LIST(APPEND _BACKWARD_LIBRARIES ${LIBBFD_LIBRARIES})
|
||||||
|
|
||||||
|
# If we attempt to link against static bfd, make sure to link its dependencies, too
|
||||||
|
get_filename_component(bfd_lib_ext "${LIBBFD_LIBRARY}" EXT)
|
||||||
|
if (bfd_lib_ext STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||||
|
list(APPEND _BACKWARD_LIBRARIES iberty z)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(STACK_DETAILS_DW FALSE)
|
||||||
|
set(STACK_DETAILS_BFD TRUE)
|
||||||
|
set(STACK_DETAILS_DWARF FALSE)
|
||||||
|
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE)
|
||||||
|
elseif(LIBDWARF_FOUND)
|
||||||
|
LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIRS})
|
||||||
|
LIST(APPEND _BACKWARD_LIBRARIES ${LIBDWARF_LIBRARIES})
|
||||||
|
|
||||||
|
set(STACK_DETAILS_DW FALSE)
|
||||||
|
set(STACK_DETAILS_BFD FALSE)
|
||||||
|
set(STACK_DETAILS_DWARF TRUE)
|
||||||
|
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE)
|
||||||
|
else()
|
||||||
|
set(STACK_DETAILS_DW FALSE)
|
||||||
|
set(STACK_DETAILS_BFD FALSE)
|
||||||
|
set(STACK_DETAILS_DWARF FALSE)
|
||||||
|
set(STACK_DETAILS_BACKTRACE_SYMBOL TRUE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if (STACK_DETAILS_DW)
|
||||||
|
LIST(APPEND _BACKWARD_LIBRARIES dw)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (STACK_DETAILS_BFD)
|
||||||
|
LIST(APPEND _BACKWARD_LIBRARIES bfd dl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (STACK_DETAILS_DWARF)
|
||||||
|
LIST(APPEND _BACKWARD_LIBRARIES dwarf elf)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
macro(map_definitions var_prefix define_prefix)
|
||||||
|
foreach(def ${ARGN})
|
||||||
|
if (${${var_prefix}${def}})
|
||||||
|
LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=1")
|
||||||
|
else()
|
||||||
|
LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=0")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
if (NOT _BACKWARD_DEFINITIONS)
|
||||||
|
map_definitions("STACK_WALKING_" "BACKWARD_HAS_" UNWIND LIBUNWIND BACKTRACE)
|
||||||
|
map_definitions("STACK_DETAILS_" "BACKWARD_HAS_" BACKTRACE_SYMBOL DW BFD DWARF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
list(APPEND _BACKWARD_LIBRARIES dbghelp psapi)
|
||||||
|
if(MINGW)
|
||||||
|
set(MINGW_MSVCR_LIBRARY "msvcr90$<$<CONFIG:DEBUG>:d>" CACHE STRING "Mingw MSVC runtime import library")
|
||||||
|
list(APPEND _BACKWARD_LIBRARIES ${MINGW_MSVCR_LIBRARY})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(BACKWARD_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
|
||||||
|
set(BACKWARD_HAS_EXTERNAL_LIBRARIES FALSE)
|
||||||
|
set(FIND_PACKAGE_REQUIRED_VARS BACKWARD_INCLUDE_DIR)
|
||||||
|
if(DEFINED _BACKWARD_LIBRARIES)
|
||||||
|
set(BACKWARD_HAS_EXTERNAL_LIBRARIES TRUE)
|
||||||
|
list(APPEND FIND_PACKAGE_REQUIRED_VARS _BACKWARD_LIBRARIES)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Backward
|
||||||
|
REQUIRED_VARS ${FIND_PACKAGE_REQUIRED_VARS}
|
||||||
|
)
|
||||||
|
list(APPEND _BACKWARD_INCLUDE_DIRS ${BACKWARD_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# add_backward, optional bool argument; if passed and true, backward will be included as a system header
|
||||||
|
macro(add_backward target)
|
||||||
|
if ("${ARGN}")
|
||||||
|
target_include_directories(${target} SYSTEM PRIVATE ${BACKWARD_INCLUDE_DIRS})
|
||||||
|
else()
|
||||||
|
target_include_directories(${target} PRIVATE ${BACKWARD_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${BACKWARD_DEFINITIONS})
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${BACKWARD_LIBRARIES})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
set(BACKWARD_INCLUDE_DIRS ${_BACKWARD_INCLUDE_DIRS} CACHE INTERNAL "_BACKWARD_INCLUDE_DIRS")
|
||||||
|
set(BACKWARD_DEFINITIONS ${_BACKWARD_DEFINITIONS} CACHE INTERNAL "BACKWARD_DEFINITIONS")
|
||||||
|
set(BACKWARD_LIBRARIES ${_BACKWARD_LIBRARIES} CACHE INTERNAL "BACKWARD_LIBRARIES")
|
||||||
|
mark_as_advanced(BACKWARD_INCLUDE_DIRS BACKWARD_DEFINITIONS BACKWARD_LIBRARIES)
|
||||||
|
|
||||||
|
# Expand each definition in BACKWARD_DEFINITIONS to its own cmake var and export
|
||||||
|
# to outer scope
|
||||||
|
foreach(var ${BACKWARD_DEFINITIONS})
|
||||||
|
string(REPLACE "=" ";" var_as_list ${var})
|
||||||
|
list(GET var_as_list 0 var_name)
|
||||||
|
list(GET var_as_list 1 var_value)
|
||||||
|
set(${var_name} ${var_value})
|
||||||
|
mark_as_advanced(${var_name})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if (NOT TARGET Backward::Backward)
|
||||||
|
add_library(Backward::Backward INTERFACE IMPORTED)
|
||||||
|
set_target_properties(Backward::Backward PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${BACKWARD_INCLUDE_DIRS}"
|
||||||
|
INTERFACE_COMPILE_DEFINITIONS "${BACKWARD_DEFINITIONS}"
|
||||||
|
)
|
||||||
|
if(BACKWARD_HAS_EXTERNAL_LIBRARIES)
|
||||||
|
set_target_properties(Backward::Backward PROPERTIES
|
||||||
|
INTERFACE_LINK_LIBRARIES "${BACKWARD_LIBRARIES}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
139
extern/backward/CMakeLists.txt
vendored
Normal file
139
extern/backward/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
#
|
||||||
|
# CMakeLists.txt
|
||||||
|
# Copyright 2013 Google Inc. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
project(backward CXX)
|
||||||
|
|
||||||
|
# Introduce variables:
|
||||||
|
# * CMAKE_INSTALL_LIBDIR
|
||||||
|
# * CMAKE_INSTALL_BINDIR
|
||||||
|
# * CMAKE_INSTALL_INCLUDEDIR
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
include(BackwardConfig.cmake)
|
||||||
|
|
||||||
|
# check if compiler is nvcc or nvcc_wrapper
|
||||||
|
set(COMPILER_IS_NVCC false)
|
||||||
|
get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
|
||||||
|
if (COMPILER_NAME MATCHES "^nvcc")
|
||||||
|
set(COMPILER_IS_NVCC true)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (DEFINED ENV{OMPI_CXX} OR DEFINED ENV{MPICH_CXX})
|
||||||
|
if ( ($ENV{OMPI_CXX} MATCHES "nvcc") OR ($ENV{MPICH_CXX} MATCHES "nvcc") )
|
||||||
|
set(COMPILER_IS_NVCC true)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# set CXX standard
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
if (${COMPILER_IS_NVCC})
|
||||||
|
# GNU CXX extensions are not supported by nvcc
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# COMPILER FLAGS
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||||
|
if (NOT ${COMPILER_IS_NVCC})
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# BACKWARD OBJECT
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
add_library(backward_object OBJECT backward.cpp)
|
||||||
|
target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS})
|
||||||
|
target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS})
|
||||||
|
set(BACKWARD_ENABLE $<TARGET_OBJECTS:backward_object> CACHE STRING
|
||||||
|
"Link with this object to setup backward automatically")
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# BACKWARD LIBRARY (Includes backward.cpp)
|
||||||
|
###############################################################################
|
||||||
|
option(BACKWARD_SHARED "Build dynamic backward-cpp shared lib" OFF)
|
||||||
|
|
||||||
|
if(BACKWARD_SHARED)
|
||||||
|
set(libtype SHARED)
|
||||||
|
endif()
|
||||||
|
add_library(backward ${libtype} backward.cpp)
|
||||||
|
target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS})
|
||||||
|
target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# TESTS
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
if(BACKWARD_TESTS)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_library(test_main OBJECT test/_test_main.cpp)
|
||||||
|
|
||||||
|
macro(backward_add_test src)
|
||||||
|
get_filename_component(name ${src} NAME_WE)
|
||||||
|
set(test_name "test_${name}")
|
||||||
|
|
||||||
|
add_executable(${test_name} ${src} ${ARGN} $<TARGET_OBJECTS:test_main>)
|
||||||
|
|
||||||
|
target_link_libraries(${test_name} PRIVATE Backward::Backward)
|
||||||
|
|
||||||
|
add_test(NAME ${name} COMMAND ${test_name})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# Tests without backward.cpp
|
||||||
|
set(TESTS
|
||||||
|
test
|
||||||
|
stacktrace
|
||||||
|
rectrace
|
||||||
|
select_signals
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(test ${TESTS})
|
||||||
|
backward_add_test(test/${test}.cpp)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Tests with backward.cpp
|
||||||
|
set(TESTS
|
||||||
|
suicide
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(test ${TESTS})
|
||||||
|
backward_add_test(test/${test}.cpp ${BACKWARD_ENABLE})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES "backward.hpp"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES "BackwardConfig.cmake"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/backward
|
||||||
|
)
|
21
extern/backward/LICENSE.txt
vendored
Normal file
21
extern/backward/LICENSE.txt
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Copyright 2013 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
442
extern/backward/README.md
vendored
Normal file
442
extern/backward/README.md
vendored
Normal file
|
@ -0,0 +1,442 @@
|
||||||
|
Backward-cpp [![badge](https://img.shields.io/badge/conan.io-backward%2F1.3.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC)](http://www.conan.io/source/backward/1.3.0/Manu343726/testing)
|
||||||
|
============
|
||||||
|
|
||||||
|
Backward is a beautiful stack trace pretty printer for C++.
|
||||||
|
|
||||||
|
If you are bored to see this:
|
||||||
|
|
||||||
|
![default trace](doc/rude.png)
|
||||||
|
|
||||||
|
Backward will spice it up for you:
|
||||||
|
|
||||||
|
![pretty stackstrace](doc/pretty.png)
|
||||||
|
|
||||||
|
There is not much to say. Of course it will be able to display the code
|
||||||
|
snippets only if the source files are accessible (else see trace #4 in the
|
||||||
|
example).
|
||||||
|
|
||||||
|
All "Source" lines and code snippet prefixed by a pipe "|" are frames inline
|
||||||
|
the next frame.
|
||||||
|
You can see that for the trace #1 in the example, the function
|
||||||
|
`you_shall_not_pass()` was inlined in the function `...read2::do_test()` by the
|
||||||
|
compiler.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
#### Install backward.hpp
|
||||||
|
|
||||||
|
Backward is a header only library. So installing Backward is easy, simply drop
|
||||||
|
a copy of `backward.hpp` along with your other source files in your C++ project.
|
||||||
|
You can also use a git submodule or really any other way that best fits your
|
||||||
|
environment, as long as you can include `backward.hpp`.
|
||||||
|
|
||||||
|
#### Install backward.cpp
|
||||||
|
|
||||||
|
If you want Backward to automatically print a stack trace on most common fatal
|
||||||
|
errors (segfault, abort, un-handled exception...), simply add a copy of
|
||||||
|
`backward.cpp` to your project, and don't forget to tell your build system.
|
||||||
|
|
||||||
|
The code in `backward.cpp` is trivial anyway, you can simply copy what it's
|
||||||
|
doing at your convenience.
|
||||||
|
|
||||||
|
Note for [folly](https://github.com/facebook/folly) library users: must define `backward::SignalHandling sh;` after `folly::init(&argc, &argv);`.
|
||||||
|
|
||||||
|
## Configuration & Dependencies
|
||||||
|
|
||||||
|
### Integration with CMake
|
||||||
|
|
||||||
|
If you are using CMake and want to use its configuration abilities to save
|
||||||
|
you the trouble, you can easily integrate Backward, depending on how you obtained
|
||||||
|
the library.
|
||||||
|
|
||||||
|
#### As a subdirectory:
|
||||||
|
|
||||||
|
In this case you have a subdirectory containing the whole repository of Backward
|
||||||
|
(eg.: using git-submodules), in this case you can do:
|
||||||
|
|
||||||
|
```
|
||||||
|
add_subdirectory(/path/to/backward-cpp)
|
||||||
|
|
||||||
|
# This will add backward.cpp to your target
|
||||||
|
add_executable(mytarget mysource.cpp ${BACKWARD_ENABLE})
|
||||||
|
|
||||||
|
# This will add libraries, definitions and include directories needed by backward
|
||||||
|
# by setting each property on the target.
|
||||||
|
add_backward(mytarget)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Modifying CMAKE_MODULE_PATH
|
||||||
|
|
||||||
|
In this case you can have Backward installed as a subdirectory:
|
||||||
|
|
||||||
|
```
|
||||||
|
list(APPEND CMAKE_MODULE_PATH /path/to/backward-cpp)
|
||||||
|
find_package(Backward)
|
||||||
|
|
||||||
|
# This will add libraries, definitions and include directories needed by backward
|
||||||
|
# through an IMPORTED target.
|
||||||
|
target_link_libraries(mytarget PUBLIC Backward::Backward)
|
||||||
|
```
|
||||||
|
|
||||||
|
Notice that this is equivalent to using the the approach that uses `add_subdirectory()`,
|
||||||
|
however it uses cmake's [imported target](https://cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets) mechanism.
|
||||||
|
|
||||||
|
#### Installation through a regular package manager
|
||||||
|
|
||||||
|
In this case you have obtained Backward through a package manager.
|
||||||
|
|
||||||
|
Packages currently available:
|
||||||
|
- [conda-forge](https://anaconda.org/conda-forge/backward-cpp)
|
||||||
|
|
||||||
|
```
|
||||||
|
find_package(Backward)
|
||||||
|
|
||||||
|
# This will add libraries, definitions and include directories needed by backward
|
||||||
|
# through an IMPORTED target.
|
||||||
|
target_link_libraries(mytarget PUBLIC Backward::Backward)
|
||||||
|
```
|
||||||
|
### Libraries to unwind the stack
|
||||||
|
|
||||||
|
On Linux and macOS, backtrace can back-trace or "walk" the stack using the
|
||||||
|
following libraries:
|
||||||
|
|
||||||
|
#### unwind
|
||||||
|
|
||||||
|
Unwind comes from libgcc, but there is an equivalent inside clang itself. With
|
||||||
|
unwind, the stacktrace is as accurate as it can possibly be, since this is
|
||||||
|
used by the C++ runtine in gcc/clang for stack unwinding on exception.
|
||||||
|
|
||||||
|
Normally libgcc is already linked to your program by default.
|
||||||
|
|
||||||
|
#### libunwind from the [libunwind project](https://github.com/libunwind/libunwind)
|
||||||
|
|
||||||
|
apt-get install binutils-dev (or equivalent)
|
||||||
|
|
||||||
|
Libunwind provides, in some cases, a more accurate stacktrace as it knows
|
||||||
|
to decode signal handler frames and lets us edit the context registers when
|
||||||
|
unwinding, allowing stack traces over bad function references.
|
||||||
|
|
||||||
|
For best results make sure you are using libunwind 1.3 or later, which added
|
||||||
|
`unw_init_local2` and support for handling signal frames.
|
||||||
|
|
||||||
|
CMake will warn you when configuring if your libunwind version doesn't support
|
||||||
|
signal frames.
|
||||||
|
|
||||||
|
On macOS clang provides a libunwind API compatible library as part of its
|
||||||
|
environment, so no third party libraries are necessary.
|
||||||
|
|
||||||
|
### Compile with debug info
|
||||||
|
|
||||||
|
You need to compile your project with generation of debug symbols enabled,
|
||||||
|
usually `-g` with clang++ and g++.
|
||||||
|
|
||||||
|
Note that you can use `-g` with any level of optimization, with modern debug
|
||||||
|
information encoding like DWARF, it only takes space in the binary (it's not
|
||||||
|
loaded in memory until your debugger or Backward makes use of it, don't worry),
|
||||||
|
and it doesn't impact the code generation (at least on GNU/Linux x86\_64 for
|
||||||
|
what I know).
|
||||||
|
|
||||||
|
If you are missing debug information, the stack trace will lack details about
|
||||||
|
your sources.
|
||||||
|
|
||||||
|
### Libraries to read the debug info
|
||||||
|
|
||||||
|
Backward supports pretty printed stack traces on GNU/Linux, macOS and Windows,
|
||||||
|
it will compile fine under other platforms but will not do anything. **Pull
|
||||||
|
requests are welcome :)**
|
||||||
|
|
||||||
|
Also, by default you will get a really basic stack trace, based on the
|
||||||
|
`backtrace_symbols` API:
|
||||||
|
|
||||||
|
![default trace](doc/nice.png)
|
||||||
|
|
||||||
|
You will need to install some dependencies to get the ultimate stack trace.
|
||||||
|
Three libraries are currently supported, the only difference is which one is the
|
||||||
|
easiest for you to install, so pick your poison:
|
||||||
|
|
||||||
|
#### libbfd from the [GNU/binutils](http://www.gnu.org/software/binutils/)
|
||||||
|
|
||||||
|
apt-get install binutils-dev (or equivalent)
|
||||||
|
|
||||||
|
And do not forget to link with the lib: `g++/clang++ -lbfd -ldl ...`
|
||||||
|
|
||||||
|
This library requires dynamic loading. Which is provided by the library `dl`.
|
||||||
|
Hence why we also link with `-ldl`.
|
||||||
|
|
||||||
|
Then define the following before every inclusion of `backward.hpp` (don't
|
||||||
|
forget to update `backward.cpp` as well):
|
||||||
|
|
||||||
|
#define BACKWARD_HAS_BFD 1
|
||||||
|
|
||||||
|
#### libdw from the [elfutils](https://fedorahosted.org/elfutils/)
|
||||||
|
|
||||||
|
apt-get install libdw-dev (or equivalent)
|
||||||
|
|
||||||
|
And do not forget to link with the lib and inform Backward to use it:
|
||||||
|
|
||||||
|
#define BACKWARD_HAS_DW 1
|
||||||
|
|
||||||
|
Of course you can simply add the define (`-DBACKWARD_HAS_...=1`) and the
|
||||||
|
linkage details in your build system and even auto-detect which library is
|
||||||
|
installed, it's up to you.
|
||||||
|
|
||||||
|
#### [libdwarf](https://sourceforge.net/projects/libdwarf/) and [libelf](http://www.mr511.de/software/english.html)
|
||||||
|
|
||||||
|
apt-get install libdwarf-dev (or equivalent)
|
||||||
|
|
||||||
|
And do not forget to link with the lib and inform Backward to use it:
|
||||||
|
|
||||||
|
#define BACKWARD_HAS_DWARF 1
|
||||||
|
|
||||||
|
There are several alternative implementations of libdwarf and libelf that
|
||||||
|
are API compatible so it's possible, although it hasn't been tested, to
|
||||||
|
replace the ones used when developing backward (in bold, below):
|
||||||
|
|
||||||
|
* **_libelf_** by [Michael "Tired" Riepe](http://www.mr511.de/software/english.html)
|
||||||
|
* **_libdwarf_** by [David Anderson](https://www.prevanders.net/dwarf.html)
|
||||||
|
* libelf from [elfutils](https://fedorahosted.org/elfutils/)
|
||||||
|
* libelf and libdwarf from FreeBSD's [ELF Tool Chain](https://sourceforge.net/p/elftoolchain/wiki/Home/) project
|
||||||
|
|
||||||
|
|
||||||
|
Of course you can simply add the define (`-DBACKWARD_HAS_...=1`) and the
|
||||||
|
linkage details in your build system and even auto-detect which library is
|
||||||
|
installed, it's up to you.
|
||||||
|
|
||||||
|
That's it, you are all set, you should be getting nice stack traces like the
|
||||||
|
one at the beginning of this document.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
If you don't want to limit yourself to the defaults offered by `backward.cpp`,
|
||||||
|
and you want to take some random stack traces for whatever reason and pretty
|
||||||
|
print them the way you love or you decide to send them all to your buddies over
|
||||||
|
the Internet, you will appreciate the simplicity of Backward's API.
|
||||||
|
|
||||||
|
### Stacktrace
|
||||||
|
|
||||||
|
The StackTrace class lets you take a "snapshot" of the current stack.
|
||||||
|
You can use it like this:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
using namespace backward;
|
||||||
|
StackTrace st; st.load_here(32);
|
||||||
|
Printer p; p.print(st);
|
||||||
|
```
|
||||||
|
|
||||||
|
The public methods are:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
class StackTrace { public:
|
||||||
|
// Take a snapshot of the current stack, with at most "trace_cnt_max"
|
||||||
|
// traces in it. The first trace is the most recent (ie the current
|
||||||
|
// frame). You can also provide a trace address to load_from() assuming
|
||||||
|
// the address is a valid stack frame (useful for signal handling traces).
|
||||||
|
// Both function return size().
|
||||||
|
size_t load_here(size_t trace_cnt_max)
|
||||||
|
size_t load_from(void* address, size_t trace_cnt_max)
|
||||||
|
|
||||||
|
// The number of traces loaded. This can be less than "trace_cnt_max".
|
||||||
|
size_t size() const
|
||||||
|
|
||||||
|
// A unique id for the thread in which the trace was taken. The value
|
||||||
|
// 0 means the stack trace comes from the main thread.
|
||||||
|
size_t thread_id() const
|
||||||
|
|
||||||
|
// Retrieve a trace by index. 0 is the most recent trace, size()-1 is
|
||||||
|
// the oldest one.
|
||||||
|
Trace operator[](size_t trace_idx)
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### TraceResolver
|
||||||
|
|
||||||
|
The `TraceResolver` does the heavy lifting, and intends to transform a simple
|
||||||
|
`Trace` from its address into a fully detailed `ResolvedTrace` with the
|
||||||
|
filename of the source, line numbers, inlined functions and so on.
|
||||||
|
|
||||||
|
You can use it like this:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
using namespace backward;
|
||||||
|
StackTrace st; st.load_here(32);
|
||||||
|
|
||||||
|
TraceResolver tr; tr.load_stacktrace(st);
|
||||||
|
for (size_t i = 0; i < st.size(); ++i) {
|
||||||
|
ResolvedTrace trace = tr.resolve(st[i]);
|
||||||
|
std::cout << "#" << i
|
||||||
|
<< " " << trace.object_filename
|
||||||
|
<< " " << trace.object_function
|
||||||
|
<< " [" << trace.addr << "]"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The public methods are:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
class TraceResolver { public:
|
||||||
|
// Pre-load whatever is necessary from the stack trace.
|
||||||
|
template <class ST>
|
||||||
|
void load_stacktrace(ST&)
|
||||||
|
|
||||||
|
// Resolve a trace. It takes a ResolvedTrace, because a `Trace` is
|
||||||
|
// implicitly convertible to it.
|
||||||
|
ResolvedTrace resolve(ResolvedTrace t)
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### SnippetFactory
|
||||||
|
|
||||||
|
The SnippetFactory is a simple helper class to automatically load and cache
|
||||||
|
source files in order to extract code snippets.
|
||||||
|
|
||||||
|
```c++
|
||||||
|
class SnippetFactory { public:
|
||||||
|
// A snippet is a list of line numbers and line contents.
|
||||||
|
typedef std::vector<std::pair<size_t, std::string> > lines_t;
|
||||||
|
|
||||||
|
// Return a snippet starting at line_start with up to context_size lines.
|
||||||
|
lines_t get_snippet(const std::string& filename,
|
||||||
|
size_t line_start, size_t context_size)
|
||||||
|
|
||||||
|
// Return a combined snippet from two different locations and combine them.
|
||||||
|
// context_size / 2 lines will be extracted from each location.
|
||||||
|
lines_t get_combined_snippet(
|
||||||
|
const std::string& filename_a, size_t line_a,
|
||||||
|
const std::string& filename_b, size_t line_b,
|
||||||
|
size_t context_size)
|
||||||
|
|
||||||
|
// Tries to return a unified snippet if the two locations from the same
|
||||||
|
// file are close enough to fit inside one context_size, else returns
|
||||||
|
// the equivalent of get_combined_snippet().
|
||||||
|
lines_t get_coalesced_snippet(const std::string& filename,
|
||||||
|
size_t line_a, size_t line_b, size_t context_size)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Printer
|
||||||
|
|
||||||
|
A simpler way to pretty print a stack trace to the terminal. It will
|
||||||
|
automatically resolve the traces for you:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
using namespace backward;
|
||||||
|
StackTrace st; st.load_here(32);
|
||||||
|
Printer p;
|
||||||
|
p.object = true;
|
||||||
|
p.color_mode = ColorMode::always;
|
||||||
|
p.address = true;
|
||||||
|
p.print(st, stderr);
|
||||||
|
```
|
||||||
|
|
||||||
|
You can set a few options:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
class Printer { public:
|
||||||
|
// Print a little snippet of code if possible.
|
||||||
|
bool snippet = true;
|
||||||
|
|
||||||
|
// Colorize the trace
|
||||||
|
// - ColorMode::automatic: Activate colors if possible. For example, when using a TTY on linux.
|
||||||
|
// - ColorMode::always: Always use colors.
|
||||||
|
// - ColorMode::never: Never use colors.
|
||||||
|
bool color_mode = ColorMode::automatic;
|
||||||
|
|
||||||
|
// Add the addresses of every source location to the trace.
|
||||||
|
bool address = false;
|
||||||
|
|
||||||
|
// Even if there is a source location, also prints the object
|
||||||
|
// from where the trace came from.
|
||||||
|
bool object = false;
|
||||||
|
|
||||||
|
// Resolve and print a stack trace to the given C FILE* object.
|
||||||
|
// On linux, if the FILE* object is attached to a TTY,
|
||||||
|
// color will be used if color_mode is set to automatic.
|
||||||
|
template <typename StackTrace>
|
||||||
|
FILE* print(StackTrace& st, FILE* fp = stderr);
|
||||||
|
|
||||||
|
// Resolve and print a stack trace to the given std::ostream object.
|
||||||
|
// Color will only be used if color_mode is set to always.
|
||||||
|
template <typename ST>
|
||||||
|
std::ostream& print(ST& st, std::ostream& os);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### SignalHandling
|
||||||
|
|
||||||
|
A simple helper class that registers for you the most common signals and other
|
||||||
|
callbacks to segfault, hardware exception, un-handled exception etc.
|
||||||
|
|
||||||
|
`backward.cpp` simply uses it like that:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
backward::SignalHandling sh;
|
||||||
|
```
|
||||||
|
|
||||||
|
Creating the object registers all the different signals and hooks. Destroying
|
||||||
|
this object doesn't do anything. It exposes only one method:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
bool loaded() const // true if loaded with success
|
||||||
|
```
|
||||||
|
|
||||||
|
### Trace object
|
||||||
|
|
||||||
|
To keep the memory footprint of a loaded `StackTrace` on the low-side, there a
|
||||||
|
hierarchy of trace object, from a minimal `Trace `to a `ResolvedTrace`.
|
||||||
|
|
||||||
|
#### Simple trace
|
||||||
|
|
||||||
|
```c++
|
||||||
|
struct Trace {
|
||||||
|
void* addr; // address of the trace
|
||||||
|
size_t idx; // its index (0 == most recent)
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Resolved trace
|
||||||
|
|
||||||
|
A `ResolvedTrace` should contains a maximum of details about the location of
|
||||||
|
the trace in the source code. Note that not all fields might be set.
|
||||||
|
|
||||||
|
```c++
|
||||||
|
struct ResolvedTrace: public Trace {
|
||||||
|
|
||||||
|
struct SourceLoc {
|
||||||
|
std::string function;
|
||||||
|
std::string filename;
|
||||||
|
size_t line;
|
||||||
|
size_t col;
|
||||||
|
};
|
||||||
|
|
||||||
|
// In which binary object this trace is located.
|
||||||
|
std::string object_filename;
|
||||||
|
|
||||||
|
// The function in the object that contains the trace. This is not the same
|
||||||
|
// as source.function which can be an function inlined in object_function.
|
||||||
|
std::string object_function;
|
||||||
|
|
||||||
|
// The source location of this trace. It is possible for filename to be
|
||||||
|
// empty and for line/col to be invalid (value 0) if this information
|
||||||
|
// couldn't be deduced, for example if there is no debug information in the
|
||||||
|
// binary object.
|
||||||
|
SourceLoc source;
|
||||||
|
|
||||||
|
// An optional list of "inliners". All of these sources locations where
|
||||||
|
// inlined in the source location of the trace (the attribute right above).
|
||||||
|
// This is especially useful when you compile with optimizations turned on.
|
||||||
|
typedef std::vector<SourceLoc> source_locs_t;
|
||||||
|
source_locs_t inliners;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contact and copyright
|
||||||
|
|
||||||
|
François-Xavier Bourlet <bombela@gmail.com>
|
||||||
|
|
||||||
|
Copyright 2013-2017 Google Inc. All Rights Reserved.
|
||||||
|
MIT License.
|
||||||
|
|
||||||
|
### Disclaimer
|
||||||
|
|
||||||
|
Although this project is owned by Google Inc. this is not a Google supported or
|
||||||
|
affiliated project.
|
42
extern/backward/backward.cpp
vendored
Normal file
42
extern/backward/backward.cpp
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Pick your poison.
|
||||||
|
//
|
||||||
|
// On GNU/Linux, you have few choices to get the most out of your stack trace.
|
||||||
|
//
|
||||||
|
// By default you get:
|
||||||
|
// - object filename
|
||||||
|
// - function name
|
||||||
|
//
|
||||||
|
// In order to add:
|
||||||
|
// - source filename
|
||||||
|
// - line and column numbers
|
||||||
|
// - source code snippet (assuming the file is accessible)
|
||||||
|
|
||||||
|
// Install one of the following libraries then uncomment one of the macro (or
|
||||||
|
// better, add the detection of the lib and the macro definition in your build
|
||||||
|
// system)
|
||||||
|
|
||||||
|
// - apt-get install libdw-dev ...
|
||||||
|
// - g++/clang++ -ldw ...
|
||||||
|
// #define BACKWARD_HAS_DW 1
|
||||||
|
|
||||||
|
// - apt-get install binutils-dev ...
|
||||||
|
// - g++/clang++ -lbfd ...
|
||||||
|
// #define BACKWARD_HAS_BFD 1
|
||||||
|
|
||||||
|
// - apt-get install libdwarf-dev ...
|
||||||
|
// - g++/clang++ -ldwarf ...
|
||||||
|
// #define BACKWARD_HAS_DWARF 1
|
||||||
|
|
||||||
|
// Regardless of the library you choose to read the debug information,
|
||||||
|
// for potentially more detailed stack traces you can use libunwind
|
||||||
|
// - apt-get install libunwind-dev
|
||||||
|
// - g++/clang++ -lunwind
|
||||||
|
// #define BACKWARD_HAS_LIBUNWIND 1
|
||||||
|
|
||||||
|
#include "backward.hpp"
|
||||||
|
|
||||||
|
namespace backward {
|
||||||
|
|
||||||
|
backward::SignalHandling sh;
|
||||||
|
|
||||||
|
} // namespace backward
|
4488
extern/backward/backward.hpp
vendored
Normal file
4488
extern/backward/backward.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
77
extern/backward/builds.sh
vendored
Executable file
77
extern/backward/builds.sh
vendored
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
COMPILERS_CXX98=`cat<<EOF
|
||||||
|
gcc-4.4
|
||||||
|
gcc-4.6
|
||||||
|
gcc-4.7
|
||||||
|
gcc-4.8
|
||||||
|
clang
|
||||||
|
EOF`
|
||||||
|
|
||||||
|
COMPILERS_CXX11=`cat<<EOF
|
||||||
|
gcc-4.7
|
||||||
|
gcc-4.8
|
||||||
|
clang
|
||||||
|
EOF`
|
||||||
|
|
||||||
|
|
||||||
|
function mkbuild() {
|
||||||
|
local compiler=$1
|
||||||
|
local lang=$2
|
||||||
|
local buildtype=$3
|
||||||
|
local builddir="$4"
|
||||||
|
export CC=$compiler
|
||||||
|
export CXX=`echo $compiler | sed -e 's/clang/clang++/' -e 's/gcc/g++/'`
|
||||||
|
export CXXFLAGS="-std=$lang"
|
||||||
|
echo "Creating $builddir"
|
||||||
|
mkdir $builddir 2>/dev/null
|
||||||
|
(
|
||||||
|
cd "$builddir"
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=$buildtype -DBACKWARD_TESTS=ON ..
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
local builddir=$1
|
||||||
|
shift
|
||||||
|
make -C "$builddir" $@
|
||||||
|
}
|
||||||
|
|
||||||
|
function dotest() {
|
||||||
|
local builddir=$1
|
||||||
|
shift
|
||||||
|
make -C "$builddir" test $@
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_action() {
|
||||||
|
local lang=$1
|
||||||
|
local action=$2
|
||||||
|
shift 2
|
||||||
|
|
||||||
|
for compiler in $COMPILERS; do
|
||||||
|
local builddir="build_${lang}_${compiler}"
|
||||||
|
|
||||||
|
if [[ $action == "cmake" ]]; then
|
||||||
|
buildtype=$1
|
||||||
|
mkbuild $compiler $lang "$buildtype" "$builddir"
|
||||||
|
[[ $? != 0 ]] && exit
|
||||||
|
elif [[ $action == "make" ]]; then
|
||||||
|
build "$builddir" $@
|
||||||
|
[[ $? != 0 ]] && exit
|
||||||
|
elif [[ $action == "test" ]]; then
|
||||||
|
dotest "$builddir" $@
|
||||||
|
[[ $? != 0 ]] && exit
|
||||||
|
elif [[ $action == "clean" ]]; then
|
||||||
|
rm -r "$builddir"
|
||||||
|
else
|
||||||
|
echo "usage: $0 cmake [debug|release|relwithdbg]|make|test|clean"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
COMPILERS=$COMPILERS_CXX98
|
||||||
|
do_action c++98 $@
|
||||||
|
COMPILERS=$COMPILERS_CXX11
|
||||||
|
do_action c++11 $@
|
16
extern/igfd/ImGuiFileDialog.cpp
vendored
16
extern/igfd/ImGuiFileDialog.cpp
vendored
|
@ -1220,6 +1220,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1249,6 +1251,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1283,6 +1287,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1298,6 +1304,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1319,6 +1327,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1334,6 +1344,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1355,6 +1367,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1370,6 +1384,8 @@ namespace IGFD
|
||||||
std::sort(prFileList.begin(), prFileList.end(),
|
std::sort(prFileList.begin(), prFileList.end(),
|
||||||
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
[](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool
|
||||||
{
|
{
|
||||||
|
if (a==NULL || b==NULL)
|
||||||
|
return false;
|
||||||
if (!a.use_count() || !b.use_count())
|
if (!a.use_count() || !b.use_count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
13
extern/imgui_patched/imgui.cpp
vendored
13
extern/imgui_patched/imgui.cpp
vendored
|
@ -1075,6 +1075,7 @@ ImGuiStyle::ImGuiStyle()
|
||||||
PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested.
|
PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested.
|
||||||
FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets)
|
FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets)
|
||||||
FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
|
FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
|
||||||
|
FrameShading = 0.0f; // Gradient intensity of frame
|
||||||
FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested.
|
FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested.
|
||||||
ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
|
ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
|
||||||
ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
||||||
|
@ -2881,6 +2882,7 @@ static const ImGuiStyleVarInfo GStyleVarInfo[] =
|
||||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
|
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
|
||||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
||||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
||||||
|
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameShading) }, // ImGuiStyleVar_FrameShading
|
||||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
|
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
|
||||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
||||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
||||||
|
@ -3205,7 +3207,14 @@ void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border,
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
if (g.Style.FrameShading>0.0f) {
|
||||||
|
ImVec4 fill_colPre=ImGui::ColorConvertU32ToFloat4(fill_col);
|
||||||
|
fill_colPre.w*=1.0f-g.Style.FrameShading;
|
||||||
|
ImU32 fill_col1=ImGui::ColorConvertFloat4ToU32(fill_colPre);
|
||||||
|
window->DrawList->AddRectFilledMultiColor(p_min, p_max, fill_col, fill_col, fill_col1, fill_col1, rounding);
|
||||||
|
} else {
|
||||||
window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
|
window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
|
||||||
|
}
|
||||||
const float border_size = g.Style.FrameBorderSize;
|
const float border_size = g.Style.FrameBorderSize;
|
||||||
if (border && border_size > 0.0f)
|
if (border && border_size > 0.0f)
|
||||||
{
|
{
|
||||||
|
@ -3909,6 +3918,8 @@ void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* nod
|
||||||
if (root_node->OnlyNodeWithWindows != node || root_node->CentralNode != NULL) // -V1051 PVS-Studio thinks node should be root_node and is wrong about that.
|
if (root_node->OnlyNodeWithWindows != node || root_node->CentralNode != NULL) // -V1051 PVS-Studio thinks node should be root_node and is wrong about that.
|
||||||
if (undock_floating_node || root_node->IsDockSpace())
|
if (undock_floating_node || root_node->IsDockSpace())
|
||||||
can_undock_node = true;
|
can_undock_node = true;
|
||||||
|
if (node->MergedFlags & ImGuiDockNodeFlags_NoMove)
|
||||||
|
can_undock_node = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool clicked = IsMouseClicked(0);
|
const bool clicked = IsMouseClicked(0);
|
||||||
|
@ -6122,7 +6133,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||||
|
|
||||||
// Docking: Unhide tab bar (small triangle in the corner), drag from small triangle to quickly undock
|
// Docking: Unhide tab bar (small triangle in the corner), drag from small triangle to quickly undock
|
||||||
ImGuiDockNode* node = window->DockNode;
|
ImGuiDockNode* node = window->DockNode;
|
||||||
if (window->DockIsActive && node->IsHiddenTabBar() && !node->IsNoTabBar())
|
if (window->DockIsActive && node->IsHiddenTabBar() && !node->IsNoTabBar() && !(node->MergedFlags & ImGuiDockNodeFlags_NoMove))
|
||||||
{
|
{
|
||||||
float unhide_sz_draw = ImFloor(g.FontSize * 0.70f);
|
float unhide_sz_draw = ImFloor(g.FontSize * 0.70f);
|
||||||
float unhide_sz_hit = ImFloor(g.FontSize * 0.55f);
|
float unhide_sz_hit = ImFloor(g.FontSize * 0.55f);
|
||||||
|
|
7
extern/imgui_patched/imgui.h
vendored
7
extern/imgui_patched/imgui.h
vendored
|
@ -1342,7 +1342,8 @@ enum ImGuiDockNodeFlags_
|
||||||
ImGuiDockNodeFlags_PassthruCentralNode = 1 << 3, // Shared // Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
|
ImGuiDockNodeFlags_PassthruCentralNode = 1 << 3, // Shared // Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
|
||||||
ImGuiDockNodeFlags_NoSplit = 1 << 4, // Shared/Local // Disable splitting the node into smaller nodes. Useful e.g. when embedding dockspaces into a main root one (the root one may have splitting disabled to reduce confusion). Note: when turned off, existing splits will be preserved.
|
ImGuiDockNodeFlags_NoSplit = 1 << 4, // Shared/Local // Disable splitting the node into smaller nodes. Useful e.g. when embedding dockspaces into a main root one (the root one may have splitting disabled to reduce confusion). Note: when turned off, existing splits will be preserved.
|
||||||
ImGuiDockNodeFlags_NoResize = 1 << 5, // Shared/Local // Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces.
|
ImGuiDockNodeFlags_NoResize = 1 << 5, // Shared/Local // Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces.
|
||||||
ImGuiDockNodeFlags_AutoHideTabBar = 1 << 6 // Shared/Local // Tab bar will automatically hide when there is a single window in the dock node.
|
ImGuiDockNodeFlags_AutoHideTabBar = 1 << 6, // Shared/Local // Tab bar will automatically hide when there is a single window in the dock node.
|
||||||
|
ImGuiDockNodeFlags_NoMove = 1 << 7 // Shared/Local // Disable moving node
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
|
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
|
||||||
|
@ -1680,6 +1681,7 @@ enum ImGuiStyleVar_
|
||||||
ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize
|
ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize
|
||||||
ImGuiStyleVar_FramePadding, // ImVec2 FramePadding
|
ImGuiStyleVar_FramePadding, // ImVec2 FramePadding
|
||||||
ImGuiStyleVar_FrameRounding, // float FrameRounding
|
ImGuiStyleVar_FrameRounding, // float FrameRounding
|
||||||
|
ImGuiStyleVar_FrameShading, // float FrameShading
|
||||||
ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize
|
ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize
|
||||||
ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing
|
ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing
|
||||||
ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing
|
ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing
|
||||||
|
@ -1926,6 +1928,7 @@ struct ImGuiStyle
|
||||||
float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
||||||
ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets).
|
ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets).
|
||||||
float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
|
float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
|
||||||
|
float FrameShading;
|
||||||
float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
||||||
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
|
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
|
||||||
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
|
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
|
||||||
|
@ -2652,7 +2655,7 @@ struct ImDrawList
|
||||||
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size)
|
IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size)
|
||||||
IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0); // a: upper-left, b: lower-right (== upper-left + size)
|
IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0); // a: upper-left, b: lower-right (== upper-left + size)
|
||||||
IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
|
IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left, float rounding = 0.0f, ImDrawFlags flags = 0);
|
||||||
IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col);
|
IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col);
|
||||||
IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f);
|
||||||
|
|
49
extern/imgui_patched/imgui_draw.cpp
vendored
49
extern/imgui_patched/imgui_draw.cpp
vendored
|
@ -1427,11 +1427,58 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c
|
||||||
}
|
}
|
||||||
|
|
||||||
// p_min = upper-left, p_max = lower-right
|
// p_min = upper-left, p_max = lower-right
|
||||||
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left, float rounding, ImDrawFlags flags)
|
||||||
{
|
{
|
||||||
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (rounding > 0.0f) {
|
||||||
|
// https://github.com/ocornut/imgui/issues/3710
|
||||||
|
// TODO: optimize
|
||||||
|
const int v0 = VtxBuffer.Size;
|
||||||
|
AddRectFilled(p_min,p_max,0xffffffff,rounding,flags);
|
||||||
|
const int v1 = VtxBuffer.Size;
|
||||||
|
|
||||||
|
for (int i=v0; i<v1; i++) {
|
||||||
|
ImDrawVert* v=&VtxBuffer.Data[i];
|
||||||
|
ImVec4 col0=ImGui::ColorConvertU32ToFloat4(col_upr_left);
|
||||||
|
ImVec4 col1=ImGui::ColorConvertU32ToFloat4(col_bot_left);
|
||||||
|
ImVec4 col2=ImGui::ColorConvertU32ToFloat4(col_upr_right);
|
||||||
|
ImVec4 col3=ImGui::ColorConvertU32ToFloat4(col_bot_right);
|
||||||
|
|
||||||
|
float shadeX=(v->pos.x-p_min.x)/(p_max.x-p_min.x);
|
||||||
|
float shadeY=(v->pos.y-p_min.y)/(p_max.y-p_min.y);
|
||||||
|
if (shadeX<0.0f) shadeX=0.0f;
|
||||||
|
if (shadeX>1.0f) shadeX=1.0f;
|
||||||
|
if (shadeY<0.0f) shadeY=0.0f;
|
||||||
|
if (shadeY>1.0f) shadeY=1.0f;
|
||||||
|
|
||||||
|
col0.x+=(col2.x-col0.x)*shadeX;
|
||||||
|
col0.y+=(col2.y-col0.y)*shadeX;
|
||||||
|
col0.z+=(col2.z-col0.z)*shadeX;
|
||||||
|
col0.w+=(col2.w-col0.w)*shadeX;
|
||||||
|
|
||||||
|
col1.x+=(col3.x-col1.x)*shadeX;
|
||||||
|
col1.y+=(col3.y-col1.y)*shadeX;
|
||||||
|
col1.z+=(col3.z-col1.z)*shadeX;
|
||||||
|
col1.w+=(col3.w-col1.w)*shadeX;
|
||||||
|
|
||||||
|
col0.x+=(col1.x-col0.x)*shadeY;
|
||||||
|
col0.y+=(col1.y-col0.y)*shadeY;
|
||||||
|
col0.z+=(col1.z-col0.z)*shadeY;
|
||||||
|
col0.w+=(col1.w-col0.w)*shadeY;
|
||||||
|
|
||||||
|
ImVec4 conv=ImGui::ColorConvertU32ToFloat4(v->col);
|
||||||
|
col0.x*=conv.x;
|
||||||
|
col0.y*=conv.y;
|
||||||
|
col0.z*=conv.z;
|
||||||
|
col0.w*=conv.w;
|
||||||
|
|
||||||
|
v->col=ImGui::ColorConvertFloat4ToU32(col0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const ImVec2 uv = _Data->TexUvWhitePixel;
|
const ImVec2 uv = _Data->TexUvWhitePixel;
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2));
|
||||||
|
|
8
extern/imgui_patched/imgui_widgets.cpp
vendored
8
extern/imgui_patched/imgui_widgets.cpp
vendored
|
@ -8160,12 +8160,16 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||||
// Drag and drop a single floating window node moves it
|
// Drag and drop a single floating window node moves it
|
||||||
ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
|
ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
|
||||||
const bool single_floating_window_node = node && node->IsFloatingNode() && (node->Windows.Size == 1);
|
const bool single_floating_window_node = node && node->IsFloatingNode() && (node->Windows.Size == 1);
|
||||||
|
bool can_undock = true;
|
||||||
|
if (node) {
|
||||||
|
if (node->MergedFlags & ImGuiDockNodeFlags_NoMove) can_undock = false;
|
||||||
|
}
|
||||||
if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
|
if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
|
||||||
{
|
{
|
||||||
// Move
|
// Move
|
||||||
StartMouseMovingWindow(docked_window);
|
StartMouseMovingWindow(docked_window);
|
||||||
}
|
}
|
||||||
else if (held && !tab_appearing && IsMouseDragging(0))
|
else if (held && !tab_appearing && IsMouseDragging(0) && can_undock)
|
||||||
{
|
{
|
||||||
// Drag and drop: re-order tabs
|
// Drag and drop: re-order tabs
|
||||||
int drag_dir = 0;
|
int drag_dir = 0;
|
||||||
|
@ -8247,7 +8251,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||||
flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
|
flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
|
||||||
|
|
||||||
// Render tab label, process close button
|
// Render tab label, process close button
|
||||||
const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, docked_window ? docked_window->ID : id) : 0;
|
const ImGuiID close_button_id = (p_open && can_undock) ? GetIDWithSeed("#CLOSE", NULL, docked_window ? docked_window->ID : id) : 0;
|
||||||
bool just_closed;
|
bool just_closed;
|
||||||
bool text_clipped;
|
bool text_clipped;
|
||||||
TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped);
|
TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Namco 163
|
# Namco C163
|
||||||
|
|
||||||
This is Namco's one of NES mapper, with up to 8 wavetable channels. It has also 128 byte of internal RAM, both channel register and wavetables are stored here. Wavetables are variable size and freely allocable anywhere in RAM, it means it can be uses part of or continuously pre-loaded waveform and/or its sequences in RAM. But waveform RAM area becomes smaller as much as activating more channels; Channel register consumes 8 byte for each channels. You must avoid conflict with channel register area and waveform for avoid channel playback broken.
|
This is Namco's one of NES mapper, with up to 8 wavetable channels. It has also 128 byte of internal RAM, both channel register and wavetables are stored here. Wavetables are variable size and freely allocable anywhere in RAM, it means it can be uses part of or continuously pre-loaded waveform and/or its sequences in RAM. But waveform RAM area becomes smaller as much as activating more channels; Channel register consumes 8 byte for each channels. You must avoid conflict with channel register area and waveform for avoid channel playback broken.
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ furthermore, an `or reserved` indicates this field is always present, but is res
|
||||||
|
|
||||||
the format versions are:
|
the format versions are:
|
||||||
|
|
||||||
|
- 97: Furnace dev97
|
||||||
- 96: Furnace dev96
|
- 96: Furnace dev96
|
||||||
- 95: Furnace dev95
|
- 95: Furnace dev95
|
||||||
- 94: Furnace dev94
|
- 94: Furnace dev94
|
||||||
|
@ -300,7 +301,8 @@ size | description
|
||||||
1 | SN duty macro always resets phase (>=86) or reserved
|
1 | SN duty macro always resets phase (>=86) or reserved
|
||||||
1 | pitch macro is linear (>=90) or reserved
|
1 | pitch macro is linear (>=90) or reserved
|
||||||
1 | pitch slide speed in full linear pitch mode (>=94) or reserved
|
1 | pitch slide speed in full linear pitch mode (>=94) or reserved
|
||||||
14 | reserved
|
1 | old octave boundary behavior (>=97) or reserved
|
||||||
|
13 | reserved
|
||||||
--- | **virtual tempo data**
|
--- | **virtual tempo data**
|
||||||
2 | virtual tempo numerator of first song (>=96) or reserved
|
2 | virtual tempo numerator of first song (>=96) or reserved
|
||||||
2 | virtual tempo denominator of first song (>=96) or reserved
|
2 | virtual tempo denominator of first song (>=96) or reserved
|
||||||
|
|
42
src/backtrace.cpp
Normal file
42
src/backtrace.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Pick your poison.
|
||||||
|
//
|
||||||
|
// On GNU/Linux, you have few choices to get the most out of your stack trace.
|
||||||
|
//
|
||||||
|
// By default you get:
|
||||||
|
// - object filename
|
||||||
|
// - function name
|
||||||
|
//
|
||||||
|
// In order to add:
|
||||||
|
// - source filename
|
||||||
|
// - line and column numbers
|
||||||
|
// - source code snippet (assuming the file is accessible)
|
||||||
|
|
||||||
|
// Install one of the following libraries then uncomment one of the macro (or
|
||||||
|
// better, add the detection of the lib and the macro definition in your build
|
||||||
|
// system)
|
||||||
|
|
||||||
|
// - apt-get install libdw-dev ...
|
||||||
|
// - g++/clang++ -ldw ...
|
||||||
|
// #define BACKWARD_HAS_DW 1
|
||||||
|
|
||||||
|
// - apt-get install binutils-dev ...
|
||||||
|
// - g++/clang++ -lbfd ...
|
||||||
|
// #define BACKWARD_HAS_BFD 1
|
||||||
|
|
||||||
|
// - apt-get install libdwarf-dev ...
|
||||||
|
// - g++/clang++ -ldwarf ...
|
||||||
|
// #define BACKWARD_HAS_DWARF 1
|
||||||
|
|
||||||
|
// Regardless of the library you choose to read the debug information,
|
||||||
|
// for potentially more detailed stack traces you can use libunwind
|
||||||
|
// - apt-get install libunwind-dev
|
||||||
|
// - g++/clang++ -lunwind
|
||||||
|
// #define BACKWARD_HAS_LIBUNWIND 1
|
||||||
|
|
||||||
|
#include "../extern/backward/backward.hpp"
|
||||||
|
|
||||||
|
namespace backward {
|
||||||
|
|
||||||
|
backward::SignalHandling sh;
|
||||||
|
|
||||||
|
} // namespace backward
|
|
@ -21,6 +21,8 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "platform/genesis.h"
|
#include "platform/genesis.h"
|
||||||
#include "platform/genesisext.h"
|
#include "platform/genesisext.h"
|
||||||
|
#include "platform/msm6258.h"
|
||||||
|
#include "platform/msm6295.h"
|
||||||
#include "platform/namcowsg.h"
|
#include "platform/namcowsg.h"
|
||||||
#include "platform/sms.h"
|
#include "platform/sms.h"
|
||||||
#include "platform/opll.h"
|
#include "platform/opll.h"
|
||||||
|
@ -190,6 +192,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
|
||||||
break;
|
break;
|
||||||
case DIV_SYSTEM_SMS:
|
case DIV_SYSTEM_SMS:
|
||||||
dispatch=new DivPlatformSMS;
|
dispatch=new DivPlatformSMS;
|
||||||
|
((DivPlatformSMS*)dispatch)->setNuked(eng->getConfInt("snCore",0));
|
||||||
break;
|
break;
|
||||||
case DIV_SYSTEM_GB:
|
case DIV_SYSTEM_GB:
|
||||||
dispatch=new DivPlatformGB;
|
dispatch=new DivPlatformGB;
|
||||||
|
@ -368,6 +371,12 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
|
||||||
case DIV_SYSTEM_SOUND_UNIT:
|
case DIV_SYSTEM_SOUND_UNIT:
|
||||||
dispatch=new DivPlatformSoundUnit;
|
dispatch=new DivPlatformSoundUnit;
|
||||||
break;
|
break;
|
||||||
|
case DIV_SYSTEM_MSM6258:
|
||||||
|
dispatch=new DivPlatformMSM6258;
|
||||||
|
break;
|
||||||
|
case DIV_SYSTEM_MSM6295:
|
||||||
|
dispatch=new DivPlatformMSM6295;
|
||||||
|
break;
|
||||||
case DIV_SYSTEM_NAMCO:
|
case DIV_SYSTEM_NAMCO:
|
||||||
dispatch=new DivPlatformNamcoWSG;
|
dispatch=new DivPlatformNamcoWSG;
|
||||||
// Pac-Man (TODO: support Pole Position?)
|
// Pac-Man (TODO: support Pole Position?)
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
#include "safeReader.h"
|
#include "safeReader.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
#include "../fileutils.h"
|
#include "../fileutils.h"
|
||||||
|
#ifdef HAVE_SDL2
|
||||||
#include "../audio/sdl.h"
|
#include "../audio/sdl.h"
|
||||||
|
#endif
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -34,7 +36,9 @@
|
||||||
#include "../audio/jack.h"
|
#include "../audio/jack.h"
|
||||||
#endif
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#ifdef HAVE_SNDFILE
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
#endif
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
|
|
||||||
void process(void* u, float** in, float** out, int inChans, int outChans, unsigned int size) {
|
void process(void* u, float** in, float** out, int inChans, int outChans, unsigned int size) {
|
||||||
|
@ -187,6 +191,7 @@ bool DivEngine::isExporting() {
|
||||||
|
|
||||||
#define EXPORT_BUFSIZE 2048
|
#define EXPORT_BUFSIZE 2048
|
||||||
|
|
||||||
|
#ifdef HAVE_SNDFILE
|
||||||
void DivEngine::runExportThread() {
|
void DivEngine::runExportThread() {
|
||||||
switch (exportMode) {
|
switch (exportMode) {
|
||||||
case DIV_EXPORT_MODE_ONE: {
|
case DIV_EXPORT_MODE_ONE: {
|
||||||
|
@ -438,8 +443,16 @@ void DivEngine::runExportThread() {
|
||||||
}
|
}
|
||||||
stopExport=false;
|
stopExport=false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void DivEngine::runExportThread() {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool DivEngine::saveAudio(const char* path, int loops, DivAudioExportModes mode) {
|
bool DivEngine::saveAudio(const char* path, int loops, DivAudioExportModes mode) {
|
||||||
|
#ifndef HAVE_SNDFILE
|
||||||
|
logE("Furnace was not compiled with libsndfile. cannot export!");
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
exportPath=path;
|
exportPath=path;
|
||||||
exportMode=mode;
|
exportMode=mode;
|
||||||
if (exportMode!=DIV_EXPORT_MODE_ONE) {
|
if (exportMode!=DIV_EXPORT_MODE_ONE) {
|
||||||
|
@ -461,6 +474,7 @@ bool DivEngine::saveAudio(const char* path, int loops, DivAudioExportModes mode)
|
||||||
remainingLoops=loops;
|
remainingLoops=loops;
|
||||||
exportThread=new std::thread(_runExportThread,this);
|
exportThread=new std::thread(_runExportThread,this);
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::waitAudioFile() {
|
void DivEngine::waitAudioFile() {
|
||||||
|
@ -2027,6 +2041,10 @@ int DivEngine::addSampleFromFile(const char* path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_SNDFILE
|
||||||
|
lastError="Furnace was not compiled with libsndfile!";
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
SF_INFO si;
|
SF_INFO si;
|
||||||
SNDFILE* f=sf_open(path,SFM_READ,&si);
|
SNDFILE* f=sf_open(path,SFM_READ,&si);
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
|
@ -2107,6 +2125,7 @@ int DivEngine::addSampleFromFile(const char* path) {
|
||||||
renderSamples();
|
renderSamples();
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
return sampleCount;
|
return sampleCount;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::delSample(int index) {
|
void DivEngine::delSample(int index) {
|
||||||
|
@ -2757,13 +2776,23 @@ bool DivEngine::initAudioBackend() {
|
||||||
logE("Furnace was not compiled with JACK support!");
|
logE("Furnace was not compiled with JACK support!");
|
||||||
setConf("audioEngine","SDL");
|
setConf("audioEngine","SDL");
|
||||||
saveConf();
|
saveConf();
|
||||||
|
#ifdef HAVE_SDL2
|
||||||
output=new TAAudioSDL;
|
output=new TAAudioSDL;
|
||||||
|
#else
|
||||||
|
logE("Furnace was not compiled with SDL support either!");
|
||||||
|
output=new TAAudio;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
output=new TAAudioJACK;
|
output=new TAAudioJACK;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case DIV_AUDIO_SDL:
|
case DIV_AUDIO_SDL:
|
||||||
|
#ifdef HAVE_SDL2
|
||||||
output=new TAAudioSDL;
|
output=new TAAudioSDL;
|
||||||
|
#else
|
||||||
|
logE("Furnace was not compiled with SDL support!");
|
||||||
|
output=new TAAudio;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case DIV_AUDIO_DUMMY:
|
case DIV_AUDIO_DUMMY:
|
||||||
output=new TAAudio;
|
output=new TAAudio;
|
||||||
|
@ -2858,7 +2887,7 @@ bool DivEngine::init() {
|
||||||
// init config
|
// init config
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
configPath=getWinConfigPath();
|
configPath=getWinConfigPath();
|
||||||
#elif defined(ANDROID)
|
#elif defined(IS_MOBILE)
|
||||||
configPath=SDL_GetPrefPath("tildearrow","furnace");
|
configPath=SDL_GetPrefPath("tildearrow","furnace");
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
|
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
|
||||||
#define BUSY_END isBusy.unlock(); softLocked=false;
|
#define BUSY_END isBusy.unlock(); softLocked=false;
|
||||||
|
|
||||||
#define DIV_VERSION "dev96"
|
#define DIV_VERSION "dev97"
|
||||||
#define DIV_ENGINE_VERSION 96
|
#define DIV_ENGINE_VERSION 97
|
||||||
|
|
||||||
// for imports
|
// for imports
|
||||||
#define DIV_VERSION_MOD 0xff01
|
#define DIV_VERSION_MOD 0xff01
|
||||||
|
|
|
@ -166,6 +166,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
ds.e1e2AlsoTakePriority=true;
|
ds.e1e2AlsoTakePriority=true;
|
||||||
ds.fbPortaPause=true;
|
ds.fbPortaPause=true;
|
||||||
ds.snDutyReset=true;
|
ds.snDutyReset=true;
|
||||||
|
ds.oldOctaveBoundary=false;
|
||||||
|
|
||||||
// 1.1 compat flags
|
// 1.1 compat flags
|
||||||
if (ds.version>24) {
|
if (ds.version>24) {
|
||||||
|
@ -307,19 +308,19 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
logI("reading instruments (%d)...",ds.insLen);
|
logI("reading instruments (%d)...",ds.insLen);
|
||||||
for (int i=0; i<ds.insLen; i++) {
|
for (int i=0; i<ds.insLen; i++) {
|
||||||
DivInstrument* ins=new DivInstrument;
|
DivInstrument* ins=new DivInstrument;
|
||||||
|
unsigned char mode=0;
|
||||||
if (ds.version>0x05) {
|
if (ds.version>0x05) {
|
||||||
ins->name=reader.readString((unsigned char)reader.readC());
|
ins->name=reader.readString((unsigned char)reader.readC());
|
||||||
}
|
}
|
||||||
logD("%d name: %s",i,ins->name.c_str());
|
logD("%d name: %s",i,ins->name.c_str());
|
||||||
if (ds.version<0x0b) {
|
if (ds.version<0x0b) {
|
||||||
// instruments in ancient versions were all FM or STD.
|
// instruments in ancient versions were all FM or STD.
|
||||||
ins->mode=1;
|
mode=1;
|
||||||
} else {
|
} else {
|
||||||
unsigned char mode=reader.readC();
|
mode=reader.readC();
|
||||||
if (mode>1) logW("%d: invalid instrument mode %d!",i,mode);
|
if (mode>1) logW("%d: invalid instrument mode %d!",i,mode);
|
||||||
ins->mode=mode;
|
|
||||||
}
|
}
|
||||||
ins->type=ins->mode?DIV_INS_FM:DIV_INS_STD;
|
ins->type=mode?DIV_INS_FM:DIV_INS_STD;
|
||||||
if (ds.system[0]==DIV_SYSTEM_GB) {
|
if (ds.system[0]==DIV_SYSTEM_GB) {
|
||||||
ins->type=DIV_INS_GB;
|
ins->type=DIV_INS_GB;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +330,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
if (ds.system[0]==DIV_SYSTEM_YM2610 || ds.system[0]==DIV_SYSTEM_YM2610_EXT
|
if (ds.system[0]==DIV_SYSTEM_YM2610 || ds.system[0]==DIV_SYSTEM_YM2610_EXT
|
||||||
|| ds.system[0]==DIV_SYSTEM_YM2610_FULL || ds.system[0]==DIV_SYSTEM_YM2610_FULL_EXT
|
|| ds.system[0]==DIV_SYSTEM_YM2610_FULL || ds.system[0]==DIV_SYSTEM_YM2610_FULL_EXT
|
||||||
|| ds.system[0]==DIV_SYSTEM_YM2610B || ds.system[0]==DIV_SYSTEM_YM2610B_EXT) {
|
|| ds.system[0]==DIV_SYSTEM_YM2610B || ds.system[0]==DIV_SYSTEM_YM2610B_EXT) {
|
||||||
if (!ins->mode) {
|
if (!mode) {
|
||||||
ins->type=DIV_INS_AY;
|
ins->type=DIV_INS_AY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +344,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
ins->type=DIV_INS_OPL;
|
ins->type=DIV_INS_OPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ins->mode) { // FM
|
if (mode) { // FM
|
||||||
if (ds.version>0x05) {
|
if (ds.version>0x05) {
|
||||||
ins->fm.alg=reader.readC();
|
ins->fm.alg=reader.readC();
|
||||||
if (ds.version<0x13) {
|
if (ds.version<0x13) {
|
||||||
|
@ -1027,6 +1028,9 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
if (ds.version<90) {
|
if (ds.version<90) {
|
||||||
ds.pitchMacroIsLinear=false;
|
ds.pitchMacroIsLinear=false;
|
||||||
}
|
}
|
||||||
|
if (ds.version<97) {
|
||||||
|
ds.oldOctaveBoundary=true;
|
||||||
|
}
|
||||||
ds.isDMF=false;
|
ds.isDMF=false;
|
||||||
|
|
||||||
reader.readS(); // reserved
|
reader.readS(); // reserved
|
||||||
|
@ -1404,7 +1408,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
} else {
|
} else {
|
||||||
reader.readC();
|
reader.readC();
|
||||||
}
|
}
|
||||||
for (int i=0; i<14; i++) {
|
if (ds.version>=97) {
|
||||||
|
ds.oldOctaveBoundary=reader.readC();
|
||||||
|
} else {
|
||||||
|
reader.readC();
|
||||||
|
}
|
||||||
|
for (int i=0; i<13; i++) {
|
||||||
reader.readC();
|
reader.readC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2405,8 +2414,8 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len) {
|
||||||
|
|
||||||
const int dpcmNotes=(blockVersion>=2)?96:72;
|
const int dpcmNotes=(blockVersion>=2)?96:72;
|
||||||
for (int j=0; j<dpcmNotes; j++) {
|
for (int j=0; j<dpcmNotes; j++) {
|
||||||
ins->amiga.noteMap[j]=(short)((unsigned char)reader.readC())-1;
|
ins->amiga.noteMap[j].ind=(short)((unsigned char)reader.readC())-1;
|
||||||
ins->amiga.noteFreq[j]=(unsigned char)reader.readC();
|
ins->amiga.noteMap[j].freq=(unsigned char)reader.readC();
|
||||||
if (blockVersion>=6) {
|
if (blockVersion>=6) {
|
||||||
reader.readC(); // DMC value
|
reader.readC(); // DMC value
|
||||||
}
|
}
|
||||||
|
@ -2884,7 +2893,8 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
w->writeC(song.snDutyReset);
|
w->writeC(song.snDutyReset);
|
||||||
w->writeC(song.pitchMacroIsLinear);
|
w->writeC(song.pitchMacroIsLinear);
|
||||||
w->writeC(song.pitchSlideSpeed);
|
w->writeC(song.pitchSlideSpeed);
|
||||||
for (int i=0; i<14; i++) {
|
w->writeC(song.oldOctaveBoundary);
|
||||||
|
for (int i=0; i<13; i++) {
|
||||||
w->writeC(0);
|
w->writeC(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3234,15 +3244,15 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
|
||||||
w->writeString(i->name,true);
|
w->writeString(i->name,true);
|
||||||
|
|
||||||
// safety check
|
// safety check
|
||||||
if (!isFMSystem(sys) && i->mode) {
|
if (!isFMSystem(sys) && i->type!=DIV_INS_STD && i->type!=DIV_INS_FDS) {
|
||||||
i->mode=0;
|
i->type=DIV_INS_STD;
|
||||||
}
|
}
|
||||||
if (!isSTDSystem(sys) && i->mode==0) {
|
if (!isSTDSystem(sys) && i->type!=DIV_INS_FM) {
|
||||||
i->mode=1;
|
i->type=DIV_INS_FM;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->writeC(i->mode);
|
w->writeC((i->type==DIV_INS_FM || i->type==DIV_INS_OPLL)?1:0);
|
||||||
if (i->mode) { // FM
|
if (i->type==DIV_INS_FM || i->type==DIV_INS_OPLL) { // FM
|
||||||
w->writeC(i->fm.alg);
|
w->writeC(i->fm.alg);
|
||||||
w->writeC(i->fm.fb);
|
w->writeC(i->fm.fb);
|
||||||
w->writeC(i->fm.fms);
|
w->writeC(i->fm.fms);
|
||||||
|
|
|
@ -326,7 +326,7 @@ struct DivInstrumentAmiga {
|
||||||
double sliceEnd;
|
double sliceEnd;
|
||||||
|
|
||||||
// inlines
|
// inlines
|
||||||
inline double updateSize(double length, double loopStart, double loopEnd) {
|
inline void updateSize(double length, double loopStart, double loopEnd) {
|
||||||
sliceSize=loopEnd-loopStart;
|
sliceSize=loopEnd-loopStart;
|
||||||
sliceBound=(length-sliceSize);
|
sliceBound=(length-sliceSize);
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,6 @@ struct DivInstrument {
|
||||||
bool save(const char* path);
|
bool save(const char* path);
|
||||||
DivInstrument():
|
DivInstrument():
|
||||||
name(""),
|
name(""),
|
||||||
mode(false),
|
|
||||||
type(DIV_INS_FM) {
|
type(DIV_INS_FM) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -207,7 +207,7 @@ void DivPlatformAmiga::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ void DivPlatformArcade::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ void DivPlatformArcade::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ void DivPlatformAY8930::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ void DivPlatformBubSysWSG::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ void DivPlatformC64::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ void DivPlatformES5506::e_pin(bool state)
|
||||||
}
|
}
|
||||||
if (chan[ch].transwaveIRQ) {
|
if (chan[ch].transwaveIRQ) {
|
||||||
if ((chan[ch].cr&0x37)==0x34) { // IRQE = 1, BLE = 1, LPE = 0, LEI = 1
|
if ((chan[ch].cr&0x37)==0x34) { // IRQE = 1, BLE = 1, LPE = 0, LEI = 1
|
||||||
DivInstrument* ins=parent->getIns(chan[i].ins);
|
DivInstrument* ins=parent->getIns(chan[ch].ins);
|
||||||
if (!ins->amiga.useNoteMap && ins->amiga.transWave.enable) {
|
if (!ins->amiga.useNoteMap && ins->amiga.transWave.enable) {
|
||||||
const int next=chan[ch].pcm.next;
|
const int next=chan[ch].pcm.next;
|
||||||
if (next>=0 && next<ins->amiga.transWaveMap.size()) {
|
if (next>=0 && next<ins->amiga.transWaveMap.size()) {
|
||||||
|
@ -316,8 +316,7 @@ void DivPlatformES5506::e_pin(bool state)
|
||||||
loopEnd=(double)transWaveInd.loopEnd;
|
loopEnd=(double)transWaveInd.loopEnd;
|
||||||
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
||||||
chan[ch].transWave.updateSize(s->samples,loopStart,loopEnd);
|
chan[ch].transWave.updateSize(s->samples,loopStart,loopEnd);
|
||||||
chan[ch].transWave.slice=transWaveInd.slice;
|
chan[ch].transWave.slicePos(double(chan[ch].transWave.slice)/4095.0);
|
||||||
chan[ch].transWave.slicePos(chan[ch].transWave.slice);
|
|
||||||
loopStart=transWaveInd.sliceStart;
|
loopStart=transWaveInd.sliceStart;
|
||||||
loopEnd=transWaveInd.sliceEnd;
|
loopEnd=transWaveInd.sliceEnd;
|
||||||
}
|
}
|
||||||
|
@ -371,10 +370,10 @@ void DivPlatformES5506::e_pin(bool state)
|
||||||
}
|
}
|
||||||
chan[ch].transwaveIRQ=false;
|
chan[ch].transwaveIRQ=false;
|
||||||
}
|
}
|
||||||
if (chan[ch].isTransWave) {
|
if (chan[ch].isTranswave) {
|
||||||
pageReadMask(0x00|ch,0x5f,0x00,&chan[ch].cr);
|
pageReadMask(0x00|ch,0x5f,0x00,&chan[ch].cr);
|
||||||
chan[ch].transwaveIRQ=true;
|
chan[ch].transwaveIRQ=true;
|
||||||
chan[ch].isTransWave=false;
|
chan[ch].isTranswave=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -640,7 +639,7 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
chan[i].volChanged.changed=0;
|
chan[i].volChanged.changed=0;
|
||||||
}
|
}
|
||||||
if (chan[i].pcmChanged.changed) {
|
if (chan[i].pcmChanged.changed) {
|
||||||
if (!chan[i].isTransWave) {
|
if (!chan[i].isTranswave) {
|
||||||
if (chan[i].pcmChanged.transwaveInd && (!ins->amiga.useNoteMap && ins->amiga.transWave.enable)) {
|
if (chan[i].pcmChanged.transwaveInd && (!ins->amiga.useNoteMap && ins->amiga.transWave.enable)) {
|
||||||
const int next=chan[i].pcm.next;
|
const int next=chan[i].pcm.next;
|
||||||
if (next>=0 && next<ins->amiga.transWaveMap.size()) {
|
if (next>=0 && next<ins->amiga.transWaveMap.size()) {
|
||||||
|
@ -667,8 +666,7 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
loopEnd=(double)transWaveInd.loopEnd;
|
loopEnd=(double)transWaveInd.loopEnd;
|
||||||
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
||||||
chan[i].transWave.updateSize(s->samples,loopStart,loopEnd);
|
chan[i].transWave.updateSize(s->samples,loopStart,loopEnd);
|
||||||
chan[i].transWave.slice=transWaveInd.slice;
|
chan[i].transWave.slicePos(double(chan[i].transWave.slice)/4095.0);
|
||||||
chan[i].transWave.slicePos(transWaveInd.slice);
|
|
||||||
loopStart=transWaveInd.sliceStart;
|
loopStart=transWaveInd.sliceStart;
|
||||||
loopEnd=transWaveInd.sliceEnd;
|
loopEnd=transWaveInd.sliceEnd;
|
||||||
}
|
}
|
||||||
|
@ -688,7 +686,7 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
chan[i].pcmChanged.transwaveInd=0;
|
chan[i].pcmChanged.transwaveInd=0;
|
||||||
}
|
}
|
||||||
if ((!chan[i].pcmChanged.transwaveInd) && (!chan[i].isTransWave)) {
|
if ((!chan[i].pcmChanged.transwaveInd) && (!chan[i].isTranswave)) {
|
||||||
if (chan[i].pcmChanged.index) {
|
if (chan[i].pcmChanged.index) {
|
||||||
const int next=chan[i].pcm.next;
|
const int next=chan[i].pcm.next;
|
||||||
bool sampleVaild=false;
|
bool sampleVaild=false;
|
||||||
|
@ -737,8 +735,7 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
loopEnd=(double)transWaveInd.loopEnd;
|
loopEnd=(double)transWaveInd.loopEnd;
|
||||||
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
||||||
chan[i].transWave.updateSize(s->samples,loopStart,loopEnd);
|
chan[i].transWave.updateSize(s->samples,loopStart,loopEnd);
|
||||||
chan[i].transWave.slice=transWaveInd.slice;
|
chan[i].transWave.slicePos(double(chan[i].transWave.slice)/4095.0);
|
||||||
chan[i].transWave.slicePos(transWaveInd.slice);
|
|
||||||
loopStart=transWaveInd.sliceStart;
|
loopStart=transWaveInd.sliceStart;
|
||||||
loopEnd=transWaveInd.sliceEnd;
|
loopEnd=transWaveInd.sliceEnd;
|
||||||
}
|
}
|
||||||
|
@ -790,7 +787,7 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
double loopEnd=(double)s->loopEnd;
|
double loopEnd=(double)s->loopEnd;
|
||||||
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
||||||
chan[i].transWave.updateSize(s->samples,loopStart,loopEnd);
|
chan[i].transWave.updateSize(s->samples,loopStart,loopEnd);
|
||||||
chan[i].transWave.slicePos(chan[i].transWave.slice);
|
chan[i].transWave.slicePos(double(chan[i].transWave.slice)/4095.0);
|
||||||
loopStart=chan[i].transWave.sliceStart;
|
loopStart=chan[i].transWave.sliceStart;
|
||||||
loopEnd=chan[i].transWave.sliceEnd;
|
loopEnd=chan[i].transWave.sliceEnd;
|
||||||
}
|
}
|
||||||
|
@ -798,8 +795,8 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
const unsigned int nextLoopStart=(start+(unsigned int)(loopStart*2048.0))&0xfffff800;
|
const unsigned int nextLoopStart=(start+(unsigned int)(loopStart*2048.0))&0xfffff800;
|
||||||
const unsigned int nextLoopEnd=(start+(unsigned int)((loopEnd-1.0)*2048.0))&0xffffff80;
|
const unsigned int nextLoopEnd=(start+(unsigned int)((loopEnd-1.0)*2048.0))&0xffffff80;
|
||||||
if ((chan[i].pcm.loopStart!=nextLoopStart) || (chan[i].pcm.loopEnd!=nextLoopEnd)) {
|
if ((chan[i].pcm.loopStart!=nextLoopStart) || (chan[i].pcm.loopEnd!=nextLoopEnd)) {
|
||||||
chan[i].pcm.loopStart=(start+(unsigned int)(loopStart*2048.0))&0xfffff800;
|
chan[i].pcm.loopStart=nextLoopStart;
|
||||||
chan[i].pcm.loopEnd=(start+(unsigned int)((loopEnd-1.0)*2048.0))&0xffffff80;
|
chan[i].pcm.loopEnd=nextLoopEnd;
|
||||||
chan[i].pcmChanged.position=1;
|
chan[i].pcmChanged.position=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1002,11 +999,11 @@ void DivPlatformES5506::tick(bool sysTick) {
|
||||||
int DivPlatformES5506::dispatch(DivCommand c) {
|
int DivPlatformES5506::dispatch(DivCommand c) {
|
||||||
switch (c.cmd) {
|
switch (c.cmd) {
|
||||||
case DIV_CMD_NOTE_ON: {
|
case DIV_CMD_NOTE_ON: {
|
||||||
|
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
|
||||||
bool sampleVaild=false;
|
bool sampleVaild=false;
|
||||||
if (((ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (c.value>=0 && c.value<120)) ||
|
if (((ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (c.value>=0 && c.value<120)) ||
|
||||||
((!ins->amiga.useNoteMap && ins->amiga.transWave.enable) && (ins->amiga.transWave.ind>=0 && ins->amiga.transWave.ind<ins->amiga.transWaveMap.size())) ||
|
((!ins->amiga.useNoteMap && ins->amiga.transWave.enable) && (ins->amiga.transWave.ind>=0 && ins->amiga.transWave.ind<ins->amiga.transWaveMap.size())) ||
|
||||||
((!ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (ins->amiga.initSample>=0 && ins->amiga.initSample<parent->song.sampleLen))) {
|
((!ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (ins->amiga.initSample>=0 && ins->amiga.initSample<parent->song.sampleLen))) {
|
||||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
|
|
||||||
DivInstrumentAmiga::NoteMap& noteMapind=ins->amiga.noteMap[c.value];
|
DivInstrumentAmiga::NoteMap& noteMapind=ins->amiga.noteMap[c.value];
|
||||||
DivInstrumentAmiga::TransWaveMap& transWaveInd=ins->amiga.transWaveMap[ins->amiga.transWave.ind];
|
DivInstrumentAmiga::TransWaveMap& transWaveInd=ins->amiga.transWaveMap[ins->amiga.transWave.ind];
|
||||||
int sample=ins->amiga.initSample;
|
int sample=ins->amiga.initSample;
|
||||||
|
@ -1043,7 +1040,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
|
||||||
if (ins->amiga.transWave.enable) {
|
if (ins->amiga.transWave.enable) {
|
||||||
if (transWaveInd.loopMode!=DIV_SAMPLE_LOOPMODE_ONESHOT) {
|
if (transWaveInd.loopMode!=DIV_SAMPLE_LOOPMODE_ONESHOT) {
|
||||||
loopMode=transWaveInd.loopMode;
|
loopMode=transWaveInd.loopMode;
|
||||||
} else if ((chan[i].pcm.loopMode==DIV_SAMPLE_LOOPMODE_ONESHOT) || (!s->isLoopable())) { // default
|
} else if ((chan[c.chan].pcm.loopMode==DIV_SAMPLE_LOOPMODE_ONESHOT) || (!s->isLoopable())) { // default
|
||||||
loopMode=DIV_SAMPLE_LOOPMODE_PINGPONG;
|
loopMode=DIV_SAMPLE_LOOPMODE_PINGPONG;
|
||||||
}
|
}
|
||||||
// get loop position
|
// get loop position
|
||||||
|
@ -1051,8 +1048,8 @@ int DivPlatformES5506::dispatch(DivCommand c) {
|
||||||
loopEnd=(double)transWaveInd.loopEnd;
|
loopEnd=(double)transWaveInd.loopEnd;
|
||||||
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
if (ins->amiga.transWave.sliceEnable) { // sliced loop position?
|
||||||
chan[c.chan].transWave.updateSize(s->samples,loopStart,loopEnd);
|
chan[c.chan].transWave.updateSize(s->samples,loopStart,loopEnd);
|
||||||
chan[c.chan].transWave.slice=transWaveInd.slice;
|
chan[c.chan].transWave.slice=ins->amiga.transWave.slice;
|
||||||
chan[c.chan].transWave.slicePos(transWaveInd.slice);
|
chan[c.chan].transWave.slicePos(double(ins->amiga.transWave.slice)/4095.0);
|
||||||
loopStart=transWaveInd.sliceStart;
|
loopStart=transWaveInd.sliceStart;
|
||||||
loopEnd=transWaveInd.sliceEnd;
|
loopEnd=transWaveInd.sliceEnd;
|
||||||
}
|
}
|
||||||
|
@ -1173,6 +1170,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
|
||||||
case DIV_CMD_WAVE:
|
case DIV_CMD_WAVE:
|
||||||
if (!chan[c.chan].useWave) {
|
if (!chan[c.chan].useWave) {
|
||||||
if (chan[c.chan].active) {
|
if (chan[c.chan].active) {
|
||||||
|
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
|
||||||
if (((ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (c.value>=0 && c.value<120)) ||
|
if (((ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (c.value>=0 && c.value<120)) ||
|
||||||
((!ins->amiga.useNoteMap && ins->amiga.transWave.enable) && (c.value>=0 && c.value<ins->amiga.transWaveMap.size())) ||
|
((!ins->amiga.useNoteMap && ins->amiga.transWave.enable) && (c.value>=0 && c.value<ins->amiga.transWaveMap.size())) ||
|
||||||
((!ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (c.value>=0 && c.value<parent->song.sampleLen))) {
|
((!ins->amiga.useNoteMap && !ins->amiga.transWave.enable) && (c.value>=0 && c.value<parent->song.sampleLen))) {
|
||||||
|
@ -1246,7 +1244,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
|
||||||
if (chan[c.chan].active) {
|
if (chan[c.chan].active) {
|
||||||
if (chan[c.chan].pcm.pause!=(bool)(c.value&1)) {
|
if (chan[c.chan].pcm.pause!=(bool)(c.value&1)) {
|
||||||
chan[c.chan].pcm.pause=c.value&1;
|
chan[c.chan].pcm.pause=c.value&1;
|
||||||
pageWriteMask(0x00|i,0x5f,0x00,chan[c.chan].pcm.pause?0x0002:0x0000,0x0002);
|
pageWriteMask(0x00|c.chan,0x5f,0x00,chan[c.chan].pcm.pause?0x0002:0x0000,0x0002);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1325,7 +1323,7 @@ void DivPlatformES5506::forceIns() {
|
||||||
chan[i].volChanged.changed=0xff;
|
chan[i].volChanged.changed=0xff;
|
||||||
chan[i].filterChanged.changed=0xff;
|
chan[i].filterChanged.changed=0xff;
|
||||||
chan[i].envChanged.changed=0xff;
|
chan[i].envChanged.changed=0xff;
|
||||||
chan[i].sample=-1;
|
chan[i].pcmChanged.changed=0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
|
||||||
} pcm;
|
} pcm;
|
||||||
int freq, baseFreq, nextFreq, pitch, pitch2, note, nextNote, prevNote, ins, wave;
|
int freq, baseFreq, nextFreq, pitch, pitch2, note, nextNote, prevNote, ins, wave;
|
||||||
unsigned int volMacroMax, panMacroMax;
|
unsigned int volMacroMax, panMacroMax;
|
||||||
bool active, insChanged, freqChanged, pcmChanged, keyOn, keyOff, inPorta, useWave, isReverseLoop, isTranswave, transwaveIRQ;
|
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, isReverseLoop, isTranswave, transwaveIRQ;
|
||||||
unsigned int cr;
|
unsigned int cr;
|
||||||
|
|
||||||
struct NoteChanged { // Note changed flags
|
struct NoteChanged { // Note changed flags
|
||||||
|
@ -181,7 +181,6 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
|
||||||
active(false),
|
active(false),
|
||||||
insChanged(true),
|
insChanged(true),
|
||||||
freqChanged(false),
|
freqChanged(false),
|
||||||
pcmChanged(false),
|
|
||||||
keyOn(false),
|
keyOn(false),
|
||||||
keyOff(false),
|
keyOff(false),
|
||||||
inPorta(false),
|
inPorta(false),
|
||||||
|
|
|
@ -185,7 +185,7 @@ void DivPlatformFDS::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -498,6 +498,10 @@ void DivPlatformFDS::notifyInsDeletion(void* ins) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float DivPlatformFDS::getPostAmp() {
|
||||||
|
return useNP?2.0f:1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
void DivPlatformFDS::poke(unsigned int addr, unsigned short val) {
|
void DivPlatformFDS::poke(unsigned int addr, unsigned short val) {
|
||||||
rWrite(addr,val);
|
rWrite(addr,val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@ class DivPlatformFDS: public DivDispatch {
|
||||||
void setNSFPlay(bool use);
|
void setNSFPlay(bool use);
|
||||||
void setFlags(unsigned int flags);
|
void setFlags(unsigned int flags);
|
||||||
void notifyInsDeletion(void* ins);
|
void notifyInsDeletion(void* ins);
|
||||||
|
float getPostAmp();
|
||||||
void poke(unsigned int addr, unsigned short val);
|
void poke(unsigned int addr, unsigned short val);
|
||||||
void poke(std::vector<DivRegWrite>& wlist);
|
void poke(std::vector<DivRegWrite>& wlist);
|
||||||
const char** getRegisterSheet();
|
const char** getRegisterSheet();
|
||||||
|
|
|
@ -32,4 +32,65 @@
|
||||||
#define ADDR_FB_ALG 0xb0
|
#define ADDR_FB_ALG 0xb0
|
||||||
#define ADDR_LRAF 0xb4
|
#define ADDR_LRAF 0xb4
|
||||||
|
|
||||||
|
#define PLEASE_HELP_ME(_targetChan) \
|
||||||
|
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false); \
|
||||||
|
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false); \
|
||||||
|
int destFreq=NOTE_FNUM_BLOCK(c.value2,11); \
|
||||||
|
int newFreq; \
|
||||||
|
bool return2=false; \
|
||||||
|
if (_targetChan.portaPause) { \
|
||||||
|
if (parent->song.oldOctaveBoundary) { \
|
||||||
|
if ((_targetChan.portaPauseFreq&0xf800)>(_targetChan.baseFreq&0xf800)) { \
|
||||||
|
_targetChan.baseFreq=((_targetChan.baseFreq&0x7ff)>>1)|(_targetChan.portaPauseFreq&0xf800); \
|
||||||
|
} else { \
|
||||||
|
_targetChan.baseFreq=((_targetChan.baseFreq&0x7ff)<<1)|(_targetChan.portaPauseFreq&0xf800); \
|
||||||
|
} \
|
||||||
|
c.value*=2; \
|
||||||
|
} else { \
|
||||||
|
_targetChan.baseFreq=_targetChan.portaPauseFreq; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if (destFreq>_targetChan.baseFreq) { \
|
||||||
|
newFreq=_targetChan.baseFreq+c.value; \
|
||||||
|
if (newFreq>=destFreq) { \
|
||||||
|
newFreq=destFreq; \
|
||||||
|
return2=true; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
newFreq=_targetChan.baseFreq-c.value; \
|
||||||
|
if (newFreq<=destFreq) { \
|
||||||
|
newFreq=destFreq; \
|
||||||
|
return2=true; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
/* check for octave boundary */ \
|
||||||
|
/* what the heck! */ \
|
||||||
|
if (!_targetChan.portaPause) { \
|
||||||
|
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) { \
|
||||||
|
if (parent->song.fbPortaPause) { \
|
||||||
|
_targetChan.portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800); \
|
||||||
|
_targetChan.portaPause=true; \
|
||||||
|
break; \
|
||||||
|
} else { \
|
||||||
|
newFreq=((newFreq&0x7ff)>>1)|((newFreq+0x800)&0xf800); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) { \
|
||||||
|
if (parent->song.fbPortaPause) { \
|
||||||
|
_targetChan.portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800); \
|
||||||
|
_targetChan.portaPause=true; \
|
||||||
|
break; \
|
||||||
|
} else { \
|
||||||
|
newFreq=((newFreq&0x7ff)<<1)|((newFreq-0x800)&0xf800); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
_targetChan.portaPause=false; \
|
||||||
|
_targetChan.freqChanged=true; \
|
||||||
|
_targetChan.baseFreq=newFreq; \
|
||||||
|
if (return2) { \
|
||||||
|
_targetChan.inPorta=false; \
|
||||||
|
return 2; \
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -204,7 +204,7 @@ void DivPlatformGB::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ void DivPlatformGenesis::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ void DivPlatformGenesis::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -758,48 +758,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(chan[c.chan]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (chan[c.chan].portaPause) {
|
|
||||||
chan[c.chan].baseFreq=chan[c.chan].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>chan[c.chan].baseFreq) {
|
|
||||||
newFreq=chan[c.chan].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=chan[c.chan].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check for octave boundary
|
|
||||||
// what the heck!
|
|
||||||
if (!chan[c.chan].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
chan[c.chan].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
chan[c.chan].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chan[c.chan].portaPause=false;
|
|
||||||
chan[c.chan].freqChanged=true;
|
|
||||||
chan[c.chan].baseFreq=newFreq;
|
|
||||||
if (return2) {
|
|
||||||
chan[c.chan].inPorta=false;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_SAMPLE_MODE: {
|
case DIV_CMD_SAMPLE_MODE: {
|
||||||
|
|
|
@ -150,52 +150,7 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(opChan[ch]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (opChan[ch].portaPause) {
|
|
||||||
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>opChan[ch].baseFreq) {
|
|
||||||
newFreq=opChan[ch].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=opChan[ch].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// what the heck!
|
|
||||||
if (!opChan[ch].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq>>1)|((newFreq+0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq<<1)|((newFreq-0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opChan[ch].portaPause=false;
|
|
||||||
opChan[ch].freqChanged=true;
|
|
||||||
opChan[ch].baseFreq=newFreq;
|
|
||||||
if (return2) return 2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_SAMPLE_MODE: {
|
case DIV_CMD_SAMPLE_MODE: {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
|
||||||
unsigned char freqH, freqL;
|
unsigned char freqH, freqL;
|
||||||
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
OpChannel():
|
OpChannel():
|
||||||
|
@ -45,6 +45,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
|
||||||
keyOn(false),
|
keyOn(false),
|
||||||
keyOff(false),
|
keyOff(false),
|
||||||
portaPause(false),
|
portaPause(false),
|
||||||
|
inPorta(false),
|
||||||
vol(0),
|
vol(0),
|
||||||
pan(3) {}
|
pan(3) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,23 +142,52 @@ const char* DivPlatformLynx::getEffectName(unsigned char effect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
mikey->sampleAudio( bufL + start, bufR + start, len, oscBuf );
|
for (size_t h=start; h<start+len; h++) {
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
if (chan[i].pcm && chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
|
||||||
|
chan[i].sampleAccum-=chan[i].sampleFreq;
|
||||||
|
if (chan[i].sampleAccum<0) {
|
||||||
|
chan[i].sampleAccum+=rate;
|
||||||
|
DivSample* s=parent->getSample(chan[i].sample);
|
||||||
|
if (s!=NULL) {
|
||||||
|
if (isMuted[i]) {
|
||||||
|
WRITE_VOLUME(i,0);
|
||||||
|
chan[i].samplePos++;
|
||||||
|
} else {
|
||||||
|
WRITE_VOLUME(i,(s->data8[chan[i].samplePos++]*chan[i].outVol)>>7);
|
||||||
|
}
|
||||||
|
if (chan[i].samplePos>=(int)s->samples) {
|
||||||
|
chan[i].sample=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mikey->sampleAudio( bufL + h, bufR + h, 1, oscBuf );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformLynx::tick(bool sysTick) {
|
void DivPlatformLynx::tick(bool sysTick) {
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
chan[i].std.next();
|
chan[i].std.next();
|
||||||
if (chan[i].std.vol.had) {
|
if (chan[i].std.vol.had) {
|
||||||
|
if (chan[i].pcm) {
|
||||||
|
chan[i].outVol=((chan[i].vol&127)*MIN(64,chan[i].std.vol.val))>>6;
|
||||||
|
} else {
|
||||||
chan[i].outVol=((chan[i].vol&127)*MIN(127,chan[i].std.vol.val))>>7;
|
chan[i].outVol=((chan[i].vol&127)*MIN(127,chan[i].std.vol.val))>>7;
|
||||||
WRITE_VOLUME(i,(isMuted[i]?0:(chan[i].outVol&127)));
|
WRITE_VOLUME(i,(isMuted[i]?0:(chan[i].outVol&127)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (chan[i].std.arp.had) {
|
if (chan[i].std.arp.had) {
|
||||||
if (!chan[i].inPorta) {
|
if (!chan[i].inPorta) {
|
||||||
if (chan[i].std.arp.mode) {
|
if (chan[i].std.arp.mode) {
|
||||||
chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val);
|
chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val);
|
||||||
|
if (chan[i].pcm) chan[i].sampleBaseFreq=parent->calcBaseFreq(1.0,1.0,chan[i].std.arp.val,false);
|
||||||
chan[i].actualNote=chan[i].std.arp.val;
|
chan[i].actualNote=chan[i].std.arp.val;
|
||||||
} else {
|
} else {
|
||||||
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val);
|
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val);
|
||||||
|
if (chan[i].pcm) chan[i].sampleBaseFreq=parent->calcBaseFreq(1.0,1.0,chan[i].note+chan[i].std.arp.val,false);
|
||||||
chan[i].actualNote=chan[i].note+chan[i].std.arp.val;
|
chan[i].actualNote=chan[i].note+chan[i].std.arp.val;
|
||||||
}
|
}
|
||||||
chan[i].freqChanged=true;
|
chan[i].freqChanged=true;
|
||||||
|
@ -166,6 +195,7 @@ void DivPlatformLynx::tick(bool sysTick) {
|
||||||
} else {
|
} else {
|
||||||
if (chan[i].std.arp.mode && chan[i].std.arp.finished) {
|
if (chan[i].std.arp.mode && chan[i].std.arp.finished) {
|
||||||
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note);
|
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note);
|
||||||
|
if (chan[i].pcm) chan[i].sampleBaseFreq=parent->calcBaseFreq(1.0,1.0,chan[i].note,false);
|
||||||
chan[i].actualNote=chan[i].note;
|
chan[i].actualNote=chan[i].note;
|
||||||
chan[i].freqChanged=true;
|
chan[i].freqChanged=true;
|
||||||
}
|
}
|
||||||
|
@ -188,14 +218,38 @@ void DivPlatformLynx::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
chan[i].freqChanged=true;
|
chan[i].freqChanged=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chan[i].std.phaseReset.had) {
|
||||||
|
if (chan[i].std.phaseReset.val==1) {
|
||||||
|
WRITE_LFSR(i, 0);
|
||||||
|
WRITE_OTHER(i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (chan[i].freqChanged) {
|
if (chan[i].freqChanged) {
|
||||||
|
if (chan[i].pcm) {
|
||||||
|
double off=1.0;
|
||||||
|
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
|
||||||
|
DivSample* s=parent->getSample(chan[i].sample);
|
||||||
|
if (s->centerRate<1) {
|
||||||
|
off=1.0;
|
||||||
|
} else {
|
||||||
|
off=(double)s->centerRate/8363.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chan[i].sampleFreq=off*parent->calcFreq(chan[i].sampleBaseFreq,chan[i].pitch,false,2,chan[i].pitch2,1,1);
|
||||||
|
WRITE_FEEDBACK(i,0);
|
||||||
|
WRITE_LFSR(i,0);
|
||||||
|
WRITE_OTHER(i,0);
|
||||||
|
WRITE_CONTROL(i,0x18);
|
||||||
|
WRITE_BACKUP(i,2);
|
||||||
|
} else {
|
||||||
if (chan[i].lfsr >= 0) {
|
if (chan[i].lfsr >= 0) {
|
||||||
WRITE_LFSR(i, (chan[i].lfsr&0xff));
|
WRITE_LFSR(i, (chan[i].lfsr&0xff));
|
||||||
WRITE_OTHER(i, ((chan[i].lfsr&0xf00)>>4));
|
WRITE_OTHER(i, ((chan[i].lfsr&0xf00)>>4));
|
||||||
|
@ -208,20 +262,31 @@ void DivPlatformLynx::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
WRITE_CONTROL(i, (chan[i].fd.clockDivider|0x18|chan[i].duty.int_feedback7));
|
WRITE_CONTROL(i, (chan[i].fd.clockDivider|0x18|chan[i].duty.int_feedback7));
|
||||||
WRITE_BACKUP( i, chan[i].fd.backup );
|
WRITE_BACKUP( i, chan[i].fd.backup );
|
||||||
|
}
|
||||||
chan[i].freqChanged=false;
|
chan[i].freqChanged=false;
|
||||||
} else if (chan[i].std.duty.had) {
|
} else if (chan[i].std.duty.had) {
|
||||||
chan[i].duty = chan[i].std.duty.val;
|
chan[i].duty = chan[i].std.duty.val;
|
||||||
|
if (!chan[i].pcm) {
|
||||||
WRITE_FEEDBACK(i, chan[i].duty.feedback);
|
WRITE_FEEDBACK(i, chan[i].duty.feedback);
|
||||||
WRITE_CONTROL(i, (chan[i].fd.clockDivider|0x18|chan[i].duty.int_feedback7));
|
WRITE_CONTROL(i, (chan[i].fd.clockDivider|0x18|chan[i].duty.int_feedback7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformLynx::dispatch(DivCommand c) {
|
int DivPlatformLynx::dispatch(DivCommand c) {
|
||||||
switch (c.cmd) {
|
switch (c.cmd) {
|
||||||
case DIV_CMD_NOTE_ON:
|
case DIV_CMD_NOTE_ON: {
|
||||||
|
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_MIKEY);
|
||||||
|
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA);
|
||||||
if (c.value!=DIV_NOTE_NULL) {
|
if (c.value!=DIV_NOTE_NULL) {
|
||||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
|
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
|
||||||
|
if (chan[c.chan].pcm) {
|
||||||
|
chan[c.chan].sampleBaseFreq=parent->calcBaseFreq(1.0,1.0,c.value,false);
|
||||||
|
chan[c.chan].sample=ins->amiga.getSample(c.value);
|
||||||
|
chan[c.chan].sampleAccum=0;
|
||||||
|
chan[c.chan].samplePos=0;
|
||||||
|
}
|
||||||
chan[c.chan].freqChanged=true;
|
chan[c.chan].freqChanged=true;
|
||||||
chan[c.chan].note=c.value;
|
chan[c.chan].note=c.value;
|
||||||
chan[c.chan].actualNote=c.value;
|
chan[c.chan].actualNote=c.value;
|
||||||
|
@ -232,10 +297,14 @@ int DivPlatformLynx::dispatch(DivCommand c) {
|
||||||
WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127)));
|
WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127)));
|
||||||
chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_MIKEY));
|
chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_MIKEY));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DIV_CMD_NOTE_OFF:
|
case DIV_CMD_NOTE_OFF:
|
||||||
chan[c.chan].active=false;
|
chan[c.chan].active=false;
|
||||||
WRITE_VOLUME(c.chan, 0);
|
WRITE_VOLUME(c.chan, 0);
|
||||||
chan[c.chan].macroInit(NULL);
|
chan[c.chan].macroInit(NULL);
|
||||||
|
if (chan[c.chan].pcm) {
|
||||||
|
chan[c.chan].pcm=false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_LYNX_LFSR_LOAD:
|
case DIV_CMD_LYNX_LFSR_LOAD:
|
||||||
chan[c.chan].freqChanged=true;
|
chan[c.chan].freqChanged=true;
|
||||||
|
@ -255,7 +324,7 @@ int DivPlatformLynx::dispatch(DivCommand c) {
|
||||||
if (!chan[c.chan].std.vol.has) {
|
if (!chan[c.chan].std.vol.has) {
|
||||||
chan[c.chan].outVol=c.value;
|
chan[c.chan].outVol=c.value;
|
||||||
}
|
}
|
||||||
if (chan[c.chan].active) WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127)));
|
if (chan[c.chan].active && !chan[c.chan].pcm) WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_PANNING:
|
case DIV_CMD_PANNING:
|
||||||
|
@ -289,18 +358,26 @@ int DivPlatformLynx::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chan[c.chan].freqChanged=true;
|
chan[c.chan].freqChanged=true;
|
||||||
|
if (chan[c.chan].pcm && parent->song.linearPitch==2) {
|
||||||
|
chan[c.chan].sampleBaseFreq=chan[c.chan].baseFreq;
|
||||||
|
}
|
||||||
if (return2) {
|
if (return2) {
|
||||||
chan[c.chan].inPorta=false;
|
chan[c.chan].inPorta=false;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_LEGATO:
|
case DIV_CMD_LEGATO: {
|
||||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0)));
|
int whatAMess=c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0));
|
||||||
|
chan[c.chan].baseFreq=NOTE_PERIODIC(whatAMess);
|
||||||
|
if (chan[c.chan].pcm) {
|
||||||
|
chan[c.chan].sampleBaseFreq=parent->calcBaseFreq(1.0,1.0,whatAMess,false);
|
||||||
|
}
|
||||||
chan[c.chan].freqChanged=true;
|
chan[c.chan].freqChanged=true;
|
||||||
chan[c.chan].note=c.value;
|
chan[c.chan].note=c.value;
|
||||||
chan[c.chan].actualNote=c.value;
|
chan[c.chan].actualNote=c.value;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DIV_CMD_PRE_PORTA:
|
case DIV_CMD_PRE_PORTA:
|
||||||
if (chan[c.chan].active && c.value2) {
|
if (chan[c.chan].active && c.value2) {
|
||||||
if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_MIKEY));
|
if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_MIKEY));
|
||||||
|
|
|
@ -44,9 +44,9 @@ class DivPlatformLynx: public DivDispatch {
|
||||||
DivMacroInt std;
|
DivMacroInt std;
|
||||||
MikeyFreqDiv fd;
|
MikeyFreqDiv fd;
|
||||||
MikeyDuty duty;
|
MikeyDuty duty;
|
||||||
int baseFreq, pitch, pitch2, note, actualNote, lfsr, ins;
|
int baseFreq, pitch, pitch2, note, actualNote, lfsr, ins, sample, samplePos, sampleAccum, sampleBaseFreq, sampleFreq;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
|
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, pcm;
|
||||||
signed char vol, outVol;
|
signed char vol, outVol;
|
||||||
void macroInit(DivInstrument* which) {
|
void macroInit(DivInstrument* which) {
|
||||||
std.init(which);
|
std.init(which);
|
||||||
|
@ -63,6 +63,11 @@ class DivPlatformLynx: public DivDispatch {
|
||||||
actualNote(0),
|
actualNote(0),
|
||||||
lfsr(-1),
|
lfsr(-1),
|
||||||
ins(-1),
|
ins(-1),
|
||||||
|
sample(-1),
|
||||||
|
samplePos(0),
|
||||||
|
sampleAccum(0),
|
||||||
|
sampleBaseFreq(0),
|
||||||
|
sampleFreq(0),
|
||||||
pan(0xff),
|
pan(0xff),
|
||||||
active(false),
|
active(false),
|
||||||
insChanged(true),
|
insChanged(true),
|
||||||
|
@ -70,6 +75,7 @@ class DivPlatformLynx: public DivDispatch {
|
||||||
keyOn(false),
|
keyOn(false),
|
||||||
keyOff(false),
|
keyOff(false),
|
||||||
inPorta(false),
|
inPorta(false),
|
||||||
|
pcm(false),
|
||||||
vol(127),
|
vol(127),
|
||||||
outVol(127) {}
|
outVol(127) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,7 +134,7 @@ void DivPlatformMMC5::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
349
src/engine/platform/msm6258.cpp
Normal file
349
src/engine/platform/msm6258.cpp
Normal file
|
@ -0,0 +1,349 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* 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 "msm6258.h"
|
||||||
|
#include "../engine.h"
|
||||||
|
#include "../../ta-log.h"
|
||||||
|
#include "sound/oki/okim6258.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} }
|
||||||
|
|
||||||
|
const char** DivPlatformMSM6258::getRegisterSheet() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* DivPlatformMSM6258::getEffectName(unsigned char effect) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
|
for (size_t h=start; h<start+len; h++) {
|
||||||
|
short* outs[2]={
|
||||||
|
&bufL[h],
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
if (!writes.empty()) {
|
||||||
|
QueuedWrite& w=writes.front();
|
||||||
|
switch (w.addr) {
|
||||||
|
case 0:
|
||||||
|
msm->ctrl_w(w.val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
writes.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sample>=0 && sample<parent->song.sampleLen) {
|
||||||
|
DivSample* s=parent->getSample(sample);
|
||||||
|
unsigned char nextData=(s->dataVOX[samplePos]>>4)|(s->dataVOX[samplePos]<<4);
|
||||||
|
if (msm->data_w(nextData)) {
|
||||||
|
samplePos++;
|
||||||
|
if (samplePos>=(int)s->lengthVOX) {
|
||||||
|
sample=-1;
|
||||||
|
samplePos=0;
|
||||||
|
msm->ctrl_w(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msm->sound_stream_update(outs,1);
|
||||||
|
if (isMuted[0]) {
|
||||||
|
bufL[h]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (++updateOsc>=22) {
|
||||||
|
updateOsc=0;
|
||||||
|
// TODO: per-channel osc
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=msm->m_voice[i].m_muted?0:(msm->m_voice[i].m_out<<6);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::tick(bool sysTick) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
int DivPlatformMSM6258::dispatch(DivCommand c) {
|
||||||
|
switch (c.cmd) {
|
||||||
|
case DIV_CMD_NOTE_ON: {
|
||||||
|
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_FM);
|
||||||
|
if (ins->type==DIV_INS_AMIGA) {
|
||||||
|
chan[c.chan].furnacePCM=true;
|
||||||
|
} else {
|
||||||
|
chan[c.chan].furnacePCM=false;
|
||||||
|
}
|
||||||
|
if (skipRegisterWrites) break;
|
||||||
|
if (chan[c.chan].furnacePCM) {
|
||||||
|
chan[c.chan].macroInit(ins);
|
||||||
|
if (!chan[c.chan].std.vol.will) {
|
||||||
|
chan[c.chan].outVol=chan[c.chan].vol;
|
||||||
|
}
|
||||||
|
sample=ins->amiga.getSample(c.value);
|
||||||
|
if (sample>=0 && sample<parent->song.sampleLen) {
|
||||||
|
//DivSample* s=parent->getSample(chan[c.chan].sample);
|
||||||
|
if (c.value!=DIV_NOTE_NULL) {
|
||||||
|
chan[c.chan].note=c.value;
|
||||||
|
chan[c.chan].freqChanged=true;
|
||||||
|
}
|
||||||
|
chan[c.chan].active=true;
|
||||||
|
chan[c.chan].keyOn=true;
|
||||||
|
rWrite(0,1);
|
||||||
|
rWrite(0,2);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chan[c.chan].sample=-1;
|
||||||
|
chan[c.chan].macroInit(NULL);
|
||||||
|
chan[c.chan].outVol=chan[c.chan].vol;
|
||||||
|
if ((12*sampleBank+c.value%12)>=parent->song.sampleLen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//DivSample* s=parent->getSample(12*sampleBank+c.value%12);
|
||||||
|
sample=12*sampleBank+c.value%12;
|
||||||
|
samplePos=0;
|
||||||
|
msm->ctrl_w(1);
|
||||||
|
msm->ctrl_w(2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_NOTE_OFF:
|
||||||
|
chan[c.chan].keyOff=true;
|
||||||
|
chan[c.chan].keyOn=false;
|
||||||
|
chan[c.chan].active=false;
|
||||||
|
rWrite(0,1); // turn off
|
||||||
|
sample=-1;
|
||||||
|
samplePos=0;
|
||||||
|
chan[c.chan].macroInit(NULL);
|
||||||
|
break;
|
||||||
|
case DIV_CMD_NOTE_OFF_ENV:
|
||||||
|
chan[c.chan].keyOff=true;
|
||||||
|
chan[c.chan].keyOn=false;
|
||||||
|
chan[c.chan].active=false;
|
||||||
|
rWrite(0,1); // turn off
|
||||||
|
sample=-1;
|
||||||
|
samplePos=0;
|
||||||
|
chan[c.chan].std.release();
|
||||||
|
break;
|
||||||
|
case DIV_CMD_ENV_RELEASE:
|
||||||
|
chan[c.chan].std.release();
|
||||||
|
break;
|
||||||
|
case DIV_CMD_VOLUME: {
|
||||||
|
chan[c.chan].vol=c.value;
|
||||||
|
if (!chan[c.chan].std.vol.has) {
|
||||||
|
chan[c.chan].outVol=c.value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_GET_VOLUME: {
|
||||||
|
return chan[c.chan].vol;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_INSTRUMENT:
|
||||||
|
if (chan[c.chan].ins!=c.value || c.value2==1) {
|
||||||
|
chan[c.chan].insChanged=true;
|
||||||
|
}
|
||||||
|
chan[c.chan].ins=c.value;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_PITCH: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_NOTE_PORTA: {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case DIV_CMD_SAMPLE_BANK:
|
||||||
|
sampleBank=c.value;
|
||||||
|
if (sampleBank>(parent->song.sample.size()/12)) {
|
||||||
|
sampleBank=parent->song.sample.size()/12;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DIV_CMD_LEGATO: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_ALWAYS_SET_VOLUME:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_GET_VOLMAX:
|
||||||
|
return 8;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_PRE_PORTA:
|
||||||
|
break;
|
||||||
|
case DIV_CMD_PRE_NOTE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//printf("WARNING: unimplemented command %d\n",c.cmd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::muteChannel(int ch, bool mute) {
|
||||||
|
isMuted[ch]=mute;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::forceIns() {
|
||||||
|
while (!writes.empty()) writes.pop();
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
chan[i].insChanged=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void* DivPlatformMSM6258::getChanState(int ch) {
|
||||||
|
return &chan[ch];
|
||||||
|
}
|
||||||
|
|
||||||
|
DivDispatchOscBuffer* DivPlatformMSM6258::getOscBuffer(int ch) {
|
||||||
|
return oscBuf[ch];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* DivPlatformMSM6258::getRegisterPool() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DivPlatformMSM6258::getRegisterPoolSize() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::poke(unsigned int addr, unsigned short val) {
|
||||||
|
//immWrite(addr,val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::poke(std::vector<DivRegWrite>& wlist) {
|
||||||
|
//for (DivRegWrite& i: wlist) immWrite(i.addr,i.val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::reset() {
|
||||||
|
while (!writes.empty()) writes.pop();
|
||||||
|
msm->device_reset();
|
||||||
|
if (dumpWrites) {
|
||||||
|
addWrite(0xffffffff,0);
|
||||||
|
}
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
chan[i]=DivPlatformMSM6258::Channel();
|
||||||
|
chan[i].std.setEngine(parent);
|
||||||
|
}
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
chan[i].vol=8;
|
||||||
|
chan[i].outVol=8;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampleBank=0;
|
||||||
|
sample=-1;
|
||||||
|
samplePos=0;
|
||||||
|
|
||||||
|
delay=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DivPlatformMSM6258::keyOffAffectsArp(int ch) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::notifyInsChange(int ins) {
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
if (chan[i].ins==ins) {
|
||||||
|
chan[i].insChanged=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::notifyInsDeletion(void* ins) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* DivPlatformMSM6258::getSampleMem(int index) {
|
||||||
|
return index == 0 ? adpcmMem : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t DivPlatformMSM6258::getSampleMemCapacity(int index) {
|
||||||
|
return index == 0 ? 262144 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t DivPlatformMSM6258::getSampleMemUsage(int index) {
|
||||||
|
return index == 0 ? adpcmMemLen : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::renderSamples() {
|
||||||
|
memset(adpcmMem,0,getSampleMemCapacity(0));
|
||||||
|
|
||||||
|
// sample data
|
||||||
|
size_t memPos=0;
|
||||||
|
int sampleCount=parent->song.sampleLen;
|
||||||
|
if (sampleCount>128) sampleCount=128;
|
||||||
|
for (int i=0; i<sampleCount; i++) {
|
||||||
|
DivSample* s=parent->song.sample[i];
|
||||||
|
int paddedLen=s->lengthVOX;
|
||||||
|
if (memPos>=getSampleMemCapacity(0)) {
|
||||||
|
logW("out of ADPCM memory for sample %d!",i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (memPos+paddedLen>=getSampleMemCapacity(0)) {
|
||||||
|
memcpy(adpcmMem+memPos,s->dataVOX,getSampleMemCapacity(0)-memPos);
|
||||||
|
logW("out of ADPCM memory for sample %d!",i);
|
||||||
|
} else {
|
||||||
|
memcpy(adpcmMem+memPos,s->dataVOX,paddedLen);
|
||||||
|
}
|
||||||
|
s->offVOX=memPos;
|
||||||
|
memPos+=paddedLen;
|
||||||
|
}
|
||||||
|
adpcmMemLen=memPos+256;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::setFlags(unsigned int flags) {
|
||||||
|
if (flags&1) {
|
||||||
|
chipClock=4096000;
|
||||||
|
} else {
|
||||||
|
chipClock=4000000;
|
||||||
|
}
|
||||||
|
rate=chipClock/256;
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
isMuted[i]=false;
|
||||||
|
oscBuf[i]->rate=rate/256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DivPlatformMSM6258::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||||
|
parent=p;
|
||||||
|
adpcmMem=new unsigned char[getSampleMemCapacity(0)];
|
||||||
|
adpcmMemLen=0;
|
||||||
|
dumpWrites=false;
|
||||||
|
skipRegisterWrites=false;
|
||||||
|
updateOsc=0;
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
isMuted[i]=false;
|
||||||
|
oscBuf[i]=new DivDispatchOscBuffer;
|
||||||
|
}
|
||||||
|
msm=new okim6258_device(4000000);
|
||||||
|
msm->device_start();
|
||||||
|
setFlags(flags);
|
||||||
|
reset();
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6258::quit() {
|
||||||
|
for (int i=0; i<1; i++) {
|
||||||
|
delete oscBuf[i];
|
||||||
|
}
|
||||||
|
delete msm;
|
||||||
|
delete[] adpcmMem;
|
||||||
|
}
|
||||||
|
|
||||||
|
DivPlatformMSM6258::~DivPlatformMSM6258() {
|
||||||
|
}
|
129
src/engine/platform/msm6258.h
Normal file
129
src/engine/platform/msm6258.h
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* 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 _MSM6258_H
|
||||||
|
#define _MSM6258_H
|
||||||
|
#include "../dispatch.h"
|
||||||
|
#include "../macroInt.h"
|
||||||
|
#include <queue>
|
||||||
|
#include "sound/oki/okim6258.h"
|
||||||
|
|
||||||
|
class DivPlatformMSM6258: public DivDispatch {
|
||||||
|
protected:
|
||||||
|
const unsigned short chanOffs[6]={
|
||||||
|
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Channel {
|
||||||
|
unsigned char freqH, freqL;
|
||||||
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
|
||||||
|
unsigned char psgMode, autoEnvNum, autoEnvDen;
|
||||||
|
signed char konCycles;
|
||||||
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
|
||||||
|
int vol, outVol;
|
||||||
|
int sample;
|
||||||
|
unsigned char pan;
|
||||||
|
DivMacroInt std;
|
||||||
|
void macroInit(DivInstrument* which) {
|
||||||
|
std.init(which);
|
||||||
|
pitch2=0;
|
||||||
|
}
|
||||||
|
Channel():
|
||||||
|
freqH(0),
|
||||||
|
freqL(0),
|
||||||
|
freq(0),
|
||||||
|
baseFreq(0),
|
||||||
|
pitch(0),
|
||||||
|
pitch2(0),
|
||||||
|
portaPauseFreq(0),
|
||||||
|
note(0),
|
||||||
|
ins(-1),
|
||||||
|
psgMode(1),
|
||||||
|
autoEnvNum(0),
|
||||||
|
autoEnvDen(0),
|
||||||
|
active(false),
|
||||||
|
insChanged(true),
|
||||||
|
freqChanged(false),
|
||||||
|
keyOn(false),
|
||||||
|
keyOff(false),
|
||||||
|
portaPause(false),
|
||||||
|
inPorta(false),
|
||||||
|
furnacePCM(false),
|
||||||
|
hardReset(false),
|
||||||
|
vol(0),
|
||||||
|
outVol(15),
|
||||||
|
sample(-1),
|
||||||
|
pan(3) {}
|
||||||
|
};
|
||||||
|
Channel chan[1];
|
||||||
|
DivDispatchOscBuffer* oscBuf[1];
|
||||||
|
bool isMuted[1];
|
||||||
|
struct QueuedWrite {
|
||||||
|
unsigned short addr;
|
||||||
|
unsigned char val;
|
||||||
|
bool addrOrVal;
|
||||||
|
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
||||||
|
};
|
||||||
|
std::queue<QueuedWrite> writes;
|
||||||
|
okim6258_device* msm;
|
||||||
|
unsigned char regPool[512];
|
||||||
|
unsigned char lastBusy;
|
||||||
|
|
||||||
|
unsigned char* adpcmMem;
|
||||||
|
size_t adpcmMemLen;
|
||||||
|
unsigned char sampleBank;
|
||||||
|
|
||||||
|
int delay, updateOsc, sample, samplePos;
|
||||||
|
|
||||||
|
bool extMode;
|
||||||
|
|
||||||
|
short oldWrites[512];
|
||||||
|
short pendingWrites[512];
|
||||||
|
|
||||||
|
friend void putDispatchChan(void*,int,int);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
|
int dispatch(DivCommand c);
|
||||||
|
void* getChanState(int chan);
|
||||||
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||||
|
unsigned char* getRegisterPool();
|
||||||
|
int getRegisterPoolSize();
|
||||||
|
void reset();
|
||||||
|
void forceIns();
|
||||||
|
void tick(bool sysTick=true);
|
||||||
|
void muteChannel(int ch, bool mute);
|
||||||
|
bool keyOffAffectsArp(int ch);
|
||||||
|
void notifyInsChange(int ins);
|
||||||
|
void notifyInsDeletion(void* ins);
|
||||||
|
void poke(unsigned int addr, unsigned short val);
|
||||||
|
void poke(std::vector<DivRegWrite>& wlist);
|
||||||
|
void setFlags(unsigned int flags);
|
||||||
|
const char** getRegisterSheet();
|
||||||
|
const char* getEffectName(unsigned char effect);
|
||||||
|
const void* getSampleMem(int index);
|
||||||
|
size_t getSampleMemCapacity(int index);
|
||||||
|
size_t getSampleMemUsage(int index);
|
||||||
|
void renderSamples();
|
||||||
|
|
||||||
|
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
||||||
|
void quit();
|
||||||
|
~DivPlatformMSM6258();
|
||||||
|
};
|
||||||
|
#endif
|
345
src/engine/platform/msm6295.cpp
Normal file
345
src/engine/platform/msm6295.cpp
Normal file
|
@ -0,0 +1,345 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* 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 "msm6295.h"
|
||||||
|
#include "../engine.h"
|
||||||
|
#include "../../ta-log.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define rWrite(v) if (!skipRegisterWrites) {writes.emplace(0,v); if (dumpWrites) {addWrite(0,v);} }
|
||||||
|
|
||||||
|
const char** DivPlatformMSM6295::getRegisterSheet() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* DivPlatformMSM6295::getEffectName(unsigned char effect) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 DivMSM6295Interface::read_byte(u32 address) {
|
||||||
|
return adpcmMem[address&0xffff];
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
|
for (size_t h=start; h<start+len; h++) {
|
||||||
|
if (delay<=0) {
|
||||||
|
if (!writes.empty()) {
|
||||||
|
QueuedWrite& w=writes.front();
|
||||||
|
msm->command_w(w.val);
|
||||||
|
writes.pop();
|
||||||
|
delay=32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delay--;
|
||||||
|
}
|
||||||
|
|
||||||
|
msm->tick();
|
||||||
|
|
||||||
|
bufL[h]=msm->out()<<4;
|
||||||
|
|
||||||
|
if (++updateOsc>=22) {
|
||||||
|
updateOsc=0;
|
||||||
|
// TODO: per-channel osc
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=msm->m_voice[i].m_muted?0:(msm->m_voice[i].m_out<<6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::tick(bool sysTick) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
int DivPlatformMSM6295::dispatch(DivCommand c) {
|
||||||
|
switch (c.cmd) {
|
||||||
|
case DIV_CMD_NOTE_ON: {
|
||||||
|
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_FM);
|
||||||
|
if (ins->type==DIV_INS_AMIGA) {
|
||||||
|
chan[c.chan].furnacePCM=true;
|
||||||
|
} else {
|
||||||
|
chan[c.chan].furnacePCM=false;
|
||||||
|
}
|
||||||
|
if (skipRegisterWrites) break;
|
||||||
|
if (chan[c.chan].furnacePCM) {
|
||||||
|
chan[c.chan].macroInit(ins);
|
||||||
|
if (!chan[c.chan].std.vol.will) {
|
||||||
|
chan[c.chan].outVol=chan[c.chan].vol;
|
||||||
|
}
|
||||||
|
chan[c.chan].sample=ins->amiga.getSample(c.value);
|
||||||
|
if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) {
|
||||||
|
//DivSample* s=parent->getSample(chan[c.chan].sample);
|
||||||
|
if (c.value!=DIV_NOTE_NULL) {
|
||||||
|
chan[c.chan].note=c.value;
|
||||||
|
chan[c.chan].freqChanged=true;
|
||||||
|
}
|
||||||
|
chan[c.chan].active=true;
|
||||||
|
chan[c.chan].keyOn=true;
|
||||||
|
rWrite((8<<c.chan)); // turn off
|
||||||
|
rWrite(0x80|chan[c.chan].sample); // set phrase
|
||||||
|
rWrite((16<<c.chan)|(8-chan[c.chan].outVol)); // turn on
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chan[c.chan].sample=-1;
|
||||||
|
chan[c.chan].macroInit(NULL);
|
||||||
|
chan[c.chan].outVol=chan[c.chan].vol;
|
||||||
|
if ((12*sampleBank+c.value%12)>=parent->song.sampleLen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//DivSample* s=parent->getSample(12*sampleBank+c.value%12);
|
||||||
|
chan[c.chan].sample=12*sampleBank+c.value%12;
|
||||||
|
rWrite((8<<c.chan)); // turn off
|
||||||
|
rWrite(0x80|chan[c.chan].sample); // set phrase
|
||||||
|
rWrite((16<<c.chan)|(8-chan[c.chan].outVol)); // turn on
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_NOTE_OFF:
|
||||||
|
chan[c.chan].keyOff=true;
|
||||||
|
chan[c.chan].keyOn=false;
|
||||||
|
chan[c.chan].active=false;
|
||||||
|
rWrite((8<<c.chan)); // turn off
|
||||||
|
chan[c.chan].macroInit(NULL);
|
||||||
|
break;
|
||||||
|
case DIV_CMD_NOTE_OFF_ENV:
|
||||||
|
chan[c.chan].keyOff=true;
|
||||||
|
chan[c.chan].keyOn=false;
|
||||||
|
chan[c.chan].active=false;
|
||||||
|
rWrite((8<<c.chan)); // turn off
|
||||||
|
chan[c.chan].std.release();
|
||||||
|
break;
|
||||||
|
case DIV_CMD_ENV_RELEASE:
|
||||||
|
chan[c.chan].std.release();
|
||||||
|
break;
|
||||||
|
case DIV_CMD_VOLUME: {
|
||||||
|
chan[c.chan].vol=c.value;
|
||||||
|
if (!chan[c.chan].std.vol.has) {
|
||||||
|
chan[c.chan].outVol=c.value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_GET_VOLUME: {
|
||||||
|
return chan[c.chan].vol;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_INSTRUMENT:
|
||||||
|
if (chan[c.chan].ins!=c.value || c.value2==1) {
|
||||||
|
chan[c.chan].insChanged=true;
|
||||||
|
}
|
||||||
|
chan[c.chan].ins=c.value;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_PITCH: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_CMD_NOTE_PORTA: {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case DIV_CMD_SAMPLE_BANK:
|
||||||
|
sampleBank=c.value;
|
||||||
|
if (sampleBank>(parent->song.sample.size()/12)) {
|
||||||
|
sampleBank=parent->song.sample.size()/12;
|
||||||
|
}
|
||||||
|
iface.sampleBank=sampleBank;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_LEGATO: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DIV_ALWAYS_SET_VOLUME:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_GET_VOLMAX:
|
||||||
|
return 8;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_PRE_PORTA:
|
||||||
|
break;
|
||||||
|
case DIV_CMD_PRE_NOTE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//printf("WARNING: unimplemented command %d\n",c.cmd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::muteChannel(int ch, bool mute) {
|
||||||
|
isMuted[ch]=mute;
|
||||||
|
msm->m_voice[ch].m_muted=mute;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::forceIns() {
|
||||||
|
while (!writes.empty()) writes.pop();
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
chan[i].insChanged=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void* DivPlatformMSM6295::getChanState(int ch) {
|
||||||
|
return &chan[ch];
|
||||||
|
}
|
||||||
|
|
||||||
|
DivDispatchOscBuffer* DivPlatformMSM6295::getOscBuffer(int ch) {
|
||||||
|
return oscBuf[ch];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char* DivPlatformMSM6295::getRegisterPool() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DivPlatformMSM6295::getRegisterPoolSize() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::poke(unsigned int addr, unsigned short val) {
|
||||||
|
//immWrite(addr,val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::poke(std::vector<DivRegWrite>& wlist) {
|
||||||
|
//for (DivRegWrite& i: wlist) immWrite(i.addr,i.val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::reset() {
|
||||||
|
while (!writes.empty()) writes.pop();
|
||||||
|
msm->reset();
|
||||||
|
if (dumpWrites) {
|
||||||
|
addWrite(0xffffffff,0);
|
||||||
|
}
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
chan[i]=DivPlatformMSM6295::Channel();
|
||||||
|
chan[i].std.setEngine(parent);
|
||||||
|
}
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
chan[i].vol=8;
|
||||||
|
chan[i].outVol=8;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampleBank=0;
|
||||||
|
|
||||||
|
delay=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DivPlatformMSM6295::keyOffAffectsArp(int ch) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::notifyInsChange(int ins) {
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
if (chan[i].ins==ins) {
|
||||||
|
chan[i].insChanged=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::notifyInsDeletion(void* ins) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* DivPlatformMSM6295::getSampleMem(int index) {
|
||||||
|
return index == 0 ? adpcmMem : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t DivPlatformMSM6295::getSampleMemCapacity(int index) {
|
||||||
|
return index == 0 ? 262144 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t DivPlatformMSM6295::getSampleMemUsage(int index) {
|
||||||
|
return index == 0 ? adpcmMemLen : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::renderSamples() {
|
||||||
|
memset(adpcmMem,0,getSampleMemCapacity(0));
|
||||||
|
|
||||||
|
// sample data
|
||||||
|
size_t memPos=128*8;
|
||||||
|
int sampleCount=parent->song.sampleLen;
|
||||||
|
if (sampleCount>128) sampleCount=128;
|
||||||
|
for (int i=0; i<sampleCount; i++) {
|
||||||
|
DivSample* s=parent->song.sample[i];
|
||||||
|
int paddedLen=s->lengthVOX;
|
||||||
|
if (memPos>=getSampleMemCapacity(0)) {
|
||||||
|
logW("out of ADPCM memory for sample %d!",i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (memPos+paddedLen>=getSampleMemCapacity(0)) {
|
||||||
|
memcpy(adpcmMem+memPos,s->dataVOX,getSampleMemCapacity(0)-memPos);
|
||||||
|
logW("out of ADPCM memory for sample %d!",i);
|
||||||
|
} else {
|
||||||
|
memcpy(adpcmMem+memPos,s->dataVOX,paddedLen);
|
||||||
|
}
|
||||||
|
s->offVOX=memPos;
|
||||||
|
memPos+=paddedLen;
|
||||||
|
}
|
||||||
|
adpcmMemLen=memPos+256;
|
||||||
|
|
||||||
|
// phrase book
|
||||||
|
for (int i=0; i<sampleCount; i++) {
|
||||||
|
DivSample* s=parent->song.sample[i];
|
||||||
|
int endPos=s->offVOX+s->lengthVOX;
|
||||||
|
adpcmMem[i*8]=(s->offVOX>>16)&0xff;
|
||||||
|
adpcmMem[1+i*8]=(s->offVOX>>8)&0xff;
|
||||||
|
adpcmMem[2+i*8]=(s->offVOX)&0xff;
|
||||||
|
adpcmMem[3+i*8]=(endPos>>16)&0xff;
|
||||||
|
adpcmMem[4+i*8]=(endPos>>8)&0xff;
|
||||||
|
adpcmMem[5+i*8]=(endPos)&0xff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::setFlags(unsigned int flags) {
|
||||||
|
if (flags&1) {
|
||||||
|
chipClock=8448000;
|
||||||
|
} else {
|
||||||
|
chipClock=8000000;
|
||||||
|
}
|
||||||
|
rate=chipClock/((flags&2)?6:24);
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
isMuted[i]=false;
|
||||||
|
oscBuf[i]->rate=rate/22;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DivPlatformMSM6295::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||||
|
parent=p;
|
||||||
|
adpcmMem=new unsigned char[getSampleMemCapacity(0)];
|
||||||
|
adpcmMemLen=0;
|
||||||
|
iface.adpcmMem=adpcmMem;
|
||||||
|
iface.sampleBank=0;
|
||||||
|
dumpWrites=false;
|
||||||
|
skipRegisterWrites=false;
|
||||||
|
updateOsc=0;
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
isMuted[i]=false;
|
||||||
|
oscBuf[i]=new DivDispatchOscBuffer;
|
||||||
|
}
|
||||||
|
msm=new msm6295_core(iface);
|
||||||
|
setFlags(flags);
|
||||||
|
reset();
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformMSM6295::quit() {
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
delete oscBuf[i];
|
||||||
|
}
|
||||||
|
delete msm;
|
||||||
|
delete[] adpcmMem;
|
||||||
|
}
|
||||||
|
|
||||||
|
DivPlatformMSM6295::~DivPlatformMSM6295() {
|
||||||
|
}
|
138
src/engine/platform/msm6295.h
Normal file
138
src/engine/platform/msm6295.h
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* 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 _MSM6295_H
|
||||||
|
#define _MSM6295_H
|
||||||
|
#include "../dispatch.h"
|
||||||
|
#include "../macroInt.h"
|
||||||
|
#include <queue>
|
||||||
|
#include "sound/oki/msm6295.hpp"
|
||||||
|
|
||||||
|
class DivMSM6295Interface: public vgsound_emu_mem_intf {
|
||||||
|
public:
|
||||||
|
unsigned char* adpcmMem;
|
||||||
|
int sampleBank;
|
||||||
|
u8 read_byte(u32 address);
|
||||||
|
DivMSM6295Interface(): adpcmMem(NULL), sampleBank(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class DivPlatformMSM6295: public DivDispatch {
|
||||||
|
protected:
|
||||||
|
const unsigned short chanOffs[6]={
|
||||||
|
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Channel {
|
||||||
|
unsigned char freqH, freqL;
|
||||||
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
|
||||||
|
unsigned char psgMode, autoEnvNum, autoEnvDen;
|
||||||
|
signed char konCycles;
|
||||||
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
|
||||||
|
int vol, outVol;
|
||||||
|
int sample;
|
||||||
|
unsigned char pan;
|
||||||
|
DivMacroInt std;
|
||||||
|
void macroInit(DivInstrument* which) {
|
||||||
|
std.init(which);
|
||||||
|
pitch2=0;
|
||||||
|
}
|
||||||
|
Channel():
|
||||||
|
freqH(0),
|
||||||
|
freqL(0),
|
||||||
|
freq(0),
|
||||||
|
baseFreq(0),
|
||||||
|
pitch(0),
|
||||||
|
pitch2(0),
|
||||||
|
portaPauseFreq(0),
|
||||||
|
note(0),
|
||||||
|
ins(-1),
|
||||||
|
psgMode(1),
|
||||||
|
autoEnvNum(0),
|
||||||
|
autoEnvDen(0),
|
||||||
|
active(false),
|
||||||
|
insChanged(true),
|
||||||
|
freqChanged(false),
|
||||||
|
keyOn(false),
|
||||||
|
keyOff(false),
|
||||||
|
portaPause(false),
|
||||||
|
inPorta(false),
|
||||||
|
furnacePCM(false),
|
||||||
|
hardReset(false),
|
||||||
|
vol(0),
|
||||||
|
outVol(15),
|
||||||
|
sample(-1),
|
||||||
|
pan(3) {}
|
||||||
|
};
|
||||||
|
Channel chan[4];
|
||||||
|
DivDispatchOscBuffer* oscBuf[4];
|
||||||
|
bool isMuted[4];
|
||||||
|
struct QueuedWrite {
|
||||||
|
unsigned short addr;
|
||||||
|
unsigned char val;
|
||||||
|
bool addrOrVal;
|
||||||
|
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
||||||
|
};
|
||||||
|
std::queue<QueuedWrite> writes;
|
||||||
|
msm6295_core* msm;
|
||||||
|
unsigned char regPool[512];
|
||||||
|
unsigned char lastBusy;
|
||||||
|
|
||||||
|
unsigned char* adpcmMem;
|
||||||
|
size_t adpcmMemLen;
|
||||||
|
DivMSM6295Interface iface;
|
||||||
|
unsigned char sampleBank;
|
||||||
|
|
||||||
|
int delay, updateOsc;
|
||||||
|
|
||||||
|
bool extMode;
|
||||||
|
|
||||||
|
short oldWrites[512];
|
||||||
|
short pendingWrites[512];
|
||||||
|
|
||||||
|
friend void putDispatchChan(void*,int,int);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
|
int dispatch(DivCommand c);
|
||||||
|
void* getChanState(int chan);
|
||||||
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||||
|
unsigned char* getRegisterPool();
|
||||||
|
int getRegisterPoolSize();
|
||||||
|
void reset();
|
||||||
|
void forceIns();
|
||||||
|
void tick(bool sysTick=true);
|
||||||
|
void muteChannel(int ch, bool mute);
|
||||||
|
bool keyOffAffectsArp(int ch);
|
||||||
|
void notifyInsChange(int ins);
|
||||||
|
void notifyInsDeletion(void* ins);
|
||||||
|
void poke(unsigned int addr, unsigned short val);
|
||||||
|
void poke(std::vector<DivRegWrite>& wlist);
|
||||||
|
void setFlags(unsigned int flags);
|
||||||
|
const char** getRegisterSheet();
|
||||||
|
const char* getEffectName(unsigned char effect);
|
||||||
|
const void* getSampleMem(int index);
|
||||||
|
size_t getSampleMemCapacity(int index);
|
||||||
|
size_t getSampleMemUsage(int index);
|
||||||
|
void renderSamples();
|
||||||
|
|
||||||
|
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
||||||
|
void quit();
|
||||||
|
~DivPlatformMSM6295();
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -268,7 +268,7 @@ void DivPlatformN163::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ void DivPlatformOPL::tick(bool sysTick) {
|
||||||
if (isMuted[i]) {
|
if (isMuted[i]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[i].state.alg][j] || i>=melodicChans) {
|
if (isOutputL[ops==4][chan[i].state.alg][j] || i>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[i].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[i].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -384,7 +384,7 @@ void DivPlatformOPL::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ void DivPlatformOPL::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,7 @@ void DivPlatformOPL::tick(bool sysTick) {
|
||||||
if (isMuted[i]) {
|
if (isMuted[i]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[i].state.alg][j] || i>=melodicChans) {
|
if (isOutputL[ops==4][chan[i].state.alg][j] || i>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[i].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[i].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -688,7 +688,7 @@ void DivPlatformOPL::muteChannel(int ch, bool mute) {
|
||||||
if (isMuted[ch]) {
|
if (isMuted[ch]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[ch].state.alg][i] || ch>=melodicChans) {
|
if (isOutputL[ops==4][chan[ch].state.alg][i] || ch>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[ch].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[ch].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -734,12 +734,12 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
chan[c.chan].sample=ins->amiga.getSample(c.value);
|
chan[c.chan].sample=ins->amiga.getSample(c.value);
|
||||||
if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) {
|
if (chan[c.chan].sample>=0 && chan[c.chan].sample<parent->song.sampleLen) {
|
||||||
DivSample* s=parent->getSample(chan[c.chan].sample);
|
DivSample* s=parent->getSample(chan[c.chan].sample);
|
||||||
immWrite(9,(s->offB>>5)&0xff);
|
immWrite(8,0);
|
||||||
immWrite(10,(s->offB>>13)&0xff);
|
immWrite(9,(s->offB>>2)&0xff);
|
||||||
|
immWrite(10,(s->offB>>10)&0xff);
|
||||||
int end=s->offB+s->lengthB-1;
|
int end=s->offB+s->lengthB-1;
|
||||||
immWrite(11,(end>>5)&0xff);
|
immWrite(11,(end>>2)&0xff);
|
||||||
immWrite(12,(end>>13)&0xff);
|
immWrite(12,(end>>10)&0xff);
|
||||||
immWrite(8,1);
|
|
||||||
immWrite(7,(s->loopStart>=0)?0xb0:0xa0); // start/repeat
|
immWrite(7,(s->loopStart>=0)?0xb0:0xa0); // start/repeat
|
||||||
if (c.value!=DIV_NOTE_NULL) {
|
if (c.value!=DIV_NOTE_NULL) {
|
||||||
chan[c.chan].note=c.value;
|
chan[c.chan].note=c.value;
|
||||||
|
@ -769,12 +769,12 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DivSample* s=parent->getSample(12*sampleBank+c.value%12);
|
DivSample* s=parent->getSample(12*sampleBank+c.value%12);
|
||||||
|
immWrite(8,0);
|
||||||
immWrite(9,(s->offB>>2)&0xff);
|
immWrite(9,(s->offB>>2)&0xff);
|
||||||
immWrite(10,(s->offB>>10)&0xff);
|
immWrite(10,(s->offB>>10)&0xff);
|
||||||
int end=s->offB+s->lengthB-1;
|
int end=s->offB+s->lengthB-1;
|
||||||
immWrite(11,(end>>2)&0xff);
|
immWrite(11,(end>>2)&0xff);
|
||||||
immWrite(12,(end>>10)&0xff);
|
immWrite(12,(end>>10)&0xff);
|
||||||
immWrite(8,1);
|
|
||||||
immWrite(7,(s->loopStart>=0)?0xb0:0xa0); // start/repeat
|
immWrite(7,(s->loopStart>=0)?0xb0:0xa0); // start/repeat
|
||||||
int freq=(65536.0*(double)s->rate)/(double)rate;
|
int freq=(65536.0*(double)s->rate)/(double)rate;
|
||||||
immWrite(16,freq&0xff);
|
immWrite(16,freq&0xff);
|
||||||
|
@ -808,7 +808,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
if (isMuted[c.chan]) {
|
if (isMuted[c.chan]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[c.chan].state.alg][i] || c.chan>=melodicChans) {
|
if (isOutputL[ops==4][chan[c.chan].state.alg][i] || c.chan>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -911,7 +911,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
if (isMuted[c.chan]) {
|
if (isMuted[c.chan]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[c.chan].state.alg][i] || c.chan>=melodicChans) {
|
if (isOutputL[ops==4][chan[c.chan].state.alg][i] || c.chan>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -1060,7 +1060,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
if (isMuted[c.chan]) {
|
if (isMuted[c.chan]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[c.chan].state.alg][c.value] || c.chan>=melodicChans) {
|
if (isOutputL[ops==4][chan[c.chan].state.alg][c.value] || c.chan>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -1290,7 +1290,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
if (isMuted[c.chan]) {
|
if (isMuted[c.chan]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[c.chan].state.alg][i] || c.chan>=melodicChans) {
|
if (isOutputL[ops==4][chan[c.chan].state.alg][i] || c.chan>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -1307,7 +1307,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
if (isMuted[c.chan]) {
|
if (isMuted[c.chan]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[c.chan].state.alg][c.value] || c.chan>=melodicChans) {
|
if (isOutputL[ops==4][chan[c.chan].state.alg][c.value] || c.chan>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -1367,9 +1367,10 @@ void DivPlatformOPL::forceIns() {
|
||||||
totalChans=properDrums?11:9;
|
totalChans=properDrums?11:9;
|
||||||
}
|
}
|
||||||
for (int i=0; i<totalChans; i++) {
|
for (int i=0; i<totalChans; i++) {
|
||||||
int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2;
|
//int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2;
|
||||||
chan[i].insChanged=true;
|
chan[i].insChanged=true;
|
||||||
chan[i].freqChanged=true;
|
chan[i].freqChanged=true;
|
||||||
|
/*
|
||||||
chan[i].fourOp=(ops==4);
|
chan[i].fourOp=(ops==4);
|
||||||
for (int j=0; j<ops; j++) {
|
for (int j=0; j<ops; j++) {
|
||||||
unsigned char slot=slots[j][i];
|
unsigned char slot=slots[j][i];
|
||||||
|
@ -1380,7 +1381,7 @@ void DivPlatformOPL::forceIns() {
|
||||||
if (isMuted[i]) {
|
if (isMuted[i]) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
if (isOutputL[ops==4][chan[i].state.alg][j] || i>=melodicChans) {
|
if (isOutputL[ops==4][chan[i].state.alg][j] || i>melodicChans) {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[i].outVol&0x3f))/63))|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[i].outVol&0x3f))/63))|(op.ksl<<6));
|
||||||
} else {
|
} else {
|
||||||
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
|
||||||
|
@ -1406,6 +1407,10 @@ void DivPlatformOPL::forceIns() {
|
||||||
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1)|((chan[i].pan&3)<<4));
|
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1)|((chan[i].pan&3)<<4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
for (int i=0; i<512; i++) {
|
||||||
|
oldWrites[i]=-1;
|
||||||
}
|
}
|
||||||
immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState);
|
immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState);
|
||||||
update4OpMask=true;
|
update4OpMask=true;
|
||||||
|
@ -1698,7 +1703,7 @@ int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, unsigned int f
|
||||||
adpcmBMemLen=0;
|
adpcmBMemLen=0;
|
||||||
iface.adpcmBMem=adpcmBMem;
|
iface.adpcmBMem=adpcmBMem;
|
||||||
iface.sampleBank=0;
|
iface.sampleBank=0;
|
||||||
adpcmB=new ymfm::adpcm_b_engine(iface,5);
|
adpcmB=new ymfm::adpcm_b_engine(iface,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
|
@ -181,7 +181,7 @@ void DivPlatformOPLL::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ void DivPlatformOPLL::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ void DivPlatformPCE::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ void DivPlatformPCSpeaker::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,7 @@ void DivPlatformQSound::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ void DivPlatformRF5C68::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ void DivPlatformSAA1099::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ void DivPlatformSCC::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,14 @@ void DivPlatformSCC::tick(bool sysTick) {
|
||||||
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER)-1;
|
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER)-1;
|
||||||
if (chan[i].freq<0) chan[i].freq=0;
|
if (chan[i].freq<0) chan[i].freq=0;
|
||||||
if (chan[i].freq>4095) chan[i].freq=4095;
|
if (chan[i].freq>4095) chan[i].freq=4095;
|
||||||
|
if (!chan[i].freqInit || regPool[regBase+0+i*2]!=(chan[i].freq&0xff)) {
|
||||||
rWrite(regBase+0+i*2,chan[i].freq&0xff);
|
rWrite(regBase+0+i*2,chan[i].freq&0xff);
|
||||||
|
}
|
||||||
|
if (!chan[i].freqInit || regPool[regBase+1+i*2]!=(chan[i].freq>>8)) {
|
||||||
rWrite(regBase+1+i*2,chan[i].freq>>8);
|
rWrite(regBase+1+i*2,chan[i].freq>>8);
|
||||||
|
}
|
||||||
chan[i].freqChanged=false;
|
chan[i].freqChanged=false;
|
||||||
|
chan[i].freqInit=!skipRegisterWrites;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +291,7 @@ void DivPlatformSCC::forceIns() {
|
||||||
for (int i=0; i<5; i++) {
|
for (int i=0; i<5; i++) {
|
||||||
chan[i].insChanged=true;
|
chan[i].insChanged=true;
|
||||||
chan[i].freqChanged=true;
|
chan[i].freqChanged=true;
|
||||||
|
chan[i].freqInit=false;
|
||||||
if (isPlus || i<3) {
|
if (isPlus || i<3) {
|
||||||
updateWave(i);
|
updateWave(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
class DivPlatformSCC: public DivDispatch {
|
class DivPlatformSCC: public DivDispatch {
|
||||||
struct Channel {
|
struct Channel {
|
||||||
int freq, baseFreq, pitch, pitch2, note, ins;
|
int freq, baseFreq, pitch, pitch2, note, ins;
|
||||||
bool active, insChanged, freqChanged, inPorta;
|
bool active, insChanged, freqChanged, freqInit, inPorta;
|
||||||
signed char vol, outVol, wave;
|
signed char vol, outVol, wave;
|
||||||
signed char waveROM[32] = {0}; // 4 bit PROM per channel on bubble system
|
signed char waveROM[32] = {0}; // 4 bit PROM per channel on bubble system
|
||||||
DivMacroInt std;
|
DivMacroInt std;
|
||||||
|
@ -48,6 +48,7 @@ class DivPlatformSCC: public DivDispatch {
|
||||||
active(false),
|
active(false),
|
||||||
insChanged(true),
|
insChanged(true),
|
||||||
freqChanged(false),
|
freqChanged(false),
|
||||||
|
freqInit(false),
|
||||||
inPorta(false),
|
inPorta(false),
|
||||||
vol(15),
|
vol(15),
|
||||||
outVol(15),
|
outVol(15),
|
||||||
|
|
|
@ -122,7 +122,7 @@ void DivPlatformSegaPCM::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "../engine.h"
|
#include "../engine.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define rWrite(v) {if (!skipRegisterWrites) {sn->write(v); if (dumpWrites) {addWrite(0x200,v);}}}
|
#define rWrite(v) {if (!skipRegisterWrites) {writes.push(v); if (dumpWrites) {addWrite(0x200,v);}}}
|
||||||
|
|
||||||
const char* regCheatSheetSN[]={
|
const char* regCheatSheetSN[]={
|
||||||
"DATA", "0",
|
"DATA", "0",
|
||||||
|
@ -41,7 +41,47 @@ const char* DivPlatformSMS::getEffectName(unsigned char effect) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSMS::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
|
for (size_t h=start; h<start+len; h++) {
|
||||||
|
if (!writes.empty()) {
|
||||||
|
unsigned char w=writes.front();
|
||||||
|
YMPSG_Write(&sn_nuked,w);
|
||||||
|
writes.pop();
|
||||||
|
}
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
YMPSG_Clock(&sn_nuked);
|
||||||
|
bufL[h]=YMPSG_GetOutput(&sn_nuked)*8192.0;
|
||||||
|
/*
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
if (isMuted[i]) {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=0;
|
||||||
|
} else {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=sn->get_channel_output(i);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivPlatformSMS::acquire_mame(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
|
while (!writes.empty()) {
|
||||||
|
unsigned char w=writes.front();
|
||||||
|
sn->write(w);
|
||||||
|
writes.pop();
|
||||||
|
}
|
||||||
for (size_t h=start; h<start+len; h++) {
|
for (size_t h=start; h<start+len; h++) {
|
||||||
sn->sound_stream_update(bufL+h,1);
|
sn->sound_stream_update(bufL+h,1);
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
|
@ -54,6 +94,14 @@ void DivPlatformSMS::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivPlatformSMS::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
|
if (nuked) {
|
||||||
|
acquire_nuked(bufL,bufR,start,len);
|
||||||
|
} else {
|
||||||
|
acquire_mame(bufL,bufR,start,len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int DivPlatformSMS::acquireOne() {
|
int DivPlatformSMS::acquireOne() {
|
||||||
short v;
|
short v;
|
||||||
sn->sound_stream_update(&v,1);
|
sn->sound_stream_update(&v,1);
|
||||||
|
@ -112,7 +160,7 @@ void DivPlatformSMS::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -301,6 +349,7 @@ DivDispatchOscBuffer* DivPlatformSMS::getOscBuffer(int ch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSMS::reset() {
|
void DivPlatformSMS::reset() {
|
||||||
|
while (!writes.empty()) writes.pop();
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
chan[i]=DivPlatformSMS::Channel();
|
chan[i]=DivPlatformSMS::Channel();
|
||||||
chan[i].std.setEngine(parent);
|
chan[i].std.setEngine(parent);
|
||||||
|
@ -309,6 +358,7 @@ void DivPlatformSMS::reset() {
|
||||||
addWrite(0xffffffff,0);
|
addWrite(0xffffffff,0);
|
||||||
}
|
}
|
||||||
sn->device_start();
|
sn->device_start();
|
||||||
|
YMPSG_Init(&sn_nuked,isRealSN);
|
||||||
snNoiseMode=3;
|
snNoiseMode=3;
|
||||||
rWrite(0xe7);
|
rWrite(0xe7);
|
||||||
updateSNMode=false;
|
updateSNMode=false;
|
||||||
|
@ -352,6 +402,7 @@ void DivPlatformSMS::setFlags(unsigned int flags) {
|
||||||
chipClock=COLOR_NTSC;
|
chipClock=COLOR_NTSC;
|
||||||
}
|
}
|
||||||
resetPhase=!(flags&16);
|
resetPhase=!(flags&16);
|
||||||
|
|
||||||
if (sn!=NULL) delete sn;
|
if (sn!=NULL) delete sn;
|
||||||
switch ((flags>>2)&3) {
|
switch ((flags>>2)&3) {
|
||||||
case 1: // TI
|
case 1: // TI
|
||||||
|
@ -377,6 +428,10 @@ void DivPlatformSMS::setFlags(unsigned int flags) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivPlatformSMS::setNuked(bool value) {
|
||||||
|
nuked=value;
|
||||||
|
}
|
||||||
|
|
||||||
int DivPlatformSMS::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
int DivPlatformSMS::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||||
parent=p;
|
parent=p;
|
||||||
dumpWrites=false;
|
dumpWrites=false;
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
#include "../dispatch.h"
|
#include "../dispatch.h"
|
||||||
#include "../macroInt.h"
|
#include "../macroInt.h"
|
||||||
#include "sound/sn76496.h"
|
#include "sound/sn76496.h"
|
||||||
|
extern "C" {
|
||||||
|
#include "../../../extern/Nuked-PSG/ympsg.h"
|
||||||
|
}
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
class DivPlatformSMS: public DivDispatch {
|
class DivPlatformSMS: public DivDispatch {
|
||||||
struct Channel {
|
struct Channel {
|
||||||
|
@ -59,8 +63,14 @@ class DivPlatformSMS: public DivDispatch {
|
||||||
bool updateSNMode;
|
bool updateSNMode;
|
||||||
bool resetPhase;
|
bool resetPhase;
|
||||||
bool isRealSN;
|
bool isRealSN;
|
||||||
|
bool nuked;
|
||||||
sn76496_base_device* sn;
|
sn76496_base_device* sn;
|
||||||
|
ympsg_t sn_nuked;
|
||||||
|
std::queue<unsigned char> writes;
|
||||||
friend void putDispatchChan(void*,int,int);
|
friend void putDispatchChan(void*,int,int);
|
||||||
|
|
||||||
|
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
|
void acquire_mame(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
public:
|
public:
|
||||||
int acquireOne();
|
int acquireOne();
|
||||||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
|
@ -80,6 +90,7 @@ class DivPlatformSMS: public DivDispatch {
|
||||||
void poke(std::vector<DivRegWrite>& wlist);
|
void poke(std::vector<DivRegWrite>& wlist);
|
||||||
const char** getRegisterSheet();
|
const char** getRegisterSheet();
|
||||||
const char* getEffectName(unsigned char effect);
|
const char* getEffectName(unsigned char effect);
|
||||||
|
void setNuked(bool value);
|
||||||
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
||||||
void quit();
|
void quit();
|
||||||
~DivPlatformSMS();
|
~DivPlatformSMS();
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "n163.hpp"
|
#include "n163.hpp"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
void n163_core::tick()
|
void n163_core::tick()
|
||||||
{
|
{
|
||||||
|
@ -126,12 +127,12 @@ void n163_core::reset()
|
||||||
// reset this chip
|
// reset this chip
|
||||||
m_disable = false;
|
m_disable = false;
|
||||||
m_multiplex = true;
|
m_multiplex = true;
|
||||||
std::fill(std::begin(m_ram), std::end(m_ram), 0);
|
memset(m_ram,0,sizeof(m_ram));
|
||||||
m_voice_cycle = 0x78;
|
m_voice_cycle = 0x78;
|
||||||
m_addr_latch.reset();
|
m_addr_latch.reset();
|
||||||
m_out = 0;
|
m_out = 0;
|
||||||
m_acc = 0;
|
m_acc = 0;
|
||||||
std::fill(std::begin(m_ch_out), std::end(m_ch_out), 0);
|
memset(m_ch_out,0,sizeof(m_ch_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
// accessor
|
// accessor
|
||||||
|
|
|
@ -243,7 +243,7 @@ unsigned int NES_FDS::Render (int b[2])
|
||||||
int((MASTER_VOL / MAX_OUT) * 256.0 * 2.0f / 4.0f),
|
int((MASTER_VOL / MAX_OUT) * 256.0 * 2.0f / 4.0f),
|
||||||
int((MASTER_VOL / MAX_OUT) * 256.0 * 2.0f / 5.0f) };
|
int((MASTER_VOL / MAX_OUT) * 256.0 * 2.0f / 5.0f) };
|
||||||
|
|
||||||
int v = fout * MASTER[master_vol] >> 8;
|
int v = fout * MASTER[master_vol] >> 1;
|
||||||
|
|
||||||
// lowpass RC filter
|
// lowpass RC filter
|
||||||
int rc_out = ((rc_accum * rc_k) + (v * rc_l)) >> RC_BITS;
|
int rc_out = ((rc_accum * rc_k) + (v * rc_l)) >> RC_BITS;
|
||||||
|
@ -252,8 +252,8 @@ unsigned int NES_FDS::Render (int b[2])
|
||||||
|
|
||||||
// output mix
|
// output mix
|
||||||
int m = mask ? 0 : v;
|
int m = mask ? 0 : v;
|
||||||
b[0] = (m * sm[0]) >> 7;
|
b[0] = (m * sm[0]) >> 14;
|
||||||
b[1] = (m * sm[1]) >> 7;
|
b[1] = (m * sm[1]) >> 14;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
214
src/engine/platform/sound/oki/msm6295.cpp
Normal file
214
src/engine/platform/sound/oki/msm6295.cpp
Normal file
|
@ -0,0 +1,214 @@
|
||||||
|
/*
|
||||||
|
License: BSD-3-Clause
|
||||||
|
see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details
|
||||||
|
|
||||||
|
Copyright holder(s): cam900
|
||||||
|
OKI MSM6295 emulation core
|
||||||
|
|
||||||
|
It is 4 channel ADPCM playback chip from OKI semiconductor.
|
||||||
|
It was becomes de facto standard for ADPCM playback in arcade machine, due to cost performance.
|
||||||
|
|
||||||
|
The chip itself is pretty barebone: there is no "register" in chip.
|
||||||
|
It can't control volume and pitch in currently playing channels, only stopable them.
|
||||||
|
And volume is must be determined at playback start command.
|
||||||
|
|
||||||
|
Command format:
|
||||||
|
|
||||||
|
Playback command (2 byte):
|
||||||
|
|
||||||
|
Byte Bit Description
|
||||||
|
76543210
|
||||||
|
0 1xxxxxxx Phrase select (Header stored in ROM)
|
||||||
|
1 x000---- Play channel 4
|
||||||
|
0x00---- Play channel 3
|
||||||
|
00x0---- Play channel 2
|
||||||
|
000x---- Play channel 1
|
||||||
|
----xxxx Volume
|
||||||
|
----0000 0.0dB
|
||||||
|
----0001 -3.2dB
|
||||||
|
----0010 -6.0dB
|
||||||
|
----0011 -9.2dB
|
||||||
|
----0100 -12.0dB
|
||||||
|
----0101 -14.5dB
|
||||||
|
----0110 -18.0dB
|
||||||
|
----0111 -20.5dB
|
||||||
|
----1000 -24.0dB
|
||||||
|
|
||||||
|
Suspend command (1 byte):
|
||||||
|
|
||||||
|
Byte Bit Description
|
||||||
|
76543210
|
||||||
|
0 0x------ Suspend channel 4
|
||||||
|
0-x----- Suspend channel 3
|
||||||
|
0--x---- Suspend channel 2
|
||||||
|
0---x--- Suspend channel 1
|
||||||
|
|
||||||
|
Frequency calculation:
|
||||||
|
if (SS) then
|
||||||
|
Frequency = Input clock / 165
|
||||||
|
else then
|
||||||
|
Frequency = Input clock / 132
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "msm6295.hpp"
|
||||||
|
|
||||||
|
#define CORE_DIVIDER 3
|
||||||
|
|
||||||
|
#define CHANNEL_DELAY (15/CORE_DIVIDER)
|
||||||
|
#define MASTER_DELAY (33/CORE_DIVIDER)
|
||||||
|
|
||||||
|
void msm6295_core::tick()
|
||||||
|
{
|
||||||
|
// command handler
|
||||||
|
if (m_command_pending)
|
||||||
|
{
|
||||||
|
if (bitfield(m_command, 7)) // play voice
|
||||||
|
{
|
||||||
|
if ((++m_clock) >= ((CHANNEL_DELAY * (m_ss ? 5 : 4))))
|
||||||
|
{
|
||||||
|
m_clock = 0;
|
||||||
|
if (bitfield(m_next_command, 4, 4) != 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (bitfield(m_next_command, 4 + i))
|
||||||
|
{
|
||||||
|
if (!m_voice[i].m_busy)
|
||||||
|
{
|
||||||
|
m_voice[i].m_command = m_command;
|
||||||
|
m_voice[i].m_volume = (bitfield(m_next_command, 0, 4) < 9) ? m_volume_table[std::min<u8>(8, bitfield(m_next_command, 0, 4))] : 0;
|
||||||
|
}
|
||||||
|
break; // voices aren't be playable simultaneously at once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_command = 0;
|
||||||
|
m_command_pending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bitfield(m_next_command, 7)) // select phrase
|
||||||
|
{
|
||||||
|
if ((++m_clock) >= ((CHANNEL_DELAY * (m_ss ? 5 : 4))))
|
||||||
|
{
|
||||||
|
m_clock = 0;
|
||||||
|
m_command = m_next_command;
|
||||||
|
m_command_pending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bitfield(m_next_command, 3, 4) != 0) // suspend voices
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (bitfield(m_next_command, 3 + i))
|
||||||
|
{
|
||||||
|
if (m_voice[i].m_busy)
|
||||||
|
m_voice[i].m_command = m_next_command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_next_command &= ~0x78;
|
||||||
|
}
|
||||||
|
m_command_pending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_out = 0;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
m_voice[i].tick();
|
||||||
|
if (!m_voice[i].m_muted) m_out += m_voice[i].m_out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void msm6295_core::reset()
|
||||||
|
{
|
||||||
|
for (auto & elem : m_voice)
|
||||||
|
elem.reset();
|
||||||
|
|
||||||
|
m_command = 0;
|
||||||
|
m_next_command = 0;
|
||||||
|
m_command_pending = false;
|
||||||
|
m_clock = 0;
|
||||||
|
m_out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void msm6295_core::voice_t::tick()
|
||||||
|
{
|
||||||
|
if (!m_busy)
|
||||||
|
{
|
||||||
|
if (bitfield(m_command, 7))
|
||||||
|
{
|
||||||
|
// get phrase header (stored in data memory)
|
||||||
|
const u32 phrase = bitfield(m_command, 0, 7) << 3;
|
||||||
|
// Start address
|
||||||
|
m_addr = (bitfield(m_host.m_intf.read_byte(phrase | 0), 0, 2) << 16)
|
||||||
|
| (m_host.m_intf.read_byte(phrase | 1) << 8)
|
||||||
|
| (m_host.m_intf.read_byte(phrase | 2) << 0);
|
||||||
|
// End address
|
||||||
|
m_end = (bitfield(m_host.m_intf.read_byte(phrase | 3), 0, 2) << 16)
|
||||||
|
| (m_host.m_intf.read_byte(phrase | 4) << 8)
|
||||||
|
| (m_host.m_intf.read_byte(phrase | 5) << 0);
|
||||||
|
m_nibble = 4; // MSB first, LSB second
|
||||||
|
m_command = 0;
|
||||||
|
m_busy = true;
|
||||||
|
vox_decoder_t::reset();
|
||||||
|
}
|
||||||
|
m_out = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// playback
|
||||||
|
if ((++m_clock) >= ((MASTER_DELAY * (m_host.m_ss ? 5 : 4))))
|
||||||
|
{
|
||||||
|
m_clock = 0;
|
||||||
|
bool is_end = (m_command != 0);
|
||||||
|
m_curr.decode(bitfield(m_host.m_intf.read_byte(m_addr), m_nibble, 4));
|
||||||
|
if (m_nibble <= 0)
|
||||||
|
{
|
||||||
|
m_nibble = 4;
|
||||||
|
if (++m_addr > m_end)
|
||||||
|
is_end = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_nibble -= 4;
|
||||||
|
if (is_end)
|
||||||
|
{
|
||||||
|
m_command = 0;
|
||||||
|
m_busy = false;
|
||||||
|
}
|
||||||
|
m_out = (out() * m_volume) >> 7; // scale out to 12 bit output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void msm6295_core::voice_t::reset()
|
||||||
|
{
|
||||||
|
vox_decoder_t::reset();
|
||||||
|
m_clock = 0;
|
||||||
|
m_busy = false;
|
||||||
|
m_command = 0;
|
||||||
|
m_addr = 0;
|
||||||
|
m_nibble = 0;
|
||||||
|
m_end = 0;
|
||||||
|
m_volume = 0;
|
||||||
|
m_out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
u8 msm6295_core::busy_r()
|
||||||
|
{
|
||||||
|
return (m_voice[0].m_busy ? 0x01 : 0x00)
|
||||||
|
| (m_voice[1].m_busy ? 0x02 : 0x00)
|
||||||
|
| (m_voice[2].m_busy ? 0x04 : 0x00)
|
||||||
|
| (m_voice[3].m_busy ? 0x08 : 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
void msm6295_core::command_w(u8 data)
|
||||||
|
{
|
||||||
|
if (!m_command_pending)
|
||||||
|
{
|
||||||
|
m_next_command = data;
|
||||||
|
m_command_pending = true;
|
||||||
|
}
|
||||||
|
}
|
94
src/engine/platform/sound/oki/msm6295.hpp
Normal file
94
src/engine/platform/sound/oki/msm6295.hpp
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
License: BSD-3-Clause
|
||||||
|
see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details
|
||||||
|
|
||||||
|
Copyright holder(s): cam900
|
||||||
|
OKI MSM6295 emulation core
|
||||||
|
|
||||||
|
See msm6295.cpp for more info.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "util.hpp"
|
||||||
|
#include "vox.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#ifndef _VGSOUND_EMU_MSM6295_HPP
|
||||||
|
#define _VGSOUND_EMU_MSM6295_HPP
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class msm6295_core : public vox_core
|
||||||
|
{
|
||||||
|
friend class vgsound_emu_mem_intf; // common memory interface
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
msm6295_core(vgsound_emu_mem_intf &intf)
|
||||||
|
: m_voice{{*this,*this},{*this,*this},{*this,*this},{*this,*this}}
|
||||||
|
, m_intf(intf)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// accessors, getters, setters
|
||||||
|
u8 busy_r();
|
||||||
|
void command_w(u8 data);
|
||||||
|
void ss_w(bool ss) { m_ss = ss; } // SS pin
|
||||||
|
|
||||||
|
// internal state
|
||||||
|
void reset();
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
s32 out() { return m_out; } // built in 12 bit DAC
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Internal volume table, 9 step
|
||||||
|
const s32 m_volume_table[9] = {
|
||||||
|
32/* 0.0dB */,
|
||||||
|
22/* -3.2dB */,
|
||||||
|
16/* -6.0dB */,
|
||||||
|
11/* -9.2dB */,
|
||||||
|
8/* -12.0dB */,
|
||||||
|
6/* -14.5dB */,
|
||||||
|
4/* -18.0dB */,
|
||||||
|
3/* -20.5dB */,
|
||||||
|
2/* -24.0dB */ }; // scale out to 5 bit for optimization
|
||||||
|
|
||||||
|
public:
|
||||||
|
// msm6295 voice structs
|
||||||
|
struct voice_t : vox_decoder_t
|
||||||
|
{
|
||||||
|
// constructor
|
||||||
|
voice_t(vox_core &vox, msm6295_core &host)
|
||||||
|
: vox_decoder_t(vox)
|
||||||
|
, m_host(host)
|
||||||
|
{};
|
||||||
|
|
||||||
|
// internal state
|
||||||
|
virtual void reset() override;
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
// accessors, getters, setters
|
||||||
|
// registers
|
||||||
|
msm6295_core &m_host;
|
||||||
|
u16 m_clock = 0; // clock counter
|
||||||
|
bool m_busy = false; // busy status
|
||||||
|
bool m_muted = false; // muted
|
||||||
|
u8 m_command = 0; // current command
|
||||||
|
u32 m_addr = 0; // current address
|
||||||
|
s8 m_nibble = 0; // current nibble
|
||||||
|
u32 m_end = 0; // end address
|
||||||
|
s32 m_volume = 0; // volume
|
||||||
|
s32 m_out = 0; // output
|
||||||
|
};
|
||||||
|
voice_t m_voice[4];
|
||||||
|
private:
|
||||||
|
vgsound_emu_mem_intf &m_intf; // common memory interface
|
||||||
|
|
||||||
|
bool m_ss = false; // SS pin controls divider, input clock / 33 * (SS ? 5 : 4)
|
||||||
|
u8 m_command = 0; // Command byte
|
||||||
|
u8 m_next_command = 0; // Next command
|
||||||
|
bool m_command_pending = false; // command pending flag
|
||||||
|
u16 m_clock = 0; // clock counter
|
||||||
|
s32 m_out = 0; // 12 bit output
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -11,8 +11,10 @@
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "emu.h"
|
|
||||||
#include "okim6258.h"
|
#include "okim6258.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define COMMAND_STOP (1 << 0)
|
#define COMMAND_STOP (1 << 0)
|
||||||
#define COMMAND_PLAY (1 << 1)
|
#define COMMAND_PLAY (1 << 1)
|
||||||
|
@ -34,9 +36,6 @@ static int tables_computed = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// device type definition
|
|
||||||
DEFINE_DEVICE_TYPE(OKIM6258, okim6258_device, "okim6258", "OKI MSM6258 ADPCM")
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// LIVE DEVICE
|
// LIVE DEVICE
|
||||||
|
@ -46,19 +45,18 @@ DEFINE_DEVICE_TYPE(OKIM6258, okim6258_device, "okim6258", "OKI MSM6258 ADPCM")
|
||||||
// okim6258_device - constructor
|
// okim6258_device - constructor
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
okim6258_device::okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
okim6258_device::okim6258_device(uint32_t clock)
|
||||||
: device_t(mconfig, OKIM6258, tag, owner, clock),
|
:
|
||||||
device_sound_interface(mconfig, *this),
|
|
||||||
m_status(0),
|
m_status(0),
|
||||||
m_start_divider(0),
|
m_start_divider(0),
|
||||||
m_divider(512),
|
m_divider(512),
|
||||||
m_adpcm_type(0),
|
m_adpcm_type(0),
|
||||||
m_data_in(0),
|
m_data_in(0),
|
||||||
m_nibble_shift(0),
|
m_nibble_shift(0),
|
||||||
m_stream(nullptr),
|
|
||||||
m_output_bits(0),
|
m_output_bits(0),
|
||||||
m_signal(0),
|
m_signal(0),
|
||||||
m_step(0)
|
m_step(0),
|
||||||
|
m_clock(clock)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +112,9 @@ void okim6258_device::device_start()
|
||||||
|
|
||||||
m_divider = dividers[m_start_divider];
|
m_divider = dividers[m_start_divider];
|
||||||
|
|
||||||
m_stream = stream_alloc(0, 1, clock()/m_divider);
|
|
||||||
|
|
||||||
m_signal = -2;
|
m_signal = -2;
|
||||||
m_step = 0;
|
m_step = 0;
|
||||||
|
m_has_data = false;
|
||||||
state_save_register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,11 +124,10 @@ void okim6258_device::device_start()
|
||||||
|
|
||||||
void okim6258_device::device_reset()
|
void okim6258_device::device_reset()
|
||||||
{
|
{
|
||||||
m_stream->update();
|
|
||||||
|
|
||||||
m_signal = -2;
|
m_signal = -2;
|
||||||
m_step = 0;
|
m_step = 0;
|
||||||
m_status = 0;
|
m_status = 0;
|
||||||
|
m_has_data = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +135,7 @@ void okim6258_device::device_reset()
|
||||||
// sound_stream_update - handle a stream update
|
// sound_stream_update - handle a stream update
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
void okim6258_device::sound_stream_update(short** outputs, int len)
|
||||||
{
|
{
|
||||||
auto &buffer = outputs[0];
|
auto &buffer = outputs[0];
|
||||||
|
|
||||||
|
@ -149,7 +143,7 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read
|
||||||
{
|
{
|
||||||
int nibble_shift = m_nibble_shift;
|
int nibble_shift = m_nibble_shift;
|
||||||
|
|
||||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
for (int sampindex = 0; sampindex < len; sampindex++)
|
||||||
{
|
{
|
||||||
/* Compute the new amplitude and update the current step */
|
/* Compute the new amplitude and update the current step */
|
||||||
int nibble = (m_data_in >> nibble_shift) & 0xf;
|
int nibble = (m_data_in >> nibble_shift) & 0xf;
|
||||||
|
@ -159,7 +153,9 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read
|
||||||
|
|
||||||
nibble_shift ^= 4;
|
nibble_shift ^= 4;
|
||||||
|
|
||||||
buffer.put_int(sampindex, sample, 32768);
|
if (nibble_shift==0) m_has_data=false;
|
||||||
|
|
||||||
|
buffer[sampindex]=sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the parameters */
|
/* Update the parameters */
|
||||||
|
@ -167,29 +163,12 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer.fill(0);
|
memset(buffer,0,len*sizeof(short));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************************************
|
|
||||||
|
|
||||||
state save support for MAME
|
|
||||||
|
|
||||||
***********************************************************************************************/
|
|
||||||
|
|
||||||
void okim6258_device::state_save_register()
|
|
||||||
{
|
|
||||||
save_item(NAME(m_status));
|
|
||||||
save_item(NAME(m_divider));
|
|
||||||
save_item(NAME(m_data_in));
|
|
||||||
save_item(NAME(m_nibble_shift));
|
|
||||||
save_item(NAME(m_signal));
|
|
||||||
save_item(NAME(m_step));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16_t okim6258_device::clock_adpcm(uint8_t nibble)
|
int16_t okim6258_device::clock_adpcm(uint8_t nibble)
|
||||||
{
|
{
|
||||||
int32_t max = (1 << (m_output_bits - 1)) - 1;
|
int32_t max = (1 << (m_output_bits - 1)) - 1;
|
||||||
|
@ -224,7 +203,6 @@ int16_t okim6258_device::clock_adpcm(uint8_t nibble)
|
||||||
void okim6258_device::set_divider(int val)
|
void okim6258_device::set_divider(int val)
|
||||||
{
|
{
|
||||||
m_divider = dividers[val];
|
m_divider = dividers[val];
|
||||||
notify_clock_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,7 +214,6 @@ void okim6258_device::set_divider(int val)
|
||||||
|
|
||||||
void okim6258_device::device_clock_changed()
|
void okim6258_device::device_clock_changed()
|
||||||
{
|
{
|
||||||
m_stream->set_sample_rate(clock() / m_divider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,7 +225,7 @@ void okim6258_device::device_clock_changed()
|
||||||
|
|
||||||
int okim6258_device::get_vclk()
|
int okim6258_device::get_vclk()
|
||||||
{
|
{
|
||||||
return (clock() / m_divider);
|
return (m_clock / m_divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,8 +237,6 @@ int okim6258_device::get_vclk()
|
||||||
|
|
||||||
uint8_t okim6258_device::status_r()
|
uint8_t okim6258_device::status_r()
|
||||||
{
|
{
|
||||||
m_stream->update();
|
|
||||||
|
|
||||||
return (m_status & STATUS_PLAYING) ? 0x00 : 0x80;
|
return (m_status & STATUS_PLAYING) ? 0x00 : 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,13 +246,13 @@ uint8_t okim6258_device::status_r()
|
||||||
okim6258_data_w -- write to the control port of an OKIM6258-compatible chip
|
okim6258_data_w -- write to the control port of an OKIM6258-compatible chip
|
||||||
|
|
||||||
***********************************************************************************************/
|
***********************************************************************************************/
|
||||||
void okim6258_device::data_w(uint8_t data)
|
bool okim6258_device::data_w(uint8_t data)
|
||||||
{
|
{
|
||||||
/* update the stream */
|
if (m_has_data) return false;
|
||||||
m_stream->update();
|
|
||||||
|
|
||||||
m_data_in = data;
|
m_data_in = data;
|
||||||
m_nibble_shift = 0;
|
m_nibble_shift = 0;
|
||||||
|
m_has_data = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,11 +264,10 @@ void okim6258_device::data_w(uint8_t data)
|
||||||
|
|
||||||
void okim6258_device::ctrl_w(uint8_t data)
|
void okim6258_device::ctrl_w(uint8_t data)
|
||||||
{
|
{
|
||||||
m_stream->update();
|
|
||||||
|
|
||||||
if (data & COMMAND_STOP)
|
if (data & COMMAND_STOP)
|
||||||
{
|
{
|
||||||
m_status &= ~(STATUS_PLAYING | STATUS_RECORDING);
|
m_status &= ~(STATUS_PLAYING | STATUS_RECORDING);
|
||||||
|
m_has_data = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +290,7 @@ void okim6258_device::ctrl_w(uint8_t data)
|
||||||
|
|
||||||
if (data & COMMAND_RECORD)
|
if (data & COMMAND_RECORD)
|
||||||
{
|
{
|
||||||
logerror("M6258: Record enabled\n");
|
//logerror("M6258: Record enabled\n");
|
||||||
m_status |= STATUS_RECORDING;
|
m_status |= STATUS_RECORDING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
#ifndef MAME_SOUND_OKIM6258_H
|
#ifndef MAME_SOUND_OKIM6258_H
|
||||||
#define MAME_SOUND_OKIM6258_H
|
#define MAME_SOUND_OKIM6258_H
|
||||||
|
|
||||||
#pragma once
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// TYPE DEFINITIONS
|
// TYPE DEFINITIONS
|
||||||
|
@ -12,9 +11,7 @@
|
||||||
|
|
||||||
// ======================> okim6258_device
|
// ======================> okim6258_device
|
||||||
|
|
||||||
class okim6258_device : public device_t,
|
class okim6258_device {
|
||||||
public device_sound_interface
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static constexpr int FOSC_DIV_BY_1024 = 0;
|
static constexpr int FOSC_DIV_BY_1024 = 0;
|
||||||
static constexpr int FOSC_DIV_BY_768 = 1;
|
static constexpr int FOSC_DIV_BY_768 = 1;
|
||||||
|
@ -26,7 +23,7 @@ public:
|
||||||
static constexpr int OUTPUT_10BITS = 10;
|
static constexpr int OUTPUT_10BITS = 10;
|
||||||
static constexpr int OUTPUT_12BITS = 12;
|
static constexpr int OUTPUT_12BITS = 12;
|
||||||
|
|
||||||
okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
okim6258_device(uint32_t clock);
|
||||||
|
|
||||||
// configuration
|
// configuration
|
||||||
void set_start_div(int div) { m_start_divider = div; }
|
void set_start_div(int div) { m_start_divider = div; }
|
||||||
|
@ -34,23 +31,21 @@ public:
|
||||||
void set_outbits(int outbit) { m_output_bits = outbit; }
|
void set_outbits(int outbit) { m_output_bits = outbit; }
|
||||||
|
|
||||||
uint8_t status_r();
|
uint8_t status_r();
|
||||||
void data_w(uint8_t data);
|
bool data_w(uint8_t data);
|
||||||
void ctrl_w(uint8_t data);
|
void ctrl_w(uint8_t data);
|
||||||
|
|
||||||
void set_divider(int val);
|
void set_divider(int val);
|
||||||
int get_vclk();
|
int get_vclk();
|
||||||
|
|
||||||
protected:
|
// device-levels
|
||||||
// device-level overrides
|
void device_start();
|
||||||
virtual void device_start() override;
|
void device_reset();
|
||||||
virtual void device_reset() override;
|
void device_clock_changed();
|
||||||
virtual void device_clock_changed() override;
|
|
||||||
|
|
||||||
// sound stream update overrides
|
// sound stream updates
|
||||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
void sound_stream_update(short** outputs, int len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void state_save_register();
|
|
||||||
int16_t clock_adpcm(uint8_t nibble);
|
int16_t clock_adpcm(uint8_t nibble);
|
||||||
|
|
||||||
uint8_t m_status;
|
uint8_t m_status;
|
||||||
|
@ -59,16 +54,15 @@ private:
|
||||||
uint32_t m_divider; /* master clock divider */
|
uint32_t m_divider; /* master clock divider */
|
||||||
uint8_t m_adpcm_type; /* 3/4 bit ADPCM select */
|
uint8_t m_adpcm_type; /* 3/4 bit ADPCM select */
|
||||||
uint8_t m_data_in; /* ADPCM data-in register */
|
uint8_t m_data_in; /* ADPCM data-in register */
|
||||||
|
bool m_has_data; /* whether we already have data */
|
||||||
uint8_t m_nibble_shift; /* nibble select */
|
uint8_t m_nibble_shift; /* nibble select */
|
||||||
sound_stream *m_stream; /* which stream are we playing on? */
|
|
||||||
|
|
||||||
uint8_t m_output_bits; /* D/A precision is 10-bits but 12-bit data can be
|
uint8_t m_output_bits; /* D/A precision is 10-bits but 12-bit data can be
|
||||||
output serially to an external DAC */
|
output serially to an external DAC */
|
||||||
|
|
||||||
int32_t m_signal;
|
int32_t m_signal;
|
||||||
int32_t m_step;
|
int32_t m_step;
|
||||||
|
unsigned int m_clock;
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(OKIM6258, okim6258_device)
|
|
||||||
|
|
||||||
#endif // MAME_SOUND_OKIM6258_H
|
#endif // MAME_SOUND_OKIM6258_H
|
||||||
|
|
158
src/engine/platform/sound/oki/util.hpp
Normal file
158
src/engine/platform/sound/oki/util.hpp
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
/*
|
||||||
|
License: BSD-3-Clause
|
||||||
|
see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details
|
||||||
|
|
||||||
|
Copyright holders: cam900
|
||||||
|
Various core utilities for vgsound_emu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifndef _VGSOUND_EMU_CORE_UTIL_HPP
|
||||||
|
#define _VGSOUND_EMU_CORE_UTIL_HPP
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
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;
|
||||||
|
typedef float f32;
|
||||||
|
typedef double f64;
|
||||||
|
|
||||||
|
const f64 PI = 3.1415926535897932384626433832795;
|
||||||
|
|
||||||
|
// get bitfield, bitfield(input, position, len)
|
||||||
|
template<typename T> T bitfield(T in, u8 pos, u8 len = 1)
|
||||||
|
{
|
||||||
|
return (in >> pos) & (len ? (T(1 << len) - 1) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get sign extended value, sign_ext<type>(input, len)
|
||||||
|
template<typename T> T sign_ext(T in, u8 len)
|
||||||
|
{
|
||||||
|
len = std::max<u8>(0, (8 * sizeof(T)) - len);
|
||||||
|
return T(T(in) << len) >> len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert attenuation decibel value to gain
|
||||||
|
inline f32 dB_to_gain(f32 attenuation)
|
||||||
|
{
|
||||||
|
return powf(10.0f, attenuation / 20.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
class vgsound_emu_mem_intf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual u8 read_byte(u32 address) { return 0; }
|
||||||
|
virtual u16 read_word(u32 address) { return 0; }
|
||||||
|
virtual u32 read_dword(u32 address) { return 0; }
|
||||||
|
virtual u64 read_qword(u32 address) { return 0; }
|
||||||
|
virtual void write_byte(u32 address, u8 data) { }
|
||||||
|
virtual void write_word(u32 address, u16 data) { }
|
||||||
|
virtual void write_dword(u32 address, u32 data) { }
|
||||||
|
virtual void write_qword(u32 address, u64 data) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, T InitWidth, u8 InitEdge = 0>
|
||||||
|
struct clock_pulse_t
|
||||||
|
{
|
||||||
|
void reset(T init = InitWidth)
|
||||||
|
{
|
||||||
|
m_edge.reset();
|
||||||
|
m_width = m_width_latch = m_counter = init;
|
||||||
|
m_cycle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tick(T width = 0)
|
||||||
|
{
|
||||||
|
bool carry = ((--m_counter) <= 0);
|
||||||
|
if (carry)
|
||||||
|
{
|
||||||
|
if (!width)
|
||||||
|
m_width = m_width_latch;
|
||||||
|
else
|
||||||
|
m_width = width; // reset width
|
||||||
|
m_counter = m_width;
|
||||||
|
m_cycle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_cycle++;
|
||||||
|
|
||||||
|
m_edge.tick(carry);
|
||||||
|
return carry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_width(T width) { m_width = width; }
|
||||||
|
void set_width_latch(T width) { m_width_latch = width; }
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
bool current_edge() { return m_edge.m_current; }
|
||||||
|
bool rising_edge() { return m_edge.m_rising; }
|
||||||
|
bool falling_edge() { return m_edge.m_rising; }
|
||||||
|
T cycle() { return m_cycle; }
|
||||||
|
|
||||||
|
struct edge_t
|
||||||
|
{
|
||||||
|
edge_t()
|
||||||
|
: m_current(InitEdge ^ 1)
|
||||||
|
, m_previous(InitEdge)
|
||||||
|
, m_rising(0)
|
||||||
|
, m_falling(0)
|
||||||
|
, m_changed(0)
|
||||||
|
{
|
||||||
|
set(InitEdge);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tick(bool toggle)
|
||||||
|
{
|
||||||
|
u8 current = m_current;
|
||||||
|
if (toggle)
|
||||||
|
current ^= 1;
|
||||||
|
set(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(u8 edge)
|
||||||
|
{
|
||||||
|
edge &= 1;
|
||||||
|
m_rising = m_falling = m_changed = 0;
|
||||||
|
if (m_current != edge)
|
||||||
|
{
|
||||||
|
m_changed = 1;
|
||||||
|
if (m_current && (!edge))
|
||||||
|
m_falling = 1;
|
||||||
|
else if ((!m_current) && edge)
|
||||||
|
m_rising = 1;
|
||||||
|
m_current = edge;
|
||||||
|
}
|
||||||
|
m_previous = m_current;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
m_previous = InitEdge;
|
||||||
|
m_current = InitEdge ^ 1;
|
||||||
|
set(InitEdge);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 m_current : 1; // current edge
|
||||||
|
u8 m_previous : 1; // previous edge
|
||||||
|
u8 m_rising : 1; // rising edge
|
||||||
|
u8 m_falling : 1; // falling edge
|
||||||
|
u8 m_changed : 1; // changed flag
|
||||||
|
};
|
||||||
|
|
||||||
|
edge_t m_edge;
|
||||||
|
T m_width = InitWidth; // clock pulse width
|
||||||
|
T m_width_latch = InitWidth; // clock pulse width latch
|
||||||
|
T m_counter = InitWidth; // clock counter
|
||||||
|
T m_cycle = 0; // clock cycle
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
115
src/engine/platform/sound/oki/vox.hpp
Normal file
115
src/engine/platform/sound/oki/vox.hpp
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
License: BSD-3-Clause
|
||||||
|
see https://github.com/cam900/vgsound_emu/blob/main/LICENSE for more details
|
||||||
|
|
||||||
|
Copyright holder(s): cam900
|
||||||
|
Dialogic ADPCM core
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "util.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#ifndef _VGSOUND_EMU_CORE_VOX_HPP
|
||||||
|
#define _VGSOUND_EMU_CORE_VOX_HPP
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define MODIFIED_CLAMP(x,xMin,xMax) (std::min(std::max((x),(xMin)),(xMax)))
|
||||||
|
|
||||||
|
class vox_core
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
struct vox_decoder_t
|
||||||
|
{
|
||||||
|
vox_decoder_t(vox_core &vox)
|
||||||
|
: m_curr(vox)
|
||||||
|
, m_loop(vox)
|
||||||
|
{ };
|
||||||
|
|
||||||
|
virtual void reset()
|
||||||
|
{
|
||||||
|
m_curr.reset();
|
||||||
|
m_loop.reset();
|
||||||
|
m_loop_saved = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void save()
|
||||||
|
{
|
||||||
|
if (!m_loop_saved)
|
||||||
|
{
|
||||||
|
m_loop.copy(m_curr);
|
||||||
|
m_loop_saved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore()
|
||||||
|
{
|
||||||
|
if (m_loop_saved)
|
||||||
|
m_curr.copy(m_loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 out() { return m_curr.m_step; }
|
||||||
|
|
||||||
|
struct decoder_state_t
|
||||||
|
{
|
||||||
|
decoder_state_t(vox_core &vox)
|
||||||
|
: m_vox(vox)
|
||||||
|
{ };
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
m_index = 0;
|
||||||
|
m_step = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void copy(decoder_state_t src)
|
||||||
|
{
|
||||||
|
m_index = src.m_index;
|
||||||
|
m_step = src.m_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
void decode(u8 nibble)
|
||||||
|
{
|
||||||
|
const u8 delta = bitfield(nibble, 0, 3);
|
||||||
|
s16 ss = m_vox.m_step_table[m_index]; // ss(n)
|
||||||
|
|
||||||
|
// d(n) = (ss(n) * B2) + ((ss(n) / 2) * B1) + ((ss(n) / 4) * B0) + (ss(n) / 8)
|
||||||
|
s16 d = ss >> 3;
|
||||||
|
if (bitfield(delta, 2))
|
||||||
|
d += ss;
|
||||||
|
if (bitfield(delta, 1))
|
||||||
|
d += (ss >> 1);
|
||||||
|
if (bitfield(delta, 0))
|
||||||
|
d += (ss >> 2);
|
||||||
|
|
||||||
|
// if (B3 = 1) then d(n) = d(n) * (-1) X(n) = X(n-1) * d(n)
|
||||||
|
if (bitfield(nibble, 3))
|
||||||
|
m_step = std::max(m_step - d, -2048);
|
||||||
|
else
|
||||||
|
m_step = std::min(m_step + d, 2047);
|
||||||
|
|
||||||
|
// adjust step index
|
||||||
|
m_index = MODIFIED_CLAMP(m_index + m_vox.m_index_table[delta], 0, 48);
|
||||||
|
}
|
||||||
|
|
||||||
|
vox_core &m_vox;
|
||||||
|
s8 m_index = 0;
|
||||||
|
s32 m_step = 16;
|
||||||
|
};
|
||||||
|
|
||||||
|
decoder_state_t m_curr;
|
||||||
|
decoder_state_t m_loop;
|
||||||
|
bool m_loop_saved = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
s8 m_index_table[8] = {-1, -1, -1, -1, 2, 4, 6, 8};
|
||||||
|
s32 m_step_table[49] = {
|
||||||
|
16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
|
||||||
|
50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143,
|
||||||
|
157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449,
|
||||||
|
494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -322,6 +322,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scc.hpp"
|
#include "scc.hpp"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
// shared SCC features
|
// shared SCC features
|
||||||
void scc_core::tick()
|
void scc_core::tick()
|
||||||
|
@ -372,12 +373,12 @@ void scc_core::reset()
|
||||||
|
|
||||||
m_test.reset();
|
m_test.reset();
|
||||||
m_out = 0;
|
m_out = 0;
|
||||||
std::fill(std::begin(m_reg), std::end(m_reg), 0);
|
memset(m_reg,0,sizeof(m_reg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void scc_core::voice_t::reset()
|
void scc_core::voice_t::reset()
|
||||||
{
|
{
|
||||||
std::fill(std::begin(wave), std::end(wave), 0);
|
memset(wave,0,sizeof(wave));
|
||||||
enable = false;
|
enable = false;
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
volume = 0;
|
volume = 0;
|
||||||
|
@ -454,6 +455,7 @@ void scc_core::freq_vol_enable_w(u8 address, u8 data)
|
||||||
if (m_test.resetpos) // Reset address
|
if (m_test.resetpos) // Reset address
|
||||||
m_voice[voice_freq].addr = 0;
|
m_voice[voice_freq].addr = 0;
|
||||||
m_voice[voice_freq].pitch = (m_voice[voice_freq].pitch & ~0x0ff) | data;
|
m_voice[voice_freq].pitch = (m_voice[voice_freq].pitch & ~0x0ff) | data;
|
||||||
|
m_voice[voice_freq].counter = m_voice[voice_freq].pitch;
|
||||||
break;
|
break;
|
||||||
case 0x1: // 0x*1 Voice 0 Pitch MSB
|
case 0x1: // 0x*1 Voice 0 Pitch MSB
|
||||||
case 0x3: // 0x*3 Voice 1 Pitch MSB
|
case 0x3: // 0x*3 Voice 1 Pitch MSB
|
||||||
|
@ -463,6 +465,7 @@ void scc_core::freq_vol_enable_w(u8 address, u8 data)
|
||||||
if (m_test.resetpos) // Reset address
|
if (m_test.resetpos) // Reset address
|
||||||
m_voice[voice_freq].addr = 0;
|
m_voice[voice_freq].addr = 0;
|
||||||
m_voice[voice_freq].pitch = (m_voice[voice_freq].pitch & ~0xf00) | (u16(bitfield(data, 0, 4)) << 8);
|
m_voice[voice_freq].pitch = (m_voice[voice_freq].pitch & ~0xf00) | (u16(bitfield(data, 0, 4)) << 8);
|
||||||
|
m_voice[voice_freq].counter = m_voice[voice_freq].pitch;
|
||||||
break;
|
break;
|
||||||
case 0xa: // 0x*a Voice 0 Volume
|
case 0xa: // 0x*a Voice 0 Volume
|
||||||
case 0xb: // 0x*b Voice 1 Volume
|
case 0xb: // 0x*b Voice 1 Volume
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vrcvi.hpp"
|
#include "vrcvi.hpp"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
void vrcvi_core::tick()
|
void vrcvi_core::tick()
|
||||||
{
|
{
|
||||||
|
@ -119,7 +120,7 @@ void vrcvi_core::reset()
|
||||||
m_timer.reset();
|
m_timer.reset();
|
||||||
m_control.reset();
|
m_control.reset();
|
||||||
m_out = 0;
|
m_out = 0;
|
||||||
std::fill(std::begin(m_ch_out),std::end(m_ch_out),0);
|
memset(m_ch_out,0,sizeof(m_ch_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vrcvi_core::alu_t::tick()
|
bool vrcvi_core::alu_t::tick()
|
||||||
|
|
|
@ -168,7 +168,7 @@ void DivPlatformSoundUnit::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ void DivPlatformSwan::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ void DivPlatformTIA::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ void DivPlatformTX81Z::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ void DivPlatformTX81Z::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ void DivPlatformVERA::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ void DivPlatformVIC20::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ void DivPlatformVRC6::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,7 +390,7 @@ void DivPlatformX1_010::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ void DivPlatformYM2203::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ void DivPlatformYM2203::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,48 +659,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(chan[c.chan]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (chan[c.chan].portaPause) {
|
|
||||||
chan[c.chan].baseFreq=chan[c.chan].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>chan[c.chan].baseFreq) {
|
|
||||||
newFreq=chan[c.chan].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=chan[c.chan].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check for octave boundary
|
|
||||||
// what the heck!
|
|
||||||
if (!chan[c.chan].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
chan[c.chan].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
chan[c.chan].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chan[c.chan].portaPause=false;
|
|
||||||
chan[c.chan].freqChanged=true;
|
|
||||||
chan[c.chan].baseFreq=newFreq;
|
|
||||||
if (return2) {
|
|
||||||
chan[c.chan].inPorta=false;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_LEGATO: {
|
case DIV_CMD_LEGATO: {
|
||||||
|
|
|
@ -143,52 +143,7 @@ int DivPlatformYM2203Ext::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(opChan[ch]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (opChan[ch].portaPause) {
|
|
||||||
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>opChan[ch].baseFreq) {
|
|
||||||
newFreq=opChan[ch].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=opChan[ch].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// what the heck!
|
|
||||||
if (!opChan[ch].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq>>1)|((newFreq+0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq<<1)|((newFreq-0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opChan[ch].portaPause=false;
|
|
||||||
opChan[ch].freqChanged=true;
|
|
||||||
opChan[ch].baseFreq=newFreq;
|
|
||||||
if (return2) return 2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_LEGATO: {
|
case DIV_CMD_LEGATO: {
|
||||||
|
|
|
@ -27,10 +27,12 @@ class DivPlatformYM2203Ext: public DivPlatformYM2203 {
|
||||||
unsigned char freqH, freqL;
|
unsigned char freqH, freqL;
|
||||||
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
|
// UGLY
|
||||||
|
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false),
|
||||||
|
inPorta(false), vol(0), pan(3) {}
|
||||||
};
|
};
|
||||||
OpChannel opChan[4];
|
OpChannel opChan[4];
|
||||||
bool isOpMuted[4];
|
bool isOpMuted[4];
|
||||||
|
|
|
@ -536,7 +536,7 @@ void DivPlatformYM2608::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ void DivPlatformYM2608::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -980,48 +980,7 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(chan[c.chan]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (chan[c.chan].portaPause) {
|
|
||||||
chan[c.chan].baseFreq=chan[c.chan].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>chan[c.chan].baseFreq) {
|
|
||||||
newFreq=chan[c.chan].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=chan[c.chan].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check for octave boundary
|
|
||||||
// what the heck!
|
|
||||||
if (!chan[c.chan].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
chan[c.chan].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
chan[c.chan].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chan[c.chan].portaPause=false;
|
|
||||||
chan[c.chan].freqChanged=true;
|
|
||||||
chan[c.chan].baseFreq=newFreq;
|
|
||||||
if (return2) {
|
|
||||||
chan[c.chan].inPorta=false;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_SAMPLE_BANK:
|
case DIV_CMD_SAMPLE_BANK:
|
||||||
|
|
|
@ -143,52 +143,7 @@ int DivPlatformYM2608Ext::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(opChan[ch]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (opChan[ch].portaPause) {
|
|
||||||
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>opChan[ch].baseFreq) {
|
|
||||||
newFreq=opChan[ch].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=opChan[ch].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// what the heck!
|
|
||||||
if (!opChan[ch].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq>>1)|((newFreq+0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq<<1)|((newFreq-0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opChan[ch].portaPause=false;
|
|
||||||
opChan[ch].freqChanged=true;
|
|
||||||
opChan[ch].baseFreq=newFreq;
|
|
||||||
if (return2) return 2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_LEGATO: {
|
case DIV_CMD_LEGATO: {
|
||||||
|
|
|
@ -27,10 +27,12 @@ class DivPlatformYM2608Ext: public DivPlatformYM2608 {
|
||||||
unsigned char freqH, freqL;
|
unsigned char freqH, freqL;
|
||||||
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
|
// UGLY
|
||||||
|
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false),
|
||||||
|
inPorta(false), vol(0), pan(3) {}
|
||||||
};
|
};
|
||||||
OpChannel opChan[4];
|
OpChannel opChan[4];
|
||||||
bool isOpMuted[4];
|
bool isOpMuted[4];
|
||||||
|
|
|
@ -580,7 +580,7 @@ void DivPlatformYM2610::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ void DivPlatformYM2610::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1027,48 +1027,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(chan[c.chan]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (chan[c.chan].portaPause) {
|
|
||||||
chan[c.chan].baseFreq=chan[c.chan].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>chan[c.chan].baseFreq) {
|
|
||||||
newFreq=chan[c.chan].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=chan[c.chan].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check for octave boundary
|
|
||||||
// what the heck!
|
|
||||||
if (!chan[c.chan].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
chan[c.chan].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
chan[c.chan].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chan[c.chan].portaPause=false;
|
|
||||||
chan[c.chan].freqChanged=true;
|
|
||||||
chan[c.chan].baseFreq=newFreq;
|
|
||||||
if (return2) {
|
|
||||||
chan[c.chan].inPorta=false;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_SAMPLE_BANK:
|
case DIV_CMD_SAMPLE_BANK:
|
||||||
|
|
|
@ -559,7 +559,7 @@ void DivPlatformYM2610B::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ void DivPlatformYM2610B::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
if (chan[i].std.phaseReset.val==1) {
|
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
|
||||||
chan[i].keyOn=true;
|
chan[i].keyOn=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1005,48 +1005,7 @@ int DivPlatformYM2610B::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(chan[c.chan]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (chan[c.chan].portaPause) {
|
|
||||||
chan[c.chan].baseFreq=chan[c.chan].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>chan[c.chan].baseFreq) {
|
|
||||||
newFreq=chan[c.chan].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=chan[c.chan].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check for octave boundary
|
|
||||||
// what the heck!
|
|
||||||
if (!chan[c.chan].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
chan[c.chan].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
chan[c.chan].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
chan[c.chan].portaPause=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chan[c.chan].portaPause=false;
|
|
||||||
chan[c.chan].freqChanged=true;
|
|
||||||
chan[c.chan].baseFreq=newFreq;
|
|
||||||
if (return2) {
|
|
||||||
chan[c.chan].inPorta=false;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_SAMPLE_BANK:
|
case DIV_CMD_SAMPLE_BANK:
|
||||||
|
|
|
@ -143,52 +143,7 @@ int DivPlatformYM2610BExt::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(opChan[ch]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (opChan[ch].portaPause) {
|
|
||||||
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>opChan[ch].baseFreq) {
|
|
||||||
newFreq=opChan[ch].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=opChan[ch].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// what the heck!
|
|
||||||
if (!opChan[ch].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq>>1)|((newFreq+0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq<<1)|((newFreq-0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opChan[ch].portaPause=false;
|
|
||||||
opChan[ch].freqChanged=true;
|
|
||||||
opChan[ch].baseFreq=newFreq;
|
|
||||||
if (return2) return 2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_LEGATO: {
|
case DIV_CMD_LEGATO: {
|
||||||
|
|
|
@ -27,10 +27,12 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B {
|
||||||
unsigned char freqH, freqL;
|
unsigned char freqH, freqL;
|
||||||
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
|
// UGLY
|
||||||
|
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false),
|
||||||
|
inPorta(false), vol(0), pan(3) {}
|
||||||
};
|
};
|
||||||
OpChannel opChan[4];
|
OpChannel opChan[4];
|
||||||
bool isOpMuted[4];
|
bool isOpMuted[4];
|
||||||
|
|
|
@ -143,52 +143,7 @@ int DivPlatformYM2610Ext::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false);
|
PLEASE_HELP_ME(opChan[ch]);
|
||||||
int boundaryTop=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,12,false);
|
|
||||||
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
|
||||||
int newFreq;
|
|
||||||
bool return2=false;
|
|
||||||
if (opChan[ch].portaPause) {
|
|
||||||
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
|
|
||||||
}
|
|
||||||
if (destFreq>opChan[ch].baseFreq) {
|
|
||||||
newFreq=opChan[ch].baseFreq+c.value;
|
|
||||||
if (newFreq>=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFreq=opChan[ch].baseFreq-c.value;
|
|
||||||
if (newFreq<=destFreq) {
|
|
||||||
newFreq=destFreq;
|
|
||||||
return2=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// what the heck!
|
|
||||||
if (!opChan[ch].portaPause) {
|
|
||||||
if ((newFreq&0x7ff)>boundaryTop && (newFreq&0xf800)<0x3800) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=(boundaryBottom)|((newFreq+0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq>>1)|((newFreq+0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((newFreq&0x7ff)<boundaryBottom && (newFreq&0xf800)>0) {
|
|
||||||
if (parent->song.fbPortaPause) {
|
|
||||||
opChan[ch].portaPauseFreq=newFreq=(boundaryTop-1)|((newFreq-0x800)&0xf800);
|
|
||||||
opChan[ch].portaPause=true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
newFreq=(newFreq<<1)|((newFreq-0x800)&0xf800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opChan[ch].portaPause=false;
|
|
||||||
opChan[ch].freqChanged=true;
|
|
||||||
opChan[ch].baseFreq=newFreq;
|
|
||||||
if (return2) return 2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_CMD_LEGATO: {
|
case DIV_CMD_LEGATO: {
|
||||||
|
|
|
@ -27,10 +27,12 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 {
|
||||||
unsigned char freqH, freqL;
|
unsigned char freqH, freqL;
|
||||||
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
|
// UGLY
|
||||||
|
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), portaPauseFreq(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false),
|
||||||
|
inPorta(false), vol(0), pan(3) {}
|
||||||
};
|
};
|
||||||
OpChannel opChan[4];
|
OpChannel opChan[4];
|
||||||
bool isOpMuted[4];
|
bool isOpMuted[4];
|
||||||
|
|
|
@ -115,7 +115,7 @@ void DivPlatformYMZ280B::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ void DivPlatformZXBeeper::tick(bool sysTick) {
|
||||||
if (chan[i].std.pitch.had) {
|
if (chan[i].std.pitch.had) {
|
||||||
if (chan[i].std.pitch.mode) {
|
if (chan[i].std.pitch.mode) {
|
||||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||||
CLAMP_VAR(chan[i].pitch2,-2048,2048);
|
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||||
} else {
|
} else {
|
||||||
chan[i].pitch2=chan[i].std.pitch.val;
|
chan[i].pitch2=chan[i].std.pitch.val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#ifdef HAVE_SNDFILE
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
|
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
|
||||||
|
|
||||||
|
@ -566,6 +568,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
||||||
if (divider<10) divider=10;
|
if (divider<10) divider=10;
|
||||||
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/divider;
|
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/divider;
|
||||||
clockDrift=0;
|
clockDrift=0;
|
||||||
|
subticks=0;
|
||||||
break;
|
break;
|
||||||
case 0xe0: // arp speed
|
case 0xe0: // arp speed
|
||||||
if (effectVal>0) {
|
if (effectVal>0) {
|
||||||
|
@ -646,6 +649,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
||||||
if (divider<10) divider=10;
|
if (divider<10) divider=10;
|
||||||
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/divider;
|
cycles=got.rate*pow(2,MASTER_CLOCK_PREC)/divider;
|
||||||
clockDrift=0;
|
clockDrift=0;
|
||||||
|
subticks=0;
|
||||||
break;
|
break;
|
||||||
case 0xf1: // single pitch ramp up
|
case 0xf1: // single pitch ramp up
|
||||||
case 0xf2: // single pitch ramp down
|
case 0xf2: // single pitch ramp down
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_SNDFILE
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
#endif
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -41,6 +43,10 @@ bool DivSample::isLoopable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivSample::save(const char* path) {
|
bool DivSample::save(const char* path) {
|
||||||
|
#ifndef HAVE_SNDFILE
|
||||||
|
logE("Furnace was not compiled with libsndfile!");
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
SNDFILE* f;
|
SNDFILE* f;
|
||||||
SF_INFO si;
|
SF_INFO si;
|
||||||
memset(&si,0,sizeof(SF_INFO));
|
memset(&si,0,sizeof(SF_INFO));
|
||||||
|
@ -80,6 +86,7 @@ bool DivSample::save(const char* path) {
|
||||||
sf_close(f);
|
sf_close(f);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 16-bit memory is padded to 512, to make things easier for ADPCM-A/B.
|
// 16-bit memory is padded to 512, to make things easier for ADPCM-A/B.
|
||||||
|
|
|
@ -394,6 +394,7 @@ struct DivSong {
|
||||||
bool fbPortaPause;
|
bool fbPortaPause;
|
||||||
bool snDutyReset;
|
bool snDutyReset;
|
||||||
bool pitchMacroIsLinear;
|
bool pitchMacroIsLinear;
|
||||||
|
bool oldOctaveBoundary;
|
||||||
|
|
||||||
std::vector<DivInstrument*> ins;
|
std::vector<DivInstrument*> ins;
|
||||||
std::vector<DivWavetable*> wave;
|
std::vector<DivWavetable*> wave;
|
||||||
|
@ -486,7 +487,8 @@ struct DivSong {
|
||||||
newSegaPCM(true),
|
newSegaPCM(true),
|
||||||
fbPortaPause(false),
|
fbPortaPause(false),
|
||||||
snDutyReset(false),
|
snDutyReset(false),
|
||||||
pitchMacroIsLinear(true) {
|
pitchMacroIsLinear(true),
|
||||||
|
oldOctaveBoundary(false) {
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<32; i++) {
|
||||||
system[i]=DIV_SYSTEM_NULL;
|
system[i]=DIV_SYSTEM_NULL;
|
||||||
systemVol[i]=64;
|
systemVol[i]=64;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue