aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 5a6c60fc39bf0f15e4c3f14eec9950c05ce6a091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Beeper engine

This is simple beeper engine for the ZX Spectrum 48K (or later), designed to be
run from an interrupt handler.

This project was inspired by the works of Steve Turner (of Graftgold fame) and
Shiru. I made this for myself (to be used in my games), and I'm releasing it
in case it is useful to someone else.

The player supports three types of effects:

* Silence (stops the sound)
* Tone (square wave)
* Noise (random)

Tone and noise require:

* the number of frames (ints) to play the effect
* the frequency; the higher the value, the more time the effect will use in the int
* an optional slide to apply to the frequency
* the next sound to play in a chain, or zero to stop (silence)

It is possible to chain multiple sounds and have a loop. To break the loop,
just play "silence" (queue effect 0) or another effect out of the loop.

The beeper library is documented in `sdcc/beeper.h`, and it provides three
functions:

* `beeper_init` to set the effect data and initialize the engine
* `beeper_queue` to schedule an effect to be played starting on next interrupt
  (0 for silence, the effects start on 1)
* `beeper_play` to be called from the interrupt handler on each interrupt

The engine comes with a simple GUI editor (`sfxed`) to design the effects on a PC.

<img src="https://git.usebox.net/beeper-int-zx/plain/sfxed-1.0.0.png" alt="SFXED 1.0.0" style="width:auto;">

`sfxed` uses the Zymosis Z80 CPU emulation engine to execute the player and
collect audio samples to be played using SDL. The sound emulation should be
accurate enough!

The GUI is built with ImGui.

The editor can export the effect data in binary form, so it can be included in
any assembler project, and as a C include file (for example to be used with
SDCC).

Check the `example` directory for a sample.

## Building the player

Check the README file in `sdcc` directory.

The code is provided in assembler for SDCC, to be built as a library. It should
be easy to convert to other assemblers.

## Building the editor

Edit the `Makefile` and change the following variables to point to the corerct directory:

- `IMGUI_DIR`: a checkout of ImGui; see: https://github.com/ocornut/imgui
- `IMGUI_FILE_DIALOG_DIR`: a checkout of ImGuiFileDialog "Lib_Only"; see: https://github.com/aiekick/ImGuiFileDialog

To build on Linux, you'll need:

- GNU Make, GCC
- SDL2 for development (e.g. libsdl2-dev in Debian)

When all the requirements are satisfied, just run `make`.

## License

This software is distributed under MIT license. See COPYING file.

**TL;DR**: the only condition is that you are required to preserve the copyright
and license notices. Licensed works, modifications, and larger works may be
distributed under different terms and without source code; this includes any game
made with the help of this software.