gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > LZ77 - compression problems

#15284 - qw3rty - Tue Jan 20, 2004 12:57 pm

Hi,

I tried to compress my graphics with LZ77 - after a couple of attempts I got it working *partly* - some sprites work perfect, but others don`t - it seems like some color indexes got mixed up - I think all the color-indexes were decremented by one(e.g. a pixel with color 1 is now color 0) - however, the palette seems to be intact, only the pixels got another color-index.
Color 0-pixels aren`t effected by this (the transparent parts of the image stay transparent)
I convert my GFX with gfx2gba, btw, and decompress directly to the sprite-character-memory.

Any ideas ?
(I tend to remove the compressed images, because it didn`t save place, the .bin even got bigger by a few bytes :( )

#15316 - Miked0801 - Tue Jan 20, 2004 8:27 pm

LZ77 compression takes a while to get good compression (usually.) I'd not expect much compression on files of less than 100 bytes.

Don't know on the tool thing though.

#15326 - tepples - Tue Jan 20, 2004 9:23 pm

Perhaps gfx2gba is trying to optimize your palettes at the same time. You might want to look for a switch for that.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#15358 - qw3rty - Wed Jan 21, 2004 11:42 am

I just got a private message from a guy, asking about the code...
This code is for ARM-mode btw, I think the swi"0xnn0000" have to replaced by "0xnn" for THUMB-mode...
Code:

void LZ77UnCompWRAM(u8* inBuffer, u16* outBuffer)
{

    asm volatile("
    mov r0, %0
    mov r1, %1
    swi 0x110000
    ":    /* No output */ :
    "r" (inBuffer) , "r" (outBuffer) :
    "r0", "r1");
}

void LZ77UnCompVRAM(u8* inBuffer, u16* outBuffer)
{

    asm volatile("
    mov r0, %0
    mov r1, %1
    swi 0x120000
    ":    /* No output */ :
    "r" (inBuffer) , "r" (outBuffer) :
    "r0", "r1");
}


This code throws some errors at me , when compiling:
"warning: multi-line string literals are deprecated"
but I don`t know any assembler, and don`t know how to fix this code...
(I copied this code from the yahoo-gba-dev-forum)

Anybody knows how to fix it ?

#15365 - NEiM0D - Wed Jan 21, 2004 2:00 pm

It's been a long time since I used GCC, but I believe you needed to add '\n' to each assembler line for use in C.

#15372 - poslundc - Wed Jan 21, 2004 4:08 pm

You're trying to put a quoted string literal on multiple lines. IIRC, you need to put a backslash (\) at the end of each line before going to the next line. ie.

Code:
    asm volatile("
    mov r0, %0
    mov r1, %1
    swi 0x110000
    ":    /* No output */ :
    "r" (inBuffer) , "r" (outBuffer) :
    "r0", "r1");

becomes:

    asm volatile(" \
    mov r0, %0 \
    mov r1, %1 \
    swi 0x110000 \
    ":    /* No output */ :
    "r" (inBuffer) , "r" (outBuffer) :
    "r0", "r1");


Dan.