Skip to content

Instantly share code, notes, and snippets.

@daphee
Created August 7, 2015 10:06
Show Gist options
  • Save daphee/cc098a947d83e440922c to your computer and use it in GitHub Desktop.
Save daphee/cc098a947d83e440922c to your computer and use it in GitHub Desktop.
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