mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-07 14:18:30 +03:00
Temp commit. Need to store all sh... Changes
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "header.hpp"
|
||||
|
||||
void f2_header_read(stream& s, f2_header* h) {
|
||||
memset(h, 0, sizeof(f2_header));
|
||||
|
||||
switch (s.type) {
|
||||
case STREAM_FILE:
|
||||
if (!s.io.stream)
|
||||
return;
|
||||
break;
|
||||
case STREAM_MEMORY:
|
||||
if (!s.io.data.vec.size())
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
s.read(h, 0x20);
|
||||
if (h->length == 0x40)
|
||||
s.read((uint8_t*)h + 0x20, 0x20);
|
||||
}
|
||||
|
||||
void f2_header_write(stream& s, f2_header* h, bool extended) {
|
||||
switch (s.type) {
|
||||
case STREAM_FILE:
|
||||
if (!s.io.stream)
|
||||
return;
|
||||
break;
|
||||
case STREAM_MEMORY:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
h->length = extended ? 0x40 : 0x20;
|
||||
s.write(h, h->length);
|
||||
}
|
||||
|
||||
void f2_header_write_end_of_container(stream& s, uint32_t depth) {
|
||||
switch (s.type) {
|
||||
case STREAM_FILE:
|
||||
if (!s.io.stream)
|
||||
return;
|
||||
break;
|
||||
case STREAM_MEMORY:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
f2_header h;
|
||||
memset(&h, 0, sizeof(f2_header));
|
||||
h.signature = reverse_endianness_uint32_t('EOFC');
|
||||
h.length = 0x20;
|
||||
h.depth = depth;
|
||||
h.use_section_size = true;
|
||||
f2_header_write(s, &h, false);
|
||||
}
|
||||
Reference in New Issue
Block a user