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
1 change: 0 additions & 1 deletion dwarf/SB/Game/zTalkBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4637,4 +4637,3 @@ static enum state_enum update() {
// Range: 0x322690 -> 0x322698
}
}

30 changes: 17 additions & 13 deletions src/SB/Core/x/containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ template <class T> struct static_queue
U32 _max_size_mask;
T* _buffer;

struct iterator {
struct iterator
{
U32 _it;
static_queue<T>* _owner;

Expand All @@ -68,12 +69,12 @@ template <class T> struct static_queue
return this;
}
};

bool empty() const
{
return size() == 0;
}

U32 size() const
{
return _size;
Expand All @@ -93,7 +94,7 @@ template <class T> struct static_queue
_buffer = (T*)xMemAlloc(gActiveHeap, sizeof(T) * (size), 0);
clear();
}

void clear()
{
_size = 0;
Expand Down Expand Up @@ -140,7 +141,7 @@ template <class T> struct static_queue
{
return size() == max_size();
}

U32 max_size() const
{
return _max_size - 1;
Expand All @@ -160,7 +161,7 @@ template <class T> struct static_queue
_size -= mod_max_size(other._it - it._it);
}
}

iterator end() const
{
iterator it;
Expand Down Expand Up @@ -190,19 +191,22 @@ template <class T, U32 N> struct fixed_queue
}
void pop_front()
{
_first = (_first + 1) & N;
_first = (_first + 1) % (N + 1);
}
void push_front()
{
_first = (_first + N) & N;
_first = (_first + N) & N;
}
void push_front(const T& data)
{
push_front();
T& new_front = front();
new_front = data;
}
void push_back();
void push_back()
{
_last = (_last + 1) % (N + 1);
}
U32 max_size() const
{
return N;
Expand All @@ -229,7 +233,8 @@ template <class T, U32 N> struct fixed_queue
return _last - _first;
}

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

Expand All @@ -245,8 +250,8 @@ template <class T, U32 N> struct fixed_queue

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

Expand Down Expand Up @@ -296,5 +301,4 @@ template <class T, U32 N> struct fixed_queue
return create_iterator(_last);
}
};

#endif
11 changes: 6 additions & 5 deletions src/SB/Core/x/xFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ struct xtextbox
void* context;
basic_rect<F32> bounds;
basic_rect<F32> render_bounds;
const callback* cb;
tag_type* tag;
const callback* cb; //0x34
tag_type* tag; //0x38

void intersect_flags(const jot& other);
void reset_flags();
Expand Down Expand Up @@ -138,9 +138,9 @@ struct xtextbox
struct tag_entry
{
substr name;
char op;
substr* args;
size_t args_size;
char op; //0x08
substr* args; //0x0C
size_t args_size; //0x10
};

struct tag_entry_list
Expand Down Expand Up @@ -274,6 +274,7 @@ struct xtextbox::layout
F32 yextent(F32 max, S32& size, S32 begin_jot, S32 end_jot) const;
bool changed(const xtextbox& ctb);
size_t jots_size() const;
jot* jots() const;
};

void render_fill_rect(const basic_rect<F32>& bounds, iColor_tag color);
Expand Down
63 changes: 63 additions & 0 deletions src/SB/Core/x/xSnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,69 @@ template <S32 N> struct sound_queue
void play(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags, U32 parentID,
sound_category snd_category);
void push(U32 id);

void pop()
{
xSndStop(_playing[head]);
head = (head + 1) % (N + 1);
}
S32 size() const
{
if (tail >= head)
{
return tail - head;
}
return tail + (N + 1) - head;
}
void clear()
{
while (size() > 0)
{
pop();
}
}
U32 recent(S32 index) const
{
S32 i = tail - index - 1;
if (i < 0)
{
i += (N + 1);
}
return _playing[i];
}
bool playing(S32 index, bool streaming) const
{
S32 count = size();
S32 i;

if (index < 0 || index > count)
{
index = count;
}

if (streaming)
{
for (i = 0; i < index; i++)
{
if (!xSndIsPlayingByHandle(recent(i)))
{
return false;
}
}
return true;
}
else
{
for (i = 0; i < index; i++)
{
if (xSndIsPlayingByHandle(recent(i)))
{
return true;
}
}
return false;
}
}
};

enum sound_effect
Expand Down
Loading