// SPDX-License-Identifier: GPL-3.0-or-later #include unsigned char orch90_play(const struct orch90_frame *frames, unsigned int count, unsigned char clock) { unsigned int savedY; unsigned char delay; if (clock != ORCH90_CLOCK_NORMAL && clock != ORCH90_CLOCK_FAST) return 0; if (count == 0) return 1; // For a non-null 16-bit address, unsigned negation counts the remaining // bytes up to and including $FFFF. Each sample frame requires two. if (!frames || count > (0u - (unsigned int)frames) / sizeof(*frames)) return 0; delay = clock == ORCH90_CLOCK_NORMAL ? 39 : 84; asm { ldx :frames sty :savedY ldy :count @frame ldd ,x++ // One interleaved left/right pair. std >$ff7a ldb :delay @wait decb bne @wait leay -1,y bne @frame ldy :savedY } return 1; }