whenever reading fractions of bytes. The low bits always come from the next byte while the high bits come from the current byte
| 122 | // whenever reading fractions of bytes. The low bits always come from the next byte |
| 123 | // while the high bits come from the current byte |
| 124 | __ri static u8 getBits64(u8 *address, bool advance) |
| 125 | { |
| 126 | if (!g_BP.FillBuffer(64)) return 0; |
| 127 | |
| 128 | const u8* readpos = &g_BP.internal_qwc[0]._u8[g_BP.BP/8]; |
| 129 | |
| 130 | if (uint shift = (g_BP.BP & 7)) |
| 131 | { |
| 132 | u64 mask = (0xff >> shift); |
| 133 | mask = mask | (mask << 8) | (mask << 16) | (mask << 24) | (mask << 32) | (mask << 40) | (mask << 48) | (mask << 56); |
| 134 | |
| 135 | *(u64*)address = ((~mask & *(u64*)(readpos + 1)) >> (8 - shift)) | (((mask) & *(u64*)readpos) << shift); |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | *(u64*)address = *(u64*)readpos; |
| 140 | } |
| 141 | |
| 142 | if (advance) g_BP.Advance(64); |
| 143 | |
| 144 | return 1; |
| 145 | } |
| 146 | |
| 147 | // whenever reading fractions of bytes. The low bits always come from the next byte |
| 148 | // while the high bits come from the current byte |