232 Commits

Author SHA1 Message Date
Andre Zeps
266b32dddf Documentation and removal of unused code 2026-05-25 22:12:43 +02:00
Andre Zeps
2c0332e40e CDIC: Add support for Subchannel R..W
- Allows playback of CD+G
2026-05-25 22:12:43 +02:00
Andre Zeps
de2f7cf32d CDIC: Added DBUF[15] reset latency
- Fixes missing sleep during ss_cont() syscall
- On a real machine, about 7 sectors before the first IRQ is received after seek,
  DBUF[15] is reset. This is not consistent however and this is only an approximation.
2026-05-25 20:27:35 +02:00
Andre Zeps
7f3be52193 FMV: Fixed regression of GOP Timecode
- Issue was introduced with 594bae844
- Fixes division by zero with Addams Family Disc 2 when
  opening playback controls
2026-05-02 19:07:03 +02:00
Andre Zeps
98eb8b7755 Added test ROM for TOC analysis 2026-05-02 19:07:03 +02:00
Andre Zeps
2b2c222d82 SERVO: Perform machine reset when a CD image is remounted with a closed tray
- Remount is allowed without reset, when the CD wasn't read yet during power cycle
- Allows changing a disc with multi disc titles after application induced eject
- Added debug option to allow replacing the image during operation
- Also fixed tray close on image mount
2026-02-28 21:53:11 +01:00
Andre Zeps
090ec12ea8 FMV: Fix missing last frame
Fix required for
https://github.com/Slamy/CDi_FMVTest/tree/main/fmv_event_timing
2026-02-22 14:12:37 +01:00
Andre Zeps
c0faa4906e FMV: Added support for MPEG frame synced register updates
- Required for games like Lost Ride
- Partially breaks https://github.com/Slamy/CDi_FMVTest/tree/main/fmv_moving_window again
- Mechanism not yet fully understood
2026-02-22 14:12:37 +01:00
Andre Zeps
ec0ff3b771 FMA: Fixed regression with timing of buffer underflow IRQ
Fixes regression by 7e3d995781
2026-02-22 14:12:37 +01:00
Andre Zeps
92909e9362 FMV: Fixes hiccups with the FMV Window Move Test
Fixes regression of 957ab71ae2
2026-02-22 14:12:37 +01:00
Andre Zeps
112d467b92 FMV: Altered timing of DTS register
- Slightly improves stability of MPEG pause and continue
  with "Lost Ride"
  Still not 100% there...
2026-02-22 14:12:37 +01:00
Andre Zeps
594bae844e FMV: Fixed timing of frame events and parameters
- Decoupled SEQ event from GOP event.
  Now behaves like real VMPEG hardware
- Fixes Lost Ride gameplay after vehicle charge intro
- Fixes timing accuracy of temp ref and time code
  Measurable with mv_status()
2026-02-22 14:12:37 +01:00
Andre Zeps
176e9b6403 FMV: Add support for mid stream sequence parameter change
- Fixes graphical issues after vehicle charge intro
  in "Lost Ride"
2026-02-22 14:12:37 +01:00
Andre Zeps
0393f32cd0 FMV: Patch pl_mpeg for prediction of skipped macroblocks after the slices
- Fixes glitches on macroblock level at the bottom right
2026-02-22 14:12:37 +01:00
Andre Zeps
66cf1711ca FMV: Add 65ms playback delay after SYSCMD Play
- Fixes MPEG buffer underflow with certain titles
  like "Mad Dog McCree"
- Measured on real hardware with 30 and 25 FPS MPEG stream.
  Display rate seems irrelevant
2026-02-22 14:12:37 +01:00
Andre Zeps
47addf7da0 FMA: Fixed MPEG Audio Frame Header Register
- Replaced stub with actual data from stream
- Fixes value of MAS_Head as returned by ma_status()
  - Stereo and Mono are correctly detected by VCD bridge
2026-02-22 14:12:37 +01:00
Andre Zeps
dc711c9776 Added pointing device speed settings
- 22ER9021 and RV 8701 are available to select
2026-02-20 15:28:45 +01:00
Andre Zeps
8bd003002f FMA+CDIC: Extended duration of "play end pop filter"
- Workaround for the pop at the end of the railroad ambience loop
  in "The Lost Ride"

