don't click here

Sonic 1: Widescreen Edition

Discussion in 'Engineering & Reverse Engineering' started by vladikcomper, Jun 17, 2022.

  1. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    I know the release of Sonic Origins will likely make years of slowly crafting this little project somewhat obsolete (its Sonic 1 version is undoubtedly going to be on a different level), so I'm going to release this as-is~

    Sonic 1: Widescreen Edition
    for the Mega-Drive



    The title says it all. It's a Sonic 1 hack which revamps game engine to support widescreen. And I mean proper and stable widescreen support to the best hardware can do (and as you may guess, increased draw distances come with noticeable penalties on the old hardware).

    However, don't get your expectations too high, as this is nowhere near the levels of perfection Sonic 2 Community's Cut and Taxman's Sonic 1 remaster achieve.

    The base game is exactly the same, with almost no level-design accommodations to wider screen. However, there are tons of quality improvements, optimizations, bugfixes and your favourite Spin Dash is here!

    The main point of this hack is not to fully remake Taxman's Sonic 1 on Mega-Drive, but to draw more attention to widescreen Mega-Drive emulation in general (seriously guys, it's about time we get more widescreen hacks!)

    How to get widescreen emulator

    Now, obviously the original hardware and its emulators don't support widescreen, so to play this hack you'll need GensPlusGX-Wide emulator available through Retroarch. And don't you worry, you can install it and get things going in a couple of clicks!

    1. Launch RetroArch, select "Load Core > Download a Core".
    [​IMG]
    2. Find and install "Genesis Plus GX Wide" core.
    [​IMG]
    3. Now you can use this core to play this hack!

    DOWNLOAD


    Known issues
    1. With no adjustments to boss arenas, some of the bosses are much easier in widescreen. Most notably Spring Yard and Final Zone bosses;
    2. Some objects-heavy portions of Special stages have disappearing sprites at the edges of the screen. This one is unavoidable. Sonic 1 Special stages already pushed hardware to its limits and with increased draw distances, there aren't enough video-memory to draw all the sprites when there's to many of them;
    3. Ending sequence scene is slightly off-center. I didn't have time to properly extend level and fix this.

    - ...Wait a minute! We've had heyjoeway's Widescreen ROM patcher for years now, that's not news!

    That's right. Joye's Quick & dirty autopatcher has been around for years and it's extremely valuable in that it supports both S1 and S2 ROMs as well as the majority of hacks (given engine's base drawing code isn't too modified). However, there's only so much a patcher can do. As the result, ROMs are playable, but quite far from being polished...
    [​IMG]
    NOTICE: Please don't think ROM autopatcher is of bad quality. It's incredibly impressive because of its flexibility and heyjoeway put a lot of efforts into it. It's just the limitations of technology (ROM patching) and emulator quirks.
    The issues may seem minor to moderate, but it takes months and years to refactor engine and fix them.
     
  2. SuperSnoopy

    SuperSnoopy

    I like Sonic Advance Member
    1,778
    740
    93
    Lyon, France
    Slice of life visual novel, coming soon...?
    Incredible work. I have a lot of respect for people that work on "obsolete" hacks or mods that still have their uses, however niche they might be.
    Will definitely give this a try...if I can get retroarch to work on my pc. I tried everything but it just refuses to play roms lol, I guess now is a good time to give it another shot
     
  3. Brainulator

    Brainulator

    Regular garden-variety member Member
    I'll have to check this out a some point.

    Vladikomper, I sincerely hope all is alright where you are. Knowing what's been happening where you live for the past several months, I imagine it's been something of hell.
     
  4. Clownacy

    Clownacy

    Tech Member
    1,061
    607
    93
    I dunno, I prefer to make hacks for actual Mega Drives, not one specific emulator. Working within the Mega Drive's limitations is the whole point of ROM-hacking to me: if I wanted to be free of them, I'd mod the Retro Engine games or use an open-source PC fan engine.
     
    Last edited: Jun 30, 2022
  5. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    Fair point, staying faithful to limitations of the original hardware is ROM-hacking's greatest challenge and beauty~ But we shouldn't be that strict to ourselves, really :) After all, we're doing it because we enjoy it. I enjoy it. So why not have more ways to enjoy it if we can?

    As for Retro Engine modding and fan-games, unfortunately, this is a whole new world with completely different tools, know-hows and a steep learning curve. For me at least. I'm afraid I'm not that young, free and energetic anymore. I cannot make such a drastic switch. I feel good enough where I am.

    I always dreamed of transferring my hacks to widescreen. And now I'm making it come true. The only way I know how. This may not be the most elegant and efficient way for sure, but if I have the right tools and knowledge, why not?

    And I know the release of GensPlusGX-Wide sparkled at least some interest in widescreen hacks. So it certainly wouldn't hurt to have more of them. In reality, most of the people don't really care about emulation accuracy. They only care to have the best experience with their beloved games. That's why from PS era onwards, most of the popular emulators upscale textures, game resolution, allow widescreen hacks and high-res texture packs. Even though most of this is barely possible in 16-bit and 8-bit era games, but we still have potential with widescreen hacks and I love the fact Mega-Drive is the first console to get such an emulator.

    And to be absolutely precise, Sonic 1: Widescreen Edition isn't locked to GensPlusFX-Wide. It's faithful to the original hardware limitations and it works in any emulator and the real hardware itself. It only draws things as if Mega-Drive was capable of widescreen output~ This actually was a challenge: increase drawing distances without slowing the game down or hitting sprite limits of the original hardware (I'm looking at you, Special stages!)

    Thank you for caring about my well-being! Yes, last months hit incredibly hard in many ways (most of all psychologically), that's why I stopped working on my projects and postponed the release of widescreen update for Sonic 1 Blastless and this hack (even though they were 99% ready by February). I had to leave my home and move to a different country. But I'm more or less alright now.
     
    Last edited: Jun 19, 2022
  6. Brainulator

    Brainulator

    Regular garden-variety member Member
    Glad to hear! Hope to see more in the future.
     
  7. Hivebrain

    Hivebrain

    Administrator
    3,048
    160
    43
    53.4N, 1.5W
    Github
    Very nicely done. Using a modded emulator seems like a convenient way to make a fangame with accurate physics. Does it do anything besides widescreen, like disabling the sprite limit?
     
  8. sheepytina

    sheepytina

    "Accidental" Puyo Puyo Queen Member
    I wouldn't say this is without merit nor is it superseded by the mobile decomp or Sonic Origins, especially if someone makes a widescreen Mega Drive core for the MiSTer FPGA or similar projects. You've done good work here! :D
     
  9. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    Not really, GensPlusGX-Wide is literally just GensPlusGX with rendering code slightly altered. Otherwise, it behaves exactly like the original core, which is accurate to the real hardware.

    The only difference is that it adds 2 new core options on top of GensPlusGX:
    • Fix DMA boundary bug (if crossing 128kb ROM boundary)
    • Change how many additional tile columns are draw around the screen (so resolution can go even "wider")
    Original GensPlusGX already had an option to disable sprite limit (as well as many other emulators), and it can also overlock CPU.

    But since there aren't any emulation changes, "widescreen" ROMs are playable in every other emulator and on real hardware, albeit with the original 4:3 aspect ratio.

    Actually, emulation didn't change to the point there's currently no way to detect GensPlusGX-Wide when booting the game. So for every hack with widescreen support, I'll have to ship "widescreen" version of the ROM separately.
     
  10. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    You said:
    So I say (if this is the case); perform a DMA transfer of data across a boundary deliberately into VRAM, then read the data back out of VRAM and verify it, if it matches, then it's GensPlusGX.

    Unless of course what you mean by "options" is a selection by the user, rather than a hard-coded addition to the emulator that's always on?
     
  11. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    That would be a really good idea, but yeah, "core options" refer to settings end-user can alter and unfortunately, "DMA boundary bug fix" is off by default, which means this approach won't work for 99% of casual users (as most of them won't even know this setting exists).
     
  12. Epsilonsama

    Epsilonsama

    THE FASTEST TAPE ALIVE! Member
    690
    42
    28
    Earth
    Love this. The idea of Widescreen Genesis hacks are captivating. This is the original game but in widescreen, so while it doesnt have the bells and whistles of the Retro Engine port it does feel nice knowing that theres a new way to experience the original game with a more modern presentation.
     
  13. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    Well nuts... Should have known.

    ...what about the H/V counter? With a wider screen the H counter should go further, unless this widescreen thing is literally just hacked onto the emulator without any serious thought?
     
  14. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    I will admit to a tiny tinge of disappointment because as someone who has their Sega consoles plugged into a widescreen television I was hoping for anamorphic widescreen, rather than the modified-emulator approach which has become popular recently. That said, making it remain functional on real hardware is impressive—normally the widescreen emulators break compatibility to make it happen. Does the emulator expose some sort of status register to let you turn off the additional wizardry?
     
  15. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    I was considering anamorphic widescreen at some point, yes, but unfortunately, console's resolution is so low and target proportions are so far from integer scaling, it's almost impossible to make results look any good, unless the game art would be designed with anamorphic widescreen to begin with.

    As for the wide emulator, its "widescreen" part is as barebones as you may get. It's just a quick & dirty hack for the rendering code: render 5 extra tile columns to the left of the original TV frame, render 5 tile columns to the right. 5+5 = 10 columns = 80 pixels of extra space in total (by default), which appends 4:3 screen to a 16:9 screen. It doesn't modify hardware behaviour at all. And unfortunately, no custom registers are exposed to detect it.

    This emulator has a major problem as the result of such simplicity: (0,0) coordinate is not screen's top-left corner anymore. The real top-left corner is (-40, 0) pixels now. This actually works better for most of unmodified games, because the camera is still centred and visible redraws are somewhat balanced between left and right borders, so it doesn't look too bad.

    But if you want to get things right, these incorrect on-screen coordinates create major problems for the game's engine.

    In Sonic 1, you cannot easily draw level chunks on negative coordinates, but if you naively shift camera 40 pixels, you still end up with background layer incorrectly placed relative to it and the beginning of a level (obviously, because background coordinates scale differently compared to foreground).

    And then, there are sprites. With screen as wide as 400 pixels, visible sprites start at X-coordinate 128 - 40 = 88 (used to be 128 for 4:3 screen), and end at X-coordinate 88 + 400 = 488 (used to be 448). This is incredibly close to 511, which is VDP's limit for storing sprite's X-coordinate. At this rate, if you draw a sprite wider than 24 pixels at the edge of the screen, some of its pieces may easily overflow: 488 + 24 = 512, which overflows to 0, due to VDP limitations. And Sonic 1 has a good amount of large sprites and it often like to draw them long before they're visible. Collapsing GHZ platforms are a good example.

    With that in mind, I had to overhaul engine quite a bit to compensate for emulator's simplicity. To work around solve negative coordinates issue, I implemented on-the-fly coordinate space conversion for BG/FG as well as sprites. To solve X-coordinate overflow/corruption for sprites, I had to rewrite sprite renderer completely, to a much aggressive one, which is able to cut individual sprite pieces as soon as they go out of visible screen area.
     
    • Informative Informative x 1
    • List
  16. sheepytina

    sheepytina

    "Accidental" Puyo Puyo Queen Member
    So that's how they do it, huh? This approach really doesn't make sense to me. I 3000% get that it's for compatibility with unmodified games, but negative screen coordinates are all sorts of funky in any situation, and for rom hacks like this a more sensible approach would have been for the emulator to just extend the right-hand side 10 columns, or offer that as an option. I know this isn't your doing and it's totally out of your control, but yeah. I think this widescreen emulator core needs some work.

    I would have thought to implement a wider/"skinnier pixel" screen mode, like how the Mega Drive already has 320-wide and 256-wide modes. But then modifying a game to utilize that that would break real hardware compatibility. So it's tricky I guess. Maybe I'm overthinking it.

    To that end, none of this would work on a real Mega Drive or Genesis as the hardware is just not designed that way, but again, this same widescreen hack could totally could be implemented on an FPGA core for the MiSTer project or similar, which would be functionally close enough to real hardware and really take advantage of those good old widescreen CRT TVs. – In fact, the PlayStation core already has a widescreen hack feature like this!

    Though of course, there are also ways to output RetroArch to a 15KHz 240p signal too, be it on a Raspberry Pi or whatever. Not quite the same as real hardware but you still get that CRT goodness.
     
    Last edited: Jul 7, 2022