scsp: add "slot" example
This demonstrates the most basic possible SCSP usage. Strangely this does not work in Kronos, only in mednafen and on real hardware. I'd like to find a hack, if possible, that fixes Kronos playback.
This commit is contained in:
parent
9db0c570d9
commit
29e049ab69
11
Makefile
11
Makefile
@ -20,6 +20,9 @@ endef
|
||||
%.bin.o: %.bin
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.pcm.o: %.pcm
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.data.pal.o: %.data.pal
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
@ -69,6 +72,14 @@ wordle/wordle.o: wordle/word_list.hpp
|
||||
|
||||
wordle/wordle.elf: wordle/main_saturn.o wordle/wordle.o wordle/draw.o sh/lib1funcs.o res/dejavusansmono.font.bin.o common/keyboard.o common/draw_font.o common/palette.o
|
||||
|
||||
scsp/sine-44100-s16be-1ch.pcm:
|
||||
sox \
|
||||
-r 44100 -e signed-integer -b 16 -c 1 -n -B \
|
||||
$@.raw \
|
||||
synth 1 sin 440 vol -10dB
|
||||
mv $@.raw $@
|
||||
|
||||
scsp/slot.elf: scsp/slot.o scsp/sine-44100-s16be-1ch.pcm.o
|
||||
|
||||
# clean
|
||||
clean: clean-sh
|
||||
|
BIN
scsp/sine-44100-s16be-1ch.pcm
Normal file
BIN
scsp/sine-44100-s16be-1ch.pcm
Normal file
Binary file not shown.
43
scsp/slot.cpp
Normal file
43
scsp/slot.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include <stdint.h>
|
||||
#include "smpc.h"
|
||||
#include "scsp.h"
|
||||
|
||||
#include "../common/copy.hpp"
|
||||
|
||||
extern void * _sine_start __asm("_binary_scsp_sine_44100_s16be_1ch_pcm_start");
|
||||
|
||||
void main()
|
||||
{
|
||||
while ((smpc.reg.SF & 1) != 0);
|
||||
smpc.reg.SF = 1;
|
||||
smpc.reg.COMREG = COMREG__SNDON;
|
||||
while (smpc.reg.oreg[31] != 0b00000110);
|
||||
|
||||
for (long i = 0; i < 807; i++) { asm volatile ("nop"); } // wait for (way) more than 30µs
|
||||
|
||||
scsp.reg.ctrl.MIXER = MIXER__MEM4MB | MIXER__DAC18B | MIXER__MVOL(0xf);
|
||||
|
||||
const uint32_t * buf = reinterpret_cast<uint32_t*>(&_sine_start);
|
||||
copy<uint32_t>(&scsp.ram.u32[0], buf, 44100 * 2);
|
||||
|
||||
scsp_slot& slot = scsp.reg.slot[0];
|
||||
slot.LOOP = LOOP__KYONB | LOOP__LPCTL__NORMAL; // kx kb sbctl[1:0] ssctl[1:0] lpctl[1:0] 8b sa[19:16]
|
||||
slot.SA = 0; // start address (bytes)
|
||||
slot.LSA = 0; // loop start address (samples)
|
||||
slot.LEA = 44100; // loop end address (samples)
|
||||
slot.EG = EG__EGHOLD; // d2r d1r ho ar krs dl rr
|
||||
slot.VOLUME = 0; // stwinh sdir tl
|
||||
slot.FM = 0; // mdl mdxsl mdysl
|
||||
slot.PITCH = PITCH__OCT(0) | PITCH__FNS(0); // oct fns
|
||||
slot.LFO = 0; // lfof plfows
|
||||
slot.MIXER = MIXER__DISDL(0b101); // disdl dipan efsdl efpan
|
||||
|
||||
slot.LOOP |= LOOP__KYONEX;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void start(void)
|
||||
{
|
||||
main();
|
||||
while (1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user