Class: N65::INESHeader
- Inherits:
-
InstructionBase
- Object
- InstructionBase
- N65::INESHeader
- Defined in:
- lib/n65/directives/ines_header.rb
Overview
This directive instruction can setup an ines header
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
-
#mapper ⇒ Object
readonly
Returns the value of attribute mapper.
-
#mirror ⇒ Object
readonly
Returns the value of attribute mirror.
-
#prog ⇒ Object
readonly
Returns the value of attribute prog.
Class Method Summary collapse
-
.parse(line) ⇒ Object
Implementation of the parser for this directive.
Instance Method Summary collapse
-
#emit_bytes ⇒ Object
Emit the header bytes, this is not exactly right, but it works for now.
-
#exec(assembler) ⇒ Object
Exec function the assembler will call.
-
#initialize(prog, char, mapper, mirror) ⇒ INESHeader
constructor
Construct a header.
-
#to_s ⇒ Object
Display.
Methods inherited from InstructionBase
Constructor Details
#initialize(prog, char, mapper, mirror) ⇒ INESHeader
Construct a header
26 27 28 |
# File 'lib/n65/directives/ines_header.rb', line 26 def initialize(prog, char, mapper, mirror) @prog, @char, @mapper, @mirror = prog, char, mapper, mirror end |
Instance Attribute Details
#char ⇒ Object (readonly)
Returns the value of attribute char.
10 11 12 |
# File 'lib/n65/directives/ines_header.rb', line 10 def char @char end |
#mapper ⇒ Object (readonly)
Returns the value of attribute mapper.
10 11 12 |
# File 'lib/n65/directives/ines_header.rb', line 10 def mapper @mapper end |
#mirror ⇒ Object (readonly)
Returns the value of attribute mirror.
10 11 12 |
# File 'lib/n65/directives/ines_header.rb', line 10 def mirror @mirror end |
#prog ⇒ Object (readonly)
Returns the value of attribute prog.
10 11 12 |
# File 'lib/n65/directives/ines_header.rb', line 10 def prog @prog end |
Class Method Details
.parse(line) ⇒ Object
Implementation of the parser for this directive
15 16 17 18 19 20 21 |
# 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 |
Instance Method Details
#emit_bytes ⇒ Object
Emit the header bytes, this is not exactly right, but it works for now.
40 41 42 |
# 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) ⇒ Object
Exec function the assembler will call
33 34 35 |
# File 'lib/n65/directives/ines_header.rb', line 33 def exec(assembler) assembler.set_ines_header(self) end |
#to_s ⇒ Object
Display
47 48 49 |
# File 'lib/n65/directives/ines_header.rb', line 47 def to_s ".ines {\"prog\": #{@prog}, \"char\": #{@char}, \"mapper\": #{@mapper}, \"mirror\": #{@mirror}}" end |