Class: Amaterasu::GameBoy::Cpu::Instructions::Misc
- Defined in:
- lib/amaterasu/game_boy/cpu/instructions/misc.rb,
sig/akane/game_boy/cpu/instructions/misc.rbs
Overview
Holds the logic for CPL, SCF and CCF instructions.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #build_logic(operation) ⇒ Proc
-
#ccf ⇒ void
Complement the Carry flag.
-
#cpl ⇒ void
Complement the value from the A register.
-
#initialize(cpu:, operation:) ⇒ Misc
constructor
A new instance of Misc.
-
#scf ⇒ void
Set Carry flag.
Methods inherited from Base
Constructor Details
#initialize(cpu:, operation:) ⇒ Misc
Returns a new instance of Misc.
9 10 11 12 13 14 |
# File 'lib/amaterasu/game_boy/cpu/instructions/misc.rb', line 9 def initialize(cpu:, operation:) super(cpu:) @mnemonic = format_operand(operation) @logic = build_logic(operation) end |
Instance Method Details
#build_logic(operation) ⇒ Proc
18 19 20 21 22 23 24 25 26 |
# File 'lib/amaterasu/game_boy/cpu/instructions/misc.rb', line 18 def build_logic(operation) case operation when :cpl then -> { cpl } when :scf then -> { scf } when :ccf then -> { ccf } else raise ArgumentError, 'Unknown Misc operation' end end |
#ccf ⇒ void
This method returns an undefined value.
Complement the Carry flag.
36 37 38 39 40 |
# File 'lib/amaterasu/game_boy/cpu/instructions/misc.rb', line 36 def ccf @registers.n_flag = false @registers.h_flag = false @registers.c_flag = @registers.c_flag.zero? end |
#cpl ⇒ void
This method returns an undefined value.
Complement the value from the A register.
43 44 45 46 47 48 |
# File 'lib/amaterasu/game_boy/cpu/instructions/misc.rb', line 43 def cpl @registers.a = ~@registers.a @registers.n_flag = true @registers.h_flag = true end |
#scf ⇒ void
This method returns an undefined value.
Set Carry flag.
29 30 31 32 33 |
# File 'lib/amaterasu/game_boy/cpu/instructions/misc.rb', line 29 def scf @registers.n_flag = false @registers.h_flag = false @registers.c_flag = true end |