22 #ifndef ULTIMA8_USECODE_UCSTACK_H 23 #define ULTIMA8_USECODE_UCSTACK_H 25 #include "common/scummsys.h" 38 BaseUCStack(uint32 len, uint8 *b) : _buf(b), _size(len) {
40 _bufPtr = _buf + _size;
44 inline uint32 getSize()
const {
48 inline uint32 stacksize()
const {
49 return _size - (_bufPtr - _buf);
52 inline void addSP(
const int32 offset) {
56 inline unsigned int getSP()
const {
57 return static_cast<unsigned int>(_bufPtr - _buf);
60 inline void setSP(
unsigned int pos) {
68 inline void push1(uint8 val) {
73 inline void push2(uint16 val) {
75 _bufPtr[0] =
static_cast<uint8
>(val & 0xFF);
76 _bufPtr[1] =
static_cast<uint8
>((val >> 8) & 0xFF);
78 inline void push4(uint32 val) {
80 _bufPtr[0] =
static_cast<uint8
>(val & 0xFF);
81 _bufPtr[1] =
static_cast<uint8
>((val >> 8) & 0xFF);
82 _bufPtr[2] =
static_cast<uint8
>((val >> 16) & 0xFF);
83 _bufPtr[3] =
static_cast<uint8
>((val >> 24) & 0xFF);
86 inline void push0(
const uint32 count) {
88 memset(_bufPtr, 0, count);
91 inline void push(
const uint8 *in,
const uint32 count) {
93 memcpy(_bufPtr, in, count);
100 inline uint16 pop2() {
104 return (b0 | (b1 << 8));
106 inline uint32 pop4() {
107 uint8 b0, b1, b2, b3;
112 return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24));
114 inline void pop(uint8 *out,
const uint32 count) {
115 memcpy(out, _bufPtr, count);
123 inline uint8 access1(
const uint32 offset)
const {
126 inline uint16 access2(
const uint32 offset)
const {
127 return (_buf[offset] | (_buf[offset + 1] << 8));
129 inline uint32 access4(
const uint32 offset)
const {
130 return _buf[offset] | (_buf[offset + 1] << 8) |
131 (_buf[offset + 2] << 16) | (_buf[offset + 3] << 24);
133 inline uint8 *access(
const uint32 offset) {
134 return _buf + offset;
136 inline uint8 *access() {
144 inline void assign1(
const uint32 offset,
const uint8 val) {
145 const_cast<uint8 *
>(_buf)[offset] = static_cast<uint8>(val & 0xFF);
147 inline void assign2(
const uint32 offset,
const uint16 val) {
148 const_cast<uint8 *
>(_buf)[offset] = static_cast<uint8>(val & 0xFF);
149 const_cast<uint8 *
>(_buf)[offset + 1] = static_cast<uint8>((val >> 8) & 0xFF);
151 inline void assign4(
const uint32 offset,
const uint32 val) {
152 const_cast<uint8 *
>(_buf)[offset] = static_cast<uint8>(val & 0xFF);
153 const_cast<uint8 *
>(_buf)[offset + 1] = static_cast<uint8>((val >> 8) & 0xFF);
154 const_cast<uint8 *
>(_buf)[offset + 2] = static_cast<uint8>((val >> 16) & 0xFF);
155 const_cast<uint8 *
>(_buf)[offset + 3] = static_cast<uint8>((val >> 24) & 0xFF);
157 inline void assign(
const uint32 offset,
const uint8 *in,
const uint32 len) {
158 memcpy(const_cast<uint8 *>(_buf) + offset, in, len);
169 #ifdef USE_DYNAMIC_UCSTACK 170 #define UCStack DynamicUCStack 176 #ifndef USE_DYNAMIC_UCSTACK 178 uint8 _bufArray[0x1000];
Definition: uc_stack.h:177
Definition: uc_stack.h:31
Definition: detection.h:27
Definition: uc_stack.h:162