How to convert Sonic 1 Level Select to ASCII

Discussion in 'Engineering & Reverse Engineering' started by SoullessSentinel, Jul 14, 2013.

  1. SoullessSentinel


    Grimsby, England
    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.

    I am aware that many seasoned hackers will have no use for this, as it is an extremely simple edit, but I think it will help some newbie hackers.

    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 (Text):
    2. LevelMenuText:  if Revision=0
    3.         incbin  "misc\Level Select Text.bin"
    4.         else
    5.         incbin  "misc\Level Select Text (JP1).bin"
    6.         endc
    7.         even

    With this (Pastebin link)

    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 (Text):
    2.     LevSel_CharOk:
    4.                     add.w   d3,d0       ; combine char with VRAM setting
    5.                     move.w  d0,(a6)     ; send to VRAM
    6.                     dbf     d2,LevSel_LineLoop
    7.                     rts
    With this
    Code (Text):
    3.     LevSel_CharOk:
    4.                     cmp.w   #$40, d0    ; Check for $40 (End of ASCII number area)
    5.                     blt.s       @notText    ; If this is not an ASCII text character, branch
    6.                     sub.w   #$3,d0      ; Subtract an extra 3 (Compensate for missing characters in the font)
    7.     @notText:
    8.                     sub.w   #$30,d0     ; Subtract #$33 (Convert to S2 font from ASCII)
    9.                     add.w   d3,d0       ; combine char with VRAM setting
    10.                     move.w  d0,(a6)     ; send to VRAM
    11.                     dbf     d2,LevSel_LineLoop
    12.                     rts
    Now to fix the Sound Test numbers, find LevSel_ChgSnd and change this line:
    Code (Text):
    1. addi.b      #7,d0       ; use alpha characters
    To this:
    Code (Text):
    1. addi.b      #4,d0       ; use alpha characters

    There is one more 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.

    EDIT: Gah, forgot to include the new palette.
    EDIT2: Pastebin link for the level select text, as the forum keeps fucking up the spacing.