[BITWISE OPS] Missing operation in lookback-buffer RLE decoding math

Results 1 to 1 of 1
  1. #1
    Libre Software Developer PyroSamurai is offline
    ModeratorRank
    Sep 2012 Join Date
    USALocation
    661Posts

    [BITWISE OPS] Missing operation in lookback-buffer RLE decoding math

    This is a problem I've come across while rev-engineering a file format encoding,
    but it is not a rev-engineering problem, it is a math/programming problem.
    Code:
    lo:0F, lo<<8:3840, NB: -3, rawOff:  -3, offset:  -3, pos:  6, newOffset:  3
    lo:0F, lo<<8:3840, NB: -6, rawOff:  -6, offset:  -6, pos:  9, newOffset:  3
    lo:0F, lo<<8:3840, NB:-10, rawOff: -10, offset: -10, pos: 15, newOffset:  5
    lo:0F, lo<<8:3840, NB:-22, rawOff: -22, offset: -22, pos: 25, newOffset:  3
    lo:0F, lo<<8:3840, NB:-40, rawOff: -40, offset: -40, pos: 43, newOffset:  3
    lo:0F, lo<<8:3840, NB:-59, rawOff: -59, offset: -59, pos: 62, newOffset:  3
    lo:0F, lo<<8:3840, NB:-71, rawOff: -71, offset: -71, pos: 71, newOffset:  0
    lo:0F, lo<<8:3840, NB:-23, rawOff: -23, offset: -23, pos: 92, newOffset: 69
    lo:0F, lo<<8:3840, NB: -8, rawOff:  -8, offset:  -8, pos:120, newOffset:112
    lo:0F, lo<<8:3840, NB:-51, rawOff: -51, offset: -51, pos:139, newOffset: 88
    lo:0F, lo<<8:3840, NB:-44, rawOff: -44, offset: -44, pos:152, newOffset:108
    lo:0F, lo<<8:3840, NB:-40, rawOff: -40, offset: -40, pos:156, newOffset:116
    lo:0F, lo<<8:3840, NB: -6, rawOff:  -6, offset:  -6, pos:172, newOffset:166
    lo:0F, lo<<8:3840, NB:-64, rawOff: -64, offset: -64, pos:176, newOffset:112
    lo:0F, lo<<8:3840, NB:123, rawOff:3963, offset:-133, pos:202, newOffset: 69
    lo:0F, lo<<8:3840, NB: 52, rawOff:3892, offset:-204, pos:207, newOffset:  3
    lo:0F, lo<<8:3840, NB: 34, rawOff:3874, offset:-222, pos:225, newOffset:  3
    lo:0F, lo<<8:3840, NB: 16, rawOff:3856, offset:-240, pos:243, newOffset:  3
    lo:0F, lo<<8:3840, NB: 57, rawOff:3897, offset:-199, pos:261, newOffset: 62
    lo:0E, lo<<8:3584, NB: -9, rawOff:  -9, offset:  -9, pos:268, newOffset:259
    lo:0F, lo<<8:3840, NB: 29, rawOff:3869, offset:-227, pos:296, newOffset: 69
    lo:0F, lo<<8:3840, NB: 37, rawOff:3877, offset:-219, pos:305, newOffset: 86
    lo:0F, lo<<8:3840, NB:-25, rawOff: -25, offset: -25, pos:317, newOffset:292
    lo:0F, lo<<8:3840, NB:-49, rawOff: -49, offset: -49, pos:336, newOffset:287
    lo:0E, lo<<8:3584, NB:-30, rawOff: -30, offset: -30, pos:355, newOffset:325
    The code here is in JAVA but any C-based language knowledge will do for this:
    Code:
    lo  = curByte & 0x0F;
    
    // *code to get nextByte*
    
    int offset = (lo<<8) | nextByte; //rawOffset
    
    offset = offset | -0x1000; //offset
    
    // *print current position*
    
    newOffset = pos + (offset);
    This issue here is that the new offset on the last line needs to be 295 not 325.

    I'm sure that I'm missing some mathematical operation(s). I just don't know what it is.
    Whatever operation(s) I add/change, the rest of the results must stay the same, since they are correct.

    I will not post any other code. This is all that is needed to solve.
    Anyways, if you can figure out the solution, I will 'rep' & 'like' your reply.
    Happy Hacking!
    "Unless someone like you cares a whole awful lot, nothing is going to get better. It's not."-Dr. Seuss

    I don't want admiration. I want you to follow my example.
    The best way to bring moderator attention to a post is to use the report button (⚠️).

    Like my releases or want to thank me? -> give me rep. (✶ at bottom left)
    For other displays of affection -> use the like button.
    Moderator of Trickster Online & f168
    RZ Dev





Advertisement