Re: Blitzkrieg Banzai? (SP1 Conversion)
			 
             
			
		
		
		
		A compressed section is made up of multiple interspersed compressed and uncompressed run-length encoded data blocks. 
 
Each run-length coded data block consists of: 
 
[N] a run-length coding byte (RLB) 
[b] one or more data bytes. 
 
The Run Length Coding Byte (RLB) is the trigger that tells us what type of data block it is: 
 
If the RLB is equal to or less than 127, it's a uncompressed run-length coded (URLC) data block, which is used for sequences with mixed values: 
 
[N] The RLB indicates the number of data bytes that follow, which can be from 1 to 127 bytes. 
[b] Individual Data Bytes that can be copied/edited as/is. 
 
If the RLB is equal to or greater than 128, it's a compressed run-length coded (CRLC) data block, which is used for large sequences of identical data bytes to save space. 
 
[N] The RLB indicates the number of identical data bytes that follow from 1 to 127 bytes.  
 
BIG IMPORTANT NOTE: 
To get the true RLB for a CRLC block, you need to subtract 128 from the initial RLB. For example, if your CRLC has a RLB of 250, it's true length is actually: 250 – 128 = 122 Byte RLB. (This is what tripped me up; I was assuming 250, 0 meant 250 bytes of identical 0 value.) 
 
[b] Data Value for All the Bytes in this block. The decompressed data is the sequence of N times the data byte B. 
 
A visual representation of the typical sequence of a compressed data block is attached. 
 
RED: Section Header. 4-byte Header Marker (37 0 0 0) followed by compressed size (33 0 0 0) and the compressed flag (1). 
 
GREEN (Uncompressed) and BLUE (Compressed) Blocks You can see how the RLB says 16 bytes, followed by 16 bytes, then you have a compressed block of 86 bytes (214 - 128 = 86) with a value of zero; and so on so on. 
		
	
		
		
			
		
		
		
		
		
		
		
		
		
		
		
            
                  
				
                    
                        Last edited by MarkSheppard; April 8th, 2020 at 05:44 PM..
                    
                    
				
			
		
		
	
		
		
	
	
	 |