http://gravelstudios.com/TileNipper1.0.zip
the compression it uses is a very simple RLE scheme in which a positive control byte means copy that many following bytes in a row, a negative control byte means copy the following byte that many times, and a zero means end of data. I've used it on my own graphics tile data so far with decent results (I know there are compression schemes that would do much better than this, but I wanted something simple and easy to program). This code can be used to decompress the data:
Code: Select all
LoadCompressedTileBlock:
LDY #0 ;Y stays fixed on 0. increments are done on the pointers directly.
.Loop:
LDA [pointerLo], Y
BEQ .Exit ;zero control byte is end of data. exit.
TAX ;otherwise, it indicates the number of tiles to load.
JSR IncrementPointers ;go to the first byte in the run.
TXA
BMI .LoadRun ;a negative control byte indicates a run of identical tiles.
.LoadUnique:
JSR LoadNonCompressedTileBlock
JMP .Loop
.LoadRun:
LDA [pointerLo], Y
STA $2007
INX
BNE .LoadRun
JSR IncrementPointers
JMP .Loop
.Exit:
RTS
LoadNonCompressedTileBlock: ;takes X as number of bytes to transfer.
LDY #0
.Loop:
LDA [pointerLo], Y
STA $2007
JSR IncrementPointers
DEX
BNE .Loop
RTS
IncrementPointers:
LDA <pointerLo
CLC
ADC #1
STA <pointerLo
LDA <pointerHi
ADC #0
STA <pointerHi
RTS