News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Kirby Super Star Rom Expansion?  (Read 510 times)

chrismario104

  • Newbie
  • *
  • Posts: 3
    • View Profile
Kirby Super Star Rom Expansion?
« on: August 02, 2018, 05:39:22 pm »
Is there any way to expand the rom of Kirby Super Star in order to stuff more stuff into the rom? I tried Lunar Expand and what happens is that the expansion either said that they can't expand the rom because of the rom size of Super Star (32KB) being larger than the given size expansions.

FuSoYa

  • Jr. Member
  • **
  • Posts: 17
    • View Profile
    • FuSoYa's Niche
Re: Kirby Super Star Rom Expansion?
« Reply #1 on: August 03, 2018, 03:36:14 am »
Games that use the SA-1 chip can technically go up to 8MB (64 mbit).  However, ROM access is controlled through the chip using registers $2220-$2223 to allow for bank switching.  The low bits set where to get banks C0-CF, D0-DF, E0-EF, F0-FF while the high bit lets you choose if banks 00-1F, 20-3F, 80-9F, A0-BF will mirror the same place that the first 4 areas do or just get fixed to the first 4MB of the ROM.

That means ROM expansion for an SA-1 game can sometimes get tricky.  Ideally you'd want to be able to access your expanded ROM data without messing with banks that the game is already reading ROM data from, but also without having to fall back on writing ASM to dynamically switch banks to access your data then switching back before the game needs it again.

So based on just a very quick glance with an SNES tracer, I can see ROM banks 00, 01, 07, CA, CB, D1, EF, F0 being accessed.  There's probably lots more, but it looks like there's a chance they may not of used many of the "LoROM" type banks.  So if I were you, I'd try the following:  at 0x300000 PC in the ROM (assuming it has no copier header), insert (NOT OVERWRITE!) 1MB of zeros.  Yes, that will move the last 1MB of the existing ROM to 0x400000 PC.  This is going to be an unusual expansion for an SNES game.

Next, we need to find where the game sets up the banks.  If you're lucky they just set it up once and leave it that way.  A quick trace gave me this:

$00/80C3 9C 20 22    STZ $2220  [$00:2220]   A:00A0 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:eNvMxdIzC
$00/80C6 A9 01       LDA #$01                A:00A0 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:eNvMxdIzC
$00/80C8 8D 21 22    STA $2221  [$00:2221]   A:0001 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:envMxdIzC
$00/80CB A9 02       LDA #$02                A:0001 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:envMxdIzC
$00/80CD 8D 22 22    STA $2222  [$00:2222]   A:0002 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:envMxdIzC
$00/80D0 A9 03       LDA #$03                A:0002 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:envMxdIzC
$00/80D2 8D 23 22    STA $2223  [$00:2223]   A:0003 X:1FFF Y:0000 D:3700 DB:00 S:1FFF P:envMxdIzC

Note that it seems there's also a LDA #$01 STA $2221 at $DBF0 SNES, which you might want to keep in mind if you play with things later.

Anyway, change the byte at 0xD1 PC (or $80D1 SNES, again assuming no copier header) from 03 to 04.  Then try playing through as much of the game as you can to see if any problems show up.  If everything seems fine, congrats!  You can access your new 1MB of space at $A0:8000-BF:FFFF SNES (32KB LoROM type banks).  You could possibly go up to 6 or 7MB this way by playing with 20-3F and 80-9F along with inserting space at the required locations while setting the right registers, depending on if the game accessed those areas already or not.

If it isn't fine, well...  the original game probably accessed that area after all.  You could try messing with one of 20-3F or 80-9F instead, but I doubt your chances would be any better.  You may just end up having to do dynamic switching with ASM in this case, though you'll have to know what you're doing.


For testing, just be careful which emulator and version you use.  I'd suggest Snes9x 1.54 or higher (older versions do not fully implement those SA-1 registers).

chrismario104

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Kirby Super Star Rom Expansion?
« Reply #2 on: August 03, 2018, 10:12:58 am »
How would you find the area where you would set up bank in the SNES?
« Last Edit: August 03, 2018, 03:55:05 pm by chrismario104 »

FuSoYa

  • Jr. Member
  • **
  • Posts: 17
    • View Profile
    • FuSoYa's Niche
Re: Kirby Super Star Rom Expansion?
« Reply #3 on: August 04, 2018, 10:04:20 pm »
By using an SNES tracer/debugger to look for writes to those registers I mentioned above.  Since I already did that bit for you, you can just use the PC offsets I listed to try making those edits using just about any hex editor.

chrismario104

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Kirby Super Star Rom Expansion?
« Reply #4 on: August 09, 2018, 06:03:24 pm »
Just to check in, what would 1MB be in a decimal? And I would need to only insert 1MB as the offset 00 or just 0, (BTW, I'm using Hex Workshop)? Also would I need to just do that and change the value of $D1 to 04? Would "the original area being accessed already" mean that there is save data already stored? When I would have to try again with expanding a different bank, would I still keep the edit to $D1? (Sorry for all the questions, I just have a few questions after my previous attempt at expanding the rom failed)

FuSoYa

  • Jr. Member
  • **
  • Posts: 17
    • View Profile
    • FuSoYa's Niche
Re: Kirby Super Star Rom Expansion?
« Reply #5 on: August 10, 2018, 08:39:34 pm »
Just to check in, what would 1MB be in a decimal?

0x100000 bytes in hex = 1048576 in decimal.

And I would need to only insert 1MB as the offset 00 or just 0, (BTW, I'm using Hex Workshop)?

Insert 1MB of bytes at offset 0x300000.  The value of the individual bytes doesn't actually matter and it'll probably treat 0 the same as 00, but you can enter 00 if you want.

Also would I need to just do that and change the value of $D1 to 04?

Yes.

Would "the original area being accessed already" mean that there is save data already stored?

It'd just mean the original game was already accessing ROM data from those banks.  With the original bank setup, there's 2 different addresses that could have been used by the game to read any particular byte.  For example, $00:8000 and $C0:0000 SNES access the exact same location in the ROM file (PC offset 0).  There are sometimes reasons a game will use one address instead of the other (which I won't get into), but this modification is betting on the chance that they didn't try to read from banks A0-BF as they can read the same data from F0-FF.  *If* that turns out to be true, it means you're free to permanently redirect those banks to new space.

When I would have to try again with expanding a different bank, would I still keep the edit to $D1? (Sorry for all the questions, I just have a few questions after my previous attempt at expanding the rom failed)

No, you'd have to do something a bit different for those.  I wouldn't even bother if this one fails, because if these banks were already being read from then chances are the lower ones are too.


I should probably mention that I already went and tried applying the expansion change for banks A0-BF to the ROM and the initial results looked promising.  The game ran and I played around a bit in the first level.  You're still going to want to playtest through the whole game though just to be absolutely sure that it's all going to be ok with this type of expansion.