-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowrooms.c
76 lines (59 loc) · 1.34 KB
/
showrooms.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define NUMROOMS 102
int main()
{
FILE *rd;
struct stat fs;
uint8_t *roomdata;
rd=fopen("roomdata.bin", "rb");
if (rd==NULL) return 1;
fstat(fileno(rd), &fs);
roomdata=malloc(fs.st_size);
if (roomdata!=NULL)
{
int room;
fread(roomdata, fs.st_size, 1, rd);
fclose(rd);
// Process it
for (room=0; room<(NUMROOMS-1); room++)
{
int start, end;
start=(roomdata[room*2]);
start=((roomdata[(room*2)+1]<<8)+start);
end=(roomdata[(room+1)*2]);
end=((roomdata[((room+1)*2)+1]<<8)+end);
if (end!=start)
{
int i;
printf("%d : 0x%.4x to 0x%.4x (len %d)\n", room, start, end, end-start);
printf(" ");
for (i=start; i<end; i+=3)
{
printf("[%.2x ", roomdata[(NUMROOMS*2)+i]);
printf("%dx%d", (roomdata[(NUMROOMS*2)+i+1]&0x7f)*2, roomdata[(NUMROOMS*2)+i+2]);
if (!(roomdata[(NUMROOMS*2)+i+1] & 0x80))
{
printf(" 0x%.2x]", roomdata[(NUMROOMS*2)+i+3]);
i++;
}
else
printf("]");
}
printf("\n");
}
}
free(roomdata);
}
else
{
fclose(rd);
return 1;
}
return 0;
}