This is probably not the correct fix, since it seems
that the real VMPEG continues to do a subband synthesis to fade
out the playback. I don't even know how that works and
how I need to change pl_mpeg to do that.
2026-01-31 15:31:55 +01:00
Andre Zeps
7e3d995781 FMA: Fixed timing of buffer underflow IRQ
- Fixes ma_hostplay() and ma_loop() combo of "The Lost Ride"
  to play the railroad ambient sound

Game is still not playable
2026-01-30 21:41:08 +01:00
Andre Zeps
a05eac5daf MCD212: Disable region effects during horizontal blank
- Fixes graphical issues with "AIUEO (Japan)", caused by perpetually
  running region slots that all have the left edge as X position

In case of AIUEO, it will run through all 8 slots, resulting into RF0
having the wrong state when it matters, causing a transparency effect to fail
2026-01-30 20:34:39 +01:00
Andre Zeps
c6c211cd76 MCD212: Increased ROM bus bandwidth
- Was slightly slower than real hardware. Now slightly faster than real hardware.
- Fixes black flicker during the intro of "The Ultimate Noah’s Ark", when
  running in 60 Hz mode

This title is on the edge when it comes to using DC_PWrLCT just a few lines
before it is too late. This resulted into wrong mixing weights for single frames
2026-01-25 11:37:40 +01:00
Andre Zeps
84dd96fc43 MCD212: Fix latch timing of DYUV Abs. Start Value
- Ensure DCA completion before start value is utilized
- Fixes graphical corruption in "Lost Eden" during the character screen of "Dina"
2026-01-22 20:59:18 +01:00
Andre Zeps
43ce071e4f MCD212: Add Mosaic Pixel Hold effect
Since no commercial software seems to use this effect,
a custom test application was written for CLUT7 and CLUT4
video modes to compare against real hardware.
2026-01-22 20:59:18 +01:00
Andre Zeps
1f919ea6a4 MCD212: Improved architectural design
- Easing video timing modifications
- Videosim results are still equivalent
2026-01-22 20:59:18 +01:00
Andre Zeps
c029785c57 FMV: Added averaging filter to MPEG video during VCD pixel clock mode
- Isn't visible on CRT but improves perceived HDMI quality
- Can be deactivated in debug options to show the improvement
2026-01-22 20:59:18 +01:00
Andre Zeps
957ab71ae2 FMV: Added experimental slow motion and single step
- Added slow motion mode
- Added support for single step
- Fixes playback control problems with "Imagination in Motion - A New Era in 3D Chill Out Video"

This commit introduces technical debt
- The stepping mechanism is not fully understood
- Slow motion seems to desync audio and video when resuming normal playback

With the current state, the playback speed is still dictated
by the MPEG decoder. It might be possible, that this is wrong.
2026-01-16 19:02:03 +01:00
Andre Zeps
df9e95abf4 FMV: Extended headroom for framebuffers
- Fixes data corruption when output
  buffer is full with 26 frames

I was able to prove that 30 framebuffers
are not enough when allowing 26 of them
to be queued for viewing.
There is a certain distance between
allocation and actually offering the framebuffer
to the queue of ready frames.
It can reach up to 5 frames, it seems.
This is probably the result of B and P frames?
2026-01-12 18:11:44 +01:00
Andre Zeps
3732decfd6 FMV: Added FIFO full flag
- Fixes overflow of MPEG stream data, when
  pausing the playback via mv_pause()
  and causing a flood of data with mv_continue()
- Fixes pausing with
  "Imagination in Motion - A New Era in 3D Chill Out Video"

This doesn't fix scanning through this title.

Previously, there was an assumption that
MPEG data will never be shoveled in, faster than
the CD speed allows. This assumption is wrong
when the functions mv_pause() and mv_continue()
are involved. The FMV driver will not stop
uploading PCL data into the FMV buffer, because
the FIFO full flag was not yet implemented.

The FIFO level had to be moved around, because
it needs to be able to store at least 2324 byte
when not full.
2026-01-10 17:10:04 +01:00
Andre Zeps
65d49f5fb3 Add support for a secondary pointing device
- Optional, must be enabled in Hardware Config

The typical use case of a CD-i, based on
the Mono-I architecture, is the connection
of a pointing device to the front port or
the usage of an Ir Controller.
Both are handled by the SLAVE and usually
combined as the first pointing device.
The back port is available as a serial port.

