From 62b312980033bad470531905f2bcdb3b46cc1c14 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 18 May 2021 07:39:11 +0100 Subject: Added a sfx2h tool --- tools/sfx2h.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tools/sfx2h.md (limited to 'tools/sfx2h.md') diff --git a/tools/sfx2h.md b/tools/sfx2h.md new file mode 100644 index 0000000..bfd6b88 --- /dev/null +++ b/tools/sfx2h.md @@ -0,0 +1,51 @@ +# sfx2h.py + +This tool requires Python 3 and can generate a C include file from a sfx file +as saved by `sfxed`. + +Being Python is easier to modify and adapt to your own needs! + +Example: +``` +sfx2h.py ../test.sfx sounds +``` + +Will generate: +``` + +/* file: ../example/test.sfx */ +#ifndef SOUNDS_H_ +#define SOUNDS_H_ + +#include "beeper.h" + +enum sounds_enum { + SOUNDS_LASER = 1, + SOUNDS_ZAP, + SOUNDS_DRILL, + SOUNDS_EXPLO, +}; + +#ifdef LOCAL + +const struct beeper_sfx sounds[] = { +{ 0x01, 0x20, 0x78, 0xfc, 0x00 }, +{ 0x02, 0x10, 0x0c, 0x00, 0x00 }, +{ 0x01, 0x20, 0x01, 0x00, 0x00 }, +{ 0x02, 0x20, 0x80, 0xff, 0x00 }, +}; + +#else +extern const struct beeper_sfx sounds[]; +#endif +#endif // SOUNDS_H_ +``` + +You can include it normally on any C file, just remember to define `LOCAL` +before included in the module containing the data (only once!). + +## CAVEATS + +* Is not perfuming exhaustive checks on the effects' names or the provided id +* `LOCAL` is not undefined after used + -- cgit v1.2.3