Sonic and Sega Retro Message Board: Dynamic Credits Screen [Tutorial] - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked Forum

Dynamic Credits Screen [Tutorial] An easily editable Sonic 2 Credits screen!

#1 User is offline pacguy 

Posted 17 April 2018 - 01:54 AM

  • ASM amateur
  • Posts: 32
  • Joined: 27-July 14
  • Gender:Female
  • Location:Labyrinth Zone
  • Project:Sonic 2 CD Remix
I finally got around to centralizing all the main code for my credits screen, so that it's portable enough to release! It reads text from a raw .txt file, so editing it is easy; no more fiddling around with mappings or a spider web of macros required! The screen does all the work for you, so you can do what's important; credit the people who helped you along the way :3

Here's a demo rom that doubles as the credits for this very tutorial :v: The entire thing was built on top of Hitaxas' Splash Screen, which handles the screen clearing, background, and other stuff like that.

Keep in mind that this guide is only for the Sonic 2 GitHub Disassembly! It uses a lot of its' labels, constants, and macros, so converting it into something more universal seemed like it would be a pain. So for now, no other games/disassemblies are supported.

Implementing the main code

For starters, download this. It includes the main assets required for it to work. copy the contents of the zip file into your disassembly.

Next, copy the following into your disassembly. It could technically go anywhere, but I'd recommend putting it near the end of the rom, before the "end of 'ROM'" line.

    INCLUDE "CreditsScreen/CreditsScreen.asm"; Credits Screen Code

Now search for "s2.constants.asm". below that line, add this:

    include "CreditsScreen/constants.asm"

Next, search for "GameModesArray:". You should find this:

; loc_3A2:
GameModesArray: ;;
GameMode_SegaScreen:    bra.w    SegaScreen        ; SEGA screen mode
GameMode_TitleScreen:    bra.w    TitleScreen        ; Title screen mode
GameMode_Demo:        bra.w    Level            ; Demo mode
GameMode_Level:        bra.w    Level            ; Zone play mode
GameMode_SpecialStage:    bra.w    SpecialStage        ; Special stage play mode
GameMode_ContinueScreen:bra.w    ContinueScreen        ; Continue mode
GameMode_2PResults:    bra.w    TwoPlayerResults    ; 2P results mode
GameMode_2PLevelSelect:    bra.w    LevelSelectMenu2P    ; 2P level select mode
GameMode_EndingSequence:bra.w    JmpTo_EndingSequence    ; End sequence mode
GameMode_OptionsMenu:    bra.w    OptionsMenu        ; Options mode
GameMode_LevelSelect:    bra.w    LevelSelectMenu        ; Level select mode

Add the following line to the end of it:

GameMode_CustomCredits:    bra.w    CustomCredits

Then scroll down to "LevelSelectMenu:". Copy this code after all the "=" characters, but before the ">" characters:

    jmp    CreditScreen_Init

Now we need to add the new text object to the main object pointers list. Search for "ObjPtr_RingPrize:". You should find this:

ObjPtr_RingPrize:    dc.l ObjDC    ; Ring prize from Casino Night Zone

After that, insert this line:

ObjPtr_TextChar:        dc.l ObjTextChar    ; Credits Text

And with that, the Credits screen is now technically installed. Of course, there's no way to access it, though...


As it currently stands, the old, hardcoded credits screen still runs after you beat the game! Lets' fix that:

Search for "EndgameCredits:". A ways below that should be this code:

 ; Bug: The '+4' shouldn't be here; clearRAM accidentally clears an additional 4 bytes
 clearRAM Horiz_Scroll_Buf,Horiz_Scroll_Buf_End+4

below that, paste this:

st (Level_Inactive_flag).w
   move.b    #GameModeID_CreditsCustom,(Game_Mode).w ; => CustomCredits

And that's it! The credits now appear at the end of the game!


Now, you can see the credits screen; but what's the point in crediting people if very few players will make it to the end? Heck, maybe your making a demo, or removing Death Egg Zone and the end cutscene entirely! How will people see the credits then? Fear no more, for this section will add the credits to the title screen!

