Download on GitHub:
https://github.com/HardCade/hardcade/releases================================================================================
CRT-MAME-ARCADE-2D Perceptual Sync 0.168 V2.1
================================================================================
Development Version December 2025
© 2025 Hardcade Olivier Mileo
================================================================================
DESCRIPTION
================================================================================
CRT-MAME-ARCADE-2D Perceptual Sync is a specialized version of MAME 0.168 optimized for
2D arcade on 15 kHz CRT monitors under WINXP-32 with ATI or NVIDIA graphics card +
crt_emu drivers or soft15khz.
Three complementary approaches for CRT video synchronization and selection are
offered for total control of your display:
INI Option auto_refresh_sync = 0
→ MANUAL PERFECT SYNC MODE: Precise tuning of the Refresh Rate Slider up to
4 decimals (±0.0001 Hz) for total timing control. Ideal for purists
who want to calibrate each game individually and achieve strictly
authentic hardware timing with quasi-invisible fixed tearing.
INI Option auto_refresh_sync = 1
→ AUTOMATIC PERFECT SYNC MODE (DDRAW): The real CRT refresh rate is measured automatically
at game launch, after the video screen has produced a sufficient number of stable frames.
The calculated value is applied dynamically to the video engine and user slider in memory
only (no writing to CFG file). Ultra-smooth scrolling even on atypical modelines
(57.45878 Hz, 58.25494 Hz, 60.61575 Hz
)
HARDCADE SWITCHRES CRT (Built-in)
→ OPTIMIZED 15KHZ MODE SELECTION: A deep rewrite of the DirectDraw algorithm.
Unlike standard MAME, this version prioritizes fluidity (Hz) over exact
resolution through a ±24 line vertical tolerance. It allows using your best
240p modelines for the entire catalog (224p, 239p, 256p...) to guarantee
always complete, centered display, and perfect vertical synchronization without stuttering.
Choose your philosophy: absolute manual control or automatic fluidity without effort.
Both methods eliminate mobile tearing and guarantee an optimal CRT experience.
If your modelines are close to the original game timings, activating this
option will offer you the ultimate experience.
If your modelines are far from the original timings, you will only perceive a slight
increase or decrease in game speed, while maintaining perfect timing in terms
of smooth scrolling, tearing elimination, and overall visual fidelity.
// PHILOSOPHY:
Why "CRT-MAME-ARCADE-2D Perceptual Sync" when other emulators like GROOVYMAME already exist?
Whether you emulate in 15khz with recent or old hardware, synchronization between emulation and display
is never 100% perfect in practice. Even if the modeline is calculated to match exactly the original game frequency,
sometimes even respecting the precise values of MAME video drivers, the timing interpreted by your hardware will be more or less
distant from the timing it should actually adopt to be perfectly aligned with the game timing,
there are always discrepancies (large or tiny) due to:
- Hardware tolerances (CRT monitor, graphics card)
- Imprecisions in clocks and oscillators
- Rounding in calculations, operating system
These discrepancies are random depending on your hardware even if you use THE perfect modeline that mathematically respects
the values imposed by the MAME game system, despite that the synchronization drifts more or less over time,
creating this tearing line that "walks" slowly or quickly on the screen - it can take several minutes or even dozens of
minutes to cross the entire screen. This is generally considered acceptable because:
The line moves so slowly that it's hardly noticeable in-game
It's infinitely better than classic tearing with multiple lines moving quickly
By adding V-sync we make it disappear at the cost of one frame of input lag, but if our modeline is too far
from perfect timing we will get stuttering scrolling. Some users still refine their modelines or adjust
slightly the refresh rate to minimize this phenomenon, but micro-tearing often remains present.
Perceptual Sync is the philosophy of a CRT display mode that prioritizes perceived visual stability
(zero mobile tearing, smooth scrolling) rather than absolute accuracy of theoretical refresh.
it's a CRT display doctrine based on human perception, not mathematical perfection.
Perceptual Sync prioritizes perceived fluidity and CRT image stability.
Slight speed variations (≤0.0001 to 0.5 Hz) are voluntarily accepted to eliminate mobile tearing.
🔴 What Perceptual Sync DOES NOT TRY to do
❌ Be mathematically exact
❌ Be "perfect frame"
❌ Imitate GroovyMAME
❌ Convince theoretical purists
👉 It assumes its choices.
In other words: "What the eye sees is more important than what the numbers say."
// Fundamental principles:
- Refresh DOES NOT need to be exact if we tolerate a variation of: ±0.0001 to 0.5 Hz (configurable)
👉 Result: imperceptibly different speed, stable image.
// Absolute priority to tearing stability:
- Tearing allowed or not with Vsync enabled
But: fixed, stuck out of visible area if possible or always in the same place
👉 Immobile tearing is psychologically invisible.
// No chase for "perfect modeline":
- No dynamic calculation
- No mode creation
- No real-time adjustment
👉 Once the mode is chosen → and the refresh rate slider refined, don't touch it anymore!
// Player takes priority over chronometer:
- Emulation respects gameplay
- Not the atomic clock
- No perceptible drift in game
================================================================================
MAIN FEATURES
================================================================================
INPUT & LATENCY
───────────────
Late Input Polling Input lag reduction
Non-buffered DirectInput Direct polling of peripheral state
GPU frame queue suppression (D3D9)
VIDEO & SYNCHRONIZATION
───────────────────────
Auto Refresh Syncro, real refresh rate calculation, adapts AUTOMATICALLY to real CRT refresh
Screen Refresh Rate slider save in CFG + 4 decimal precision instead of default 3
Switchres - HARDCADE CRT-OPTIMIZED MODE SELECTION (Version 3.0)
DirectDraw Low-Level VSync Tearing suppression without overhead
D3D9 Real VSync Tearing suppression without overhead
Implicit frameskip deactivation Smooth scrolling on CRT
INTERFACE & CONFIGURATION
─────────────────────────
Optimized 2D ARCADE Build Lightweight executable (without 3D games, mechanical, casino, mahjong, computers, consoles...
No Open GL, No BGFX, No Network support, No midi sound, No LUA Script)
================================================================================
DETAILED TECHNICAL MODIFICATIONS
================================================================================
┌─────────────────────────────────────────────────────────────────────────────
│ AUTO REFRESH SYNC CRT / LCD DDRAW (HARDCADE)
└─────────────────────────────────────────────────────────────────────────────
This feature allows automatic measurement and synchronization of
the real CRT refresh rate at game launch.
Calibration is performed ONLY ONCE, after effective game startup,
when the video screen is stable (real frames already produced).
The measured refresh is:
applied dynamically to the video engine
applied to the user slider in memory only
When auto_refresh_sync is enabled, any option to save the
refresh slider in CFG is deliberately ignored.
This approach guarantees:
exact CRT ↔ game synchronization
perfectly smooth scrolling
absence of tearing
deterministic behavior at each launch
Calibration is deliberately delayed by several dozen frames
to avoid any unstable measurement during initialization phases.
INI Option:
auto_refresh_sync 1
Behavior:
Function active only when auto_refresh_sync = 1
Refresh is recalculated at each game launch
User slider remains modifiable during execution
Compatible with direct command line launch
Independent of MAME UI
Modified files:
src/emu/video.cpp
src/emu/video.h
src/emu/ui/ui.cpp
src/osd/windows/drawdd.cpp
┌─────────────────────────────────────────────────────────────────────────────
│ AUTO REFRESH SYNC CRT / LCD D3D (HARDCADE)
└─────────────────────────────────────────────────────────────────────────────
.... Under development ....
┌─────────────────────────────────────────────────────────────────────────────
│ SLIDER SCREEN REFRESH RATE HIGH PRECISION & CFG SAVE
└─────────────────────────────────────────────────────────────────────────────
Automatic save and reload of user frequency in
cfg/[game_name].cfg, with ultra-fine CRT refresh rate adjustment management
at 0.0001 Hz, display and save at 4 decimals.
Works only if auto_refresh_sync = 0
Key operation:
Arrows alone → ±1.0000 Hz
SHIFT + arrows → ±0.1000 Hz
ALT + arrows → ±0.0010 Hz
SPACE + arrows → ±0.0001 Hz
CTRL + arrows → ±1.0000 Hz (fast)
Added functions:
config_load_screen_refresh() src/emu/video.cpp
config_save_screen_refresh() src/emu/video.cpp
Modified functions:
slider_refresh() src/emu/ui/ui.cpp
◦ Base 10000 → Hz conversion for 4 decimals
◦ Rounding and precise CFG save at 4 decimals
◦ FPS display at 4 decimals
ui_menu_sliders::handle() src/emu/ui/sliders.cpp
◦ SPACE key management for ultra-fine increment
slider_init() src/emu/ui/ui.cpp
◦ refresh slider incval modified to 1 (0.0001 Hz)
Affected files:
src/emu/screen.cpp / screen.h
src/emu/video.cpp
src/emu/ui/ui.cpp
src/emu/ui/sliders.cpp
┌─────────────────────────────────────────────────────────────────────────────
│ HARDCADE SWITCHRES - CRT-OPTIMIZED MODE SELECTION
└─────────────────────────────────────────────────────────────────────────────
This version of CRT-MAME-ARCADE 0.168 introduces a complete rewrite of the
DirectDraw SwitchRes function, specifically designed for 15 kHz CRT display
(arcade / JAMMA / RGB) and Windows XP / GeForce configurations.
DirectDraw video mode selection now relies on a "Hardware-First"
priority hierarchy, guaranteeing fluidity and image integrity.
HARDCADE V3 SELECTION LOGIC:
1. ABSOLUTE PRIORITY TO "INI" (User Override):
If a resolution is forced in the game's .ini file, SwitchRes
applies it immediately with a priority score (1,000,000 pts).
This allows forcing a specific mode even if it's technically
far from the game's native resolution.
2. INTELLIGENT VERTICAL TOLERANCE (±24 Lines):
In Auto mode, SwitchRes now allows a gap of up to
24 vertical lines (ex: using a 240p mode for a 224p game).
This allows maintaining the use of stable and well
physically framed modelines, avoiding black screens or truncated images.
3. REFRESH RATE PRIORITY (Total Fluidity):
Within the vertical tolerance zone, refresh rate proximity
(Hz) determines the winner. The system will always prefer
a 58Hz mode for a 58Hz game, even if the number of lines
differs slightly, guaranteeing perfect scrolling without stuttering.
DIFFERENCES WITH ORIGINAL MAME LOGIC:
ORIGINAL MAME (LCD Logic):
- Priority to higher refresh (penalty if Hz lower).
- Immediate rejection if resolution lower than target (Truncated image).
- Excessive importance of width (Pixel Clock).
HARDCADE CRT (Analog Logic):
- Height (Scanlines) and Refresh are the only vital criteria.
- Width treated as secondary criterion (adjustable on monitor).
- Elimination of destructive vertical scaling.
MODIFIED FILES:
src/osd/modules/render/drawdd.cpp
→ Rewrite of enum_modes_callback (Hardcade V3 Logic)
LCD Rendering (Works perfectly too!)
No impact on:
D3D / OGL
Other video backends
┌─────────────────────────────────────────────────────────────────────────────
│ LATE INPUT POLLING
└─────────────────────────────────────────────────────────────────────────────
DirectInput inputs are polled as late as possible in the frame,
just before video rendering. Avoids using N-1 frame inputs.
Modified file: src/osd/windows/video.cpp
Function : windows_osd_interface::update(bool skip_redraw)
┌─────────────────────────────────────────────────────────────────────────────
│ NON-BUFFERED DIRECTINPUT
└─────────────────────────────────────────────────────────────────────────────
Deactivation of DirectInput event buffer (DIPROP_BUFFERSIZE = 0).
Direct reading via GetDeviceState eliminates 1 to 3 ms of latency.
Modified file: src/osd/windows/input.cpp
┌─────────────────────────────────────────────────────────────────────────────
│ IMPLICIT FRAMESKIP DEACTIVATION (CRT)
└─────────────────────────────────────────────────────────────────────────────
MAME 0.168 applies internal frameskip even with frameskip=0 when no
video modification is detected. This behavior degrades CRT scrolling.
Implicit frameskip is disabled when frameskip=0 is explicit.
Compatible with DDraw, Windows XP, 15 kHz CRT.
Modified file: src/emu/video.cpp
┌─────────────────────────────────────────────────────────────────────────────
│ GPU FRAME QUEUE SUPPRESSION (D3D9)
└─────────────────────────────────────────────────────────────────────────────
D3D9 configuration:
SwapEffect = D3DSWAPEFFECT_COPY
BackBufferCount = 1
Result: -1 frame of real display-side latency.
Modified file: src/osd/windows/ddrawd3d.cpp
┌─────────────────────────────────────────────────────────────────────────────
│ D3D9 REAL VSYNC (NO TEARING)
└─────────────────────────────────────────────────────────────────────────────
Forces real D3D9 hardware VSync (PresentationInterval = D3DPRESENT_INTERVAL_ONE)
independent of classic MAME VSync. Suppresses tearing without CPU overhead.
INI Option: crtvsync 0|1
0 Original MAME behavior (default)
1 D3D9 hardware VSync enabled
Recommended usage: 31kHz LCD screens or CRT (adds ~1 frame of lag on CRT)
Modified files:
src/osd/windows/winmain.cpp
src/osd/windows/video.h / video.cpp
src/osd/windows/ddrawd3d.cpp
┌─────────────────────────────────────────────────────────────────────────────
│ DIRECTDRAW LOW-LEVEL VSYNC (CRT) V3
└─────────────────────────────────────────────────────────────────────────────
Low-level DirectDraw VSync mode for 15 kHz CRT under Windows XP.
Direct rendering in primary surface synchronized on Vertical Blank.
INI Option: ddraw_lowlevel_vsync 0|1
0 Classic MAME behavior (default)
1 Low-level DirectDraw VSync
⚠ Active only if waitvsync = 0
⚠ Automatically disabled if triple buffering active
Operation:
1. VBL wait via WaitForVerticalBlank(DDWAITVB_BLOCKEND)
2. Direct lock of primary surface
3. Primitive scan (blending/alpha detection)
4. Membuffer or direct rendering according to needs
5. Controlled copy membuffer → primary surface
6. Unlock + MAME blit bypass
7. Complete MAME throttling deactivation (update_throttle bypass)
Result:
Latency reduced by approximately 1 frame
Automatic perfect CRT synchronization (Snes9x/RetroArch type)
Zero tearing, ultra-smooth scrolling whatever the modeline
No more need to manually fine-tune each game
Modified files:
src/osd/modules/render/drawdd.cpp
src/emu/video.cpp (update_throttle bypass)
src/emu/emuopts.cpp / emuopts.h
┌─────────────────────────────────────────────────────────────────────────────
│ AUTOMATIC REFRESH ROUNDING (ONE-SHOT) (FUNCTION REMOVED)
└─────────────────────────────────────────────────────────────────────────────
....(FUNCTION REMOVED)....
┌─────────────────────────────────────────────────────────────────────────────
│ OPTIMIZED 2D BUILD ARCADE.LST CLEANUP
└─────────────────────────────────────────────────────────────────────────────
Lightweight version specialized for classic 2D arcade on 15 kHz CRT.
Removed systems:
✗ All 3D games (Model 2/3, Naomi, Taito Type X etc.)
✗ Casino systems (slot machines, video poker)
✗ Mahjong games
✗ Non-arcade "machine" systems (computers, consoles)
✗ Mechanical game systems etc.
Preserved systems (2D only):
✓ Capcom CPS1/CPS2/CPS3
✓ Neo Geo MVS
✓ Konami (GX, Classic)
✓ Sega System 16/18/24
✓ Taito (F2, F3)
✓ Cave (CV1000, PGM)
✓ Irem M72/M92
✓ Toaplan, Psikyo, Data East
✓ Namco System 1/2
✓ 8-bit classics (Pac-Man, Donkey Kong, Galaga, etc.)
Result: Reduced executable, faster compilation, targeted 2D CRT list.
Modified file: src/mame/arcade.lst
┌─────────────────────────────────────────────────────────────────────────────
│ UI LUA DEACTIVATION
└─────────────────────────────────────────────────────────────────────────────
Lua periodic_check and frame_hook periodic calls are now commented out
to avoid any impact on performance or menus.
================================================================================
COMPATIBILITY
================================================================================
OS : Windows XP / 7 / 8 / 10
Renderers : DDraw (XP), D3D9, GDI
Monitors : CRT 15 kHz, LCD 31 kHz
================================================================================
CREDITS
================================================================================
Development : Olivier Mileo
Project : CRT-MAME ARCADE-2D 0.168 Edition
Base : MAME 0.168
© 2025 Hardcade All rights reserved
================================================================================
================================================================================
Download on GitHub:
https://github.com/HardCade/hardcade/releases