rubyboy 1.6.0 → 1.7.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +40 -84
  4. data/exe/rubyboy +5 -7
  5. data/exe/rubyboy-bench +9 -20
  6. data/lib/bench.rb +17 -46
  7. data/lib/executor.rb +19 -10
  8. data/lib/rubyboy/apu_channels/channel1.rb +4 -4
  9. data/lib/rubyboy/apu_channels/channel2.rb +4 -4
  10. data/lib/rubyboy/apu_channels/channel3.rb +2 -9
  11. data/lib/rubyboy/apu_channels/channel4.rb +0 -7
  12. data/lib/rubyboy/audio.rb +7 -2
  13. data/lib/rubyboy/emulator.rb +7 -23
  14. data/lib/rubyboy/emulator_headless.rb +1 -1
  15. data/lib/rubyboy/emulator_wasm.rb +30 -7
  16. data/lib/rubyboy/hardware_state.rb +1 -0
  17. data/lib/rubyboy/lcd.rb +2 -10
  18. data/lib/rubyboy/rom.rb +3 -0
  19. data/lib/rubyboy/sdl.rb +1 -1
  20. data/lib/rubyboy/state_file.rb +1 -2
  21. data/lib/rubyboy/version.rb +1 -1
  22. metadata +4 -60
  23. data/.rspec +0 -3
  24. data/.rubocop.yml +0 -54
  25. data/CODE_OF_CONDUCT.md +0 -84
  26. data/Rakefile +0 -12
  27. data/docs/favicon.png +0 -0
  28. data/docs/index.html +0 -75
  29. data/docs/index.js +0 -113
  30. data/docs/logo-light-23.svg +0 -1
  31. data/docs/ogp.png +0 -0
  32. data/docs/styles.css +0 -245
  33. data/docs/worker.js +0 -115
  34. data/exe/rubyboy-wasm +0 -26
  35. data/lib/opcodes.json +0 -11657
  36. data/lib/roms/bgbtest.gb +0 -0
  37. data/lib/roms/cpu_instrs/cpu_instrs.gb +0 -0
  38. data/lib/roms/cpu_instrs/individual/01-special.gb +0 -0
  39. data/lib/roms/cpu_instrs/individual/02-interrupts.gb +0 -0
  40. data/lib/roms/cpu_instrs/individual/03-op sp,hl.gb +0 -0
  41. data/lib/roms/cpu_instrs/individual/04-op r,imm.gb +0 -0
  42. data/lib/roms/cpu_instrs/individual/05-op rp.gb +0 -0
  43. data/lib/roms/cpu_instrs/individual/06-ld r,r.gb +0 -0
  44. data/lib/roms/cpu_instrs/individual/07-jr,jp,call,ret,rst.gb +0 -0
  45. data/lib/roms/cpu_instrs/individual/08-misc instrs.gb +0 -0
  46. data/lib/roms/cpu_instrs/individual/09-op r,r.gb +0 -0
  47. data/lib/roms/cpu_instrs/individual/10-bit ops.gb +0 -0
  48. data/lib/roms/cpu_instrs/individual/11-op a,(hl).gb +0 -0
  49. data/lib/roms/cpu_instrs/readme.txt +0 -119
  50. data/lib/roms/dmg-acid2.gb +0 -0
  51. data/lib/roms/hello-world.gb +0 -0
  52. data/lib/roms/instr_timing/instr_timing.gb +0 -0
  53. data/lib/roms/instr_timing/readme.txt +0 -139
  54. data/lib/rubyboy/raylib/audio.rb +0 -32
  55. data/lib/rubyboy/raylib/lcd.rb +0 -40
  56. data/lib/rubyboy/raylib/raylib_loader.rb +0 -36
  57. data/lib/stackprof.rb +0 -14
  58. data/resource/logo/logo.png +0 -0
  59. data/resource/logo/logo.svg +0 -1
  60. data/resource/logo/rubyboy.png +0 -0
  61. data/resource/screenshots/pokemon.png +0 -0
  62. data/resource/screenshots/puyopuyo.png +0 -0
  63. data/sig/rubyboy.rbs +0 -4
@@ -3,7 +3,6 @@
3
3
  require_relative 'apu'
4
4
  require_relative 'bus'
5
5
  require_relative 'cpu'
