Skip to content

How to build

dgrfactory edited this page Jun 22, 2024 · 11 revisions

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

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 Borland Delphi

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

Using Free Pascal (since v2.20.1)

Required software for build:

Build commands:

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

SNESAPU.DLL

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. Open "SNESAPU.inc" in "snesapu" folder with a text editor.
  2. Change DSP_ALIGN to 0, 64, 128, or 192 as per the comments, and rebuild.
    ;Align Adjustment ----------------------
    ;   Note: Please refer to the map file output during build and adjust the numbers,
    ;     so that the lower 8-bits of the start address of '_mix' are '00'.
    ;    If it is not, the output audio will be noisy because occurred memory-leak and
    ;     buffer-overflow.
    ;    The value specified here is 0, 64, 128, or 192.
    DSP_ALIGN   EQU 0                                               ;DSP Object Locate Alignment
                   ⬆️
  3. 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
            ⬆️                                        ⬆️