Sonic and Sega Retro Message Board: Sonic Engine Demo - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 5 Pages +
  • 1
  • 2
  • 3
  • Last ►
    Locked
    Locked Forum

Sonic Engine Demo Attempt at a completely C-based portable Sonic Engine

#1 User is offline Rob Jinnai 

  Posted 30 November 2008 - 02:37 AM

  • Not really master of theory debunking anymore
  • Posts: 215
  • Joined: 17-April 03
  • Gender:Male
  • Project:Custom Game Engine Prototypes
  • Wiki edits:1
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-hazard...2EngineDemo.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:
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!
This post has been edited by Rob Jinnai: 06 December 2008 - 03:37 AM

#2 User is offline muteKi 

Posted 30 November 2008 - 03:11 AM

  • Fuck it
  • Posts: 7427
  • Joined: 03-March 05
  • Gender:Male
  • Wiki edits:91
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 User is offline roxahris 

Posted 30 November 2008 - 03:46 AM

  • Everyone's a hypocrite. Take my word for it.
  • Posts: 1221
  • Joined: 24-January 07
  • Gender:Male
  • Project:Doing anything at all
  • Wiki edits:30
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.
This post has been edited by roxahris: 30 November 2008 - 04:02 AM

#4 User is offline Sintendo 

Posted 30 November 2008 - 03:47 AM

  • Posts: 249
  • Joined: 15-June 04
  • Gender:Male
  • Wiki edits:2
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 User is offline Delta 

Posted 30 November 2008 - 04:23 AM

  • Posts: 367
  • Joined: 11-January 03
  • Gender:Male
  • Location:California
  • Wiki edits:47
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:
This post has been edited by Delta: 30 November 2008 - 04:31 AM

#6 User is offline Stealth 

Posted 30 November 2008 - 06:00 AM

  • Posts: 546
  • Joined: 31-July 05
  • Gender:Male
  • Project:HCGE, Project HC, Sonic Megamix, SonED2, [...]
  • Wiki edits:19

View PostRob Jinnai, on Nov 29 2008, 11:37 PM, said:

I'm especially interested in anyone who has ever been involved with E02 or ProSonic, obviously.

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

View PostRob Jinnai, on Nov 29 2008, 11:37 PM, said:

Or of course feel free to tell me that this is a redundant project and need not exist.

What if either of us did? :/

#7 User is offline GIHunter 

Posted 30 November 2008 - 09:34 AM

  • Posts: 65
  • Joined: 08-November 08
  • Gender:Male
  • Location:Arkansas

View PostmuteKi, on Nov 30 2008, 02:11 AM, said:

Main issue I had with Sonic was how he seemed to gradually lose forward momentum while he was in the air...

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 User is offline Polygon Jim 

Posted 30 November 2008 - 10:30 AM

  • Posts: 3071
  • Joined: 29-March 08
  • Gender:Male
  • Location:across town from Hinchy
  • Project:All the bitches.
  • Wiki edits:582
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 User is offline Krigo 

Posted 30 November 2008 - 11:18 AM

  • MOTIVATION
  • Posts: 2098
  • Joined: 09-December 06
  • Gender:Male
  • Location:Alberta, Canada
  • Wiki edits:30

View PostPolygon Jim, on Nov 30 2008, 03:30 PM, said:

Sonic 4 project has to use. NOAW!

It really does, this gives out the audience for a PC version and a Genesis version. Which means, WIN.

#10 User is offline Rob Jinnai 

Posted 30 November 2008 - 11:32 AM

  • Not really master of theory debunking anymore
  • Posts: 215
  • Joined: 17-April 03
  • Gender:Male
  • Project:Custom Game Engine Prototypes
  • Wiki edits:1

View PostStealth, on Nov 30 2008, 07:00 AM, said:

View PostRob Jinnai, on Nov 29 2008, 11:37 PM, said:

I'm especially interested in anyone who has ever been involved with E02 or ProSonic, obviously.

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


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 User is offline Tweaker 

Posted 30 November 2008 - 11:40 AM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male

View PostPolygon Jim, on Nov 30 2008, 10:30 AM, said:

Also, omg Genesis version D: !!!

Sonic 4 project has to use. NOAW!

View PostKrigo, on Nov 30 2008, 11:18 AM, said:

It really does, this gives out the audience for a PC version and a Genesis version. Which means, WIN.

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 User is offline Rob Jinnai 

Posted 30 November 2008 - 12:08 PM

  • Not really master of theory debunking anymore
  • Posts: 215
  • Joined: 17-April 03
  • Gender:Male
  • Project:Custom Game Engine Prototypes
  • Wiki edits:1

View PostTweaker, on Nov 30 2008, 12:40 PM, said:

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.


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
This post has been edited by Rob Jinnai: 30 November 2008 - 12:55 PM

#13 User is offline Tweaker 

Posted 30 November 2008 - 12:48 PM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male
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 User is offline Rob Jinnai 

Posted 30 November 2008 - 12:54 PM

  • Not really master of theory debunking anymore
  • Posts: 215
  • Joined: 17-April 03
  • Gender:Male
  • Project:Custom Game Engine Prototypes
  • Wiki edits:1
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.
This post has been edited by Rob Jinnai: 30 November 2008 - 01:01 PM

#15 User is offline Hez 

Posted 30 November 2008 - 02:16 PM

  • Asshole
  • Posts: 2592
  • Joined: 11-January 03
  • Gender:Male
  • Location:Hell
  • Project:Your mother
  • Wiki edits:27

View PostRob Jinnai, on Nov 30 2008, 01:54 PM, said:

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."


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

  • 5 Pages +
  • 1
  • 2
  • 3
  • Last ►
    Locked
    Locked Forum

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users