CEmu icon indicating copy to clipboard operation
CEmu copied to clipboard

Improved emulation of ST7789 LCD controller

Open calc84maniac opened this issue 1 month ago • 0 comments

Implemented many features as documented in the Sitronix datasheet, as well as based on research of the actual behavior on real hardware.

New features:

  • MCU and VSYNC display modes, which scan the display using the LCD's internal clock
  • Porch control for RGB display mode, as well as porch and frame rate control for the new display modes
  • Approximate LCD response time emulation (exposed as a user setting)
  • Approximate analog gamma emulation (exposed as a user setting), as well as approximated presets
  • Digital gamma emulation for red/blue components
  • Black/white color parameter for unused lines in partial mode
  • Endianness parameter for 16bpp pixel format through SPI
  • LCM Control parameter, as well as other parameters that reverse scan direction
  • RAM bypass and HV mode for RGB display mode (still WIP)

Fixed behavior:

  • Changes to certain display modes and scroll/partial parameters take effect only at the next VSYNC
  • VSYNC signal from the PL111 is properly ignored if the current frame hasn't finished yet
  • Various PL111 timing fixes, such as sending HSYNC signals during a multi-line VSYNC and properly applying the clock divisor in some places
  • Accurate timing for LCD RAM reads during display scanning
  • Low bits of color components are filled as configured for 12bpp and 16bpp pixel formats
  • Many LCD RAM pointer edge cases are fixed, and support is added for different wrapping modes

Performance improvements:

  • Scheduler is rewritten to use 64-bit timestamps with a fixed (least common multiple) clock unit, and event clocks refactored to use multiplication
  • LCD scanning now batches pixels, and batches are only processed at the end of each line, before LCD RAM is modified on the current line, or when the inverted mode is changed
  • Partial and disabled display modes are checked and rendered only once per line, instead of on each pixel
  • Inverted and idle modes are integrated into the gamma lookup and thus reduced to zero cost

calc84maniac avatar May 14 '24 01:05 calc84maniac