class N65::INESHeader

This directive instruction can setup an ines header

Attributes

char[R]
mapper[R]
mirror[R]
prog[R]

Public Class Methods

new(prog, char, mapper, mirror) click to toggle source

Construct a header

# File lib/n65/directives/ines_header.rb, line 26
def initialize(prog, char, mapper, mirror)
  @prog, @char, @mapper, @mirror = prog, char, mapper, mirror
end
parse(line) click to toggle source

Implementation of the parser for this directive

# File lib/n65/directives/ines_header.rb, line 15
def self.parse(line)
  match_data = line.match(/^\.ines (.+)$/)
  return nil if match_data.nil?

  header = JSON.parse(match_data[1])
  INESHeader.new(header['prog'], header['char'], header['mapper'], header['mirror'])
end

Public Instance Methods

emit_bytes() click to toggle source

Emit the header bytes, this is not exactly right, but it works for now.

# File lib/n65/directives/ines_header.rb, line 40
def emit_bytes
  [0x4E, 0x45, 0x53, 0x1a, @prog, @char, @mapper, @mirror, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
end
exec(assembler) click to toggle source

Exec function the assembler will call

# File lib/n65/directives/ines_header.rb, line 33
def exec(assembler)
  assembler.set_ines_header(self)
end
to_s() click to toggle source

Display

# File lib/n65/directives/ines_header.rb, line 47
def to_s
  ".ines {\"prog\": #{@prog}, \"char\": #{@char}, \"mapper\": #{@mapper}, \"mirror\": #{@mirror}}"
end