SIEdit/lib/sitypes.cpp

124 lines
2 KiB
C++
Raw Normal View History

2022-07-03 11:57:43 -04:00
#include "sitypes.h"
2022-07-18 03:27:00 -04:00
#include "util.h"
2022-07-03 11:57:43 -04:00
namespace si {
const char *MxOb::GetTypeName(Type type)
{
switch (type) {
2022-07-11 04:48:20 -04:00
case Video:
2022-07-03 11:57:43 -04:00
return "SMK";
2022-07-11 04:48:20 -04:00
case Sound:
2022-07-03 11:57:43 -04:00
return "WAV";
case Presenter:
return "MxPresenter";
case Bitmap:
2022-07-03 11:57:43 -04:00
return "BMP";
case Object:
2022-07-03 11:57:43 -04:00
return "3D Object";
case World:
return "World";
case Event:
return "Event";
case Animation:
return "Animation";
case Null:
2022-07-03 11:57:43 -04:00
case TYPE_COUNT:
break;
}
return "Unknown";
}
std::vector<const char*> MxOb::GetFlagsName(Flags flags)
{
std::vector<const char*> names;
if (flags == FLAGS_COUNT) {
return names;
}
if (flags & Transparent) {
names.push_back("Transparent");
}
if (flags & NoLoop) {
names.push_back("NoLoop");
}
if (flags & LoopCache) {
names.push_back("LoopCache");
}
if (flags & LoopStream) {
names.push_back("LoopStream");
}
if (flags & Unknown) {
names.push_back("Unknown");
}
return names;
}
2022-07-18 03:27:00 -04:00
const char *RIFF::GetTypeDescription(Type t)
{
switch (t) {
case RIFF_:
return "Resource Interchange File Format";
case LIST:
return "List of sub-elements";
case MxSt:
return "Stream";
case MxHd:
return "Interleaf Header";
case MxCh:
return "Data Chunk";
case MxOf:
return "Offset Table";
case pad_:
return "Padding";
case MxOb:
return "Streamable Object";
case MxDa:
return "Data";
case WAVE:
return "WAVE";
case fmt_:
return "WAVE Format";
case OMNI:
return "OMNI";
case data:
return "WAVE Data";
}
return "Unknown";
}
2022-07-18 14:25:00 -04:00
RIFF::Chk RIFF::BeginChunk(FileBase *f, uint32_t type)
2022-07-18 03:27:00 -04:00
{
Chk stat;
2022-07-18 14:25:00 -04:00
f->WriteU32(type);
stat.size_position = f->pos();
f->WriteU32(0);
stat.data_start = f->pos();
2022-07-18 03:27:00 -04:00
return stat;
}
2022-07-18 14:25:00 -04:00
void RIFF::EndChunk(FileBase *f, const Chk &stat)
2022-07-18 03:27:00 -04:00
{
2022-07-18 14:26:26 -04:00
size_t now = f->pos();
2022-07-18 03:27:00 -04:00
uint32_t sz = now - stat.data_start;
2022-07-18 14:25:00 -04:00
f->seek(stat.size_position);
f->WriteU32(sz);
2022-07-18 03:27:00 -04:00
2022-07-18 14:25:00 -04:00
f->seek(now);
2022-07-18 03:27:00 -04:00
if (sz%2 == 1) {
2022-07-18 14:25:00 -04:00
f->WriteU8(0);
2022-07-18 03:27:00 -04:00
}
}
2022-07-03 11:57:43 -04:00
}