6
- require_relative 'emulator'
7
6
  require_relative 'ppu'
8
7
  require_relative 'rom'
9
8
  require_relative 'ram'
@@ -14,8 +13,9 @@ require_relative 'cartridge/factory'
14
13
 
15
14
  module Rubyboy
16
15
  class EmulatorWasm
17
- CPU_CLOCK_HZ = 4_194_304
18
- CYCLE_NANOSEC = 1_000_000_000 / CPU_CLOCK_HZ
16
+ FRAME_CYCLES = 70_224
17
+
18
+ attr_reader :audio_samples
19
19
 
20
20
  def initialize(rom_data)
21
21
  rom = Rom.new(rom_data)
@@ -28,16 +28,39 @@ module Rubyboy
28
28
  @apu = Apu.new
29
29
  @bus = Bus.new(@ppu, rom, ram, mbc, @timer, interrupt, @joypad, @apu)
30
30
  @cpu = Cpu.new(@bus, interrupt)
31
+ @audio_samples = []
31
32
  end
32
33
 
33
34
  def step(direction_key, action_key)
34
- @joypad.direction_button(direction_key)
35
- @joypad.action_button(action_key)
36
- loop do
35
+ set_input(direction_key, action_key)
36
+ @audio_samples.clear
37
+ elapsed_cycles = 0
38
+ # LCD-off games must return to the browser event loop as well.
39
+ while elapsed_cycles < FRAME_CYCLES
37
40
  cycles = @cpu.exec
41
+ elapsed_cycles += cycles
38
42
  @timer.step(cycles)
39
- return @ppu.buffer if @ppu.step(cycles)
43
+ collect_audio(cycles)
44
+ break if @ppu.step(cycles)
40
45
  end
46
+ framebuffer
47
+ end
48
+
49
+ def framebuffer
50
+ @ppu.buffer
51
+ end
52
+
53
+ private
54
+
55
+ def set_input(direction_key, action_key)
56
+ @joypad.direction_button(direction_key & 15)
57
+ @joypad.action_button(action_key & 15)
58
+ end
59
+
60
+ def collect_audio(cycles)
61
+ # Complete 512-frame stereo blocks are copied before the APU reuses its
62
+ # sample buffer. Its incomplete block remains intact between calls.
63
+ @audio_samples.concat(@apu.samples) if @apu.step(cycles)
41
64
  end
42
65
  end
43
66
  end
@@ -173,6 +173,7 @@ module Rubyboy
173
173
  end
174
174
  end
175
175
 
176
+ # Keep channel fields explicit so Spinel can compile them without reflection.
176
177
  module ApuChannels
177
178
  class Channel1
178
179
  def hardware_state
data/lib/rubyboy/lcd.rb CHANGED
@@ -9,7 +9,7 @@ module Rubyboy
9
9
  SCALE = 3
10
10
  SDL_EVENT_SIZE = 56
11
11
 
12
- def initialize(vsync: nil)
12
+ def initialize
13
13
  raise SDL.GetError() if SDL.InitSubSystem(SDL::INIT_VIDEO) != 0
14
14
 
15
15
  @buffer = FFI::MemoryPointer.new(:uint32, SCREEN_WIDTH * SCREEN_HEIGHT)
@@ -17,15 +17,7 @@ module Rubyboy
17
17
 
18
18
  raise SDL.GetError() if @window.null?
19
19
 
20
- begin
21
- @renderer = SDL.CreateRenderer(@window, -1, 0)
22
- raise SDL.GetError() if @renderer.null?
23
- raise SDL.GetError() if !vsync.nil? && SDL.RenderSetVSync(@renderer, vsync ? 1 : 0) != 0
24
- rescue StandardError
25
- close_window
26
- raise
27
- end
28
-
20
+ @renderer = SDL.CreateRenderer(@window, -1, 0)
29
21
  SDL.SetHint('SDL_HINT_RENDER_SCALE_QUALITY', '2')
30
22
  SDL.RenderSetLogicalSize(@renderer, SCREEN_WIDTH * SCALE, SCREEN_HEIGHT * SCALE)
31
23
  @texture = SDL.CreateTexture(@renderer, SDL::PIXELFORMAT_ABGR8888, 1, SCREEN_WIDTH, SCREEN_HEIGHT)
data/lib/rubyboy/rom.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Rubyboy
4
4
  class Rom