For 2 players, the first pointing device
is connected to the back port.
During bootup, the operating system decides to
disable the serial port in favor of having
the first pointing device on the back.
The SLAVE doesn't know about this and
all input devices handled by it,
will be perceived as the second pointing device.
2026-01-09 17:16:23 +01:00
Andre Zeps
0535194185 Simulation: Added more fdrvs1 variables to analysis
- Provides better insight into state of FMV driver
2026-01-08 19:48:35 +01:00
Andre Zeps
77c4a85d30 FMV: Allow up to 25 frames in picture FIFO
- Fixes long videos with even smaller frame size
- Fixes even more videos in "Les Guignols de l’Info"

This is the change of b8e3bac amplified.
The failing video this time is at seek position 0xB278800.
The previous one failing was 208x128, this one is
even smaller with 160x112.

It reaches a FIFO level of 21 until playback is started
even on real hardware.
2026-01-07 20:23:28 +01:00
Andre Zeps
80941cd718 FMV: Configured VCD pixel clock as 13.5 MHz
- Instead of going for full 352 pixels, we adapt the behavior
  according to real hardware, as it turns out that the software
  adapts to the misbehavior of it.
- Based on analysis of the Robocop VCD, this is required
  to go full screen
2026-01-04 12:37:18 +01:00
Andre Zeps
f45ae19bcc VMPEG: Added a debug option to disable the VCD pixel clock
Since the visual quality is subpar due to the clock stretching approach,
the core shall have an option to restore the previous behavior until
that problem is solved.

It was squeezed but pixel perfect and therefore might look better
for some users
2026-01-04 11:25:50 +01:00
Andre Zeps
b8e3baca21 FMV: Allow up to 17 frames in picture FIFO
- Fixes long videos with small frame size
- Fixes videos in "Les Guignols de l’Info"

A user has mentioned that "Les Guignols de l’Info" sometimes has problems with videos.

After analysis of "/cd/rtf/application.rtf" from said disc,
starting at byte position 0x11DEA000, it turns out that the
pictures in FIFO (0x0E040A4) can go up to 17 even on real hardware.
This has never happened before and I've assumed that 8 is the maximum.

This is an issue because DecodTS of fdrvs1 calculates the DTS of the next picture with
the formula GEN_DEC_TIM1 (0x0E040A0) - GEN_PINF (0x0E040A4) * GEN_PICT_RATE (0x0E040A8).
This means that GEN_DEC_TIM1 is constantly increasing but GEN_PINF was limited to 8
before. This resulted in having the next picture to show getting more and more out of reach
of V_SCR.

On real hardware, the FIFO reaches 14 until playback starts.
2026-01-04 11:23:43 +01:00
Andre Zeps
fd68fef278 SERVO: Fixed disc type according to actual hardware (210/05)
- Required for the vcd module to even attempt detecting a VCD medium
2026-01-04 11:23:43 +01:00
Andre Zeps
a4059a0af9 VMPEG: Adapted address decoder for VCD pixel clock
- The lower 12 bits are "don't care" and the vcd module accidentally
  writes twice to this space. We only care for the second write because
  of the big endian nature of the long word access
2026-01-04 11:23:43 +01:00
Andre Zeps
06dc8cf866 FMA: Added MPEG Audio Attenuation
- Added DSP registers for storing the derived volume
  from the attenuation value
- Since the official LUT of the VMPEG is not known, a custom
  one is derived, based on measurements from the real machine
- Should make "Lost Eden" more pleasant, since this game attenuates
  the music during spoken dialog.

Compared to a real CD-i, I've decided to recycle the dual AD7528
of the base case to control the volume.
So, it is no longer a dual but a quadro configuration.
2026-01-03 22:14:23 +01:00
Andre Zeps
f855ffc493 FMV: Fixed some meta data returned by MV_Status
- Fixed temporal ref and both frame rate registers
- Effect on commerical titles unknown
2025-12-28 15:49:43 +01:00
Andre Zeps
92a47322d9 FMV: Fix occurrence of NIS event when playing another video
- Fixes soft lock of "Brain Dead 13" after company logo

