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,470
    612
    93

    Heh, flattered you put one of mine in the 'of course' pile. :)

    Okay, questions:

    *I'm trying to get a control lock onto this Sonic 2 move, my guess is it would involve activating the 'move_lock' flag somewhere in the routine though I'm not sure where (also not sure if I can implement it while keeping the automatic nudge forward):

    Code (ASM):
    1. ; ---------------------------------------------------------------------------
    2. ; Subroutine allowing Sonic to attack
    3. ; ---------------------------------------------------------------------------
    4.  
    5. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    6.  
    7.  
    8. Sonic_Hammer:
    9.         cmp.b   #$23,anim(a0)
    10.         bne.s   lol7
    11.         move.w  $14(a0),d0
    12.         move.w  d0,d1
    13.         asr.w   #3,d1
    14.         sub.w   d1,d0
    15.         move.w  d0,$14(a0)
    16.         rts
    17. lol7:
    18.         btst    #1,(Ctrl_1_Held_Logical).w  ; is Down button pressed?  
    19.         bne.s   JmpTo_SonicHammerreturn ; if yes, return
    20.         btst    #6,(Ctrl_1_Press_Logical).w ; is A button pressed?
    21.         beq lol         ; if not branch
    22.         move.b  #$23,anim(a0)       ; show hammer animation
    23.         jmp Hammer_Cont
    24.  
    25. JmpTo_SonicHammerreturn:
    26.         jmp Sonic_Hammer_return
    27.  
    28. Hammer_Cont:
    29.         move.w  $14(a0),d0
    30.         btst    #0,$22(a0)
    31.         beq lol8
    32.         neg.w   d0
    33. lol8:
    34.         cmp.w   #$400,d0
    35.         bgt lol
    36.         move.w  #$400,d0
    37.         btst    #0,$22(a0)
    38.         beq lol9
    39.         neg.w   d0
    40. lol9:      
    41.         move.w  d0,$14(a0)
    42. lol:
    43.         move.w  $10(a0),d0
    44.         tst.w   d0
    45.         bpl label
    46.         neg.w   d0
    47. label:
    48.         cmpi.w  #$600,d0
    49.         bgt Sonic_Hammer_Return
    50.         btst    #6,(Ctrl_1_Press_Logical).w ; is A button pressed? 
    51.         beq.b   Sonic_Hammer_return ; if not, return
    52.         move.b  #$23,anim(a0)       ; show animation $23
    53.         move.w  #$3D+$80,d0             ; play sound
    54.         jsr (PlaySound).l
    55.  
    56.  
    57. Sonic_Hammer_return:   
    58.         rts
    59. ; End of function Sonic_Hammer 
    Oh and if anyone knows how to work this, is there an equivelent flag for move_lock in Sonic 1?

    * How exactly do you switch pallettes for a sprite (eg. swap it from using Sonic's pallette to say Green Hill's). I also noticed some sprites use different pallettes for certain tiles, is that possible to implement? This would be useful for both Sonic 1 or 2.
     
  2. To lock controls you will need to do:

    move.b #01,(Control_Locked).w


    iirc. Move_lock is for something completely different. (If you want it to lock controls and press something else, you'd need to run your code before sonic's move code, or else nothing will happen to hold your new buttons in place, PM me for more info.


    As for the palette line for certain objects, it's with the art tile, it's a question I asked a page or two back :)
     
  3. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    You know the Walk-Jump bug in Sonic 1? It actually plays havoc with more than just the jump - it could just as accurately be called the Walk-Drown bug. A while ago, I extended the SCHG How-to:Fix the Walk-Jump Bug in Sonic 1 to cover the drowning issue, too.

    However, I've noticed that it causes problems with the normal death animation (in Rev 00) and with the Spindash when you port it, as well. It would be nice to have a fix that doesn't involve just querying for each of these states.

    The How-to says this:

    Does anyone know specificically what these "little animation bugs" are? I've tested it after simply removing that one line, and nothing seems to be amiss.

    Are there any examples of what actually goes awry when that line is removed?
     
  4. PsychoSk8r

    PsychoSk8r

    PsychedelAnt | Tone Turner Oldbie
    2,643
    57
    28
    Birmingham, UK
    30 Day Project: Revisited.A New Release!
    What format are the 16x16 tiles in Sonic 1 & Sonic 2?
    Trying to get S1's 16x16s to load in S2 as an experiment.
     
  5. GT Koopa

    GT Koopa

    Member
    2,021
    18
    18
    Elgin, IL
    Flicky Turncoat DX, T.L.W.S. Vs M.G.W.
    I have a music ethics question that has been bothering me, so much that I stopped doing my original music idea.


    The original idea for the music in my hack was to be like Sonic rush, and sample hit old songs. However, I want to know if it is right or not to use FREE midis people made on FREE midi sites to check how the notes go. If not I will just go another direction, which is the safer "rip the best songs from genesis and SNES games."

    My friend said it was fine, however it is important to know how YOU guys feel about it. I just can't tell.
     
  6. Namo

    Namo

    take a screenshot of your heart Member
    2,912
    0
    0
    Sampling is a legal practice. Lots of bands do it, such as Daft Punk and every rap group ever.

    However... I would like to see what it would sound like if you sampled SNES and Genesis music and mixed them Sonic Rush style.
     
  7. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    The flag sorta works. It does the correct motion and keeps the player from changing it, however it also disables other sequences that use the flag (eg. the Wing Fortress cutscene which you now have to create 'manually'). Also the flag only seems to clear when on the floor, similar to the jump dash flag, meaning if you swirve off a ledge it keeps falling in that direction with no control until you land. Here's how I implemented it if that helps:

    Code (ASM):
    1. Sonic_Hammer:
    2.         cmp.b   #$23,anim(a0)
    3.         bne.s   lol7
    4.         move.b  #01,(Control_Locked).w
    5.         move.w  $14(a0),d0
    6.         move.w  d0,d1
    7.         asr.w   #3,d1
    8.         sub.w   d1,d0
    9.         move.w  d0,$14(a0)
    10.         rts
    11. lol7:
    12.         btst    #1,(Ctrl_1_Held_Logical).w  ; is Down button pressed?  
    13.         bne.s   JmpTo_SonicHammerreturn ; if yes, return
    14.         btst    #6,(Ctrl_1_Press_Logical).w ; is A button pressed?
    15.         beq lol         ; if not branch
    16.         move.b  #$23,anim(a0)       ; show hammer animation
    17.         jmp Hammer_Cont
    18.  
    19. JmpTo_SonicHammerreturn:
    20.         jmp Sonic_Hammer_return
    21.  
    22. Hammer_Cont:
    23.         move.w  $14(a0),d0
    24.         btst    #0,$22(a0)
    25.         beq lol8
    26.         neg.w   d0
    27. lol8:
    28.         cmp.w   #$400,d0
    29.         bgt lol
    30.         move.w  #$400,d0
    31.         btst    #0,$22(a0)
    32.         beq lol9
    33.         neg.w   d0
    34. lol9:      
    35.         move.w  d0,$14(a0)
    36. lol:
    37.         move.w  $10(a0),d0
    38.         tst.w   d0
    39.         bpl label
    40.         neg.w   d0
    41. label:
    42.         cmpi.w  #$600,d0
    43.         bgt Sonic_Hammer_Return
    44.         btst    #6,(Ctrl_1_Press_Logical).w ; is A button pressed? 
    45.         beq.b   Sonic_Hammer_return ; if not, return
    46.         move.b  #$23,anim(a0)       ; show animation $20
    47.         move.w  #$3D+$80,d0             ; play sound
    48.         jsr (PlaySound).l
    49.  
    50.  
    51. Sonic_Hammer_return:
    52.         clr.w   (Control_Locked).w 
    53.         rts
    54. ; End of function Sonic_Hammer 
    *Hmm, not quite sure how this pallette thing works even after looking at the recent discussion. Is it a Hex editor thing?

    *Oh some other things that have perked up if anyone knows, I've tried implementing the spring motion so it activates when you are next to it without jumping on top of it (like in Advance for Amy), I managed to get it to run only with the necessary animation, however I hear the spring activate and then the game freezes, anyone know what I've done wrong here?:

    Code (ASM):
    1. loc_18980:
    2.     move.w  #$1B,d1
    3.     move.w  #8,d2
    4.     move.w  #$10,d3
    5.     move.w  x_pos(a0),d4
    6.     lea (MainCharacter).w,a1 ; a1=character
    7.     moveq   #3,d6
    8.     movem.l d1-d4,-(sp)
    9.     bsr.w   loc_1978E
    10.     btst    #3,status(a0)
    11.     beq.s   Obj41_Hammer
    12.     bsr.s   loc_189CA
    13. Obj41_Hammer:
    14.     tst.b   $25(a0)     ; is Sonic on top of the spring?
    15.     bne.s   loc_189CA   ; if yes, branch
    16.     cmpi.b  #$23,(MainCharacter+anim).w ; is hammer attack being performed?
    17.     bne.s   loc_189A8       ; if not, branch
    18.     moveq   #0,d0           ; clear d0
    19.     move.w  $8(a0),d0       ; load block's X-pos to d0
    20.     sub.w   (MainCharacter+$8).w,d0 ; substract Amy's X-pos from it
    21.     bpl.s   Obj41_XPositive     ; if answer is positive, branch
    22.     neg.w   d0          ; otherwise negate d0
    23.  
    24. Obj41_XPositive:
    25.     cmpi.w  #45,d0          ; is Amy within 45 pixels of the spring (X-axis)?
    26.     bge.s   loc_189A8   ; if not, branch
    27.     moveq   #0,d0           ; clear d0
    28.     move.w  $C(a0),d0       ; load springs's Y-pos to d0
    29.     sub.w   (MainCharacter+$C).w,d0 ; substract Amy's Y-pos from it
    30.     bpl.s   Obj41_YPositive     ; if answer is positive, branch
    31.     neg.w   d0          ; otherwise negate d0
    32.  
    33. Obj41_YPositive:
    34.     cmpi.w  #45,d0          ; is Amy within 45 pixels of the spring (Y-axis)?
    35.     bge.s   loc_189A8   ; if not, branch
    36.     bra.s   loc_189CA       ; otherwise make spring bouncing
    37.     rts
    38.  
    39. loc_189A8:
    40.     movem.l (sp)+,d1-d4
    41.     lea (Sidekick).w,a1 ; a1=character
    42.     moveq   #4,d6
    43.     bsr.w   loc_1978E
    44.     btst    #4,status(a0)
    45.     beq.s   loc_189C0
    46.     bsr.s   loc_189CA
    47.  
    48. loc_189C0:
    49.     lea (off_18FE2).l,a1
    50.     bra.w   AnimateSprite
    51.     rts
    52.  
    53. ; ===========================================================================
    54.  
    55. loc_189CA:
    56.     move.w  #$100,anim(a0)
    57.     addq.w  #8,y_pos(a1)
    58.                 ...
    * Oh and some of 1P's new sprites are overlapping onto Tails' (eg. tiles of 1p appearing on Tails when large sprites are used). Is there anyway to expand one of the characters' memory so they aren't merging into each other?
     
  8. GT Koopa

    GT Koopa

    Member
    2,021
    18
    18
    Elgin, IL
    Flicky Turncoat DX, T.L.W.S. Vs M.G.W.
  9. theocas

    theocas

    Tech Member
    346
    0
    16
    I have a port of different art into LZ, and I want a different layout. The issue is that the old doors that slide to the left and right that are activated by a button are still there. How would I get rid of them for Act 1 only, or move them?
     
  10. Jimmy Hedgehog

    Jimmy Hedgehog

    Member
    1,728
    8
    18
    England - Slough
    Getting the motivation to continue old projects
    Random question...was messing around with object and such, and now Sonic shoots a fireball (the ones in MZ) by pressing A, and I've made it not hurt sonic upon launching it...how would I go about making the fireball able to hit monitors and badniks?
     
  11. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    You need to make checks in TouchResponse for an object other than Sonic (in this case, the fireball) and call that routine from the fireball object, also set it so it only gets called after sonic launched it (setting a flag could help).

    There aren't many checks you have to do for the fireball though, there's an area which checks collision with rings which has to be changed to only apply to sonic. Also, porting status_secondary from sonic 2 helps a lot too. Call touchresponse and make the fireball invincible.
     
  12. Jimmy Hedgehog

    Jimmy Hedgehog

    Member
    1,728
    8
    18
    England - Slough
    Getting the motivation to continue old projects
    Well I decided to give things a go and by simply adding a jsr TouchResponse to the end of Obj14_Action, it destroys badniks and monitors...sometimes. Not sure how to explain it...just sometimes it does, sometimes it doesn't. I asked Psy and he said it might be something about the fireball's X & Y positions...but I can't find any checks for it. Any ideas what I should look for?
     
  13. Selbi

    Selbi

    The Euphonic Mess Member
    1,501
    52
    28
    Northern Germany
    Sonic ERaZor
    Code (ASM):
    1.         move    #$2700,sr
    Another line I see quite often, without knowing what it does. I'd also like to know why it doesn't need anything like .b, .w or .l.
     
  14. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    IIRC it stops hblank and vblank, or starts vblank.
    Not sure...
     
  15. Selbi

    Selbi

    The Euphonic Mess Member
    1,501
    52
    28
    Northern Germany
    Sonic ERaZor
    If that's so, could someone tell me what hblanking and vblanking is?
     
  16. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    Im not really sure, but I know markeyjester explained me something about hblank. Its used for loading different palettes for the 2nd half of the screen (like water). Ie, updating the horizontal pieces of the screen per frame.

    Vblank is actually loc_b10 in the june 2005 disassembly. Im not sure what it does though.
     
  17. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    Code (ASM):
    1.     move.w  #$2700, sr
    That disables all IRQs, which includes the VBlank and HBlank interrupts.

    VBlank indicates when the frame has just finished being shown on screen (all graphics should be updated in this period when possible), while HBlank kicks in right after a scanline on screen ends (which is used to do mid-screen changes, aka raster effects).

    Er, that's really dirty and inaccurate, but I don't feel like explaining how the video hardware works =P The following code should reenable the interrupts, in case you're curious:

    Code (ASM):
    1.     move.w  #$2000, sr
     
  18. nineko

    nineko

    I am the Holy Cat Tech Member
    6,316
    489
    63
    italy
    I'll complement what Sik said.
    Selbi, read this: http://en.wikipedia.org/wiki/Cathode_ray_tube. It explains how a CRT works. I'll try to make this as simple as I can.
    Basically there is an electron beam that goes from left to right, doing one row per time. The time the electron gun takes to go back from right to left once a row is complete, is used as Hblank on the Genesis. The time the electron gun takes to go back from the bottom right corner to the upper left corner, is used as Vblank on the Genesis.
     
  19. ColinC10

    ColinC10

    Tech Member
    Hi E-122-Psi, I'll have a shot at answering this. The game is freezing because you put data onto the stack without taking it off again. The stack is used by the system to keep track of important things like where to go back to after an rts, and if you don't move data to and from it properly things go wrong very quickly! Here's what happens in the spring object:

    First, we put a bunch of data into d1, d2, d3 and d4. These will be used in the solidity routine, loc_1978E.
    Next, we copy these variables to the stack using this line:
    Code (ASM):
    1. movem.l d1-d4,-(sp)
    This is to keep them safe because we'll need them later.
    Now we run loc_1978E for Sonic, which messes around with d1-d4. Luckily we kept a copy.
    We now check to see if Sonic was standing on the spring, and do the bounce routine if he was (loc_189CA).
    Now, in the real game, we'd continue from loc_189A8. The first line is
    Code (ASM):
    1. movem.l (sp)+,d1-d4
    This takes our data back off the stack again. It's now as it was before we started messing around with it, so the system finds its data where it expected it and everybody's happy.
    We now run the solidity routine again, this time for Tails.

    In your code it's possible to bypass the line that takes the data back off the stack. This can happen in two places: the branches to loc_189CA that you've added.

    It's easy to fix the second one by changing this:

    Code (ASM):
    1. Obj41_YPositive:
    2.     cmpi.w  #45,d0          ; is Amy within 45 pixels of the spring (Y-axis)?
    3.     bge.s   loc_189A8   ; if not, branch
    4.     bra.s   loc_189CA       ; otherwise make spring bouncing
    5.     rts
    6.  
    7. loc_189A8:
    8.     movem.l (sp)+,d1-d4
    to this:

    Code (ASM):
    1. Obj41_YPositive:
    2.     cmpi.w  #45,d0          ; is Amy within 45 pixels of the spring (Y-axis)?
    3.     bge.s   loc_189A8   ; if not, branch
    4.     bsr.s   loc_189CA       ; otherwise make spring bouncing
    5.  
    6. loc_189A8:
    7.     movem.l (sp)+,d1-d4 ;This line can now be reached.
    However, I'm slightly confused by the first one:
    Code (ASM):
    1. Obj41_Hammer:
    2.     tst.b   $25(a0)     ; is Sonic on top of the spring?
    3.     bne.s   loc_189CA   ; if yes, branch
    We've already checked to see if Sonic is standing on the spring by testing bit 3 of the spring's status (set in the solidity routine). The method you're using is the Sonic 1 version, which is now obsolete. I'm going to take a guess that you've copy/pasted this section of code from a Sonic 1 object. If that's the case, then just delete these two lines - job done. :)
     
  20. FeliciaVal

    FeliciaVal

    Member
    693
    11
    18
    Spain
    I heard that if you try to fix the Walk-Jump in Sonic 1 with the Hivebran dissasembly and if you have ported the spindash using the tutorial, it might give some problems to it and won't work correctly. Can someone confirm me if this is true? I'd like very much to fix the walk-jump bug on my hack but since I have the spindash I'm not sure if it's going to mess it with it or not. Thx in advance!