How to get lives through points - Hivebrain and GitHub

Discussion in 'Tutorials' started by DeltaWooloo, Feb 23, 2020.

  1. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    In Sonic 1 REV00 (the NA and Europe release), points were useless and nobody cared, except you and your mate, were trying to see who can get the highest score until the Final Zone. In the Japanese release in Sonic 1 (REV01), not just there were background differences but points were useful! Every 50000 points award you with a 1UP. This continued on with Sonic 2 and 3K. This tutorial will show you how you can get lives through points.

    HIVEBRAIN USERS

    First off, go to the beginning of the "sonic1.asm" file, aka this:

    Code:
    ; /=========================================================================\
    ; º    This file is generated by The Interactive Disassembler (IDA)        º
    ; º    Copyright (c) 2003 by DataRescue sa/nv,    <ida@datarescue.com>        º
    ; \=========================================================================/
    ;
    ; Disassembly created by Hivebrain
    ; thanks to drx and Stealth
    
    ; Processor:        68000
    ; Target Assembler: 680x0 Assembler in MRI compatible mode
    ; This file should be compiled with "as    -M"
    
    ; ===========================================================================
    align macro
        cnop 0,\1
        endm
     
    StartOfRom:
    Right before:
    Code:
    StartOfRom:
    Insert this:
    Code:
    Next_Extra_life_score =        $FFFFFFC0
    This is the RAM for getting lives through points that were used in Sonic 2. This RAM is unused in Sonic 1. If you want to use any unused RAM, by all means, go for it.

    Go to PlayLevel and insert this piece of code:
    Code:
            move.l    #$1388,(Next_Extra_life_score).w ; extra life is awarded at 50000 points
    under this:
    Code:
            move.b    d0,($FFFFFE18).w ; clear continues
    Do the same to Level_Demo and LevSel_Level_SS and insert the code before the rts.

    Next, we have to go to "AddPoints". From there replace everything inside of it:
    Code:
    ; ---------------------------------------------------------------------------
    ; Add points subroutine
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    AddPoints:
            move.b    #1,($FFFFFE1F).w ; set score counter to    update
            lea    ($FFFFFFC0).w,a2
            lea    ($FFFFFE26).w,a3
            add.l    d0,(a3)        ; add d0*10 to the score
            move.l    #999999,d1
            cmp.l    (a3),d1        ; is #999999 higher than the score?
            bhi.w    loc_1C6AC    ; if yes, branch
            move.l    d1,(a3)        ; reset    score to #999999
            move.l    d1,(a2)
    
    loc_1C6AC:
            move.l    (a3),d0
            cmp.l    (a2),d0
            bcs.w    locret_1C6B6
            move.l    d0,(a2)
    
    locret_1C6B6:
            rts
    ; End of function AddPoints
    with this:

    Code:
    ; ---------------------------------------------------------------------------
    ; Add points subroutine
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    AddPoints:                      ; ...
            move.b    #1,($FFFFFE1F).w
            lea    ($FFFFFE26).w,a3
            add.l    d0,(a3)
            move.l    #999999,d1
            cmp.l    (a3),d1
            bhi.s    loc_1C6AC
            move.l    d1,(a3)
    
    loc_1C6AC:                      ; ...
            move.l    (a3),d0
            cmp.l    (Next_Extra_life_score).w,d0
            blo.s    locret_1C6B6
            add.l    #$1388,(Next_Extra_life_score).w
            jmp        ExtraLife
    
    locret_1C6B6:
        rts
    ; End of function AddPoints
    This makes sure when you gain 50000 points, it jumps to "ExtraLife" and gives you the life.

    All sorted for Hivebrain users.

    GITHUB USERS;

    Let's go to the start of the "sonic.asm" file:

    Code:
    ;  =========================================================================
    ; |           Sonic the Hedgehog Disassembly for Sega Mega Drive            |
    ;  =========================================================================
    ;
    ; Disassembly created by Hivebrain
    ; thanks to drx, Stealth and Esrael L.G. Neto
    
    ; ===========================================================================
    
        include    "Constants.asm"
        include    "Variables.asm"
        include    "Macros.asm"
    
    EnableSRAM:    equ 0    ; change to 1 to enable SRAM
    BackupSRAM:    equ 1
    AddressSRAM:    equ 3    ; 0 = odd+even; 2 = even only; 3 = odd only
    
    ; Change to 0 to build the original version of the game, dubbed REV00
    ; Change to 1 to build the later vesion, dubbed REV01, which includes various bugfixes and enhancements
    ; Change to 2 to build the version from Sonic Mega Collection, dubbed REVXB, which fixes the infamous "spike bug"
    Revision:    equ 0
    
    ZoneCount:    equ 6    ; discrete zones are: GHZ, MZ, SYZ, LZ, SLZ, and SBZ
    
    OptimiseSound:    equ 0    ; change to 1 to optimise sound queuing
    
    ; ===========================================================================
    
    StartOfRom:
    I don't want to say much but to look at this:
    Code:
    ; Change to 0 to build the original version of the game, dubbed REV00
    ; Change to 1 to build the later version, dubbed REV01, which includes various bugfixes and enhancements
    ; Change to 2 to build the version from Sonic Mega Collection, dubbed REVXB, which fixes the infamous "spike bug"
    Revision:    equ 0
    I already mentioned the fact that REV01 and later gives you the new points system, so let the asm do the talking for you.


    Anyways, that's done. If you have any questions, feel free to ask.

    EDIT: Mega fixed it
     
    Last edited: Oct 27, 2021
  2. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    Slight criticism: You tell people to create an equate for Next_Extra_life_score, but then in code you only reference $FFFFFFC0... It doesn't seem to make any sense. Why create an equate that will never be used? Also I believe you missed a piece of code that initializes that RAM address with a value, too?
     
  3. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    OK, I've had tested the equate out and it works as usual, but I'll try and sort out the RAM initialization ASAP. I have also edited the steps to use the equate.
     
  4. Kilo

    Kilo Foxy Fren Exiled

    Joined:
    Oct 9, 2017
    Messages:
    391
    Location:
    A warm and lovely place~
    Doesn't work, you'll get a life for the first bit of points you get, then it'll start counting up in 50000's. The fix is simple, however. Simply paste this where ever the score is cleared.
    Code:
            move.l    #$1388,($FFFFFFC0).w    ; Initialize score limit for 1-up (50000)
    Edit - Derp Sonic 1 interprets it from 5000 to 50000
     
    Last edited: Mar 1, 2020
    ProjectFM likes this.
  5. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    I did notice that I put that specific piece of code into the .asm but forgot to mention it. The guide should be fixed soon.
     
  6. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    The score in RAM is actually a tenth of what you see while you play, the rightmost zero in the HUD is basically a decoration to make the score feel more important.
     
  7. MightyArnold

    MightyArnold Newcomer Trialist

    Joined:
    Mar 6, 2020
    Messages:
    1
    Location:
    Brazil
    Well, I tried this revision change on my GitHub edit, but... It didn' change nothing. It still don't make a life reaching 50000 score.

    EDIT: Well, I realized that I was blind to not looking that applies only to the Japanese REV01, but I find how to apply this change for the USA and Europe too.

    Go to AddPoints: on the "Add points subrotine" (in the very end of the main Sonic.asm file), and you will find those lines:

    tst.b (v_megadrive).w
    bmi.s @noextralife ; branch if Mega Drive is Japanese

    Just comment or remove these lines.
    And voila, now you get life through points regardless of the region.
     
    Last edited: Apr 8, 2020