5
+ # Tobu Tobu Girl, bundled with the gem and used when no ROM is given.
6
+ DEFAULT_PATH = File.expand_path('../roms/tobu.gb', __dir__).freeze
7
+
5
8
  attr_reader :data, :entroy_point, :logo, :title, :new_licensee_code, :sgb_flag, :cartridge_type, :rom_size, :ram_size, :destination_code, :old_licensee_code, :mask_rom_version_number, :header_checksum, :global_checksum
6
9
 
7
10
  LOGO_DUMP = %w[
data/lib/rubyboy/sdl.rb CHANGED
@@ -5,6 +5,7 @@ require 'ffi'
5
5
  module Rubyboy
6
6
  module SDL
7
7
  extend FFI::Library
8
+
8
9
  ffi_lib 'SDL2'
9
10
 
10
11
  INIT_TIMER = 0x01
@@ -53,7 +54,6 @@ module Rubyboy
53
54
  attach_function :GetKeyboardState, 'SDL_GetKeyboardState', [:pointer], :pointer
54
55
  attach_function :SetHint, 'SDL_SetHint', %i[string string], :int
55
56
  attach_function :RenderSetLogicalSize, 'SDL_RenderSetLogicalSize', %i[pointer int int], :int
56
- attach_function :RenderSetVSync, 'SDL_RenderSetVSync', %i[pointer int], :int
57
57
  attach_function :SetWindowTitle, 'SDL_SetWindowTitle', %i[pointer string], :void
58
58
  attach_function :RaiseWindow, 'SDL_RaiseWindow', [:pointer], :void
59
59
  attach_function :GetError, 'SDL_GetError', [], :string
@@ -32,9 +32,8 @@ module Rubyboy
32
32
  return warn_and_false("ROM checksum mismatch for state file #{path}") unless checksum == rom.global_checksum_value
33
33
 
34
34
  # State files are local emulator snapshots written by this process.
35
- # rubocop:disable Security/MarshalLoad
35
+ # rubocop:disable-next Security/MarshalLoad
36
36
  yield Marshal.load(data.byteslice(HEADER_SIZE..))
37
- # rubocop:enable Security/MarshalLoad
38
37
  true
39
38
  rescue StandardError => e
40
39
  warn "[rubyboy] failed to read state file #{path}: #{e.message}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubyboy
4
- VERSION = '1.6.0'
4
+ VERSION = '1.7.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyboy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sacckey
@@ -29,65 +29,19 @@ dependencies:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
31
  version: 1.16.3
32
- - !ruby/object:Gem::Dependency
33
- name: json
34
- requirement: !ruby/object:Gem::Requirement
35
- requirements:
36
- - - "~>"
37
- - !ruby/object:Gem::Version
38
- version: '2.8'
39
- type: :runtime
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- requirements:
43
- - - "~>"
44
- - !ruby/object:Gem::Version
45
- version: '2.8'
46
32
  executables:
47
33
  - rubyboy
48
34
  - rubyboy-bench
49
- - rubyboy-wasm
50
35
  extensions: []
51
36
  extra_rdoc_files: []
52
37
  files:
53
- - ".rspec"
54
- - ".rubocop.yml"
55
38
  - CHANGELOG.md
56
- - CODE_OF_CONDUCT.md
57
39
  - LICENSE.txt
58
40
  - README.md
59
- - Rakefile
60
- - docs/favicon.png
61
- - docs/index.html
62
- - docs/index.js
63
- - docs/logo-light-23.svg
64
- - docs/ogp.png
65
- - docs/styles.css
66
- - docs/worker.js
67
41
  - exe/rubyboy
68
42
  - exe/rubyboy-bench
69
- - exe/rubyboy-wasm
70
43
  - lib/bench.rb
71
44
  - lib/executor.rb
72
- - lib/opcodes.json
73
- - lib/roms/bgbtest.gb
74
- - lib/roms/cpu_instrs/cpu_instrs.gb
75
- - lib/roms/cpu_instrs/individual/01-special.gb
76
- - lib/roms/cpu_instrs/individual/02-interrupts.gb
77
- - lib/roms/cpu_instrs/individual/03-op sp,hl.gb
78
- - lib/roms/cpu_instrs/individual/04-op r,imm.gb
79
- - lib/roms/cpu_instrs/individual/05-op rp.gb
80
- - lib/roms/cpu_instrs/individual/06-ld r,r.gb
81
- - lib/roms/cpu_instrs/individual/07-jr,jp,call,ret,rst.gb
82
- - lib/roms/cpu_instrs/individual/08-misc instrs.gb
83
- - lib/roms/cpu_instrs/individual/09-op r,r.gb
84
- - lib/roms/cpu_instrs/individual/10-bit ops.gb
85
- - lib/roms/cpu_instrs/individual/11-op a,(hl).gb
86
- - lib/roms/cpu_instrs/readme.txt
87
- - lib/roms/dmg-acid2.gb
88
- - lib/roms/hello-world.gb
89
- - lib/roms/instr_timing/instr_timing.gb
90
- - lib/roms/instr_timing/readme.txt
91
45
  - lib/roms/tobu.gb
92
46
  - lib/rubyboy.rb
93
47
  - lib/rubyboy/apu.rb
@@ -110,9 +64,6 @@ files:
110
64
  - lib/rubyboy/lcd.rb
111
65
  - lib/rubyboy/ppu.rb
112
66
  - lib/rubyboy/ram.rb
113
- - lib/rubyboy/raylib/audio.rb
114
- - lib/rubyboy/raylib/lcd.rb
115
- - lib/rubyboy/raylib/raylib_loader.rb
116
67
  - lib/rubyboy/registers.rb
117
68
  - lib/rubyboy/rom.rb
118
69
  - lib/rubyboy/save_file.rb
@@ -120,19 +71,12 @@ files:
120
71
  - lib/rubyboy/state_file.rb
121
72
  - lib/rubyboy/timer.rb
122
73
  - lib/rubyboy/version.rb
123
- - lib/stackprof.rb
124
- - resource/logo/logo.png
125
- - resource/logo/logo.svg
126
- - resource/logo/rubyboy.png
127
- - resource/screenshots/pokemon.png
128
- - resource/screenshots/puyopuyo.png
129
- - sig/rubyboy.rbs
130
- homepage: https://github.com/sacckey/rubyboy
74
+ homepage: https://sacckey.github.io/rubyboy/
131
75
  licenses:
132
76
  - MIT
133
77
  metadata:
134
78
  allowed_push_host: https://rubygems.org
135
- homepage_uri: https://github.com/sacckey/rubyboy
79
+ homepage_uri: https://sacckey.github.io/rubyboy/
136
80
  source_code_uri: https://github.com/sacckey/rubyboy
137
81
  changelog_uri: https://github.com/sacckey/rubyboy/blob/main/CHANGELOG.md
138
82
  rubygems_mfa_required: 'true'
@@ -143,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
87
  requirements:
144
88
  - - ">="
145
89
  - !ruby/object:Gem::Version
146
- version: 3.2.0
90
+ version: 4.0.0
147
91
  required_rubygems_version: !ruby/object:Gem::Requirement
148
92
  requirements:
149
93
  - - ">="
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,54 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 3.2
3
- NewCops: enable
4
-
5
- Lint/AmbiguousOperatorPrecedence:
6
- Enabled: false
7
-
8
- Lint/DuplicateBranch:
9
- Enabled: false
10
-
11
- Layout/LineLength:
12
- Enabled: false
13
-
14
- Metrics/AbcSize:
15
- Enabled: false
16
-
17
- Metrics/BlockNesting:
18
- Enabled: false
19
-
20
- Metrics/BlockLength:
21
- Enabled: false
22
-
23
- Metrics/CyclomaticComplexity:
24
- Enabled: false
25
-
26
- Metrics/ParameterLists:
27
- Enabled: false
28
-
29
- Metrics/PerceivedComplexity:
30
- Enabled: false
31
-
32
- Metrics/ClassLength:
33
- Enabled: false
34
-
35
- Metrics/MethodLength:
36
- Enabled: false
37
-
38
- Naming/MethodParameterName:
39
- Enabled: false
40
-
41
- Style/Documentation:
42
- Enabled: false
43
-
44
- Style/FormatString:
45
- Enabled: false
46
-
47
- Style/MultipleComparison:
48
- Enabled: false
49
-
50
- Style/NumericLiterals:
51
- Enabled: false
52
-
53
- Style/NumericPredicate:
54
- EnforcedStyle: comparison
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sacckey. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require 'rubocop/rake_task'
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
data/docs/favicon.png DELETED
Binary file
data/docs/index.html DELETED
@@ -1,75 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <title>Ruby Boy</title>
5
- <meta charset="utf-8"/>
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <meta name="author" content="sacckey" />
8
- <meta name="description" content="Game Boy emulator written in Ruby, running on ruby.wasm" />
9
- <meta property="og:url" content="https://sacckey.github.io/rubyboy/" />
10
- <meta property="og:title" content="Ruby Boy" />
11
- <meta property="og:description" content="Game Boy emulator written in Ruby, running on ruby.wasm" />
12
- <meta property="og:image" content="https://sacckey.github.io/rubyboy/ogp.png" />
13
- <meta name="twitter:card" content="summary_large_image" />
14
- <meta name="twitter:site" content="@sacckey" />
15
- <meta name="twitter:creator" content="@sacckey" />
16
- <link rel="icon" href="./favicon.png">
17
- <link rel="stylesheet" href="./styles.css">
18
- <script src="./index.js" defer></script>
19
- </head>
20
- <body>
21
- <div class="main-content">
22
- <div class="gameboy">
23
- <div class="screen-container">
24
- <canvas id="canvas" width="320" height="288"></canvas>
25
- </div>
26
- <div class="controls">
27
- <div class="d-pad">
28
- <button class="d-pad-button" id="d-pad-left" title="Left" data-code="KeyA"></button>
29
- <button class="d-pad-button" id="d-pad-right" title="Right" data-code="KeyD"></button>
30
- <button class="d-pad-button" id="d-pad-up" title="Up" data-code="KeyW"></button>
31
- <button class="d-pad-button" id="d-pad-down" title="Down" data-code="KeyS"></button>
32
- </div>
33
- <div class="buttons">
34
- <button class="action-button" id="button-a" title="A" data-code="KeyK"></button>
35
- <button class="action-button" id="button-b" title="B" data-code="KeyJ"></button>
36
- </div>
37
- </div>
38
- <div class="start-select">
39
- <button class="start-select-button" title="Select" data-code="KeyU"></button>
40
- <button class="start-select-button" title="Start" data-code="KeyI"></button>
41
- </div>
42
- <img src="./logo-light-23.svg" alt="Ruby Boy">
43
- </div>
44
- <div class="control-panel">
45
- <section id="rom-select">
46
- <h3>ROM Select</h3>
47
- <select id="rom-select-box" class="rom-select-box" disabled >
48
- <option value="tobu.gb">Tobu Tobu Girl</option>
49
- <option value="bgbtest.gb">BGB Test</option>
50
- </select>
51
- <label id="rom-upload-button" class="rom-upload-button disabled">
52
- <input type="file" id="rom-input" accept=".gb" disabled />
53
- Upload
54
- </label>
55
- </section>
56
- <section id="controls">
57
- <h3>Controls</h3>
58
- <div>
59
- <kbd>w</kbd> <kbd>a</kbd> <kbd>s</kbd> <kbd>d</kbd>: ↑ ← ↓ →
60
- </div>
61
- <div>
62
- <kbd>k</kbd> <kbd>j</kbd> <kbd>i</kbd> <kbd>u</kbd>: A B Start Select
63
- </div>
64
- </section>
65
- <section id="performance">
66
- <h3>Performance</h3>
67
- <p>FPS: <span id="fps-display">0</span></p>
68
- </section>
69
- </div>
70
- </div>
71
- <footer class="footer">
72
- <p>&copy; 2024 sacckey | <a href="https://github.com/sacckey/rubyboy" target="_blank" rel="noopener noreferrer">GitHub</a></p>
73
- </footer>
74
- </body>
75
- </html>
data/docs/index.js DELETED
@@ -1,113 +0,0 @@
1
- const worker = new Worker('worker.js', { type: 'module' });
2
-
3
- const SCALE = 2;
4
- const canvas = document.getElementById('canvas');
5
- const canvasContext = canvas.getContext('2d');
6
- canvasContext.scale(SCALE, SCALE);
7
- const tmpCanvas = document.createElement('canvas');
8
- const tmpCanvasContext = tmpCanvas.getContext('2d');
9
- tmpCanvas.width = canvas.width;
10
- tmpCanvas.height = canvas.height;
11
-
12
- // Display "LOADING..."
13
- (() => {
14
- const str = `
15
- 10000 01110 01110 11110 01110 10001 01110 00000 00000 00000
16
- 10000 10001 10001 10001 00100 11001 10000 00000 00000 00000
17
- 10000 10001 10001 10001 00100 10101 10011 00000 00000 00000
18
- 10000 10001 11111 10001 00100 10011 10001 01100 01100 01100
19
- 11111 01110 10001 11110 01110 10001 01110 01100 01100 01100
20
- `;
21
- const dotSize = 2;
22
- const rows = str.trim().split('\n')
23
- const xSpacing = canvas.width / (2 * SCALE) - rows[0].length * dotSize / 2;
24
- const ySpacing = canvas.height / (2 * SCALE) - rows.length * dotSize / 2;
25
- canvasContext.fillStyle = 'white';
26
-
27
- rows.forEach((row, y) => {
28
- [...row.trim()].forEach((char, x) => {
29
- if (char === '1') {
30
- canvasContext.fillRect(
31
- x * dotSize + xSpacing,
32
- y * dotSize + ySpacing,
33
- dotSize,
34
- dotSize
35
- );
36
- }
37
- });
38
- });
39
- })();
40
-
41
- document.addEventListener('keydown', (event) => {
42
- worker.postMessage({ type: 'keydown', code: event.code });
43
- });
44
- document.addEventListener('keyup', (event) => {
45
- worker.postMessage({ type: 'keyup', code: event.code });
46
- });
47
-
48
- const handleButtonPress = (event) => {
49
- event.preventDefault();
50
- worker.postMessage({ type: 'keydown', code: event.target.dataset.code });
51
- }
52
- const handleButtonRelease = (event) => {
53
- event.preventDefault();
54
- worker.postMessage({ type: 'keyup', code: event.target.dataset.code });
55
- }
56
- const buttons = document.querySelectorAll('.d-pad-button, .action-button, .start-select-button');
57
- buttons.forEach(button => {
58
- button.addEventListener('mousedown', handleButtonPress);
59
- button.addEventListener('mouseup', handleButtonRelease);
60
- button.addEventListener('touchstart', handleButtonPress);
61
- button.addEventListener('touchend', handleButtonRelease);
62
- });
63
-
64
- const romInput = document.getElementById('rom-input');
65
- romInput.addEventListener('change', (event) => {
66
- const file = event.target.files[0];
67
- if (file) {
68
- const reader = new FileReader();
69
-
70
- reader.onload = (e) => {
71
- const romData = e.target.result;
72
- worker.postMessage({ type: 'loadROM', data: romData }, [romData]);
73
- };
74
-
75
- reader.readAsArrayBuffer(file);
76
- }
77
- });
78
-
79
- const romSelectBox = document.getElementById('rom-select-box');
80
- romSelectBox.addEventListener('change', (event) => {
81
- worker.postMessage({ type: 'loadPreInstalledRom', romName: event.target.value });
82
- });
83
-
84
- const times = [];
85
- const fpsDisplay = document.getElementById('fps-display');
86
- worker.onmessage = (event) => {
87
- if (event.data.type === 'pixelData') {
88
- const pixelData = new Uint8ClampedArray(event.data.data);
89
- const imageData = new ImageData(pixelData, 160, 144);
90
- tmpCanvasContext.putImageData(imageData, 0, 0);
91
- canvasContext.drawImage(tmpCanvas, 0, 0);
92
-
93
- const now = performance.now();
94
- while (times.length > 0 && times[0] <= now - 1000) {
95
- times.shift();
96
- }
97
- times.push(now);
98
- fpsDisplay.innerText = times.length.toString();
99
- }
100
-
101
- if (event.data.type === 'initialized') {
102
- romSelectBox.disabled = false;
103
- romInput.disabled = false;
104
- document.getElementById('rom-upload-button').classList.remove('disabled');
105
- worker.postMessage({ type: 'startRubyboy' });
106
- }
107
-
108
- if (event.data.type === 'error') {
109
- console.error('Error from Worker:', event.data.message);
110
- }
111
- };
112
-
113
- worker.postMessage({ type: 'initRubyboy' });
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="108" height="18" viewBox="0 0 108 18"><path fill="#fff" d="M5.84 10.68L5.00 10.68L4.23 16.94L0.51 16.94L2.55 0.18L7.64 0.18Q9.18 0.18 10.26 0.51Q11.35 0.84 12.04 1.41Q12.73 1.99 13.05 2.78Q13.36 3.56 13.36 4.48L13.36 4.48Q13.36 5.42 13.12 6.24Q12.87 7.07 12.40 7.77Q11.93 8.46 11.24 9.00Q10.56 9.53 9.68 9.88L9.68 9.88Q10.03 10.07 10.33 10.35Q10.64 10.63 10.81 11.04L10.81 11.04L13.25 16.94L9.87 16.94Q9.40 16.94 9.07 16.76Q8.75 16.57 8.63 16.23L8.63 16.23L6.81 11.27Q6.68 10.95 6.47 10.82Q6.26 10.68 5.84 10.68L5.84 10.68ZM7.29 2.98L5.96 2.98L5.32 8.10L6.69 8.10Q7.50 8.10 8.06 7.85Q8.63 7.60 8.98 7.19Q9.33 6.77 9.48 6.22Q9.64 5.67 9.64 5.06L9.64 5.06Q9.64 4.59 9.50 4.20Q9.36 3.82 9.07 3.55Q8.77 3.28 8.33 3.13Q7.89 2.98 7.29 2.98L7.29 2.98ZM20.79 14.00L20.79 14.00Q21.49 14.00 22.07 13.73Q22.64 13.45 23.08 12.95Q23.52 12.45 23.80 11.74Q24.09 11.03 24.20 10.14L24.20 10.14L25.41 0.18L29.16 0.18L27.95 10.14Q27.75 11.67 27.13 12.95Q26.52 14.24 25.54 15.16Q24.55 16.09 23.25 16.61Q21.95 17.12 20.40 17.12L20.40 17.12Q19.00 17.12 17.90 16.70Q16.80 16.27 16.05 15.50Q15.29 14.72 14.90 13.64Q14.51 12.56 14.51 11.26L14.51 11.26Q14.51 10.72 14.58 10.14L14.58 10.14L15.78 0.18L19.53 0.18L18.31 10.14Q18.29 10.35 18.27 10.55Q18.26 10.75 18.26 10.95L18.26 10.95Q18.26 12.37 18.91 13.18Q19.56 14.00 20.79 14.00ZM35.53 16.94L29.28 16.94L31.35 0.18L37.10 0.18Q38.56 0.18 39.60 0.46Q40.64 0.74 41.30 1.25Q41.96 1.76 42.27 2.48Q42.57 3.20 42.57 4.07L42.57 4.07Q42.57 4.76 42.39 5.40Q42.22 6.04 41.83 6.58Q41.45 7.12 40.84 7.56Q40.23 8.00 39.36 8.30L39.36 8.30Q40.72 8.67 41.37 9.45Q42.02 10.22 42.02 11.41L42.02 11.41Q42.02 12.57 41.58 13.58Q41.14 14.58 40.30 15.33Q39.46 16.08 38.25 16.51Q37.05 16.94 35.53 16.94L35.53 16.94ZM36.32 9.79L33.90 9.79L33.37 14.12L35.83 14.12Q36.52 14.12 37.00 13.92Q37.47 13.72 37.76 13.36Q38.05 12.99 38.19 12.51Q38.32 12.03 38.32 11.45L38.32 11.45Q38.32 11.07 38.22 10.76Q38.12 10.45 37.89 10.24Q37.65 10.03 37.27 9.91Q36.88 9.79 36.32 9.79L36.32 9.79ZM34.73 2.98L34.20 7.30L35.99 7.30Q36.63 7.30 37.13 7.18Q37.64 7.05 38.00 6.74Q38.36 6.44 38.56 5.93Q38.75 5.43 38.75 4.68L38.75 4.68Q38.75 3.75 38.27 3.36Q37.78 2.98 36.75 2.98L36.75 2.98L34.73 2.98ZM58.72 0.18L51.85 10.52L51.06 16.94L47.31 16.94L48.10 10.56L43.79 0.18L47.13 0.18Q47.61 0.18 47.88 0.41Q48.15 0.63 48.28 1.00L48.28 1.00L49.89 6.07Q50.05 6.58 50.18 7.05Q50.31 7.52 50.40 7.96L50.40 7.96Q50.62 7.52 50.89 7.06Q51.15 6.59 51.45 6.07L51.45 6.07L54.30 1.00Q54.48 0.69 54.81 0.44Q55.14 0.18 55.61 0.18L55.61 0.18L58.72 0.18ZM68.31 16.94L62.05 16.94L64.12 0.18L69.87 0.18Q71.33 0.18 72.38 0.46Q73.42 0.74 74.08 1.25Q74.74 1.76 75.04 2.48Q75.35 3.20 75.35 4.07L75.35 4.07Q75.35 4.76 75.17 5.40Q74.99 6.04 74.61 6.58Q74.22 7.12 73.61 7.56Q73.00 8.00 72.14 8.30L72.14 8.30Q73.50 8.67 74.15 9.45Q74.80 10.22 74.80 11.41L74.80 11.41Q74.80 12.57 74.35 13.58Q73.91 14.58 73.07 15.33Q72.23 16.08 71.03 16.51Q69.83 16.94 68.31 16.94L68.31 16.94ZM69.09 9.79L66.68 9.79L66.15 14.12L68.61 14.12Q69.30 14.12 69.77 13.92Q70.24 13.72 70.54 13.36Q70.83 12.99 70.96 12.51Q71.09 12.03 71.09 11.45L71.09 11.45Q71.09 11.07 71.00 10.76Q70.90 10.45 70.66 10.24Q70.43 10.03 70.04 9.91Q69.66 9.79 69.09 9.79L69.09 9.79ZM67.50 2.98L66.98 7.30L68.77 7.30Q69.40 7.30 69.91 7.18Q70.41 7.05 70.78 6.74Q71.14 6.44 71.33 5.93Q71.53 5.43 71.53 4.68L71.53 4.68Q71.53 3.75 71.04 3.36Q70.55 2.98 69.53 2.98L69.53 2.98L67.50 2.98ZM92.32 7.49L92.32 7.49Q92.32 8.84 92.01 10.09Q91.69 11.33 91.11 12.40Q90.53 13.47 89.71 14.34Q88.88 15.21 87.86 15.83Q86.84 16.44 85.64 16.78Q84.44 17.12 83.12 17.12L83.12 17.12Q81.47 17.12 80.15 16.54Q78.83 15.96 77.91 14.96Q76.99 13.95 76.50 12.59Q76.02 11.22 76.02 9.65L76.02 9.65Q76.02 8.29 76.33 7.04Q76.65 5.80 77.23 4.73Q77.81 3.66 78.64 2.78Q79.47 1.91 80.49 1.29Q81.51 0.68 82.71 0.34Q83.90-0.00 85.24-0.00L85.24-0.00Q86.88-0.00 88.20 0.58Q89.52 1.16 90.43 2.17Q91.34 3.19 91.83 4.55Q92.32 5.92 92.32 7.49ZM88.48 7.58L88.48 7.58Q88.48 6.54 88.23 5.70Q87.99 4.85 87.51 4.25Q87.03 3.65 86.34 3.32Q85.65 2.99 84.78 2.99L84.78 2.99Q83.63 2.99 82.72 3.47Q81.81 3.94 81.17 4.81Q80.53 5.67 80.20 6.88Q79.86 8.10 79.86 9.57L79.86 9.57Q79.86 10.60 80.10 11.44Q80.34 12.28 80.80 12.88Q81.27 13.48 81.96 13.81Q82.65 14.13 83.54 14.13L83.54 14.13Q84.69 14.13 85.60 13.66Q86.51 13.19 87.15 12.33Q87.79 11.47 88.14 10.26Q88.48 9.05 88.48 7.58ZM107.41 0.18L100.54 10.52L99.75 16.94L96.00 16.94L96.80 10.56L92.48 0.18L95.82 0.18Q96.30 0.18 96.57 0.41Q96.84 0.63 96.97 1.00L96.97 1.00L98.58 6.07Q98.74 6.58 98.87 7.05Q99.00 7.52 99.10 7.96L99.10 7.96Q99.31 7.52 99.58 7.06Q99.84 6.59 100.14 6.07L100.14 6.07L102.99 1.00Q103.17 0.69 103.50 0.44Q103.83 0.18 104.30 0.18L104.30 0.18L107.41 0.18Z"></path></svg>
data/docs/ogp.png DELETED
Binary file