Commit Graph
146 Commits
Author SHA1 Message Date
Ian Scott 2be3565e5c Firmware v4.1.0 2026-04-13 22:31:52 -06:00
Ian Scott e4fd9037a8 Add PGDEBUG CMake var to save runtime overhead of printf & save code size 2026-04-13 18:20:56 -06:00
Ian Scott 4860c2685d Firmware v4.0.0 2026-04-06 09:53:20 -06:00
Ian Scott 315a5cac85 Firmware v4.0.0-beta 2026-04-06 09:46:48 -06:00
Ian Scott 05bcdae735 Build multifw with emu8950 2026-04-05 21:25:47 -06:00
Ian Scott 9675556be7 HW interpolator for SB 2026-04-05 21:25:47 -06:00
Ian Scott 8c56f4d133 More optimizations around clamping for SB and GUS 2026-04-05 21:25:47 -06:00
Ian Scott d0d448e3bf Disable hardware clamp in dbopl - there's races due to it being used in multiple places 2026-04-03 23:09:48 -06:00
Ian Scott 29da06d8ea Fix multifw build 2026-03-30 08:25:53 -06:00
Ian Scott bcd1c76f12 Overclock at runtime instead of at start to help stability on marginal boards 2026-03-29 16:25:55 -06:00
Ian Scott 553a6a889a SB-like audio IRQ for GUS 2026-03-29 15:56:01 -06:00
Ian Scott 35caedfd40 Reduce MIDI buffer sizes in non-MPU modes 2026-03-29 12:28:04 -06:00
Ian Scott 6de116068c Clamp with hardware interpolator 2026-03-29 12:28:04 -06:00
Ian Scott db355ec4d6 Merge branch 'wss-sb16' into sb16_merge
Bring in SB16/WSS support (bufferless SB DSP, AD1848, SB mixer, IRQ/DMA configuration) and 0.12 fixed-point volume scaling from wss-sb16, and combine with stereo OPL3 pipeline and lock-free SPSC audio FIFO from sb16_merge.
Conflict resolutions:
- volctrl.h: use 0.12 scale from wss-sb16 (no int64_t)
- sbplay.cpp: keep stereo opl_resample_tick() with clamp16 before resampler buffers; lock-free SPSC FIFO reads with stereo volume; add sbdsp_process() from wss-sb16
- pgusinit.c: use wss-sb16's full BLASTER parser (A/I/D/H/T fields)
2026-03-28 23:50:22 -06:00
wbcbz7 328d5c16e0 add DOSBox OPL3 core 2026-03-28 11:53:01 -06:00
Daniel Arnold 82de83fe3a Update versioning v3.3.0-beta 2026-03-28 11:53:01 -06:00
Daniel Arnold 82fa438059 feat(opl): add ymfm OPL2/OPL3 backend with true stereo output
Adds ymfm as a new OPL synthesis backend alongside the existing emu8950
implementation, selectable at compile time via USE_YMFM_OPL / USE_YMF3812.

- ymf262 (OPL3): 18-channel true stereo via data[0]/data[1] (L1/R1)
- ym3812 (OPL2): mono, duplicated to both channels
- Pre-generation buffer (128 samples) for cache-efficient synthesis
- Stereo FIFO pipeline in sbplay: interleaved L/R pairs, proper resampling
  from 49716 Hz to 44100 Hz via Q16.16 phase accumulator
- OPL3 bank 2 port handling in SOUND_SB path (ports +0xA/+0xB) and
  SOUND_OPL path (port mask widened to 0x3fc, case 2/3 added)
- opl_addr widened to uint16_t to carry the 0x100 bank 2 flag
- OPL3 bank 2 status read port (oplBasePort+2) added to IOR handler
- Panning bits default to 0x30 (L1+R1) for 0xC0-0xC8 regs when unset,
  preventing channels from going silent after newflag (reg 0x105) is set
- pgusinit: BLASTER T type now accepts T3-T6 (adds SB16 OPL3 / AWE32)
- Removed OPL cmd buffer drain spin-wait from IOR path (timer regs are
  handled on core 0, no drain needed)
2026-03-28 11:53:01 -06:00
Daniel Arnold 3365378a77 fix(opl): eliminate cross-core OPL struct race via OPL_CMD_BUFFER
This was an audible in games like Doom. It would cause an occasional small interruption when picking up items.

Core 0 (bus ISR) was calling OPL_writeReg() directly on the emu8950
OPL struct while Core 1 was simultaneously reading it in OPL_calc_buffer()
to generate audio. With no synchronization between the cores, a register
write landing mid-calculation produces torn state — a mix of old and new
operator fields — causing occasional clicks or pops during OPL music.

The OPL_CMD_BUFFER mechanism was already implemented in picogus.cpp and
sbplay.cpp but never enabled. Enable it in CMakeLists.txt for all OPL
targets (pg-adlib, pg-sb).

With OPL_CMD_BUFFER enabled, Core 0 enqueues raw (addr, data) pairs into
a 256-entry SPSC ring buffer. Core 1 drains the queue at the top of each
main loop iteration, before the resampler fill loop, so OPL_writeReg()
only ever runs on Core 1 and never races with OPL_calc_buffer().

