Class: GBRb::InstructionSet::Bit
- Inherits:
-
Instruction
- Object
- Instruction
- GBRb::InstructionSet::Bit
- Defined in:
- lib/gbrb/instruction_set/bitwise.rb
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
- #call(r, mem) ⇒ Object
-
#initialize(bit, target, indirect = false, m = 2, t = 8) ⇒ Bit
constructor
A new instance of Bit.
Methods inherited from Instruction
Constructor Details
#initialize(bit, target, indirect = false, m = 2, t = 8) ⇒ Bit
Returns a new instance of Bit.
44 45 46 47 48 49 50 |
# File 'lib/gbrb/instruction_set/bitwise.rb', line 44 def initialize bit, target, indirect=false, m=2, t=8 super m,t @target = target @bit = bit @indirect = indirect @mask = 1 << @bit end |
Instance Method Details
#call(r, mem) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gbrb/instruction_set/bitwise.rb', line 52 def call r, mem if @indirect v = mem.read_byte r.public_send(@target).read else v = r.public_send(@target).read end v & @mask != @mask ? r.set_zero_flag : r.clear_zero_flag r.set_half_carry_flag r.clear_add_sub_flag end |