-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoart.cpp
More file actions
70 lines (64 loc) · 1.36 KB
/
foart.cpp
File metadata and controls
70 lines (64 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "foart.h"
void file_t::read(ByteReader* reader)
{
check_num1 = reader->u8();
if (check_num1 != 42) return;
hdr_t newHdr;
newHdr.read(reader);
hdr = newHdr;
for (size_t i = 0; i < hdr.dirs; i++)
{
data_t currData;
currData.hdr_ptr = &hdr;
currData.read(reader);
data.push_back(currData);
}
}
void hdr_t::read(ByteReader* reader)
{
frames_count = reader->u16();
anim_ticks = reader->u16();
dirs = reader->u8();
}
void data_t::read(ByteReader* reader)
{
offs_x = reader->i16();
offs_y = reader->i16();
for (size_t i = 0; i < hdr_ptr->frames_count; i++)
{
frame_t currFrame;
currFrame.read(reader);
frames.push_back(currFrame);
}
}
void frame_t::read(ByteReader* reader)
{
is_shared = reader->u8() > 0;
if(!is_shared)
{
width = reader->u16();
height = reader->u16();
next_x = reader->i16();
next_y = reader->i16();
for (size_t i = 0, len = width * height; i < len; i++)
{
ucolor currPixel{ reader->u8(), reader->u8(), reader->u8(), reader->u8() };
pixels.push_back(currPixel);
}
}
else
{
shared_indx = reader->u16();
}
}
void oldfile_t::read(ByteReader* reader)
{
width = reader->u32();
height = reader->u32();
if(width == 1196314761) return;
for (size_t i = 0, len = width * height; i < len; i++)
{
ucolor currPixel{ reader->u8(), reader->u8(), reader->u8(), reader->u8() };
pixels.push_back(currPixel);
}
}