Created
August 7, 2015 10:06
-
-
Save daphee/cc098a947d83e440922c to your computer and use it in GitHub Desktop.
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
class MemoryCursor | |
property :addr | |
def initialize @memory, @addr | |
@chunk = Array(UInt8).new | |
end | |
def read_byte | |
@chunk << @memory.read_byte @addr | |
@addr += 1 | |
@memory.read_byte addr - 1 | |
end | |
def read_word | |
@chunk << @memory.read_byte @addr | |
@chunk << @memory.read_byte @addr + 1 | |
@addr += 2 | |
@memory.read_word addr - 2 | |
end | |
def start_new_chunk | |
@chunk = Array(UInt8).new | |
end | |
def get_chunk | |
@chunk | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment