Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    There are no guides which I assume is because we don't want everyone have it in their hacks and we see that feature as something you have to earn by being skilled enough in asm to port in yourself. Also adding it is a bit complex because you have to add:
    • Shield art, mappings, and dynamic pattern load cues
    • Code to use the dynamic pattern load cue
    • Extra monitor art
    • Additional objects for the added shields
    • Code to keep Sonic from getting hurt depending on the enemy and shield
    • Code to check which monitor is hit and to load the shield
    • A flag in each enemy's code to keep it from hurting Sonic with the shield
    • Shield ability code (optional)
    I recommend getting familiar with Sonic 1's code, messing around with stuff to see what they affect, and trying to accomplish smaller goals. Once you get a good idea of how the game works, you can try working on this by using what you know to edit Sonic 1's code and taking a look at the Sonic 3K Github disassembly to see how things are done there. While a lot of the code is different than Sonic 1, the shield code and object interaction routine contains code that can be brought to Sonic 1 pretty easily.

    Adding the elemental shields helped me improve a lot as a programmer and so I find it to be a great task to try completing once you have a good idea of how to accomplish it.
     
  2. Painto

    Painto Arthurus Paintus Erinaceus Member

    Joined:
    Mar 24, 2014
    Messages:
    321
    Location:
    Lublin, Poland
    I've recently created a detailed Shields guide for my hacking friends and I've even thought about releasing it to public, however since the moment I started though the finishing until the present moment, I not sure about releasing it, mostly I'm scared on the thing getting generic etc.

    On the main question though, I think ProjectFM gave a good list of what you need. What I can say from my side is that the shield porting/own coding really helps to understand things and differences between Sonic 1/2 and Sonic 3&K. The shields codes are in most part well commented and labeled (except for the boucing part, but that's a pretty easy part if you compare codes). Most of code can be easily used in S1 with some pointer changes. You'll also need to change the art to fit the S1 palette.

    Nevertheless, you can consider adding these as a challenge when you get familiar with things, just like I motivated my implementation.
     
    EMK-20218, ProjectFM and FireRat like this.
  3. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Just a little question: Where is the Angle data file in the Sonic 2 Xenowhirl disassembly?
     
  4. TheBlurCafe

    TheBlurCafe Welcome to TheBlurCafe! Member

    Joined:
    Sep 6, 2016
    Messages:
    101
    Location:
    Somewhere
    Just a seemingly useless question, I just started using SonLVL (call me crazy) and I saw that there is an export function in it.
    I was wondering, is there any import function too? That would save some time.

    EDIT: there is indeed an import function, but it messes up the colors when I import art (ex. BG from GHZ darkens the water for some reason)
     
  5. Devon

    Devon You are the perfect drug Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    I would like to know some really good optimization tricks I could use when it comes to MegaDrive tile manipulation. I'm making some rather basic code that allows you to scroll art via animated tiles, which is generated by code, and have a static image overlaying it, to allow for artificial layering without taking up a ton of ROM space.

    Currently, it pretty much does it similarly to how Marble Zone handles scrolling its lava, in which the original data is like a bitmap that gets scrolled and then converted to tiles. Difference being is that it allows for custom sizes and an overlay image. Currently it doesn't make the game lag, but it does take a lot of CPU usage.
     
  6. MotoBadnik

    MotoBadnik Newcomer Trialist

    Joined:
    Mar 11, 2017
    Messages:
    6
    Location:
    Sunset Hill
    Hello! I'm working on a Sprite Hack for Sonic 1, and for some reason some sprites look messed up,does anyone know how fix this? It happens only on the extra titles[​IMG]
     
  7. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    If you import the image outputted from SonLVL unmodified, you should get an identical result. It sounds to me like you used a 24 or 32 bit per pixel image, and the color matching picked the wrong color. SonLVL has a specific way of handling 2, 16, and 256 color images that maps the color indexes in the image directly to the palette indexes in the level.

    You should also be aware that SonLVL can export and import collision and priority information from images (try an export to see how it works), and can import not only chunks, blocks, and tiles, but layout as well, from the context menu in the layout editor.
     
    TheBlurCafe likes this.
  8. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,015
    It appears that you're using too many tiles. Those 'extra tiles' were being used by something else - in this case, the points. Sonic 1's engine is designed to only give Sonic 23 tiles per frame.
     
  9. MotoBadnik

    MotoBadnik Newcomer Trialist

    Joined:
    Mar 11, 2017
    Messages:
    6
    Location:
    Sunset Hill
    There isn't any way to expand the number?
     
    MarkeyJester likes this.
  10. Devon

    Devon You are the perfect drug Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    Porting over the DMA queue is one way without needing to extend the buffer used for Sonic's art in RAM, but, the extra tiles will overwrite the point art. You would then need to find a different place to put the point art in VRAM.
     
  11. MotoBadnik

    MotoBadnik Newcomer Trialist

    Joined:
    Mar 11, 2017
    Messages:
    6
    Location:
    Sunset Hill
    Sorry, but it's possible to extend Sonic s'art ram instead of relocating sprites? If so, how?
     
  12. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    What he told you was how you can extend Sonic's limit of tiles in VRAM.
    The problem is that the Points art comes right after where Sonic's art is normally dumped, as the developers did not originally expect Sonic to use more than 23 tiles. Essentially, there's no way around relocating the points art if you are extending the tile limit.
    Never fear, however! Relocating is pretty simple. Let's take a look at how you can do it, shall we?

    Firstly, finding a new, free location in VRAM to dump the Points art to. This is a bit tricky, since Sonic 1 packs VRAM pretty tightly.
    My recommendation to you is to just follow this simple guide by our favorite Texan SuperEgg on getting the Shield and Invincibility Stars to use DPLCs. This will free up some tiles to use, which is exactly what you need!

    Now then, we have a free location on VRAM. It's at $AB80, a safe location past the newly created area for Shield and Invincibility art. So, the question is, how do we get the points art there?
    Assuming you're using the Hivebrain 2005 disassembly, go into "_inc/Pattern Load Cues.asm". In the PLC_Main label, you should see something like this:
    Code:
           dc.l Nem_Points       ; points from enemy
           dc.w $F2E0
    
    This is the PLC entry for the Points art, along with the VRAM address for the art to load into. Simply change that $F2E0 to $AB80. Now the art will load at its new destination, and you shouldn't see the points art on Sonic anymore.

    ...Except you may notice now that the points appear either as blank or as tiles from Sonic.
    "What gives, TSB?" I hear you say. Well, we also need to edit something within the Points object itself so it uses the correct tiles.

    In "sonic1.asm", search for Obj29. We need to go to the object initialization routine at Obj29_Main and look for this line:
    Code:
    ...
           move.w   #$2797,2(a0)
    ...
    
    This value details what art tiles in VRAM for an object to use, as well as a few other things such as mirroring, which palette line the object should use, and if the object is drawn on the high or low plane.
    To get the VRAM location, take out the first 10 bits of that value, which is $797. Multiply it by $20.

    $797 * $20 = $F2E0

    Ayyyyy, that's the old VRAM location! Now, it's pretty obvious what we must do. Take the new VRAM location and divide it by $20.

    $AB80 / $20 = $55C

    This means that the line we pointed out before should be changed to:
    Code:
    ...
           move.w   #$255C,2(a0)
    ...
    
    And there we go!
    We have now completely relocated the Points art, and Sonic will have no issues with the Points art overlapping. :D
     
    LuigiXHero and MotoBadnik like this.
  13. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,015
    That guide you linked to is a little broken. I pointed them out in the Retro thread.
     
  14. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    You might also be using more VRAM tiles than necessary in each frame. Make sure each frame contains as little blank tiles as possible. This may involve some re-importing of your sprites. In you're image editing program with an 8x8 pixel grid on, you can adjust each sprites position so it uses as little tiles as possible. Then, once the sprite is imported, you can use SonMapED or Flex to readjust the sprites back to the correct positions.

    Edit: It seems that you palette isn't in the correct order because green is where yellow is and vice verse. Luckily SonMapED has a feature in the options menu where you can reorder the palette line while keeping the sprite's colors intact.
     
    MotoBadnik likes this.
  15. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    After my long hiatus I went and looked at my hack and it is a total fucking mess™. I would start over but I don't want to re-port spindash and supersonic. Should I just hack Sonic 2 instead.
    I'm lazy and I should be ashamed :(
     
  16. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    No, you should start again, and put effort into it right from the beginning.

    Force yourself to work on it, no distractions. And you'll be amazed with marvel at how much you'll achieve, and you'll thank yourself much later for it~
     
    AkumaYin likes this.
  17. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    You are probably right. No you are right.
     
  18. AdelTheQadi

    AdelTheQadi Leader of the anti body pillow movement Member

    Joined:
    Jan 19, 2013
    Messages:
    31
    Location:
    Heck off
    So here's a question. I've kind of just been playing around with art editing in the git disassembly of Sonic 1. I've moved on to the 128px chunk git project because of the pathswapping system.

    I've been using SonLVL and I'm practicing with level art right now. I imported some edited/combined art from different games just to try out the importing/tiling process. I've imported several chunks and they generated quite a few new tiles. They displayed correctly in SonLVL:
    [​IMG]

    However, when I built the game, there were a few tiny jumbles:
    [​IMG]

    So at the time, I was thinking that I had too many tiles because this also broke animated art like flowers, waterfalls, etc, so I deleted some tiles for art that I would not be using from the original green hill zone. I deleted all the tiles pertaining to the default tree as an example.

    [​IMG]
    Thinking the number of tiles was the issue, I thought that if anything, nothing would change.
    [​IMG]
    Instead, more art toward the bottom of the tile sheet gets messed up after building. The blocks look just fine in SonLVL and the tile IDs match up with what's displayed, but this is really off ingame. Can anyone explain why this happens and how to fix it? Is it a bug with SonLVL not saving right or is it the game?
     
    pixelcat likes this.
  19. MotoBadnik

    MotoBadnik Newcomer Trialist

    Joined:
    Mar 11, 2017
    Messages:
    6
    Location:
    Sunset Hill
    Thanks, I followed the guide and it's fixed! But.. now the SEGA sound corrupts,it's related to the fix?
     
  20. Devon

    Devon You are the perfect drug Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    I assume you're using the Hivebrain disassembly, which doesn't automatically fix the bank ID for the SEGA sample.

    The GitHub disassembly fixes that issue, so you can copy it from there. The sample will still play from the DAC driver (loaded in Z80 memory), taking up a slot.

    OR

    Follow this guide which allows the sample to be played from the 68000 side of the console instead of the Z80 side. It can save a DAC sample slot in DAC drivers.

    Both are pretty easy and quick fixes, so it's up to you on what you want to do.
     
    MotoBadnik likes this.