Class: GBRb::CPU::RegisterEnsemble
- Inherits:
-
Object
- Object
- GBRb::CPU::RegisterEnsemble
- Defined in:
- lib/gbrb/cpu/register_ensemble.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#af ⇒ Object
Returns the value of attribute af.
-
#b ⇒ Object
Returns the value of attribute b.
-
#bc ⇒ Object
Returns the value of attribute bc.
-
#c ⇒ Object
Returns the value of attribute c.
-
#d ⇒ Object
Returns the value of attribute d.
-
#de ⇒ Object
Returns the value of attribute de.
-
#e ⇒ Object
Returns the value of attribute e.
-
#f ⇒ Object
Returns the value of attribute f.
-
#h ⇒ Object
Returns the value of attribute h.
-
#hl ⇒ Object
Returns the value of attribute hl.
-
#l ⇒ Object
Returns the value of attribute l.
-
#m ⇒ Object
Returns the value of attribute m.
-
#pc ⇒ Object
Returns the value of attribute pc.
-
#sp ⇒ Object
Returns the value of attribute sp.
-
#t ⇒ Object
Returns the value of attribute t.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ RegisterEnsemble
constructor
A new instance of RegisterEnsemble.
- #method_missing(m, *a, &b) ⇒ Object
Constructor Details
#initialize ⇒ RegisterEnsemble
Returns a new instance of RegisterEnsemble.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 10 def initialize @a = Register.new @b = Register.new @c = Register.new @d = Register.new @e = Register.new @h = Register.new @l = Register.new @f = FlagsRegister.new @pc = Register.new(0x0000, 16) @sp = Register.new(0x0000, 16) @m = Register.new @t = Register.new @bc = ConcatenatedRegister.new @b, @c @de = ConcatenatedRegister.new @d, @e @hl = ConcatenatedRegister.new @h, @l @af = ConcatenatedRegister.new @a, @f end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 41 def method_missing m, *a, &b case m when /\Aset_.*_flag\z/ f.public_send m when /\Aclear_.*_flag\z/ f.public_send m when /\A.*_flag\?\z/ f.public_send m else super m, a, b end end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def a @a end |
#af ⇒ Object
Returns the value of attribute af.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def af @af end |
#b ⇒ Object
Returns the value of attribute b.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def b @b end |
#bc ⇒ Object
Returns the value of attribute bc.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def bc @bc end |
#c ⇒ Object
Returns the value of attribute c.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def c @c end |
#d ⇒ Object
Returns the value of attribute d.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def d @d end |
#de ⇒ Object
Returns the value of attribute de.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def de @de end |
#e ⇒ Object
Returns the value of attribute e.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def e @e end |
#f ⇒ Object
Returns the value of attribute f.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def f @f end |
#h ⇒ Object
Returns the value of attribute h.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def h @h end |
#hl ⇒ Object
Returns the value of attribute hl.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def hl @hl end |
#l ⇒ Object
Returns the value of attribute l.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def l @l end |
#m ⇒ Object
Returns the value of attribute m.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def m @m end |
#pc ⇒ Object
Returns the value of attribute pc.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def pc @pc end |
#sp ⇒ Object
Returns the value of attribute sp.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def sp @sp end |
#t ⇒ Object
Returns the value of attribute t.
8 9 10 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 8 def t @t end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 37 def == other register_list.inject(true){|result, el| result && public_send(el) == other.public_send(el)} end |
#each(&block) ⇒ Object
33 34 35 |
# File 'lib/gbrb/cpu/register_ensemble.rb', line 33 def each &block [@pc, @sp, @a, @b, @c, @d, @e, @h, @l, @f].each &block end |