So I made something that renders Sonic Rush level maps

Discussion in 'Engineering & Reverse Engineering' started by Techokami, Dec 11, 2010.

  1. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,309
    2
    18
    HoleNet!
    Sonic Edge
    <!--quoteo(post=540728:date=Dec 22 2010, 09:49 PM:name=Cruizer)--><div class='quotetop'>QUOTE (Cruizer @ Dec 22 2010, 09:49 PM) <a href="index.php?act=findpost&pid=540728"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Also looking elsewhere in the Rush ROM, it seems that object data is stored in /act. So perhaps there is something within those Sprite files that is used in .ev/.dc.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Be careful! It seems that, partway in development, they switched things up. Each level has another archive that goes with it, the act_lz7 archive (the suffix means the archive itself is lz77 compressed) that contains level-specific actor collection files (where actor, in this case, means objects like enemies, items, gimmicks, etc), and there is also the archive act_com_lz7.narc which contains generic stuff like special effects and HUD elements. The ones in the /act directory seem to be residual files that are left over from a previous state of development (in fact they still lingered in the E3 beta but I don't think the game actually uses them even then!) and was cleaned up and cleaned out in Rush Adventure and Colors DS.
    The actor collection files themselves contain graphic placement data, animation data, palettes, and graphics for certain object(s). For example, the rocket launcher Egg Pawn's file contains the badnik itself, and the rockets it fires.
     
  2. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Hope you guys had a good Christmas and new year :P

    I've only just gotten onto deciphering .ev/.dc files, and so far, I haven't gotten a way to test them. .ev seems to be too inconsistent for me to understand for now, so I can't really report on them. Not to mention I don't understand what the decoration files do >_>

    .dc however, I can explain its format. They are extremely similar to .rg files, except that there is a word after the X/Y locations for the object, which presumably denotes which object is at the location. I'm not sure what these values exactly say, but this is a start :P.

    Also about these 256x256 sections, I'm not sure which way they are aligned on the map, other than Left to Right. I cant tell if it goes from the bottom row left, to top row right, or the other way around.

    But thats all for now.
     
  3. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Alright, it's now confirmed .dc are decoration files. To prove, may I introduce you to section 253:
    <img src="http://jake.arch3r.net/public/Block%20253.PNG" border="0" class="linked-image" />

    Do note, that this has been scaled down by a factor of 2. So any position given by any files is halved. Luckily we have no odd value objects :P
    You'll notice 6 irregular black parts. These have been added by paint. the 253 so that we know this is section 253. The line towards the bottom right is...a smudge. It shouldn't be there, but no matter >_>

    The other two dots, are special locations. The one at the top, is the spring. It's code is given as such:
    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>z11.ev:

    Block 253 Pointer.
    Location: 0x3F4 - 0x3F7
    Value: 30 16 00 00

    Block Contents.
    Location: 0x1630 - 0x163D
    Values: 01 00 28 40 43 00 00 00 02 00 00 00 00 00</div>

    Now, springs like this are given the identifier 43 00. You can swap any object to a spring by making the word after the location values to 43 00. The isolated 02 value, seems to be a singular byte, and it relates to how high or low the spring bounces Sonic/Blaze. I've tried testing this value, however there doesn't seem to be a pattern to them. Values of F0-FF, 70-7F are little or no bounce at all. Values of 00-0F seem to be regular spring bouncing. 30-3F is pretty strong, however 40-4F is far stronger. I'll try looking into this more later, it's pretty confusing.

    Now onto the .dc; This is what the .dc file says about that block:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>z11.dc:

    Block 253 Pointer.
    Location: 0x3F4 - 0x3F7
    Value: 94 16 00 00

    Block Contents.
    Location: 0x1694 - 0x169A
    Values: 01 00 10 C8 10 00</div>

    Here's what it looks like in game:

    <img src="http://jake.arch3r.net/public/Proof%20of%20dc.PNG" border="0" class="linked-image" />

    Now this isn't -just- block 253. but it's the part we care about. That flower you see? THAT is what the .dc file is creating. So we now have a way to map decorations! Except we have to find all the decorations first, and if there isn't an easy way to do so, then I'll just produce sprites for it.

    Also partially related, does anyone have something that can view .bac sprites?
     
  4. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    So we're finally getting somewhere. I have <a href="http://jake.arch3r.net/public/rush/Rings" target="_blank">preliminary</a> <a href="http://jake.arch3r.net/public/rushadv/Rings" target="_blank">rings</a> <a href="http://jake.arch3r.net/public/colours/Rings" target="_blank">maps</a> for each 3 games. A friend is currently syncing them with the currently standing maps. So we're almost there! Techokami, the help I requested last night on IRC is no longer needed; it turned out I goofed up part of my recursive function (specifically, using the wrong variable). I'm about to get a script that reads .ev and .dc files, however it will be difficult. My current plan to do this will be to map out placeholders, sync them with the map and then play through each game until each object/event/decoration ID is taken down. After which, I'll (somehow) get necassary sprites, and rerun the script, but instead of having placeholder images used, I'll get the actual sprites in. At that point, the maps will be complete :P

    Finishing these won't be it for me though, I'll be following through with hopes of developing a level editor. So in the meantime, here's a <a href="http://jake.arch3r.net/rushparser" target="_blank">ring counter</a> which counts how many rings there are in each map, and how big the map is (almost) in 256x256 pixel blocks.

    <a href="http://jake.arch3r.net/public/rushringparser.inc" target="_blank">Here's the script I used in it's entirety.</a> It'll later be modified to work with .ev and .dc files. It also needs libripper.phps which is linked in the first post of this thread. Enjoy :D
     
  5. Max Firestorm

    Max Firestorm

    Pyrodramatic Member
    Hmm... With this, is it possible to get things like the "cutscene" dialog sprites from Colours? I know the ones from Rush and Rush Adventure have been ripped (At least partly) but I'm having trouble finding the Colours ones on places like Spriter's Resource
     
  6. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,309
    2
    18
    HoleNet!
    Sonic Edge
    Decorations and other objects are stored as .BAC files. <a href="http://jaquadro.homedns.org/~stream/Sonic_rush_bac.txt" target="_blank">A friend of mine mapped out their innards a while ago</a> and I really need to make a tool that rips from them directly :P

    Also, like I told you earlier Firestorm, the cutscene sprites are stored as background images (BBG files) which are some sort of compressed 8bpp image data. You either need to use an emulator with a layer viewer, or crack the format.
     
  7. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Well frankly I can't make sense of that documentation of the sprites. I'd help, but I don't have a clue about palette data ^^;
    However, I can make the mapping scripts without the sprites for now, since I only need to read a single file. I already know enough about .ev/.dc files to place them on a map, so I'll have them done by Thursday hopefully (since I'm now back at Uni, I can't do it today >_>). Soon, we shall have finished maps for all 3 games!
     
  8. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,309
    2
    18
    HoleNet!
    Sonic Edge
    <!--quoteo(post=563671:date=Feb 27 2011, 07:15 PM:name=Cruizer)--><div class='quotetop'>QUOTE (Cruizer @ Feb 27 2011, 07:15 PM) <a href="index.php?act=findpost&pid=563671"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->but I don't have a clue about palette data ^^;<!--QuoteEnd--></div><!--QuoteEEnd-->GBA 4BPP format. It's supported by libripper.

    function makeGBAPallete( $source, $gd, $keeptrans = FALSE )
    Generates an array of color data representing a palette in the GBA 4bpp format.
    $source: address of palette data in working file
    $gd: GD graphics resource to link this palette to
    $keeptrans: preserve color index 0? If true, override color index 0's data with pure magenta. Defaults to false because a lot of palettes use a bad color for index 0 (leading to black on black) making the creation of alphatransparent images difficult.

    I should make some docs for this thing.
     
  9. Max Firestorm

    Max Firestorm

    Pyrodramatic Member
    <!--quoteo(post=563539:date=Feb 27 2011, 08:36 PM:name=Techokami)--><div class='quotetop'>QUOTE (Techokami @ Feb 27 2011, 08:36 PM) <a href="index.php?act=findpost&pid=563539"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Decorations and other objects are stored as .BAC files. <a href="http://jaquadro.homedns.org/~stream/Sonic_rush_bac.txt" target="_blank">A friend of mine mapped out their innards a while ago</a> and I really need to make a tool that rips from them directly :P

    Also, like I told you earlier Firestorm, the cutscene sprites are stored as background images (BBG files) which are some sort of compressed 8bpp image data. You either need to use an emulator with a layer viewer, or crack the format.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Totally didn't realise it was your thread XDD I obviously wasn't awake when I posted that...
     
  10. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    So right now, there isn't anything that can create/view .bac sprite files?

    Also I think I've made enough modifications to my script so it can handle all 3 map_eve files (rg, dc and ev). Although, until those .bacs are cracked and images are mapped, I can't actually go any further with the map creation due to lack of resources.

    Also perhaps collision information is stored in .bac files? It doesnt seem that they are stored anywhere else.
     
  11. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,309
    2
    18
    HoleNet!
    Sonic Edge
    <!--quoteo(post=565752:date=Mar 5 2011, 08:04 PM:name=Cruizer)--><div class='quotetop'>QUOTE (Cruizer @ Mar 5 2011, 08:04 PM) <a href="index.php?act=findpost&pid=565752"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->So right now, there isn't anything that can create/view .bac sprite files?<!--QuoteEnd--></div><!--QuoteEEnd-->I've been meaning to create a viewer, but laaaazyyyyyy

    <!--quoteo(post=565752:date=Mar 5 2011, 08:04 PM:name=Cruizer)--><div class='quotetop'>QUOTE (Cruizer @ Mar 5 2011, 08:04 PM) <a href="index.php?act=findpost&pid=565752"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Also I think I've made enough modifications to my script so it can handle all 3 map_eve files (rg, dc and ev). Although, until those .bacs are cracked and images are mapped, I can't actually go any further with the map creation due to lack of resources.

    Also perhaps collision information is stored in .bac files? It doesnt seem that they are stored anywhere else.<!--QuoteEnd--></div><!--QuoteEEnd-->.BAC files just store object art and animation. (It stores a hotspot for each frame of animation, which corresponds to the point mapped in those map_eve files.) The object collision data is probably hardcoded in the ROM itself.
     
  12. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    <!--quoteo(post=566900:date=Mar 10 2011, 12:09 AM:name=Techokami)--><div class='quotetop'>QUOTE (Techokami @ Mar 10 2011, 12:09 AM) <a href="index.php?act=findpost&pid=566900"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->.BAC files just store object art and animation. (It stores a hotspot for each frame of animation, which corresponds to the point mapped in those map_eve files.) The object collision data is probably hardcoded in the ROM itself.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Yeah, I noticed that with the spring object in Leaf Storm 1, Section 253. The Positioning of the 'hotspot' is 4 pixels lower than the spring sprite itself. Even with the rings, the hotspot is 16 pixels down and 8 pixels right. The only thing I'll need from .bacs are single, idle sprites (idle as in, when the object/decoration isn't being interacted with), hotspot locations in relation to the top left pixel, and the Object ID. I'm not sure if that last one is even in .bac myself, but I hope it is.
     
  13. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,309
    2
    18
    HoleNet!
    Sonic Edge
    <!--quoteo(post=568216:date=Mar 12 2011, 09:48 PM:name=Cruizer)--><div class='quotetop'>QUOTE (Cruizer @ Mar 12 2011, 09:48 PM) <a href="index.php?act=findpost&pid=568216"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec--><!--quoteo(post=566900:date=Mar 10 2011, 12:09 AM:name=Techokami)--><div class='quotetop'>QUOTE (Techokami @ Mar 10 2011, 12:09 AM) <a href="index.php?act=findpost&pid=566900"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->.BAC files just store object art and animation. (It stores a hotspot for each frame of animation, which corresponds to the point mapped in those map_eve files.) The object collision data is probably hardcoded in the ROM itself.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Yeah, I noticed that with the spring object in Leaf Storm 1, Section 253. The Positioning of the 'hotspot' is 4 pixels lower than the spring sprite itself. Even with the rings, the hotspot is 16 pixels down and 8 pixels right. The only thing I'll need from .bacs are single, idle sprites (idle as in, when the object/decoration isn't being interacted with), hotspot locations in relation to the top left pixel, and the Object ID. I'm not sure if that last one is even in .bac myself, but I hope it is.
    <!--QuoteEnd--></div><!--QuoteEEnd-->All of that, except for the Object ID, <I>should</I> be present in the BAC file. Object IDs, I think are hardcoded in the game binary.
     
  14. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Long time no post. Anyway, I've finally gotten off my ass and pulled together a basic mapping script for .dc files. It works, except for the fact that there are no decoration sprites as of yet:

    http://progsoc.org/~cruizer/z11dual.png
    (new hosting domain :o~, be wary, image is very large, may not load on some computers)

    Anyway, each black box on the map represents a decoration of some sort, with it's Object ID in Cyan (#00FFFF). The only issue with mapping these, is that we need a link between sprites and IDs, and unless we find a way to find that in game, we'll have to do it the hard way: Going through it manually. The scripting will be easy, it's just a couple of minor changes and an image creator from the ID that has just been read.

    The script for .ev files is also coming along nicely, just have to do a bit more fiddling with it. Once a Leaf Storm 1 map is made for it, it'll have to go through the same ID to Sprite linking as mentioned above. I'll post again soon with more updates on how all this is going.

    EDIT: .ev is done serparately so it doesn't interfere with .dc.

    http://progsoc.org/~cruizer/z11mapeve.png
     
  15. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,309
    2
    18
    HoleNet!
    Sonic Edge
    Some of the objects you are reading from the .ev file might not have associated .bac files, I'm seeing what looks like a lot of layer switching and special command objects, along with the Sonic player object (which is a model).

    As for figuring out what object each ID is associated with, unless you can find an internal list in the ROM that also references .bac files to load for artwork you're going to have to do it manually/through brute force. I suggest you start with the decoration objects in .dc as there aren't any invisible objects in there to trip you up.
     
  16. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    What you said is true. When looking at what .ev denoted, I found a neat little trick on the first rail section in Leaf Storm 1. Normally with rails, if you jump on one, you will fall through it. However, at this point where a .ev object was denoted on the rail itself, and when jumping on the rail over this point I landed back on the rail. That technically shouldn't happen, but presumably because of this particular Event ID, it allows you to. I'm assuming there's a whole host of events like this, some may be camera triggers (like the Rolling Disc at the end of Leaf Storm 2) or something else entirely. Also brute force was the intended method, because I haven't been able to find the Sprite IDs in the last 6 months. Anyway, next post I make will be a list of IDs and their corresponding sprites.
     
  17. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Double post! Okay, The Rush maps are being a bitch to me, so I'm doing Rush Adventure's ones now. From Plant Kingdom 2, I have produced a list of some .ev ID's with their corresponding purpose. Consider this the main post for the Sonic Rush Adventure EV ID List. And if I go far enough in, each ID's attributes will be described here.

    00 - Triceratops Badnik
    01 - Pirhana Badnik
    02 - Pterodactyl Badnik

    30 - Item Box (5 Rings/Tension Gauge Up/Tension MAX(?))
    31 - Item Box (? Rings/Magnetic Shield)
    39 - ????

    41 - ????
    42 - ????
    43 - Spring (0 degree rotation)
    43 - ????
    45 - Spring (270 degree rotation)
    46 - Spring (90 degree rotation)
    48 - Spring (45 degree rotation)
    49 - ????
    4A - ????
    4C - Spring (45 degree rotation / Smaller sprite)

    50 - ????
    51 - Mushroom Spring (Orange/0 degree rotation)
    52 - Mushroom Spring (Pink/45 degree rotation)
    53 - Mushroom Spring (Pink/315 degree rotation)
    59 - Rails(?)/Proximity Animation (Leaves)(?)

    63 - ????
    64 - Rainbow Trick Ring
    6A - ????
    6B - Red Trick Ring

    70 - ????
    71 - Goal/Treasure Chest
    72 - Start Position/Platform
    73 - ????
    76 - Swinging Vines
    77 - Breakaway Walls (Wood/Vertical)
    78 - 3D Section Initiator?
    79 - 3D Section Terminator?
    7B - ????
    7C - Breakaway Walls (Wood/Horizontal)
    7D - ????
    7E - ????

    8A - ????

    94 - Tree Catapult (Plant Kingdom Zone Gimmick)

    D1 - Vault(?)

    This list is not final and can be changed at any time because, knowing me, I've gotten something wrong. If anyone can supply sprites for these, that would be greatly appreciated. In fact, if anyone can get all/some sprites from the games, you'll be saving so much time and effort (which are limited for me).

    EDIT: Currently, all ID values are the only ones that occur in Plant Kingdom 1 and 2.
     
  18. Azu

    Azu

    I must be stupid. Member
    So, are you working on a level editor or something?
    http://www.spriters-resource.com/ds/sonicrushadventure/index.html

    Not all of them, but there are some there. Do you just need still shot or complete rips?
     
  19. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Well initially, the first goal is complete maps. After that, it'll require some more format investigation to get any sort of support for a level editor. I'll be willing to figure out what the individual level files do, they just require trial and error and a lot of time.

    Also for the sprites, I'll need individual images for the objects with sprites. It'll make it easier to add to the script and map making process.
     
  20. Cruizer

    Cruizer

    Member
    28
    0
    0
    Australia
    Reverse Engineering the Rush series
    Double Post Again. I fixed my script, and this image is now fixed. I've pulled some of the IDs from Sonic Rush, and here comes it's list.
    [hr]
    00 - Egg Pawn
    01 - Egg Flapper
    02 - Flying Egg Robos
    03 - Egg Knight
    04 - Underwater Egg Flapper
    05 - Aqua Bomber (Purple)
    06 - Aqua Bomber (Green)


    30 - Item Box
    Attributes Known:
    Attribute 5: Item Identifier
    Possible Values:
    00 - ? Rings
    01 - 5 Rings
    02 - 1-Up
    03 - Max Tension Gauge
    04 - Tension Up
    05 - Invincibility
    06 - Shield
    07 - Magnetic Shield​

    31 - Item Balloon
    Attributes Known:
    Attribute 5: Item Identifier
    Known Values:
    00 - ? Rings
    01 - 5 Rings
    02 - 1-Up
    03 - Max Tension Gauge
    04 - Tension Up
    05 - Invincibility
    06 - Shield
    07 - Magnetic Shield​


    40 - Loop Event?
    41 - Loop Event?
    42 - Loop Event?
    43 - Spring (0 deg)
    44 - Spring (180 deg)
    45 - Spring (270 deg)
    46 - Spring (90 deg)
    47 - Spring (315 deg)
    48 - Spring (45 deg)
    49 - Spring (225 deg)
    4A - Spring (135 deg)
    4B - Spring (315 deg, truncated)
    4C - Spring (45 deg, truncated)
    4D - Spikes (0 deg)

    51 - Platform
    Attributes Known:
    Attribute 3: Platform Type
    Known Values:
    00 - Stationery/Moving
    03 - ????
    0C - ????
    40 - Falling​
    Attribute 5: Horizontal Movement Speed
    Attribute 6: Vertical Movement Speed
    These values should be the same, except on opposing axes. Unknown at this time.
    Attribute 7: Horizontal Displacement
    Attribute 8: Vertical Displacement
    These values should be the same, except on opposing axes.
    00 - No Movement
    01-FF - Movement Distance in Pixels?​

    52 - Long Platform
    55 - Trampoline
    56 - Wall Spring (Right to Left)
    57 - Wall Spring (Left to Right)
    58 - Bungee
    59 - Rails (?)
    5C - Dash Panel (Grey)
    5D - Hidden/Cycling Spikes
    5F - Dash Panel (Red)

    63 - Trick Ring (Rainbow, Horizontal)
    Attributes Known:
    None

    64 - Trick Ring (Rainbow, Vertical)
    Attributes Known:
    None

    67 - Trick Ramp
    68 - Horizontal Corkscrew Event
    69 - Vertical Corkscrew Event
    6A - Trick Ring (Red, Horizontal)
    6B - Trick Ring (Red, Vertical)
    6E - Checkpoint(?)
    6F - Tree Stump

    71 - Goal Ring
    Attributes Known:
    None

    72 - Start Position
    Attributes Known:
    Attribute 4: Starting Speed??
    Known Values:
    64 - Constant Value Across All Stages​

    73- Camera Event??
    75 - Big Loop Camera Holder
    76 - Platform (Crumbling?/Unsure of other uses)
    77 - Breakable Walls
    78 - Rolling Saucer
    79 - Saucer Trigger/Camera Event?
    7A - Spiral Spring Gimmick
    7B - ????(Slide Related)
    7C - ????(Slide Related)
    7D - ????(Slide Related)
    7E - ????(Slide Related)
    7F -

    80 - Spiral Water Slide Handlers?
    81 - Tipping Water Level Platforms
    82 - Rotating Fan
    83 - Water Currents
    84 - Air Bubbles
    85 - Water Spout
    86 - Level Gimmick
    87 - Level Gimmick
    88 - Level Gimmick
    89 - Level Gimmick
    8A - Level Gimmick
    8B - Level Gimmick
    8C - Level Gimmick
    8D - Level Gimmick
    8E - Level Gimmick
    8F - Level Gimmick


    9D - Aerial Checkpoint Trigger
    Attributes Known:
    Attribute 5: Unknown
    Known Values:
    C0 - ????​
    Attribute 6: Unknown
    Known Values:
    A0 - ????​
    Attribute 7: Unknown
    Known Values:
    40 - ????​
    Attribute 8: Unknown
    Known Values:
    80 - ????​

    9E - Special Stage Entry Point

    AA - Moveable Block
    [hr]

    Green Text will mean an educated guess. I will not have run into that object yet, but I'd be fairly sure that it will be that object.

    EDIT: All of Leaf Storm 1's IDs have been listed above. Before I move onto Leaf Storm 2, I'm going to try and grab info about Spring and Item Box/Balloon attributes.

    EDIT 2: All Item Box values have been found. I'm tempted to test if it allows values from 08-FF, but that's low priority for now.