Sonic and Sega Retro Message Board: How to extend S2's Level Select menu - Sonic and Sega Retro Message Board

Jump to content

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

How to extend S2's Level Select menu

#1 User is offline Clownacy 

  Posted 21 January 2014 - 03:11 PM

  • Needs to make an avatar
  • Posts: 309
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
As you may have seen with S3K or ColinC10's Sonic 1 and 2, the S2 Level Select can become really cramped, really fast. Wouldn't it be great if you could somehow extend the menu? To do this, several changes will have to be made to the Level Select's code. This does not require a total rewrite, so your own hacks can coexist with this one. I recommend that you are familiar with the Level Select's many tables, as you will be creating your own. (HINT: look here)

This guide will focus on the S2 (rev 01) HG disassembly, other disassembles may see support in the future, but not yet.

The result will be your average S2 Level Select with multiple pages, you toggle between the pages with the 'NEXT' and 'PREV' options. The switch is instantaneous (no fading, no loading screen) and supports numerous pages, the only limit I can think of is RAM, but I suppose dynamic loading can be implemented at a later time. That or you store your mappings uncompressed.


Let's begin.


Cartography
Spoiler



Setting Up Constants
Spoiler



Mappings Decompression
Spoiler



Table Expansion #1 - LevelSelect_Order
Spoiler



Table Expansion #2 - LevelSelect_SwitchTable
Spoiler



Table Expansion #3 - LevSel_IconTable
Spoiler



Table Expansion #4 - LevSel_MarkTable
Spoiler



Table Expansion - For Reference
Spoiler



Dynamic Data #1 - LevelSelect_Order
Spoiler



Dynamic Data #2 - LevelSelect_SwitchTable
Spoiler



Dynamic Data #3 - LevSel_IconTable
Spoiler



Dynamic Data #4 - LevSel_MarkTable
Spoiler



Fixing Sound Test
Spoiler



Using the New Pages
Spoiler



(Optional) Memorising LevSel_Page
Spoiler


(Optional) Using Uncompressed Mappings
Spoiler



If you encounter any of these errors...

> > >s2.asm(11686): error: addressing mode not allowed on 68000
> > > 	move.b	LevelSelect_OrderIndex(pc,d0.w),d0


...regarding lines such as these:

	move.w	LevelSelect_OrderIndex(pc,d0.w),d0
	lea	LevelSelect_OrderIndex(pc,d0.w),a0




Rearrange them to follow this format:

	lea	LevelSelect_OrderIndex(pc),a0	; if this still doesn't work, use (LevelSelect_OrderIndex).l,a0 instead
	move.w	(a0,d0.w),d0
	lea	(a0,d0.w),a0



After fixing some 'branch out of range' errors, you should be good to go. Save and build.

I have tested this guide on an untouched HG disasm. A prototype was built into my main hack with no compatibility issues between this hack and my other Level Select hacks. Hack has been tested with up to three pages. Further numbers are untested.

Update Log (dd/mm/yyyy)
Spoiler

This post has been edited by Clownacy: 16 July 2014 - 06:00 AM

#2 User is offline Cinossu 

Posted 23 January 2014 - 06:10 AM

  • inverted with love~
  • Posts: 2718
  • Joined: 21-June 04
  • Gender:Male
  • Location:London, UK
  • Project:Sonic the Hedgehog Extended Edition
  • Wiki edits:474
180
An interesting way to extend the menu indeed, and a rather thorough guide on how to do it too. Very nicely done. Please consider adding it to the wiki under the hacking how-tos (SCHG_How-to:Guide), if you haven't already.

View PostClownacy, on 21 January 2014 - 03:11 PM, said:

The only bug I've found so far is that when switching pages, the mappings overwrites the Sound Test selection, and that highlighting it will restore the old value. I've masked this by clearing Sound_test_sound whenever the page is changed.
This is most likely due to the mappings themselves, with how you are decompressing to RAM and then drawing to a plane without any modification in-between. In the mappings themselves it probably contains the default 00, meaning the first time drawn will always be this. Add some code to take the sound test value and modify the loaded mappings in RAM before drawing to a plane and it should solve it nicely.

#3 User is offline Clownacy 

Posted 23 January 2014 - 09:31 AM

  • Needs to make an avatar
  • Posts: 309
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Thanks, it turns out your Sound Test fix wasn't necessary: It seems that the zeroes defined in the mappings are redundant, since LevelSelect_DrawSoundNumber is called immediately after the plane map is loaded and replaces them. Applying this to the page loading (sub?)routine fixes the bug, in fact, you can get away with removing the zeroes from the mappings altogether!

I'm pretty happy that you recommend that the guide be added to the SCHG, but it'll be a while before I feel that it's ready. It's still incomplete, you see; scattered around the guide are a couple of to-do's, such as page-looping and dynamic mapping decompression. I should probably add constants for some of the reoccurring values too.

EDIT: SCHG version uploaded.
This post has been edited by Clownacy: 27 January 2014 - 02:22 PM

#4 User is offline KingofHarts 

Posted 25 January 2014 - 08:59 AM

  • Call me back when people stop shitting in the punch bowl...
  • Posts: 1480
  • Joined: 07-August 10
  • Gender:Male
  • Wiki edits:1
I wonder if I could throw a suggestion into the hat.

I was messing around with the Sonic 1 Level Select a while back... and did something where you had the zone name itself, followed by an Act # that would be changed ala the Sound Test. While I haven't been able to get the Act numbers to appear properly... the function works without a hitch.

Image link
In its current form, it looks like so. It has all planned zones for my hack, as well as Char Select, Score, etc. still could use a tad bit of work but the general aim was met. Also, going past the levels will jump all the way to the Sound Test.

Any chance you'd be interested in such feature? While it wouldn't be ideal for Sonic 2, or 3... due to the two act system... a modded Sonic 1 Level Select could theoretically make use of it. If so I can send REV C's source to you to pick away at.
This post has been edited by KingofHarts: 25 January 2014 - 09:03 AM

#5 User is offline Caverns 4 

Posted 25 January 2014 - 01:57 PM

  • Posts: 271
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right
KoH, extending the Sonic 1 (Or more like Sonic 2 beta, but they are similar) level select is well within my interest, due to the fact that the level select in one of my hacks really just can't quite fit all the zones I need (And due to the nature of my hack, changing it would be kind of lame). While I would most ideally prefer a scrolling effect, anything to fit all the zones I want would be great. One column just isn't enough to fit even the $10 zones that Sonic 2 has by default.

Page 1 of 1
    Locked
    Locked Forum

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