don't click here

Basic Questions & Answers thread

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

  1. E-122-Psi

    E-122-Psi

    Member
    2,503
    685
    93
    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
    Look for a line near the top of the object code that looks like this:
    Code (ASM):
    1. move.w #$wxyz, 2(a0)
    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. 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. Code (Text):
    1.     move.w    #$2680,art_tile(a1)

    that would need to be changed to
    Code (Text):
    1.     move.w    #$26A0,art_tile(a1)    ; 2680

    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. You're changing the wrong nybble. Change it to $680 and it should work.
     
  7. FeliciaVal

    FeliciaVal

    Member
    693
    11
    18
    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

    Feeling festive this year Tech Member
    3,171
    248
    43
    O'Fallon Mo
    Hacking Sonic Drift
    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
    693
    11
    18
    Spain
    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
    6,369
    524
    93
    italy
    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
    693
    11
    18
    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

    The Euphonic Mess Member
    1,517
    105
    43
    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:
    Code (ASM):
    1.         dc.w SonAni_Walk-SonicAniData
    2.         dc.w SonAni_Run-SonicAniData
    3.         dc.w SonAni_Roll-SonicAniData
    4.         dc.w SonAni_Roll2-SonicAniData
    These are the Animation ID's. You will need to find the animation you want and then go to (of course =P).
    Most animations look like this:
    Code (ASM):
    1. SonAni_Float3:  dc.b 3, $3C, $3D, $53, $3E, $54, $FF
    While "like" means, the format, not the numbers itself. To explain it:
    Code (Text):
    1. <Name>:    dc.b <Speed>, <Sprite ID's>, <What should I do next-flag>
    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:
    Code (Text):
    1. $FF =        Loop the entire animation forever
    2. $FE, <value> =    go back <value> sprites and repeat animation from there
    3. $FD, <value> =    jump to Animation ID set in <value>
    EDIT: I should try to do my posts quicker in the future. ._.
     
  13. FeliciaVal

    FeliciaVal

    Member
    693
    11
    18
    Spain
    I think I got it now :) thank you very much
     
  14. nineko

    nineko

    I am the Holy Cat Tech Member
    6,369
    524
    93
    italy
    To complement what Selbi said, to add 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
    693
    11
    18
    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

    Code (Text):
    1. dc.w SonAni_HighJump-SonicAniData
    and then this?

    Code (Text):
    1. SonAni_HighJump:     dc.b $60, $61, $62, $63, $64, $FE
    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
    6,369
    524
    93
    italy
    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
    693
    11
    18
    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
    6,369
    524
    93
    italy
    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:
    Code (Text):
    1. (...)
    2.         dc.w SonAni_Float3-SonicAniData
    3.         dc.w SonAni_Float4-SonicAniData
    4.         dc.w SonAni_Spindash-SonicAniData;1F
    Code (Text):
    1. (...)
    2. SonAni_Float3:    dc.b 3,    $3C, $3D, $53, $3E, $54, $FF, 0
    3. SonAni_Float4:    dc.b 3,    $3C, $FD, 0
    4. SonAni_Spindash:    dc.b 0, $58, $59, $58, $5A, $58, $5B, $58, $5C, $58, $5D, $FF
    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:
    Code (Text):
    1.         move.b    #$1F,$1C(a0)
     
  19. FeliciaVal

    FeliciaVal

    Member
    693
    11
    18
    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
    6,369
    524
    93
    italy
    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:
    1. You create your new frames with SonMapEd and you append them at the end of the existing frames
    2. You write down the numbers of those frames
    3. 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
    4. 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:
      Code (Text):
      1.         move.b    #2,$1C(a0); use "jumping"    animation
      The 2 is explained by looking at the Sonic animation file:
      Code (Text):
      1.         dc.w SonAni_Walk-SonicAniData ;0
      2.         dc.w SonAni_Run-SonicAniData ;1
      3.         dc.w SonAni_Roll-SonicAniData ;2
    5. 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
    Feel free to ask if you have any further question. I retired from active hacking, but I'm always up to help :)