don't click here

Sonic Engine Demo

Discussion in 'Fangaming Discussion' started by Rob Jinnai, Nov 30, 2008.

Thread Status:
Not open for further replies.
  1. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    Short version:

    Attempt at "perfect port" of Sonic the Hedgehog 2 as C source that can compile to any capable platform, including the original Genesis itself. This release is fairly premature, so maybe it shouldn't have been shown off yet. I think it's an interesting idea and not necessarily redundant against E02 / ProSonic or whatever since it focuses on being a purist portable version, not just an engine implementation.

    --- Download ---
    http://www.el-hazardonline.net/downloads/S2EngineDemo.zip
    Binary updates for above link; download both, but overwrite the binaries with this one
    -------------------


    Long version:

    Okay, guyz. Here's the gist of what I've been doing. Since I first heard of the disassemblies, I instantly had visions of porting the code to C and creating a native executable on another platform. Then Stealth did his wonderful Sonic 1 single zone demo, but after he decided not to release any source and such, I decided to finally get in gear. Quexinos actually leaked a little bit early about part of it, which is what actually resulted in this thread at the beginning of the month. The truth of it is, I didn't initially intend for the sound engine to be a solo item, but it can and obviously has use in that form. But enough about that.

    So, inspired by Stealth though not living up to his same objectives, here's what my project is about: get all of Sonic 2 into 99% portable C code. The dangling 1% is platform-specific wrapper code that obviously must exist. I chose Sonic 2 because it's obviously popular among the hackers plus I figure it easily goes backward to Sonic 1 and, with some love and more research, I believe can be forward adapted to Sonic 3, eventually.

    My work so far has been the tedious task of recreating the game engine code instruction by instruction, which obviously includes the SMPS demo previously seen, which was created by understanding the Z80 engine. So far I've been working on the actual display and detection of zone data. I have an incomplete and currently non-functional beginning of object detection. The demo included at the end of this post contains a current proof-of-concept prototype -- a demo containing all zones from Sonic 2 (some more or less browseable) that runs almost equally on both PC and a Sega Genesis/Megadrive emulator. (Untested on real hardware, not a priority yet, though eventually I'd like to get it 100% hardware compatible as well.)

    Features:
    • PC edition imitates the 8x8 64KB VRAM character graphics, palettes, scrolling layers, VDP DMA, sprites so that it is a very decent approximation of how it will display on native Genesis/Megadrive (or other character graphics based)
    • C source automagically switches resources between being constant pointers in ROM or delayed-load pointers on disk-based systems. So if you're building a ROM edition, resources are automatically labeled and linked. If you're building a disk-based edition, resources are automatically given filenames to be loaded when queued.
    • Except for system-level calls, there are no "tricks" in the source. There's no "assembly optimized" versions of the physics or zone "rendering" code at this time. The same exact code is compiled straight-up on both sides!
    • The actual engine code is tucked in a library; this means that the typical end user just utilizes the library and codes "externally." They never muck with the system-specific stuff. The end-user programmer's job is to code objects and handle their own resources on their side. The actual decompression routines, memory management, disk management, detection, and all the rest is handled by the library. This also helps keep the system "under control" to ease the portability concept.
    A few magic C macros turn a label such as:
    Code (Text):
    1. static resource ArtUnc_Sonic    = RES_SPRITE_UNC(Obj01_Sonic);
    ... into a filename string on a disk-based system (in this example, "sprites/Obj01_Sonic.art") and a ROM based system will turn it into an externally defined label (in this example, "ArtUnc_Obj01_Sonic".)

    Code is currently compiled under Microsoft Visual Studio 2003 for Win32 and GNU GCC 3.4.5 cross-compiled for 68K for the Genesis/Megadrive binary. I would hope and assume that the code could also be compiled under GCC for Win32.


    Why:
    I always felt that assembler was a very tedious way to go, and making a portable C version enables not only easier coding but use of common debug tools to facilitate a shorter, easier development cycle for those who just want to employ the engine but not get bogged down in 68K asm. This opens the doors to a wider audience. And also just plain makes it easier for the rest of us! There are currently posts made about "exciting" developments such as having more than 16 zones or adding "Act 2" music in Sonic 2 ... wouldn't it be great if the former was as simple as increasing the array size in your C source, which it currently is in this case? :psyduck: )


    Limits:
    The library is constructed to be opaque, meaning that some limits are in place, but these ease the porting of a greater PC platform to a lesser platform such as Genesis/Megadrive. E.g. it still uses an object list (which YOU supply) of a max 256 objects, so each object ID remains only one byte. The zone size is set at Sonic 2's sizing, so it cannot arbitrarily be made larger from the end-user's position.

    Memory is probably the largest concern. Currently when compiled on Genesis/Megadrive, the final binary reports using 57,496 (out of 65,536) bytes, and really you can't use every last byte anyway due to needs of stack space and whatnot. The good news is that I don't expect that figure to get much larger, so the end-user may have a few kilobytes. But don't panic -- this current figure includes the maximum supported number of in-game "active" objects, each of which has a default RAM space just like you see in the disassembly. The amount of memory you are likely to actually use in a typical application of the Sonic Engine will probably amount to only a few hundred bytes at the most!
     
  2. muteKi

    muteKi

    Fuck it Member
    7,851
    131
    43
    Very interesting and impressive! Main issue I had with Sonic was how he seemed to gradually lose forward momentum while he was in the air, but other than that it felt pretty good.
     
  3. roxahris

    roxahris

    Everyone's a hypocrite. Take my word for it. Member
    1,224
    0
    0
    Doing anything at all
    This is great!
    A few bugs...
    Both versions:
    When Sonic walks, he seems a bit wobbly.
    Sometimes while walking down a slope, it displays the wrong animation frame.
    When rolling on a slope, sometimes it might rotate Sonic the wrong way. (Example: Spindash in the half-loop in one of the CNZ acts and hold down)

    Mega Drive version:
    Looking up or down stops the camera, even if it's supposed to be going up or down (For example, hold down, then hold up)

    PC version:
    Sound sounds a little off... probably due to the core.
     
  4. Sintendo

    Sintendo

    Member
    249
    0
    16
    Very nice! However, the music is rather choppy on my PC and the CPU utilization immediately rises to 100%. I know my PC is pretty out of date, but I believe it should be able to run something like this without too much trouble.

    Specifications:
    Intel Pentium 4 2.66GHz (Northwood)
    1GB DDR RAM
    nVidia Geforce 7800 GS (AGP) 256MB
     
  5. Nibble

    Nibble

    Oldbie
    Impressive!

    Genesis version runs fine. PC version runs fine as well, but it doesn't seem to like my aging P4; almost full speed but "skips" often.

    Regardless, the prospect of cross-platform Sonic hacks and an easier hacking process in general is all extremely exciting. :psyduck:
     
  6. Stealth

    Stealth

    Tech Member
    594
    30
    28
    Sonic Mania, HCGE, Sonic Megamix, SonED2, [...]
    As far as I'm aware, only one person is and ever was directly involved with either project. What interests me, though, is that Retro Sonic isn't on that list, and, more importantly, E02 is. I understand that I've done more work with the original material than Taxman has, but as far as these programs go, E02 itself isn't exactly Sonic-centric

    What if either of us did? :/
     
  7. GIHunter

    GIHunter

    Member
    I can second that. I found it impossible to cross the gap where EHZ act 1's bridge is supposed to be because of it.
     
  8. Polygon Jim

    Polygon Jim

    Eternal Tech Member
    0
    3
    0
    across town from Hinchy
    All the bitches.
    I found no problem with the jumping really. I made it to the end of EHZ with no trouble.

    Also, omg Genesis version D: !!!

    Sonic 4 project has to use. NOAW!
     
  9. Yuzu

    Yuzu

    Member
    2,548
    51
    28
    It really does, this gives out the audience for a PC version and a Genesis version. Which means, WIN.
     
  10. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    I simply wrote a list off the top of my head. I actually honestly don't know much about either than the fact that they are used as Sonic engine implementations. I didn't even know you were involved with one until Quexinos told me last night. Understand I've only recently "re-appeared" on this scene so I didn't have time to see these projects form.


    Re: To all sound problems --

    My sister also had a laptop that for all intents and purposes SHOULD have been able to run this, and graphically it ran at full speed but sound-wise was stuttering. That's what I believe is a few possibilities, but overall probably Allegro. I should probably make this run under SDL or something to cut out the fat.

    Also, for any sound quality complaints on PC side, yes, I'm still using the ancient YM2612 core. Something to-be-upgraded.
     
  11. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Are you people dense? Using a new engine won't magically keep you from the restrictions that a Genesis program would give you in the first place. If you want a Genesis version, then build from the original games. That way it'll actually make sense to be on the Genesis.

    That said, this isn't terribly impressive so far. The physics need a lot of work, the animations are wonky, and the PC version lags horribly on my computer, both through sound and visually. If you're trying to port the entirety of Sonic 2 into a modular, general-purpose PC project, then I would have suggested waiting until you at least finished the physics engine.

    It's a nice proof of concept that the engine exists, but suffice to say I'm a bit underwhelmed. I'm sure you can shape it up with time, but I don't think right now was the time to make this 100% public. That's all.

    Regardless, I continue to be impressed by your sound core. :psyduck:
     
  12. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    Well, it's a simple attempt at "getting it out there." The reason being that it's a lonely world doing this solo, and I do wish to seek the knowledge of those who have gone before me and have a much greater understanding of the Sonic engine. This only works as well as it does by learning as I go, which is a tough road to take. I could hole up for a year and complete it and perfect it before anyone sees anything, but by that time maybe someone with a quicker wit who lives with their parents as a couch potato and can work on it 16 hours a day may have beat me out ten-fold.

    Thanks to Krigo, Polygon Jim, Delta, Sintendo, roxahris, muteKi for the enthusiasm.

    Tweaker we'll work on :P
     
  13. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Wow, way to take what I said out of proportion. When did I say I didn't support you? I think this is a promising project that, inevitably, has quite a bit of potential for expansion; however, I also wanted to give you honest feedback, instead of the somewhat-mindless ass-kissing these kinds of threads normally get. There's some fundamental problems with what you have here, and it would have been nice to wait until the physics engine was done to garner support—otherwise people aren't outright going to see the potential this project holds.

    That's my main feedback. You can either take it into account or justify to the end of time why you did it the way you did; which is going to be more useful, though? We've talked about this before quite a few times, so it should be obvious I'm not 100% against everything you're trying to do. Presentation is key, though, and to be blunt this isn't the greatest first impression to the public.
     
  14. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    It's okay, I realized some overreaction on my part, and I'm attempting to reduce it. I just know it has problems and I'd prefer if you replied with something better than "the physics are wonky and I think you should continue hiding it for a while." I'd prefer it if you used something more descriptive than "wonky"; list me problems. They might all be related. I think there's problems in the traction function for example, which would explain some strange abilities to accelerate up hills. Yes, it does have problems. Work with me here, though. I played Sonic games but never really analyzed Sonic games the way you guys have. I'm asking for help, not being told it's not time for me to be publicizing. Can we kind of meet in the middle here? :P

    The bell has been rung, and you generally can't un-ring it. So maybe this wasn't the best way to go. But I can meet half-way and say that I don't release anymore until it's been more heavily reviewed. If I can have a support system I'll perform private demos to work towards public release.
     
  15. Hez

    Hez

    Oldbie
    You must not know Tweaker very well then...

    For the most part, it is impressive that you actually went through with what you said. It does need a lot of work for it to ever be usable, but this is obviously a proof of concept and I understand that.

    P.S. If you ever need custom levels to test, talk to me =P
     
  16. Very well done! Time to list the bugs/issues:

    - Gravity is too high. Sonic falls to earth sooner than normally.

    - Running has a speed cap. Spinning doesn't, like in Sonic 1.

    - Loops are half done, and corkscrews don't work at all.

    - The screen shifts rapidly to catch up with Sonic when the "game" starts. Putting Sonic at the beginning might fix this.

    - Sonic does some wierd sprite flips when going up small hills, like self righting himself in mid-air when running up them.

    - The water and the background aren't moving.

    - When the game is active, and something else is clicked outside the game, the music freezes in place

    - Some hills look and act bumpy when running on them.

    - The bottom of the screen can sometimes be shown at the lower parts of the level.

    - When you die, the game just stays, and doesn't restart the level.


    I know most of this has to do with nothing relating to the engine, but I just thought I would let you know.
     
  17. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    Sonic seems to slow down horizontally when you jump, making those missing log bridge-related gaps kind of tricky to pass.

    EDIT: The Genesis version seems to have an instrument missing in the BGM.
     
  18. jman2050

    jman2050

    Teh Sonik Haker Tech Member
    634
    4
    18
    This whole project seems kind of redundant with stuff like E02, Sonic Retro, and ProSonic around, but hey, I'm not gonna stop you from doing this, just know you have a tall order ahead of you if you want it to get recognition. I'm gonna echo the same thing I said when Sonic 2 HD and ProSonic were released in such an early state: if it's not presentable, don't release it "just to get it out there" because that goal is ultimately pointless in the long run, as I've learned the hard way.
     
  19. Nibble

    Nibble

    Oldbie
    From what I can understand, this engine seems to be the most "purist" out of E02 or ProSonic or Retro-Sonic. It's basically a straight port of the S2 engine to C so that it runs on both the PC and the Genesis. The other engines, however, are more PC-centric and may use different data formats and such.

    Basically, (and correct me if I'm wrong) I think the point of this is not to have another PC game engine that mimics the Sonic engine; it's to *port* the Sonic engine almost verbatim to C.
     
  20. Rob Jinnai

    Rob Jinnai

    Not really master of theory debunking anymore Tech Member
    215
    0
    0
    Custom Game Engine Prototypes
    I do want an honest assessment about the E02 issue thing. I thought those were simply implementations of the physics only, idealized for a PC runtime. If that's NOT what they are... someone please rundown what these are, because apparently they're bigger than I imagined.
     
Thread Status:
Not open for further replies.