How To: Convert Sonic 1's Level Select to use ASCII

Discussion in 'Tutorials Archive' started by SoullessSentinel, Aug 28, 2013.

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

    SoullessSentinel Newcomer Member

    Joined:
    Aug 18, 2007
    Messages:
    10
    While working with Sonic 1, I got tired of having to edit the level select text in a Hex editor, when it's contents is just plain text in a non-standard encoding, I decided enough was enough, and set out to convert Sonic 1's level select to use standard ASCII text encoding. After a very small amount of work, I decided to compile it into a guide.

    This guide is for the SVN disassembly of Sonic 1. It should be VERY easy to port to other disassemblies as the code changes make no use of macros or equates.

    First, download this file (menutext.bin) and replace the existing file in the "artunc" folder. This is the Sonic 2's menu font uncompressed to work in Sonic 1. It's what I use in my hack, and it's what my code expects.

    Now open Sonic.asm and find the LevelMenuText label and replace this:


    Code:
    
    LevelMenuText:    if Revision=0
            incbin    "miscLevel Select Text.bin"
            else
            incbin    "miscLevel Select Text (JP1).bin"
            endc
            even
    
    With this:

    Code:
    
    LevelMenuText:   if Revision=0
        dc.b    "GREEN HILL ZONE  STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "LABYRINTH        STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "MARBLE ZONE      STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "STAR LIGHT ZONE  STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "SPRING YARD ZONE STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "SCRAP BRAIN ZONE STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "FINAL ZONE              "            
            dc.b    "SPECIAL STAGE           "          
            dc.b    "SOUND TEST              "              
            even
            else
            dc.b    "GREEN HILL ZONE  STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "MARBLE ZONE      STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "SPRING YARD ZONE STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "LABYRINTH        STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "STAR LIGHT ZONE  STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "SCRAP BRAIN ZONE STAGE 1"
            dc.b    "                 STAGE 2"
            dc.b    "                 STAGE 3"
            dc.b    "FINAL ZONE              "            
            dc.b    "SPECIAL STAGE           "          
            dc.b    "SOUND TEST              "        
            endc
    
    As you can see, this is much easier as you can just edit the text directly.

    Now we need to modify Sonic 1 to actually understand this text format, so scroll upwards to LevSel_CharOk: and replace this:


    Code:
    
    LevSel_CharOk:
            add.w    d3,d0        ; combine char with VRAM setting
            move.w    d0,(a6)        ; send to VRAM
            dbf        d2,LevSel_LineLoop
            rts    
    

    Code:
    
    LevSel_CharOk:
            cmp.w    #$40, d0    ; Check for $40 (End of ASCII number area)
            blt.s        @notText    ; If this is not an ASCII text character, branch
            sub.w    #$3,d0        ; Subtract an extra 3 (Compensate for missing characters in the font)
        @notText:
            sub.w    #$30,d0        ; Subtract #$33 (Convert to S2 font from ASCII)
            add.w    d3,d0        ; combine char with VRAM setting
            move.w    d0,(a6)        ; send to VRAM
            dbf        d2,LevSel_LineLoop
            rts   
    
    Now to fix the Sound Test numbers, find LevSel_ChgSnd and change this line:


    Code:
    
            addi.b #7,d0 ; use alpha characters
    
    To this:


    Code:
    
            addi.b #4,d0 ; use alpha characters
    
    The debug text and error message strings need the same fix, but this is a task left to the reader.

    There is one final problem, the Sonic 2 font requires a different colour palette than Sonic 1 uses, so take this file, and place it in the palette folder, overwriting the existing one.

    And you are done, build your rom and enjoy the easy to edit text.

     
     
  2. RocketRobz

    RocketRobz Coolest of TWL, and Sonic fan Member

    Joined:
    Aug 20, 2009
    Messages:
    80
    The Sound Test numbers are messed up!
     
  3. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Sometimes I wonder if I should just release the converter I wrote years ago when I worked on my hack, it allows to convert back and forth from the Sonic 1 charset to standard ASCII and vice-versa.
     
  4. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    293
    Location:
    Wolverhampton UK
    please do - sounds useful :)
     
    Last edited by a moderator: Aug 29, 2013
  5. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
  6. OrdosAlpha

    OrdosAlpha RIGHT! Naebody move! Root Admin

    Joined:
    Aug 5, 2007
    Messages:
    1,793
    Location:
    Glasgow, Scotland
    Had to delete a post made by Soulless pointing out how to fix the fucked up numbers, but his original post contains the deleted post's info. Post was deleted as it completely fucked up the board tables.
     
Thread Status:
Not open for further replies.