-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilities.cpp
More file actions
50 lines (45 loc) · 814 Bytes
/
Utilities.cpp
File metadata and controls
50 lines (45 loc) · 814 Bytes
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
#include <windows.h>
#include "internal.h"
#define MAGIC_NUMBER (0xdeadbeef)
bool PutHintingData(unsigned char *video, unsigned int hint)
{
unsigned char *p;
unsigned int i, magic_number = MAGIC_NUMBER;
bool error = false;
p = video;
for (i = 0; i < 32; i++)
{
*p &= ~1;
*p++ |= ((magic_number & (1 << i)) >> i);
}
for (i = 0; i < 32; i++)
{
*p &= ~1;
*p++ |= ((hint & (1 << i)) >> i);
}
return error;
}
bool GetHintingData(unsigned char *video, unsigned int *hint)
{
unsigned char *p;
unsigned int i, magic_number = 0;
bool error = false;
p = video;
for (i = 0; i < 32; i++)
{
magic_number |= ((*p++ & 1) << i);
}
if (magic_number != MAGIC_NUMBER)
{
error = true;
}
else
{
*hint = 0;
for (i = 0; i < 32; i++)
{
*hint |= ((*p++ & 1) << i);
}
}
return error;
}