DS-Homebrew / TWiLightMenu

DSi Menu replacement for DS/DSi/3DS/2DS
https://wiki.ds-homebrew.com/twilightmenu/
GNU General Public License v3.0
3.31k stars 206 forks source link

Add markdown vs megadrive autodetect and a markdown reader #2370

Open bootmii opened 8 months ago

bootmii commented 8 months ago

Is your feature request related to a problem? Please describe. Yes! The .md extension is now supported for Mega Drive roms. However, it's also used for Markdown.

Describe the solution you'd like EPUB readers exist for DS(i), and it shouldn't be that hard to repurpose them for Markdown.

Describe alternatives you've considered RetroArch on 3DS doesn't have a Markdown viewer either yet.

Additional context The same problem exists for Colors vs ColecoVision but it's probably harder to solve because Markdown is text.

bootmii commented 8 months ago

At 5:46 PM, RocketRobz wrote:

.md files will only appear if one of these checks are passes:

  • Offset 0x4 contains an entry point range between offsets 0x8 and 0x3FFFFE.

If there's a space, number, or punctuation in line 1 column 5 this check passes. For example, this comment has an entry point of 0x3a3436, and my first comment has an entry point of 0x20796f.

  • The SEGA string is stored at offset 0x100.
RocketRobz commented 8 months ago

I deleted my post because I thought I misunderstood your post...

bootmii commented 8 months ago

You weren't too far off. How many Sega Genesis ROMs have you seen where byte 0x4 was 0x0a, 0x0d, or between 0x20 and 0x3f? (The Sega Mega Drive is big-endian.)

As for deleting your post, don't worry, I got it in an email.

bootmii commented 8 months ago

Ishido would fail, as the entry point is 0x2 and Accolade wasn't putting "SEGA" at 0x100 yet (there was no need to in 1990). That's unless the entry point is actually 0x200, but then wouldn't this check guarantee that the byte at 0x4 is always 0x00? If so, there's no bug here of Markdown files getting detected as Mega Drive ROMs, which is more than I can say for RetroArch. I still want a Markdown reader though. That's my feature request.

bootmii commented 8 months ago

Thanks for writing a commit so quickly. You might actually be checking byte 0x7 though. The point of reversing bytes 4 through 7 is that the Sega Genesis is big-endian and the Nintendo DS is little-endian, I'm not sure if fread swaps the byte order when writing into a byte array (that is, if segaEntryPointReversed[0] corresponds to byte 0x7 or 0x5 and segaEntryPointReversed[3] corresponds to byte 0x4 or 0x6) but if it doesn't, we should be checking the byte that corresponds to offset 0x4.

RocketRobz commented 8 months ago

Thanks for writing a commit so quickly. You might actually be checking byte 0x7 though. The point of reversing bytes 4 through 7 is that the Sega Genesis is big-endian and the Nintendo DS is little-endian, I'm not sure if fread swaps the byte order when writing into a byte array (that is, if segaEntryPointReversed[0] corresponds to byte 0x7 or 0x5 and segaEntryPointReversed[3] corresponds to byte 0x4 or 0x6) but if it doesn't, we should be checking the byte that corresponds to offset 0x4.

Commit a6bceddd1 already checks the correct offset. fread does not swap the bytes.