don't click here

Use Normal Items In Sonic 2's VS Mode

Discussion in 'Engineering & Reverse Engineering' started by E-122-Psi, Jul 19, 2020.

  1. E-122-Psi

    E-122-Psi

    Member
    2,536
    729
    93
    This tutorial was largely (as in almost completely) compromised of coding provided by Cinossu rather than me, though I thought it was worth uploading to add onto our VS expansion craze.

    This was largely done in the Xenowhirl edit, though the variations in GitHub shouldn't be too hard to find.

    To add the option in the menu, first go to word_917A and change the Two_Player_Items flag to 2FF instead of 1FF (meaning a flag of now 0 (random), 1 (teleport) and 2 (normal)).

    Code (Text):
    1. word_917A:
    2.     dc.w $2FF
    3.     dc.w Player_option    ; 1
    4.     dc.w $2FF    ; 2
    5.     dc.w Two_player_items    ; 3
    6.     dc.w $7FFF    ; 4
    7.     dc.w Sound_test_sound    ; 5
    Now go to off_92BA. Add 3 items instead of 2 in off_92EA and add your byte for the option.

    Code (Text):
    1. off_92BA:
    2.     dc.l byte_97CA
    3.     dc.w $4192
    4.     dc.w 3
    5.     dc.l byte_982C
    6.     dc.w $4592
    7.     dc.w 3
    8.     dc.l byte_985E
    9.     dc.w $4992
    10.     dc.w 3
    11. off_92D2:
    12.     dc.l byte_97DC
    13.     dc.l byte_97FC
    14.     dc.l byte_980C
    15. off_92DE:
    16.     dc.l byte_97EC
    17.     dc.l byte_97FC
    18.     dc.l byte_981C
    19. off_92EA:
    20.     dc.l byte_983E
    21.     dc.l byte_984E
    22.     dc.l byte_Fixed
    23. off_92F2:
    24.     dc.l byte_9870
    Now find the menu text for the options bytes and the one you've made, with the desired text.

    Code (Text):
    1.     ; options screen menu text
    2.  
    3. byte_97CA:    dc.b $10,"* PLAYER SELECT *"
    4. byte_97DC:    dc.b  $E,"SONIC AND MILES"
    5. byte_97EC:    dc.b  $E,"SONIC AND TAILS"
    6. byte_97FC:    dc.b  $E,"SONIC ALONE    "
    7. byte_980C:    dc.b  $E,"MILES ALONE    "
    8. byte_981C:    dc.b  $E,"TAILS ALONE    "
    9. byte_982C:    dc.b $10,"* VS MODE ITEMS *"
    10. byte_983E:    dc.b  $E,"ALL KINDS ITEMS"
    11. byte_984E:    dc.b  $E,"TELEPORT ONLY  "
    12. byte_Fixed:    dc.b  $E," NORMAL ITEMS  "
    13. byte_985E:    dc.b $10,"*  SOUND TEST   *"
    14. byte_9870:    dc.b  $E,"      0"
    15.         dc.b $10,"       "
    16.  
    [​IMG]

    Now you should have your new option available, but it won't do anything, just give you teleport monitors. To give it a unique function go to the monitor contents routine (Obj2E) and make a branch in loc_12868 or Obj2E_Init depending on disassembly:

    Code (Text):
    1. loc_12868:
    2.     addq.b    #2,routine(a0)
    3.     move.w    #$8680,art_tile(a0)
    4.     bsr.w    Adjust2PArtPointer
    5.     move.b    #$24,render_flags(a0)
    6.     move.b    #3,priority(a0)
    7.     move.b    #8,width_pixels(a0)
    8.     move.w    #-$300,y_vel(a0)
    9.     moveq    #0,d0
    10.     move.b    anim(a0),d0
    11.     tst.w    (Two_player_mode).w
    12.     beq.s    loc_128C6
    13.     cmp.w    #2,(Two_player_items).w    ; Is it fixed items?
    14.     beq.s    loc_128C6
    15.     move.w    (Timer_frames).w,d0
    16.     andi.w    #7,d0            ;7 means 8 different items
    17.     addq.w    #1,d0            ;add 1 to prevent getting static monitor
    18.     tst.w    (Two_player_items).w    ; Are monitors set to teleport only?
    19.     beq.s    loc_128AC
    20.     moveq    #8,d0            ;force contents to be teleport
    21.  
    22. loc_128AC:
    23.     cmpi.w    #8,d0            ;teleport?
    24.     bne.s    loc_128C2
    25.     move.b    (Update_HUD_timer).w,d1
    26.     add.b    (Update_HUD_timer_2P).w,d1
    27.     cmpi.b    #2,d1            ;is either player finished?
    28.     beq.s    loc_128C2
    29.     moveq    #7,d0            ;give invincibility instead
    30.  
    31. loc_128C2:
    32.  
    33.     move.b    d0,anim(a0)
    34.  
    35. loc_128C6:            ; Determine correct mappings offset.
    36. ......
    With your new second flag branched over all the two player data edits, your monitors should now work normally....well almost.

    [​IMG]

    Since two player by default displays a question mark, that is now loaded as the content when broken (which gives you nothing). You'll have to fix it the monitors to load their normal mappings in 2-player.

    Go to loc_126E2 or Obj26_Init depending on your disassembly, and now add a check for the new items flag to branch over the ? icon implement:

    Code (Text):
    1. loc_126E2:
    2.     move.b    #$46,collision_flags(a0)
    3.     move.b    subtype(a0),anim(a0)
    4.     tst.w    (Two_player_mode).w
    5.     beq.s    obj_26_sub_2
    6.     cmp.w    #2,(Two_player_items).w    ; Is it fixed items?
    7.     beq.s    obj_26_sub_2
    8.     move.b    #9,anim(a0)    ;show ? screen
    And hurrah, you should now have a fully functioning 'normal' item option mimicing one player layout. If to a fault, since this setup obviously means there are no Tails 1-up monitors, only Sonic ones according to normal Sonic and Tails mode.

    Now there are different ways of getting around this:

    1. Use Ralakimus' tutorial to make separate object edits for the 2P levels, and then editing them in a level editor to have an even balance of Sonic and Tails monitors.

    2. Edit the monitor layouts, to give a 1-up to the character regardless. Find the pointer list for the monitor contents (Obj2E again):

    Code (Text):
    1. ; ===========================================================================
    2. sonic_1up:
    3.     cmp.w    #2,(Two_player_items).w    ; Is it fixed items?
    4.     bne.s    sonic_1up_1P
    5.     cmpa.w    #MainCharacter,a1
    6.     bne.s    tails_1up
    7. sonic_1up_1P:
    8.     addq.w    #1,($FFFFFEF4).w
    9.     addq.b    #1,(Life_count).w
    10.     addq.b    #1,(Update_HUD_lives).w
    11.     move.w    #$98,d0
    12.     jmp    (PlayMusic).l    ; Play extra life music
    13. ; ===========================================================================
    14. tails_1up:
    15.     cmp.w    #2,(Two_player_items).w    ; Is it fixed items?
    16.     bne.s    tails_1up_1P
    17.     cmpa.w    #Sidekick,a1
    18.     bne.s    sonic_1up
    19. tails_1up_1P:
    20.     addq.w    #1,($FFFFFEF6).w
    21.     addq.b    #1,(Life_count_2P).w
    22.     addq.b    #1,(Update_HUD_lives_2P).w
    23.     move.w    #$98,d0
    24.     jmp    (PlayMusic).l    ; Play extra life music
    25. ; ===========================================================================
    And now the monitor should give a 1-up to whoever breaks it in Normal Items mode, regardless of icon. Of course the monitor will still display Sonic's icon regardless, so you may want to edit the sprite art to have something more ambiguous.
     
    Last edited: Jul 19, 2020