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

Author Topic: NES ROM Compression Help  (Read 4266 times)

MrFaust

  • Jr. Member
  • **
  • Posts: 25
  • Noob Hacker
    • View Profile
NES ROM Compression Help
« on: February 13, 2014, 03:41:09 am »
So I have a Castlevania hack I been working on and I have managed to edit some of the graphics using Tile layer Pro. However I've reached a point where there is stuff I'd like to edit but it is compressed and I can't really tell what m looking at. Is there a program that can decompress the sprites or make it a tab bit more easy when viewing the sprites so I can edit/replace them. Any help would be great.
I feel asleep

VicVergil

  • Hero Member
  • *****
  • Posts: 721
    • View Profile
Re: NES ROM Compression Help
« Reply #1 on: February 13, 2014, 04:22:37 am »
You'll need to so some ASM work.

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: NES ROM Compression Help
« Reply #2 on: February 13, 2014, 04:55:40 am »
Of course there is a program that decompresses the data. It's right there in the game code.  >:D

MrFaust

  • Jr. Member
  • **
  • Posts: 25
  • Noob Hacker
    • View Profile
Re: NES ROM Compression Help
« Reply #3 on: February 13, 2014, 12:33:38 pm »
Yeah thanks for that Henke... Guess I'll have to try and figure it out on my own. What program do I need to mess with ASM code?
I feel asleep

Pennywise

  • Hero Member
  • *****
  • Posts: 2310
  • I'm curious
    • View Profile
    • Yojimbo's Translations
Re: NES ROM Compression Help
« Reply #4 on: February 13, 2014, 12:50:03 pm »
Most Konami games on the NES use a standard RLE compression format. AFAIK, Graveyard Duck is the only tool out there to compress and decompress and that doesn't mean it'll work with your game. There are plenty of variations out there.

Scio

  • Full Member
  • ***
  • Posts: 155
    • View Profile
Re: NES ROM Compression Help
« Reply #5 on: February 13, 2014, 01:59:50 pm »
Yeah thanks for that Henke... Guess I'll have to try and figure it out on my own. What program do I need to mess with ASM code?
A debugger. FCEUX is very good in this regard.
Now learning ASM is something else entirely. No easy way around it.

tomaitheous

  • Hero Member
  • *****
  • Posts: 543
    • View Profile
    • PC Engine Dev
Re: NES ROM Compression Help
« Reply #6 on: February 13, 2014, 04:51:53 pm »
So I have a Castlevania hack I been working on and I have managed to edit some of the graphics using Tile layer Pro. However I've reached a point where there is stuff I'd like to edit but it is compressed and I can't really tell what m looking at. Is there a program that can decompress the sprites or make it a tab bit more easy when viewing the sprites so I can edit/replace them. Any help would be great.

 Maybe check to see if there's an expansion hack, as well as a chr-rom hack of the game. Chr-rom stuff is uncompressed. Even if you did decompress the graphics for chr-ram, there's no guarantee that it will compress and fit back into the original space. Usually best to ASM hack the game, expand the rom, and have it point to uncompressed tiles instead. Of course, this isn't easy (and requires of processor specific assembly), but like I said - you might get lucky and find that someone already did this, and build on top of that instead of the original rom.

VicVergil

  • Hero Member
  • *****
  • Posts: 721
    • View Profile
Re: NES ROM Compression Help
« Reply #7 on: February 13, 2014, 08:26:44 pm »
Yeah thanks for that Henke... Guess I'll have to try and figure it out on my own. What program do I need to mess with ASM code?

Technically, he isn't wrong.
There are two ways to solve this problem:

1: As Henke said, you use a debugger emulator to show the program that decompresses the graphics as the game is running.
Obviously you'll need to understand that program, that means you'll need to know that ASM language. NES assembly is simple so you're lucky (I'd give you a tutorial I made but it's in another language)

So, now you have the decompression program that makes the conversion
compressed_ROM_graphics>>uncompressed_VRAM/PPU_graphics
You make two programs in C++/Java/whatever you like, one that does the decompression above, and another that re-compresses and recreate the compressed data in the ROM (that you'll need to study)
You do some tests to make sure it's fine, with the exact same data unchanged and see if the recompression is successful.

You can often end up with files bigger than the original (if smaller, you could fill with 00/FF/garbage data)
In that case, you'll need to move the data elsewhere with enough space... overflowing and overwriting other files is the best way to failure

Ironically this method does not require changing the programming of the game.

2: A more sane way is to expand the ROM (not the easiest thing to do on NES)
Put the uncompressed graphics (ripped from the PPU/VRAM, or you could do a part of solution 1 and do a decompressor only) in the new space

Change the programming of the game (ASM):
the instruction: "do_decompression_program" becomes "do_program_that simply_takes_uncompressed_data_as_is_from_ROM_to_RAM"
(of course you won't find nice looking neon glowing labels like that in the programming)

MrFaust

  • Jr. Member
  • **
  • Posts: 25
  • Noob Hacker
    • View Profile
Re: NES ROM Compression Help
« Reply #8 on: February 15, 2014, 11:33:49 am »
thanks for the help guys.
I feel asleep