From beb23b537bf8bba03b4ea989b31fbedf828538c5 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 10 May 2020 14:13:34 +0200 Subject: [PATCH 1/2] Remove duplicate assignment to @f and duplicate attr_reader --- lib/waterfoul/cpu.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/waterfoul/cpu.rb b/lib/waterfoul/cpu.rb index 2d30f0b..2f93ddb 100644 --- a/lib/waterfoul/cpu.rb +++ b/lib/waterfoul/cpu.rb @@ -43,7 +43,7 @@ module Waterfoul include Instructions::Prefix # 8 bit registers - attr_reader :a, :b, :c, :d, :e, :f, :h, :l, :f + attr_reader :a, :b, :c, :d, :e, :f, :h, :l # CPU instruction cycle count attr_reader :m # 16 bit registers @@ -55,7 +55,7 @@ module Waterfoul def initialize(options = {}) @pc = 0x0000 @sp = 0x0000 - @a = @b = @c = @d = @e = @f = @h = @l = @f = 0x00 + @a = @b = @c = @d = @e = @f = @h = @l = 0x00 @m = 0 @timer = Timer.new @ime = false From e644f89abe3b2c8ba4e776ca9ee7a9a6f7bb86ed Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 10 May 2020 14:14:30 +0200 Subject: [PATCH 2/2] Make sure all instance variables of the CPU are initialized * @halt would trigger a warning. --- lib/waterfoul/cpu.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/waterfoul/cpu.rb b/lib/waterfoul/cpu.rb index 2f93ddb..975b1eb 100644 --- a/lib/waterfoul/cpu.rb +++ b/lib/waterfoul/cpu.rb @@ -56,9 +56,10 @@ module Waterfoul @pc = 0x0000 @sp = 0x0000 @a = @b = @c = @d = @e = @f = @h = @l = 0x00 - @m = 0 @timer = Timer.new @ime = false + @halt = false + reset_tick end # This method emulates the CPU cycle process. Each instruction is