don't click here

I am completely lost and I need help

Discussion in 'Engineering & Reverse Engineering' started by Quickman, Jan 27, 2010.

Thread Status:
Not open for further replies.
  1. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    I'm trying to add a seventh emerald to Sonic 1. I've moved the ring object to $39 so the emeralds are from $3A to $40 rather than $3B to $40 (since the code relies on the emeralds being consecutive in the list of objects for the special stage). I've changed all the "do you have all the emeralds" checks to 7 instead of 6, I altered the mappings for special stage objects and changed the special stage layouts. I haven't changed the mappings for the emeralds on the results screen (so the seventh emerald is blank at this point) or the counters and mappings for the emeralds on the TRY AGAIN and ending screens.

    However, when I enter the special stage I'm met by completely stationary rings which act as blocks. This makes no sense, since I changed the code in Obj09_ChkObjects so the ring behaviour ought to occur for $39. I thought maybe there might be something to do with SS_AniWallsRings, but that code is completely impenetrable.

    At this point I feel like I'm completely lost and missing something stupidly obvious, so I'm hoping someone else can help.
     
  2. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    When I added the 7th emerald to my hack, I took a different approach. The original code, as you mentioned, actually relies on the emeralds to be consecutive, yes, but you can change this behaviour by changing the way d4 gets valorised.
    In short, since I didn't plan to use the 1-up object, I changed its behaviour to work as the 7th emerald. You can do the same if you don't plan to use the 1-up object. The advantage is that the 1-up object is naturally collectable so you don't have to do major modifications of the code.
    In short, something like this:
    Code (Text):
    1. Obj09_Chk1Up:
    2.         cmpi.b    #$28,d4    ; is the item an extra life? (NOW 7TH EMERALD)
    3.         bne.s    Obj09_ChkEmer
    4.         bsr.w    SS_RemoveCollectedItem
    5.         bne.s    Obj09_GetEmer2
    6.         move.b    #5,(a2)
    7.         move.l    a1,4(a2)
    8. Obj09_GetEmer2:
    9.         cmpi.b    #7,($FFFFFE57).w; do you have all the emeralds?
    10.         beq.s    Obj09_NoEmer; if yes, branch
    11.         move.b    #$6,d4    ; EMERALD NUMBER :o
    12.         moveq    #0,d0
    13.         move.b    ($FFFFFE57).w,d0
    14.         lea    ($FFFFFE58).w,a2
    15.         move.b    d4,(a2,d0.w)
    16.         addq.b    #1,($FFFFFE57).w; add 1 to number of emeralds
    17.         bra.s    Obj09_NoEmer
    18.  
    19. ;===========================================================================
    20.  
    21. Obj09_ChkEmer:
    22.         cmpi.b    #$3B,d4    ; is the item an emerald?
    23.         bcs.s    Obj09_ChkGhost
    24.         cmpi.b    #$40,d4
    25.         bhi.s    Obj09_ChkGhost
    26.         bsr.w    SS_RemoveCollectedItem
    27.         bne.s    Obj09_GetEmer
    28.         move.b    #5,(a2)
    29.         move.l    a1,4(a2)
    30.  
    31. Obj09_GetEmer:
    32.         cmpi.b    #7,($FFFFFE57).w; do you have all the emeralds?
    33.         beq.s    Obj09_NoEmer; if yes, branch
    34.         subi.b    #$3B,d4
    35.         moveq    #0,d0
    36.         move.b    ($FFFFFE57).w,d0
    37.         lea    ($FFFFFE58).w,a2
    38.         move.b    d4,(a2,d0.w)
    39.         addq.b    #1,($FFFFFE57).w; add 1 to number of emeralds
    40.  
    41. Obj09_NoEmer:
    42.         move.w    #$93,d0
    43.         jsr    (PlaySound_Special).l;    play emerald music
    44.         moveq    #0,d4
    45.         rts
    Emphasis on move.b #$6,d4 :)
     
  3. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    Maybe theres already an object in slot $39?

    EDIT:

    Code (ASM):
    1.  
    2. Obj09_GetEmer:
    3.         cmpi.b  #7,($FFFFFE57).w ; do you have all the emeralds?
    4.         beq.s   Obj09_NoEmer    ; if yes, branch
    5.         subi.b  #$3B,d4                   ; did you change this line to $3A?
    6.  
    Do it, it might work.
     
  4. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    Yes, it's the unused number 6 object (see picture below), but I assume that Quickman already changed that.
    [​IMG]

    edit:
    You obviously have no idea of what that line is supposed to do. Look at these instructions:
    Code (Text):
    1.         move.b    ($FFFFFE57).w,d0
    2.         lea    ($FFFFFE58).w,a2
    3.         move.b    d4,(a2,d0.w)
    So here's what happens.
    At the start of the routine, d4 contains the object number. Emeralds are from $3B to $40. So by subtracting $3B from d4 you obtain the emerald number (basically, the color) in a 0-5 range.
    move.b ($FFFFFE57).w,d0 puts the number of collected emeralds into d0
    lea ($FFFFFE58).w,a2 puts "$FFFE58" into address register a2.
    Then there is move.b d4,(a2,d0.w)
    Remember, d4 by now contains the number (or the "color") of the emerald you just collected (0 = blue, etc). The move.b puts that emerald number into $FFFE58 + d0
    Basically the ram is sorted like this in Sonic 1:
    FE57 = number of emeralds you collected
    FE58 = "color" of the first emerald you collected
    FE59 = "color" of the second emerald you collected
    FE5A = "color" of the third emerald you collected
    etc.

    This incidentally leads to the bug which allows you to collect 6 blue emeralds if you put FE57 = 6 and keep the following bytes at 0.
    By changing the line you wanted to change you would obtain no effect whatsoever other than referencing wrong emerald colors.
     
Thread Status:
Not open for further replies.