-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBus.cs
More file actions
52 lines (46 loc) · 1.04 KB
/
Bus.cs
File metadata and controls
52 lines (46 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Text;
namespace Emulators
{
public class Bus : IBus
{
private byte _size = 0;
public byte Size
{
get => _size;
set
{
if (value <= 64)
{
_size = value;
ram = new byte[_size * 1024];
ClearRam();
}
}
}
private void ClearRam()
{
Array.Clear(ram, 0, _size * 1024);
}
//ram
byte[] ram;
public Bus(byte size)
{
Size = size;
}
//read/write methods
public void Write(ushort addr, byte data)
{
if (addr >= 0x0000 && addr < _size * 1024)
ram[addr] = data;
}
public byte Read(ushort addr)
{
if (addr >= 0x0000 && addr < _size * 1024)
return ram[addr];
else
return 0x00;
}
}
}