From e14b854d7bf492b082618d7508921437128168c0 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 19 Dec 2023 00:48:03 +0100 Subject: [PATCH] cx16: added audio kernal routines example --- compiler/test/TestCompilerOnExamples.kt | 1 + examples/cx16/audio.p8 | 123 ++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 examples/cx16/audio.p8 diff --git a/compiler/test/TestCompilerOnExamples.kt b/compiler/test/TestCompilerOnExamples.kt index 2b4577092..a4c52cb7b 100644 --- a/compiler/test/TestCompilerOnExamples.kt +++ b/compiler/test/TestCompilerOnExamples.kt @@ -103,6 +103,7 @@ class TestCompilerOnExamplesCx16: FunSpec({ "sprites/dragon", "sprites/dragons", "amiga", + "audio", "bdmusic", "bobs", "bubbleuniverse", diff --git a/examples/cx16/audio.p8 b/examples/cx16/audio.p8 new file mode 100644 index 000000000..f33f983e4 --- /dev/null +++ b/examples/cx16/audio.p8 @@ -0,0 +1,123 @@ +%import textio +%zeropage basicsafe +%option no_sysinit + +main { + sub start() { + txt.print("\n\nsimple demonstration of the audio kernal routines.\n") + txt.print("fm demo...\n") + fm_demo() + sys.wait(30) + + txt.print("psg demo...\n") + psg_demo() + sys.wait(30) + + txt.print("done!\n") + } + + sub psg_demo() { + /* + + 10 PSGINIT + 20 PSGCHORD 15,"O3G>CE" : REM STARTS PLAYING A CHORD ON VOICES 15, 0, AND 1 + 30 PSGPLAY 14,">CCDE" : REM PLAYS A SERIES OF NOTES ON VOICE 14 + 40 PSGCHORD 15,"RRR" : REM RELEASES CHORD ON VOICES 15, 0, AND 1 + 50 PSGPLAY 14,"O4CAG>CCF" : REM STARTS PLAYING A CHORD ON VOICES 0, 1, AND 2 + 70 PSGPLAY 14,"L16FGAB->CDEF4" : REM PLAYS A SERIES OF NOTES ON VOICE + 80 PSGCHORD 0,"RRR" : REM RELEASES CHORD ON VOICES 0, 1, AND 2 + + */ + + cx16.rombank(10) + cx16.psg_init() + + cx16.bas_playstringvoice(15) + cx16.bas_psgchordstring(6, "o3g>ce") + + cx16.bas_playstringvoice(14) + cx16.bas_psgplaystring(10, ">ccde") + + cx16.bas_playstringvoice(15) + cx16.bas_psgchordstring(3, "rrr") + + cx16.bas_playstringvoice(14) + cx16.bas_psgplaystring(9, "o4cag>ccf") + + cx16.bas_playstringvoice(14) + cx16.bas_psgplaystring(14, "l16fgab->cdef4") + + cx16.bas_playstringvoice(0) + cx16.bas_psgchordstring(3, "rrr") + + cx16.rombank(0) + } + + sub fm_demo() { + /* +10 FMINIT +20 FMVIB 195,10 +30 FMINST 1,16:FMINST 2,16:FMINST 3,16 : REM ORGAN +40 FMVOL 1,50:FMVOL 2,50:FMVOL 3,50 : REM MAKE ORGAN QUIETER +50 FMINST 0,11 : REM VIBRAPHONE +60 FMCHORD 1,"O3CG>E T90" : REM START SOME ORGAN CHORDS (CHANNELS 1,2,3) +70 FMPLAY 0,"O4G4.A8G4E2." : REM PLAY MELODY (CHANNEL 0) +80 FMPLAY 0,"O4G4.A8G4E2." +90 FMCHORD 1,"O2G>DB" : REM SWITCH ORGAN CHORDS (CHANNELS 1,2,3) +100 FMPLAY 0,"O5D2D4e t130") + + cx16.bas_playstringvoice(0) + cx16.bas_fmplaystring(12, "o4g4.a8g4e2.") + cx16.bas_playstringvoice(0) + cx16.bas_fmplaystring(12, "o4g4.a8g4e2.") + + cx16.bas_playstringvoice(1) + cx16.bas_fmchordstring(6, "o2g>db") + + cx16.bas_playstringvoice(0) + cx16.bas_fmplaystring(9, "o5d2d4