Sprite compression (Generation I): Difference between revisions

From Glitch City Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 36: Line 36:


(Can be applied with [[arbitrary sprites]] or ROM hacking)
(Can be applied with [[arbitrary sprites]] or ROM hacking)

[[File:Sprite compression sample.png|thumb|left|160px|Sample image loaded using [[arbitrary sprites]] ([[GlitchDex/Y:230|9ゥ (E6)]] with default palette)]]
[[Category:Generation I mechanics]]

Revision as of 17:57, 9 April 2024

This article is incomplete. Please feel free to add any missing information about the subject. It is missing: needs proper analysis. The official method may also have been in the source code.

Sprite compression is the means in Generation I for where pure graphics data is compressed into a Pokémon or Trainer sprite. The sprite is decompressed again using the sprite decompression routine. While the source compressor code is not in the ROMs; there are a few rules for a compressed sprite:

  • The image to compress is usually a maximum of 56x56 pixels. Other Pokémon sprites can be 32x32, 40x40, 48x48, or 56x56 pixels.
  • Each nybble of the starting offset to the compressed sprite is dimensions/8. Front sprites can be of various sizes; a 56x56 sprite is represented as 0x77, a 48x48 one as 0x66, a 40x40 one as 0x55, a 32x32 as 0x44.
  • Backsprites are internally 32x32 pixels (0x44). Usually, these backsprites also have a little white space at the bottom (hidden by the battle menu).
  • White space occupies smaller sprites to add up to 56x56.
  • Unofficially, a .2bpp file can be converted into a compressed Pokémon sprite using the tool pkmncompress, and a .PNG can be converted using rgbds. "Sprite import tools for RBY" can be downloaded within Evie's Google Sites backup here.

If copying individual rows from a VRAM viewer, it may be necessary to rearrange the bytes; i.e. in this sample image for a 56x56 (0x44) sprite:

5100FF001D00000001000102060105021000FE00D805080019041D02CA15946B0000A200ED100000B7400EF131DEF9920000000055000000400080201804040007000102060109000201010000000000730D37086B145CA3CDF753EF2FD7B1CE2FD0FD0211018C00C59EFB8E8E5FDF0E04000400000448807C5040303040C0200000000000000000000000000000000066DD87FFEF5DAD7EBB7CDC3FB17F3DFE570CEF00D500FF00E91741BE2CD7F30C7000A04020C0C080C000E08040C0E0C000000000000000000000000000000000F17F3DFADE7D3CFFEF7F26FF32FD3EFF|22DDAFF06FF105FB3BD542BF25DF37C860C000E0A060C020806000E060E000E0

Split:

5100FF001D0000000100010206010502|1000FE00D805080019041D02CA15946B|0000A200ED100000B7400EF131DEF992|00000000550000004000802018040400
07000102060109000201010000000000|730D37086B145CA3CDF753EF2FD7B1CE|2FD0FD0211018C00C59EFB8E8E5FDF0E|04000400000448807C5040303040C020
00000000000000000000000000000000|66DD87FFEF5DAD7EBB7CDC3FB17F3DFE|570CEF00D500FF00E91741BE2CD7F30C|7000A04020C0C080C000E08040C0E0C0
00000000000000000000000000000000|F17F3DFADE7D3CFFEF7F26FF32FD3EFF|22DDAFF06FF105FB3BD542BF25DF37C8|60C000E0A060C020806000E060E000E0

Rearrange and unsplit:

5100FF001D00000001000102060105020700010206010900020101000000000000000000000000000000000000000000000000000000000000000000000000001000FE00D805080019041D02CA15946B730D37086B145CA3CDF753EF2FD7B1CE66DD87FFEF5DAD7EBB7CDC3FB17F3DFEF17F3DFADE7D3CFFEF7F26FF32FD3EFF0000A200ED100000B7400EF131DEF9922FD0FD0211018C00C59EFB8E8E5FDF0E570CEF00D500FF00E91741BE2CD7F30C22DDAFF06FF105FB3BD542BF25DF37C80000000055000000400080201804040004000400000448807C5040303040C0207000A04020C0C080C000E08040C0E0C060C000E0A060C020806000E060E000E0

Processing through pkmncompress gives:

44BE9B70D04EA91B0AA9506666A2D45C1EC318D5043EF0EE324C70BEC28870D850F232206048970A852221250837210CA6C323B86182898288C3829C72970D0506250B06CC626D0C5BB082EC62B2FAC288A97552D210A3A62239AB9DEE9DFE42A0C72BA0FFFBA72791E8385B37FF777EE82BFFFFFE844C0A47DFFFF7742861A458C83FDFC3E17F77E0E8587EF84BEFFFFB7FE161F5E83AB3FFEBDF8E0FDE1C8DBFDFFFD8487FF8EAFBDFFD4D8A0C560BBEEC17FF628C957DD0C1505410A46AB6732770

(Can be applied with arbitrary sprites or ROM hacking)

Sample image loaded using arbitrary sprites (9ゥ (E6) with default palette)