Class: Rubyboy::Registers

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyboy/registers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegisters

Returns a new instance of Registers.



7
8
9
10
11
12
13
14
15
16
# File 'lib/rubyboy/registers.rb', line 7

def initialize
  @a = 0x01
  @b = 0x00
  @c = 0x13
  @d = 0x00
  @e = 0xd8
  @h = 0x01
  @l = 0x4d
  @f = 0xb0
end

Instance Attribute Details

#aObject

Returns the value of attribute a.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def a
  @a
end

#bObject

Returns the value of attribute b.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def b
  @b
end

#cObject

Returns the value of attribute c.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def c
  @c
end

#dObject

Returns the value of attribute d.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def d
  @d
end

#eObject

Returns the value of attribute e.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def e
  @e
end

#fObject

Returns the value of attribute f.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def f
  @f
end

#hObject

Returns the value of attribute h.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def h
  @h
end

#lObject

Returns the value of attribute l.



5
6
7
# File 'lib/rubyboy/registers.rb', line 5

def l
  @l
end

Instance Method Details

#afObject



50
51
52
# File 'lib/rubyboy/registers.rb', line 50

def af
  (@a << 8) | @f
end

#af=(value) ⇒ Object



66
67
68
69
# File 'lib/rubyboy/registers.rb', line 66

def af=(value)
  @a = (value >> 8) & 0xff
  @f = value & 0xf0
end

#bcObject



54
55
56
# File 'lib/rubyboy/registers.rb', line 54

def bc
  (@b << 8) | @c
end

#bc=(value) ⇒ Object



71
72
73
74
# File 'lib/rubyboy/registers.rb', line 71

def bc=(value)
  @b = (value >> 8) & 0xff
  @c = value & 0xff
end

#deObject



58
59
60
# File 'lib/rubyboy/registers.rb', line 58

def de
  (@d << 8) | @e
end

#de=(value) ⇒ Object



76
77
78
79
# File 'lib/rubyboy/registers.rb', line 76

def de=(value)
  @d = (value >> 8) & 0xff
  @e = value & 0xff
end

#hlObject



62
63
64
# File 'lib/rubyboy/registers.rb', line 62

def hl
  (@h << 8) | @l
end

#hl=(value) ⇒ Object



81
82
83
84
# File 'lib/rubyboy/registers.rb', line 81

def hl=(value)
  @h = (value >> 8) & 0xff
  @l = value & 0xff
end