$17 = temporary location of where to output uncompressed data to

$1D = some value to append to $4B afterwards if $4B isn't 0.

$48:$47 = input data pointer (starting value seems to be B0F3, even though we read in A9BF. Some other routine must read in the other bytes)

$49 = current byte of input data

$4A = the input data bits left to read

$4B = 8 bits of data that are outputted

$4C = 3 bits (contains values 0 to 7) of data that say how many times $4B is repeated. Note we add 2 to the value read in. So if we read 0, $4B is repeated only 2 times.

Its a good thing to notice, that when it reads a bit, it reads the TOP bit first, not the lowest like most routines do.

Also note, that before we read in the next $4B, we read 1 bit. If it is 0, then we don't read in $4C, we skip it and go right to $4B. So this is a way to save 3 bits when we want to repeat $4B only once.

here is a condensed, c++ like view of the code:

`void FA88() {`

x = -1

do {

x++

$17 = X

a = getNextUncompressedByte()

if (a != 0) {

a += $1D

}

$626[$17] = a

} while (x != $15)

}

byte getNextUncompressedByte() { //FBAC

x = $4C

if ($4C == 0) {

carry = loadBit()

if (carry == 0)

{

a = loadByte(8);

return a;

}

$4b = loadByte(8)

a = loadByte(3)

x = a+2

}

x--

$4C = x

return $4B

}

byte loadByte(y) { //FBC6

a = 0

do {

carry = loadBit()

a = (a << 1) | carry

y--

} while (y != 0)

return a

}

byte loadBit() { //FBD8

if ($4A == 0) {

a = ($47) (tile data)

$48:$47 += 1 (increase input data pointer by 1)

$49 = a

$4A = #8

}

$4A--

carry = ($49 & #80); $49 <<= 1;

return carry

}

Edit:

as I pointed out that some other routine must read in the data before we get to the routine you specified.

It seems to read 5 bytes directly after it gets the pointer, and then switches in to reading the rest of the data as our compressed version.

`F9D9 A0 00 LDY #$00`

F9DB A2 47 LDX #$47

F9DD A1 00 LDA ($00,X) @ $A9BF = #06 <--- read data

F9DF F6 00 INC $00,X @ $0047 = #BF

F9E1 D0 02 BNE $F9E5

F9E3 F6 01 INC $01,X @ $0048 = #A9

F9E5 99 13 00 STA $0013,Y @ $0013 = #06

F9E8 C8 INY

F9E9 C0 04 CPY #$04 <---

F9EB D0 EE BNE $F9DB <--- loop 4 times

F9ED A2 47 LDX #$47

F9EF A1 00 LDA ($00,X) @ $A9C3 = #80 <--- read data

F9F1 F6 00 INC $00,X @ $0047 = #C3

F9F3 D0 02 BNE $F9F7

F9F5 F6 01 INC $01,X @ $0048 = #A9

............

FA32 20 A5 FB JSR $FBA5 <--- compression reset routine

............

FA3F 20 5D FB JSR $FB5D

FB5D 20 AC FB JSR $FBAC A = getNextUncompressedByte()