1 /*
2 * KCemu -- The emulator for the KC85 homecomputer series and much more.
3 * Copyright (C) 1997-2010 Torsten Paul
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include <string.h>
21
22 #include "kc/system.h"
23
24 #include "kc/kc.h"
25 #include "kc/mod_ram8.h"
26
ModuleRAM8(ModuleRAM8 & tmpl)27 ModuleRAM8::ModuleRAM8(ModuleRAM8 &tmpl) :
28 ModuleInterface(tmpl.get_name(), tmpl.get_id(), tmpl.get_type())
29 {
30 _group = NULL;
31 _size = tmpl._size;
32 _ram = new byte_t[_size];
33 _addr = tmpl._addr;
34 if (_ram)
35 {
36 memset(_ram, 0, _size);
37 set_valid(true);
38 }
39 _group = memory->register_memory(get_name(), _addr, _size, _ram, 0, 0);
40 }
41
ModuleRAM8(const char * name,word_t addr,dword_t size)42 ModuleRAM8::ModuleRAM8(const char *name, word_t addr, dword_t size) :
43 ModuleInterface(name, 0, KC_MODULE_LC_80)
44 {
45 _size = size;
46 _ram = new byte_t[_size];
47 _addr = addr;
48 if (_ram)
49 {
50 _group = 0;
51 memset(_ram, 0, _size);
52 set_valid(true);
53 }
54 }
55
~ModuleRAM8(void)56 ModuleRAM8::~ModuleRAM8(void)
57 {
58 if (_group) memory->unregister_memory(_group);
59 delete[] _ram;
60 }
61
62 void
m_out(word_t addr,byte_t val)63 ModuleRAM8::m_out(word_t addr, byte_t val)
64 {
65 }
66
67 ModuleInterface *
clone(void)68 ModuleRAM8::clone(void)
69 {
70 return new ModuleRAM8(*this);
71 }
72
73 void
reset(bool power_on)74 ModuleRAM8::reset(bool power_on)
75 {
76 if (power_on)
77 Memory::scratch_mem(_ram, _size);
78 }
79