How to build - dgrfactory/spcplay GitHub Wiki

Replace Variables

The following variable strings are included in codes:

Variable String Replacement String Example
$CAP_FILE_VER File version 2.0.0.0
$CAP_PRODUCT_VER Product version 2.0.0
$YEAR Current year 2024
$DSP_ALIGN Since v2.20.5:Align adjustment of DSP memory addressDetails: If ERROR 104 occurs when started SPCPLAY 0

These variables are not automatically replaced, so please replace them yourself.
I recommend copying the files and replacing them automatically with a batch file.

SPCPLAY.EXE

There are several ways to build SPCPLAY.

Using Free Pascal

Since v2.20.1:
Building using Free Pascal is supported since v2.20.1 source code.

Required software for build:

Build commands:

windres.exe -l 0x411 -D "NDEBUG" -i spcplay.rc -o spcplay.res
fpc.exe -dFREEPASCAL -Pi386 -Twin32 -vewin -ospcplay.exe spcplay.dpr
strip.exe -s -x spcplay.exe

Using Borland Delphi

Since v2.20.6:
Older Delphi versions do not support UTF-8, you need to convert the source code to ANSI before building.

Required software for build:

  • Borland Delphi 6 UP2 RTL3

Build commands:

brcc32.exe -l 0x411 -d "NDEBUG" -fo spcplay.res spcplay.rc
dcc32.exe spcplay.dpr

SNESAPU.DLL

Using Microsoft Visual C++

Required software for build:

Build commands:

mkdir Release
nasm.exe -D WIN32 -D STDCALL -O2 -w-macro-params -f win32 -o Release\SPC700.obj SPC700.asm
nasm.exe -D WIN32 -D STDCALL -O2 -w-macro-params -f win32 -o Release\DSP.obj DSP.asm
nasm.exe -D WIN32 -D STDCALL -O2 -w-macro-params -f win32 -o Release\APU.obj APU.asm
rc.exe /l 0x411 /d "NDEBUG" /fo Release\version.res version.rc
cl.exe @option\snesapu-cl.txt
link.exe @option\snesapu-link.txt

For 3rd-party players:

copy /y thirdparty\* .
  : (nasm, rc, cl)
link.exe @option\snesapu-3rd-link.txt

If ERROR 104 occurs when started SPCPLAY

ERROR 104 is a memory map error, SPCPLAY has stopped the operation of SNESAPU for safety reasons.
In this state, the address to a certain variable is invalid, which could lead to memory-leak and buffer-overflow.
Depending on the environment or builder state, you may need to adjust memory map.

How to fix:

  1. Change $DSP_ALIGN variable to 0, 64, 128, or 192, and rebuild.
  2. Change this value to other until the ERROR 104 does not occur.

The builder may generate a map file.
If "SNESAPU.map" file output to the "Release" folder after built, this will give you a hint.
If the address of "_mix" ends with 00, it will be successful.

 0002:00123300       _mix                       10130300     DSP.obj
            ⬆️                                       ⬆️