Skip to content

Add the PC-8801MC CD-ROM drive - #32

Merged
bubio merged 5 commits into
mainfrom
wip/cdrom-v2
Oct 13, 2026
Merged

bubio merged 5 commits into
mainfrom
wip/cdrom-v2

Conversation

@bubio

@bubio bubio commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • PC-8801MC の CD-ROM ドライブを追加(CD BIOS の解析から設計)。.cue / .ccd のイメージに対応し、データ読み込み(DMA)と CD-DA の再生、フェーダーを実装
  • ドライブは CD が入った状態でリセットしたときにつながる(cdDriveInstalled)。CD BIOS(CDBIOS.ROM)がないときはつながらない
  • ステートセーブにドライブの状態を保存。CD の中身は含めず、読み込み後に reattachCD で入れ直す。BIOS ファイルがなくなったときのために unloadCDBios を追加
  • D9 のモード 1 は区間を繰り返し再生(Mirrors は BGM のループをドライブに任せている)。サブ Q の状態値、フェーダーのビット、位置指定 0x00 を確定
  • イマーシブ出力に CD の音を独立した音源として追加(AudioSamples.cd、b88_drain_audio_stem の 4 番)
  • C ABI に CD 関連の関数を追加(b88_mount_cd / b88_reattach_cd / b88_eject_cd / b88_load_cd_bios / b88_unload_cd_bios など)

アプリ側は bubio/Bubilator88 の CD 対応 PR で使用します。

Test plan

  • swift test(1044 件すべて成功)
  • 回帰テスト scripts/regression_compare.py(20/20 PASS)
  • Mirrors(CD 版)で起動、BGM のループ、CD プレーヤーモードのフェードを確認
  • イマーシブオーディオで CD の音が鳴ることを確認

🤖 Generated with Claude Code

bubio and others added 5 commits October 12, 2026 21:47
The drive, its port interface and the CD BIOS mapping are derived from
what CDBIOS.ROM does with ports 0x90-0x9F and 0x99 and with the bytes it
gets back, plus SCSI-2 for the generic commands and ECMA-130 for the
disc layout. Where a behaviour could not be pinned down the code says so
with a TODO.

- CDDisc: .cue (several files, PREGAP/POSTGAP) and .ccd images, raw
  2352-byte sectors read on demand.
- CDROMDrive: SCSI target with auto-acknowledged handshake, TEST UNIT
  READY, REQUEST SENSE, READ(6) by PIO or DMA channel 1, MODE SELECT for
  2340-byte sectors, NEC D8/D9/DA/DD/DE audio and TOC commands, CD-DA at
  44.1kHz through the fader, save state.
- Pc88Bus: CD BIOS over 0x0000-0x7FFF (upper half with RMODE=1), port
  0x99, DMA writes.
- Machine/PC88: drive wiring, loadCDBios, cdDriveInstalled, mount and
  eject; boot strap stays on disk boot with the drive fitted.
- YM2608: external sample source mixed into the output.
- C ABI: b88_load_cd_bios, b88_set_cd_drive, b88_is_cd_drive_active,
  b88_mount_cd, b88_eject_cd, b88_cd_track_count, b88_cd_activity.
- BootTester: BOOTTEST_CD_PATH and BOOTTEST_CD_TRACE.

Mirrors boots from CD, builds its disks and plays its CD audio with
fades.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A save state carries the drive's position but not the disc. mountCD
starts the drive afresh, so restoring needs a way in that keeps the
state: PC88.reattachCD(url:) and b88_reattach_cd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app loads the CD BIOS before every reset and needs to drop it when
the file is no longer there, so the drive goes inactive instead of
running on the copy loaded earlier. Exposed to the C ABI as
b88_unload_cd_bios.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mirrors patches the BIOS's D9 routine to send mode 1 and never reads
sub-Q, so its music loops only if the drive repeats the range; the NEC
drive in BubiC-8801MA has the same modes. Mode 0 now stops, and paused
reads as 2 in sub-Q.

Fader bit 0 selects a slow fade and a fade starts from the other end:
the CD player writes 0 then 5 at the start of a track, which only fades
in from silence, and stops at once after 6.

Position type 0x00 takes a 24-bit LBA. The drive's save state layout
moves to 2 and still reads layout 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CD audio was mixed only into the stereo output, so a host playing the
immersive stems heard no CD. AudioSamples.cd carries it on its own, and
b88_drain_audio_stem drains it as stem 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bubio
bubio merged commit 917f80c into main Oct 13, 2026
3 checks passed
@bubio
bubio deleted the wip/cdrom-v2 branch October 13, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant