1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-06-23 17:29:43 +00:00
r65emu/ram.h

23 lines
525 B
C
Raw Normal View History

2014-11-10 14:16:45 +00:00
#ifndef __RAM_H__
#define __RAM_H__
2014-10-18 11:33:48 +00:00
2023-11-18 10:57:40 +00:00
template<unsigned n = 1024>
2014-10-21 18:41:44 +00:00
class ram: public Memory::Device {
2014-10-18 11:33:48 +00:00
public:
2023-11-18 10:57:40 +00:00
static const unsigned page_size = n;
2021-02-17 14:49:40 +00:00
2018-08-13 13:41:23 +00:00
virtual void operator= (uint8_t c) { _mem[_acc] = c; }
virtual operator uint8_t () { return _mem[_acc]; }
2014-10-18 11:33:48 +00:00
2019-02-24 11:50:10 +00:00
#if !defined NO_CHECKPOINT
virtual void checkpoint(Stream &s) { s.write(_mem, sizeof(_mem)); }
virtual void restore(Stream &s) { s.readBytes((char *)_mem, sizeof(_mem)); }
2019-02-24 11:50:10 +00:00
#endif
2014-10-18 11:33:48 +00:00
ram (): Memory::Device(sizeof(_mem)) {}
2014-10-18 11:33:48 +00:00
private:
2021-02-17 14:49:40 +00:00
uint8_t _mem[page_size];
2014-10-18 11:33:48 +00:00
};
#endif