forked from audetto/AppleWin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libretro: include DiscControl in save state.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
- Loading branch information
Showing
6 changed files
with
160 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <cstddef> | ||
#include <stdexcept> | ||
|
||
namespace ra2 | ||
{ | ||
|
||
template<typename C> // so it works with both char * and const char * | ||
class Buffer | ||
{ | ||
public: | ||
Buffer(C * const begin, size_t const size) : myPtr(begin), myEnd(begin + size) | ||
{ | ||
|
||
} | ||
|
||
template <typename T> | ||
T & get() | ||
{ | ||
C * c = myPtr; | ||
advance(sizeof(T)); | ||
return *reinterpret_cast<T *>(c); | ||
} | ||
|
||
void get(size_t const size, C * & begin, C * & end) | ||
{ | ||
begin = myPtr; | ||
advance(size); | ||
end = myPtr; | ||
} | ||
|
||
private: | ||
C * myPtr; | ||
C * const myEnd; | ||
|
||
void advance(size_t const size) | ||
{ | ||
if (myPtr + size > myEnd) | ||
{ | ||
throw std::runtime_error("Buffer: out of bounds"); | ||
} | ||
myPtr += size; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters