whenever reading fractions of bytes. The low bits always come from the next byte while the high bits come from the current byte
| 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 |
| 149 | __ri static u8 getBits32(u8 *address, bool advance) |
| 150 | { |
| 151 | if (!g_BP.FillBuffer(32)) return 0; |
| 152 | |
| 153 | const u8* readpos = &g_BP.internal_qwc->_u8[g_BP.BP/8]; |
| 154 | |
| 155 | if(uint shift = (g_BP.BP & 7)) |
| 156 | { |
| 157 | u32 mask = (0xff >> shift); |
| 158 | mask = mask | (mask << 8) | (mask << 16) | (mask << 24); |
| 159 | |
| 160 | *(u32*)address = ((~mask & *(u32*)(readpos + 1)) >> (8 - shift)) | (((mask) & *(u32*)readpos) << shift); |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | // Bit position-aligned -- no masking/shifting necessary |
| 165 | *(u32*)address = *(u32*)readpos; |
| 166 | } |
| 167 | |
| 168 | if (advance) g_BP.Advance(32); |
| 169 | |
| 170 | return 1; |
| 171 | } |
| 172 | |
| 173 | __ri static u8 getBits8(u8 *address, bool advance) |
| 174 | { |
no test coverage detected