FANCO v5 — SIREN ================ One chip, two ways to program it: 40–5F familiar SID-style controls 0100–01FF sixteen 16-byte sound generators 0200–02F3 mixing, three filters, master and eight delay lines 02F4–02FF exact pulse-width and ADSR parameters for generators 0–2 The old 0400–0BFF native window is NOT present in v5. RAM from 0300 through FFFF is available to programs, data and stack. 70–71 is phase restart; 72–73 selects native raw frequency, and 74–75 selects the native SID-clocked noise model. Touch input uses 80–A7. Other unassigned low-page bytes remain scratch space; this prototype has not allocated future interrupt vectors or callbacks there. This is a prototype, not an exact analog SID or Yamaha emulation. Native controls and the SID façade drive the SAME generators/filter. There is no app-version profile or automatic memory-map switch. Existing v3 program bytes/IDs are not silently rewritten. A v3 program using 0100–02FF as RAM can now affect sound and may need a user-approved port. Earlier old-map corpus checks do not prove compact-map safety. Basic vocabulary ---------------- A generator (operator) makes a repeating waveform and shapes its strength over time. It can make an audible tone OR control another operator. A mixer entry chooses which generator becomes audible. A filter changes the balance of low/high frequencies. A delay line stores past sound internally and reads it later to make echoes/reverb. Register bytes hold settings, not audio buffers or oscillator state. Addresses and values below are hexadecimal unless stated otherwise. Words are little-endian: low byte first. Audio runs at 48,000 samples/s; register writes take effect at their timed machine-cycle positions, rounded up to the next audio sample. They are not polled at 120 Hz. SID façade: simple sounds with few writes ---------------------------------------- Voice 1 2 3 Frequency low/high 40–41 47–48 4E–4F Pulse width low/high 42–43 49–4A 50–51 Waveform / gate 44 4B 52 Attack / decay 45 4C 53 Sustain / release 46 4D 54 55–56 shared filter cutoff, 11 bits 57 high nibble: resonance; low bits: voice routing to filter 0 58 low nibble: volume; bits 4/5/6: LP/BP/HP; bit 7: mute voice 3 5B existing FANCO extension: sine enable for voices 1/2/3 59–5A, 5C–5F have no additional sound function in this prototype. Control bits: 0 gate, 1 sync, 2 ring, 3 test, 4 triangle, 5 saw, 6 pulse, 7 noise. Multiple waveform bits select a combination. AD: attack high nibble, decay low nibble. SR: sustain high nibble, release low nibble. Frequency is the original raw SID-style number; SIREN translates it rather than treating it as native musical pitch. The three voices are generators 0–2; their shared filter is filter 0. Factory output is mono duplicated to both speakers, with effects dry. Writing an old pitch does not reset a native envelope or effects. Writing old filter routing changes that routing, not pan or sends. 58 still changes shared master volume: it is not a separate mixer. Native edits can enrich these same voices. Legacy frequency/waveform/ envelope writes subsequently change the corresponding settings again. The native interface can configure the same exact phase increment, 12-bit pulse width, ADR rates, LFSR and phase-ring connections independently. These are shared operator parameters, not forwarded SID writes or a second sound engine. Native exponential/segmented envelopes remain available. C64 SID addresses D400–D418 correspond to FANCO 40–58. Paddle input, oscillator readback and envelope readback are NOT provided as C64-compatible SID read registers. 5B is the sine extension, NOT D41B. SID-specific sampled-volume tricks and analog quirks are not promised. Exact native parameter controls ------------------------------ These extend the existing map; no generator/effects banks moved. 0072–0073 RAW_FREQ: sixteen little-endian mode bits. A set bit makes that generator's native pitch word (offsets 00–01) a raw PAL-compatible frequency: Hz = word * 985248 / 2^24. Zero means stopped phase. A clear bit keeps musical pitch. Select the format before writing its value; changing format reinterprets the current word. This changes frequency encoding only, not gate, envelope, waveform, pan or effects. SID frequency writes retain their own raw encoding regardless of the native selector. 0074–0075 NOISE_MODE: sixteen little-endian mode bits. Set means the 23-bit LFSR, seed 7FFFFF, advances at sixteen times the oscillator cycle rate, independently of the base phase, including multiple advances per sample. Clear retains native colored xorshift noise. Changing the selector does not restart phase or reseed either stored noise history. 02F4–02F5 / 02F6–02F7 / 02F8–02F9 FINE_PW: exact pulse-width words for generators 0 / 1 / 2. Only the low 12 bits count; duty = word / 4096. A write changes pulse width only. It does not change the native SHAPE byte's sine/triangle/saw phase warping. Keep SHAPE=80 for neutral waves when independently programming exact pulse width. 02FA–02FB / 02FC–02FD / 02FE–02FF ADSR: AD then SR for generators 0 / 1 / 2. AD high nibble attack, low nibble decay; SR high nibble sustain, low nibble release. Each byte update selects ADR execution without retriggering the held note or resetting its current envelope level. The reference factory slopes are linear full-range slopes with a sustain clamp, NOT a claim of analog SID envelope emulation. Attack times in ms: 2,8,16,24,38,56,68,80,100,250,500,800,1000,3000,5000,8000. Decay/release: 6,24,48,72,114,168,204,240,300,750,1500,2400,3000,9000,15000,24000. Sustain is high nibble / 15. Rates are read each sample, so changing a held-note rate takes effect immediately. ADR execution uses separate encoded parameters while preserving the native four-segment register bank. Writing a segmented-envelope field selects segmented execution again. Neither SID AD/SR nor native ADSR updates overwrite custom segment targets/times/curve flags. Native CONTROL method 6 means phase-ring: triangle sign uses source oscillator phase, before its envelope/output gain. Method 3 remains phase sync; method 7 combines sync with phase-ring on the same source. Raw-frequency units advance together before these phase connections are evaluated; their noise clocks stay independent. Ordinary musical-frequency units retain their existing native modulation ordering. Method 2 remains audible/enveloped AM/ring; it is not phase-ring. Raw/noise selectors cover sixteen generators. FINE_PW and ADSR word banks cover ONLY the first three; do not infer sixteen complete exact voices. Native held TEST is not added by this extension. Combined sync+phase-ring uses existing method 7, required by Commando effects 6/7 (subtunes 9/10). No additional register addresses are allocated. The existing SID façade continues providing its controls. Timing boundary --------------- The VM records writes at instruction-retirement cycle timestamps. The current 48 kHz sound renderer applies them at the next sample boundary (ceil(cycle / 2500) at 120 MHz). Exact native/SID parameter parity does NOT make this cycle-accurate or reproduce sub-sample oscillator changes. No proposed 600 Hz register latch has been implemented. Generator bank: 0100–01FF ------------------------ Generator n is at 0100 + n*10, n = 0..F. Each block uses all 16 bytes. Offset Bytes Meaning 00–01 2 PITCH: musical pitch, or raw frequency when RAW_FREQ bit is set 02 1 WAVES: six wave bits + two combination bits 03 1 SHAPE: waveform character 04 1 CONTROL: gate, modulation source, modulation method 05 1 DEPTH: modulation strength 06 1 FEEDBACK: self phase-modulation 07–08 2 envelope stage 1: target, time 09–0A 2 envelope stage 2: target, time 0B–0C 2 envelope stage 3: target, time 0D–0E 2 envelope stage 4: target, time 0F 1 envelope curves, sustain and loop PITCH: 8000 is A4, 440 Hz. Add 0100 for one semitone or 0C00 for an octave. One fractional unit is 1/256 semitone. Low pitches can be LFOs. WAVES bits 0..5: sine, triangle, saw, pulse, noise, constant. Example 05 selects sine + saw. No selected bits means silence. Bits 6..7 combine selected components: 0 average; 1 multiply; 2 XOR; 3 AND. XOR/AND quantize each component from -1..+1 into unsigned 8-bit values, combine the bits, then convert back. These are intentionally rough sound-shaping operations, not bit-exact analog SID waveform emulation. SHAPE is 8-bit. 80 is neutral for sine/triangle/saw and half-width pulse. For sine/triangle/saw it stretches the two portions of the cycle, changing symmetry; for pulse it selects duty cycle; for noise it changes brightness; for constant it selects -1 at 00 through +1 at FF. With a wave mask it applies to each selected component before combining. There is no built-in supersaw/unison bank in this map. CONTROL: bit 0 GATE bits 1..4 source generator, 0..F bits 5..7 modulation method: 0 none; 1 phase/FM; 2 ring/AM; 3 sync; 4 pitch; 5 pulse width 6 full-depth phase-ring (triangle only); 7 has no implemented method DEPTH ranges 00..FF. A source need not have a mixer entry to modulate. Its envelope still shapes the modulation signal. FEEDBACK uses the generator's two previous envelope-shaped samples before output gain. At 48 kHz these are approximately 21 and 42 us old. It changes waveform phase, not the delay/reverb system. Low amounts can brighten a sine; larger amounts can become harsh or noisy. Envelope targets are 00..FF (silent..full). Each stage has a target and an 8-bit duration. Time 00 is immediate; otherwise the duration in audio samples is round(48 * 2^((time-1)/16)): approximately 1 ms..60 s. On release the envelope moves to stage 4. 0F bits 0..3 select a curved approach for stages 1..4 (0 = linear). Bits 4..5 select sustain stage 0..3; bit 6 enables sustain; bit 7 loops stages 1..3 while the gate is held. Looping does not add extra stages. Phase restart: word 70–71 ------------------------ Bit n enables oscillator restart when generator n gets a rising gate. This is a PERSISTENT setting, not a one-shot trigger. Clear the bit for legato slides/free-running phase, set it for consistent hard attacks. Updating this bitmap alone does not retrigger an already held note. Eight mixer entries: 0200–0227 ----------------------------- Entry m is at 0200 + m*5, m = 0..7. +00–01 low four bits: source generator; high twelve bits: gain 0..4095 +02 signed pan: 00 center, 7F right, 81 left (-127); 80 clamps left +03 route: 00 direct; 01/02/03 through filters 0/1/2 +04 delay send: 00 none..FF full Pack the first word as (gain12 << 4) | source. To expand an old gain byte: gain12 = round(gain8 * 4095 / 255). No entry is required for a silent FM modulator or LFO. Entries can repeat a source for separate output paths/pans/gains. On direct routes, entry send feeds the delay bus before stereo pan. On filtered routes, the filter's send feeds the delay bus after filtering. Several sources routed to a filter are summed BEFORE that filter. A shared filter is not an independent filter/envelope per generator. Initially the three SID voices use their factory mix. The first native mixer edit makes the eight explicit entries authoritative; initial entries 0–2 contain those sources at centered, near-factory gains and other entries are silent. Native programs normally initialize all eight. This transition uses 12-bit equal-power stereo gains; the initial legacy mono amplitude can differ slightly after switching to explicit entries. Three shared filters: 0228–0242 ------------------------------ Filter f is at 0228 + f*9, f = 0..2. +00–01 cutoff on the musical pitch scale +02 resonance 00..FF +03 mode bits: 0 LP, 1 BP, 2 HP; zero native mode means bypass +04 output level 00..FF +05 signed pan, same convention as mixer +06 delay send 00..FF +07 bit 7 enables cutoff modulation; low four bits select generator +08 modulation depth 00..FF LP removes high frequencies, HP removes low frequencies, BP retains a band between them. Modes can be combined. Filter 0 also receives the SID façade's settings. Filters 1 and 2 are additional native units. Filters are classic shared audio effects here, not arbitrary envelope processors; their outputs are not native generator modulation sources. Master: 0243 ------------ Output level 00..FF, before final limiting to the output range. The chip retains headroom internally; several loud sources can clip at the final output. SID register 58 also changes this target. The output path includes a fixed 0.5 headroom factor at master FF. Eight delay lines: 0244–02F3 --------------------------- Line l is at 0244 + l*16, l = 0..7. Here 16 hex = 22 decimal bytes. Buffers are INTERNAL, not guest RAM. The prototype allocates eight 2^19-sample float buffers (16 MiB total), up to about 10.9 s per line. Long reverb tails can use short buffers with repeated feedback; a 10-second tail does not require a 10-second physical delay on each line. +00 input from shared send bus, 00..FF +01 damping: zero bright; larger values progressively darker +02 bit 0: allpass mode +03 signed allpass coefficient +04–0C tap 0 (nine bytes) +0D–15 tap 1 (nine bytes) Each tap: +0–1 delay position minifloat: exponent e = code >> 12, mantissa m = code & 0FFF; samples = m/256 when e=0, otherwise (4096+m)*2^(e-1)/256. Reads clamp to at least one sample; 0000 therefore means approximately 21 us, NOT 1 ms. +2 signed output gain left +3 signed output gain right +4 signed feedback gain +5 feedback destination-line mask; zero defaults to this same line +6 negative-destination mask (sign inversion for selected paths) +7 bit 7 enables delay-time modulation; low four bits source +8 delay-time modulation depth Signed gain bytes use two's complement, -128..127. A tap is a separate read position in the same buffer, not another buffer. Two taps can produce different echo rhythms/stereo positions. Feedback reaches its destination on the next sample, preventing a zero-time algebraic loop. Allpass mode uses tap 0 for a diffuser: echoes smear without behaving like a simple muffling filter. Several diffusers and cross-connected feedback lines make the multi-line reverb heard in the old prototype. High feedback/resonance combinations can become very loud or unstable; start quietly. More active lines/modulation cost CPU. No real-device performance figures are claimed until the requested device benchmarks. Two audio-to-RAM captures: 00D0–00E7 ----------------------------------- Added on the user's explicit request for sound-driven graphics. Channel 0: D0–DB. Channel 1: DC–E7. Each descriptor is twelve bytes: +00 source: 00..0F generator, 20..22 filter, 30 left, 31 right, 32 mono +01 format: 00 mapped unsigned byte; 01 signed 16-bit little-endian +02–03 destination RAM address +04–05 requested sample count (maximum 4096) +06–07 destination stride in bytes; zero means format width (1 or 2) +08 audio sample interval; zero means one 48 kHz sample +09 mapping LOW, default 00 +0A mapping HIGH, default FF +0B flags: bit 0 ENABLE, bit 1 ONE_SHOT, bit 7 DONE (hardware sets it) For format 00: -1 maps to LOW, +1 to HIGH; zero maps to their midpoint. For example LOW=40 and HIGH=B4 map -1..+1 into palette colors 64..180. LOW may exceed HIGH to reverse the palette. Format 01 ignores mapping, and converts -1..+1 into signed -32767..32767. Unsupported formats do no DMA. Configure source/destination/count/mapping first; write FLAGS with ENABLE last. Writing FLAGS clears DONE. At every 400-sample frame boundary both channels use the SAME latest audio-history end, so L/R pairs are aligned. The hardware writes the capture bytes and then sets DONE in device state AND guest RAM. ONE_SHOT clears ENABLE after that one transfer; continuous capture leaves it enabled. Count zero transfers no samples. Each channel retains 8192 samples. The effective count is clamped to min(requested,4096,floor(8192/interval)). Its last sample is the latest completed audio sample. Wait for the desired history span after changing sources; earlier history still belongs to the previous source. Captured generator values are before output gain; left/right/mono are final audio. Only destination bytes at 0300..FFFF are written. Wrapped addresses below 0300 are skipped, protecting CPU, input and sound controls. Programs must choose a safe RAM buffer: this does not protect their own code/data from an explicitly overlapping DMA destination. Stride 0100 puts one captured palette byte on each successive 256-byte framebuffer row in a RAM image; use the existing blitter to copy that image to the separate display plane. Native app limits ----------------- Hardware ramps remain omitted; kick/volume motion is guest code. Capture is now available for scopes and the six sound-graphics demos. The port has four keyboard notes plus four drum outputs; the old native app's eight-note keyboard, eight independent filters and second audible PAD/FLUTE layers are not silently advertised as retained. Programming examples and instruction-byte comparison: PROGRAMMING.txt. The raw-register demo and classic-style instrument use this same chip, not a separate audio engine.