PTdecode: add support for uncompressed data (NOTE: *NOT* supported by the PT-2450DX)

Wed, 05 Aug 2009 15:02:31 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 05 Aug 2009 15:02:31 +0100
changeset 13
a933b13e087f
parent 12
96e1df9bd27c
child 14
088286f9e1e4

PTdecode: add support for uncompressed data (NOTE: *NOT* supported by the PT-2450DX)

PTdecode/src/main.cpp file | annotate | diff | revisions
     1.1 diff -r 96e1df9bd27c -r a933b13e087f PTdecode/src/main.cpp
     1.2 --- a/PTdecode/src/main.cpp	Wed Aug 05 15:00:54 2009 +0100
     1.3 +++ b/PTdecode/src/main.cpp	Wed Aug 05 15:02:31 2009 +0100
     1.4 @@ -95,31 +95,39 @@
     1.5  				ch = getNext();
     1.6  				len = (((int)getNext()) << 8) + ch;
     1.7  
     1.8 -				// Dump the gfx data
     1.9 -				rowpos = 0;
    1.10 -				while (len > 0) {
    1.11 -					// get the prefix byte
    1.12 -					ch = getNext(); len--;
    1.13 -
    1.14 -					// Is this a "run" (a single byte replicated) or a "copy"?
    1.15 -					int runlen;
    1.16 -					if (ch & 0x80) {
    1.17 -						// MSB set, it's a run
    1.18 -						runlen = 257 - ((int)ch);
    1.19 +				// Is gfx payload compressed or uncompressed?
    1.20 +				if (cm == 1) {
    1.21 +					// Uncompressed. Read straight into the row buffer.
    1.22 +					while (len > 0) {
    1.23 +						row[rowpos++] = getNext(); len--;
    1.24 +					}
    1.25 +				} else {
    1.26 +					// Decompress the gfx data
    1.27 +					rowpos = 0;
    1.28 +					while (len > 0) {
    1.29 +						// get the prefix byte
    1.30 +						ch = getNext(); len--;
    1.31  
    1.32 -						// Get the byte to replicate, and replicate it into the o/p buffer
    1.33 -						ch = getNext(); len--;
    1.34 -						while (runlen-- > 0) {
    1.35 -							row[rowpos++] = ch;
    1.36 -						}
    1.37 -					} else {
    1.38 -						// MSB clear, it's a copy
    1.39 -						runlen = ((int)ch) + 1;
    1.40 +						// Is this a "run" (a single byte replicated) or a "copy"?
    1.41 +						int runlen;
    1.42 +						if (ch & 0x80) {
    1.43 +							// MSB set, it's a run
    1.44 +							runlen = 257 - ((int)ch);
    1.45  
    1.46 -						// Copy N bytes from the input stream to the output
    1.47 -						while (runlen-- > 0) {
    1.48 -							row[rowpos++] = getNext();
    1.49 -							len--;
    1.50 +							// Get the byte to replicate, and replicate it into the o/p buffer
    1.51 +							ch = getNext(); len--;
    1.52 +							while (runlen-- > 0) {
    1.53 +								row[rowpos++] = ch;
    1.54 +							}
    1.55 +						} else {
    1.56 +							// MSB clear, it's a copy
    1.57 +							runlen = ((int)ch) + 1;
    1.58 +
    1.59 +							// Copy N bytes from the input stream to the output
    1.60 +							while (runlen-- > 0) {
    1.61 +								row[rowpos++] = getNext();
    1.62 +								len--;
    1.63 +							}
    1.64  						}
    1.65  					}
    1.66  				}