Timer registers (0x02–0x04) are carved out and still handled immediately
on Core 0. This preserves the existing invariant that OPL_Pico_PortRead()
and the timer state are both Core 0 only, avoiding a new cross-core race
on the timer structs.
2026-03-28 11:53:01 -06:00
Daniel Arnold f3220f736a opl: enable EMU8950 TLL via pre-computed table in flash (.flashdata section)
The TLL (Total Level Lookup) table is 128KB — too large for the RP2040's
256KB RAM when the firmware also runs code from RAM. Previous attempts to
use a `const` array failed because the firmware uses a copy_to_ram binary
type, which copies ALL sections including `.rodata` into RAM at boot.

The fix: place the pre-computed table in the `.flashdata.tll_table` linker
section. Both pico-sdk's `memmap_copy_to_ram.ld` and the local
`fw_memmap_c2ram.ld` explicitly capture `.flashdata*` into the FLASH
`.rodata` region, which is accessed via XIP cache and never copied to RAM.

- gen_tll_table.py: new script that pre-computes makeTllTable() using the
  EMU8950_NO_FLOAT integer path, outputting tll_table_flash.c with the
  `.flashdata.tll_table` section attribute
- tll_table_flash.c: generated 128KB table (32,768 uint32_t values)
- emu8950.c: support EMU8950_TLL_FLASH — use extern const declaration and
  skip makeTllTable() at runtime when table is pre-computed in flash
- CMakeLists: replace EMU8950_NO_TLL=1 with EMU8950_TLL_FLASH=1

TLL improves OPL2 accuracy by enabling the full Key Scale Level (KSL)
attenuation lookup table rather than the inline approximation.
2026-03-28 11:53:01 -06:00
Daniel Arnold 1ceb476dfd Improve OPL synthesis quality 2026-03-28 11:53:01 -06:00
wbcbz7 38d485ef01 Revert "temp overclock UART to 2 Mbps"
This reverts commit 0e88976b60.
2026-03-28 22:02:00 +07:00
wbcbz7 0e88976b60 temp overclock UART to 2 Mbps 2026-03-23 18:54:29 +07:00
wbcbz7 4bf5631472 SB: finalize IRQ/DMA/options settings 2026-03-22 00:56:38 +07:00
Ian Scott b7b2add482 Add ISA analyzer firmware + decoder 2026-03-18 08:33:21 -06:00
Ian Scott 6eaef68625 Remove old non-bufferless code 2026-03-16 23:24:57 -06:00
Ian Scott fee4b40d76 Rebase/reimplement SB16/WSS support on latest main 2026-03-15 23:51:31 -06:00
Ian Scott d3ac864d9c Firmware version 3.2.1 2025-09-26 07:27:32 -06:00
Ian Scott 66dfb425e8 Give a bit more time for vreg to settle 2025-09-26 07:21:29 -06:00
Ian Scott 2b2b995e22 v3.2.0 release 2025-08-09 15:46:00 -06:00
Ian Scott 3fcdb17e5c Re-enable MPU in SB mode 2025-08-09 10:29:13 -06:00
Ian Scott e1791cc54e Project directory reorg 2025-08-08 00:21:39 -06:00
Ian Scott 0b92610043 Merge branch 'House_Keeping' into sb_bufferless_ng_volume 2025-08-07 22:13:24 -06:00
Ian Scott a44a3a58e5 Fix CI build 2025-07-29 23:34:57 -06:00
Ian Scott db99167180 OPL command buffer has race condition now, disable 2025-07-29 22:51:09 -06:00
Korneliusz Osmenda ff737af011 Use polyphase resampling 2025-07-29 22:09:03 +02:00
Ian Scott b076427863 Mostly working bufferless SB with CD 2025-07-28 21:56:41 -06:00
Daniel Arnold c84773c562 Volume control 2025-06-30 07:56:53 -06:00
Ian Scott 02ba99b6aa Many fixes/improvements to CD image handling:
- Fix memory leak when changing images (file handle not freed)
- Longer max file length limit (127 chars)
- Better errors when USB not present
- Fix polling of CD status register when listing images
- Add ability to load image by name
- Many weird edge cases with image loading state fixed
2025-06-21 23:46:50 -06:00
Ian Scott d9d0007d25 Version 3.0.1 2025-06-19 10:25:25 -06:00
Ian Scott d128a4fa2d Re-enable MPU in SB and USB modes 2025-06-19 09:04:47 -06:00
Ian Scott be1e90c7c0 Version 3.0.0 2025-06-19 08:11:29 -06:00
Ian Scott 180e1db710 Consolidate Tandy and CMS into PSG mode 2025-06-18 18:30:01 -06:00
Ian Scott 771f8f8948 Simplify: single cdrom and fatfs instance, better support single USB drive 2025-06-15 11:40:21 -06:00
Ian Scott 2076774a58 Fix FatFS lib location 2025-06-12 23:10:52 -06:00
Ian Scott e7d3ae27d6 Fix adlib build 2025-06-12 23:10:52 -06:00
Ian Scott f81a612985 Pull wbcbz7's tinyusb branch in as submodule, vendor fatfs 2025-06-12 23:10:52 -06:00
Ian Scott 09d7e81732 CDROM in USB mode 2025-06-12 23:10:52 -06:00
Ian Scott d0df0cdd42 CDROM checkpoint, hacky AdLib 2025-06-12 23:10:52 -06:00
Ian Scott f194ab3ef1 Checkpoint for cdrom emulation 2025-05-17 19:34:05 -06:00
Ian Scott 621d649e23 Use latest Pico SDK and its tinyusb instead of our own 2025-03-16 15:53:08 -06:00