Class: GBRb::CPU::Inc
- Inherits:
-
Instruction
- Object
- Instruction
- GBRb::CPU::Inc
- Defined in:
- lib/gbrb/cpu/instruction.rb
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
- #call(r, mem) ⇒ Object
-
#initialize(register, m = 1, t = 4, flags = true, indirect = false) ⇒ Inc
constructor
A new instance of Inc.
Methods inherited from Instruction
Constructor Details
#initialize(register, m = 1, t = 4, flags = true, indirect = false) ⇒ Inc
Returns a new instance of Inc.
57 58 59 60 61 62 63 64 |
# File 'lib/gbrb/cpu/instruction.rb', line 57 def initialize register, m=1, t=4, flags=true, indirect=false super m, t @register = register @flags = flags @op = :+ @indirect = indirect end |
Instance Method Details
#call(r, mem) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/gbrb/cpu/instruction.rb', line 66 def call r, mem reg = r.public_send(@register.to_sym) tmp = reg.read if @indirect v = mem.read_byte(tmp) + 1 mem.write_byte(tmp, v) else reg.store tmp + 1 end if @flags r.clear_add_sub_flag reg.zero? ? r.set_zero_flag : r.clear_zero_flag if carry? tmp, 0x01, reg.half_mask r.set_half_carry_flag else r.clear_half_carry_flag end end end |