This program plays digis on the C128 without the use of custom assembler routines. The program was inspired by the 8-bit-guys video on "C128 BASIC Hack: Playing Digital Samples". On the C128, it is possible to play a digi using the PLAY command of BASIC 7.0. However, the digi needs to be converted to a sample rate of 6kHz and each sample must be a value between 0 and 9, which is mapped to a volume value between 0 and 15 by the play command. While both, the playback frequency and the resolution are worse than standard digi players in assembler, it is still an interesting hack showing what can be done in BASIC V7.0.
Summary of how it works: The PLAY command of Commodore Basic V7.0 has a change volume tag: Ux where x is the volume between 0 and 9. The mapping is done by the routines in the ROM using a table at address F703C. Values are 00 01 03 05 07 08 0a 0c 0e 0f - thus Play volume 0 is mapped to SID volume 00. Note the gaps at some of the values. Luckily, the Volume command prefix "U" is optional, so you can also set differen volumes subsequently with PLAY "1234567890...". PLAY also accepts a string, so with PLAY A$, up to 255 volumes can be played. The playing frequency in FAST mode (2 MHz) is a bit over 6 kHZ. Thus, a very simple digi player can be done in BASIC by storing the volume values (between 0 and 9) in a string array and by having a loop FAST:FORI=0TON:PLAYA$(I):NEXT:SLOW. There is a short pause after each PLAY but - at least to - that's not audible.
|System|| Commodore 128|