MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / gmext_read_stream

Function gmext_read_stream

src/Engine/GMCat.cpp:52–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50};
51
52static int gmext_read_stream (struct gmstream *p,
53 unsigned int n, const unsigned char *data)
54{
55 if (!n--)
56 return -1;
57 p->tempo = *data++;
58
59 // subsequences
60 if (!n--)
61 return -1;
62 p->nsubs = *data++;
63
64 for (int i=0; i<p->nsubs; ++i) {
65 if (n < 4)
66 return -1;
67 unsigned int s = read_uint32_le(data);
68 if (s < 4)
69 return -1;
70 p->subs[i].size = s - 4;
71 p->subs[i].data = data + 4;
72 n -= s;
73 data += s;
74 }
75
76 // tracks
77 if (!n--)
78 return -1;
79 p->ntracks = *data++;
80
81 for (int i=0; i<p->ntracks; ++i) {
82 if (n-- < 5)
83 return -1;
84 p->tracks[i].channel = *data++;
85 unsigned int s = read_uint32_le(data);
86 if (s < 4)
87 return -1;
88 p->tracks[i].seq.size = s - 4;
89 p->tracks[i].seq.data = data + 4;
90 n -= s;
91 data += s;
92 }
93
94 return n ? -1 : 0;
95}
96
97static inline void gmext_write_int16 (std::vector<unsigned char> &midi,
98 unsigned int n)

Callers 1

loadMIDIMethod · 0.85

Calls 1

read_uint32_leFunction · 0.85

Tested by

no test coverage detected