Skip to content

Fix smd format handling for Genesis/Mega Drive#4747

Closed
mr-ke wants to merge 1 commit into
TASEmulators:masterfrom
mr-ke:fix/interleaving
Closed

Fix smd format handling for Genesis/Mega Drive#4747
mr-ke wants to merge 1 commit into
TASEmulators:masterfrom
mr-ke:fix/interleaving

Conversation

@mr-ke
Copy link
Copy Markdown

@mr-ke mr-ke commented May 24, 2026

dev build for branch | mr-ke:fix/interleaving

Summary

Fixes SMD handling for Genesis/Mega Drive cores. Previously, .smd files would result in a black screen.

Changes

SMD Header Detection

  • Use 16KB alignment check (fileLength & 0x3FFF == 0x200) instead of 1KB alignment
  • SMD files have a 512-byte header followed by 16KB interleaved blocks

Deinterleave Logic

  • Add content-based interleaving detection by checking "SEGA" signature positions
    • In interleaved format: 0x80='S', 0x2080='E', 0x81='G', 0x2081='A'
  • Skip processing if ROM is already deinterleaved (has "SEGA" at 0x100)
  • Handle trailing bytes that don't form complete 16KB blocks

Technical Details

The previous implementation used 1KB alignment for header detection, which failed for many SMD files. The correct approach is to check for 16KB alignment with 512-byte offset.


Check if completed:

…/github.com/franckverrot/EmulationResources/blob/master/consoles/megadrive/genesis_rom.txt

- Correct header detection: use 16KB alignment check instead of 1KB
  (SMD files have 512-byte header with 16KB interleaved blocks)
- Add content-based interleaving detection by checking "SEGA" signature
  positions in interleaved format
- Fix deinterleave logic: even bytes from first 8KB, odd bytes from last 8KB
- Handle trailing bytes that don't form complete 16KB blocks
- Skip processing if ROM is already deinterleaved
@mr-ke mr-ke force-pushed the fix/interleaving branch from fd8089c to 69edda3 Compare May 24, 2026 14:06
@mr-ke mr-ke closed this May 24, 2026
@mr-ke mr-ke deleted the fix/interleaving branch May 24, 2026 14:10
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