Skip to content

Commit

Permalink
Merge pull request #13 from sacckey/v1.2.0
Browse files Browse the repository at this point in the history
V1.2.0
  • Loading branch information
sacckey authored Jan 9, 2024
2 parents 449044b + 04c7717 commit 31aa875
Show file tree
Hide file tree
Showing 25 changed files with 40 additions and 169 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Metrics/BlockNesting:
Metrics/CyclomaticComplexity:
Enabled: false

Metrics/ParameterLists:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## [Unreleased]

## [1.2.0] - 2024-01-09

- Add logo
- Bump raylib-bindings version to 0.6.0
- Optimizing
- Remove unnecessary classes

## [1.1.0] - 2023-12-28

- Add bench option
Expand Down
9 changes: 6 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: .
specs:
rubyboy (1.1.0)
raylib-bindings (~> 0.5.7)
rubyboy (1.2.0)
raylib-bindings (~> 0.6.0)

GEM
remote: https://rubygems.org/
Expand All @@ -21,7 +21,10 @@ GEM
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
raylib-bindings (0.5.7)
raylib-bindings (0.6.0-x86_64-darwin)
ffi (~> 1.16)
opengl-bindings2 (~> 2)
raylib-bindings (0.6.0-x86_64-linux)
ffi (~> 1.16)
opengl-bindings2 (~> 2)
regexp_parser (2.8.2)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Rubyboy
<br>
<p align="center">
<img src="/resource/logo/logo.svg" width="480px">
</p>
<br>

A Game Boy emulator written in Ruby

Expand Down
3 changes: 2 additions & 1 deletion exe/rubyboy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ require 'bench'

arg = ARGV[0]

puts "yjit: #{RubyVM::YJIT.enabled?}"
puts "Ruby: #{RUBY_VERSION}"
puts "YJIT: #{RubyVM::YJIT.enabled?}"

if arg == 'bench'
Rubyboy::Bench.new.bench
Expand Down
13 changes: 9 additions & 4 deletions lib/rubyboy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
require_relative 'rubyboy/cpu'
require_relative 'rubyboy/ppu'
require_relative 'rubyboy/rom'
require_relative 'rubyboy/ram'
require_relative 'rubyboy/timer'
require_relative 'rubyboy/lcd'
require_relative 'rubyboy/joypad'
require_relative 'rubyboy/interrupt'
require_relative 'rubyboy/cartridge/factory'

module Rubyboy
class Console
Expand All @@ -18,11 +20,13 @@ def initialize(rom_path)
load_raylib
rom_data = File.open(rom_path, 'r') { _1.read.bytes }
rom = Rom.new(rom_data)
ram = Ram.new
mbc = Cartridge::Factory.create(rom, ram)
interrupt = Interrupt.new
@ppu = Ppu.new(interrupt)
@timer = Timer.new(interrupt)
@joypad = Joypad.new(interrupt)
@bus = Bus.new(@ppu, rom, @timer, interrupt, @joypad)
@bus = Bus.new(@ppu, rom, ram, mbc, @timer, interrupt, @joypad)
@cpu = Cpu.new(@bus, interrupt)
@lcd = Lcd.new
end
Expand Down Expand Up @@ -65,9 +69,9 @@ def draw
end

def buffer_to_pixel_data(buffer)
buffer.map do |row|
buffer.flat_map do |row|
[row, row, row]
end.flatten.pack('C*')
end.pack('C*')
end

def key_input_check
Expand All @@ -83,7 +87,8 @@ def load_raylib
when /mswin|msys|mingw/ # Windows
Raylib.load_lib("#{shared_lib_path}libraylib.dll")
when /darwin/ # macOS
Raylib.load_lib("#{shared_lib_path}libraylib.dylib")
arch = RUBY_PLATFORM.split('-')[0]
Raylib.load_lib(shared_lib_path + "libraylib.#{arch}.dylib")
when /linux/ # Ubuntu Linux (x86_64 or aarch64)
arch = RUBY_PLATFORM.split('-')[0]
Raylib.load_lib(shared_lib_path + "libraylib.#{arch}.so")
Expand Down
8 changes: 3 additions & 5 deletions lib/rubyboy/bus.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# frozen_string_literal: true

require_relative 'cartridge/factory'

module Rubyboy
class Bus
def initialize(ppu, rom, timer, interrupt, joypad)
def initialize(ppu, rom, ram, mbc, timer, interrupt, joypad)
@ppu = ppu
@rom = rom
@ram = Ram.new
@mbc = Cartridge::Factory.create(@rom, @ram)
@ram = ram
@mbc = mbc
@joypad = joypad
@interrupt = interrupt
@timer = timer
Expand Down
2 changes: 0 additions & 2 deletions lib/rubyboy/cartridge/mbc1.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative '../ram'

module Rubyboy
module Cartridge
class Mbc1
Expand Down
1 change: 0 additions & 1 deletion lib/rubyboy/cpu.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require_relative 'registers'
require_relative 'operand'

module Rubyboy
class Cpu
Expand Down
3 changes: 2 additions & 1 deletion lib/rubyboy/lcd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ def initialize
image = GenImageColor(WIDTH, HEIGHT, BLACK)
image.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8
@texture = LoadTextureFromImage(image)
@vector = Vector2.create(0, 0)
end

def draw(pixel_data)
UpdateTexture(@texture, pixel_data)

BeginDrawing()
ClearBackground(BLACK)
DrawTextureEx(@texture, Vector2.create(0, 0), 0.0, SCALE, WHITE)
DrawTextureEx(@texture, @vector, 0.0, SCALE, WHITE)
EndDrawing()
end

Expand Down
12 changes: 0 additions & 12 deletions lib/rubyboy/operand.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/direct16.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/direct8.rb

This file was deleted.

11 changes: 0 additions & 11 deletions lib/rubyboy/operand/hl_dec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions lib/rubyboy/operand/hl_inc.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/immediate16.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/immediate8.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/indirect.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/register16.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/rubyboy/operand/register8.rb

This file was deleted.

24 changes: 0 additions & 24 deletions lib/rubyboy/register.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/rubyboy/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Rubyboy
VERSION = '1.1.0'
VERSION = '1.2.0'
end
Binary file added resource/logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resource/logo/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion rubyboy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

# Uncomment to register a new dependency of your gem
spec.add_dependency 'raylib-bindings', '~> 0.5.7'
spec.add_dependency 'raylib-bindings', '~> 0.6.0'

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
Expand Down

0 comments on commit 31aa875

Please sign in to comment.