don't click here

Sonic 2 Nick Arcade disassembly

Discussion in 'Engineering & Reverse Engineering' started by drx, Dec 3, 2006.

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

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
  2. Lath

    Lath

    Member
    118
    0
    0
    Nice going DRX, let's see who the first to port over the wall crashing thing to S2 final XD

    Oh, pin please.
     
  3. Hivebrain

    Hivebrain

    Administrator
    3,065
    202
    43
    53.4N, 1.5W
    Github
    Nice work! I'll have a good look at this tomorrow.

    If you mean labels, I'm changing a lot of them for the next S1 disassembly.
     
  4. Rika Chou

    Rika Chou

    Tech Member
    5,276
    169
    43
    Awesome, I will be looking though this later for sure. Thanks drx!
     
  5. Dracula

    Dracula

    Oldbie
    605
    0
    16
    I'm watching you!
    Converting NES Mappers to MMC5
    Nice work! How did you dig this up so fast? =P
     
  6. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    Nice. Very interesting!

    Code from ROM: (Vertical Blank code...)

    Code (Text):
    1.         move.l  #$C0000000,4(a1)
    2.         move.l  (a0)+,(a1)
    3.         move.l  (a0)+,(a1)
    4.         move.l  (a0)+,(a1)
    5.         move.l  (a0)+,(a1)
    6.         move.l  (a0)+,(a1)
    7.         move.l  (a0)+,(a1)
    8.         move.l  (a0)+,(a1)
    9.         move.l  (a0)+,(a1)
    10.         move.l  (a0)+,(a1)
    11.         move.l  (a0)+,(a1)
    12.         move.l  (a0)+,(a1)
    13.         move.l  (a0)+,(a1)
    14.         move.l  (a0)+,(a1)
    15.         move.l  (a0)+,(a1)
    16.         move.l  (a0)+,(a1)
    17.         move.l  (a0)+,(a1)
    18.         move.l  (a0)+,(a1)
    19.         move.l  (a0)+,(a1)
    20.         move.l  (a0)+,(a1)
    21.         move.l  (a0)+,(a1)
    22.         move.l  (a0)+,(a1)
    23.         move.l  (a0)+,(a1)
    24.         move.l  (a0)+,(a1)
    25.         move.l  (a0)+,(a1)
    26.         move.l  (a0)+,(a1)
    27.         move.l  (a0)+,(a1)
    28.         move.l  (a0)+,(a1)
    29.         move.l  (a0)+,(a1)
    30.         move.l  (a0)+,(a1)
    31.         move.l  (a0)+,(a1)
    32.         move.l  (a0)+,(a1)
    33.         move.l  (a0)+,(a1)
    Yuji Naka isn't the organized programmer I tough he was. =P
     
  7. StephenUK

    StephenUK

    Liquor in the front, poker in the rear Tech Member
    1,678
    0
    16
    Manchester, UK
    Quackshot Disassembly
    Actually, that's done quite a few times in the S2 Final disassembly and is quicker to execute than looping over the same line X amount of times.
     
  8. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    I agree it's quicker, but the difference between a "dbra" loop and a lot of lines with the same instruction is desprezive, right?
     
  9. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    The whole wall crashing thingy is the Sonic_WallRecoil subroutine. And of course, you need to port the animation, frame and graphics.
     
  10. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    Using my ninja context-fu I am predicting the content of this post, since "desprezive" did not translate.

    "I agree it's quicker, but isn't a dbra loop quicker?"

    The answer is no, a dbra loop is a lot slower in terms of processor cycles than just doing the same thing over and over the requisite number of times.
     
  11. Weird Person

    Weird Person

    You lost two seconds reading this Member
    367
    0
    0
    Who knows?
    Fixed.

    By the way, I hate you Quickman.
     
  12. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    Let me review the case:

    Using so many move.l:

    Each instruction takes 20 CPU cycles (3 read cycles, 2 write cycle). * 32 = 640 CPU cycles (96 read cycles and 64 write cycles).

    Now using dbra, the code would have to look like this:

    Code (Text):
    1.     move.w  #31,d1
    2. loop:
    3.     move.l  (a0)+,(a1)
    4.     dbra    d1,loop
    move.w #31,d1 - 8 cycles (2 read cycles, 0 write cycles)
    move.l (a0)+,(a1) - 640 cycles (96 read cycles and 64 write cycles), like above
    dbra d1,loop - 31 * branch taken timing - 310 cpu cycles (62 read cycles, 0 write cycles)
    branch not taken, counter expired - 14 cpu cycles, 3 read cycles, 0 write cycles.

    Let's sum it up:

    using dbra - 972 cpu cycles, 163 read cycles, 64 write cycles
    not using dbra - 640 CPU cycles, 96 read cycles and 64 write cycles.

    using dbra, you would waste 25% cpu cycles in total, and 70% read cycles. Remember, this is done during the VBlank - so the timing DOES count.

    Hope that clears the matter a little.
     
  13. Rika Chou

    Rika Chou

    Tech Member
    5,276
    169
    43
    What would you recommend as the best assembeler to use for this?
     
  14. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    I use snams68k 2.1d. I know it's not the best one, but it works for me.

    I hear others use AS, but I haven't used it, so I can't tell you if it's good or not.

    Also, if you're using snasm68k, use this:

    snasm68k.exe -emax 0 -p -o ae- s2a.asm, s2a.bin
     
  15. ICEknight

    ICEknight

    Researcher Researcher
    Hm? What's this?
    Or did you mean SYZ?
     
  16. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    Join the queue, please.
     
  17. drx

    drx

    mfw Researcher
    2,254
    350
    63
    :rolleyes:
    Ice: I've updated the .rars, please redownload. That was an awful mistake on my part - it happened because I was thinking of something and wrote something else instead.
     
  18. SMTP

    SMTP

    Tech Member
    Nice description for object 10:

    Code (Text):
    1. Object 10 - Tails eating the master emerald
    =P
     
  19. Rika Chou

    Rika Chou

    Tech Member
    5,276
    169
    43
    Ok, I will try sasm68k, cause I tried to use AS and it gave me a boatload of errors.
     
  20. Ambil

    Ambil

    I want that heinous hedgehog hammered! Member
    Excellent, drx. I bet this will uncover the mysteries we can't reach just by gameplay.

    A request for you, Hive. On your next release of the Sonic 1 disassembly, please name the splitted binary files so they can be directly replaced with the ones coming from a SonED2 hack. I use your disassembly for my hacking, and that would save the work of renaming files at every turn.

    Sig'd.
     
Thread Status:
Not open for further replies.