rubyboy 0.4.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a90f9cbc5a0ac4a9f9b971f0c4454421dc83ae9686222c275679f173e7503232
4
- data.tar.gz: 52833516da6531982602c373acb11a74d292db6221b8ad34d4420a94be7fe017
3
+ metadata.gz: f71c49ce8d91b143c346ea5ac3534d531faa1d7ed7fc886243ed77e9e76e31b7
4
+ data.tar.gz: c9211303e89f8d775fb8c083a0eb3ab97e2299e41722b6c461bfac0cc9ea94ac
5
5
  SHA512:
6
- metadata.gz: ef45830027a11b9827e8660bef2fbb45a5a0fc867486aef58ece8a930acae959eb66ac5709d425e8562d1a546608cbb4cce040efc9e17940b627dfc9095c4a7b
7
- data.tar.gz: d8564cc7f5c66dbce015fead7ff770527736943e9c1de3858ed813c1cc012c1e9c5b9248010d16ee39a5fa668e720eb9cda93443b2097260b3b24688b9acdd42
6
+ metadata.gz: 76374e3846dc6a917a0dda34b71f6c667155cd5458bbb70ab0fba1ae16a8e5482153808e4de64aa8670d958a69ec52625e5f41673a04780d2b063b35c1564606
7
+ data.tar.gz: a3354719d960846738a7cb9252afa1a86fa0c3a2a0d3529013808386ab8a5aaa4a08ebc132cefed02353e20c4193f96804620031a79b6ca324c1e01ed5b8f12f
data/.rubocop.yml CHANGED
@@ -40,3 +40,6 @@ Style/FormatString:
40
40
 
41
41
  Style/NumericLiterals:
42
42
  Enabled: false
43
+
44
+ Style/NumericPredicate:
45
+ EnforcedStyle: comparison
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.0] - 2023-12-28
4
+
5
+ - Add bench option
6
+ - Improve speed by refactoring
7
+
8
+ ## [1.0.0] - 2023-12-04
9
+
10
+ - Fix halt and timer
11
+ - Add executable command
12
+ - Refactoring
13
+ - tobu.gb works at 30fps
14
+
3
15
  ## [0.4.0] - 2023-11-20
4
16
 
5
17
  - Fix interrupt
data/README.md CHANGED
@@ -1,34 +1,26 @@
1
1
  # Rubyboy
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubyboy`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A Game Boy emulator written in Ruby
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
7
+ This project requires Ruby 3.2.0 or higher.
10
8
 
11
9
  Install the gem and add to the application's Gemfile by executing:
12
10
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
11
+ $ bundle add rubyboy
14
12
 
15
13
  If bundler is not being used to manage dependencies, install the gem by executing:
16
14
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15
+ $ gem install rubyboy
18
16
 
19
17
  ## Usage
20
18
 
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
19
+ $ rubyboy <rom_path>
28
20
 
29
21
  ## Contributing
30
22
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubyboy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rubyboy/blob/main/CODE_OF_CONDUCT.md).
23
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sacckey/rubyboy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sacckey/rubyboy/blob/main/CODE_OF_CONDUCT.md).
32
24
 
33
25
  ## License
34
26
 
@@ -36,4 +28,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
28
 
37
29
  ## Code of Conduct
38
30
 
39
- Everyone interacting in the Rubyboy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rubyboy/blob/main/CODE_OF_CONDUCT.md).
31
+ Everyone interacting in the Rubyboy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sacckey/rubyboy/blob/main/CODE_OF_CONDUCT.md).
data/exe/rubyboy ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'rubyboy'
5
+ require 'bench'
6
+
7
+ arg = ARGV[0]
8
+
9
+ puts "yjit: #{RubyVM::YJIT.enabled?}"
10
+
11
+ if arg == 'bench'
12
+ Rubyboy::Bench.new.bench
13
+ elsif arg == 'stackprof'
14
+ Rubyboy::Bench.new.stackprof
15
+ else
16
+ Rubyboy::Console.new(arg).start
17
+ end
data/lib/bench.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'stackprof'
4
+ require_relative 'rubyboy'
5
+
6
+ module Rubyboy
7
+ class Bench
8
+ def stackprof
9
+ StackProf.run(mode: :cpu, out: 'stackprof-cpu-myapp.dump', raw: true) do
10
+ Rubyboy::Console.new('lib/roms/tobu.gb').bench
11
+ end
12
+ end
13
+
14
+ def bench
15
+ bench_cnt = 3
16
+ time_sum = 0
17
+ bench_cnt.times do |i|
18
+ time = Rubyboy::Console.new('lib/roms/tobu.gb').bench
19
+ time_sum += time
20
+ puts "#{i + 1}: #{time} sec"
21
+ end
22
+
23
+ puts "FPS: #{1500 * bench_cnt / time_sum}"
24
+ end
25
+ end
26
+ end
data/lib/rubyboy/bus.rb CHANGED
@@ -1,25 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'cartridge/factory'
4
- require_relative 'interrupt'
5
- require_relative 'timer'
6
4
 
7
5
  module Rubyboy
8
6
  class Bus
9
- attr_accessor :ppu, :rom, :interrupt
10
-
11
7
  def initialize(ppu, rom, timer, interrupt, joypad)
12
8
  @ppu = ppu
13
9
  @rom = rom
14
10
  @ram = Ram.new
15
- @mbc = Cartridge::Factory.create(rom, @ram)
11
+ @mbc = Cartridge::Factory.create(@rom, @ram)
16
12
  @joypad = joypad
17
-
18
13
  @interrupt = interrupt
19
14
  @timer = timer
20
15
 
21
- @oam = Array.new(0xa0, 0)
22
-
23
16
  @tmp = {}
24
17
  end
25
18
 
@@ -41,7 +41,7 @@ module Rubyboy
41
41
  @ram_enable = value & 0x0f == 0x0a
42
42
  when 0x2000..0x3fff
43
43
  @rom_bank = value & 0x1f
44
- @rom_bank = 1 if @rom_bank.zero?
44
+ @rom_bank = 1 if @rom_bank == 0
45
45
  when 0x4000..0x5fff
46
46
  @ram_bank = value & 0x03
47
47
  when 0x6000..0x7fff