Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Phantasy Star II/Notes

From Data Crystal
Jump to navigation Jump to search

The notes are for the american version. Offsets are different in the japanese version (checked).

Graphics Storage

Basic Compression

The game uses one basic compression scheme, for storing some of the arts, as well as other data (such maps). Here's its description :

First, the data is split in 32 bytes chunks. Then, for each chunk:

  • N (byte) : it's a counter. If $FF, the compression is over.
  • repeat N times:
    • V (byte) : the value that will be decoded
    • M (long) : a mask indicating the locations in the current 32 byte chunk where to put this value
  • At the end of the loop, some locations in the chunks may not have got a value. If so, they are given in raster order after at this point.
  • Go to first stage.

An example from the game : the font is located at 0x29EB8

01 : N = 1

we repeat 1 time :

BB : the value

FF88B888 : the mask (=0b11111111100010001011100010001000). The current chunk is :

   BBBBBBBB BBBBBBBB BB?????? BB?????? BB??BBBB BB?????? BB?????? BB??????

Since the loop is over, all subsequent bytes are values for each ?? in the preceding (there are 16 of them) :

11 11 11 16 66 66 16 16 BA AA 16 BA AA 16 BA AB : we get for the 1st chunk :

   BBBBBBBB BBBBBBBB BB111111 BB166666 BB16BBBB BB16BAAA BB16BAAA BB16BAAB

02 : N = 2, so

BB, EE008000 : that gives

   BBBBBB?? BBBBBB?? ???????? ???????? BB?????? ???????? ???????? ????????

55, 00102277 : now we have

   BBBBBB?? BBBBBB?? ??????55 ???????? BB??55?? ????55?? ??555555 ??555555

16 values are left unknown :

B1 15 11 11 B1 66 6B 16 15 B1 61 AB 15 56 B1 15 : so the final value is :

   BBBBBBB1 BBBBBB15 1111B155 666B1615 BBB15561 AB155556 B1555555 15555555

Some example of such graphisms (to be completed) :

29EB8 : Font

2AC66 : SEGA logo

6FF22 : intro art (2)

Nemesis compressed graphisms

Some art uses the well-known Nemesis compression scheme. You can use The Sega Compressor to decompress / recompress them.

Some example of such graphisms : see maps storage.

Font storage

Font patterns

The font is made of 192 8x8 patterns (I use the term 'pattern' to denote 8x8 objects stored in VRAM ; a "tile" is made of several patterns, see later), including :

  • icons for battle windows, status, check boxes
  • two complete alphabet sets, uppercase and lowercase
  • some remaining of the japanese version, unused

Encoding

The encoding doesn't follow the pattern ordering. An actual character is in fact a 8x16 tile (2 patterns heigh) ; the upper pattern is always a space and the bottom one is the actual glyph (in order to allow interline space).

The correspondance is stored in a table starting at 0x12BC8. Each entry is 2 bytes, the first being always 0x26 (rank of the space in the font patterns).

For example, the table starts with :

26 26 : so the character with code 0 is made of 2 stacked spaces,

26 97 : one space on top of the 0x97th font pattern, which represents the digit "0"

etc.

Special codes

  • 0xBB : [character1] this code is replaced by the name of a character
  • 0xBC : [character2] same thing (allows to have 2 characters names in the same sentence, for texts like "XXX heals YYY"
  • 0xBD : [monster] replaced by a monster name
  • 0xBE : [technique] replaced by a technique
  • 0xBF : [item] replaced by an item name
  • 0xC0 : [value] replaced by a numeric value
  • 0xC1 : carriage return
  • 0xC2 : [clear] clear current window
  • 0xC3 : [wait] wait for a button to be pressed
  • 0xC4 : [end] end of text