don't click here

Sprite Mappings Editor

Discussion in 'Engineering & Reverse Engineering' started by Xenowhirl, Dec 2, 2006.

Thread Status:
Not open for further replies.
  1. Xenowhirl

    Xenowhirl

    Tech Member
    175
    0
    0
    First, I hope someone here would be interested in a tool like this:

    [​IMG] [​IMG] [​IMG]

    I started working on it because I found LOst Library to be insufficient for managing or replacing Sonic's sprites. It's intended for use with split disassemblies, and can load and edit and save mappings and dynamic loading cue files in both .asm and .bin formats, for Sonic 1/2/3K. It will also be able to import/export graphics in whole or part in .bin or .bmp, and delete unused graphic tiles or swap palette entries without disrupting the appearance of any sprites.

    Okay, but it's not ready yet, and I have some questions:

    1. I am using this as my main reference: http://sonicology.fateback.com/hacks/mappings/
    Is there more complete information anywhere else? The support I have for Sonic Crackers is incompete because the Crackers format page is incomplete. I would support other games if their mapping formats are known and similar enough (Sonic CD? Beta/prototype of Sonic 2?)

    2. I don't know where to find mappings or pattern cues except in the few locations on that page. I can't test Sonic Crackers because I don't know any offsets for it, nor do I know where the mappings for Super Sonic are in Sonic 3, which worries me because the Super Sonic sprites are mixed in with the regular sprites and I hope the fault isn't in the mappings parser misdetecting where the mappings end.

    3. Currently for the player 2 FFTT bytes in Sonic 2 I am assuming TT_p2 = TT_p1 / 2 and FF_p2 = FF_p1, and basically ignoring them. Should I be doing something else with those bytes?

    4. Anyone have (sensible) feature requests?
     
  2. Qjimbo

    Qjimbo

    Your friendly neighbourhood lemming. Oldbie
    Wow that looks really cool! Keep up the good work =)
     
  3. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    Looks very nice. I think that if it'll be a little more user-friendly, it'll be even better.
     
  4. jman2050

    jman2050

    Teh Sonik Haker Tech Member
    634
    4
    18
    YOU STOLE MY IDEA!!!!!!!!

    :P

    No, really, I wactually was planning on making a mappings editor, and I have the notes to prove it. Not that I'm complaining or anything, as this app looks far better than I could have come up with. One ting I wish we could have though? An animation editor. Just find the offsets for the animation scripts (we have disassemblies, so they shouldn't be hard to find) to test them andmake something that allows you to build and test animations. Other than that, I have only obvious features, like ability to import art, the ability to draw a sprite and THEN generate art and mappings based on the completed image. As for your questions:

    1: We have disassemblies for 1 & 2 we can use. As for S3K, you're gonna have to actually ask someone. Of course, there's always Nemesis' hacking guides on SCHG at info.sonicretro.org .

    2: The Super Sonic mappings for S3K are actually seperate from regular sonic's mappings. Might explain why you didn't find them :P The address is $146816

    3: Actually, I was under the impression they were unused by the game, and a quick look at my disasm shows that that is quite he case, even when loading sprites in 2P mode. Maybe it just does some quick math that applies to all sprites, I dunno. Regardless, I thoink you should just ignore it, or at the very most provide an editable field for it just in case.

    Great job with this so far, and I look forward to its progress.
     
  5. SMTP

    SMTP

    Tech Member
    That looks amazingly useful! Keep up the good work!
     
  6. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    That looks very useful and easy to use. Good for you, you've combined the powers of Tile layer pro and Sonik sprite into one. I might just start doing hacks again :)
     
  7. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    Wow, that's impressive.

    Why is this man's square not green?
     
  8. Sonic 65

    Sonic 65

    Tech Member
    Can this tool edit all mappings PLUS the character mappings?

    If so, as soon as this is released LOst Library is basically obsolete.
     
  9. Varion Icaria

    Varion Icaria

    He's waiting.... Tech Member
    1,019
    11
    18
    S4: Cybernetic Outbreak
    In Mappings it's Actually FTTT and not FFTT, The Second FTTT in S2 deals with 2P Mode, The F Remains the Same as the First but the TTT is Divided in Half of the 1P TTT, It's simple really since that's how 2P stores it's Vram, Halved.
     
  10. Xenowhirl

    Xenowhirl

    Tech Member
    175
    0
    0
    I think it's neither FTTT nor FFTT. Broken down into bits it appears to be FFFFFTTT TTTTTTTT. The divided in half 2 player part I guessed from looking at the Sonic 2 mappings, but the game ignores most or all of the mapping T values in Sonic's sprites so I was unsure if that applied to everything.

    It won't be as beginner-friendly as Sonik sprite because it can't edit a ROM directly, unless there is a way to expand the mappings and pattern cues and tile graphics in a ROM without changing the offsets of anything else. Also, I don't plan to add tile pixel editing features beyond bitmap import and export, there's no way they could measure up to external dedicated painting programs.

    I'll see about adding an animation editor or viewer, but I don't know why some animations end with 3 $FF's and others have 1 $FF and a 0 at the end, or why when I add frames to the walking animation Sonic has a chance of getting stuck in some other random animation when he should start running.

    This isn't directly related, but I would also like to know what is wrong with Sonic 1's sprite loader that makes it render some tiles as red numbers when the graphics are expanded beyond a certain point.

    Oh one more question: Editing compressed tile graphics files... what's the preferred method for that, package Kens DLLs with the application and use those?
     
  11. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    The 0s after FFs in animation data is just padding, to make the stuff after the data on an even byte (68k code will only work if its on an even byte address).

    As for compression - you could use Kens DLLs, or the Kens source code I guess.
     
  12. BadCopNoDonut

    BadCopNoDonut

    O RLY? Oldbie
    785
    0
    0
    Sonic D T
    Xenowhirl for full member now plz. :>
     
  13. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    Wow, best GUI ever. Continue on it. I like how the other sprites of the animations (the nearest ones) are shown, too. Amazing.
     
  14. ICEknight

    ICEknight

    Researcher Researcher
    It's not that some animations end with FFFFFF, it's that there's some blank animations that begin and end with FF. Check the "?" animations in the following list, for example:
    Code (Text):
    1. Sonic object animations (Sonic 2 prototype)
    2. Documented by ICEknigh7
    3.  
    4.  
    5. 00  Walk            FF0F10111213140D0EFF
    6. 01  Run         FF2D2E2F30FF
    7.     ?           FFFF
    8.     ?           FFFF
    9. 02  Spin            FE3D413E413F414041FF
    10. 03  Fast spin       FE3D413E413F414041FF
    11. 04  Push            FD48494A4BFF
    12.     ?           FFFF
    13.     ?           FFFF
    14. 05  Wait            050101010101010101010101010101010101010101010101010101010101010203030303030
    15. 40404
    16. 05050504040405050504040405050504040405050506060606060606060606040404050505040404
    17. 050505040
    18. 40405050504040405050506060606060606060606040404050505040404050505040404050505040
    19. 404050505060606060606060606060404040505050404040505050404040505050404040505050606
    20. 060606060606060607080808090909FE06
    21. 06  Ledge           09CCCDCECDFF
    22. 07  Look up         050B0CFE01
    23. 08  Look down       054C4DFE01
    24. 09  Spindash charge     0042434244424542464247FF
    25. 0A  Return to Wait      0102FD00
    26. 0B  To Lying pose       030AFD00
    27. 0C  Ledge edge      03C8C9CACBFF
    28. 0D  Skid            05D2D3D4D5FD00
    29. 0E  Float           075459FF
    30. 0F  Float & rotate      075455565758FF
    31. 10  Spring          2F5BFD00
    32. 11  Grabbing pole       015051FF
    33. 12  Leftover (S1)       0F434343FE01
    34. 13  Leftover (S1)       0F4344FE01
    35. 14  Hanging         136B6CFF
    36. 15  Bubble breathing    0B5A5A1112FD00
    37. 16  Burnt           205EFF
    38. 17  Drowning        205DFF
    39. 18  Dead            205CFF
    40. 19  Hit         404EFF
    41. 1A  Hit
    42. 1B  Slide           094E4FFF
    43. 1C  Disappear after hit 7700FD00
    44. 1D  Ledge backwards     13D0D1FF
    45. 1E  Ledge edge backwards    03CFC8C9CACBFE04
    46. 1F  To Super Sonic      090809FF
    47. 20  Lying           0307FD00
    48. 21  Getting up      0040004AFEAA
    Seems like they removed some animations and they got FFFF's as leftovers, for some reason.

    If you add more frames and don't change the pointers to the following animations, these will keep pointing to the same place, which might now have another animation in its place.
    No idea where the pointers are, though.
     
  15. Cinossu

    Cinossu

    Administrator
    2,832
    44
    28
    London, UK
    Sonic the Hedgehog Extended Edition
    The only problem I can see with this is that mappings can be set to any position in the 320x224 frame, and that information about each specific fragment would be useful added as well.

    But other than that, very impressive. I look forward to the release.

    EDIT: Oh, and a problem with that, IceKnight, is that the same thing is done with Sonic CD's added walking and rolling frames; extra $FFs at the end. Why would they keep them in for added animations if they were for unused animations at an earlier date in Sonic 1's development?
     
  16. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Because I wasn't here.

    Still, I don't think I'll tech him just yet... But full member is a given.

    Nice job! I'm hoping I can make better use of this than LL.

    But, by split disassemblies, do you mean in hex, or do you support actual ASM mappings? I'd prefer the latter, if at all possible.
     
  17. Xenowhirl

    Xenowhirl

    Tech Member
    175
    0
    0
    I mean both. Currently it supports saving/loading ASM/BIN Sonic 1/2/3/Crackers mapping/cue files. For loading, it converts the ASM to binary (in memory) and then loads that. It's not a complete ASM parser but it suffices for the stuff found in those files, assuming you don't embed arithmetic or instructions in there.

    The animation file I was editing was ASM with a label for each animation, so it's not a pointer problem. Also, I tried removing two of those trailing $FF's and it screwed up the animation sometimes. Sometimes, as in the running animation sometimes worked fully and sometimes failed to start.

    Piece and fragment information and editing is planned but NYI. I don't know what 320x224 frame you're talking about, I thought the offset range was 256x256 or $FFFFx256, but it doesn't seem like that will be a problem.
     
  18. Hivebrain

    Hivebrain

    Administrator
    3,049
    161
    43
    53.4N, 1.5W
    Github
    Looks very interesting. Like jman2050, I was also going to do a sprite mappings editor, but it's good that you're actually doing it instead of just thinking about it :P

    Running and walking animations are (partially) hard-coded, so you can only edit the frames displayed, not the durations or the number of frames. "Special" animations are prefixed by flags ($FF, $FE etc) instead of the frame duration.

    An idea I had for my mappings editor was to use script files which let people add support for almost any game. The scripts would contain some sort of description of the mappings format.
     
  19. Stealth

    Stealth

    Tech Member
    594
    30
    28
    Sonic Mania, HCGE, Sonic Megamix, SonED2, [...]
    That's not quite right either.. from my notes:
    Code (Text):
    1. Mappings are stored in Object RAM to determine how any sprite should be drawn. It points
    2. to a starting tile by ID, and contains information on how many tiles from that point on
    3. in VRAM should be drawn, and in what shape, direction, and palette row they should be
    4. drawn
    5.  
    6. They begin with a byte describing how many mappings are used to build a particular sprite.
    7. Each mapping for said sprite is defined as listed:
    8.  
    9. Byte 0- (Signed Char) Y offset from the sprite's position at which to draw this mapping
    10.  
    11. Byte 1- Bitfield: 0000 00 00
    12.         Field 0- Not Used
    13.         Field 1- Horizontal Size (in tiles) - 1
    14.         Field 2- Vertical Size (in tiles) - 1
    15.        
    16.         Horizontal and Vertical sizes are defined in the number of tiles taken to build the sprite.
    17.         Sprites are filled vertically first, then horizontally, meaning that the second tile to be
    18.         drawn will go BELOW the first (if the height is greater than 1 tile). A value of 0 will
    19.         give a size of 1, making the largest possible height/width 4 tiles (32 pixels)
    20.  
    21. Byte 2- Bitfield: 0 00 0 0 000 (Palette/Direction)
    22.         Field 0- Display on Low/High Plane
    23.         Field 1- Palette Row
    24.         Field 2- Y Flip
    25.         Field 3- X Flip
    26.         Field 4- Tile ID High Bits
    27.  
    28.         Plane values: 0 - Low
    29.                   1 - High
    30.  
    31.         Palette row values: 0 - row 1
    32.                             1 - row 2
    33.                             2 - row 3
    34.                             3 - row 0
    35.  
    36. Byte 3- (unsigned char) Tile ID Low Bits
    37.  
    38.         Tile ID is an offset (in tiles) from the starting point in VRAM, given elsewhere. Take the
    39.         lower 3 bits of Byte 2, multiply them by 256, and add them to Byte 3 to get this value
    40.  
    41. Byte 4- (Signed Char) X offset from the sprite's position at which to draw this mapping
    That's the Sonic 1 format. In Sonic 2, bytes 2 and 3 are duplicated with the tile ID cut in half to account for the fact that tiles are double-height in the 320x448 mode, and byte 4 is extended to a word (as is the byte representing the number of entries), probably just to keep the data size even. In Sonic 3, the only difference from Sonic 1 is that the number of entries and the X offset are extended to word.

    There's nothing wrong with the art loader, they just knew exactly how much space they would need to store the player frames they had, and allowed themselves only that much. In Sonic 1, the art player art is copied to RAM first, and then DMA'd to VRAM from there during VBLANK by hard code. Sonic 2 and above use a list where they queue whatever DMA transfers they want to happen during VBLANK by listing the source address, destination address, and data size, and they usually use it to send art directly from ROM to VRAM
     
  20. Pinkerton

    Pinkerton

    サメジマ・マミミ Oldbie
    You heard the man, we best scrap these "disassemblies" if we want to make finding the animation script offsets easier. :P *shot*
     
Thread Status:
Not open for further replies.