First, download this file and replace the old one in "mappings/sprite". Then, download this file and replace the old one in "art/nemesis". These new graphics will be used for the credits title screen menu.

Now we need to edit the menu object itself. Search of "Obj0f:". Then find this line below it:

move.w    #make_art_tile(ArtTile_ArtKos_LevelArt,0,0),art_tile(a0)

Replace that line with this:

    move.w    #make_art_tile(ArtTile_ArtNem_Player1VS2,0,0),art_tile(a0)    ;changed to make mappings edits easier

Now that the graphics are fixed, we need to change some values to add our new option. Go down a bit further, and find this line:

    move.b    #2,d2

Change the 2 to a 3. Then find this line:

    cmpi.b    #3,d2

And replace the 3 with a 4.

Finally, search for "TitleScreen_ChoseOptions:". Add this code just under the label:

 subq.b #1,d0
 bne.s TitleScreen_Option4

And add this code before all the "=" signs:

;Pacguys' custom credits screen
    move.b    #GameModeID_CreditsCustom,(Game_Mode).w ; => Custom Credits screen
    move.b    #0,(Options_menu_box).w

And that's it! Editing the credits is extremely easy; just open up Credits.txt and start typing! There are some tips at the end of the file, to help you figure out some of the quirks of the Credits screen (I highly recommend reading them).

Of course, I can tell some of you aren't gonna be satisfied with just that, so here's some optional things you can do:

Use your favorite mappings editor to load CreditsScreen/Alphabet.asm and art/nemesis/Credit Text.bin . This will give you the ability to change the art used by the Character object. Each mapping frame corresponds to a character in the Microsoft ANSI character set; if you want to add more characters, number, lowercase letters, etc., just find the appropriate mapping frame (the hex numbers on the Wikipedia page correspond to the mapping frame), and add some new font art in.

Maybe your unsatisfied with the control characters I used. Maybe your name has a dollar sign in it; or maybe you like to end every post with a ~. Whatever the case, this can be easily fixed. Open CreditsScreen.asm and search for "CustomCredits_readChars:". You should see the following:
;this section finds control characters, and responds accordingly
;If you want to make your own control character, just add a check here!
    cmp.b    #$A,d2    ;is d2 a carriage return character (an actual ANSI control character for the end of a line)?
    beq.s    CustomCredits_readChars_endloop    ;if so, end loop
    cmp.b    #$24,d2    ;is d2 a '$' (control code defined by PACGUY)?
    beq.s    CustomCredits_readChars_setcolorflag    ;if so, set color flag and adjust header text
    cmp.b    #$7E,d2    ;is d2 a '~' (control code defined by PACGUY)?
    beq.s    CustomCredits_endoffile    ;if so, set as end of file (prevents further text reading)

    bsr.s    Hitaxas_splash_spawn_credits_object    ;otherwise, spawn a character/letter/symbol object
    bra.s    CustomCredits_readChars    ;continue looping inside character read loop

These are where control characters are defined. The first one should never be touched; it's for an actual ANSI control character, which determines where the end of a line is. The others, however, can be freely changed; the hex values correspond to Microsoft ANSI characters, so you can replace them with what you like. You could even add your own custom control characters like so:
    cmp.b    #$7,d2    ;is d2 a 'bel' character?
    beq.s    CustomCredits_readChars_playRingSound    ;if so, run a routine that makes a ring sound :3

As you've probably seen by my videos, the credits screen in Sonic 2 CD Remix spawns the players, and lets them run amuck while the credits are going. It might not look quite as professional, but its' fun! The code for this was intentionally left in, but some things still need to be changed for it to work. Open up CreditsScreen.asm and find this line:
    ;comment out this line if you want Sonic and/or Tails to spawn!
    bra.s    CustomCredits_skipplayers

It should be self explanatory. Now, that'll spawn the players, and some walls and a floor. However, there will be some odd issues. To fix them, open up s2.asm and search for "RunObjects:". You should see this:
    cmpi.b    #GameModeID_Demo,(Game_Mode).w    ; demo mode?
    beq.s    +    ; if in a level in a demo, branch

