bsnes/snesreader/unrar/getbits.hpp
byuu 46a1eb8cce Update to bsnes v059r06 release.
This is an experimental release, as such it is posted only to Google Code.
Changelog:
    - 21fx API moved to pre-finalized form as S-MSU1; more about this on the forum
    - OpenGL driver now uses GL_CLAMP_TO_BORDER instead of GL_CLAMP_TO_EDGE to support screen curvature shader
    - rewrote file open dialog; code is greatly simplified, interface is improved
    - all cheat code columns are now enquoted, and empty codes at the bottom of the file are omitted (format is compatible with previous releases still)
    - debugger: added missing DMA variables to S-CPU properties viewer
    - snesfilter: added OpenMP (multi-threading) support to HQ2x filter
    - lots of other miscellaneous code cleanup work
2010-01-24 23:21:38 +00:00

40 lines
717 B
C++

#ifndef _RAR_GETBITS_
#define _RAR_GETBITS_
class BitInput
: public Rar_Allocator
{
public:
enum BufferSize {MAX_SIZE=0x8000};
protected:
int InAddr,InBit;
public:
BitInput();
~BitInput();
void handle_mem_error( Rar_Error_Handler& );
byte *InBuf;
void InitBitInput()
{
InAddr=InBit=0;
}
void addbits(int Bits)
{
Bits+=InBit;
InAddr+=Bits>>3;
InBit=Bits&7;
}
unsigned int getbits()
{
unsigned int BitField=(uint)InBuf[InAddr] << 16;
BitField|=(uint)InBuf[InAddr+1] << 8;
BitField|=(uint)InBuf[InAddr+2];
BitField >>= (8-InBit);
return(BitField & 0xffff);
}
void faddbits(int Bits);
unsigned int fgetbits();
bool Overflow(int IncPtr) {return(InAddr+IncPtr>=MAX_SIZE);}
};
#endif