GBRb 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/README.md +9 -1
  4. data/bin/gbrb +3 -3
  5. data/doc/images/blargg_cpu.png +0 -0
  6. data/doc/images/cpu_01.png +0 -0
  7. data/doc/images/cpu_03.png +0 -0
  8. data/doc/images/cpu_04.png +0 -0
  9. data/doc/images/cpu_05.png +0 -0
  10. data/doc/images/cpu_06.png +0 -0
  11. data/doc/images/cpu_07.png +0 -0
  12. data/doc/images/cpu_08.png +0 -0
  13. data/doc/images/cpu_09.png +0 -0
  14. data/doc/images/cpu_10.png +0 -0
  15. data/doc/images/cpu_11.png +0 -0
  16. data/doc/images/nintendo_logo.png +0 -0
  17. data/doc/images/opus5.png +0 -0
  18. data/doc/images/test.gb.png +0 -0
  19. data/doc/images/ttt.png +0 -0
  20. data/lib/gbrb.rb +7 -0
  21. data/lib/gbrb/cartridge.rb +21 -8
  22. data/lib/gbrb/cartridge/cartridge.rb +187 -0
  23. data/lib/gbrb/cpu/concatenated_register.rb +1 -1
  24. data/lib/gbrb/cpu/z80.rb +575 -498
  25. data/lib/gbrb/gb.rb +102 -32
  26. data/lib/gbrb/graphics.rb +1 -1
  27. data/lib/gbrb/graphics/gpu.rb +38 -30
  28. data/lib/gbrb/graphics/mode_clock.rb +31 -30
  29. data/lib/gbrb/graphics/screen_client.rb +3 -2
  30. data/lib/gbrb/instruction_set.rb +16 -0
  31. data/lib/gbrb/instruction_set/arithmetic.rb +238 -0
  32. data/lib/gbrb/instruction_set/bitwise.rb +64 -0
  33. data/lib/gbrb/instruction_set/boolean.rb +61 -0
  34. data/lib/gbrb/instruction_set/call.rb +40 -0
  35. data/lib/gbrb/instruction_set/carry.rb +23 -0
  36. data/lib/gbrb/instruction_set/cpl.rb +12 -0
  37. data/lib/gbrb/instruction_set/daa.rb +33 -0
  38. data/lib/gbrb/instruction_set/instruction.rb +23 -0
  39. data/lib/gbrb/instruction_set/jump.rb +47 -0
  40. data/lib/gbrb/instruction_set/ld.rb +241 -0
  41. data/lib/gbrb/instruction_set/return.rb +43 -0
  42. data/lib/gbrb/instruction_set/rotate.rb +178 -0
  43. data/lib/gbrb/instruction_set/rst.rb +16 -0
  44. data/lib/gbrb/instruction_set/special.rb +37 -0
  45. data/lib/gbrb/instruction_set/stack.rb +34 -0
  46. data/lib/gbrb/instruction_set/swap.rb +32 -0
  47. data/lib/gbrb/mmu.rb +60 -35
  48. data/lib/gbrb/options.rb +54 -0
  49. data/lib/gbrb/timer.rb +114 -0
  50. data/lib/gbrb/version.rb +1 -1
  51. data/misc/dump_diff +133 -0
  52. data/perf/cpu_perf_spec.rb +2 -2
  53. data/spec/gbrb/cartridge/cartridge_spec.rb +19 -0
  54. data/spec/gbrb/cartridge/mbc1_spec.rb +83 -0
  55. data/spec/gbrb/cpu/z80_spec.rb +92 -2
  56. data/spec/gbrb/{cpu/instruction_spec.rb → instruction_set/arithmetic_spec.rb} +21 -100
  57. data/spec/gbrb/instruction_set/boolean_spec.rb +50 -0
  58. data/spec/gbrb/instruction_set/instruction_spec.rb +22 -0
  59. data/spec/gbrb/instruction_set/ld_spec.rb +21 -0
  60. data/spec/gbrb/instruction_set/special_spec.rb +22 -0
  61. data/spec/gbrb/mmu_spec.rb +1 -1
  62. data/spec/gbrb/timer_spec.rb +26 -0
  63. metadata +53 -9
  64. data/lib/gbrb/cpu/instruction.rb +0 -648
  65. data/spec/gbrb/cartridge_spec.rb +0 -19
  66. data/spec/gbrb/graphics/mode_clock_spec.rb +0 -82
@@ -1,19 +0,0 @@
1
- require_relative '../spec_helper.rb'
2
-
3
- require_relative '../../lib/gbrb/cartridge.rb'
4
-
5
- module GBRb
6
- describe Cartridge do
7
- it "is initialized with an IO object" do
8
- c = Cartridge.new StringIO.new ""
9
- end
10
-
11
- it "separates data into banks" do
12
- raw_data = StringIO.new(0x01.chr * MEMORY_BANK_SIZE + 0x02.chr * MEMORY_BANK_SIZE)
13
- c = Cartridge.new raw_data
14
- c.bank(0).each {|b| b.should eq 0x01}
15
- c.bank(1).each {|b| b.should eq 0x02}
16
- end
17
- end
18
- end
19
-
@@ -1,82 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_relative '../../../lib/gbrb/graphics/mode_clock'
3
-
4
- module GBRb::Graphics
5
- class DummyModeClock
6
- include ModeClock
7
- attr_accessor :line
8
- def initialize
9
- reset
10
- end
11
- end
12
-
13
- describe DummyModeClock do
14
- it 'updates the internal clock' do
15
- mc = DummyModeClock.new
16
- initial_clock = mc.instance_eval '@clock'
17
- mc.update! 8
18
- mc.instance_eval('@clock').should eq initial_clock + 8
19
- end
20
-
21
- context 'mode transitions' do
22
- let(:mc) { DummyModeClock.new }
23
- it '2 -> 3' do
24
- mc.instance_eval '@clock = 76'
25
- mc.instance_eval '@mode = 2'
26
- mc.update! 4
27
- mc.mode.should eq 3
28
- end
29
-
30
- it '3 -> 0' do
31
- mc.instance_eval '@clock = 168'
32
- mc.instance_eval '@mode = 3'
33
-
34
- mc.should_receive :render_scan_line
35
- mc.update! 4
36
- mc.mode.should eq 0
37
- end
38
-
39
- it '0 -> 1' do
40
- mc.instance_eval '@clock = 200'
41
- mc.instance_eval '@mode = 0'
42
- mc.instance_eval '@line = 143'
43
-
44
- mc.should_receive :draw_frame_buffer
45
- mc.update! 4
46
- mc.mode.should eq 1
47
- mc.line.should eq 144
48
- end
49
-
50
- it '0 -> 2' do
51
- mc.instance_eval '@clock = 200'
52
- mc.instance_eval '@mode = 0'
53
-
54
- mc.should_not_receive :draw_frame_buffer
55
- mc.update! 4
56
- mc.mode.should eq 2
57
- mc.line.should eq 1
58
- end
59
-
60
- it '1 -> 1' do
61
- mc.instance_eval '@clock = 452'
62
- mc.instance_eval '@mode = 1'
63
- mc.update! 4
64
- mc.line.should eq 1
65
- mc.mode.should eq 1
66
- end
67
-
68
- it '1 -> 2' do
69
- mc.instance_eval '@clock = 452'
70
- mc.instance_eval '@mode = 1'
71
- mc.instance_eval '@line = 153'
72
- mc.update! 4
73
- mc.line.should eq 0
74
- mc.mode.should eq 2
75
- end
76
- end
77
-
78
- it 'can be reset' do
79
- DummyModeClock.new.reset
80
- end
81
- end
82
- end