Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 120 additions & 9 deletions src/SB/Core/x/containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,127 @@ template <class T, U32 N> struct fixed_queue
U32 _last;
T _buffer[N + 1];

void reset();
void front();
void pop_front();
void push_front(const T& element);
void reset()
{
clear();
}
void clear()
{
_last = 0;
_first = 0;
}
T& front()
{
fixed_queue<T, N>::iterator it = begin();
return *it;
}
void pop_front()
{
_first = (_first + 1) & N;
}
void push_front()
{
_first = (_first + N) & N;
}
void push_front(const T& data)
{
push_front();
T& new_front = front();
new_front = data;
}
void push_back();
bool full() const;
void back();
void pop_back();
bool empty() const;
U32 size() const;
U32 max_size() const
{
return N;
}
bool full() const
{
return size() == max_size();
}
T& back()
{
fixed_queue<T, N>::iterator it = end() - 1;
return *it;
}
void pop_back()
{
_last = (_last + N) & N;
}
bool empty() const
{
return _last == _first;
}
U32 size() const
{
return _last - _first;
}

struct iterator {
U32 _it;
fixed_queue<T, N>* _owner;

T& operator*() const
{
return _owner->_buffer[_it];
}

bool operator!=(const iterator& other) const
{
return _it != other._it;
}

iterator* operator+=(S32 value)
{
value += _it;
_it = (value + N) & N;
return this;
}

iterator* operator-=(S32 value)
{
iterator* tmp = operator+=(-value);
return tmp;
}

iterator* operator--()
{
*this -= 1;
return this;
}

iterator operator-(S32 value) const
{
iterator tmp;
tmp._it = _it;
tmp._owner = _owner;
tmp -= value;
return tmp;
}

iterator* operator++()
{
*this += 1;
return this;
}
};

iterator create_iterator(u32 initial_location) const
{
iterator it;
it._it = initial_location;
it._owner = const_cast<fixed_queue<T, N>*>(this);
return it;
}

iterator begin() const
{
return create_iterator(_first);
}

iterator end() const
{
return create_iterator(_last);
}
};

#endif
4 changes: 4 additions & 0 deletions src/SB/Core/x/xSnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ void xSndStopAll(U32 mask)
xSndDelayedInit();
}

void xSndStopFade(U32 id, F32 fade_time)
{
}

void xSndSetCategoryVol(sound_category category, F32 vol)
{
gSnd.categoryVolFader[category] = vol;
Expand Down
1 change: 1 addition & 0 deletions src/SB/Core/x/xSnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void xSndSetVol(U32 snd, F32 vol);
void xSndSetPitch(U32 snd, F32 pitch);
void xSndStop(U32 snd);
void xSndStopAll(U32 mask);
void xSndStopFade(U32, F32);
void xSndPauseAll(U32 pause_effects, U32 pause_streams);
void xSndPauseCategory(U32 mask, U32 pause);
void xSndDelayedInit();
Expand Down
Loading