Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. E-122-Psi

    E-122-Psi

    Member
    1,791
    0
    0
    <!--quoteo(post=481319:date=Jul 19 2010, 06:59 AM:name=Selbi)--><div class='quotetop'>QUOTE (Selbi @ Jul 19 2010, 06:59 AM) <a href="index.php?act=findpost&pid=481319"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->@Psi: I don't want pages of conversation. Go to IRC (you know which channel), we try to figure it out there.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Okay. I think I may have got the code working now though (the two lines of code actually seem to interfere if they are cancelled out). The project I think is near complete outside some cosmetic issues (eg. the aforementioned Act font and ending sprites problems).
     
  2. Having a small issue—If I select ARZ from the level select the screen fades to black like it's supposed to, and then nothing....


    If I look at it via the VDP debugger, the palette fades to black, and then 'hops' back to the bit before it started fading, and it loops like this forever, any idea what I can do to fix this?




    How do I change the palette line a specific object uses? Mappings with SonMapEd show up fine for some new art, but the object itself uses the old palette line.
     
  3. Hayate

    Hayate

    Tech Member
    <!--quoteo(post=481409:date=Jul 19 2010, 07:30 PM:name=Irixion)--><div class='quotetop'>QUOTE (Irixion @ Jul 19 2010, 07:30 PM) <a href="index.php?act=findpost&pid=481409"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->How do I change the palette line a specific object uses? Mappings with SonMapEd show up fine for some new art, but the object itself uses the old palette line.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Look for a line near the top of the object code that looks like this:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='codemain'><!--eg1--><pre class="asm" style="font-family:monospace;"><span style="color: #00bfff;">move</span>.<span style="color: #00bfff;">w</span> <span style="color: #ff0000;">#</span><span style="color: #ff0000;">$</span>wxyz, <span style="color: #ff0000;">2</span><span style="">(</span><span style="font-weight:bold;">a0</span><span style="">)</span></pre><!--gc2--><!--bW92ZS53ICMmIzAzNjt3eHl6LCAyKGEwKQ==--><!--egc2--><!--g2--></div><!--eg2-->

    That's the base art offset, which is added to every art offset in the mappings. w controls the priority, palette and whether it's vertically flipped.

    0, 1, 8, 9 -> Palette line 0
    2, 3, A, B -> Palette line 1
    4, 5, C, D -> Palette line 2
    6, 7, E, F - > Palette line 3

    Just be sure to use the number from the same column when you change palette. So if w is 9 to start with, and you want to change it to palette line 2, replace it with D. etc etc.
     
  4. shobiz

    shobiz

    Tech Member
    To be more specific, the entire word is a bitfield of the form PCCV HAAA AAAA AAAA. P is the high priority flag, CC is the palette line (00 = line 1, 01 = line 2, 10 = line 3, 11 = line 4), V is the vertical flip flag, H is the horizontal flip flag and the A bits give the starting pattern index (which is multiplied by $20 to get the starting VRAM address).
     
  5. <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&nbsp;&nbsp;&nbsp;&nbsp;move.w&nbsp;&nbsp;&nbsp;&nbsp;#$2680,art_tile(a1)<!--c2--></div><!--ec2-->


    that would need to be changed to
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&nbsp;&nbsp;&nbsp;&nbsp;move.w&nbsp;&nbsp;&nbsp;&nbsp;#$26A0,art_tile(a1)&nbsp;&nbsp;&nbsp;&nbsp;; 2680<!--c2--></div><!--ec2-->


    Correct? All that comes up now is it being garbled (probably because I didn't change the plreqs), but the bits and pieces that I can tell appart are still using palette line... I'm confused : <


    I want to make it use palette line 0 -- Sonic and Tails'
     
  6. shobiz

    shobiz

    Tech Member
    You're changing the wrong nybble. Change it to $680 and it should work.
     
  7. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    Maybe can someone help me on something?
    Let's see...I added some custom sprites to my Sonic 1 hack for making a new movement for Sonic. Then, apparently I have to edit the sonic.asm file in _anim for adding them and make them work properly. The thing is, I noticed that all animations are labeled by numbers and letters, and I don't know how to check which number and/or letter my custom sprites are. I used SonMapED to add them. Can someone tell where or how can I find these numbers and letters? Thank you in advance
     
  8. Ravenfreak

    Ravenfreak

    Sucks at sprite art Tech Member
    2,787
    3
    18
    O'Fallon Mo
    Sonic 1 Game Gear Disassembly
    <!--quoteo(post=482199:date=Jul 21 2010, 05:28 PM:name=FeliciaVal)--><div class='quotetop'>QUOTE (FeliciaVal @ Jul 21 2010, 05:28 PM) <a href="index.php?act=findpost&pid=482199"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Maybe can someone help me on something?
    Let's see...I added some custom sprites to my Sonic 1 hack for making a new movement for Sonic. Then, apparently I have to edit the sonic.asm file in _anim for adding them and make them work properly. The thing is, I noticed that all animations are labeled by numbers and letters, and I don't know how to check which number and/or letter my custom sprites are. I used SonMapED to add them. Can someone tell where or how can I find these numbers and letters? Thank you in advance<!--QuoteEnd--></div><!--QuoteEEnd-->The hex numbers you are talking about actually are the sprite's frame id's. For example, let's look at Sonic's walking animation script. (The SVN disassembly has this stuff labled BTW, look at that for a reference.)
    SonAni_Walk: dc.b $FF, 8, 9, $A, $B, 6, 7, $FF
    8,9,$A,$B,6,7 translates out to be fr_walk13, fr_walk14, fr_walk15, fr_walk16, fr_walk11, fr_walk12.
     
  9. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    <!--quoteo(post=482217:date=Jul 21 2010, 06:16 PM:name=Ravenfreak)--><div class='quotetop'>QUOTE (Ravenfreak @ Jul 21 2010, 06:16 PM) <a href="index.php?act=findpost&pid=482217"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec--><!--quoteo(post=482199:date=Jul 21 2010, 05:28 PM:name=FeliciaVal)--><div class='quotetop'>QUOTE (FeliciaVal @ Jul 21 2010, 05:28 PM) <a href="index.php?act=findpost&pid=482199"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Maybe can someone help me on something?
    Let's see...I added some custom sprites to my Sonic 1 hack for making a new movement for Sonic. Then, apparently I have to edit the sonic.asm file in _anim for adding them and make them work properly. The thing is, I noticed that all animations are labeled by numbers and letters, and I don't know how to check which number and/or letter my custom sprites are. I used SonMapED to add them. Can someone tell where or how can I find these numbers and letters? Thank you in advance<!--QuoteEnd--></div><!--QuoteEEnd-->The hex numbers you are talking about actually are the sprite's frame id's. For example, let's look at Sonic's walking animation script. (The SVN disassembly has this stuff labled BTW, look at that for a reference.)
    SonAni_Walk: dc.b $FF, 8, 9, $A, $B, 6, 7, $FF
    8,9,$A,$B,6,7 translates out to be fr_walk13, fr_walk14, fr_walk15, fr_walk16, fr_walk11, fr_walk12. Every animation script must start with $FF, and end with $FF (if using the older disassembly.)
    <!--QuoteEnd--></div><!--QuoteEEnd-->
    Uhm...I kinda understand what do you mean. But, what I mean is that I added custom sprites to my hack, is there any way to know which code are them or do I have to label them from scrath? Like...calling them $2A, $2B, etc. or does SonMapED labels them automatically? Sorry if im asking too much, I'm kinda lost there
     
  10. nineko

    nineko

    I am the Holy Cat Tech Member
    IDs are assigned progressively. If you added them after the existing sprites, the first ID will be one more than the previous greatest ID.

    edit: also, Ravenfreak said something wrong. The first byte sets the animation speed, it *doesn't* need to be $FF. And the last byte, well yeah, it has a special meaning. A $FF there means "repeat the whole animation", but there are other values in case you want to repeat only a specific number of frames.
     
  11. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    Thank you very much. So, to see if I got it correctly, for example: I'm gonna say I added the spindash, right? And I added it right after the last sprite I see, in this case is Sonic getting hurt. In SonmapEd it says "frame 57", then the next frame is the first sprite of spindash which says "frame 58". Then, I look into the _anim script and the Sonic getting hurt sprite ID is $1A, so...the first spindash sprite would be $1F? Since I see the $1B, $1C and $1D are used already...but im not sure if that's the correct ID, I'm just guessing
     
  12. Selbi

    Selbi

    Impaled with Extreme Prejudice Member
    1,482
    0
    0
    Northern Germany
    Sonic ERaZor
    EDIT: I guess your only question was to find out the correct animation ID's. These are easy to find out, they are in the header of SonMapED. You don't need to calculate anything, these are exactly the numbers you want. So if SonMapED says in the header "Frame: 57/58" it means the current sprite ID is $57.

    SonMapED doesn't give you any outputs of animations, you gotta do that yourself, but don't worry, they are easy to work with once you understood it. =)

    What Raven told was basically correct, except for the $FF part. And to make sure you don't get confused now, I start over again:
    Once you opened the file (_anim\Sonic.asm), you will notice this at the beginning:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='codemain'><!--eg1--><pre class="asm" style="font-family:monospace;"> <span style="color: #00bfff;">dc</span>.<span style="color: #00bfff;">w</span> SonAni_Walk-SonicAniData
    <span style="color: #00bfff;">dc</span>.<span style="color: #00bfff;">w</span> SonAni_Run-SonicAniData
    <span style="color: #00bfff;">dc</span>.<span style="color: #00bfff;">w</span> SonAni_Roll-SonicAniData
    <span style="color: #00bfff;">dc</span>.<span style="color: #00bfff;">w</span> SonAni_Roll2-SonicAniData</pre><!--gc2--><!--CQlkYy53IFNvbkFuaV9XYWxrLVNvbmljQW5pRGF0YQoJCWRjLncgU29uQW5pX1J1bi1Tb25pY0FuaURh
    dGEKCQlkYy53IFNvbkFuaV9Sb2xsLVNvbmljQW5pRGF0YQoJCWRjLncgU29uQW5pX1JvbGwyLVNvbmljQ
    W5pRGF0YQ==--><!--egc2--><!--g2--></div><!--eg2-->
    These are the <I>Animation ID's</I>. You will need to find the animation you want and then go to (of course =P).
    Most animations look like this:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='codemain'><!--eg1--><pre class="asm" style="font-family:monospace;">SonAni_Float3: <span style="color: #00bfff;">dc</span>.<span style="color: #00bfff;">b</span> <span style="color: #ff0000;">3</span>, <span style="color: #ff0000;">$</span><span style="color: #ff0000;">3C</span>, <span style="color: #ff0000;">$</span><span style="color: #ff0000;">3D</span>, <span style="color: #ff0000;">$</span><span style="color: #ff0000;">53</span>, <span style="color: #ff0000;">$</span><span style="color: #ff0000;">3E</span>, <span style="color: #ff0000;">$</span><span style="color: #ff0000;">54</span>, <span style="color: #ff0000;">$</span><span style="color: #ff0000;">FF</span></pre><!--gc2--><!--U29uQW5pX0Zsb2F0MzoJZGMuYiAzLAkmIzAzNjszQywgJiMwMzY7M0QsICYjMDM2OzUzLCAmIzAzNjsz
    RSwgJiMwMzY7NTQsICYjMDM2O0ZG--><!--egc2--><!--g2--></div><!--eg2-->
    While "like" means, the format, not the numbers itself. To explain it:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><Name>:&nbsp;&nbsp;&nbsp;&nbsp;dc.b <Speed>, <Sprite ID's>, <What should I do next-flag><!--c2--></div><!--ec2-->
    The higher the Speed value is, the slower the animation is, e.g. 5 makes run slower than 3. The Sprite ID's are the sprites itself in hex. You can look them up in the header of SonMapED, if you aren't sure which Sprite ID's to use. The What should I do next-flag has 3 different methods:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$FF =&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop the entire animation forever
    $FE, <value> =&nbsp;&nbsp;&nbsp;&nbsp;go back <value> sprites and repeat animation from there
    $FD, <value> =&nbsp;&nbsp;&nbsp;&nbsp;jump to Animation ID set in <value><!--c2--></div><!--ec2-->

    EDIT: I should try to do my posts quicker in the future. ._.
     
  13. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    I think I got it now :) thank you very much
     
  14. nineko

    nineko

    I am the Holy Cat Tech Member
    To complement what Selbi said, to <I>add</I> a new animation you have to add a new dc.w at the top, in the same format as the other ones. So, give your animation a label name.
    To get the animation ID which should be used from sonic1.asm, just count the number of things there are after the dc.w lines (there can be more than one per line, separated by a comma).
     
  15. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    I see, thank you.

    So, just to be sure, let's say I made Sonic a high jump animation.

    Therefore, I should make this:

    Add this line in _anim sonic.asm

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->dc.w SonAni_HighJump-SonicAniData<!--c2--></div><!--ec2-->

    and then this?

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->SonAni_HighJump:&nbsp;&nbsp;&nbsp;&nbsp; dc.b $60, $61, $62, $63, $64, $FE<!--c2--></div><!--ec2-->

    Is just an example, just to see if I got the information right xD I just have to check the real numbers of my custom sprites in Sonmaped
     
  16. nineko

    nineko

    I am the Holy Cat Tech Member
    Correct. The dc.w must be after all the existing ones, while the actual animation script can be placed (almost) anywhere, though it's common practice to put it after the other ones, as well. Also, make sure there is an even number of numbers in the animation script. If it's odd, add a ", 0" at the end.
     
  17. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    ooh ok, that's what I was thinking about, adding a 0 in first place instead of $FE.
    Thx for all the help :) I've been having issues with this, I hope to get it working soon.

    PS: thank you Selbi, now I read your edit, that's what I wanted to know and I wasn't sure about it :)
     
  18. nineko

    nineko

    I am the Holy Cat Tech Member
    Here is an example. In the original animation file for Sonic there are 31 animations. If you add the spin dash at the end it will be the 32th animation. From the main sonic1.asm you will reference it as 31, or $1F in hex, because you start counting from 0. To keep track of it you can add a comment after the dc.w, like this:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->(...)
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dc.w SonAni_Float3-SonicAniData
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dc.w SonAni_Float4-SonicAniData
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dc.w SonAni_Spindash-SonicAniData;1F<!--c2--></div><!--ec2--><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->(...)
    SonAni_Float3:&nbsp;&nbsp;&nbsp;&nbsp;dc.b 3,&nbsp;&nbsp;&nbsp;&nbsp;$3C, $3D, $53, $3E, $54, $FF, 0
    SonAni_Float4:&nbsp;&nbsp;&nbsp;&nbsp;dc.b 3,&nbsp;&nbsp;&nbsp;&nbsp;$3C, $FD, 0
    SonAni_Spindash:&nbsp;&nbsp;&nbsp;&nbsp;dc.b 0, $58, $59, $58, $5A, $58, $5B, $58, $5C, $58, $5D, $FF<!--c2--></div><!--ec2-->These are straight from my hack, not sure if they are the same as the ones in the guides. Notice how there is an even number of parameters for all those animations. Float3 would have ended at the $FF per se, but the ", 0" at the end is added to make it even. The Spindash animation instead already has an even number of parameters so it can end with $FF.

    edit: and btw, when I say "reference it as $1F", I mean something like this in the main sonic1.asm:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move.b&nbsp;&nbsp;&nbsp;&nbsp;#$1F,$1C(a0)<!--c2--></div><!--ec2-->
     
  19. FeliciaVal

    FeliciaVal

    Member
    690
    0
    0
    Spain
    mmm...I see. Then this is much difficult than I expected, because now I have to program the new animation itself and sadly I'm still new to ASM so I don't understand some stuff >_< but well, thank you very much for explaining, as I said I hope to get this done sooner or later.
    And with that I mean, editing sonic1.asm and add the subroutine, that's where I am more lost since I'm still learning ASM and I have no idea how to program new movements, I'm just drawing sprites and replacing them in SonMapEd (except for the spindash that I added following the guide)
     
  20. nineko

    nineko

    I am the Holy Cat Tech Member
    It's easier than it seems. Even I could figure it out, and I am a musician kind of guy who knows almost nothing about graphics and animations. Basically:<ol type='1'><li>You create your new frames with SonMapEd and you append them at the end of the existing frames</li><li>You write down the numbers of those frames</li><li>You add your animation to the animation file, specifying the speed as the first parameter, followed by all the frames you need, and by the animation control byte. If there is an odd number of parameters, add an extra zero at the end</li><li>Go to the main sonic1.asm and find the routine where you want your animation to be used. For a jump you're likely to be interested into the Sonic_Jump: routine. That routine normally uses this line to set the jumping animation:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move.b&nbsp;&nbsp;&nbsp;&nbsp;#2,$1C(a0); use "jumping"&nbsp;&nbsp;&nbsp;&nbsp;animation<!--c2--></div><!--ec2-->The 2 is explained by looking at the Sonic animation file:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dc.w SonAni_Walk-SonicAniData ;0
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dc.w SonAni_Run-SonicAniData ;1
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dc.w SonAni_Roll-SonicAniData ;2<!--c2--></div><!--ec2--></li><li>If you want to use a different kind of jump, you need to put a branch somewhere in your code. The jump routine isn't the most intuitive one to be edited, but it could be worse. Basically, right before the jsr (CalcSine).l you have the jump "strenght" in the d2 register, which will be split into its X and Y coordinates by the CalcSine routine</li></ol>Feel free to ask if you have any further question. I retired from active hacking, but I'm always up to help :)