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,7 +8,8 @@ auto PPU::serialize(serializer& s) -> void {
|
||||||
s.array(cgram);
|
s.array(cgram);
|
||||||
for(auto& object : objects) object.serialize(s);
|
for(auto& object : objects) object.serialize(s);
|
||||||
|
|
||||||
for(auto address : range(32768)) updateTiledata(address);
|
if (s.mode() == s.Load)
|
||||||
|
for(auto address : range(32768)) updateTiledata(address);
|
||||||
Line::start = 0;
|
Line::start = 0;
|
||||||
Line::count = 0;
|
Line::count = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,30 @@ struct serializer {
|
||||||
return *this;
|
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& {
|
template<typename T, uint Size> auto array(nall::array<T[Size]>& array) -> serializer& {
|
||||||
for(auto& value : array) operator()(value);
|
for(auto& value : array) operator()(value);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
Loading…
Reference in New Issue