Thanks, guys!
Kasumi wrote:Anyway, this stuff is really, really cool. And I'd certainly love to read about your video compression/implementation. I was happy enough just to get 53% on text, heh.
The compression is actually extremely simple. The first frame is an intraframe (actual image data), encoded as follows:
Code: Select all
1 = repeat current value for 3 bytes (12 pixels)
10 = repeat current value for 1 byte (4 pixels)
11 = change current value to following value (next 8 bits)
And all the other frames are interframes (delta values), encoded as follows:
Code: Select all
1 = no change for 3 bytes (12 pixels)
10 = no change for 1 byte (4 pixels)
11 = add following value to current value (next 8 bits)
There's some other stuff about lossy encoding of delta values on the encoder side, but that's all the decompressor needs to do.
The implementation is a little bit trickier. Rendering is done using a program I wrote to autogenerate a giant unrolled loop, which executes MMC5 ExRAM nametable changes until HBlank then sets the scroll appropriately (writing to the nametable as it's rendering so that new rows of the image are transferred just as the old ones finish). Part of the image is also transferred beforehand, at the start of every new video frame, to help allow a bit of leeway. Decompression is relatively straightforward in comparison, though still fairly optimized (I think about as much as it can be without changing the format, or relying on self-modifying code stored in RAM).
If you or anyone else is interested, I can clean up the encoder/ASM generation programs as well as the asm6 source and post them in a bit. I don't know how much more I'm going to work on this myself, it was just a quick proof of concept for fun/out of curiosity, but maybe others can expand on it and make it more viable.
ccovell wrote:I did some NES experiments with animation/FMV back in 2000, but these had no compression and used no mapper.
Cool stuff! Especially awesome given that it was almost 15 years ago, I'm sure the state of NES emulation was far worse back then and there were far more unknowns. The mapper is kind of key to how this works as I mentioned above, so I'm not sure this same technique could be used for FMV off the MMC5 sadly. Regular nametable writes just seem too slow...
LOL, can't believe I didn't think of that! That's awesome, I'm sure something similar could be used for 4-color video too (could possibly even save space?)
Anyway, assuming infinite cartridge space isn't really a cheat. Pretend you have a 128 kilobyte RAM and an eMMC (NAND flash) that you can read through a separate mapper port. Someone on this board has proposed exactly this configuration.
So, theoretically, I could do things like e.g. render large bosses on arbitrary backgrounds and just use the excuse of "lol CHR ROM"? (The interior of the boss would be tiles and the exterior would be sprites, in this hypothetical scenario.) Here's a link to the
game's current style guide BTW.
BMF54123 wrote:What would be really cool is something like the
MSU-1 for the PowerPak and/or Everdrive N8. Perhaps something with the same basic capabilities as an FME-7 or VRC6, but with the ability to stream a PCM sound file to the sound expansion pin, and a PRG/CHR data file to either a mapper register or directly to PRG/CHR RAM. Surely both cartridges have enough hardware to accomplish this.
That would be awesome. Compressing audio could also save more space here, I did some experiments with ADPCM on an 8-bit processor (the Z80 in the Sega Genesis) a few years back and it actually got to
a pretty advanced stage. I'm sure similar techniques could be used on the NES (especially if video "decompression" just consists of switching CHR banks).
Also, completely unrelated, are you the same BMF who made the Sonic 2 Genocide City mockup many years ago? lol