Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.epfl.gameboj.component.memory;
- import java.util.Arrays;
- import ch.epfl.gameboj.Preconditions;
- public final class Ram {
- private final Byte[] memory;
- public Ram(int size) throws IllegalArgumentException{
- if (size < 0) {
- throw new IllegalArgumentException();
- }else {
- memory = new Byte[size];
- }
- }
- public int size() {
- return memory.length;
- }
- public final int read(int index) throws IndexOutOfBoundsException {
- return Byte.toUnsignedInt(memory[java.util.Objects.checkIndex(index,memory.length)]);
- }
- public void write(int index, int value) {
- memory[java.util.Objects.checkIndex(index,memory.length)] = (byte) Preconditions.checkBits8(value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement