Skip to content

About improved SNESAPU.DLL

dgrfactory edited this page Oct 10, 2022 · 36 revisions

Features

The SNESAPU published here is based on v2.0 by Alpha-II Productions with various improvements and customizations, some features are ported from v3.0.
Some emulators can perfectly reproduce the actual device, but the SNESAPU is not perfect because slightly old design.
Instead, it provides high-quality sound output and a number of features that will especially please those who enjoy the SPC as a soundtrack.

Main customized parts:

  • 8-point sinc interporation.
    • Features ported from v3.0, sound is as clear as a CD without the muffled sound of the actual device.
  • Low-pass filter as in the actual device.
    • A low-pass filter with the same cutoff frequency as the actual device gives it an analog feel.
  • Same noise generator as in the actual device.
    • Before just a random value, now changed to the same algorithm as the actual device.
  • Script700/TimerTrick compatible.
    • Can play PuyoPuyo's SPC without patching. See below.
  • Data transfer to actual APU using external equipment.
    • Use parallel port or additional hardware to can play SPC using actual device. See below.
  • Switching context.
    • It can makes it look as if multiple SPCs are being processed simultaneously.

How to emulate

To emulate the SPC700 and DSP, call APIs of the SNESAPU in the following order:

  1. void SetAPUOpt(u32 mixType, u32 numChn, u32 bits, u32 rate, u32 inter, u32 opts);
  2. void LoadSPCFile(void *pFile);
  3. void* EmuAPU(void *pBuf, u32 len, u8 type);

See APU.h for a description of each API.

Compatible Script700 support

The Script700 is an auxiliary script of SPC700 used in Japan.
Some songs (ex. PuyoPuyo series, RPG tsukuru 2, Furai no shiren, etc.) are not played simply by saving an SPC, because SNES main CPU transfers additional data in real time.
If used the Script700, these special SPCs can be reproduced by mimicking main CPU instructions.

For using the Script700 in the SNES SPC700 Player, save a code of the Script700 to a file with same name as the SPC file, and change extension to "700".
For example, if you want to apply the Script700 to "sample.spc", write a code in "sample.700".
If you want to apply the Script700 for all SPC files in a folder at once, write script in the "65816.700" file instead.

For example, here is the script to correctly play an SPC of PuyoPuyo.
If you write this in the "65816.700" file, you will be able to play it without hacking all SPC files.

	m	0	w0
:001
	w	16384
	a	#1	w0
	m	w0	0

	bra	001

	e

There are many scripts that can be adapted to each game.
KUROHANE Works has made a summary page for the list of known the Script700.
See also: About special SPC (in Japanese)

For coding the Script700, provided an extension plugin for VSCode.
This plug-in provides functions such as instruction highlighting.
See also: Script700 Helper

To use the Script700 with SNESAPU alone, use the following API:
s32 SetScript700(void *pSource);

APU communication support using parallel (LPT) port

This Improved SNESAPU.DLL supports data transfer to a SHVC-SOUND using parallel port.
Refer to the following pages for electronic circuits for transfer.
See also: Snes APU on a PC

To transfer data, install "GiveIO" or "InpOut32" first, and call APIs of the SNESAPU in the following order:

  1. void LoadSPCFile(void *pFile);
  2. s32 TransmitSPC(u32 addr);
    • addr: Data address of parallel port. (ex. 0x378)
    • Result:
      • 0 = Successful transfer
      • not 0 = Failed, see below for the meaning of the numbers.
Result Cause
-1 Not installed GiveIO or InpOut32.
-2 Not supported EPP/ECP mode.
-3 No space available for boot loader.
1 ~ 9 Failed reset SHVC-SOUND.
10 ~ 19
-10 ~ -19
Failed transfer memory loader.
20 ~ 29
-20 ~ -29
Failed transfer SPC buffer.

SPC module support on G.I.M.I.C

In Japan, there is Dojin hardware called G.I.M.I.C which operates a retro music chip and outputs high quality sound.
This device with GMC-SPC2 module can output real SNES music without need for make electronic circuitry.
In addition, it supports optical output and can extract sound from SNES without degradation.

This improved SNESAPU.DLL supports SPC playing using G.I.M.I.C and fast transfer.
Transfer time of is about 1.7 seconds, because unique boot code increases transfer capacity 3 times.
Since the memory used for echo is cleared to 0 in advance, loud noise is not generated at the start of playing.

Clone this wiki locally