Merge branch 'master' of https://github.com/tildearrow/furnace into gui_systems

This commit is contained in:
cam900 2022-03-11 03:53:51 +09:00
commit 3b6559a5a1
59 changed files with 3694 additions and 390 deletions

1
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1 @@
<!-- NOTICE: if you are contributing a new system, please be sure to ask tildearrow first in order to get system IDs allocated! -->

3
.gitmodules vendored
View File

@ -19,3 +19,6 @@
[submodule "extern/adpcm"]
path = extern/adpcm
url = https://github.com/superctr/adpcm
[submodule "extern/Nuked-OPL3"]
path = extern/Nuked-OPL3
url = https://github.com/nukeykt/Nuked-OPL3.git

View File

@ -150,39 +150,20 @@ endif()
if (SYSTEM_SDL2)
if (PKG_CONFIG_FOUND)
pkg_check_modules(SDL sdl>=${SYSTEM_SDL_MIN_VER})
if (SDL_FOUND)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL_INCLUDE_DIRS})
list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${SDL_CFLAGS_OTHER})
list(APPEND DEPENDENCIES_LIBRARIES ${SDL_LIBRARIES})
list(APPEND DEPENDENCIES_LIBRARY_DIRS ${SDL_LIBRARY_DIRS})
list(APPEND DEPENDENCIES_LINK_OPTIONS ${SDL_LDFLAGS_OTHER})
list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${SDL_LDFLAGS})
pkg_check_modules(SDL2 sdl2>=${SYSTEM_SDL_MIN_VER})
if (SDL2_FOUND)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${SDL2_CFLAGS_OTHER})
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARIES})
list(APPEND DEPENDENCIES_LIBRARY_DIRS ${SDL2_LIBRARY_DIRS})
list(APPEND DEPENDENCIES_LINK_OPTIONS ${SDL2_LDFLAGS_OTHER})
list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${SDL2_LDFLAGS})
endif()
endif()
if (NOT SDL_FOUND)
find_package(SDL ${SYSTEM_SDL_MIN_VER})
if (SDL_FOUND)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL_INCLUDE_DIR})
list(APPEND DEPENDENCIES_LIBRARIES ${SDL_LIBRARY})
else()
if (PKG_CONFIG_FOUND)
pkg_check_modules(SDL2 sdl2>=${SYSTEM_SDL_MIN_VER})
if (SDL2_FOUND)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${SDL2_CFLAGS_OTHER})
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARIES})
list(APPEND DEPENDENCIES_LIBRARY_DIRS ${SDL2_LIBRARY_DIRS})
list(APPEND DEPENDENCIES_LINK_OPTIONS ${SDL2_LDFLAGS_OTHER})
list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${SDL2_LDFLAGS})
endif()
endif()
if (NOT SDL2_FOUND)
find_package(SDL2 ${SYSTEM_SDL_MIN_VER} REQUIRED)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARY})
endif()
endif()
if (NOT SDL2_FOUND)
find_package(SDL2 ${SYSTEM_SDL_MIN_VER} REQUIRED)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
list(APPEND DEPENDENCIES_LIBRARIES ${SDL2_LIBRARY})
endif()
message(STATUS "Using system-installed SDL2")
else()
@ -245,6 +226,7 @@ extern/adpcm/ymz_codec.c
extern/Nuked-OPN2/ym3438.c
extern/opm/opm.c
extern/Nuked-OPLL/opll.c
extern/Nuked-OPL3/opl3.c
src/engine/platform/sound/sn76496.cpp
src/engine/platform/sound/ay8910.cpp
src/engine/platform/sound/saa1099.cpp
@ -283,6 +265,8 @@ src/engine/platform/sound/lynx/Mikey.cpp
src/engine/platform/sound/qsound.c
src/engine/platform/sound/swan.cpp
src/engine/platform/ym2610Interface.cpp
src/engine/blip_buf.c
@ -317,13 +301,16 @@ src/engine/platform/ym2610b.cpp
src/engine/platform/ym2610bext.cpp
src/engine/platform/ay.cpp
src/engine/platform/ay8930.cpp
src/engine/platform/opl.cpp
src/engine/platform/tia.cpp
src/engine/platform/saa.cpp
src/engine/platform/amiga.cpp
src/engine/platform/pcspkr.cpp
src/engine/platform/segapcm.cpp
src/engine/platform/qsound.cpp
src/engine/platform/dummy.cpp
src/engine/platform/lynx.cpp
src/engine/platform/swan.cpp
src/engine/platform/dummy.cpp
)
if (WIN32)

View File

