Class: GBRb::CPU::Boolean

Inherits:
Instruction show all
Defined in:
lib/gbrb/cpu/instruction.rb

Direct Known Subclasses

And, Or, Xor

Instance Attribute Summary

Attributes inherited from Instruction

#i, #m, #t

Instance Method Summary collapse

Methods inherited from Instruction

#carry?, #immediate_count

Constructor Details

#initialize(target, m, t, indirect, immediates = 0) ⇒ Boolean



438
439
440
441
442
# File 'lib/gbrb/cpu/instruction.rb', line 438

def initialize target, m, t, indirect, immediates=0
  @target = target
  @indirect = indirect
  super m, t, immediates
end

Instance Method Details

#call(r, mem, v = nil) ⇒ Object



444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/gbrb/cpu/instruction.rb', line 444

def call r, mem, v=nil
  if v
    value = v
  else
    value = r.public_send(@target.to_sym).read
    value = mem.read_byte value if @indirect
  end
  r.a.store r.a.read.public_send(@op, value)
  r.a.zero? ? r.set_zero_flag : r.clear_zero_flag
  r.clear_carry_flag
  r.clear_add_sub_flag
end