Class: C8dasm::Chip8Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/c8dasm/chip8_reader.rb

Overview

Read a Chip-8 binary file.

Examples

reader = Chip8Reader.new('./MAZE')
p reader.opcodes.first
#=> "a21e"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Chip8Reader

Creates a Chip8Reader instance.

filename - The String name of the binary file to read.



15
16
17
18
19
20
# File 'lib/c8dasm/chip8_reader.rb', line 15

def initialize(filename)
  @file = File.new(filename, 'rb')
  @opcodes = []
  binaries_to_opcodes
  @file.close
end

Instance Attribute Details

#opcodesObject (readonly)

Returns an Array of String Chip-8 opcodes.



23
24
25
# File 'lib/c8dasm/chip8_reader.rb', line 23

def opcodes
  @opcodes
end