@ -29,6 +29,7 @@ this is a work-in-progress chiptune tracker compatible with DefleMask modules (.
- accurate emulation cores whether possible (Nuked, MAME, SameBoy, Mednafen PCE, puNES, reSID, Stella, SAASound and ymfm)
- additional features on top:
- FM macros!
- negative octaves
- arbitrary pitch samples
- sample loop points
- SSG envelopes in Neo Geo
@ -48,6 +49,23 @@ see the [Discussions](https://github.com/tildearrow/furnace/discussions) section
check out the [documentation](papers/doc/README.md). it's mostly incomplete, but has details on effects.
# unofficial packages
[![Packaging status](https://repology.org/badge/tiny-repos/furnace.svg)](https://repology.org/project/furnace/versions)
some people have provided packages for Unix/Unix-like distributions. here's a list.
## Arch Linux
[furnace-git is in the AUR.](https://aur.archlinux.org/packages/furnace-git) thank you Essem!
## FreeBSD
[a package in ports](https://www.freshports.org/audio/furnace/) is available courtesy of ehaupt.
## Nix
(TODO)
# developer info
**NOTE: do not download the project's source as a .zip or .tar.gz as these do not include the project's submodules which are necessary to proceed with building.**
@ -169,6 +187,10 @@ also provided are two effects:
- `3xxx`: set fine duty.
- `4xxx`: set fine cutoff. `xxx` range is 000-7ff.
> how do I use PCM on a PCM-capable system?
Two possibilities: the recommended way is via creating the "Amiga/Sample" type instrument and assigning sample to it, or via old, Deflemask-compatible method, using `17xx` effect
> my song sounds very odd at a certain point
file a bug report. use the Issues page.

BIN
demos/Coconut_Mall.fur Normal file

Binary file not shown.

1
extern/Nuked-OPL3 vendored Submodule

@ -0,0 +1 @@
Subproject commit bb5c8d08a85779c42b75c79d7b84f365a1b93b66

View File

@ -10,12 +10,13 @@ double-click to open the instrument editor.
every instrument can be renamed and have its type changed.
depending on the instrument type, there are currently 10 different types of an instrument editor:
depending on the instrument type, there are currently 12 different types of an instrument editor:
- [FM synthesis](fm.md) - for use with YM2612, YM2151 and FM block portion of YM2610.
- [Standard](standard.md) - for use with NES and Sega Master System's PSG sound source and its derivatives.
- [Game Boy](game-boy.md) - for use with Game Boy APU.
- [PC Engine/TurboGrafx-16](pce.md) - for use with PC Engine's wavetable synthesizer.
- [WonderSwan](wonderswan.md) - for use with WonderSwan's wavetable synthesizer.
- [AY8930](8930.md) - for use with Microchip AY8930 E-PSG sound source.
- [Commodore 64](c64.md) - for use with Commodore 64 SID.
- [SAA1099](saa.md) - for use with Philips SAA1099 PSG sound source.

View File

@ -0,0 +1,8 @@
# WonderSwan instrument editor
WS instrument editor consists of only four macros, similar to PCE but with different volume and noise range:
- [Volume] - volume sequence
- [Arpeggio] - pitch sequencr
- [Noise] - noise LFSR tap sequence
- [Waveform] - spicifies wavetables sequence

View File

@ -1,5 +1,5 @@
# wavetable editor
Wavetable synthizers, in context of Furnace, are sound sources that operate on extremely short n-bit PCM streams. By extremely short, no more than 256 bytes. This amount of space is nowhere near enough to store an actual sampled sound, it allows certain amount of freedom to define a waveform shape. As of Furnace 0.5.5, wavetable editor affects PC Engine and channel 3 of Game Boy.
Wavetable synthizers, in context of Furnace, are sound sources that operate on extremely short n-bit PCM streams. By extremely short, no more than 256 bytes. This amount of space is nowhere near enough to store an actual sampled sound, it allows certain amount of freedom to define a waveform shape. As of Furnace 0.5.8, wavetable editor affects PC Engine, WonderSwan and channel 3 of Game Boy.
Furnace's wavetable editor is rather simple, you can draw the waveform using mouse or by pasting an MML bit stream in the input field. Maximum wave width (length) is 256 bytes, and maximum wave height (depth) is 256. NOTE: both Game Boy and PCE can handle max 32 byte waveforms as of now, width 16-level height for GB and 32-level height for PCE. If larger wave will be defined for these two systems, it will be squashed to fit in the constrains of the system.
Furnace's wavetable editor is rather simple, you can draw the waveform using mouse or by pasting an MML bit stream in the input field. Maximum wave width (length) is 256 bytes, and maximum wave height (depth) is 256. NOTE: Game Boy, PCE and WonderSwan can handle max 32 byte waveforms as of now, with 16-level height for GB and WS, and 32-level height for PCE. If larger wave will be defined for these two systems, it will be squashed to fit within the constraints of the system.

View File

@ -18,5 +18,6 @@ this is a list of systems that Furnace supports, including each system's effects
- [Atari 2600](tia.md)
- [Philips SAA1099](saa1099.md)
- [Microchip AY8930](ay8930.md)
- [WonderSwan](wonderswan.md)
Furnace also reads .dmf files with the [Yamaha YMU759](ymu759.md) system, but does not emulate the chip at all.

View File

@ -0,0 +1,20 @@
# WonderSwan
A handheld console released only in Japan by Bandai. Designed by the same
people behind Game Boy and Virtual Boy, it has lots of similar elements from
those two systems in the sound department.
It has 4 wavetable channels, one channel could play PCM, the other has hardware
sweep and the other could play noise.
# effects
- `10xx`: change wave.
- `11xx`: setup noise mode (channel 4 only).
- 0: disable.
- 1-8: enable and set tap preset.
- `12xx`: setup sweep period (channel 3 only).
- 0: disable.
- 1-32: enable and set period.
- `13xx`: setup sweep amount (channel 3 only).
- `17xx`: toggle PCM mode (channel 2 only).

View File

@ -29,6 +29,8 @@ furthermore, an `or reserved` indicates this field is always present, but is res
the format versions are:
- 63: Furnace dev63
- 62: Furnace dev62
- 61: Furnace dev61
- 60: Furnace dev60
- 59: Furnace dev59
@ -119,13 +121,13 @@ size | description
| - 0x06: NES - 5 channels
| - 0x07: C64 (8580) - 3 channels
| - 0x08: Arcade (YM2151+SegaPCM) - 13 channels (compound!)
| - 0x09: Neo Geo (YM2610) - 13 channels
| - 0x09: Neo Geo CD (YM2610) - 13 channels
| - bit 6 enables alternate mode:
| - 0x42: Genesis extended - 13 channels
| - 0x43: SMS (SN76489) + OPLL (YM2413) - 13 channels (compound!)
| - 0x46: NES + VRC7 - 11 channels (compound!)
| - 0x47: C64 (6581) - 3 channels
| - 0x49: Neo Geo extended - 16 channels
| - 0x49: Neo Geo CD extended - 16 channels
| - bit 7 for non-DefleMask chips:
| - 0x80: AY-3-8910 - 3 channels
| - 0x81: Amiga - 4 channels
@ -164,10 +166,15 @@ size | description
| - 0xa2: OPL drums (YM3526) - 11 channels
| - 0xa3: OPL2 drums (YM3812) - 11 channels
| - 0xa4: OPL3 drums (YMF262) - 20 channels
| - 0xa5: OPL3 4-op (YMF262) - 12 channels
| - 0xa6: OPL3 4-op + drums (YMF262) - 14 channels
| - 0xa5: Neo Geo (YM2610) - 14 channels
| - 0xa6: Neo Geo extended (YM2610) - 17 channels
| - 0xa7: OPLL drums (YM2413) - 11 channels
| - 0xa8: Atari Lynx - 4 channels
| - 0xa9: SegaPCM (for Deflemask Compatibility) - 5 channels
| - 0xaa: MSM6295 - 4 channels
| - 0xab: MSM6258 - 1 channel
| - 0xac: Commander X16 (VERA) - 17 channels
| - 0xb0: Seta/Allumer X1-010 - 16 channels
| - 0xde: YM2610B extended - 19 channels
| - 0xe0: QSound - 19 channels
| - (compound!) means that the system is composed of two or more chips,
@ -194,7 +201,9 @@ size | description
1 | wack algorithm macro (>=47) or reserved
1 | broken shortcut slides (>=49) or reserved
1 | ignore duplicate slides (>=50) or reserved
6 | reserved
1 | stop portamento on note off (>=62) or reserved
1 | continuous vibrato (>=62) or reserved
4 | reserved
4?? | pointers to instruments
4?? | pointers to wavetables
4?? | pointers to samples
@ -239,7 +248,9 @@ size | description
1 | feedback
1 | fms
1 | ams
1 | operator count (always 4)
1 | operator count
| - this is either 2 or 4, and is ignored on non-OPL systems.
| - always read 4 ops regardless of this value.
1 | OPLL preset (>=60) or reserved
| - 0: custom
| - 1-15: pre-defined patches
@ -470,6 +481,12 @@ size | description
1?? | VIB macro
1?? | WS macro
1?? | KSR macro
--- | **OPL drums mode data** (>=63)
1 | fixed frequency mode
1 | reserved
2 | kick frequency
2 | snare/hi-hat frequency
2 | tom/top frequency
```
# wavetable

View File

@ -17,4 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "../../extern/rtmidi/RtMidi.h"
#include "../../extern/rtmidi/RtMidi.h"
#include "taAudio.h"
class TAMidiInRtMidi: public TAMidiIn {
};
class TAMidiOutRtMidi: public TAMidiOut {
};

View File

@ -20,6 +20,7 @@
#ifndef _TAAUDIO_H
#define _TAAUDIO_H
#include "../ta-utils.h"
#include <queue>
#include <vector>
struct SampleRateChangeEvent {
@ -116,23 +117,28 @@ struct TAMidiMessage {
void submitSysEx(std::vector<unsigned char> data);
void done();
TAMidiMessage():
type(0),
sysExData(NULL),
sysExLen(0) {
memset(&data,0,sizeof(data));
}
};
class TAMidiIn {
std::queue<TAMidiMessage> queue;
public:
virtual bool gather();
bool next(TAMidiMessage& where);
};
class TAMidiOut {
std::queue<TAMidiMessage> queue;
public:
bool send(TAMidiMessage& what);
};
class TAMidi {
std::vector<TAMidiIn*> in;
std::vector<TAMidiOut*> out;
};
class TAAudio {
protected:
TAAudioDesc desc;
@ -145,7 +151,8 @@ class TAAudio {
void (*sampleRateChanged)(SampleRateChangeEvent);
void (*bufferSizeChanged)(BufferSizeChangeEvent);
public:
TAMidi* midi;
TAMidiIn* midiIn;
TAMidiOut* midiOut;
void setSampleRateChangeCallback(void (*callback)(SampleRateChangeEvent));
void setBufferSizeChangeCallback(void (*callback)(BufferSizeChangeEvent));

View File

@ -29,6 +29,12 @@
#define addWrite(a,v) regWrites.push_back(DivRegWrite(a,v));
// HOW TO ADD A NEW COMMAND:
// add it to this enum. then see playback.cpp.
// there is a const char* cmdName[] array, which contains the command
// names as strings for the commands (and other debug stuff).
//
// if you miss it, the program will crash or misbehave at some point.
enum DivDispatchCmds {
DIV_CMD_NOTE_ON=0,
DIV_CMD_NOTE_OFF,
@ -103,6 +109,9 @@ enum DivDispatchCmds {
DIV_CMD_QSOUND_ECHO_DELAY,
DIV_CMD_QSOUND_ECHO_LEVEL,
DIV_CMD_WS_SWEEP_TIME,
DIV_CMD_WS_SWEEP_AMOUNT,
DIV_ALWAYS_SET_VOLUME,
DIV_CMD_MAX
@ -310,6 +319,11 @@ class DivDispatch {
*/
virtual void notifyInsDeletion(void* ins);
/**
* notify that playback stopped.
*/
virtual void notifyPlaybackStop();
/**
* force-retrigger instruments.
*/

View File

@ -34,11 +34,14 @@
#include "platform/ym2610bext.h"
#include "platform/ay.h"
#include "platform/ay8930.h"
#include "platform/opl.h"
#include "platform/tia.h"
#include "platform/saa.h"
#include "platform/amiga.h"
#include "platform/pcspkr.h"
#include "platform/segapcm.h"
#include "platform/qsound.h"
#include "platform/swan.h"
#include "platform/dummy.h"
#include "platform/lynx.h"
#include "../ta-log.h"
@ -209,6 +212,30 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
((DivPlatformOPLL*)dispatch)->setVRC7(sys==DIV_SYSTEM_VRC7);
((DivPlatformOPLL*)dispatch)->setProperDrums(sys==DIV_SYSTEM_OPLL_DRUMS);
break;
case DIV_SYSTEM_OPL:
dispatch=new DivPlatformOPL;
((DivPlatformOPL*)dispatch)->setOPLType(1,false);
break;
case DIV_SYSTEM_OPL_DRUMS:
dispatch=new DivPlatformOPL;
((DivPlatformOPL*)dispatch)->setOPLType(1,true);
break;
case DIV_SYSTEM_OPL2:
dispatch=new DivPlatformOPL;
((DivPlatformOPL*)dispatch)->setOPLType(2,false);
break;
case DIV_SYSTEM_OPL2_DRUMS:
dispatch=new DivPlatformOPL;
((DivPlatformOPL*)dispatch)->setOPLType(2,true);
break;
case DIV_SYSTEM_OPL3:
dispatch=new DivPlatformOPL;
((DivPlatformOPL*)dispatch)->setOPLType(3,false);
break;
case DIV_SYSTEM_OPL3_DRUMS:
dispatch=new DivPlatformOPL;
((DivPlatformOPL*)dispatch)->setOPLType(3,true);
break;
case DIV_SYSTEM_SAA1099: {
int saaCore=eng->getConfInt("saaCore",0);
if (saaCore<0 || saaCore>2) saaCore=0;
@ -216,6 +243,9 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
((DivPlatformSAA1099*)dispatch)->setCore((DivSAACores)saaCore);
break;
}
case DIV_SYSTEM_PCSPKR:
dispatch=new DivPlatformPCSpeaker;
break;
case DIV_SYSTEM_LYNX:
dispatch=new DivPlatformLynx;
break;
@ -226,6 +256,9 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
case DIV_SYSTEM_SEGAPCM_COMPAT:
dispatch=new DivPlatformSegaPCM;
break;
case DIV_SYSTEM_SWAN:
dispatch=new DivPlatformSwan;
break;
default:
logW("this system is not supported yet! using dummy platform.\n");
dispatch=new DivPlatformDummy;

View File

@ -828,6 +828,9 @@ void DivEngine::stop() {
sPreview.sample=-1;
sPreview.wave=-1;
sPreview.pos=0;
for (int i=0; i<song.systemLen; i++) {
disCont[i].dispatch->notifyPlaybackStop();
}
isBusy.unlock();
}

View File

@ -37,8 +37,8 @@
warnings+=(String("\n")+x); \
}
#define DIV_VERSION "dev61"
#define DIV_ENGINE_VERSION 61
#define DIV_VERSION "dev63"
#define DIV_ENGINE_VERSION 63
enum DivStatusView {
DIV_STATUS_NOTHING=0,

View File

@ -796,6 +796,9 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
if (ds.version<50) {
ds.ignoreDuplicateSlides=false;
}
if (ds.version<62) {
ds.stopPortaOnNoteOff=true;
}
ds.isDMF=false;
reader.readS(); // reserved
@ -965,7 +968,14 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
} else {
reader.readC();
}
for (int i=0; i<6; i++) reader.readC();
if (ds.version>=62) {
ds.stopPortaOnNoteOff=reader.readC();
ds.continuousVibrato=reader.readC();
} else {
reader.readC();
reader.readC();
}
for (int i=0; i<4; i++) reader.readC();
} else {
for (int i=0; i<20; i++) reader.readC();
}
@ -1102,6 +1112,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
logW("%d: sample depth is wrong! (%d)\n",i,sample->depth);
sample->depth=16;
}
sample->samples=(double)sample->samples/samplePitches[pitch];
sample->init(sample->samples);
unsigned int k=0;
@ -1404,7 +1415,9 @@ SafeWriter* DivEngine::saveFur() {
w->writeC(song.algMacroBehavior);
w->writeC(song.brokenShortcutSlides);
w->writeC(song.ignoreDuplicateSlides);
for (int i=0; i<6; i++) {
w->writeC(song.stopPortaOnNoteOff);
w->writeC(song.continuousVibrato);
for (int i=0; i<4; i++) {
w->writeC(0);
}

View File

@ -39,7 +39,7 @@ void DivInstrument::putInsData(SafeWriter* w) {
w->writeC(fm.fb);
w->writeC(fm.fms);
w->writeC(fm.ams);
w->writeC(4); // operator count; always 4
w->writeC(fm.ops);
w->writeC(fm.opllPreset);
w->writeC(0); // reserved
w->writeC(0);
@ -371,6 +371,13 @@ void DivInstrument::putInsData(SafeWriter* w) {
w->writeC(op.ksrMacro[j]);
}
}
// OPL drum data
w->writeC(fm.fixedDrums);
w->writeC(0); // reserved
w->writeS(fm.kickFreq);
w->writeS(fm.snareHatFreq);
w->writeS(fm.tomTopFreq);
}
DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
@ -694,6 +701,22 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
}
}
// OPL drum data
if (version>=63) {
fm.fixedDrums=reader.readC();
reader.readC(); // reserved
fm.kickFreq=reader.readS();
fm.snareHatFreq=reader.readS();
fm.tomTopFreq=reader.readS();
}
// clear noise macro if PCE instrument and version<63
if (version<63 && type==DIV_INS_PCE) {
std.dutyMacroLen=0;
std.dutyMacroLoop=-1;
std.dutyMacroRel=-1;
}
return DIV_DATA_SUCCESS;
}

View File

@ -23,6 +23,9 @@
#include "dataErrors.h"
#include "../ta-utils.h"
// NOTICE!
// before adding new instrument types to this struct, please ask me first.
// absolutely zero support granted to conflicting formats.
enum DivInstrumentType {
DIV_INS_STD=0,
DIV_INS_FM=1,
@ -67,6 +70,8 @@ enum DivInstrumentType {
struct DivInstrumentFM {
unsigned char alg, fb, fms, ams, ops, opllPreset;
bool fixedDrums;
unsigned short kickFreq, snareHatFreq, tomTopFreq;
struct Operator {
unsigned char am, ar, dr, mult, rr, sl, tl, dt2, rs, dt, d2r, ssgEnv;
unsigned char dam, dvb, egt, ksl, sus, vib, ws, ksr; // YMU759/OPL/OPZ
@ -98,7 +103,11 @@ struct DivInstrumentFM {
fms(0),
ams(0),
ops(4),
opllPreset(0) {
opllPreset(0),
fixedDrums(false),
kickFreq(0x520),
snareHatFreq(0x550),
tomTopFreq(0x1c0) {
// default instrument
fb=4;
op[0].tl=42;

View File

@ -97,6 +97,10 @@ void DivDispatch::notifyInsDeletion(void* ins) {
}
void DivDispatch::notifyPlaybackStop() {
}
void DivDispatch::forceIns() {
}

View File

@ -84,7 +84,7 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le
} else {
chan[i].sample=-1;
}
if (chan[i].freq<124) {
/*if (chan[i].freq<124) {
if (++chan[i].busClock>=512) {
unsigned int rAmount=(124-chan[i].freq)*2;
if (chan[i].audPos>=rAmount) {
@ -92,7 +92,7 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le
}
chan[i].busClock=0;
}
}
}*/
chan[i].audSub+=MAX(114,chan[i].freq);
}
}

View File

@ -42,7 +42,7 @@ static bool isOutput[8][4]={
{true ,true ,true ,true},
};
static unsigned char dtTable[8]={
7,6,5,0,1,2,3,0
7,6,5,0,1,2,3,4
};
static int orderedOps[4]={
@ -495,8 +495,8 @@ int DivPlatformArcade::dispatch(DivCommand c) {
chan[c.chan].ins=c.value;
break;
case DIV_CMD_PANNING: {
chan[c.chan].chVolL=((c.value>>4)==1);
chan[c.chan].chVolR=((c.value&15)==1);
chan[c.chan].chVolL=((c.value>>4)>0);
chan[c.chan].chVolR=((c.value&15)>0);
if (isMuted[c.chan]) {
rWrite(chanOffs[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&7)|(chan[c.chan].state.fb<<3));
} else {

View File

@ -491,6 +491,12 @@ void DivPlatformAY8910::setFlags(unsigned int flags) {
case 8:
chipClock=COLOR_PAL*3.0/16.0;
break;
case 9:
chipClock=COLOR_PAL/4.0;
break;
case 10:
chipClock=2097152;
break;
default:
chipClock=COLOR_NTSC/2.0;
break;

View File

@ -372,7 +372,7 @@ int DivPlatformAY8930::dispatch(DivCommand c) {
}
} else {
chan[c.chan].duty=c.value&15;
immWrite(0x16,chan[c.chan].duty);
immWrite(0x16+c.chan,chan[c.chan].duty);
}
break;
case DIV_CMD_STD_NOISE_FREQ:
@ -552,6 +552,12 @@ void DivPlatformAY8930::setFlags(unsigned int flags) {
case 8:
chipClock=COLOR_PAL*3.0/16.0;
break;
case 9:
chipClock=COLOR_PAL/4.0;
break;
case 10:
chipClock=2097152;
break;
default:
chipClock=COLOR_NTSC/2.0;
break;

View File

@ -340,6 +340,7 @@ int DivPlatformGB::dispatch(DivCommand c) {
case DIV_CMD_PANNING: {
lastPan&=~(0x11<<c.chan);
if (c.value==0) c.value=0x11;
c.value=((c.value&15)>0)|(((c.value>>4)>0)<<4);
lastPan|=c.value<<c.chan;
rWrite(0x25,procMute());
break;

View File

@ -133,17 +133,11 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
//OPN2_Write(&fm,0,0);
}
psgClocks+=psg.rate;
while (psgClocks>=rate) {
psgOut=(psg.acquireOne()*3)>>3;
psgClocks-=rate;
}
os[0]=(os[0]<<5)+psgOut;
os[0]=(os[0]<<5);
if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767;
os[1]=(os[1]<<5)+psgOut;
os[1]=(os[1]<<5);
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
@ -197,17 +191,9 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
os[1]=out_ymfm.data[1];
//OPN2_Write(&fm,0,0);
psgClocks+=psg.rate;
while (psgClocks>=rate) {
psgOut=(psg.acquireOne()*3)>>3;
psgClocks-=rate;
}
os[0]=os[0]+psgOut;
if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767;
os[1]=os[1]+psgOut;
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
@ -391,13 +377,6 @@ void DivPlatformGenesis::tick() {
chan[i].keyOn=false;
}
}
psg.tick();
for (DivRegWrite& i: psg.getRegisterWrites()) {
if (dumpWrites) addWrite(i.addr,i.val);
}
psg.getRegisterWrites().clear();
}
int DivPlatformGenesis::octave(int freq) {
@ -442,10 +421,6 @@ int DivPlatformGenesis::toFreq(int freq) {
}
void DivPlatformGenesis::muteChannel(int ch, bool mute) {
if (ch>5) {
psg.muteChannel(ch-6,mute);
return;
}
isMuted[ch]=mute;
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[ch]|opOffs[j];
@ -464,10 +439,6 @@ void DivPlatformGenesis::muteChannel(int ch, bool mute) {
}
int DivPlatformGenesis::dispatch(DivCommand c) {
if (c.chan>5) {
c.chan-=6;
return psg.dispatch(c);
}
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
@ -619,16 +590,10 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
chan[c.chan].ins=c.value;
break;
case DIV_CMD_PANNING: {
switch (c.value) {
case 0x01:
chan[c.chan].pan=1;
break;
case 0x10:
chan[c.chan].pan=2;
break;
default:
chan[c.chan].pan=3;
break;
if (c.value==0) {
chan[c.chan].pan=3;
} else {
chan[c.chan].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
}
rWrite(chanOffs[c.chan]+ADDR_LRAF,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|(chan[c.chan].state.fms&7)|((chan[c.chan].state.ams&3)<<4));
break;
@ -786,16 +751,13 @@ void DivPlatformGenesis::forceIns() {
rWrite(0x2b,0x80);
}
immWrite(0x22,lfoValue);
psg.forceIns();
}
void DivPlatformGenesis::toggleRegisterDump(bool enable) {
DivDispatch::toggleRegisterDump(enable);
psg.toggleRegisterDump(enable);
}
void* DivPlatformGenesis::getChanState(int ch) {
if (ch>5) return psg.getChanState(ch-6);
return &chan[ch];
}
@ -844,12 +806,6 @@ void DivPlatformGenesis::reset() {
immWrite(0x22,lfoValue);
delay=0;
// PSG
psg.reset();
psg.getRegisterWrites().clear();
psgClocks=0;
psgOut=0;
}
bool DivPlatformGenesis::isStereo() {
@ -865,17 +821,14 @@ bool DivPlatformGenesis::keyOffAffectsPorta(int ch) {
}
void DivPlatformGenesis::notifyInsChange(int ins) {
for (int i=0; i<10; i++) {
if (i>5) {
psg.notifyInsChange(ins);
} else if (chan[i].ins==ins) {
for (int i=0; i<6; i++) {
if (chan[i].ins==ins) {
chan[i].insChanged=true;
}
}
}
void DivPlatformGenesis::notifyInsDeletion(void* ins) {
psg.notifyInsDeletion(ins);
}
void DivPlatformGenesis::poke(unsigned int addr, unsigned short val) {
@ -904,7 +857,6 @@ void DivPlatformGenesis::setFlags(unsigned int flags) {
} else {
chipClock=COLOR_NTSC*15.0/7.0;
}
psg.setFlags(flags==1);
ladder=flags&0x80000000;
OPN2_SetChipType(ladder?ym3438_mode_ym2612:0);
if (useYMFM) {
@ -929,7 +881,6 @@ int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, unsigned i
isMuted[i]=false;
}
fm_ymfm=NULL;
psg.init(p,4,sugRate,flags==1);
setFlags(flags);
reset();
@ -938,7 +889,6 @@ int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, unsigned i
void DivPlatformGenesis::quit() {
if (fm_ymfm!=NULL) delete fm_ymfm;
psg.quit();
}
DivPlatformGenesis::~DivPlatformGenesis() {

View File

@ -70,9 +70,6 @@ class DivPlatformGenesis: public DivDispatch {
};
std::queue<QueuedWrite> writes;
ym3438_t fm;
DivPlatformSMS psg;
int psgClocks;
int psgOut;
int delay;
unsigned char lastBusy;

View File

@ -106,16 +106,10 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
opChan[ch].ins=c.value;
break;
case DIV_CMD_PANNING: {
switch (c.value) {
case 0x01:
opChan[ch].pan=1;
break;
case 0x10:
opChan[ch].pan=2;
break;
default:
opChan[ch].pan=3;
break;
if (c.value==0) {
opChan[ch].pan=3;
} else {
opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
}
// TODO: ???
rWrite(chanOffs[2]+0xb4,(opChan[ch].pan<<6)|(chan[2].state.fms&7)|((chan[2].state.ams&3)<<4));
@ -378,4 +372,4 @@ void DivPlatformGenesisExt::quit() {
}
DivPlatformGenesisExt::~DivPlatformGenesisExt() {
}
}

View File

@ -35,7 +35,7 @@ static bool isOutput[8][4]={
{true ,true ,true ,true},
};
static unsigned char dtTable[8]={
7,6,5,0,1,2,3,0
7,6,5,0,1,2,3,4
};
static int orderedOps[4]={
@ -45,4 +45,4 @@ static int orderedOps[4]={
#define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;}
#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} }
#include "fmshared_OPN.h"
#include "fmshared_OPN.h"

882
src/engine/platform/opl.cpp Normal file
View File

@ -0,0 +1,882 @@
/**
* 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 "opl.h"
#include "../engine.h"
#include <string.h>
#include <math.h>
#define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;}
#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} }
#define CHIP_FREQBASE chipFreqBase
// N = invalid
#define N 255
const unsigned char slotsOPL2i[4][20]={
{0, 1, 2, 6, 7, 8, 12, 13, 14}, // OP1
{3, 4, 5, 9, 10, 11, 15, 16, 17}, // OP2
{N, N, N, N, N, N, N, N, N},
{N, N, N, N, N, N, N, N, N}
};
const unsigned char slotsOPL2Drumsi[4][20]={
{0, 1, 2, 6, 7, 8, 12, 16, 14, 17, 13}, // OP1
{3, 4, 5, 9, 10, 11, 15, N, N, N, N}, // OP2
{N, N, N, N, N, N, N, N, N, N, N},
{N, N, N, N, N, N, N, N, N, N, N}
};
const unsigned short chanMapOPL2[20]={
0, 1, 2, 3, 4, 5, 6, 7, 8, N, N, N, N, N, N, N, N, N, N, N
};
const unsigned char* slotsOPL2[4]={
slotsOPL2i[0],
slotsOPL2i[1],
slotsOPL2i[2],
slotsOPL2i[3]
};
const unsigned char* slotsOPL2Drums[4]={
slotsOPL2Drumsi[0],
slotsOPL2Drumsi[1],
slotsOPL2Drumsi[2],
slotsOPL2Drumsi[3]
};
const unsigned char slotsOPL3i[4][20]={
{0, 6, 1, 7, 2, 8, 18, 24, 19, 25, 20, 26, 30, 31, 32, 12, 13, 14}, // OP1
{3, 9, 4, 10, 5, 11, 21, 27, 22, 28, 23, 29, 33, 34, 35, 15, 16, 17}, // OP2
{6, N, 7, N, 8, N, 24, N, 25, N, 26, N, N, N, N, N, N, N}, // OP3
{9, N, 10, N, 11, N, 27, N, 28, N, 29, N, N, N, N, N, N, N} // OP4
};
const unsigned char slotsOPL3Drumsi[4][20]={
{0, 6, 1, 7, 2, 8, 18, 24, 19, 25, 20, 26, 30, 31, 32, 12, 16, 14, 17, 13}, // OP1
{3, 9, 4, 10, 5, 11, 21, 27, 22, 28, 23, 29, 33, 34, 35, N, N, N, N, N}, // OP2
{6, N, 7, N, 8, N, 24, N, 25, N, 26, N, N, N, N, N, N, N, N, N}, // OP3
{9, N, 10, N, 11, N, 27, N, 28, N, 29, N, N, N, N, N, N, N, N, N} // OP4
};
const unsigned short chanMapOPL3[20]={
0, 3, 1, 4, 2, 5, 0x100, 0x103, 0x101, 0x104, 0x102, 0x105, 0x106, 0x107, 0x108, 6, 7, 8, N, N
};
const unsigned char* slotsOPL3[4]={
slotsOPL3i[0],
slotsOPL3i[1],
slotsOPL3i[2],
slotsOPL3i[3]
};
const unsigned char* slotsOPL3Drums[4]={
slotsOPL3Drumsi[0],
slotsOPL3Drumsi[1],
slotsOPL3Drumsi[2],
slotsOPL3Drumsi[3]
};
const unsigned int slotMap[36]={
0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x100, 0x101, 0x102, 0x103, 0x104, 0x105,
0x108, 0x109, 0x10a, 0x10b, 0x10c, 0x10d,
0x110, 0x111, 0x112, 0x113, 0x114, 0x115,
};
const bool isOutputL[2][4][4]={
{ // 2-op
{false, true, false, false}, // 1 > 2
{ true, true, false, false}, // 1 + 2
{false, true, false, false}, // ditto, 0
{ true, true, false, false}, // ditto, 1
},
{ // 4-op
{false, false, false, true}, // 1 > 2 > 3 > 4
{ true, false, false, true}, // 1 + (2 > 3 > 4)
{false, true, false, true}, // (1 > 2) + (3 > 4)
{ true, false, true, true} // 1 + (2 > 3) + 4
}
};
#undef N
const int orderedOpsL[4]={
0,2,1,3
};
#define ADDR_AM_VIB_SUS_KSR_MULT 0x20
#define ADDR_KSL_TL 0x40
#define ADDR_AR_DR 0x60
#define ADDR_SL_RR 0x80
#define ADDR_WS 0xe0
#define ADDR_FREQ 0xa0
#define ADDR_FREQH 0xb0
#define ADDR_LR_FB_ALG 0xc0
const char* DivPlatformOPL::getEffectName(unsigned char effect) {
switch (effect) {
case 0x10:
return "10xy: Setup LFO (x: enable; y: speed)";
break;
case 0x11:
return "11xx: Set feedback (0 to 7)";
break;
case 0x12:
return "12xx: Set level of operator 1 (0 highest, 3F lowest)";
break;
case 0x13:
return "13xx: Set level of operator 2 (0 highest, 3F lowest)";
break;
case 0x14:
return "14xx: Set level of operator 3 (0 highest, 3F lowest; 4-op only)";
break;
case 0x15:
return "15xx: Set level of operator 4 (0 highest, 3F lowest; 4-op only)";
break;
case 0x16:
return "16xy: Set operator multiplier (x: operator from 1 to 4; y: multiplier)";
break;
case 0x17:
return "17xx: Enable channel 6 DAC";
break;
case 0x18:
return "18xx: Toggle extended channel 3 mode";
break;
case 0x19:
return "19xx: Set attack of all operators (0 to F)";
break;
case 0x1a:
return "1Axx: Set attack of operator 1 (0 to F)";
break;
case 0x1b:
return "1Bxx: Set attack of operator 2 (0 to F)";
break;
case 0x1c:
return "1Cxx: Set attack of operator 3 (0 to F; 4-op only)";
break;
case 0x1d:
return "1Dxx: Set attack of operator 4 (0 to F; 4-op only)";
break;
case 0x20:
return "20xy: Set PSG noise mode (x: preset freq/ch3 freq; y: thin pulse/noise)";
break;
}
return NULL;
}
void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
static short o[2];
static int os[2];
for (size_t h=start; h<start+len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty() && --delay<0) {
delay=1;
QueuedWrite& w=writes.front();
OPL3_WriteReg(&fm,w.addr,w.val);
regPool[w.addr&511]=w.val;
writes.pop();
}
OPL3_Generate(&fm,o); os[0]+=o[0]; os[1]+=o[1];
if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767;
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
}
}
void DivPlatformOPL::acquire(short* bufL, short* bufR, size_t start, size_t len) {
//if (useYMFM) {
// acquire_ymfm(bufL,bufR,start,len);
//} else {
acquire_nuked(bufL,bufR,start,len);
//}
}
void DivPlatformOPL::tick() {
for (int i=0; i<20; i++) {
chan[i].std.next();
/*
if (chan[i].std.hadVol) {
chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127;
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (isMuted[i]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[i].state.alg][j]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
}
}
if (chan[i].std.hadArp) {
if (!chan[i].inPorta) {
if (chan[i].std.arpMode) {
chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp);
} else {
chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp);
}
}
chan[i].freqChanged=true;
} else {
if (chan[i].std.arpMode && chan[i].std.finishedArp) {
chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note);
chan[i].freqChanged=true;
}
}
if (chan[i].std.hadAlg) {
chan[i].state.alg=chan[i].std.alg;
rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3));
if (!parent->song.algMacroBehavior) for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (isMuted[i]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[i].state.alg][j]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
}
}
if (chan[i].std.hadFb) {
chan[i].state.fb=chan[i].std.fb;
rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3));
}
if (chan[i].std.hadFms) {
chan[i].state.fms=chan[i].std.fms;
rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4));
}
if (chan[i].std.hadAms) {
chan[i].state.ams=chan[i].std.ams;
rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4));
}
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
DivMacroInt::IntOp& m=chan[i].std.op[j];
if (m.hadAm) {
op.am=m.am;
rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7));
}
if (m.hadAr) {
op.ar=m.ar;
rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6));
}
if (m.hadDr) {
op.dr=m.dr;
rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7));
}
if (m.hadMult) {
op.mult=m.mult;
rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4));
}
if (m.hadRr) {
op.rr=m.rr;
rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4));
}
if (m.hadSl) {
op.sl=m.sl;
rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4));
}
if (m.hadTl) {
op.tl=127-m.tl;
if (isMuted[i]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[i].state.alg][j]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
}
if (m.hadRs) {
op.rs=m.rs;
rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6));
}
if (m.hadDt) {
op.dt=m.dt;
rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4));
}
if (m.hadD2r) {
op.d2r=m.d2r;
rWrite(baseAddr+ADDR_DT2_D2R,op.d2r&31);
}
if (m.hadSsg) {
op.ssgEnv=m.ssg;
rWrite(baseAddr+ADDR_SSG,op.ssgEnv&15);
}
}
*/
if (chan[i].keyOn || chan[i].keyOff) {
immWrite(chanMap[i]+ADDR_FREQH,0x00|(chan[i].freqH&31));
chan[i].keyOff=false;
}
}
for (int i=0; i<512; i++) {
if (pendingWrites[i]!=oldWrites[i]) {
immWrite(i,pendingWrites[i]&0xff);
oldWrites[i]=pendingWrites[i];
}
}
for (int i=0; i<20; i++) {
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
if (chan[i].freq>131071) chan[i].freq=131071;
int freqt=toFreq(chan[i].freq);
chan[i].freqH=freqt>>8;
chan[i].freqL=freqt&0xff;
immWrite(chanMap[i]+ADDR_FREQ,chan[i].freqL);
}
if (chan[i].keyOn) {
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(0x20));
chan[i].keyOn=false;
} else if (chan[i].freqChanged) {
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(chan[i].active<<5));
}
chan[i].freqChanged=false;
}
}
#define OPLL_C_NUM 686
int DivPlatformOPL::octave(int freq) {
if (freq>=OPLL_C_NUM*64) {
return 128;
} else if (freq>=OPLL_C_NUM*32) {
return 64;
} else if (freq>=OPLL_C_NUM*16) {
return 32;
} else if (freq>=OPLL_C_NUM*8) {
return 16;
} else if (freq>=OPLL_C_NUM*4) {
return 8;
} else if (freq>=OPLL_C_NUM*2) {
return 4;
} else if (freq>=OPLL_C_NUM) {
return 2;
} else {
return 1;
}
return 1;
}
int DivPlatformOPL::toFreq(int freq) {
if (freq>=OPLL_C_NUM*64) {
return 0x1c00|((freq>>7)&0x3ff);
} else if (freq>=OPLL_C_NUM*32) {
return 0x1800|((freq>>6)&0x3ff);
} else if (freq>=OPLL_C_NUM*16) {
return 0x1400|((freq>>5)&0x3ff);
} else if (freq>=OPLL_C_NUM*8) {
return 0x1000|((freq>>4)&0x3ff);
} else if (freq>=OPLL_C_NUM*4) {
return 0xc00|((freq>>3)&0x3ff);
} else if (freq>=OPLL_C_NUM*2) {
return 0x800|((freq>>2)&0x3ff);
} else if (freq>=OPLL_C_NUM) {
return 0x400|((freq>>1)&0x3ff);
} else {
return freq&0x3ff;
}
}
void DivPlatformOPL::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
/*
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[ch]|opOffs[j];
DivInstrumentFM::Operator& op=chan[ch].state.op[j];
if (isMuted[ch]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[ch].state.alg][j]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[ch].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
}
rWrite(chanOffs[ch]+ADDR_LRAF,(isMuted[ch]?0:(chan[ch].pan<<6))|(chan[ch].state.fms&7)|((chan[ch].state.ams&3)<<4));
*/
}
int DivPlatformOPL::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
if (chan[c.chan].insChanged) {
chan[c.chan].state=ins->fm;
}
chan[c.chan].std.init(ins);
if (!chan[c.chan].std.willVol) {
chan[c.chan].outVol=chan[c.chan].vol;
}
if (chan[c.chan].insChanged) {
int ops=(slots[3][c.chan]!=255 && ins->fm.ops==4 && oplType==3)?4:2;
for (int i=0; i<ops; i++) {
unsigned char slot=slots[i][c.chan];
if (slot==255) continue;
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[c.chan].state.op[(ops==4)?orderedOpsL[i]:i];
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (isOutputL[ops==4][chan[c.chan].state.alg][i]) {
rWrite(baseAddr+ADDR_KSL_TL,(63-(((63-op.tl)*(chan[c.chan].outVol&0x3f))/63))|(op.ksl<<6));
} else {
rWrite(baseAddr+ADDR_KSL_TL,op.tl|(op.ksl<<6));
}
}
rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,(op.am<<7)|(op.vib<<6)|(op.sus<<5)|(op.ksr<<4)|op.mult);
rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|op.dr);
rWrite(baseAddr+ADDR_SL_RR,(op.sl<<4)|op.rr);
if (oplType>1) {
rWrite(baseAddr+ADDR_WS,op.ws&((oplType==3)?7:3));
}
}
if (isMuted[c.chan]) {
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1));
if (ops==4) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1));
}
} else {
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
if (ops==4) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
}
}
}
chan[c.chan].insChanged=false;
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
}
chan[c.chan].keyOn=true;
chan[c.chan].active=true;
break;
}
case DIV_CMD_NOTE_OFF:
chan[c.chan].keyOff=true;
chan[c.chan].keyOn=false;
chan[c.chan].active=false;
break;
case DIV_CMD_NOTE_OFF_ENV:
chan[c.chan].keyOff=true;
chan[c.chan].keyOn=false;
chan[c.chan].active=false;
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.hasVol) {
chan[c.chan].outVol=c.value;
}
/*
for (int i=0; i<4; i++) {
unsigned short baseAddr=chanOffs[c.chan]|opOffs[i];
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[c.chan].state.alg][i]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[c.chan].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
}
*/
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_PANNING: {
switch (c.value) {
case 0x01:
chan[c.chan].pan=1;
break;
case 0x10:
chan[c.chan].pan=2;
break;
default:
chan[c.chan].pan=3;
break;
}
//rWrite(chanOffs[c.chan]+ADDR_LRAF,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|(chan[c.chan].state.fms&7)|((chan[c.chan].state.ams&3)<<4));
break;
}
case DIV_CMD_PITCH: {
chan[c.chan].pitch=c.value;
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_FREQUENCY(c.value2);
int newFreq;
bool return2=false;
if (destFreq>chan[c.chan].baseFreq) {
newFreq=chan[c.chan].baseFreq+c.value*octave(chan[c.chan].baseFreq);
if (newFreq>=destFreq) {
newFreq=destFreq;
return2=true;
}
} else {
newFreq=chan[c.chan].baseFreq-c.value*octave(chan[c.chan].baseFreq);
if (newFreq<=destFreq) {
newFreq=destFreq;
return2=true;
}
}
if (!chan[c.chan].portaPause) {
if (octave(chan[c.chan].baseFreq)!=octave(newFreq)) {
chan[c.chan].portaPause=true;
break;
}
}
chan[c.chan].baseFreq=newFreq;
chan[c.chan].portaPause=false;
chan[c.chan].freqChanged=true;
if (return2) {
chan[c.chan].inPorta=false;
return 2;
}
break;
}
case DIV_CMD_LEGATO: {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_FM_LFO: {
lfoValue=(c.value&7)|((c.value>>4)<<3);
rWrite(0x22,lfoValue);
break;
}
case DIV_CMD_FM_FB: {
chan[c.chan].state.fb=c.value&7;
//rWrite(chanOffs[c.chan]+ADDR_FB_ALG,(chan[c.chan].state.alg&7)|(chan[c.chan].state.fb<<3));
break;
}
case DIV_CMD_FM_MULT: {
/*
unsigned short baseAddr=chanOffs[c.chan]|opOffs[orderedOps[c.value]];
DivInstrumentFM::Operator& op=chan[c.chan].state.op[orderedOps[c.value]];
op.mult=c.value2&15;
rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4));
*/
break;
}
case DIV_CMD_FM_TL: {
/*
unsigned short baseAddr=chanOffs[c.chan]|opOffs[orderedOps[c.value]];
DivInstrumentFM::Operator& op=chan[c.chan].state.op[orderedOps[c.value]];
op.tl=c.value2;
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[c.chan].state.alg][c.value]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[c.chan].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
*/
break;
}
case DIV_CMD_FM_AR: {
/*
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
op.ar=c.value2&31;
unsigned short baseAddr=chanOffs[c.chan]|opOffs[i];
rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6));
}
} else {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[orderedOps[c.value]];
op.ar=c.value2&31;
unsigned short baseAddr=chanOffs[c.chan]|opOffs[orderedOps[c.value]];
rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6));
}
*/
break;
}
case DIV_ALWAYS_SET_VOLUME:
return 0;
break;
case DIV_CMD_GET_VOLMAX:
return 63;
break;
case DIV_CMD_PRE_PORTA:
chan[c.chan].inPorta=c.value;
break;
case DIV_CMD_PRE_NOTE:
break;
default:
//printf("WARNING: unimplemented command %d\n",c.cmd);
break;
}
return 1;
}
void DivPlatformOPL::forceIns() {
/*
for (int i=0; i<20; i++) {
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (isMuted[i]) {
rWrite(baseAddr+ADDR_TL,127);
} else {
if (isOutput[chan[i].state.alg][j]) {
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127));
} else {
rWrite(baseAddr+ADDR_TL,op.tl);
}
}
rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4));
rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6));
rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7));
rWrite(baseAddr+ADDR_DT2_D2R,op.d2r&31);
rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4));
rWrite(baseAddr+ADDR_SSG,op.ssgEnv&15);
}
rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3));
rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4));
if (chan[i].active) {
chan[i].keyOn=true;
chan[i].freqChanged=true;
}
}
if (dacMode) {
rWrite(0x2b,0x80);
}
immWrite(0x22,lfoValue);
*/
}
void DivPlatformOPL::toggleRegisterDump(bool enable) {
DivDispatch::toggleRegisterDump(enable);
}
void* DivPlatformOPL::getChanState(int ch) {
return &chan[ch];
}
unsigned char* DivPlatformOPL::getRegisterPool() {
return regPool;
}
int DivPlatformOPL::getRegisterPoolSize() {
return 512;
}
void DivPlatformOPL::reset() {
while (!writes.empty()) writes.pop();
memset(regPool,0,512);
/*
if (useYMFM) {
fm_ymfm->reset();
}
*/
OPL3_Reset(&fm,rate);
if (dumpWrites) {
addWrite(0xffffffff,0);
}
for (int i=0; i<20; i++) {
chan[i]=DivPlatformOPL::Channel();
chan[i].vol=0x3f;
chan[i].outVol=0x3f;
}
for (int i=0; i<512; i++) {
oldWrites[i]=-1;
pendingWrites[i]=-1;
}
lastBusy=60;
lfoValue=8;
properDrums=properDrumsSys;
if (oplType==3) { // enable OPL3 features
immWrite(0x105,1);
}
delay=0;
}
bool DivPlatformOPL::isStereo() {
return true;
}
bool DivPlatformOPL::keyOffAffectsArp(int ch) {
return (ch>5);
}
bool DivPlatformOPL::keyOffAffectsPorta(int ch) {
return (ch>5);
}
void DivPlatformOPL::notifyInsChange(int ins) {
for (int i=0; i<20; i++) {
if (chan[i].ins==ins) {
chan[i].insChanged=true;
}
}
}
void DivPlatformOPL::notifyInsDeletion(void* ins) {
}
void DivPlatformOPL::poke(unsigned int addr, unsigned short val) {
immWrite(addr,val);
}
void DivPlatformOPL::poke(std::vector<DivRegWrite>& wlist) {
for (DivRegWrite& i: wlist) immWrite(i.addr,i.val);
}
int DivPlatformOPL::getPortaFloor(int ch) {
return (ch>5)?12:0;
}
void DivPlatformOPL::setYMFM(bool use) {
useYMFM=use;
}
void DivPlatformOPL::setOPLType(int type, bool drums) {
switch (type) {
case 1: case 2:
slotsNonDrums=slotsOPL2;
slotsDrums=slotsOPL2Drums;
slots=drums?slotsDrums:slotsNonDrums;
chanMap=chanMapOPL2;
chipFreqBase=9440540*0.25;
break;
case 3:
slotsNonDrums=slotsOPL3;
slotsDrums=slotsOPL3Drums;
slots=drums?slotsDrums:slotsNonDrums;
chanMap=chanMapOPL3;
chipFreqBase=9440540;
break;
}
oplType=type;
properDrumsSys=drums;
}
void DivPlatformOPL::setFlags(unsigned int flags) {
/*
if (flags==3) {
chipClock=COLOR_NTSC*12.0/7.0;
} else if (flags==2) {
chipClock=8000000.0;
} else if (flags==1) {
chipClock=COLOR_PAL*12.0/7.0;
} else {
chipClock=COLOR_NTSC*15.0/7.0;
}
ladder=flags&0x80000000;
OPN2_SetChipType(ladder?ym3438_mode_ym2612:0);
if (useYMFM) {
if (fm_ymfm!=NULL) delete fm_ymfm;
if (ladder) {
fm_ymfm=new ymfm::ym2612(iface);
} else {
fm_ymfm=new ymfm::ym3438(iface);
}
rate=chipClock/144;
} else {
rate=chipClock/36;
}*/
if (oplType==3) {
chipClock=COLOR_NTSC*4.0;
rate=chipClock/288;
} else {
chipClock=COLOR_NTSC;
rate=chipClock/72;
}
}
int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
parent=p;
dumpWrites=false;
skipRegisterWrites=false;
for (int i=0; i<20; i++) {
isMuted[i]=false;
}
setFlags(flags);
reset();
return 10;
}
void DivPlatformOPL::quit() {
}
DivPlatformOPL::~DivPlatformOPL() {
}

121
src/engine/platform/opl.h Normal file
View File

@ -0,0 +1,121 @@
/**
* 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 _OPL_H
#define _OPL_H
#include "../dispatch.h"
#include "../macroInt.h"
#include <queue>
#include "../../../extern/Nuked-OPL3/opl3.h"
class DivPlatformOPL: public DivDispatch {
protected:
struct Channel {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
int vol, outVol;
unsigned char pan;
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
furnaceDac(false),
inPorta(false),
vol(0),
pan(3) {}
};
Channel chan[20];
bool isMuted[20];
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;
opl3_chip fm;
const unsigned char** slotsNonDrums;
const unsigned char** slotsDrums;
const unsigned char** slots;
const unsigned short* chanMap;
double chipFreqBase;
int delay, oplType;
unsigned char lastBusy;
unsigned char regPool[512];
bool properDrums, properDrumsSys;
unsigned char lfoValue;
bool useYMFM;
short oldWrites[512];
short pendingWrites[512];
int octave(int freq);
int toFreq(int freq);
friend void putDispatchChan(void*,int,int);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
//void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();
void forceIns();
void tick();
void muteChannel(int ch, bool mute);
bool isStereo();
void setYMFM(bool use);
void setOPLType(int type, bool drums);
bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch);
void toggleRegisterDump(bool enable);
void setFlags(unsigned int flags);
void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int getPortaFloor(int ch);
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char* getEffectName(unsigned char effect);
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformOPL();
};
#endif

View File

@ -29,47 +29,31 @@
const char* DivPlatformOPLL::getEffectName(unsigned char effect) {
switch (effect) {
case 0x10:
return "10xy: Setup LFO (x: enable; y: speed)";
break;
case 0x11:
return "11xx: Set feedback (0 to 7)";
break;
case 0x12:
return "12xx: Set level of operator 1 (0 highest, 7F lowest)";
return "12xx: Set level of operator 1 (0 highest, 3F lowest)";
break;
case 0x13:
return "13xx: Set level of operator 2 (0 highest, 7F lowest)";
break;
case 0x14:
return "14xx: Set level of operator 3 (0 highest, 7F lowest)";
break;
case 0x15:
return "15xx: Set level of operator 4 (0 highest, 7F lowest)";
return "13xx: Set level of operator 2 (0 highest, F lowest)";
break;
case 0x16:
return "16xy: Set operator multiplier (x: operator from 1 to 4; y: multiplier)";
break;
case 0x17:
return "17xx: Enable channel 6 DAC";
return "16xy: Set operator multiplier (x: operator from 1 to 2; y: multiplier)";
break;
case 0x18:
return "18xx: Toggle extended channel 3 mode";
if (properDrumsSys) {
return "18xx: Toggle drums mode (1: enabled; 0: disabled)";
}
break;
case 0x19:
return "19xx: Set attack of all operators (0 to 1F)";
return "19xx: Set attack of all operators (0 to F)";
break;
case 0x1a:
return "1Axx: Set attack of operator 1 (0 to 1F)";
return "1Axx: Set attack of operator 1 (0 to F)";
break;
case 0x1b:
return "1Bxx: Set attack of operator 2 (0 to 1F)";
break;
case 0x1c:
return "1Cxx: Set attack of operator 3 (0 to 1F)";
break;
case 0x1d:
return "1Dxx: Set attack of operator 4 (0 to 1F)";
return "1Bxx: Set attack of operator 2 (0 to F)";
break;
}
return NULL;
@ -133,7 +117,9 @@ void DivPlatformOPLL::tick() {
if (chan[i].std.hadVol) {
chan[i].outVol=(chan[i].vol*MIN(15,chan[i].std.vol))/15;
rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4));
if (i<9) {
rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4));
}
}
if (chan[i].std.hadArp) {
@ -159,15 +145,15 @@ void DivPlatformOPLL::tick() {
}
if (chan[i].std.hadFb) {
chan[i].state.fb=chan[i].std.fb;
rWrite(0x03,(chan[i].state.op[0].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
}
if (chan[i].std.hadFms) {
chan[i].state.fms=chan[i].std.fms;
rWrite(0x03,(chan[i].state.op[0].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
}
if (chan[i].std.hadAms) {
chan[i].state.ams=chan[i].std.ams;
rWrite(0x03,(chan[i].state.op[0].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
}
for (int j=0; j<2; j++) {
@ -201,9 +187,11 @@ void DivPlatformOPLL::tick() {
if (m.hadTl) {
op.tl=((j==1)?15:63)-m.tl;
if (j==1) {
rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4));
if (i<9) {
rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4));
}
} else {
rWrite(0x02,(chan[i].state.op[1].ksl<<6)|(op.tl&63));
rWrite(0x02,(chan[i].state.op[0].ksl<<6)|(op.tl&63));
}
}
@ -214,9 +202,9 @@ void DivPlatformOPLL::tick() {
if (m.hadKsl) {
op.ksl=m.ksl;
if (j==1) {
rWrite(0x02,(op.ksl<<6)|(chan[i].state.op[0].tl&63));
rWrite(0x02,(chan[i].state.op[0].ksl<<6)|(chan[i].state.op[0].tl&63));
} else {
rWrite(0x03,(chan[i].state.op[0].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
}
}
if (m.hadKsr) {
@ -238,7 +226,9 @@ void DivPlatformOPLL::tick() {
drumState&=~(0x10>>(chan[i].note%12));
immWrite(0x0e,0x20|drumState);
} else {
immWrite(0x20+i,(chan[i].freqH)/*|(chan[i].state.alg?0x20:0)*/);
if (i<9) {
immWrite(0x20+i,(chan[i].freqH)|(chan[i].state.alg?0x20:0));
}
}
//chan[i].keyOn=false;
chan[i].keyOff=false;
@ -257,21 +247,23 @@ void DivPlatformOPLL::tick() {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
if (chan[i].freq>262143) chan[i].freq=262143;
int freqt=toFreq(chan[i].freq);
chan[i].freqH=freqt>>8;
chan[i].freqL=freqt&0xff;
if (i>=6 && properDrums) {
immWrite(0x10+drumSlot[i],freqt&0xff);
immWrite(0x20+drumSlot[i],freqt>>8);
} else if (i<6 || !drums) {
immWrite(0x10+i,freqt&0xff);
if (i<9) {
immWrite(0x10+i,freqt&0xff);
}
}
chan[i].freqH=freqt>>8;
}
if (chan[i].keyOn && i>=6 && properDrums) {
if (!isMuted[i]) {
drumState|=(0x10>>(i-6));
immWrite(0x0e,0x20|drumState);
}
chan[i].keyOn=false;
chan[i].keyOn=false;
} else if (chan[i].keyOn && i>=6 && drums) {
//printf("%d\n",chan[i].note%12);
drumState|=(0x10>>(chan[i].note%12));
@ -279,7 +271,11 @@ void DivPlatformOPLL::tick() {
chan[i].keyOn=false;
} else if ((chan[i].keyOn || chan[i].freqChanged) && i<9) {
//immWrite(0x28,0xf0|konOffs[i]);
immWrite(0x20+i,(chan[i].freqH)|(chan[i].active<<4)|(chan[i].state.alg?0x20:0));
if (!(i>=6 && properDrums)) {
if (i<9) {
immWrite(0x20+i,(chan[i].freqH)|(chan[i].active<<4)|(chan[i].state.alg?0x20:0));
}
}
chan[i].keyOn=false;
}
chan[i].freqChanged=false;
@ -365,7 +361,24 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
if (c.chan>=6 && properDrums) { // drums mode
chan[c.chan].insChanged=false;
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
if (chan[c.chan].state.opllPreset==16 && chan[c.chan].state.fixedDrums) {
switch (c.chan) {
case 6:
chan[c.chan].baseFreq=(chan[c.chan].state.kickFreq&511)<<(chan[c.chan].state.kickFreq>>9);
break;
case 7: case 10:
chan[c.chan].baseFreq=(chan[c.chan].state.snareHatFreq&511)<<(chan[c.chan].state.snareHatFreq>>9);
break;
case 8: case 9:
chan[c.chan].baseFreq=(chan[c.chan].state.tomTopFreq&511)<<(chan[c.chan].state.tomTopFreq>>9);
break;
default:
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
break;
}
} else {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
}
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
}
@ -381,8 +394,8 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
DivInstrumentFM::Operator& car=chan[c.chan].state.op[1];
rWrite(0x00,(mod.am<<7)|(mod.vib<<6)|((mod.ssgEnv&8)<<2)|(mod.ksr<<4)|(mod.mult));
rWrite(0x01,(car.am<<7)|(car.vib<<6)|((car.ssgEnv&8)<<2)|(car.ksr<<4)|(car.mult));
rWrite(0x02,(car.ksl<<6)|(mod.tl&63));
rWrite(0x03,(mod.ksl<<6)|((chan[c.chan].state.fms&1)<<4)|((chan[c.chan].state.ams&1)<<3)|chan[c.chan].state.fb);
rWrite(0x02,(mod.ksl<<6)|(mod.tl&63));
rWrite(0x03,(car.ksl<<6)|((chan[c.chan].state.fms&1)<<4)|((chan[c.chan].state.ams&1)<<3)|chan[c.chan].state.fb);
rWrite(0x04,(mod.ar<<4)|(mod.dr));
rWrite(0x05,(car.ar<<4)|(car.dr));
rWrite(0x06,(mod.sl<<4)|(mod.rr));
@ -410,7 +423,9 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
immWrite(0x0e,0);
}
}
rWrite(0x30+c.chan,((15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)&15)|(chan[c.chan].state.opllPreset<<4));
if (c.chan<9) {
rWrite(0x30+c.chan,((15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)&15)|(chan[c.chan].state.opllPreset<<4));
}
}
}
@ -471,15 +486,16 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
if (!chan[c.chan].std.hasVol) {
chan[c.chan].outVol=c.value;
}
if (c.chan>=6 || properDrums) {
if (c.chan>=6 && properDrums) {
drumVol[c.chan-6]=15-chan[c.chan].outVol;
rWrite(0x36,drumVol[0]);
rWrite(0x37,drumVol[1]|(drumVol[4]<<4));
rWrite(0x38,drumVol[3]|(drumVol[2]<<4));
break;
}
if (c.chan<6 || !drums) {
rWrite(0x30+c.chan,((15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)&15)|(chan[c.chan].state.opllPreset<<4));
} else if (c.chan<6 || !drums) {
if (c.chan<9) {
rWrite(0x30+c.chan,((15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)&15)|(chan[c.chan].state.opllPreset<<4));
}
}
break;
}
@ -541,10 +557,10 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
}
case DIV_CMD_FM_FB: {
if (c.chan>=9 && !properDrums) return 0;
DivInstrumentFM::Operator& mod=chan[c.chan].state.op[0];
//DivInstrumentFM::Operator& car=chan[c.chan].state.op[1];
//DivInstrumentFM::Operator& mod=chan[c.chan].state.op[0];
DivInstrumentFM::Operator& car=chan[c.chan].state.op[1];
chan[c.chan].state.fb=c.value&7;
rWrite(0x03,(mod.ksl<<6)|((chan[c.chan].state.fms&1)<<4)|((chan[c.chan].state.ams&1)<<3)|chan[c.chan].state.fb);
rWrite(0x03,(car.ksl<<6)|((chan[c.chan].state.fms&1)<<4)|((chan[c.chan].state.ams&1)<<3)|chan[c.chan].state.fb);
break;
}
@ -565,13 +581,15 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
if (c.chan>=9 && !properDrums) return 0;
if (c.value==0) {
DivInstrumentFM::Operator& mod=chan[c.chan].state.op[0];
DivInstrumentFM::Operator& car=chan[c.chan].state.op[1];
//DivInstrumentFM::Operator& car=chan[c.chan].state.op[1];
mod.tl=c.value2&63;
rWrite(0x02,(car.ksl<<6)|(mod.tl&63));
rWrite(0x02,(mod.ksl<<6)|(mod.tl&63));
} else {
DivInstrumentFM::Operator& car=chan[c.chan].state.op[1];
car.tl=c.value2&15;
rWrite(0x30+c.chan,((15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)&15)|(chan[c.chan].state.opllPreset<<4));
if (c.chan<9) {
rWrite(0x30+c.chan,((15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)&15)|(chan[c.chan].state.opllPreset<<4));
}
}
break;
}
@ -632,14 +650,16 @@ void DivPlatformOPLL::forceIns() {
DivInstrumentFM::Operator& car=chan[i].state.op[1];
rWrite(0x00,(mod.am<<7)|(mod.vib<<6)|((mod.ssgEnv&8)<<2)|(mod.ksr<<4)|(mod.mult));
rWrite(0x01,(car.am<<7)|(car.vib<<6)|((car.ssgEnv&8)<<2)|(car.ksr<<4)|(car.mult));
rWrite(0x02,(car.ksl<<6)|(mod.tl&63));
rWrite(0x03,(mod.ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
rWrite(0x02,(mod.ksl<<6)|(mod.tl&63));
rWrite(0x03,(car.ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb);
rWrite(0x04,(mod.ar<<4)|(mod.dr));
rWrite(0x05,(car.ar<<4)|(car.dr));
rWrite(0x06,(mod.sl<<4)|(mod.rr));
rWrite(0x07,(car.sl<<4)|(car.rr));
}
rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4));
if (i<9) {
rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4));
}
if (!(i>=6 && properDrums)) {
if (chan[i].active) {
chan[i].keyOn=true;

View File

@ -162,6 +162,13 @@ void DivPlatformPCE::tick() {
chWrite(i,0x04,0x80|chan[i].outVol);
}
}
if (chan[i].std.hadDuty && i>=4) {
chan[i].noise=chan[i].std.duty;
chan[i].freqChanged=true;
int noiseSeek=chan[i].note;
if (noiseSeek<0) noiseSeek=0;
chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0);
}
if (chan[i].std.hadArp) {
if (!chan[i].inPorta) {
if (chan[i].std.arpMode) {

View File

@ -0,0 +1,413 @@
/**
* 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 "pcspkr.h"
#include "../engine.h"
#include <math.h>
#ifdef __linux__
#include <sys/ioctl.h>
#include <sys/select.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/kd.h>
#endif
#define PCSPKR_DIVIDER 4
#define CHIP_DIVIDER 1
const char* regCheatSheetPCSpeaker[]={
"Period", "0",
NULL
};
const char** DivPlatformPCSpeaker::getRegisterSheet() {
return regCheatSheetPCSpeaker;
}
const char* DivPlatformPCSpeaker::getEffectName(unsigned char effect) {
return NULL;
}
const float cut=0.05;
const float reso=0.06;
void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
while (pos<0) {
if (freq<1) {
pos=1;
} else {
pos+=freq;
}
}
bufL[i]=(pos>(freq>>1) && !isMuted[0])?32767:0;
} else {
bufL[i]=0;
}
}
}
void DivPlatformPCSpeaker::acquire_cone(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
while (pos<0) {
if (freq<1) {
pos=1;
} else {
pos+=freq;
}
}
float next=(pos>((freq+16)>>1) && !isMuted[0])?1:0;
low+=0.04*band;
band+=0.04*(next-low-band);
float out=(low+band)*0.75;
if (out>1.0) out=1.0;
if (out<-1.0) out=-1.0;
bufL[i]=out*32767;
} else {
bufL[i]=0;
}
}
}
void DivPlatformPCSpeaker::acquire_piezo(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
while (pos<0) {
if (freq<1) {
pos=1;
} else {
pos+=freq;
}
}
float next=(pos>((freq+64)>>1) && !isMuted[0])?1:0;
low+=cut*band;
band+=cut*(next-low-(reso*band));
float out=band*0.15-(next-low)*0.06;
if (out>1.0) out=1.0;
if (out<-1.0) out=-1.0;
bufL[i]=out*32767;
} else {
bufL[i]=0;
}
}
}
void DivPlatformPCSpeaker::beepFreq(int freq) {
#ifdef __linux__
static struct input_event ie;
if (beepFD>=0) {
gettimeofday(&ie.time,NULL);
ie.type=EV_SND;
ie.code=SND_TONE;
if (freq>0) {
ie.value=chipClock/freq;
} else {
ie.value=0;
}
if (write(beepFD,&ie,sizeof(struct input_event))<0) {
perror("error while writing frequency!");
} else {
//printf("writing freq: %d\n",freq);
}
}
#endif
}
void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start, size_t len) {
if (lastOn!=on || lastFreq!=freq) {
lastOn=on;
lastFreq=freq;
beepFreq((on && !isMuted[0])?freq:0);
}
for (size_t i=start; i<start+len; i++) {
bufL[i]=0;
}
}
void DivPlatformPCSpeaker::acquire(short* bufL, short* bufR, size_t start, size_t len) {
switch (speakerType) {
case 0:
acquire_unfilt(bufL,bufR,start,len);
break;
case 1:
acquire_cone(bufL,bufR,start,len);
break;
case 2:
acquire_piezo(bufL,bufR,start,len);
break;
case 3:
acquire_real(bufL,bufR,start,len);
break;
}
}
void DivPlatformPCSpeaker::tick() {
for (int i=0; i<1; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
// ok, why are the volumes like that?
chan[i].outVol=chan[i].vol;
}
if (chan[i].std.hadArp) {
if (!chan[i].inPorta) {
if (chan[i].std.arpMode) {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp);
} else {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp);
}
}
chan[i].freqChanged=true;
} else {
if (chan[i].std.arpMode && chan[i].std.finishedArp) {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note);
chan[i].freqChanged=true;
}
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1;
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
if (chan[i].keyOn) {
on=true;
}
if (chan[i].keyOff) {
on=false;
}
freq=chan[i].freq;
if (chan[i].keyOn) chan[i].keyOn=false;
if (chan[i].keyOff) chan[i].keyOff=false;
chan[i].freqChanged=false;
}
}
}
int DivPlatformPCSpeaker::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON:
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
}
chan[c.chan].active=true;
chan[c.chan].keyOn=true;
chan[c.chan].std.init(parent->getIns(chan[c.chan].ins));
break;
case DIV_CMD_NOTE_OFF:
chan[c.chan].active=false;
chan[c.chan].keyOff=true;
chan[c.chan].std.init(NULL);
break;
case DIV_CMD_NOTE_OFF_ENV:
case DIV_CMD_ENV_RELEASE:
chan[c.chan].std.release();
break;
case DIV_CMD_INSTRUMENT:
if (chan[c.chan].ins!=c.value || c.value2==1) {
chan[c.chan].ins=c.value;
}
break;
case DIV_CMD_VOLUME:
if (chan[c.chan].vol!=c.value) {
chan[c.chan].vol=c.value;
if (!chan[c.chan].std.hasVol) {
chan[c.chan].outVol=c.value;
}
if (chan[c.chan].active) {
on=chan[c.chan].vol;
}
}
break;
case DIV_CMD_GET_VOLUME:
return chan[c.chan].vol;
break;
case DIV_CMD_PITCH:
chan[c.chan].pitch=c.value;
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_PERIODIC(c.value2);
bool return2=false;
if (destFreq>chan[c.chan].baseFreq) {
chan[c.chan].baseFreq+=c.value;
if (chan[c.chan].baseFreq>=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
} else {
chan[c.chan].baseFreq-=c.value;
if (chan[c.chan].baseFreq<=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
}
chan[c.chan].freqChanged=true;
if (return2) {
chan[c.chan].inPorta=false;
return 2;
}
break;
}
case DIV_CMD_LEGATO:
if (c.chan==3) break;
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0)));
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
break;
case DIV_CMD_PRE_PORTA:
if (chan[c.chan].active && c.value2) {
if (parent->song.resetMacroOnPorta) chan[c.chan].std.init(parent->getIns(chan[c.chan].ins));
}
chan[c.chan].inPorta=c.value;
break;
case DIV_CMD_GET_VOLMAX:
return 1;
break;
case DIV_ALWAYS_SET_VOLUME:
return 1;
break;
default:
break;
}
return 1;
}
void DivPlatformPCSpeaker::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
}
void DivPlatformPCSpeaker::forceIns() {
for (int i=0; i<1; i++) {
chan[i].insChanged=true;
}
}
void* DivPlatformPCSpeaker::getChanState(int ch) {
return &chan[ch];
}
unsigned char* DivPlatformPCSpeaker::getRegisterPool() {
if (on) {
regPool[0]=freq;
regPool[1]=freq>>8;
} else {
regPool[0]=0;
regPool[1]=0;
}
return regPool;
}
int DivPlatformPCSpeaker::getRegisterPoolSize() {
return 2;
}
void DivPlatformPCSpeaker::reset() {
for (int i=0; i<1; i++) {
chan[i]=DivPlatformPCSpeaker::Channel();
}
if (dumpWrites) {
addWrite(0xffffffff,0);
}
on=false;
lastOn=false;
freq=0;
lastFreq=0;
pos=0;
flip=false;
low=0;
band=0;
if (speakerType==3) {
#ifdef __linux__
if (beepFD==-1) {
beepFD=open("/dev/input/by-path/platform-pcspkr-event-spkr",O_WRONLY);
if (beepFD<0) {
perror("error while opening PC speaker");
}
}
#endif
beepFreq(0);
} else {
beepFreq(0);
}
memset(regPool,0,2);
}
bool DivPlatformPCSpeaker::keyOffAffectsArp(int ch) {
return true;
}
void DivPlatformPCSpeaker::setFlags(unsigned int flags) {
chipClock=COLOR_NTSC/3.0;
rate=chipClock/PCSPKR_DIVIDER;
speakerType=flags&3;
}
void DivPlatformPCSpeaker::notifyInsDeletion(void* ins) {
for (int i=0; i<1; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
void DivPlatformPCSpeaker::notifyPlaybackStop() {
beepFreq(0);
}
void DivPlatformPCSpeaker::poke(unsigned int addr, unsigned short val) {
// ???
}
void DivPlatformPCSpeaker::poke(std::vector<DivRegWrite>& wlist) {
// ???
}
int DivPlatformPCSpeaker::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
parent=p;
dumpWrites=false;
skipRegisterWrites=false;
beepFD=-1;
for (int i=0; i<1; i++) {
isMuted[i]=false;
}
setFlags(flags);
reset();
return 5;
}
void DivPlatformPCSpeaker::quit() {
if (speakerType==3) {
beepFreq(0);
}
#ifdef __linux__
if (beepFD>=0) close(beepFD);
#endif
}
DivPlatformPCSpeaker::~DivPlatformPCSpeaker() {
}

View File

@ -0,0 +1,95 @@
/**
* 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 _PCSPKR_H
#define _PCSPKR_H
#include "../dispatch.h"
#include "../macroInt.h"
class DivPlatformPCSpeaker: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;
Channel():
freq(0),
baseFreq(0),
pitch(0),
note(0),
ins(-1),
duty(0),
sweep(8),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
furnaceDac(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[1];
bool isMuted[1];
bool on, flip, lastOn;
int pos, speakerType, beepFD;
float low, band;
float low2, high2, band2;
float low3, band3;
unsigned short freq, lastFreq;
unsigned char regPool[2];
friend void putDispatchChan(void*,int,int);
void beepFreq(int freq);
void acquire_unfilt(short* bufL, short* bufR, size_t start, size_t len);
void acquire_cone(short* bufL, short* bufR, size_t start, size_t len);
void acquire_piezo(short* bufL, short* bufR, size_t start, size_t len);
void acquire_real(short* bufL, short* bufR, size_t start, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();
void forceIns();
void tick();
void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch);
void setFlags(unsigned int flags);
void notifyInsDeletion(void* ins);
void notifyPlaybackStop();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();
const char* getEffectName(unsigned char effect);
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformPCSpeaker();
};
#endif

View File

@ -157,12 +157,6 @@ void PCE_PSG::RecalcUOFunc(int chnum)
//printf("UO Update: %d, %02x\n", chnum, ch->control);
// what is this?
if (lfoctrl&3 && chnum==1) {
ch->UpdateOutput = &PCE_PSG::UpdateOutput_Off;
return;
}
if((revision != REVISION_HUC6280 && !(ch->control & 0xC0)) || (revision == REVISION_HUC6280 && !(ch->control & 0x80)))
ch->UpdateOutput = &PCE_PSG::UpdateOutput_Off;
else if(ch->noisectrl & ch->control & 0x80)

View File

@ -0,0 +1,409 @@
/******************************************************************************/
/* Mednafen - Multi-system Emulator */
/******************************************************************************/
/* sound.cpp - WonderSwan Sound Emulation
** Copyright (C) 2007-2017 Mednafen Team
** Copyright (C) 2016 Alex 'trap15' Marshall - http://daifukkat.su/
**
** 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 "swan.h"
#include <string.h>
#define MK_SAMPLE_CACHE \
{ \
int sample; \
sample = (((wsRAM[(/*(SampleRAMPos << 6) + */(sample_pos[ch] >> 1) + (ch << 4)) ] >> ((sample_pos[ch] & 1) ? 4 : 0)) & 0x0F)); \
sample_cache[ch][0] = sample * ((volume[ch] >> 4) & 0x0F); \
sample_cache[ch][1] = sample * ((volume[ch] >> 0) & 0x0F); \
}
#define MK_SAMPLE_CACHE_NOISE \
{ \
int sample; \
sample = ((nreg & 1) ? 0xF : 0x0); \
sample_cache[ch][0] = sample * ((volume[ch] >> 4) & 0x0F); \
sample_cache[ch][1] = sample * ((volume[ch] >> 0) & 0x0F); \
}
#define MK_SAMPLE_CACHE_VOICE \
{ \
int sample, half; \
sample = volume[ch]; \
half = sample >> 1; \
sample_cache[ch][0] = (voice_volume & 4) ? sample : (voice_volume & 8) ? half : 0; \
sample_cache[ch][1] = (voice_volume & 1) ? sample : (voice_volume & 2) ? half : 0; \
}
#define SYNCSAMPLE(wt) /* \
{ \
int32_t left = sample_cache[ch][0], right = sample_cache[ch][1]; \
WaveSynth.offset_inline(wt, left - last_val[ch][0], sbuf[0]); \
WaveSynth.offset_inline(wt, right - last_val[ch][1], sbuf[1]); \
last_val[ch][0] = left; \
last_val[ch][1] = right; \
} */
#define SYNCSAMPLE_NOISE(wt) SYNCSAMPLE(wt)
void WSwan::SoundUpdate(uint32_t v30mz_timestamp)
{
int32_t run_time;
//printf("%d\n", v30mz_timestamp);
//printf("%02x %02x\n", control, noise_control);
run_time = v30mz_timestamp - last_ts;
for(int y = 0; y < 2; y++)
sbuf[y] = 0;
for(unsigned int ch = 0; ch < 4; ch++)
{
// Channel is disabled?
if(!(control & (1 << ch)))
continue;
if(ch == 1 && (control & 0x20)) // Direct D/A mode?
{
MK_SAMPLE_CACHE_VOICE;
SYNCSAMPLE(v30mz_timestamp);
}
else if(ch == 2 && (control & 0x40) && sweep_value) // Sweep
{
uint32_t tmp_pt = 2048 - period[ch];
uint32_t tmp_run_time = run_time;
while(tmp_run_time)
{
int32_t sub_run_time = tmp_run_time;
if(sub_run_time > sweep_8192_divider)
sub_run_time = sweep_8192_divider;
sweep_8192_divider -= sub_run_time;
if(sweep_8192_divider <= 0)
{
sweep_8192_divider += 8192;
sweep_counter--;
if(sweep_counter <= 0)
{
sweep_counter = sweep_step + 1;
period[ch] = (period[ch] + (int8_t)sweep_value) & 0x7FF;
}
}
if(tmp_pt > 4)
{
period_counter[ch] -= sub_run_time;
while(period_counter[ch] <= 0)
{
sample_pos[ch] = (sample_pos[ch] + 1) & 0x1F;
MK_SAMPLE_CACHE;
period_counter[ch] += tmp_pt;
}
}
tmp_run_time -= sub_run_time;
}
}
else if(ch == 3 && (control & 0x80) && (noise_control & 0x10)) // Noise
{
uint32_t tmp_pt = 2048 - period[ch];
period_counter[ch] -= run_time;
while(period_counter[ch] <= 0)
{
static const uint8_t stab[8] = { 14, 10, 13, 4, 8, 6, 9, 11 };
nreg = ((nreg << 1) | ((1 ^ (nreg >> 7) ^ (nreg >> stab[noise_control & 0x7])) & 1)) & 0x7FFF;
if(control & 0x80)
{
MK_SAMPLE_CACHE_NOISE;
SYNCSAMPLE_NOISE(v30mz_timestamp + period_counter[ch]);
}
else if(tmp_pt > 4)
{
sample_pos[ch] = (sample_pos[ch] + 1) & 0x1F;
MK_SAMPLE_CACHE;
SYNCSAMPLE(v30mz_timestamp + period_counter[ch]);
}
period_counter[ch] += tmp_pt;
}
}
else
{
uint32_t tmp_pt = 2048 - period[ch];
if(tmp_pt > 4)
{
period_counter[ch] -= run_time;
while(period_counter[ch] <= 0)
{
sample_pos[ch] = (sample_pos[ch] + 1) & 0x1F;
MK_SAMPLE_CACHE;
SYNCSAMPLE(v30mz_timestamp + period_counter[ch]); // - period_counter[ch]);
period_counter[ch] += tmp_pt;
}
}
}
sbuf[0] += sample_cache[ch][0];
sbuf[1] += sample_cache[ch][1];
}
if(HVoiceCtrl & 0x80)
{
int16_t sample = (uint8_t)HyperVoice;
switch(HVoiceCtrl & 0xC)
{
case 0x0: sample = (uint16_t)sample << (8 - (HVoiceCtrl & 3)); break;
case 0x4: sample = (uint16_t)(sample | -0x100) << (8 - (HVoiceCtrl & 3)); break;
case 0x8: sample = (uint16_t)((int8_t)sample) << (8 - (HVoiceCtrl & 3)); break;
case 0xC: sample = (uint16_t)sample << 8; break;
}
// bring back to 11bit, keeping signedness
sample >>= 5;
int32_t left, right;
left = (HVoiceChanCtrl & 0x40) ? sample : 0;
right = (HVoiceChanCtrl & 0x20) ? sample : 0;
// WaveSynth.offset_inline(v30mz_timestamp, left - last_hv_val[0], sbuf[0]);
// WaveSynth.offset_inline(v30mz_timestamp, right - last_hv_val[1], sbuf[1]);
// last_hv_val[0] = left;
// last_hv_val[1] = right;
sbuf[0] += left;
sbuf[1] += right;
}
last_ts = v30mz_timestamp;
}
void WSwan::SoundWrite(uint32_t A, uint8_t V)
{
if(A >= 0x80 && A <= 0x87)
{
int ch = (A - 0x80) >> 1;
if(A & 1)
period[ch] = (period[ch] & 0x00FF) | ((V & 0x07) << 8);
else
period[ch] = (period[ch] & 0x0700) | ((V & 0xFF) << 0);
//printf("Period %d: 0x%04x --- %f\n", ch, period[ch], 3072000.0 / (2048 - period[ch]));
}
else if(A >= 0x88 && A <= 0x8B)
{
volume[A - 0x88] = V;
}
else if(A == 0x8C)
sweep_value = V;
else if(A == 0x8D)
{
sweep_step = V;
sweep_counter = sweep_step + 1;
sweep_8192_divider = 8192;
}
else if(A == 0x8E)
{
//printf("NOISECONTROL: %02x\n", V);
if(V & 0x8)
nreg = 0;
noise_control = V & 0x17;
}
else if(A == 0x90)
{
for(int n = 0; n < 4; n++)
{
if(!(control & (1 << n)) && (V & (1 << n)))
{
period_counter[n] = 1;
sample_pos[n] = 0x1F;
}
}
control = V;
//printf("Sound Control: %02x\n", V);
}
else if(A == 0x91)
{
output_control = V & 0xF;
//printf("%02x, %02x\n", V, (V >> 1) & 3);
}
else if(A == 0x92)
nreg = (nreg & 0xFF00) | (V << 0);
else if(A == 0x93)
nreg = (nreg & 0x00FF) | ((V & 0x7F) << 8);
else if(A == 0x94)
{
voice_volume = V & 0xF;
//printf("%02x\n", V);
}
else switch(A)
{
case 0x6A: HVoiceCtrl = V; break;
case 0x6B: HVoiceChanCtrl = V & 0x6F; break;
case 0x8F: SampleRAMPos = V; break;
case 0x95: HyperVoice = V; break; // Pick a port, any port?!
//default: printf("%04x:%02x\n", A, V); break;
}
}
uint8_t WSwan::SoundRead(uint32_t A)
{
if(A >= 0x80 && A <= 0x87)
{
int ch = (A - 0x80) >> 1;
if(A & 1)
return(period[ch] >> 8);
else
return(period[ch]);
}
else if(A >= 0x88 && A <= 0x8B)
return(volume[A - 0x88]);
else switch(A)
{
default: /*printf("SoundRead: %04x\n", A);*/ return(0);
case 0x6A: return(HVoiceCtrl);
case 0x6B: return(HVoiceChanCtrl);
case 0x8C: return(sweep_value);
case 0x8D: return(sweep_step);
case 0x8E: return(noise_control);
case 0x8F: return(SampleRAMPos);
case 0x90: return(control);
case 0x91: return(output_control | 0x80);
case 0x92: return((nreg >> 0) & 0xFF);
case 0x93: return((nreg >> 8) & 0xFF);
case 0x94: return(voice_volume);
}
}
void WSwan::RAMWrite(uint32_t A, uint8_t V)
{
wsRAM[A & 0x3F] = V;
}
int32_t WSwan::SoundFlush(int16_t *SoundBuf, const int32_t MaxSoundFrames)
{
int32_t FrameCount = 0;
if(SoundBuf)
{
for(int y = 0; y < 2; y++)
{
// sbuf[y]->end_frame(v30mz_timestamp);
// FrameCount = sbuf[y]->read_samples(SoundBuf + y, MaxSoundFrames, true);
int32_t left = sbuf[0];
int32_t right = sbuf[1];
if (left >= 0x400) left = 0x3FF;
else if (left < -0x400) left = -0x400;
if (right >= 0x400) left = 0x3FF;
else if (right < -0x400) left = -0x400;
SoundBuf[0] = (int16_t)left << 5;
SoundBuf[1] = (int16_t)right << 5;
}
}
last_ts = 0;
return(FrameCount);
}
// Call before wsRAM is updated
// void WSwan::SoundCheckRAMWrite(uint32_t A)
// {
// if((A >> 6) == SampleRAMPos)
// SoundUpdate();
// }
// static void RedoVolume(void)
// {
// WaveSynth.volume(2.5);
// }
// void WSwan::SoundInit(void)
// {
// for(int i = 0; i < 2; i++)
// {
// sbuf[i] = new Blip_Buffer();
// sbuf[i]->set_sample_rate(0 ? 0 : 44100, 60);
// sbuf[i]->clock_rate((long)(3072000));
// sbuf[i]->bass_freq(20);
// }
// RedoVolume();
// }
// void WSwan::SoundKill(void)
// {
// for(int i = 0; i < 2; i++)
// {
// if(sbuf[i])
// {
// delete sbuf[i];
// sbuf[i] = NULL;
// }
// }
// }
// bool WSwan::SetSoundRate(uint32_t rate)
// {
// for(int i = 0; i < 2; i++)
// sbuf[i]->set_sample_rate(rate?rate:44100, 60);
// return(true);
// }
void WSwan::SoundReset(void)
{
memset(period, 0, sizeof(period));
memset(volume, 0, sizeof(volume));
voice_volume = 0;
sweep_step = 0;
sweep_value = 0;
noise_control = 0;
control = 0;
output_control = 0;
sweep_8192_divider = 8192;
sweep_counter = 1;
SampleRAMPos = 0;
for(unsigned ch = 0; ch < 4; ch++)
period_counter[ch] = 1;
memset(sample_pos, 0, sizeof(sample_pos));
nreg = 0;
memset(sample_cache, 0, sizeof(sample_cache));
// memset(last_val, 0, sizeof(last_val));
last_v_val = 0;
HyperVoice = 0;
last_hv_val[0] = last_hv_val[1] = 0;
HVoiceCtrl = 0;
HVoiceChanCtrl = 0;
for(int y = 0; y < 2; y++)
// sbuf[y]->clear();
sbuf[y] = 0;
last_ts = 0;
}

View File

@ -0,0 +1,81 @@
/******************************************************************************/
/* Mednafen - Multi-system Emulator */
/******************************************************************************/
/* sound.h - WonderSwan Sound Emulation
** Copyright (C) 2007-2016 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __WSWAN_SOUND_H
#define __WSWAN_SOUND_H
#include <stdint.h>
class WSwan
{
public:
int32_t SoundFlush(int16_t *SoundBuf, const int32_t MaxSoundFrames);
// void SoundInit(void);
// void SoundKill(void);
// void SetSoundMultiplier(double multiplier);
// bool SetSoundRate(uint32_t rate);
void SoundWrite(uint32_t, uint8_t);
uint8_t SoundRead(uint32_t);
void SoundReset(void);
// void SoundCheckRAMWrite(uint32_t A);
void SoundUpdate(uint32_t);
void RAMWrite(uint32_t, uint8_t);
private:
// Blip_Synth<blip_good_quality, 4096> WaveSynth;
// Blip_Buffer *sbuf[2] = { NULL };
int32_t sbuf[2];
uint16_t period[4];
uint8_t volume[4]; // left volume in upper 4 bits, right in lower 4 bits
uint8_t voice_volume;
uint8_t sweep_step, sweep_value;
uint8_t noise_control;
uint8_t control;
uint8_t output_control;
int32_t sweep_8192_divider;
uint8_t sweep_counter;
uint8_t SampleRAMPos;
int32_t sample_cache[4][2];
int32_t last_v_val;
uint8_t HyperVoice;
int32_t last_hv_val[2];
uint8_t HVoiceCtrl, HVoiceChanCtrl;
int32_t period_counter[4];
// int32_t last_val[4][2]; // Last outputted value, l&r
uint8_t sample_pos[4];
uint16_t nreg;
uint32_t last_ts;
uint8_t wsRAM[64];
};
#endif

View File

@ -0,0 +1,521 @@
/**
* 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 "swan.h"
#include "../engine.h"
#include <math.h>
#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);}}
#define CHIP_DIVIDER 32
const char* regCheatSheetWS[]={
"CH1_Pitch", "00",
"CH2_Pitch", "02",
"CH3_Pitch", "04",
"CH4_Pitch", "06",
"CH1_Vol", "08",
"CH2_Vol", "09",
"CH3_Vol", "0A",
"CH4_Vol", "0B",
"Sweep_Value", "0C",
"Sweep_Time", "0D",
"Noise", "0E",
"Wave_Base", "0F",
"Ctrl", "10",
"Output", "11",
"Random", "12",
"Voice_Ctrl", "14",
"Wave_Mem", "40",
NULL
};
const char** DivPlatformSwan::getRegisterSheet() {
return regCheatSheetWS;
}
const char* DivPlatformSwan::getEffectName(unsigned char effect) {
switch (effect) {
case 0x10:
return "10xx: Change waveform";
break;
case 0x11:
return "11xx: Setup noise mode (0: disabled; 1-8: enabled/tap)";
break;
case 0x12:
return "12xx: Setup sweep period (0: disabled; 1-20: enabled/period)";
break;
case 0x13:
return "13xx: Set sweep amount";
break;
case 0x17:
return "17xx: Toggle PCM mode";
break;
}
return NULL;
}
void DivPlatformSwan::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
// PCM part
if (pcm && dacSample!=-1) {
dacPeriod+=dacRate;
while (dacPeriod>rate) {
DivSample* s=parent->getSample(dacSample);
if (s->samples<=0) {
dacSample=-1;
continue;
}
rWrite(0x09,(unsigned char)s->data8[dacPos++]+0x80);
if (dacPos>=s->samples) {
if (s->loopStart>=0 && s->loopStart<=(int)s->samples) {
dacPos=s->loopStart;
} else {
dacSample=-1;
}
}
dacPeriod-=rate;
}
}
// the rest
while (!writes.empty()) {
QueuedWrite w=writes.front();
regPool[w.addr]=w.val;
if (w.addr<0x40) ws->SoundWrite(w.addr|0x80,w.val);
else ws->RAMWrite(w.addr&0x3f,w.val);
writes.pop();
}
int16_t samp[2]{0, 0};
ws->SoundUpdate(16);
ws->SoundFlush(samp, 1);
bufL[h]=samp[0];
bufR[h]=samp[1];
}
}
void DivPlatformSwan::updateWave(int ch) {
DivWavetable* wt=parent->getWave(chan[ch].wave);
unsigned char addr=0x40+ch*16;
if (wt->max<1 || wt->len<1) {
for (int i=0; i<16; i++) {
rWrite(addr+i,0);
}
} else {
for (int i=0; i<16; i++) {
unsigned char nibble1=(wt->data[(i*2)*wt->len/32]*15)/wt->max;
unsigned char nibble2=(wt->data[(1+i*2)*wt->len/32]*15)/wt->max;
rWrite(addr+i,nibble1|(nibble2<<4));
}
}
}
void DivPlatformSwan::calcAndWriteOutVol(int ch, int env) {
int vl=chan[ch].vol*((chan[ch].pan>>4)&0x0f)*env/225;
int vr=chan[ch].vol*(chan[ch].pan&0x0f)*env/225;
if (ch==1&&pcm) {
vl=(vl>0)?((vl>7)?3:2):0;
vr=(vr>0)?((vr>7)?3:2):0;
chan[1].outVol=vr|(vl<<2);
} else {
chan[ch].outVol=vr|(vl<<4);
}
writeOutVol(ch);
}
void DivPlatformSwan::writeOutVol(int ch) {
unsigned char val=isMuted[ch]?0:chan[ch].outVol;
if (ch==1&&pcm) {
rWrite(0x14,val)
} else {
rWrite(0x08+ch,val);
}
}
void DivPlatformSwan::tick() {
unsigned char sndCtrl=(pcm?0x20:0)|(sweep?0x40:0)|((noise>0)?0x80:0);
for (int i=0; i<4; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
int env=chan[i].std.vol;
if(parent->getIns(chan[i].ins)->type==DIV_INS_AMIGA) {
env=MIN(env/4,15);
}
calcAndWriteOutVol(i,env);
}
if (chan[i].std.hadArp) {
if (!chan[i].inPorta) {
if (chan[i].std.arpMode) {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp);
} else {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp);
}
}
chan[i].freqChanged=true;
} else {
if (chan[i].std.arpMode && chan[i].std.finishedArp) {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note);
chan[i].freqChanged=true;
}
}
if (chan[i].std.hadWave && !(i==1 && pcm)) {
if (chan[i].wave!=chan[i].std.wave) {
chan[i].wave=chan[i].std.wave;
updateWave(i);
}
}
if (chan[i].active) {
sndCtrl|=(1<<i);
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
if (i==1 && pcm && furnaceDac) {
double off=1.0;
if (dacSample>=0 && dacSample<parent->song.sampleLen) {
DivSample* s=parent->getSample(dacSample);
if (s->centerRate<1) {
off=1.0;
} else {
off=8363.0/(double)s->centerRate;
}
}
dacRate=((double)chipClock/2)/MAX(1,off*chan[i].freq);
if (dumpWrites) addWrite(0xffff0001,dacRate);
}
if (chan[i].freq>2048) chan[i].freq=2048;
if (chan[i].freq<1) chan[i].freq=1;
int rVal=2048-chan[i].freq;
rWrite(i*2,rVal&0xff);
rWrite(i*2+1,rVal>>8);
if (chan[i].keyOn) {
if (!chan[i].std.willVol) {
calcAndWriteOutVol(i,15);
}
if (chan[i].wave<0) {
chan[i].wave=0;
updateWave(i);
}
chan[i].keyOn=false;
}
if (chan[i].keyOff) {
chan[i].keyOff=false;
}
chan[i].freqChanged=false;
}
}
if (chan[3].std.hadDuty) {
noise=chan[3].std.duty;
if (noise>0) {
rWrite(0x0e,((noise-1)&0x07)|0x18);
sndCtrl|=0x80;
} else {
sndCtrl&=~0x80;
}
}
rWrite(0x10,sndCtrl);
}
int DivPlatformSwan::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
if (c.chan==1) {
if (ins->type==DIV_INS_AMIGA) {
pcm=true;
} else if (furnaceDac) {
pcm=false;
}
if (pcm) {
if (skipRegisterWrites) break;
dacPos=0;
dacPeriod=0;
if (ins->type==DIV_INS_AMIGA) {
dacSample=ins->amiga.initSample;
if (dacSample<0 || dacSample>=parent->song.sampleLen) {
dacSample=-1;
if (dumpWrites) addWrite(0xffff0002,0);
break;
} else {
if (dumpWrites) {
addWrite(0xffff0000,dacSample);
}
}
if (c.value!=DIV_NOTE_NULL) {
chan[1].baseFreq=NOTE_PERIODIC(c.value);
chan[1].freqChanged=true;
chan[1].note=c.value;
}
chan[1].active=true;
chan[1].keyOn=true;
chan[1].std.init(ins);
furnaceDac=true;
} else {
if (c.value!=DIV_NOTE_NULL) {
chan[1].note=c.value;
}
dacSample=12*sampleBank+chan[1].note%12;
if (dacSample>=parent->song.sampleLen) {
dacSample=-1;
if (dumpWrites) addWrite(0xffff0002,0);
break;
} else {
if (dumpWrites) addWrite(0xffff0000,dacSample);
}
dacRate=parent->getSample(dacSample)->rate;
if (dumpWrites) {
addWrite(0xffff0001,dacRate);
}
chan[1].active=true;
chan[1].keyOn=true;
furnaceDac=false;
}
break;
}
}
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
}
chan[c.chan].active=true;
chan[c.chan].keyOn=true;
chan[c.chan].std.init(ins);
break;
}
case DIV_CMD_NOTE_OFF:
if (c.chan==1&&pcm) {
dacSample=-1;
if (dumpWrites) addWrite(0xffff0002,0);
pcm=false;
}
chan[c.chan].active=false;
chan[c.chan].keyOff=true;
chan[c.chan].std.init(NULL);
break;
case DIV_CMD_NOTE_OFF_ENV:
case DIV_CMD_ENV_RELEASE:
chan[c.chan].std.release();
break;
case DIV_CMD_INSTRUMENT:
if (chan[c.chan].ins!=c.value || c.value2==1) {
chan[c.chan].ins=c.value;
}
break;
case DIV_CMD_VOLUME:
if (chan[c.chan].vol!=c.value) {
chan[c.chan].vol=c.value;
if (!chan[c.chan].std.hadVol) {
calcAndWriteOutVol(c.chan,15);
}
}
break;
case DIV_CMD_GET_VOLUME:
return chan[c.chan].vol;
break;
case DIV_CMD_PITCH:
chan[c.chan].pitch=c.value;
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_WAVE:
chan[c.chan].wave=c.value;
updateWave(c.chan);
chan[c.chan].keyOn=true;
break;
case DIV_CMD_WS_SWEEP_TIME:
if (c.chan==2) {
if (c.value==0) {
sweep=false;
} else {
sweep=true;
rWrite(0x0d,(c.value-1)&0xff);
}
}
break;
case DIV_CMD_WS_SWEEP_AMOUNT:
if (c.chan==2) {
rWrite(0x0c,c.value&0xff);
}
break;
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_PERIODIC(c.value2);
bool return2=false;
if (destFreq>chan[c.chan].baseFreq) {
chan[c.chan].baseFreq+=c.value;
if (chan[c.chan].baseFreq>=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
} else {
chan[c.chan].baseFreq-=c.value;
if (chan[c.chan].baseFreq<=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
}
chan[c.chan].freqChanged=true;
if (return2) {
chan[c.chan].inPorta=false;
return 2;
}
break;
}
case DIV_CMD_STD_NOISE_MODE:
if (c.chan==3) {
noise=c.value&0xff;
if (noise>0) rWrite(0x0e,((noise-1)&0x07)|0x18);
}
break;
case DIV_CMD_SAMPLE_MODE:
if (c.chan==1) pcm=c.value;
break;
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_PANNING: {
chan[c.chan].pan=c.value;
calcAndWriteOutVol(c.chan,chan[c.chan].std.willVol?chan[c.chan].std.vol:15);
break;
}
case DIV_CMD_LEGATO:
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0)));
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
break;
case DIV_CMD_PRE_PORTA:
if (chan[c.chan].active && c.value2) {
if (parent->song.resetMacroOnPorta) chan[c.chan].std.init(parent->getIns(chan[c.chan].ins));
}
chan[c.chan].inPorta=c.value;
break;
case DIV_CMD_GET_VOLMAX:
return 15;
break;
case DIV_ALWAYS_SET_VOLUME:
return 1;
break;
default:
break;
}
return 1;
}
void DivPlatformSwan::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
writeOutVol(ch);
}
void DivPlatformSwan::forceIns() {
for (int i=0; i<4; i++) {
chan[i].insChanged=true;
chan[i].freqChanged=true;
updateWave(i);
writeOutVol(i);
}
}
void* DivPlatformSwan::getChanState(int ch) {
return &chan[ch];
}
unsigned char* DivPlatformSwan::getRegisterPool() {
// get Random from emulator
regPool[0x12]=ws->SoundRead(0x92);
regPool[0x13]=ws->SoundRead(0x93);
return regPool;
}
int DivPlatformSwan::getRegisterPoolSize() {
return 128;
}
void DivPlatformSwan::reset() {
while (!writes.empty()) writes.pop();
memset(regPool,0,128);
for (int i=0; i<4; i++) {
chan[i]=Channel();
chan[i].vol=15;
chan[i].pan=0xff;
rWrite(0x08+i,0xff);
}
if (dumpWrites) {
addWrite(0xffffffff,0);
}
ws->SoundReset();
pcm=false;
sweep=false;
furnaceDac=false;
noise=0;
dacPeriod=0;
dacRate=0;
dacPos=0;
dacSample=-1;
sampleBank=0;
rWrite(0x0f,0x00); // wave table at 0x0000
rWrite(0x11,0x09); // enable speakers
}
bool DivPlatformSwan::isStereo() {
return true;
}
void DivPlatformSwan::notifyWaveChange(int wave) {
for (int i=0; i<4; i++) {
if (chan[i].wave==wave) {
updateWave(i);
}
}
}
void DivPlatformSwan::notifyInsDeletion(void* ins) {
for (int i=0; i<4; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
}
}
void DivPlatformSwan::poke(unsigned int addr, unsigned short val) {
rWrite(addr,val);
}
void DivPlatformSwan::poke(std::vector<DivRegWrite>& wlist) {
for (DivRegWrite& i: wlist) rWrite(i.addr,i.val);
}
int DivPlatformSwan::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
parent=p;
dumpWrites=false;
skipRegisterWrites=false;
chipClock=3072000;
rate=chipClock/16; // = 192000kHz, should be enough
for (int i=0; i<4; i++) {
isMuted[i]=false;
}
ws=new WSwan();
reset();
return 4;
}
void DivPlatformSwan::quit() {
delete ws;
}
DivPlatformSwan::~DivPlatformSwan() {
}

View File

@ -0,0 +1,95 @@
/**
* 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 _SWAN_H
#define _SWAN_H
#include "../dispatch.h"
#include "../macroInt.h"
#include "sound/swan.h"
#include <queue>
class DivPlatformSwan: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave;
DivMacroInt std;
Channel():
freq(0),
baseFreq(0),
pitch(0),
note(0),
ins(-1),
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[4];
bool isMuted[4];
bool pcm, sweep, furnaceDac;
unsigned char sampleBank, noise;
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample;
unsigned char regPool[0x80];
struct QueuedWrite {
unsigned char addr;
unsigned char val;
QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
};
std::queue<QueuedWrite> writes;
WSwan* ws;
void updateWave(int ch);
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);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();
void forceIns();
void tick();
void muteChannel(int ch, bool mute);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
bool isStereo();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();
const char* getEffectName(unsigned char effect);
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformSwan();
private:
void calcAndWriteOutVol(int ch, int env);
void writeOutVol(int ch);
};
#endif

View File

@ -892,16 +892,10 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
chan[c.chan].ins=c.value;
break;
case DIV_CMD_PANNING: {
switch (c.value) {
case 0x01:
chan[c.chan].pan=1;
break;
case 0x10:
chan[c.chan].pan=2;
break;
default:
chan[c.chan].pan=3;
break;
if (c.value==0) {
chan[c.chan].pan=3;
} else {
chan[c.chan].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
}
if (c.chan>12) {
immWrite(0x11,isMuted[c.chan]?0:(chan[c.chan].pan<<6));

View File

@ -955,16 +955,10 @@ int DivPlatformYM2610B::dispatch(DivCommand c) {
chan[c.chan].ins=c.value;
break;
case DIV_CMD_PANNING: {
switch (c.value) {
case 0x01:
chan[c.chan].pan=1;
break;
case 0x10:
chan[c.chan].pan=2;
break;
default:
chan[c.chan].pan=3;
break;
if (c.value==0) {
chan[c.chan].pan=3;
} else {
chan[c.chan].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
}
if (c.chan>14) {
immWrite(0x11,isMuted[c.chan]?0:(chan[c.chan].pan<<6));

View File

@ -97,16 +97,10 @@ int DivPlatformYM2610BExt::dispatch(DivCommand c) {
opChan[ch].ins=c.value;
break;
case DIV_CMD_PANNING: {
switch (c.value) {
case 0x01:
opChan[ch].pan=1;
break;
case 0x10:
opChan[ch].pan=2;
break;
default:
opChan[ch].pan=3;
break;
if (c.value==0) {
opChan[ch].pan=3;
} else {
opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
}
DivInstrument* ins=parent->getIns(opChan[ch].ins);
// TODO: ???
@ -334,4 +328,4 @@ void DivPlatformYM2610BExt::quit() {
}
DivPlatformYM2610BExt::~DivPlatformYM2610BExt() {
}
}

View File

@ -97,16 +97,10 @@ int DivPlatformYM2610Ext::dispatch(DivCommand c) {
opChan[ch].ins=c.value;
break;
case DIV_CMD_PANNING: {
switch (c.value) {
case 0x01:
opChan[ch].pan=1;
break;
case 0x10:
opChan[ch].pan=2;
break;
default:
opChan[ch].pan=3;
break;
if (c.value==0) {
opChan[ch].pan=3;
} else {
opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
}
DivInstrument* ins=parent->getIns(opChan[ch].ins);
// TODO: ???
@ -334,4 +328,4 @@ void DivPlatformYM2610Ext::quit() {
}
DivPlatformYM2610Ext::~DivPlatformYM2610Ext() {
}
}

View File

@ -32,7 +32,7 @@ static bool isOutput[8][4]={
{true ,true ,true ,true},
};
static unsigned char dtTable[8]={
7,6,5,0,1,2,3,0
7,6,5,0,1,2,3,4
};
static int orderedOps[4]={

View File

@ -42,6 +42,7 @@ const char* notes[12]={
"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"
};
// update this when adding new commands.
const char* cmdName[DIV_CMD_MAX]={
"NOTE_ON",
"NOTE_OFF",
@ -224,14 +225,6 @@ bool DivEngine::perSystemEffect(int ch, unsigned char effect, unsigned char effe
return false;
}
break;
case DIV_SYSTEM_LYNX:
if (effect>=0x30 && effect<0x40) {
int value = ((int)(effect&0x0f)<<8)|effectVal;
dispatchCmd(DivCommand(DIV_CMD_LYNX_LFSR_LOAD,ch,value));
break;
}
return false;
break;
case DIV_SYSTEM_OPLL_DRUMS:
switch (effect) {
case 0x18: // drum mode toggle
@ -258,6 +251,27 @@ bool DivEngine::perSystemEffect(int ch, unsigned char effect, unsigned char effe
break;
}
break;
case DIV_SYSTEM_SWAN:
switch (effect) {
case 0x10: // select waveform
dispatchCmd(DivCommand(DIV_CMD_WAVE,ch,effectVal));
break;
case 0x11: // noise mode
dispatchCmd(DivCommand(DIV_CMD_STD_NOISE_MODE,ch,effectVal));
break;
case 0x12: // sweep period
dispatchCmd(DivCommand(DIV_CMD_WS_SWEEP_TIME,ch,effectVal));
break;
case 0x13: // sweep amount
dispatchCmd(DivCommand(DIV_CMD_WS_SWEEP_AMOUNT,ch,effectVal));
break;
case 0x17: // PCM enable
dispatchCmd(DivCommand(DIV_CMD_SAMPLE_MODE,ch,(effectVal>0)));
break;
default:
return false;
}
break;
default:
return false;
}
@ -533,6 +547,14 @@ bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char
return false;
}
break;
case DIV_SYSTEM_LYNX:
if (effect>=0x30 && effect<0x40) {
int value = ((int)(effect&0x0f)<<8)|effectVal;
dispatchCmd(DivCommand(DIV_CMD_LYNX_LFSR_LOAD,ch,value));
break;
}
return false;
break;
default:
return false;
}
@ -728,7 +750,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
}
chan[i].portaStop=true;
if (chan[i].keyOn) chan[i].doNote=false;
chan[i].stopOnOff=true;
chan[i].stopOnOff=song.stopPortaOnNoteOff; // what?!
chan[i].scheduledSlideReset=false;
dispatchCmd(DivCommand(DIV_CMD_PRE_PORTA,i,true,1));
lastSlide=0x1337; // i hate this so much
@ -778,7 +800,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
chan[i].portaSpeed=(effectVal>>4)*4;
chan[i].portaStop=true;
chan[i].nowYouCanStop=false;
chan[i].stopOnOff=true;
chan[i].stopOnOff=song.stopPortaOnNoteOff; // what?!
chan[i].scheduledSlideReset=false;
if ((effectVal&15)!=0) {
chan[i].inPorta=true;
@ -794,7 +816,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
chan[i].portaSpeed=(effectVal>>4)*4;
chan[i].portaStop=true;
chan[i].nowYouCanStop=false;
chan[i].stopOnOff=true;
chan[i].stopOnOff=song.stopPortaOnNoteOff; // what?!
chan[i].scheduledSlideReset=false;
if ((effectVal&15)!=0) {
chan[i].inPorta=true;
@ -854,7 +876,9 @@ void DivEngine::processRow(int i, bool afterDelay) {
}
if (chan[i].doNote) {
chan[i].vibratoPos=0;
if (!song.continuousVibrato) {
chan[i].vibratoPos=0;
}
dispatchCmd(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+(((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos]*chan[i].vibratoFine)>>4)/15)));
if (chan[i].legato) {
dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note));

View File

@ -92,9 +92,9 @@ short SafeReader::readS() {
short SafeReader::readS_BE() {
if (curSeek+1>len) throw EndOfFileException(this,len);
short ret=*(short*)(&buf[curSeek]);
unsigned short ret=*(unsigned short*)(&buf[curSeek]);
curSeek+=2;
return (ret>>8)|((ret&0xff)<<8);
return (short)((ret>>8)|((ret&0xff)<<8));
}
int SafeReader::readI() {
@ -112,9 +112,9 @@ int SafeReader::readI() {
int SafeReader::readI_BE() {
if (curSeek+4>len) throw EndOfFileException(this,len);
int ret=*(int*)(&buf[curSeek]);
unsigned int ret=*(unsigned int*)(&buf[curSeek]);
curSeek+=4;
return (ret>>24)|((ret&0xff0000)>>8)|((ret&0xff00)<<8)|((ret&0xff)<<24);
return (int)((ret>>24)|((ret&0xff0000)>>8)|((ret&0xff00)<<8)|((ret&0xff)<<24));
}
int64_t SafeReader::readL() {

View File

@ -80,6 +80,10 @@ int SafeWriter::writeC(signed char val) {
int SafeWriter::writeS(short val) {
return write(&val,2);
}
int SafeWriter::writeS_BE(short val) {
unsigned char bytes[2]{(unsigned char)((val>>8)&0xff), (unsigned char)(val&0xff)};
return write(bytes,2);
}
int SafeWriter::writeI(int val) {
return write(&val,4);

View File

@ -194,6 +194,8 @@ struct DivSong {
// - 6: 0.89MHz (Sunsoft 5B)
// - 7: 1.67MHz
// - 8: 0.83MHz (Sunsoft 5B on PAL)
// - 9: 1.10MHz (Gamate/VIC-20 PAL)
// - 10: 2.097152MHz (Game Boy)
// - bit 4-5: chip type (ignored on AY8930)
// - 0: AY-3-8910 or similar
// - 1: YM2149
@ -215,6 +217,12 @@ struct DivSong {
// - 1: Amiga 1200
// - bit 8-14: stereo separation
// - 0 is 0% while 127 is 100%
// - PC Speaker:
// - bit 0-1: speaker type
// - 0: unfiltered
// - 1: cone
// - 2: piezo
// - 3: real (TODO)
// - QSound:
// - bit 12-20: echo feedback
// - Valid values are 0-255
@ -276,6 +284,8 @@ struct DivSong {
bool algMacroBehavior;
bool brokenShortcutSlides;
bool ignoreDuplicateSlides;
bool stopPortaOnNoteOff;
bool continuousVibrato;
DivOrders orders;
std::vector<DivInstrument*> ins;
@ -338,7 +348,9 @@ struct DivSong {
arpNonPorta(false),
algMacroBehavior(false),
brokenShortcutSlides(false),
ignoreDuplicateSlides(false) {
ignoreDuplicateSlides(false),
stopPortaOnNoteOff(false),
continuousVibrato(false) {
for (int i=0; i<32; i++) {
system[i]=DIV_SYSTEM_NULL;
systemVol[i]=64;

View File

@ -1616,6 +1616,7 @@ bool DivEngine::isVGMExportable(DivSystem which) {
case DIV_SYSTEM_OPLL:
case DIV_SYSTEM_OPLL_DRUMS:
case DIV_SYSTEM_VRC7:
case DIV_SYSTEM_SWAN:
return true;
default:
return false;

View File

@ -25,119 +25,123 @@
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool isSecond) {
unsigned char baseAddr1=isSecond?0xa0:0x50;
unsigned char baseAddr2=isSecond?0x80:0;
unsigned short baseAddr2S=isSecond?0x8000:0;
unsigned char smsAddr=isSecond?0x30:0x50;
if (write.addr==0xffffffff) { // Furnace fake reset
switch (sys) {
case DIV_SYSTEM_YM2612:
case DIV_SYSTEM_YM2612_EXT:
for (int i=0; i<3; i++) { // set SL and RR to highest
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(0x80+i);
w->writeC(0xff);
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(0x84+i);
w->writeC(0xff);
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(0x88+i);
w->writeC(0xff);
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(0x8c+i);
w->writeC(0xff);
w->writeC(isSecond?0xa3:0x53);
w->writeC(3|baseAddr1);
w->writeC(0x80+i);
w->writeC(0xff);
w->writeC(isSecond?0xa3:0x53);
w->writeC(3|baseAddr1);
w->writeC(0x84+i);
w->writeC(0xff);
w->writeC(isSecond?0xa3:0x53);
w->writeC(3|baseAddr1);
w->writeC(0x88+i);
w->writeC(0xff);
w->writeC(isSecond?0xa3:0x53);
w->writeC(3|baseAddr1);
w->writeC(0x8c+i);
w->writeC(0xff);
}
for (int i=0; i<3; i++) { // note off
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(0x28);
w->writeC(i);
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(0x28);
w->writeC(4+i);
}
w->writeC(isSecond?0xa2:0x52); // disable DAC
w->writeC(2|baseAddr1); // disable DAC
w->writeC(0x2b);
w->writeC(0);
break;
case DIV_SYSTEM_SMS:
for (int i=0; i<4; i++) {
w->writeC(isSecond?0x30:0x50);
w->writeC(smsAddr);
w->writeC(0x90|(i<<5)|15);
}
break;
case DIV_SYSTEM_GB:
// square 1
w->writeC(0xb3);
w->writeC(isSecond?0x82:2);
w->writeC(2|baseAddr2);
w->writeC(0);
w->writeC(0xb3);
w->writeC(isSecond?0x84:4);
w->writeC(4|baseAddr2);
w->writeC(0x80);
// square 2
w->writeC(0xb3);
w->writeC(isSecond?0x87:7);
w->writeC(7|baseAddr2);
w->writeC(0);
w->writeC(0xb3);
w->writeC(isSecond?0x89:9);
w->writeC(9|baseAddr2);
w->writeC(0x80);
// wave
w->writeC(0xb3);
w->writeC(isSecond?0x8c:0x0c);
w->writeC(0x0c|baseAddr2);
w->writeC(0);
w->writeC(0xb3);
w->writeC(isSecond?0x8e:0x0e);
w->writeC(0x0e|baseAddr2);
w->writeC(0x80);
// noise
w->writeC(0xb3);
w->writeC(isSecond?0x91:0x11);
w->writeC(0x11|baseAddr2);
w->writeC(0);
w->writeC(0xb3);
w->writeC(isSecond?0x93:0x13);
w->writeC(0x13|baseAddr2);
w->writeC(0x80);
break;
case DIV_SYSTEM_PCE:
for (int i=0; i<6; i++) {
w->writeC(0xb9);
w->writeC(isSecond?0x80:0);
w->writeC(0|baseAddr2);
w->writeC(i);
w->writeC(0xb9);
w->writeC(isSecond?0x84:4);
w->writeC(4|baseAddr2);
w->writeC(0);
}
break;
case DIV_SYSTEM_NES:
w->writeC(0xb4);
w->writeC(isSecond?0x95:0x15);
w->writeC(0x15|baseAddr2);
w->writeC(0);
break;
case DIV_SYSTEM_YM2151:
for (int i=0; i<8; i++) {
w->writeC(isSecond?0xa4:0x54);
w->writeC(4|baseAddr1);
w->writeC(0xe0+i);
w->writeC(0xff);
w->writeC(isSecond?0xa4:0x54);
w->writeC(4|baseAddr1);
w->writeC(0xe8+i);
w->writeC(0xff);
w->writeC(isSecond?0xa4:0x54);
w->writeC(4|baseAddr1);
w->writeC(0xf0+i);
w->writeC(0xff);
w->writeC(isSecond?0xa4:0x54);
w->writeC(4|baseAddr1);
w->writeC(0xf8+i);
w->writeC(0xff);
w->writeC(isSecond?0xa4:0x54);
w->writeC(4|baseAddr1);
w->writeC(0x08);
w->writeC(i);
}
@ -146,7 +150,7 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
case DIV_SYSTEM_SEGAPCM_COMPAT:
for (int i=0; i<16; i++) {
w->writeC(0xc0);
w->writeS((isSecond?0x8086:0x86)+(i<<3));
w->writeS((0x86|baseAddr2S)+(i<<3));
w->writeC(3);
}
break;
@ -157,60 +161,60 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
case DIV_SYSTEM_YM2610_FULL_EXT:
case DIV_SYSTEM_YM2610B_EXT:
for (int i=0; i<2; i++) { // set SL and RR to highest
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(0x81+i);
w->writeC(0xff);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(0x85+i);
w->writeC(0xff);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(0x89+i);
w->writeC(0xff);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(0x8d+i);
w->writeC(0xff);
w->writeC(isSecond?0xa9:0x59);
w->writeC(9|baseAddr1);
w->writeC(0x81+i);
w->writeC(0xff);
w->writeC(isSecond?0xa9:0x59);
w->writeC(9|baseAddr1);
w->writeC(0x85+i);
w->writeC(0xff);
w->writeC(isSecond?0xa9:0x59);
w->writeC(9|baseAddr1);
w->writeC(0x89+i);
w->writeC(0xff);
w->writeC(isSecond?0xa9:0x59);
w->writeC(9|baseAddr1);
w->writeC(0x8d+i);
w->writeC(0xff);
}
for (int i=0; i<2; i++) { // note off
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(0x28);
w->writeC(1+i);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(0x28);
w->writeC(5+i);
}
// reset AY
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(7);
w->writeC(0x3f);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(8);
w->writeC(0);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(9);
w->writeC(0);
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(10);
w->writeC(0);
// reset sample
w->writeC(isSecond?0xa9:0x59);
w->writeC(9|baseAddr1);
w->writeC(0);
w->writeC(0xbf);
break;
@ -218,56 +222,56 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
case DIV_SYSTEM_OPLL_DRUMS:
case DIV_SYSTEM_VRC7:
for (int i=0; i<9; i++) {
w->writeC(isSecond?0xa1:0x51);
w->writeC(1|baseAddr1);
w->writeC(0x20+i);
w->writeC(0);
w->writeC(isSecond?0xa1:0x51);
w->writeC(1|baseAddr1);
w->writeC(0x30+i);
w->writeC(0);
w->writeC(isSecond?0xa1:0x51);
w->writeC(1|baseAddr1);
w->writeC(0x10+i);
w->writeC(0);
}
break;
case DIV_SYSTEM_AY8910:
w->writeC(0xa0);
w->writeC(isSecond?0x87:7);
w->writeC(7|baseAddr2);
w->writeC(0x3f);
w->writeC(0xa0);
w->writeC(isSecond?0x88:8);
w->writeC(8|baseAddr2);
w->writeC(0);
w->writeC(0xa0);
w->writeC(isSecond?0x89:9);
w->writeC(9|baseAddr2);
w->writeC(0);
w->writeC(0xa0);
w->writeC(isSecond?0x8a:10);
w->writeC(10|baseAddr2);
w->writeC(0);
break;
case DIV_SYSTEM_AY8930:
w->writeC(0xa0);
w->writeC(isSecond?0x8d:0x0d);
w->writeC(0x0d|baseAddr2);
w->writeC(0);
w->writeC(0xa0);
w->writeC(isSecond?0x8d:0x0d);
w->writeC(0x0d|baseAddr2);
w->writeC(0xa0);
break;
case DIV_SYSTEM_SAA1099:
w->writeC(0xbd);
w->writeC(isSecond?0x9c:0x1c);
w->writeC(0x1c|baseAddr2);
w->writeC(0x02);
w->writeC(0xbd);
w->writeC(isSecond?0x94:0x14);
w->writeC(0x14|baseAddr2);
w->writeC(0);
w->writeC(0xbd);
w->writeC(isSecond?0x95:0x15);
w->writeC(0x15|baseAddr2);
w->writeC(0);
for (int i=0; i<6; i++) {
w->writeC(0xbd);
w->writeC((isSecond?0x80:0)+i);
w->writeC((0|baseAddr2)+i);
w->writeC(0);
}
break;
@ -346,49 +350,49 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
case DIV_SYSTEM_YM2612_EXT:
switch (write.addr>>8) {
case 0: // port 0
w->writeC(isSecond?0xa2:0x52);
w->writeC(2|baseAddr1);
w->writeC(write.addr&0xff);
w->writeC(write.val);
break;
case 1: // port 1
w->writeC(isSecond?0xa3:0x53);
w->writeC(3|baseAddr1);
w->writeC(write.addr&0xff);
w->writeC(write.val);
break;
case 2: // PSG
w->writeC(isSecond?0x30:0x50);
w->writeC(smsAddr);
w->writeC(write.val);
break;
}
break;
case DIV_SYSTEM_SMS:
w->writeC(isSecond?0x30:0x50);
w->writeC(smsAddr);
w->writeC(write.val);
break;
case DIV_SYSTEM_GB:
w->writeC(0xb3);
w->writeC((isSecond?0x80:0)|((write.addr-16)&0xff));
w->writeC(baseAddr2|((write.addr-16)&0xff));
w->writeC(write.val);
break;
case DIV_SYSTEM_PCE:
w->writeC(0xb9);
w->writeC((isSecond?0x80:0)|(write.addr&0xff));
w->writeC(baseAddr2|(write.addr&0xff));
w->writeC(write.val);
break;
case DIV_SYSTEM_NES:
w->writeC(0xb4);
w->writeC((isSecond?0x80:0)|(write.addr&0xff));
w->writeC(baseAddr2|(write.addr&0xff));
w->writeC(write.val);
break;
case DIV_SYSTEM_YM2151:
w->writeC(isSecond?0xa4:0x54);
w->writeC(4|baseAddr1);
w->writeC(write.addr&0xff);
w->writeC(write.val);
break;
case DIV_SYSTEM_SEGAPCM:
case DIV_SYSTEM_SEGAPCM_COMPAT:
w->writeC(0xc0);
w->writeS((isSecond?0x8000:0)|(write.addr&0xffff));
w->writeS(baseAddr2S|(write.addr&0xffff));
w->writeC(write.val);
break;
case DIV_SYSTEM_YM2610:
@ -399,12 +403,12 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
case DIV_SYSTEM_YM2610B_EXT:
switch (write.addr>>8) {
case 0: // port 0
w->writeC(isSecond?0xa8:0x58);
w->writeC(8|baseAddr1);
w->writeC(write.addr&0xff);
w->writeC(write.val);
break;
case 1: // port 1
w->writeC(isSecond?0xa9:0x59);
w->writeC(9|baseAddr1);
w->writeC(write.addr&0xff);
w->writeC(write.val);
break;
@ -413,19 +417,19 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
case DIV_SYSTEM_OPLL:
case DIV_SYSTEM_OPLL_DRUMS:
case DIV_SYSTEM_VRC7:
w->writeC(isSecond?0xa1:0x51);
w->writeC(1|baseAddr1);
w->writeC(write.addr&0xff);
w->writeC(write.val);
break;
case DIV_SYSTEM_AY8910:
case DIV_SYSTEM_AY8930:
w->writeC(0xa0);
w->writeC((isSecond?0x80:0)|(write.addr&0xff));
w->writeC(baseAddr2|(write.addr&0xff));
w->writeC(write.val);
break;
case DIV_SYSTEM_SAA1099:
w->writeC(0xbd);
w->writeC((isSecond?0x80:0)|(write.addr&0xff));
w->writeC(baseAddr2|(write.addr&0xff));
w->writeC(write.val);
break;
case DIV_SYSTEM_LYNX:
@ -439,6 +443,18 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
w->writeC(write.val&0xff);
w->writeC(write.addr&0xff);
break;
case DIV_SYSTEM_SWAN:
if ((write.addr&0x7f)<0x40) {
w->writeC(0xbc);
w->writeC(baseAddr2|(write.addr&0x3f));
w->writeC(write.val&0xff);
} else {
// (Wave) RAM write
w->writeC(0xc6);
w->writeS_BE(baseAddr2S|(write.addr&0x3f));
w->writeC(write.val&0xff);
}
break;
default:
logW("write not handled!\n");
break;
@ -742,6 +758,21 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
addWarning("dual QSound is not supported by the VGM format");
}
break;
case DIV_SYSTEM_SWAN:
if (!hasSwan) {
hasSwan=disCont[i].dispatch->chipClock;
willExport[i]=true;
// funny enough, VGM doesn't have support for WSC's sound DMA by design
// so DAC stream it goes
// since WS has the same PCM format as YM2612 DAC, I can just reuse this flag
writeDACSamples=true;
} else if (!(hasSwan&0x40000000)) {
isSecond[i]=true;
willExport[i]=true;
hasSwan|=0x40000000;
howManyChips++;
}
break;
default:
break;
}
@ -1027,6 +1058,24 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
streamID++;
}
break;
case DIV_SYSTEM_SWAN:
w->writeC(0x90);
w->writeC(streamID);
w->writeC(isSecond[i]?0xa1:0x21);
w->writeC(0); // port
w->writeC(0x09); // DAC
w->writeC(0x91);
w->writeC(streamID);
w->writeC(0);
w->writeC(1);
w->writeC(0);
w->writeC(0x92);
w->writeC(streamID);
w->writeI(24000); // default
streamID++;
break;
default:
break;
}

View File

@ -17,7 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <SDL_video.h>
#define _USE_MATH_DEFINES
#include "gui.h"
#include "util.h"
@ -623,6 +622,10 @@ void FurnaceGUI::drawEditControls() {
e->noteOff(activeNotes[i].chan);
}
activeNotes.clear();
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::Text("Edit Step");
@ -630,6 +633,10 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::InputInt("##EditStep",&editStep,1,1)) {
if (editStep>=e->song.patLen) editStep=e->song.patLen-1;
if (editStep<0) editStep=0;
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
if (ImGui::Button(ICON_FA_PLAY "##Play")) {
@ -649,9 +656,9 @@ void FurnaceGUI::drawEditControls() {
ImGui::Text("Follow");
ImGui::SameLine();
ImGui::Checkbox("Orders",&followOrders);
unimportant(ImGui::Checkbox("Orders",&followOrders));
ImGui::SameLine();
ImGui::Checkbox("Pattern",&followPattern);
unimportant(ImGui::Checkbox("Pattern",&followPattern));
bool repeatPattern=e->getRepeatPattern();
if (ImGui::Checkbox("Repeat pattern",&repeatPattern)) {
@ -713,6 +720,10 @@ void FurnaceGUI::drawEditControls() {
e->noteOff(activeNotes[i].chan);
}
activeNotes.clear();
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::SameLine();
@ -722,14 +733,18 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::InputInt("##EditStep",&editStep,1,1)) {
if (editStep>=e->song.patLen) editStep=e->song.patLen-1;
if (editStep<0) editStep=0;
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::SameLine();
ImGui::Text("Follow");
ImGui::SameLine();
ImGui::Checkbox("Orders",&followOrders);
unimportant(ImGui::Checkbox("Orders",&followOrders));
ImGui::SameLine();
ImGui::Checkbox("Pattern",&followPattern);
unimportant(ImGui::Checkbox("Pattern",&followPattern));
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_EDIT_CONTROLS;
ImGui::End();
@ -776,6 +791,10 @@ void FurnaceGUI::drawEditControls() {
e->noteOff(activeNotes[i].chan);
}
activeNotes.clear();
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::Text("Step");
@ -783,16 +802,20 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::InputInt("##EditStep",&editStep,0,0)) {
if (editStep>=e->song.patLen) editStep=e->song.patLen-1;
if (editStep<0) editStep=0;
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::Text("Foll.");
ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(0.2f,(followOrders)?0.6f:0.2f,0.2f,1.0f));
if (ImGui::SmallButton("Ord##FollowOrders")) {
if (ImGui::SmallButton("Ord##FollowOrders")) { handleUnimportant
followOrders=!followOrders;
}
ImGui::PopStyleColor();
ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(0.2f,(followPattern)?0.6f:0.2f,0.2f,1.0f));
if (ImGui::SmallButton("Pat##FollowPattern")) {
if (ImGui::SmallButton("Pat##FollowPattern")) { handleUnimportant
followPattern=!followPattern;
}
ImGui::PopStyleColor();
@ -860,6 +883,10 @@ void FurnaceGUI::drawEditControls() {
e->noteOff(activeNotes[i].chan);
}
activeNotes.clear();
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::Text("Step");
@ -869,11 +896,15 @@ void FurnaceGUI::drawEditControls() {
if (ImGui::InputInt("##EditStep",&editStep,1,1)) {
if (editStep>=e->song.patLen) editStep=e->song.patLen-1;
if (editStep<0) editStep=0;
if (settings.insFocusesPattern && !ImGui::IsItemActive() && patternOpen) {
nextWindow=GUI_WINDOW_PATTERN;
}
}
ImGui::NextColumn();
ImGui::Checkbox("Follow orders",&followOrders);
ImGui::Checkbox("Follow pattern",&followPattern);
unimportant(ImGui::Checkbox("Follow orders",&followOrders));
unimportant(ImGui::Checkbox("Follow pattern",&followPattern));
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_EDIT_CONTROLS;
ImGui::End();
@ -1169,10 +1200,15 @@ void FurnaceGUI::drawInsList() {
if (ImGui::Selectable(name.c_str(),curIns==i)) {
curIns=i;
}
if (settings.insFocusesPattern && patternOpen && ImGui::IsItemActivated()) {
nextWindow=GUI_WINDOW_PATTERN;
curIns=i;
}
ImGui::PopStyleColor();
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
insEditOpen=true;
nextWindow=GUI_WINDOW_INS_EDIT;
}
}
}
@ -1515,6 +1551,7 @@ const char* aboutLine[]={
"",
"-- program --",
"tildearrow",
"akumanatt",
"cam900",
"laoo",
"superctr",
@ -1540,6 +1577,7 @@ const char* aboutLine[]={
"NikonTeen",
"SuperJet Spade",
"TheDuccinator",
"TheRealHedgehogSonic",
"tildearrow",
"Ultraprogramer",
"",
@ -2053,6 +2091,10 @@ void FurnaceGUI::drawCompatFlags() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("if this is on, only the first slide of a row in a channel will be considered.");
}
ImGui::Checkbox("Continuous vibrato",&e->song.continuousVibrato);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("when enabled, vibrato will not be reset on a new note.");
}
ImGui::Text("Loop modality:");
if (ImGui::RadioButton("Reset channels",e->song.loopModality==0)) {
@ -2090,6 +2132,10 @@ void FurnaceGUI::drawCompatFlags() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("behavior changed in 0.5.7");
}
ImGui::Checkbox("Stop portamento on note off",&e->song.stopPortaOnNoteOff);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("behavior changed in 0.6");
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_COMPAT_FLAGS;
ImGui::End();
@ -2433,6 +2479,7 @@ void FurnaceGUI::moveCursorPrevChannel(bool overflow) {
selStart=cursor;
selEnd=cursor;
demandScrollX=true;
}
void FurnaceGUI::moveCursorNextChannel(bool overflow) {
@ -2455,6 +2502,7 @@ void FurnaceGUI::moveCursorNextChannel(bool overflow) {
selStart=cursor;
selEnd=cursor;
demandScrollX=true;
}
void FurnaceGUI::moveCursorTop(bool select) {
@ -2464,6 +2512,7 @@ void FurnaceGUI::moveCursorTop(bool select) {
DETERMINE_FIRST;
cursor.xCoarse=firstChannel;
cursor.xFine=0;
demandScrollX=true;
} else {
cursor.y=0;
}
@ -2481,6 +2530,7 @@ void FurnaceGUI::moveCursorBottom(bool select) {
DETERMINE_LAST;
cursor.xCoarse=lastChannel-1;
cursor.xFine=2+e->song.pat[cursor.xCoarse].effectRows*2;
demandScrollX=true;
} else {
cursor.y=e->song.patLen-1;
}
@ -2811,7 +2861,7 @@ void FurnaceGUI::doCopy(bool cut) {
}
}
void FurnaceGUI::doPaste() {
void FurnaceGUI::doPaste(PasteMode mode) {
finishSelection();
prepareUndo(GUI_UNDO_PATTERN_PASTE);
char* clipText=SDL_GetClipboardText();
@ -4344,6 +4394,99 @@ void FurnaceGUI::processDrags(int dragX, int dragY) {
#define BIND_FOR(x) getKeyName(actionKeys[x],true).c_str()
void FurnaceGUI::editOptions(bool topMenu) {
char id[4096];
if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_PAT_CUT))) doCopy(true);
if (ImGui::MenuItem("copy",BIND_FOR(GUI_ACTION_PAT_COPY))) doCopy(false);
if (ImGui::MenuItem("paste",BIND_FOR(GUI_ACTION_PAT_PASTE))) doPaste();
if (ImGui::BeginMenu("paste special...")) {
ImGui::MenuItem("paste mix",BIND_FOR(GUI_ACTION_PAT_PASTE_MIX));
ImGui::MenuItem("paste mix (background)",BIND_FOR(GUI_ACTION_PAT_PASTE_MIX_BG));
ImGui::MenuItem("paste flood",BIND_FOR(GUI_ACTION_PAT_PASTE_FLOOD));
ImGui::MenuItem("paste overflow",BIND_FOR(GUI_ACTION_PAT_PASTE_OVERFLOW));
ImGui::EndMenu();
}
if (ImGui::MenuItem("delete",BIND_FOR(GUI_ACTION_PAT_DELETE))) doDelete();
if (topMenu) {
if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_PAT_SELECT_ALL))) doSelectAll();
}
ImGui::Separator();
if (ImGui::MenuItem("set latch",BIND_FOR(GUI_ACTION_PAT_LATCH))) {
// TODO
}
ImGui::Separator();
if (ImGui::MenuItem("note up",BIND_FOR(GUI_ACTION_PAT_NOTE_UP))) doTranspose(1);
if (ImGui::MenuItem("note down",BIND_FOR(GUI_ACTION_PAT_NOTE_DOWN))) doTranspose(-1);
if (ImGui::MenuItem("octave up",BIND_FOR(GUI_ACTION_PAT_OCTAVE_UP))) doTranspose(12);
if (ImGui::MenuItem("octave down",BIND_FOR(GUI_ACTION_PAT_OCTAVE_DOWN))) doTranspose(-12);
if (ImGui::InputInt("##TransposeAmount",&transposeAmount,1,1)) {
if (transposeAmount<-96) transposeAmount=-96;
if (transposeAmount>96) transposeAmount=96;
}
ImGui::SameLine();
if (ImGui::Button("Transpose")) {
doTranspose(transposeAmount);
ImGui::CloseCurrentPopup();
}
ImGui::Separator();
ImGui::MenuItem("interpolate",BIND_FOR(GUI_ACTION_PAT_INTERPOLATE));
ImGui::MenuItem("fade in",BIND_FOR(GUI_ACTION_PAT_FADE_IN));
ImGui::MenuItem("fade out",BIND_FOR(GUI_ACTION_PAT_FADE_OUT));
if (ImGui::BeginMenu("change instrument...")) {
if (e->song.ins.empty()) {
ImGui::Text("no instruments available");
}
for (size_t i=0; i<e->song.ins.size(); i++) {
snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str());
if (ImGui::MenuItem(id)) { // TODO
}
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("scale...")) {
if (ImGui::InputFloat("Bottom",&scaleMin,1,1,"%.1f%%")) {
if (scaleMin<0.0f) scaleMin=0.0f;
if (scaleMin>100.0f) scaleMin=100.0f;
}
if (ImGui::InputFloat("Top",&scaleMax,1,1,"%.1f%%")) {
if (scaleMax<0.0f) scaleMax=0.0f;
if (scaleMax>100.0f) scaleMax=100.0f;
}
if (ImGui::Button("Scale")) {
ImGui::CloseCurrentPopup();
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("randomize...")) {
ImGui::InputInt("Minimum",&randomizeMin,1,1);
ImGui::InputInt("Maximum",&randomizeMax,1,1);
if (ImGui::Button("Randomize")) {
ImGui::CloseCurrentPopup();
}
ImGui::EndMenu();
}
ImGui::MenuItem("invert values",BIND_FOR(GUI_ACTION_PAT_INVERT_VALUES));
ImGui::Separator();
ImGui::MenuItem("flip selection",BIND_FOR(GUI_ACTION_PAT_FLIP_SELECTION));
ImGui::MenuItem("collapse",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_ROWS));
ImGui::MenuItem("expand",BIND_FOR(GUI_ACTION_PAT_EXPAND_ROWS));
if (topMenu) {
ImGui::Separator();
ImGui::MenuItem("collapse pattern",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_PAT));
ImGui::MenuItem("expand pattern",BIND_FOR(GUI_ACTION_PAT_EXPAND_PAT));
ImGui::Separator();
ImGui::MenuItem("collapse song",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_SONG));
ImGui::MenuItem("expand song",BIND_FOR(GUI_ACTION_PAT_EXPAND_SONG));
}
}
bool FurnaceGUI::loop() {
while (!quit) {
SDL_Event ev;
@ -4580,14 +4723,22 @@ bool FurnaceGUI::loop() {
sysAddOption(DIV_SYSTEM_YM2610B_EXT);
sysAddOption(DIV_SYSTEM_AY8910);
sysAddOption(DIV_SYSTEM_AMIGA);
sysAddOption(DIV_SYSTEM_PCSPKR);
sysAddOption(DIV_SYSTEM_OPLL);
sysAddOption(DIV_SYSTEM_OPLL_DRUMS);
sysAddOption(DIV_SYSTEM_VRC7);
sysAddOption(DIV_SYSTEM_OPL);
sysAddOption(DIV_SYSTEM_OPL_DRUMS);
sysAddOption(DIV_SYSTEM_OPL2);
sysAddOption(DIV_SYSTEM_OPL2_DRUMS);
sysAddOption(DIV_SYSTEM_OPL3);
sysAddOption(DIV_SYSTEM_OPL3_DRUMS);
sysAddOption(DIV_SYSTEM_TIA);
sysAddOption(DIV_SYSTEM_SAA1099);
sysAddOption(DIV_SYSTEM_AY8930);
sysAddOption(DIV_SYSTEM_LYNX);
sysAddOption(DIV_SYSTEM_QSOUND);
sysAddOption(DIV_SYSTEM_SWAN);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("configure system...")) {
@ -4787,6 +4938,14 @@ bool FurnaceGUI::loop() {
e->setSysFlags(i,(flags&(~15))|8,restart);
updateWindowTitle();
}
if (ImGui::RadioButton("1.10MHz (Gamate/VIC-20 PAL)",(flags&15)==9)) {
e->setSysFlags(i,(flags&(~15))|9,restart);
updateWindowTitle();
}
if (ImGui::RadioButton("2^21Hz (Game Boy)",(flags&15)==10)) {
e->setSysFlags(i,(flags&(~15))|10,restart);
updateWindowTitle();
}
if (e->song.system[i]==DIV_SYSTEM_AY8910) {
ImGui::Text("Chip type:");
if (ImGui::RadioButton("AY-3-8910",(flags&0x30)==0)) {
@ -4848,6 +5007,26 @@ bool FurnaceGUI::loop() {
}
break;
}
case DIV_SYSTEM_PCSPKR: {
ImGui::Text("Speaker type:");
if (ImGui::RadioButton("Unfiltered",(flags&3)==0)) {
e->setSysFlags(i,(flags&(~3))|0,restart);
updateWindowTitle();
}
if (ImGui::RadioButton("Cone",(flags&3)==1)) {
e->setSysFlags(i,(flags&(~3))|1,restart);
updateWindowTitle();
}
if (ImGui::RadioButton("Piezo",(flags&3)==2)) {
e->setSysFlags(i,(flags&(~3))|2,restart);
updateWindowTitle();
}
if (ImGui::RadioButton("Use system beeper (Linux only!)",(flags&3)==3)) {
e->setSysFlags(i,(flags&(~3))|3,restart);
updateWindowTitle();
}
break;
}
case DIV_SYSTEM_QSOUND: {
ImGui::Text("Echo delay:");
int echoBufSize=2725 - (flags & 4095);
@ -4868,6 +5047,7 @@ bool FurnaceGUI::loop() {
break;
}
case DIV_SYSTEM_GB:
case DIV_SYSTEM_SWAN:
case DIV_SYSTEM_YM2610:
case DIV_SYSTEM_YM2610_EXT:
case DIV_SYSTEM_YM2610_FULL:
@ -4911,14 +5091,22 @@ bool FurnaceGUI::loop() {
sysChangeOption(i,DIV_SYSTEM_YM2610B_EXT);
sysChangeOption(i,DIV_SYSTEM_AY8910);
sysChangeOption(i,DIV_SYSTEM_AMIGA);
sysChangeOption(i,DIV_SYSTEM_PCSPKR);
sysChangeOption(i,DIV_SYSTEM_OPLL);
sysChangeOption(i,DIV_SYSTEM_OPLL_DRUMS);
sysChangeOption(i,DIV_SYSTEM_VRC7);
sysChangeOption(i,DIV_SYSTEM_OPL);
sysChangeOption(i,DIV_SYSTEM_OPL_DRUMS);
sysChangeOption(i,DIV_SYSTEM_OPL2);
sysChangeOption(i,DIV_SYSTEM_OPL2_DRUMS);
sysChangeOption(i,DIV_SYSTEM_OPL3);
sysChangeOption(i,DIV_SYSTEM_OPL3_DRUMS);
sysChangeOption(i,DIV_SYSTEM_TIA);
sysChangeOption(i,DIV_SYSTEM_SAA1099);
sysChangeOption(i,DIV_SYSTEM_AY8930);
sysChangeOption(i,DIV_SYSTEM_LYNX);
sysChangeOption(i,DIV_SYSTEM_QSOUND);
sysChangeOption(i,DIV_SYSTEM_SWAN);
ImGui::EndMenu();
}
}
@ -4948,16 +5136,7 @@ bool FurnaceGUI::loop() {
if (ImGui::MenuItem("undo",BIND_FOR(GUI_ACTION_UNDO))) doUndo();
if (ImGui::MenuItem("redo",BIND_FOR(GUI_ACTION_REDO))) doRedo();
ImGui::Separator();
if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_PAT_CUT))) doCopy(true);
if (ImGui::MenuItem("copy",BIND_FOR(GUI_ACTION_PAT_COPY))) doCopy(false);
if (ImGui::MenuItem("paste",BIND_FOR(GUI_ACTION_PAT_PASTE))) doPaste();
if (ImGui::MenuItem("delete",BIND_FOR(GUI_ACTION_PAT_DELETE))) doDelete();
if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_PAT_SELECT_ALL))) doSelectAll();
ImGui::Separator();
if (ImGui::MenuItem("note up",BIND_FOR(GUI_ACTION_PAT_NOTE_UP))) doTranspose(1);
if (ImGui::MenuItem("note down",BIND_FOR(GUI_ACTION_PAT_NOTE_DOWN))) doTranspose(-1);
if (ImGui::MenuItem("octave up",BIND_FOR(GUI_ACTION_PAT_OCTAVE_UP))) doTranspose(12);
if (ImGui::MenuItem("octave down",BIND_FOR(GUI_ACTION_PAT_OCTAVE_DOWN))) doTranspose(-12);
editOptions(true);
/*ImGui::Separator();
ImGui::MenuItem("clear...");*/
ImGui::EndMenu();
@ -5076,19 +5255,19 @@ bool FurnaceGUI::loop() {
ImGui::DockSpaceOverViewport();
drawPattern();
drawEditControls();
drawSongInfo();
drawOrders();
drawInsList();
drawInsEdit();
drawWaveList();
drawWaveEdit();
drawSampleList();
drawSampleEdit();
drawWaveList();
drawWaveEdit();
drawInsList();
drawInsEdit();
drawMixer();
drawOsc();
drawVolMeter();
drawPattern();
drawSettings();
drawDebug();
drawStats();
@ -5454,7 +5633,11 @@ void FurnaceGUI::parseKeybinds() {
void FurnaceGUI::applyUISettings() {
ImGuiStyle sty;
ImGui::StyleColorsDark(&sty);
if (settings.guiColorsBase) {
ImGui::StyleColorsLight(&sty);
} else {
ImGui::StyleColorsDark(&sty);
}
if (settings.dpiScale>=0.5f) dpiScale=settings.dpiScale;
@ -5555,8 +5738,14 @@ void FurnaceGUI::applyUISettings() {
primaryHover.w=primaryActive.w;
primary.w=primaryActive.w;
ImGui::ColorConvertRGBtoHSV(primaryActive.x,primaryActive.y,primaryActive.z,hue,sat,val);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.5,primaryHover.x,primaryHover.y,primaryHover.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.8,val*0.35,primary.x,primary.y,primary.z);
if (settings.guiColorsBase) {
primary=primaryActive;
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.9,primaryHover.x,primaryHover.y,primaryHover.z);
ImGui::ColorConvertHSVtoRGB(hue,sat,val*0.5,primaryActive.x,primaryActive.y,primaryActive.z);
} else {
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.5,primaryHover.x,primaryHover.y,primaryHover.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.8,val*0.35,primary.x,primary.y,primary.z);
}
ImVec4 secondaryActive=uiColors[GUI_COLOR_ACCENT_SECONDARY];
ImVec4 secondaryHover, secondary, secondarySemiActive;
@ -5564,9 +5753,16 @@ void FurnaceGUI::applyUISettings() {
secondaryHover.w=secondaryActive.w;
secondary.w=secondaryActive.w;
ImGui::ColorConvertRGBtoHSV(secondaryActive.x,secondaryActive.y,secondaryActive.z,hue,sat,val);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.75,secondarySemiActive.x,secondarySemiActive.y,secondarySemiActive.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.5,secondaryHover.x,secondaryHover.y,secondaryHover.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.25,secondary.x,secondary.y,secondary.z);
if (settings.guiColorsBase) {
secondary=secondaryActive;
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.7,secondarySemiActive.x,secondarySemiActive.y,secondarySemiActive.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.9,secondaryHover.x,secondaryHover.y,secondaryHover.z);
ImGui::ColorConvertHSVtoRGB(hue,sat,val*0.5,secondaryActive.x,secondaryActive.y,secondaryActive.z);
} else {
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.75,secondarySemiActive.x,secondarySemiActive.y,secondarySemiActive.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.5,secondaryHover.x,secondaryHover.y,secondaryHover.z);
ImGui::ColorConvertHSVtoRGB(hue,sat*0.9,val*0.25,secondary.x,secondary.y,secondary.z);
}
sty.Colors[ImGuiCol_WindowBg]=uiColors[GUI_COLOR_FRAME_BACKGROUND];
@ -6042,6 +6238,11 @@ FurnaceGUI::FurnaceGUI():
bindSetPending(false),
nextScroll(-1.0f),
nextAddScroll(0.0f),
transposeAmount(0),
randomizeMin(0),
randomizeMax(255),
scaleMin(0.0f),
scaleMax(100.0f),
oldOrdersLen(0) {
// octave 1
@ -6325,6 +6526,12 @@ FurnaceGUI::FurnaceGUI():
0
}
));
cat.systems.push_back(FurnaceGUISysDef(
"WonderSwan", {
DIV_SYSTEM_SWAN, 64, 0, 0,
0
}
));
sysCategories.push_back(cat);
cat=FurnaceGUISysCategory("Computers");

View File

@ -29,6 +29,9 @@
#define rightClickable if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) ImGui::SetKeyboardFocusHere(-1);
#define handleUnimportant if (settings.insFocusesPattern && patternOpen) {nextWindow=GUI_WINDOW_PATTERN;}
#define unimportant(x) if (x) {handleUnimportant}
enum FurnaceGUIColors {
GUI_COLOR_BACKGROUND=0,
GUI_COLOR_FRAME_BACKGROUND,
@ -230,6 +233,10 @@ enum FurnaceGUIActions {
GUI_ACTION_PAT_CUT,
GUI_ACTION_PAT_COPY,
GUI_ACTION_PAT_PASTE,
GUI_ACTION_PAT_PASTE_MIX,
GUI_ACTION_PAT_PASTE_MIX_BG,
GUI_ACTION_PAT_PASTE_FLOOD,
GUI_ACTION_PAT_PASTE_OVERFLOW,
GUI_ACTION_PAT_CURSOR_UP,
GUI_ACTION_PAT_CURSOR_DOWN,
GUI_ACTION_PAT_CURSOR_LEFT,
@ -265,6 +272,18 @@ enum FurnaceGUIActions {
GUI_ACTION_PAT_COLLAPSE,
GUI_ACTION_PAT_INCREASE_COLUMNS,
GUI_ACTION_PAT_DECREASE_COLUMNS,
GUI_ACTION_PAT_INTERPOLATE,
GUI_ACTION_PAT_FADE_IN,
GUI_ACTION_PAT_FADE_OUT,
GUI_ACTION_PAT_INVERT_VALUES,
GUI_ACTION_PAT_FLIP_SELECTION,
GUI_ACTION_PAT_COLLAPSE_ROWS,
GUI_ACTION_PAT_EXPAND_ROWS,
GUI_ACTION_PAT_COLLAPSE_PAT,
GUI_ACTION_PAT_EXPAND_PAT,
GUI_ACTION_PAT_COLLAPSE_SONG,
GUI_ACTION_PAT_EXPAND_SONG,
GUI_ACTION_PAT_LATCH,
GUI_ACTION_PAT_MAX,
GUI_ACTION_INS_LIST_MIN,
@ -331,6 +350,14 @@ enum FurnaceGUIActions {
GUI_ACTION_MAX
};
enum PasteMode {
GUI_PASTE_MODE_NORMAL=0,
GUI_PASTE_MODE_MIX_FG,
GUI_PASTE_MODE_MIX_BG,
GUI_PASTE_MODE_FLOOD,
GUI_PASTE_MODE_OVERFLOW
};
#define FURKMOD_CTRL (1<<31)
#define FURKMOD_SHIFT (1<<29)
#define FURKMOD_META (1<<28)
@ -493,6 +520,9 @@ class FurnaceGUI {
int statusDisplay;
float dpiScale;
int viewPrevPattern;
int guiColorsBase;
int avoidRaisingPattern;
int insFocusesPattern;
unsigned int maxUndoSteps;
String mainFontPath;
String patFontPath;
@ -533,6 +563,9 @@ class FurnaceGUI {
statusDisplay(0),
dpiScale(0.0f),
viewPrevPattern(1),
guiColorsBase(0),
avoidRaisingPattern(0),
insFocusesPattern(1),
maxUndoSteps(100),
mainFontPath(""),
patFontPath(""),
@ -641,6 +674,8 @@ class FurnaceGUI {
ImVec2 threeChars, twoChars;
SelectionPoint sel1, sel2;
int dummyRows, demandX;
int transposeAmount, randomizeMin, randomizeMax;
float scaleMin, scaleMax;
int oldOrdersLen;
DivOrders oldOrders;
@ -709,9 +744,10 @@ class FurnaceGUI {
void doInsert();
void doTranspose(int amount);
void doCopy(bool cut);
void doPaste();
void doPaste(PasteMode mode=GUI_PASTE_MODE_NORMAL);
void doUndo();
void doRedo();
void editOptions(bool topMenu);
void play(int row=0);
void stop();

View File

@ -59,7 +59,7 @@ const char* ssgEnvTypes[8]={
};
const char* fmParamNames[3][27]={
{"Algorithm", "Feedback", "LFO > Freq", "LFO > Amp", "Attack", "Decay", "Decay 2", "Release", "Sustain", "Level", "EnvScale", "Multiplier", "Detune", "Detune 2", "SSG-EG", "AM", "AM Depth", "Vibrato Depth", "EnvAlternate", "EnvAlternate", "LevelScale/key", "Sustain", "Vibrato", "Waveform", "EnvScale/key", "OP2 HalfSine", "OP1 HalfSine"},
{"Algorithm", "Feedback", "LFO > Freq", "LFO > Amp", "Attack", "Decay", "Decay 2", "Release", "Sustain", "Level", "EnvScale", "Multiplier", "Detune", "Detune 2", "SSG-EG", "AM", "AM Depth", "Vibrato Depth", "Sustained", "Sustained", "Level Scaling", "Sustain", "Vibrato", "Waveform", "Key Scale Rate", "OP2 Half Sine", "OP1 Half Sine"},
{"ALG", "FB", "FMS/PMS", "AMS", "AR", "DR", "SR", "RR", "SL", "TL", "KS", "MULT", "DT", "DT2", "SSG-EG", "AM", "AMD", "FMD", "EGT", "EGT", "KSL", "SUS", "VIB", "WS", "KSR", "DC", "DM"},
{"ALG", "FB", "FMS/PMS", "AMS", "AR", "DR", "D2R", "RR", "SL", "TL", "RS", "MULT", "DT", "DT2", "SSG-EG", "AM", "DAM", "DVB", "EGT", "EGS", "KSL", "SUS", "VIB", "WS", "KSR", "DC", "DM"}
};
@ -81,7 +81,15 @@ const char* opllInsNames[17]={
"Synth Bass",
"Acoustic Bass",
"Electric Guitar",
"Drums (compatibility only!)"
"Drums"
};
const char* oplWaveforms[8]={
"Sine", "Half Sine", "Absolute Sine", "Quarter Sine", "Squished Sine", "Squished AbsSine", "Square", "Derived Square"
};
const char* opzWaveforms[8]={
"Sine", "Triangle", "Cut Sine", "Cut Triangle", "Squished Sine", "Squished Triangle", "Squished AbsSine", "Squished AbsTriangle"
};
enum FMParams {
@ -796,7 +804,8 @@ void FurnaceGUI::drawInsEdit() {
int asInt[256];
float loopIndicator[256];
int opCount=4;
if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL) opCount=2;
if (ins->type==DIV_INS_OPLL) opCount=2;
if (ins->type==DIV_INS_OPL) opCount=(ins->fm.ops==4)?4:2;
if (ImGui::BeginTabItem("FM")) {
if (ImGui::BeginTable("fmDetails",3,ImGuiTableFlags_SizingStretchSame)) {
@ -816,7 +825,25 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextColumn();
drawAlgorithm(ins->fm.alg,FM_ALGS_4OP,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
break;
case DIV_INS_OPL:
case DIV_INS_OPL: {
bool fourOp=(ins->fm.ops==4);
bool drums=ins->fm.opllPreset==16;
int algMax=fourOp?3:1;
ImGui::TableNextColumn();
ins->fm.alg&=algMax;
P(ImGui::SliderScalar(FM_NAME(FM_FB),ImGuiDataType_U8,&ins->fm.fb,&_ZERO,&_SEVEN)); rightClickable
if (ImGui::Checkbox("4-op",&fourOp)) { PARAMETER
ins->fm.ops=fourOp?4:2;
}
ImGui::TableNextColumn();
P(ImGui::SliderScalar(FM_NAME(FM_ALG),ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&algMax)); rightClickable
if (ImGui::Checkbox("Drums",&drums)) { PARAMETER
ins->fm.opllPreset=drums?16:0;
}
ImGui::TableNextColumn();
drawAlgorithm(ins->fm.alg&1,FM_ALGS_2OP_OPL,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
break;
}
case DIV_INS_OPLL: {
bool dc=ins->fm.fms;
bool dm=ins->fm.ams;
@ -857,12 +884,84 @@ void FurnaceGUI::drawInsEdit() {
}
if (ins->type==DIV_INS_OPLL && ins->fm.opllPreset==16) {
ImGui::Text("the Drums patch is only there for compatibility.\nit is highly encouraged you use the OPLL (drums) system instead!");
P(ImGui::Checkbox("Fixed frequency mode",&ins->fm.fixedDrums));
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("when enabled, drums will be set to the specified frequencies, ignoring the note.");
}
if (ins->fm.fixedDrums) {
int block=0;
int fNum=0;
if (ImGui::BeginTable("fixedDrumSettings",3)) {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn();
ImGui::Text("Drum");
ImGui::TableNextColumn();
ImGui::Text("Block");
ImGui::TableNextColumn();
ImGui::Text("FreqNum");
ImGui::TableNextRow();
ImGui::TableNextColumn();
block=(ins->fm.kickFreq>>9)&7;
fNum=ins->fm.kickFreq&511;
ImGui::Text("Kick");
ImGui::TableNextColumn();
if (ImGui::InputInt("##DBlock0",&block,1,1)) {
if (block<0) block=0;
if (block>7) block=7;
ins->fm.kickFreq=(block<<9)|fNum;
}
ImGui::TableNextColumn();
if (ImGui::InputInt("##DFreq0",&fNum,1,1)) {
if (fNum<0) fNum=0;
if (fNum>511) fNum=511;
ins->fm.kickFreq=(block<<9)|fNum;
}
ImGui::TableNextRow();
ImGui::TableNextColumn();
block=(ins->fm.snareHatFreq>>9)&7;
fNum=ins->fm.snareHatFreq&511;
ImGui::Text("Snare/Hi-hat");
ImGui::TableNextColumn();
if (ImGui::InputInt("##DBlock1",&block,1,1)) {
if (block<0) block=0;
if (block>7) block=7;
ins->fm.snareHatFreq=(block<<9)|fNum;
}
ImGui::TableNextColumn();
if (ImGui::InputInt("##DFreq1",&fNum,1,1)) {
if (fNum<0) fNum=0;
if (fNum>511) fNum=511;
ins->fm.snareHatFreq=(block<<9)|fNum;
}
ImGui::TableNextRow();
ImGui::TableNextColumn();
block=(ins->fm.tomTopFreq>>9)&7;
fNum=ins->fm.tomTopFreq&511;
ImGui::Text("Tom/Top");
ImGui::TableNextColumn();
if (ImGui::InputInt("##DBlock2",&block,1,1)) {
if (block<0) block=0;
if (block>7) block=7;
ins->fm.tomTopFreq=(block<<9)|fNum;
}
ImGui::TableNextColumn();
if (ImGui::InputInt("##DFreq2",&fNum,1,1)) {
if (fNum<0) fNum=0;
if (fNum>511) fNum=511;
ins->fm.tomTopFreq=(block<<9)|fNum;
}
ImGui::EndTable();
}
}
}
bool willDisplayOps=true;
if (ins->type==DIV_INS_OPLL && ins->fm.opllPreset!=0) willDisplayOps=false;
if (!willDisplayOps && ins->type==DIV_INS_OPLL) {
ins->fm.op[1].tl&=15;
P(ImGui::SliderScalar("Volume##TL",ImGuiDataType_U8,&ins->fm.op[1].tl,&_FIFTEEN,&_ZERO)); rightClickable
}
if (willDisplayOps) if (ImGui::BeginTable("FMOperators",2,ImGuiTableFlags_SizingStretchSame)) {
@ -892,18 +991,30 @@ void FurnaceGUI::drawInsEdit() {
maxTl=63;
}
}
if (ins->type==DIV_INS_OPL) {
maxTl=63;
}
int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ)?31:15;
bool ssgOn=op.ssgEnv&8;
bool ksrOn=op.ksr;
bool vibOn=op.vib;
bool susOn=op.sus; // don't you make fun of this one
unsigned char ssgEnv=op.ssgEnv&7;
if (ImGui::Checkbox((ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL)?FM_NAME(FM_EGS):"SSG On",&ssgOn)) { PARAMETER
op.ssgEnv=(op.ssgEnv&7)|(ssgOn<<3);
if (ins->type!=DIV_INS_OPL && ins->type!=DIV_INS_OPZ) {
if (ImGui::Checkbox((ins->type==DIV_INS_OPLL)?FM_NAME(FM_EGS):"SSG On",&ssgOn)) { PARAMETER
op.ssgEnv=(op.ssgEnv&7)|(ssgOn<<3);
}
if (ins->type==DIV_INS_FM) {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Only for Genesis and Neo Geo systems");
}
}
}
if (ins->type==DIV_INS_FM) {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Only for Genesis and Neo Geo systems");
if (ins->type==DIV_INS_OPL) {
if (ImGui::Checkbox(FM_NAME(FM_SUS),&susOn)) { PARAMETER
op.sus=susOn;
}
}
@ -917,6 +1028,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
op.ar&=maxArDr;
P(ImGui::SliderScalar("##AR",ImGuiDataType_U8,&op.ar,&maxArDr,&_ZERO)); rightClickable
ImGui::TableNextColumn();
ImGui::Text("%s",FM_NAME(FM_AR));
@ -924,6 +1036,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
op.dr&=maxArDr;
P(ImGui::SliderScalar("##DR",ImGuiDataType_U8,&op.dr,&maxArDr,&_ZERO)); rightClickable
ImGui::TableNextColumn();
ImGui::Text("%s",FM_NAME(FM_DR));
@ -954,6 +1067,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
op.tl&=maxTl;
P(ImGui::SliderScalar("##TL",ImGuiDataType_U8,&op.tl,&maxTl,&_ZERO)); rightClickable
ImGui::TableNextColumn();
ImGui::Text("%s",FM_NAME(FM_TL));
@ -989,7 +1103,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::SliderInt("##DT",&detune,-3,3)) { PARAMETER
if (ImGui::SliderInt("##DT",&detune,-3,4)) { PARAMETER
op.dt=detune+3;
} rightClickable
ImGui::TableNextColumn();
@ -1014,6 +1128,18 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextColumn();
ImGui::Text("%s",FM_NAME(FM_SSG));
}
if (ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPZ) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
P(ImGui::SliderScalar("##WS",ImGuiDataType_U8,&op.ws,&_ZERO,&_SEVEN,(ins->type==DIV_INS_OPZ)?opzWaveforms[op.ws&7]:oplWaveforms[op.ws&7])); rightClickable
if (ins->type==DIV_INS_OPL && ImGui::IsItemHovered()) {
ImGui::SetTooltip("OPL2/3 only (last 4 waveforms are OPL3 only)");
}
ImGui::TableNextColumn();
ImGui::Text("%s",FM_NAME(FM_WS));
}
ImGui::EndTable();
}
@ -1277,7 +1403,17 @@ void FurnaceGUI::drawInsEdit() {
if (ins->type==DIV_INS_AY8930) {
dutyMax=255;
}
if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_PCE || ins->type==DIV_INS_AMIGA) {
if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_AMIGA) {
dutyMax=0;
}
if (ins->type==DIV_INS_PCE) {
dutyMax=1;
}
if (ins->type==DIV_INS_SWAN) {
dutyLabel="Noise";
dutyMax=8;
}
if (ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPL) {
dutyMax=0;
}
bool dutyIsRel=(ins->type==DIV_INS_C64 && !ins->c64.dutyIsAbs);
@ -1291,7 +1427,7 @@ void FurnaceGUI::drawInsEdit() {
if (ins->type==DIV_INS_TIA) waveMax=15;
if (ins->type==DIV_INS_C64) waveMax=4;
if (ins->type==DIV_INS_SAA1099) waveMax=2;
if (ins->type==DIV_INS_FM) waveMax=0;
if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPZ) waveMax=0;
if (ins->type==DIV_INS_MIKEY) waveMax=0;
const char** waveNames=ayShapeBits;
@ -1311,9 +1447,9 @@ void FurnaceGUI::drawInsEdit() {
if (volMax>0) {
NORMAL_MACRO(ins->std.volMacro,ins->std.volMacroLen,ins->std.volMacroLoop,ins->std.volMacroRel,volMin,volMax,"vol",volumeLabel,160,ins->std.volMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_VOLUME],mmlString[0],volMin,volMax,NULL,false);
}
NORMAL_MACRO(ins->std.arpMacro,ins->std.arpMacroLen,ins->std.arpMacroLoop,ins->std.arpMacroRel,arpMacroScroll,arpMacroScroll+24,"arp","Arpeggio",160,ins->std.arpMacroOpen,false,NULL,true,&arpMacroScroll,(arpMode?0:-80),0,0,&ins->std.arpMacroMode,uiColors[GUI_COLOR_MACRO_PITCH],mmlString[1],-92,94,(ins->std.arpMacroMode?(&macroHoverNote):NULL),true);
NORMAL_MACRO(ins->std.arpMacro,ins->std.arpMacroLen,ins->std.arpMacroLoop,ins->std.arpMacroRel,arpMacroScroll,arpMacroScroll+24,"arp","Arpeggio",160,ins->std.arpMacroOpen,false,NULL,true,&arpMacroScroll,(arpMode?-60:-80),0,0,&ins->std.arpMacroMode,uiColors[GUI_COLOR_MACRO_PITCH],mmlString[1],-92,94,(ins->std.arpMacroMode?(&macroHoverNote):NULL),true);
if (dutyMax>0) {
if (ins->type == DIV_INS_MIKEY) {
if (ins->type==DIV_INS_MIKEY) {
NORMAL_MACRO(ins->std.dutyMacro,ins->std.dutyMacroLen,ins->std.dutyMacroLoop,ins->std.dutyMacroRel,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacroOpen,true,mikeyFeedbackBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false);
}
else {
@ -1696,7 +1832,7 @@ void FurnaceGUI::drawWaveEdit() {
DivWavetable* wave=e->song.wave[curWave];
ImGui::Text("Width");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("use a width of 32 on Game Boy and PC Engine.\nany other widths will be scaled during playback.");
ImGui::SetTooltip("use a width of 32 on Game Boy, PC Engine and WonderSwan.\nany other widths will be scaled during playback.");
}
ImGui::SameLine();
ImGui::SetNextItemWidth(128.0f*dpiScale);
@ -1710,7 +1846,7 @@ void FurnaceGUI::drawWaveEdit() {
ImGui::SameLine();
ImGui::Text("Height");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("use a height of:\n- 15 for Game Boy\n- 31 for PC Engine\nany other heights will be scaled during playback.");
ImGui::SetTooltip("use a height of:\n- 15 for Game Boy and WonderSwan\n- 31 for PC Engine\nany other heights will be scaled during playback.");
}
ImGui::SameLine();
ImGui::SetNextItemWidth(128.0f*dpiScale);

View File

@ -75,6 +75,10 @@ void FurnaceGUI::drawOrders() {
e->setOrder(i);
curNibble=false;
orderCursor=-1;
if (orderEditMode==0) {
handleUnimportant;
}
}
ImGui::PopStyleColor();
for (int j=0; j<e->getTotalChannelCount(); j++) {
@ -111,6 +115,10 @@ void FurnaceGUI::drawOrders() {
curNibble=false;
}
}
if (orderEditMode==0) {
handleUnimportant;
}
}
if (!pat->name.empty() && ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s",pat->name.c_str());
@ -148,21 +156,21 @@ void FurnaceGUI::drawOrders() {
ImGui::EndTable();
}
ImGui::NextColumn();
if (ImGui::Button(ICON_FA_PLUS)) {
if (ImGui::Button(ICON_FA_PLUS)) { handleUnimportant
// add order row (new)
doAction(GUI_ACTION_ORDERS_ADD);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Add new order");
}
if (ImGui::Button(ICON_FA_MINUS)) {
if (ImGui::Button(ICON_FA_MINUS)) { handleUnimportant
// remove this order row
doAction(GUI_ACTION_ORDERS_REMOVE);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Remove order");
}
if (ImGui::Button(ICON_FA_FILES_O)) {
}
if (ImGui::Button(ICON_FA_FILES_O)) { handleUnimportant
// duplicate order row
doAction(GUI_ACTION_ORDERS_DUPLICATE);
}
@ -172,21 +180,21 @@ void FurnaceGUI::drawOrders() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Duplicate order (right-click to deep clone)");
}
if (ImGui::Button(ICON_FA_ANGLE_UP)) {
if (ImGui::Button(ICON_FA_ANGLE_UP)) { handleUnimportant
// move order row up
doAction(GUI_ACTION_ORDERS_MOVE_UP);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Move order up");
}
if (ImGui::Button(ICON_FA_ANGLE_DOWN)) {
if (ImGui::Button(ICON_FA_ANGLE_DOWN)) { handleUnimportant
// move order row down
doAction(GUI_ACTION_ORDERS_MOVE_DOWN);
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Move order down");
}
if (ImGui::Button(ICON_FA_ANGLE_DOUBLE_DOWN)) {
if (ImGui::Button(ICON_FA_ANGLE_DOUBLE_DOWN)) { handleUnimportant
// duplicate order row at end
doAction(GUI_ACTION_ORDERS_DUPLICATE_END);
}
@ -196,7 +204,7 @@ void FurnaceGUI::drawOrders() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Duplicate order at end of song (right-click to deep clone)");
}
if (ImGui::Button(changeAllOrders?ICON_FA_LINK"##ChangeAll":ICON_FA_CHAIN_BROKEN"##ChangeAll")) {
if (ImGui::Button(changeAllOrders?ICON_FA_LINK"##ChangeAll":ICON_FA_CHAIN_BROKEN"##ChangeAll")) { handleUnimportant
// whether to change one or all orders in a row
changeAllOrders=!changeAllOrders;
}
@ -217,7 +225,7 @@ void FurnaceGUI::drawOrders() {
} else {
orderEditModeLabel=ICON_FA_MOUSE_POINTER "##OrderEditMode";
}
if (ImGui::Button(orderEditModeLabel)) {
if (ImGui::Button(orderEditModeLabel)) { handleUnimportant
orderEditMode++;
if (orderEditMode>3) orderEditMode=0;
curNibble=false;

View File

@ -332,6 +332,7 @@ void FurnaceGUI::drawPattern() {
}
if (!patternOpen) return;
bool inhibitMenu=false;
float scrollX=0;
if (e->isPlaying() && followPattern) cursor.y=oldRow;
@ -357,7 +358,7 @@ void FurnaceGUI::drawPattern() {
sel2.xFine^=sel1.xFine;
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f));
if (ImGui::Begin("Pattern",&patternOpen)) {
if (ImGui::Begin("Pattern",&patternOpen,settings.avoidRaisingPattern?ImGuiWindowFlags_NoBringToFrontOnFocus:0)) {
//ImGui::SetWindowSize(ImVec2(scrW*dpiScale,scrH*dpiScale));
patWindowPos=ImGui::GetWindowPos();
patWindowSize=ImGui::GetWindowSize();
@ -411,6 +412,7 @@ void FurnaceGUI::drawPattern() {
}
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
fancyPattern=!fancyPattern;
inhibitMenu=true;
e->enableCommandStream(fancyPattern);
e->getCommandStream(cmdStream);
cmdStream.clear();
@ -448,9 +450,15 @@ void FurnaceGUI::drawPattern() {
keyHit[i]=0.2;
e->keyHit[i]=false;
}
chanHead.x*=0.25+keyHit[i]; chanHead.y*=0.25+keyHit[i]; chanHead.z*=0.25+keyHit[i];
chanHeadActive.x*=0.8; chanHeadActive.y*=0.8; chanHeadActive.z*=0.8;
chanHeadHover.x*=0.4+keyHit[i]; chanHeadHover.y*=0.4+keyHit[i]; chanHeadHover.z*=0.4+keyHit[i];
if (settings.guiColorsBase) {
chanHead.x*=1.0-keyHit[i]; chanHead.y*=1.0-keyHit[i]; chanHead.z*=1.0-keyHit[i];
chanHeadActive.x*=0.5; chanHeadActive.y*=0.5; chanHeadActive.z*=0.5;
chanHeadHover.x*=0.9-keyHit[i]; chanHeadHover.y*=0.9-keyHit[i]; chanHeadHover.z*=0.9-keyHit[i];
} else {
chanHead.x*=0.25+keyHit[i]; chanHead.y*=0.25+keyHit[i]; chanHead.z*=0.25+keyHit[i];
chanHeadActive.x*=0.8; chanHeadActive.y*=0.8; chanHeadActive.z*=0.8;
chanHeadHover.x*=0.4+keyHit[i]; chanHeadHover.y*=0.4+keyHit[i]; chanHeadHover.z*=0.4+keyHit[i];
}
keyHit[i]-=0.02*60.0*ImGui::GetIO().DeltaTime;
if (keyHit[i]<0) keyHit[i]=0;
ImGui::PushStyleColor(ImGuiCol_Header,chanHead);
@ -475,6 +483,7 @@ void FurnaceGUI::drawPattern() {
if (muted) ImGui::PopStyleColor();
ImGui::PopStyleColor(3);
if (settings.soloAction!=2) if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
inhibitMenu=true;
e->toggleSolo(i);
}
if (extraChannelButtons==2) {
@ -801,6 +810,13 @@ void FurnaceGUI::drawPattern() {
ImGui::PopFont();
}
ImGui::PopStyleVar();
if (patternOpen) {
if (!inhibitMenu && ImGui::IsItemClicked(ImGuiMouseButton_Right)) ImGui::OpenPopup("patternActionMenu");
if (ImGui::BeginPopup("patternActionMenu",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
editOptions(false);
ImGui::EndPopup();
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PATTERN;
ImGui::End();
}

View File

@ -162,6 +162,16 @@ void FurnaceGUI::drawSettings() {
settings.allowEditDocking=allowEditDockingB;
}
bool avoidRaisingPatternB=settings.avoidRaisingPattern;
if (ImGui::Checkbox("Don't raise pattern editor on click",&avoidRaisingPatternB)) {
settings.avoidRaisingPattern=avoidRaisingPatternB;
}
bool insFocusesPatternB=settings.insFocusesPattern;
if (ImGui::Checkbox("Focus pattern editor when selecting instrument",&insFocusesPatternB)) {
settings.insFocusesPattern=insFocusesPatternB;
}
bool restartOnFlagChangeB=settings.restartOnFlagChange;
if (ImGui::Checkbox("Restart song when changing system properties",&restartOnFlagChangeB)) {
settings.restartOnFlagChange=restartOnFlagChangeB;
@ -383,7 +393,7 @@ void FurnaceGUI::drawSettings() {
}
bool macroViewB=settings.macroView;
if (ImGui::Checkbox("Classic macro view (standard macros only)",&macroViewB)) {
if (ImGui::Checkbox("Classic macro view (standard macros only; deprecated!)",&macroViewB)) {
settings.macroView=macroViewB;
}
@ -425,6 +435,13 @@ void FurnaceGUI::drawSettings() {
if (ImGui::TreeNode("Color scheme")) {
if (ImGui::TreeNode("General")) {
ImGui::Text("Color scheme type:");
if (ImGui::RadioButton("Dark##gcb0",settings.guiColorsBase==0)) {
settings.guiColorsBase=0;
}
if (ImGui::RadioButton("Light##gcb1",settings.guiColorsBase==1)) {
settings.guiColorsBase=1;
}
UI_COLOR_CONFIG(GUI_COLOR_BACKGROUND,"Background");
UI_COLOR_CONFIG(GUI_COLOR_FRAME_BACKGROUND,"Window background");
UI_COLOR_CONFIG(GUI_COLOR_MODAL_BACKDROP,"Modal backdrop");
@ -817,6 +834,14 @@ void FurnaceGUI::drawSettings() {
#define LOAD_KEYBIND(x,y) \
actionKeys[x]=e->getConfInt("keybind_" #x,y);
#define clampSetting(x,minV,maxV) \
if (x<minV) { \
x=minV; \
} \
if (x>maxV) { \
x=maxV; \
}
void FurnaceGUI::syncSettings() {
settings.mainFontSize=e->getConfInt("mainFontSize",18);
settings.patFontSize=e->getConfInt("patFontSize",18);
@ -844,7 +869,6 @@ void FurnaceGUI::syncSettings() {
settings.allowEditDocking=e->getConfInt("allowEditDocking",0);
settings.chipNames=e->getConfInt("chipNames",0);
settings.overflowHighlight=e->getConfInt("overflowHighlight",0);
if (settings.fmNames<0 || settings.fmNames>2) settings.fmNames=0;
settings.partyTime=e->getConfInt("partyTime",0);
settings.germanNotation=e->getConfInt("germanNotation",0);
settings.stepOnDelete=e->getConfInt("stepOnDelete",0);
@ -856,6 +880,46 @@ void FurnaceGUI::syncSettings() {
settings.statusDisplay=e->getConfInt("statusDisplay",0);
settings.dpiScale=e->getConfFloat("dpiScale",0.0f);
settings.viewPrevPattern=e->getConfInt("viewPrevPattern",1);
settings.guiColorsBase=e->getConfInt("guiColorsBase",0);
settings.avoidRaisingPattern=e->getConfInt("avoidRaisingPattern",0);
settings.insFocusesPattern=e->getConfInt("insFocusesPattern",1);
clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96);
clampSetting(settings.iconSize,2,48);
clampSetting(settings.audioEngine,0,1);
clampSetting(settings.audioQuality,0,1);
clampSetting(settings.audioBufSize,32,4096);
clampSetting(settings.audioRate,8000,384000);
clampSetting(settings.arcadeCore,0,1);
clampSetting(settings.ym2612Core,0,1);
clampSetting(settings.saaCore,0,1);
clampSetting(settings.mainFont,0,6);
clampSetting(settings.patFont,0,6);
clampSetting(settings.patRowsBase,0,1);
clampSetting(settings.orderRowsBase,0,1);
clampSetting(settings.soloAction,0,2);
clampSetting(settings.pullDeleteBehavior,0,1);
clampSetting(settings.wrapHorizontal,0,2);
clampSetting(settings.wrapVertical,0,2);
clampSetting(settings.macroView,0,1);
clampSetting(settings.fmNames,0,2);
clampSetting(settings.allowEditDocking,0,1);
clampSetting(settings.chipNames,0,1);
clampSetting(settings.overflowHighlight,0,1);
clampSetting(settings.partyTime,0,1);
clampSetting(settings.germanNotation,0,1);
clampSetting(settings.stepOnDelete,0,1);
clampSetting(settings.scrollStep,0,1);
clampSetting(settings.sysSeparators,0,1);
clampSetting(settings.forceMono,0,1);
clampSetting(settings.controlLayout,0,3);
clampSetting(settings.statusDisplay,0,3);
clampSetting(settings.dpiScale,0.0f,4.0f);
clampSetting(settings.viewPrevPattern,0,1);
clampSetting(settings.guiColorsBase,0,1);
clampSetting(settings.avoidRaisingPattern,0,1);
clampSetting(settings.insFocusesPattern,0,1);
// keybinds
LOAD_KEYBIND(GUI_ACTION_OPEN,FURKMOD_CMD|SDLK_o);
@ -1051,6 +1115,9 @@ void FurnaceGUI::commitSettings() {
e->setConf("statusDisplay",settings.statusDisplay);
e->setConf("dpiScale",settings.dpiScale);
e->setConf("viewPrevPattern",settings.viewPrevPattern);
e->setConf("guiColorsBase",settings.guiColorsBase);
e->setConf("avoidRaisingPattern",settings.avoidRaisingPattern);
e->setConf("insFocusesPattern",settings.insFocusesPattern);
PUT_UI_COLOR(GUI_COLOR_BACKGROUND);
PUT_UI_COLOR(GUI_COLOR_FRAME_BACKGROUND);