Also decoupled frame display from FIFO consumption as the real hardware
will probably also do. I don't recall why I even made that change.
Partially reverts ca4216f95
2025-12-28 15:49:43 +01:00
Andre Zeps
948eb013f2 FMV: Added support for VCD pixelclock
- Fixes width of VCDs according to the White book
- Current implementation uses next neighbor approach
  as a first test. Linear filtering might be a better option.

This change is not 100% accurate to hardware. I can measure,
that at least my VMPEG DVC cuts off 1 pixel on the left
and 5 pixels on the right. I ignore this phenomenom for now
and show all 352 pixels, a VCD is delivering.
2025-12-28 15:49:43 +01:00
Andre Zeps
1bdb01cb74 FMV: Improved timing of latched offset settings
- VCUP and DCL IRQs should now behave like real hardware
- "FMV Moving Test" is now behaving as expected

DCL is not documented in any way. It's just that it seems
to occur at the same time as VCUP and a compare behaves differently
because of that
2025-12-28 15:49:43 +01:00
Andre Zeps
dcf221442c Simulation: Added more fdrvs1 variables to analysis
- Provides better insight into state of FMV driver
2025-12-28 15:49:43 +01:00
Andre Zeps
e5235b3cb6 FMV: Missing DTS is replaced by PTS
- This behavior is noticable on real hardware as well
  If the MPEG header has no DTS, the PTS can be read
  from 0x00E040A0 instead

I thought, this is essential for playback of very short
MPEG files but seems, it isn't? Having at least
one frame in the FIFO is more important, I guess
2025-12-28 15:49:43 +01:00
Andre Zeps
3fff0f0e41 FMV: Fix for pl_mpeg parsing single frame videos
This library is not suited for playback of short MPEG files and
pauses in stream delivery at the same time.
If the stream has not enough data, frame generation is aborted.
So one would assume to just always wait until enough data
is there to decode. But that is trap, because short MPEG files
are never decoded on time.

This fix does 2 things
- If enough data for one frame to decode is available, communicate
  at least 1 frame in the FIFO to the driver even so it is not yet
  fully commited by pl_mpeg.
- Don't wait for data as soon as the driver has
  instructed VMPEG to decode and play. I would guess that the buffer is
  filled enough at that point to not underflow.
- Since my guess was wrong as underflows can still occur,
  to abort the wait, the output buffer must be empty too.

There is also another fix here. The worker descriptor must now
be manually committed to increment the command counter.
Since waiting for data can now be aborted, it is possible
that a requested buffer for a worker descriptor needs to be thrown away,
which resulted into a wrong increment and an assertion failure ont the worker side.
2025-12-28 15:49:43 +01:00
Andre Zeps
e1409a95a5 CDIC: Stop reading from HPS when driver is not interested
- This is probably not accurate to real hardware, since
  the CD hardware is still delivering data from the spinning
  disc. But the CDIC doesn't provide that data to the CPU.
  So, for the MiSTer, there is no reason in reading from HPS.
- The scenario of resuming the read without a seek is
  supported by real CDIC hardware but is not used by the driver,
  making this possible
2025-12-28 15:49:43 +01:00
Andre Zeps
da3bfd7467 FMV: Added 3rd MPEG macroblock worker core
- Increases computing power for pixel operations
- Fixes freeze at timecode 04:32 of
  "Star Trek VI - Terre Inconnue (France) (Disc 1)"
  during the shock wave scene
2025-12-21 22:02:28 +01:00
Andre Zeps
d91cc6722c FMV: Refactored multi core architecture
- Worker cores now have their own module
- Removed copy pasta
- Better for maintanance and adding even more cores
2025-12-21 22:02:28 +01:00
Andre Zeps
e543fdaa0e FMV: Fix last missing macroblock
- Very small frame sizes (e.g. 16x128) don't work without this
2025-12-19 14:56:53 +01:00
Andre Zeps
556c2c57f5 Simulation: Verilator update fixes
Required for Verilator 5.042 2025-11-02

Also made the copy to mister script slightly more useful
2025-12-18 13:30:33 +01:00
Andre Zeps
768996504e FMV: Fixed framebuffer jump when sequence header was found
- Was noticable with Top Gun when scanning
- Fixes regression from 120a2d74e since the sequence
  header cache can now be invalidated
2025-12-18 13:30:33 +01:00