diff --git a/AGENTS.md b/AGENTS.md index be9ec1a..f34667a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ ACE is a BASIC compiler for Amiga. It compiles BASIC source code (.b files) into **Build Pipeline:** ``` -Source (.b) → Preprocess (app) → Compile (ace) → Assemble (vasm) → Link (vlink) → Executable +Source (.b) → Preprocess (yap) → Compile (ace) → Assemble (vasmm68k_mot) → Link (vlink) → Executable ``` The `bas` wrapper script in `bin/` orchestrates this full pipeline. @@ -201,7 +201,7 @@ bas myprogram # Compile myprogram.b to executable # To debug compilation issues, run phases separately: ace myprogram.b # Just compile to .s -vasm -Fhunk -o myprogram.o myprogram.s # Assemble +vasmm68k_mot -Fhunk -o myprogram.o myprogram.s # Assemble vlink -o myprogram myprogram.o ACElib:db.lib ACElib:startup.lib # Link ``` diff --git a/examples/mui/FileViewer.b b/examples/mui/FileViewer.b index ec91e43..412bf70 100644 --- a/examples/mui/FileViewer.b +++ b/examples/mui/FileViewer.b @@ -1,3 +1,4 @@ +REM #using ACE:submods/mui/mui.o {* ** FileViewer.b - File Browser with Text Editor ** ============================================= diff --git a/include/submods/Arne.h b/include/submods/Arne.h new file mode 100644 index 0000000..5f4ce60 --- /dev/null +++ b/include/submods/Arne.h @@ -0,0 +1,28 @@ +#ifndef ARNE_H +#define ARNE_H 1 + +{* Arne.h - Vampire SAGA Arne 16-bit audio submod for ACE BASIC *} + +CONST ARNE_PAL_CLOCK = 3546895 +CONST ARNE_8BIT = 0 +CONST ARNE_16BIT = 1 +CONST ARNE_ONESHOT = 2 +CONST ARNE_STEREO = 4 +CONST ARNE_LOOP16S = 5 +CONST ARNE_PLAY16S = 7 +CONST ARNE_LOOP8 = 0 +CONST ARNE_PLAY8 = 2 +CONST ARNE_MAX_CH = 16 + +DECLARE SUB ArnePlay(SHORTINT ch, LONGINT buf, LONGINT sz, ~ + SHORTINT per, SHORTINT vl, SHORTINT vr, ~ + SHORTINT md) EXTERNAL +DECLARE SUB ArneStop(SHORTINT ch) EXTERNAL +DECLARE SUB ArneStart(SHORTINT ch) EXTERNAL +DECLARE SUB ArneVolume(SHORTINT ch, SHORTINT vl, SHORTINT vr) EXTERNAL +DECLARE SUB SHORTINT ArneIsFree(SHORTINT ch) EXTERNAL +DECLARE SUB SHORTINT ArneFindFree EXTERNAL +DECLARE SUB ArneStopAll EXTERNAL +DECLARE SUB SHORTINT ArnePeriod(LONGINT rate) EXTERNAL + +#endif diff --git a/lib/db.lib b/lib/db.lib old mode 100644 new mode 100755 diff --git a/specs/arne-audio-state.txt b/specs/arne-audio-state.txt new file mode 100644 index 0000000..b09529d --- /dev/null +++ b/specs/arne-audio-state.txt @@ -0,0 +1,30 @@ +Arne Audio Submodule - Implementation State +============================================ +Branch: arne-audio-submod +Spec: specs/arne-audio-submod.txt + +Files created: + submods/arne/arne.b - Module source (8 SUBs) + include/submods/Arne.h - Header with DECLARE SUBs + constants + submods/arne/test_arne.b - Sine wave tone test + submods/arne/test_arne_aiff.b - Raw PCM file playback test + +Implementation status: + [x] arne.b: ArnePlay, ArneStop, ArneStart, ArneVolume + [x] arne.b: ArneIsFree, ArneFindFree, ArneStopAll, ArnePeriod + [x] Arne.h: constants + DECLARE SUBs + [x] test_arne.b: sine wave generator + play on ch 0 + [x] test_arne_aiff.b: raw PCM file loader + play via _Read + +Testing status: + [x] Compile arne.b as module (bas -m arne) - OK, 3.0 KB .o + [x] Compile test_arne.b (bas test_arne arne.o) - OK, 32.8 KB executable + [x] Compile test_arne_aiff.b (bas test_arne_aiff arne.o) - OK, 37 KB executable + [ ] Check generated .s assembly for correct register addresses + [ ] Functional test on Vampire hardware (future) + +Notes: + - Option A for alignment (user manages raw vs aligned addr) + - No ASSEM used, pure POKEW/POKEL/PEEKW + - dos _Read used for fast file loading in test_arne_aiff.b + - ACE uses ARG$(n) not COMMAND$(n) diff --git a/specs/arne-audio-submod.txt b/specs/arne-audio-submod.txt new file mode 100644 index 0000000..e758741 --- /dev/null +++ b/specs/arne-audio-submod.txt @@ -0,0 +1,381 @@ +Arne Audio Submodule for ACE BASIC +=================================== + +Status: DRAFT +Date: 2026-02-10 + + +1. OVERVIEW +----------- + +Add Vampire SAGA "Arne" 16-bit audio support to ACE as a self-contained +submodule. Arne is the enhanced audio chip in the Vampire FPGA +accelerator, replacing the classic Paula chip with: + + - 16 audio channels (vs Paula's 4) + - 8-bit or 16-bit sample support per channel + - Stereo volume control (independent left/right, 0-255 each) + - Sample rates up to 56 kHz independent per channel + - Interleaved stereo sample format + - Access to all 512 MB of Vampire memory for sample data + +The submodule requires zero compiler or runtime changes. It uses +POKEW/POKEL for direct register access and follows the established +submod pattern (see submods/runprog, submods/easyrequest). + +ACE's existing SOUND/WAVE/BEEP commands continue to work unchanged +via the classic Paula registers ($DFF0A0-$DFF0D0). The Arne submod +provides a separate, modern API for Vampire-equipped systems. + +Source reference for register map: + https://github.com/ApolloTeam-dev/magicsoundsystem.V4 + (apollo/ApolloCrossDev_Base.h, apollo/ApolloCrossDev_LibC.c) + + +2. SAGA CHIPSET CONTEXT +------------------------ + +The Vampire SAGA chipset consists of: + + - Arne : Audio (replaces Paula) + - Isabel : Video (replaces Lisa/Denise) + - Anni : DMA + Blitter + Copper (replaces Alice/Agnus) + - Maggie : 3D texture mapping unit (new) + +This spec covers Arne only. Maggie 3D support is a separate effort +(see section 10). + + +3. ARNE REGISTER MAP +--------------------- + +Arne uses a unified register block at $DFF400 with 16 channels, +each occupying $10 (16) bytes: + + Base address for channel N = $DFF400 + (N * $10) + + Offset Size Register Description + ------ ---- -------------- ------------------------------------------- + +$00 LONG AUD_POINTER Sample data address (32-byte aligned) + +$04 LONG AUD_LENGTH Length in 64-bit chunks (= byte_size / 8) + +$08 WORD AUD_VOLUME Bits 15-8: left vol (0-$FF) + Bits 7-0: right vol (0-$FF) + +$0A WORD AUD_MODE Bit 0: 16-bit (1) vs 8-bit (0) + Bit 1: one-shot (1) vs loop (0) + Bit 2: stereo (1) vs mono (0) + +$0C WORD AUD_PERIOD Playback period = PAL_CLOCK / sample_rate + PAL_CLOCK = 3546895 Hz + +Channel register examples: + Channel 0: $DFF400 pointer, $DFF404 length, $DFF408 volume, ... + Channel 1: $DFF410 pointer, $DFF414 length, $DFF418 volume, ... + Channel 15: $DFF4F0 pointer, $DFF4F4 length, $DFF4F8 volume, ... + +DMA control: + Channels 0-3: $DFF096 (classic DMACON) + Enable: POKEW $DFF096, $8000 + (1 SHL channel) + Disable: POKEW $DFF096, (1 SHL channel) + Channels 4-15: $DFF296 (DMACON2, new) + Enable: POKEW $DFF296, $8000 + (1 SHL (channel - 4)) + Disable: POKEW $DFF296, (1 SHL (channel - 4)) + +DMA status (read-only): + Channels 0-3: $DFF002 (classic DMACONR) + Bit N set = channel N is active + Channels 4-15: $DFF202 (DMACONR2, new) + Bit N set = channel N+4 is active + +Common AUD_MODE values: + $00 = 8-bit mono loop + $01 = 16-bit mono loop + $05 = 16-bit mono loop + stereo (interleaved L/R pairs) + $07 = 16-bit oneshot + stereo + + +4. FILE LAYOUT +-------------- + + submods/arne/arne.b Module source + include/submods/Arne.h DECLARE SUB header for users + submods/arne/test_arne.b Test program (plays a tone) + submods/arne/test_arne_aiff.b Test program (plays AIFF file) + + +5. PUBLIC API +------------- + +5.1 Constants (defined in Arne.h) + + CONST ARNE_PAL_CLOCK = 3546895 ' PAL clock frequency in Hz + + ' Mode flags (combine with OR or +) + CONST ARNE_8BIT = 0 ' 8-bit sample (default) + CONST ARNE_16BIT = 1 ' 16-bit sample + CONST ARNE_ONESHOT = 2 ' Play once then stop + CONST ARNE_STEREO = 4 ' Stereo interleaved L/R + + ' Common mode combinations + CONST ARNE_LOOP16S = 5 ' 16-bit + stereo + loop + CONST ARNE_PLAY16S = 7 ' 16-bit + stereo + oneshot + CONST ARNE_LOOP8 = 0 ' 8-bit mono loop + CONST ARNE_PLAY8 = 2 ' 8-bit mono oneshot + + ' Maximum channels + CONST ARNE_MAX_CH = 16 + +5.2 Subroutines + + SUB ArnePlay(channel%, bufAddr&, byteSize&, ~ + period%, volLeft%, volRight%, mode%) EXTERNAL + + Play a sample on a specific Arne channel. + + channel% : 0-15 (channel number) + bufAddr& : Address of sample data (must be 32-byte aligned) + byteSize& : Size of sample data in bytes + period% : Playback period (PAL_CLOCK / desired_sample_rate) + Example: 3546895 / 44100 = 80 for 44.1 kHz + volLeft% : Left volume 0-255 + volRight% : Right volume 0-255 + mode% : AUD_MODE flags (see constants above) + + SUB ArneStop(channel%) EXTERNAL + + Stop playback on a channel (disables DMA). + + SUB ArneStart(channel%) EXTERNAL + + Resume playback on a channel (re-enables DMA). + + SUB ArneVolume(channel%, volLeft%, volRight%) EXTERNAL + + Change volume on a playing channel without restarting it. + + SUB SHORTINT ArneIsFree(channel%) EXTERNAL + + Returns -1 (true) if channel is free, 0 (false) if busy. + Reads DMACONR / DMACONR2. + + SUB SHORTINT ArneFindFree() EXTERNAL + + Scan channels 0-15 and return the first free channel number. + Returns -1 if no channel is free. + + SUB ArneStopAll() EXTERNAL + + Stop all 16 channels. Convenience for cleanup. + + SUB SHORTINT ArnePeriod(sampleRate&) EXTERNAL + + Convenience: returns PAL_CLOCK / sampleRate& as a SHORT. + Example: ArnePeriod(44100) returns 80. + + +6. IMPLEMENTATION DETAILS +-------------------------- + +6.1 Register access via POKEW/POKEL + +All register writes use computed addresses: + + SUB ArnePlay(channel%, bufAddr&, byteSize&, ~ + period%, volLeft%, volRight%, mode%) EXTERNAL + LONGINT base& + base& = &HDFF400 + (CLNG(channel%) * &H10) + + POKEL base&, bufAddr& ' sample pointer + POKEL base& + &H4, byteSize& / 8 ' length in 64-bit chunks + POKEW base& + &H8, (volLeft% * 256) + volRight% ' stereo volume + POKEW base& + &HA, mode% ' mode flags + POKEW base& + &HC, period% ' playback period + + ' Enable DMA + IF channel% < 4 THEN + POKEW &HDFF096, &H8000 + (1 SHL channel%) + ELSE + POKEW &HDFF296, &H8000 + (1 SHL (channel% - 4)) + END IF + END SUB + +6.2 Channel status via PEEKW + + SUB SHORTINT ArneIsFree(channel%) EXTERNAL + SHORTINT dmaStatus% + IF channel% < 4 THEN + dmaStatus% = PEEKW(&HDFF002) + ArneIsFree = ((dmaStatus% AND (1 SHL channel%)) = 0) + ELSE + dmaStatus% = PEEKW(&HDFF202) + ArneIsFree = ((dmaStatus% AND (1 SHL (channel% - 4))) = 0) + END IF + END SUB + +6.3 Buffer alignment + +Arne requires sample buffers to be 32-byte aligned. ACE's ALLOC +returns unaligned memory. Two approaches: + + Option A - Over-allocate and align manually: + + byteSize& = + rawAddr& = ALLOC(byteSize& + 31) + alignedAddr& = (rawAddr& + 31) AND &HFFFFFFE0 + + The caller must keep rawAddr& for later FREE(rawAddr&). + + Option B - Provide a helper SUB: + + SUB LONGINT ArneAllocAligned(byteSize&) EXTERNAL + ' Allocates byteSize& + 31 bytes, returns 32-byte aligned address. + ' Stores raw address internally for ArneFreeMem. + END SUB + + SUB ArneFreeMem(alignedAddr&) EXTERNAL + ' Frees the allocation associated with alignedAddr&. + END SUB + + Option A is simpler and recommended for the first version. The user + manages raw vs aligned addresses. Option B can be added later if + the pattern proves cumbersome. + +6.4 No ASSEM needed + +All operations can be expressed with POKEW/POKEL/PEEKW. ASSEM is +not required. This keeps the module portable and readable. + +If ASSEM were used, the main benefit would be avoiding the overhead +of BASIC expression evaluation for address computation. But audio +setup is not performance-critical (it runs once per sound start), +so POKEW/POKEL is fine. + + +7. USAGE EXAMPLES +------------------ + +7.1 Play a sine wave tone + + #include + EXTERNAL Arne + + ' Generate a 16-bit sine wave in memory + DIM sineData%(31) ' 32 words = 64 bytes + FOR i% = 0 TO 31 + sineData%(i%) = CINT(SIN(i% * 6.2832 / 32) * 32767) + NEXT + + ' Calculate aligned address of array data + ' (DIM arrays may already be aligned, but be safe) + sampleAddr& = VARPTR(sineData%(0)) + + ' Play at ~440 Hz on channel 0, full volume, 16-bit mono loop + period% = ArnePeriod(440 * 32) ' 32 samples per cycle + ArnePlay(0, sampleAddr&, 64, period%, 255, 255, ARNE_16BIT) + + SLEEP + ArneStop(0) + +7.2 Play an AIFF file (conceptual) + + #include + EXTERNAL Arne + + ' Load AIFF into memory (BLOAD or manual file I/O) + ' Parse header for sample rate, data offset, data size + ' ... + + period% = ArnePeriod(sampleRate&) + ch% = ArneFindFree() + IF ch% >= 0 THEN + ArnePlay(ch%, dataAddr&, dataSize&, period%, 200, 200, ARNE_PLAY16S) + END IF + + +8. HEADER FILE (Arne.h) +------------------------- + + #ifndef ARNE_H + #define ARNE_H 1 + + {* Arne.h - Vampire SAGA Arne 16-bit audio submod for ACE BASIC *} + + CONST ARNE_PAL_CLOCK = 3546895 + CONST ARNE_8BIT = 0 + CONST ARNE_16BIT = 1 + CONST ARNE_ONESHOT = 2 + CONST ARNE_STEREO = 4 + CONST ARNE_LOOP16S = 5 + CONST ARNE_PLAY16S = 7 + CONST ARNE_LOOP8 = 0 + CONST ARNE_PLAY8 = 2 + CONST ARNE_MAX_CH = 16 + + DECLARE SUB ArnePlay(SHORTINT ch, LONGINT buf, LONGINT sz, ~ + SHORTINT per, SHORTINT vl, SHORTINT vr, ~ + SHORTINT md) EXTERNAL + DECLARE SUB ArneStop(SHORTINT ch) EXTERNAL + DECLARE SUB ArneStart(SHORTINT ch) EXTERNAL + DECLARE SUB ArneVolume(SHORTINT ch, SHORTINT vl, SHORTINT vr) EXTERNAL + DECLARE SUB SHORTINT ArneIsFree(SHORTINT ch) EXTERNAL + DECLARE SUB SHORTINT ArneFindFree() EXTERNAL + DECLARE SUB ArneStopAll() EXTERNAL + DECLARE SUB SHORTINT ArnePeriod(LONGINT rate) EXTERNAL + + #endif + + +9. TESTING PLAN +---------------- + +Phase 1 - Structural (on emulator without Vampire): + - Compile arne.b as module: bas -m arne + - Compile test_arne.b linking arne.o + - Verify no compilation errors + - Verify generated .s assembly has correct POKEW/POKEL addresses + +Phase 2 - Functional (requires Vampire hardware): + - Play a generated sine wave, verify audio output + - Test all 16 channels (at least channels 0, 4, 15) + - Test mode flags: 8-bit vs 16-bit, mono vs stereo, loop vs oneshot + - Test ArneStop / ArneStart (pause/resume) + - Test ArneVolume (change volume while playing) + - Test ArneIsFree / ArneFindFree + - Test ArneStopAll + + +10. FUTURE WORK +---------------- + +10.1 AIFF loader submod + + A separate submod (or extension to Arne) that loads AIFF files, + parses the header (COMM chunk for sample rate, SSND chunk for + data), allocates aligned memory, and returns a ready-to-play + buffer. The MagicSoundSystem.V4 code has a working AIFF parser + that can serve as reference. + +10.2 Maggie 3D submod + + The Maggie 3D unit has a proper Amiga shared library + (maggie.library) with an .fd file defining 56 functions. + Approach: + - Generate bmaps/maggie.bmap from the .fd file + - Create include/submods/Maggie.h with DECLARE FUNCTION + - Users access via LIBRARY "maggie.library" + function calls + - No compiler changes needed + + Source: https://github.com/RMortenB/MaggieLibrary + +10.3 SAGA direct video + + Direct chunky framebuffer access via SAGA registers: + $DFF1EC = framebuffer pointer + $DFF1F4 = display mode (resolution + color format) + $DFF1E6 = modulo (bytes skipped per row) + Could also be a POKEW/POKEL-based submod for bare-metal + SAGA graphics without going through P96. + +10.4 Integration with existing SOUND command + + If the submod approach proves successful, a later phase could + integrate Arne support into the compiler's built-in SOUND command + with extended syntax, for users who prefer not to use EXTERNAL. diff --git a/submods/arne/arne.b b/submods/arne/arne.b new file mode 100644 index 0000000..1c44370 --- /dev/null +++ b/submods/arne/arne.b @@ -0,0 +1,151 @@ +{* +** Arne Audio Submodule for ACE BASIC +** +** Provides access to the Vampire SAGA "Arne" 16-bit audio chip +** with 16 channels, 8/16-bit samples, stereo volume, and rates +** up to 56 kHz. Uses POKEW/POKEL for direct register access. +** +** Requires: Vampire FPGA accelerator with SAGA chipset +** +** Register map: +** Channel N base = $DFF400 + (N * $10) +** +$00 LONG AUD_POINTER (sample address, 32-byte aligned) +** +$04 LONG AUD_LENGTH (length in 64-bit chunks) +** +$08 WORD AUD_VOLUME (bits 15-8: left, bits 7-0: right) +** +$0A WORD AUD_MODE (bit0: 16bit, bit1: oneshot, bit2: stereo) +** +$0C WORD AUD_PERIOD (PAL_CLOCK / sample_rate) +** +** DMA control: +** Ch 0-3: $DFF096 (DMACON) +** Ch 4-15: $DFF296 (DMACON2) +** +** Author: ACE Project +** Date: February 2026 +*} + + +{* --- ArnePlay --- *} +{* Play a sample on a specific Arne channel. *} + +SUB ArnePlay(channel%, bufAddr&, byteSize&, ~ + period%, volLeft%, volRight%, mode%) EXTERNAL + + LONGINT base& + + base& = &HDFF400 + (CLNG(channel%) * &H10) + + POKEL base&, bufAddr& + POKEL base& + &H4, byteSize& / 8 + POKEW base& + &H8, (volLeft% * 256) + volRight% + POKEW base& + &HA, mode% + POKEW base& + &HC, period% + + IF channel% < 4 THEN + POKEW &HDFF096, &H8000 + (SHL(1, channel%)) + ELSE + POKEW &HDFF296, &H8000 + (SHL(1, channel% - 4)) + END IF + +END SUB + + +{* --- ArneStop --- *} +{* Stop playback on a channel (disable DMA). *} + +SUB ArneStop(channel%) EXTERNAL + + IF channel% < 4 THEN + POKEW &HDFF096, (SHL(1, channel%)) + ELSE + POKEW &HDFF296, (SHL(1, channel% - 4)) + END IF + +END SUB + + +{* --- ArneStart --- *} +{* Resume playback on a channel (re-enable DMA). *} + +SUB ArneStart(channel%) EXTERNAL + + IF channel% < 4 THEN + POKEW &HDFF096, &H8000 + (SHL(1, channel%)) + ELSE + POKEW &HDFF296, &H8000 + (SHL(1, channel% - 4)) + END IF + +END SUB + + +{* --- ArneVolume --- *} +{* Change volume on a playing channel without restarting it. *} + +SUB ArneVolume(channel%, volLeft%, volRight%) EXTERNAL + + LONGINT base& + + base& = &HDFF400 + (CLNG(channel%) * &H10) + POKEW base& + &H8, (volLeft% * 256) + volRight% + +END SUB + + +{* --- ArneIsFree --- *} +{* Returns -1 (true) if channel is free, 0 (false) if busy. *} + +SUB SHORTINT ArneIsFree(channel%) EXTERNAL + + SHORTINT dmaStatus% + + IF channel% < 4 THEN + dmaStatus% = PEEKW(&HDFF002) + ArneIsFree = ((dmaStatus% AND (SHL(1, channel%))) = 0) + ELSE + dmaStatus% = PEEKW(&HDFF202) + ArneIsFree = ((dmaStatus% AND (SHL(1, channel% - 4))) = 0) + END IF + +END SUB + + +{* --- ArneFindFree --- *} +{* Scan channels 0-15, return first free channel or -1 if none. *} + +SUB SHORTINT ArneFindFree EXTERNAL + + SHORTINT i% + + FOR i% = 0 TO 15 + IF ArneIsFree(i%) THEN + ArneFindFree = i% + EXIT SUB + END IF + NEXT + + ArneFindFree = -1 + +END SUB + + +{* --- ArneStopAll --- *} +{* Stop all 16 channels. *} + +SUB ArneStopAll EXTERNAL + + SHORTINT i% + + FOR i% = 0 TO 15 + ArneStop(i%) + NEXT + +END SUB + + +{* --- ArnePeriod --- *} +{* Convenience: returns PAL_CLOCK / sampleRate& as a SHORT. *} + +SUB SHORTINT ArnePeriod(sampleRate&) EXTERNAL + + ArnePeriod = CINT(3546895& / sampleRate&) + +END SUB diff --git a/submods/arne/arne.o b/submods/arne/arne.o new file mode 100755 index 0000000..fb1b852 Binary files /dev/null and b/submods/arne/arne.o differ diff --git a/submods/arne/test_arne b/submods/arne/test_arne new file mode 100644 index 0000000..12f396c Binary files /dev/null and b/submods/arne/test_arne differ diff --git a/submods/arne/test_arne.b b/submods/arne/test_arne.b new file mode 100644 index 0000000..655e0ab --- /dev/null +++ b/submods/arne/test_arne.b @@ -0,0 +1,54 @@ +REM #using ace:submods/arne/arne.o + +{* +** Test program for Arne audio submodule. +** Generates a 16-bit sine wave in memory and plays it +** as a looping tone on channel 0. +** +** Requires: Vampire with SAGA/Arne audio hardware. +*} + +#include + +SHORTINT period%, ch% + +PRINT "Arne Audio Submod Test" +PRINT "=====================" +PRINT + +{* Generate a 16-bit sine wave: 32 samples = 64 bytes *} +DIM sineData%(31) +FOR i% = 0 TO 31 + sineData%(i%) = CINT(SIN(i% * 6.2832 / 32) * 32767) +NEXT + +LONGINT sampleAddr& +sampleAddr& = VARPTR(sineData%(0)) + +{* Play at ~440 Hz on channel 0, full volume, 16-bit mono loop *} +period% = ArnePeriod(440& * 32&) + +PRINT "Playing 440 Hz sine wave on channel 0..." +PRINT "Period:"; period% +PRINT "Sample address: $"; HEX$(sampleAddr&) +PRINT + +ArnePlay(0, sampleAddr&, 64, period%, 255, 255, ARNE_16BIT) + +{* Test ArneIsFree - channel 0 should be busy *} +IF ArneIsFree(0) THEN + PRINT "Channel 0: free (unexpected!)" +ELSE + PRINT "Channel 0: busy (correct)" +END IF + +{* Test ArneFindFree - should return 1 (first free after ch 0) *} +ch% = ArneFindFree() +PRINT "First free channel:"; ch% + +PRINT +INPUT "Press ENTER to stop..."; dummy$ + +ArneStop(0) + +PRINT "Stopped." diff --git a/submods/arne/test_arne_aiff b/submods/arne/test_arne_aiff new file mode 100644 index 0000000..d0ddef8 Binary files /dev/null and b/submods/arne/test_arne_aiff differ diff --git a/submods/arne/test_arne_aiff.b b/submods/arne/test_arne_aiff.b new file mode 100644 index 0000000..8bcc55f --- /dev/null +++ b/submods/arne/test_arne_aiff.b @@ -0,0 +1,108 @@ +REM #using ace:submods/arne/arne.o + +{* +** Test program for Arne audio submodule - raw PCM file playback. +** +** Loads a raw 16-bit PCM file into memory and plays it through +** Arne. Expects a headerless raw PCM file (16-bit signed +** big-endian, mono, 44100 Hz). +** +** Usage: test_arne_aiff +** +** To create a raw PCM test file from an AIFF on a modern system: +** sox input.aiff -t raw -r 44100 -b 16 -e signed -B output.raw +** +** Requires: Vampire with SAGA/Arne audio hardware. +*} + +#include +EXTERNAL Arne + +DECLARE FUNCTION _Read&(fh&, buf&, length&) LIBRARY dos + +STRING fileName SIZE 256 +LONGINT fileSize&, rawAddr&, alignedAddr&, fh&, bytesRead& +SHORTINT period%, ch%, playing% + +playing% = 0 + +PRINT "Arne Raw PCM Player" +PRINT "===================" +PRINT + +{* Get filename from command line or prompt *} +IF ARGCOUNT > 0 THEN + fileName = ARG$(1) +ELSE + INPUT "Enter raw PCM filename: ", fileName +END IF + +IF fileName = "" THEN + PRINT "No filename given." + GOTO done +END IF + +{* Open file and get size *} +OPEN "I", #1, fileName +fh& = HANDLE(1) +IF fh& = 0& THEN + PRINT "Cannot open: "; fileName + GOTO done +END IF +fileSize& = LOF(1) + +IF fileSize& = 0 THEN + CLOSE #1 + PRINT "File is empty." + GOTO done +END IF + +PRINT "File: "; fileName +PRINT "Size:"; fileSize&; " bytes" + +{* Allocate buffer with 31 extra bytes for 32-byte alignment *} +rawAddr& = ALLOC(fileSize& + 31) +IF rawAddr& = 0 THEN + CLOSE #1 + PRINT "Out of memory!" + GOTO done +END IF +alignedAddr& = (rawAddr& + 31) AND &HFFFFFFE0 + +PRINT "Buffer: $"; HEX$(alignedAddr&); " (aligned)" + +{* Load raw PCM data via dos _Read (fast block read) *} +bytesRead& = _Read(fh&, alignedAddr&, fileSize&) +CLOSE #1 + +IF bytesRead& <> fileSize& THEN + PRINT "Read error: got"; bytesRead&; " of"; fileSize&; " bytes" + GOTO done +END IF + +{* Play AS 16-bit sterio oneshot at 44100 Hz *} +period% = ArnePeriod(44100&) +ch% = ArneFindFree() + +IF ch% < 0 THEN + PRINT "No free channels!" + GOTO done +END IF + +PRINT "Playing on channel"; ch%; " at 44100 Hz..." +PRINT "Period:"; period% +PRINT +playing% = 1 + +ArnePlay(ch%, alignedAddr&, fileSize&, period%, 255, 255, ARNE_PLAY16S) + +INPUT "Press ENTER to stop..."; dummy$ + +ArneStop(ch%) + +done: +IF playing% THEN + PRINT "Stopped." +END IF +PRINT "Done." + diff --git a/verify/scripts/otherthenamiga/aos3/S/user-startup b/verify/scripts/otherthenamiga/aos3/S/user-startup index 831efb1..136181e 100644 --- a/verify/scripts/otherthenamiga/aos3/S/user-startup +++ b/verify/scripts/otherthenamiga/aos3/S/user-startup @@ -47,7 +47,8 @@ assign ACEinclude: ACE:include path ACE:bin add protect ACE:bin/bas +s -; P96 screen support - Phase 3 complete (COLOR r,g,b) +; Arne submod - all compiled +