Below that, insert this:
    cmpi.b    #GameModeID_CreditsCustom,(Game_Mode).w    ; are we in Credits mode?
    beq.s    +    ; if in PACGUYs' custom credits mode, branch

This will fix issues with Tails' Tails and the Skidding/Spindash dust.

Yes! You can go all out and make your own mini game out of the credits! This will assume you've already setup Sonic and Tails to spawn (hint hint, it's the spoiler above this one)! To start, crack open CreditsScreen.asm and find "ObjTextChar_Init:" Below that, add this:
    move.b    #$47,collision_flags(a0)

That line allows Sonic and Tails to collide with the letters! On it's own, however, that'll make it so that touching a letter crashes the game :psyduck:

But don't worry! It's an easy fix! Go to "ObjTextChar_Index:". You should see this:
    dc.w    ObjTextChar_Init-ObjTextChar_Index        ;0
    dc.w    ObjTextChar_Main-ObjTextChar_Index        ;2

Below that, add this:
    dc.w    ObjTextChar_Collide-ObjTextChar_Index        ;4

Now, make a new routine called "ObjTextChar_Collide". Here's an example:

    jmp    DeleteObject

This will make the letters disappear when you touch them! You can do anything in this routine; play sounds, change the colors, hurt Sonic and/or Tails, instakill them, move the letters, etc. The possibilities are endless!

EDIT: Fixed some dead links, and cleaned up some minor grammer/formatting issues
This post has been edited by pacguy: 03 August 2018 - 06:34 PM

#2 User is offline Hitaxas 

Posted 06 August 2018 - 11:07 PM

  • Retro 80's themed Paladins Twich streamer
  • Posts: 1438
  • Joined: 30-September 07
  • Gender:Male
  • Location:Litchfield,CT
  • Project:Becoming a Twitch partner, and getting my life back together
  • Wiki edits:196
Oh my! I just swung around for the first time in forever to see what has been going on around here, only to see this?! I am honored and intrigued. I haven't dabbled in anything like this in a while and to see that my work inspired you to create this is awesome my friend. I am on mobile right now so I only took a brief look at the code, but I think this makes for a credits sequence that is far eaiser to edit and maintain. It's also got my head going about how to pull off some other fancy stuff that could be based on this. I might just have to mess with this sometime and see what I can do. Mad props, nice work.

Edit: I checked it out properly and got annoyed by a few lines under

Instead of using multiple add.w lines to space letters correctly like this:
	add.w		d3,d3	;multiply d3 by 2
	add.w		d3,d3	;multiply d3 by 2 again
	add.w		d3,d3	;multiply d3 by 2 again
	add.w		d3,d3	;multiply d3 by 2 again	(it needs to be big enough to bridge the gaps between chars)

You can achieve the same effect using one line:
        mulu.w    #$0010,d3	; multiply d3 enough to space letters correctly

Also just a thought, but maybe a feature could be implemented to check for specific lines in the text file? This could be utilized to do some flashy stuff, for example, if a certain line of text is at center screen when scrolling, have that line start off-screen left and scroll in ( would make for a cool header effect)
This post has been edited by Hitaxas: 07 August 2018 - 02:17 PM

#3 User is offline pacguy 

Posted 07 August 2018 - 02:20 PM

  • ASM amateur
  • Posts: 32
  • Joined: 27-July 14
  • Gender:Female
  • Location:Labyrinth Zone
  • Project:Sonic 2 CD Remix
I'm glad you liked it! The code was made to be fiddled with, so feel free to go nuts! Apologies for the unoptimized code, I initially wasn't planning on making something for release, so things like that ended up slipping in.

#4 User is offline Ralakimus 

Posted 07 August 2018 - 03:22 PM

  • Posts: 292
  • Joined: 16-April 13
  • Gender:Male
On the topic of optimization, it would be even better would be to just do

lsl.w #4,d3

Each bit shifted left is a multiplication of 2 (right being division by 2), and using LSL for something like this is pretty much faster than using MULU/MULS, and in this case, it's also still a single line.
This post has been edited by Ralakimus: 07 August 2018 - 03:24 PM

Page 1 of 1
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users