diff --git a/benchmark-program/Makefile b/benchmark-program/Makefile index 0b0a22905..1bc6b5f43 100644 --- a/benchmark-program/Makefile +++ b/benchmark-program/Makefile @@ -6,7 +6,7 @@ clean: rm -f *.prg *.PRG *.asm *.vice-* *.BIN *.PAL *.zip *.7z emu: benchmark.prg - x16emu -run -prg $< + x16emu -run -prg $< -warp benchmark.prg: benchmark.p8 b_3d.p8 b_adpcm.p8 b_circles.p8 b_life.p8 b_mandelbrot.p8 b_maze.p8 b_queens.p8 b_textelite.p8 p8compile $< -target cx16 diff --git a/compiler/res/prog8lib/cx16/audio.p8 b/compiler/res/prog8lib/cx16/audio.p8 index 011970935..116224e77 100644 --- a/compiler/res/prog8lib/cx16/audio.p8 +++ b/compiler/res/prog8lib/cx16/audio.p8 @@ -1,5 +1,11 @@ %import syslib +; Stubs for the audio routines in rom bank 10 +; They use JSRFAR to select the correct bank, so user code doesn't have to bother. +; +; The stubs here still use the romsub definitions of the routines from syslib, but those are +; just the jump addresses and are unaware of the kernal bank. Wrapping in JSRFAR fixes this. + audio { const ubyte rom_bank = $0a asmsub audio_init() clobbers(A,X,Y) -> bool @Pc { ; (re)initialize both vera PSG and YM audio chips diff --git a/compiler/test/TestCompilerOnExamples.kt b/compiler/test/TestCompilerOnExamples.kt index bc79f657e..08b02a916 100644 --- a/compiler/test/TestCompilerOnExamples.kt +++ b/compiler/test/TestCompilerOnExamples.kt @@ -114,7 +114,7 @@ class TestCompilerOnExamplesCx16: FunSpec({ "sprites/dragon", "sprites/dragons", "amiga", - "audio", + "audioroutines", "automatons", "bdmusic", "bobs", diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index 42d5e00a3..ce4da7d5c 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -945,6 +945,18 @@ Read the `psg source code `_ +to see what's in there. + + + sprites (cx16 only) -------------------- Available for the Cx16 target. Simple routines to manipulate sprites. diff --git a/examples/cx16/audio.p8 b/examples/cx16/audio.p8 deleted file mode 100644 index f33f983e4..000000000 --- a/examples/cx16/audio.p8 +++ /dev/null @@ -1,123 +0,0 @@ -%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, "o5d2d4CE" : 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 + + */ + + ; Note: the audio module contains stubs for every kernal audio call, + ; they use JSRFAR to automatically switch to the correct ROM bank (and back). + ; So we don't have to switch rom banks ourselves to access the audio routines in bank 10! + + audio.psg_init() + + audio.bas_playstringvoice(15) + audio.bas_psgchordstring(6, "o3g>ce") + + audio.bas_playstringvoice(14) + audio.bas_psgplaystring(10, ">ccde") + + audio.bas_playstringvoice(15) + audio.bas_psgchordstring(3, "rrr") + + audio.bas_playstringvoice(14) + audio.bas_psgplaystring(9, "o4cag>ccf") + + audio.bas_playstringvoice(14) + audio.bas_psgplaystring(14, "l16fgab->cdef4") + + audio.bas_playstringvoice(0) + audio.bas_psgchordstring(3, "rrr") + + } + + 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") + + audio.bas_playstringvoice(0) + audio.bas_fmplaystring(12, "o4g4.a8g4e2.") + audio.bas_playstringvoice(0) + audio.bas_fmplaystring(12, "o4g4.a8g4e2.") + + audio.bas_playstringvoice(1) + audio.bas_fmchordstring(6, "o2g>db") + + audio.bas_playstringvoice(0) + audio.bas_fmplaystring(9, "o5d2d4