SADX/SA1 Hacking/Modding

Discussion in 'Engineering & Reverse Engineering' started by MainMemory, Aug 15, 2009.

  1. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    [​IMG]

    making steady but slow progress on the model exporter. All I have to add now is texture coordinate support and fix the data totals. Yay!
     
  2. NickW

    NickW

    Member
    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->In other news, I've made a screen layout viewer/editor for SADXTweaker (not released yet). However, currently the only data in this format that has been located is for AVA_BACK.PVM. I would also like to have an option to import an image file, but I'd have to figure out how to make Puyo Tools create PVRs and a PVM for me.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Don't use Puyo Tools for creating the PVRs; use VrSharp instead (just add a reference to VrSharp.dll and you should be able to access its methods for creating them).
     
  3. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    New SADXLVL version 4.61
    Updates:
    Fixed saving asking you to load another level.
    Fixed start positions being highlighted when the last object in the list is highlighted.
    Fixed saving start positions.
    Fixed displaying of invisible models.
    "Sonic Retro" screen will now appear in the middle of the SADXLVL window.

    I have also made a <a href="http://info.sonicretro.org/SADXLVL" target="_blank">wiki page</a>, and a <a href="http://www.youtube.com/watch?v=fKt0S0lJf2g" target="_blank">new video</a> which covers just about all the features except .vt importing.
     
  4. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    Okay, what is happening here?
    So, I was trying to add Death Zone viewing to SADXLVL, but it kept crashing trying to draw the model for Emerald Coast 1, throwing a DivideByZeroException at the line "dev.DrawUserPrimitives(PrimitiveType.TriangleList, deathplanes(I)(j).Count / 3, deathplanes(I)(j))".
    I looked, and it appears that it failed to load any strips from the POLY struct.
    I went through the model data and everything seemed to be in order until I noticed something odd about this:
    .data:0102F4EC stru_102F4EC Mesh <0, 40h, 1, offset byte_102F4E4, 0, 0, 0, 0, 0>
    The PolyType value is 0x40 instead of 0xC0! And yet Dude told me that SADX only supported strips...
    And the Poly struct does seem to make one quad, as the Mesh indicates:
    Code (Text):
    1. .data:0102F4E4 word_102F4E4&nbsp;&nbsp;&nbsp;&nbsp;dw 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; DATA XREF: .data:stru_102F4ECo
    2. .data:0102F4E6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dw 1
    3. .data:0102F4E8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dw 3
    4. .data:0102F4EA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dw 2
    So, um... how do I read quads?
     
  5. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    quads are pretty simple, just split them into 2 triangles. Read the first three, then read the last three
     
  6. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    It seems like the quads aren't appearing in the right places, Emerald Coast 1's is way above where it should be, and none of Speed Highway 1's look like they're in the right places.

    In other news, I think I've almost fixed the texture coordinates! Half of the first building in Speed Highway matches the game now.

    I've also increased the Z buffer to 24-bit, which means that you won't have polygons appearing in front of things that should be in front of them. I tried 32-bit, but it gave me a NotAvailableException.
     
  7. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    <a href="http://info.sonicretro.org/SADXLVL#v4.63" target="_blank" style="background: url(http://info.sonicretro.org/images/5/50/Reticon.png) right no-repeat; padding-right: 20px; border-bottom: 1px dotted #3366BB; color: #3366BB; cursor:pointer; text-decoration:none;" class="wiki">SADXLVL#v4.63</a>
    I also moved the rendering surface onto a panel, so now I can add more controls to the main window if I want.
    I'd say more, but I'm leaving for the day.
     
  8. Mr. Mash

    Mr. Mash

    All fanbases are awful Member
    1,440
    0
    0
    drawing
    <!--quoteo(post=430289:date=Mar 23 2010, 03:38 AM:name=Dude)--><div class='quotetop'>QUOTE (Dude @ Mar 23 2010, 03:38 AM) <a href="index.php?act=findpost&pid=430289">[​IMG]</a></div><div class='quotemain'><!--quotec-->[image]

    making steady but slow progress on the model exporter. All I have to add now is texture coordinate support and fix the data totals. Yay!<!--QuoteEnd--></div><!--QuoteEEnd-->
    I had an Idea, if it's possible, maybe the centre of the circle there could be empty, and the background image change to the selected character? Is that do-able?
    I've gotta try that level editor some time, though.
     
  9. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    [​IMG]

    I've got it to the point where it will reliably export triangle strip data from an obj file. I need to fix the parser to parse and properly handle the texture coordinates, and integrate OBJ2VT into the main program. once texture coordinates are added, completely custom levels and character models will be very easy to implement.

    <a href="http://www.youtube.com/watch?v=_oKdTs1V4Ms" target="_blank">youtube example here</a>
     
  10. SANiK

    SANiK

    Tech Member
    413
    0
    16
    Amazing progress.

    Question about the strip drawing code, are you drawing the strips like so:
    Given a strip list of: 0 1 2 3 4 5 6 7
    It'd be:
    [0 1 2]
    [2 1 3] (not [1 2 3])
    [2 3 4]
    [4 3 5] (not [3 4 5])
    ...
    etc.
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    Oh, really? I had no idea. I wonder if that broke anything...
     
  12. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    I'm not drawing them, I'm having HTGEN make them. I'm pretty sure its going [0 1 2] then if it needs to draw the next poly in the opposite direction, it breaks into a new strip.
     
  13. SANiK

    SANiK

    Tech Member
    413
    0
    16
    (Dude, was referring to MM. HTGens would do this anyways because this is pretty much a standard when dealing with tri-strips.)

    If the strip is stored as: A B C D E F

    [​IMG]

    ABC would draw fine, whilst BCD would be drawn in the opposite direction, so it needs to be CBD.

    That's one thing I remember, the other thing is, if the # containing the strip total is < 0, then the even triangles are inverted, otherwise if the strip total > 0, the odd ones are inverted. (First triangle is triangle 0, so we treat it as even).
     
  14. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    I've tried giving it negative strip_total values, it crashes every time. Am I doing something wrong?
     
  15. SANiK

    SANiK

    Tech Member
    413
    0
    16
    <!--quoteo(post=435186:date=Apr 1 2010, 01:40 AM:name=Dude)--><div class='quotetop'>QUOTE (Dude @ Apr 1 2010, 01:40 AM) <a href="index.php?act=findpost&pid=435186">[​IMG]</a></div><div class='quotemain'><!--quotec-->I've tried giving it negative strip_total values, it crashes every time. Am I doing something wrong?<!--QuoteEnd--></div><!--QuoteEEnd-->

    I don't remember... I might be thinking of SA2's model format. SADX might lack this feature.
     
  16. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    It seems all that accomplished was making the UVs totally screwed up. Like they're tiling 100 times more than they should on the Speed Highway buildings.
     
  17. SANiK

    SANiK

    Tech Member
    413
    0
    16
    <!--quoteo(post=435189:date=Apr 1 2010, 01:45 AM:name=MainMemory)--><div class='quotetop'>QUOTE (MainMemory @ Apr 1 2010, 01:45 AM) <a href="index.php?act=findpost&pid=435189">[​IMG]</a></div><div class='quotemain'><!--quotec-->It seems all that accomplished was making the UVs totally screwed up. Like they're tiling 100 times more than they should on the Speed Highway buildings.<!--QuoteEnd--></div><!--QuoteEEnd-->

    But are they the correct orientation? Might be the UV divisor?
     
  18. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    No, some of the textures are still going in the wrong direction.
     
  19. SANiK

    SANiK

    Tech Member
    413
    0
    16
    <!--quoteo(post=435191:date=Apr 1 2010, 01:50 AM:name=MainMemory)--><div class='quotetop'>QUOTE (MainMemory @ Apr 1 2010, 01:50 AM) <a href="index.php?act=findpost&pid=435191">[​IMG]</a></div><div class='quotemain'><!--quotec-->No, some of the textures are still going in the wrong direction.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Well isn't each value in the strip an index?
    So shouldn't you be passing the index to the UV as well?

    You pass the strip counter # instead... I forgot how the UV data was stored. Wasn't it per vertex?

    Single3ToVector3(objects(h).Attach.Vertex(objects(h).Attach.Mesh(I).Poly(j).Stri
    p(k + 2))), _
    Single3ToVector3(objects(h).Attach.Normal(objects(h).Attach.Mesh(I).Poly(j).Stri
    p(k + 2))), _
    objects(h).Attach.Mesh(I).UV(currentstriptotal + k + 2).U / uvscale, objects(h).Attach.Mesh(I).UV(currentstriptotal + k + 2).V / uvscale))

    to

    Single3ToVector3(objects(h).Attach.Vertex(objects(h).Attach.Mesh(I).Poly(j).Stri
    p(k + 2))), _
    Single3ToVector3(objects(h).Attach.Normal(objects(h).Attach.Mesh(I).Poly(j).Stri
    p(k + 2))), _
    objects(h).Attach.Mesh(I).UV(objects(h).Attach.Mesh(I).Poly(j).Strip(k + 2)).U / uvscale, objects(h).Attach.Mesh(I).UV(objects(h).Attach.Mesh(I).Poly(j).Strip(k + 2)).V / uvscale))
     
  20. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,609
    201
    43
    SonLVL
    actually, it's

    verts.Add(New CustomVertex.PositionNormalTextured( _
    Single3ToVector3(obj.Attach.Vertex(obj.Attach.Mesh(I).Poly.Strips(j).Strip(k + 2))), _
    Single3ToVector3(obj.Attach.Normal(obj.Attach.Mesh(I).Poly.Strips(j).Strip(k + 2))), _
    obj.Attach.Mesh(I).UV(currentstriptotal + 2).U / uvscale, obj.Attach.Mesh(I).UV(currentstriptotal + 2).V / uvscale))

    and doing that made it even worse.