mirror of https://github.com/bsnes-emu/bsnes.git
Merge pull request #174 from Alcaro/master
Optimize serialization stuff a bit
This commit is contained in:
commit
53f8de6ac3
|
@ -8,6 +8,7 @@ auto PPU::serialize(serializer& s) -> void {
|
|||
s.array(cgram);
|
||||
for(auto& object : objects) object.serialize(s);
|
||||
|
||||
if (s.mode() == s.Load)
|
||||
for(auto address : range(32768)) updateTiledata(address);
|
||||
Line::start = 0;
|
||||
Line::count = 0;
|
||||
|
|
|
@ -110,6 +110,30 @@ struct serializer {
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<int N> auto array(uint8_t (&array_)[N]) -> serializer& {
|
||||
array(array_, N);
|
||||
return *this;
|
||||
}
|
||||
auto array(uint8_t* array, uint size) -> serializer& {
|
||||
if(_mode == Save) {
|
||||
memcpy(_data+_size, array, size);
|
||||
} else if(_mode == Load) {
|
||||
memcpy(array, _data+_size, size);
|
||||
}
|
||||
_size += size;
|
||||
return *this;
|
||||
}
|
||||
#ifdef ENDIAN_LSB
|
||||
template<int N> auto array(uint16_t (&array_)[N]) -> serializer& {
|
||||
array(array_, N);
|
||||
return *this;
|
||||
}
|
||||
auto array(uint16_t* array_, uint size) -> serializer& {
|
||||
array((uint8_t*)array_, size*2);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T, uint Size> auto array(nall::array<T[Size]>& array) -> serializer& {
|
||||
for(auto& value : array) operator()(value);
|
||||
return *this;
|
||||
|
|
Loading…
Reference in New Issue