-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrenderware.cpp
More file actions
114 lines (99 loc) · 2.4 KB
/
renderware.cpp
File metadata and controls
114 lines (99 loc) · 2.4 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "renderware.h"
bool HeaderInfo::read(char *bytes, size_t *offset)
{
uint32_t buf[3];
// rw.read((char*)buf, 12);
memcpy(buf, &bytes[*offset], sizeof(buf));
*offset += sizeof(buf);
//if(rw.eof())
// return false;
type = buf[0];
length = buf[1];
build = buf[2];
if(build & 0xFFFF0000)
version = ((build >> 14) & 0x3FF00) |
((build >> 16) & 0x3F) |
0x30000;
else
version = build << 8;
return true;
}
bool HeaderInfo::peek(size_t *offset)
{
//if(!read(rw))
// return false;
*offset -= 12;
// rw.seekg(-12, ios::cur);
return true;
}
bool HeaderInfo::findChunk(char *bytes, size_t *offset, uint32_t type)
{
while(read(bytes, offset)){
if(this->type == CHUNK_NAOBJECT)
return false;
if(this->type == type)
return true;
*offset = length; // , ios::cur);
}
return false;
}
//void ChunkNotFound(enum CHUNK_TYPE chunk, uint32_t address)
//{
// printf("[Error] Chunk not found at 0x%.12\n", address);
//}
int8_t readInt8(char *bytes, size_t *offset)
{
int8_t tmp;
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
// rw.read(reinterpret_cast <char *> (&tmp), sizeof(int8_t));
return tmp;
}
uint8_t readUInt8(char *bytes, size_t *offset)
{
uint8_t tmp;
//rw.read(reinterpret_cast <char *> (&tmp), sizeof(uint8_t));
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
return tmp;
}
int16_t readInt16(char *bytes, size_t *offset)
{
int16_t tmp;
//rw.read(reinterpret_cast <char *> (&tmp), sizeof(int16_t));
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
return tmp;
}
uint16_t readUInt16(char *bytes, size_t *offset)
{
uint16_t tmp;
//rw.read(reinterpret_cast <char *> (&tmp), sizeof(uint16_t));
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
return tmp;
}
int32_t readInt32(char *bytes, size_t *offset)
{
int32_t tmp;
//rw.read(reinterpret_cast <char *> (&tmp), sizeof(int32_t));
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
return tmp;
}
uint32_t readUInt32(char *bytes, size_t *offset)
{
uint32_t tmp;
//rw.read(reinterpret_cast <char *> (&tmp), sizeof(uint32_t));
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
return tmp;
}
float readFloat32(char *bytes, size_t *offset)
{
float tmp;
//rw.read(reinterpret_cast <char *> (&tmp), sizeof(float));
memcpy(&tmp, &bytes[*offset], sizeof(tmp));
*offset += sizeof(tmp);
return tmp;
}