gemba 0.1.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 (65) hide show
  1. checksums.yaml +7 -0
  2. data/THIRD_PARTY_NOTICES +113 -0
  3. data/assets/JetBrainsMonoNL-Regular.ttf +0 -0
  4. data/assets/ark-pixel-12px-monospaced-ja.ttf +0 -0
  5. data/bin/gemba +14 -0
  6. data/ext/gemba/extconf.rb +185 -0
  7. data/ext/gemba/gemba_ext.c +1051 -0
  8. data/ext/gemba/gemba_ext.h +15 -0
  9. data/gemba.gemspec +38 -0
  10. data/lib/gemba/child_window.rb +62 -0
  11. data/lib/gemba/cli.rb +384 -0
  12. data/lib/gemba/config.rb +621 -0
  13. data/lib/gemba/core.rb +121 -0
  14. data/lib/gemba/headless.rb +12 -0
  15. data/lib/gemba/headless_player.rb +206 -0
  16. data/lib/gemba/hotkey_map.rb +202 -0
  17. data/lib/gemba/input_mappings.rb +214 -0
  18. data/lib/gemba/locale.rb +92 -0
  19. data/lib/gemba/locales/en.yml +157 -0
  20. data/lib/gemba/locales/ja.yml +157 -0
  21. data/lib/gemba/method_coverage_service.rb +265 -0
  22. data/lib/gemba/overlay_renderer.rb +109 -0
  23. data/lib/gemba/player.rb +1515 -0
  24. data/lib/gemba/recorder.rb +156 -0
  25. data/lib/gemba/recorder_decoder.rb +325 -0
  26. data/lib/gemba/rom_info_window.rb +346 -0
  27. data/lib/gemba/rom_loader.rb +100 -0
  28. data/lib/gemba/runtime.rb +39 -0
  29. data/lib/gemba/save_state_manager.rb +155 -0
  30. data/lib/gemba/save_state_picker.rb +199 -0
  31. data/lib/gemba/settings_window.rb +1173 -0
  32. data/lib/gemba/tip_service.rb +133 -0
  33. data/lib/gemba/toast_overlay.rb +128 -0
  34. data/lib/gemba/version.rb +5 -0
  35. data/lib/gemba.rb +17 -0
  36. data/test/fixtures/test.gba +0 -0
  37. data/test/fixtures/test.sav +0 -0
  38. data/test/shared/screenshot_helper.rb +113 -0
  39. data/test/shared/simplecov_config.rb +59 -0
  40. data/test/shared/teek_test_worker.rb +388 -0
  41. data/test/shared/tk_test_helper.rb +354 -0
  42. data/test/support/input_mocks.rb +61 -0
  43. data/test/support/player_helpers.rb +77 -0
  44. data/test/test_cli.rb +281 -0
  45. data/test/test_config.rb +897 -0
  46. data/test/test_core.rb +401 -0
  47. data/test/test_gamepad_map.rb +116 -0
  48. data/test/test_headless_player.rb +205 -0
  49. data/test/test_helper.rb +19 -0
  50. data/test/test_hotkey_map.rb +396 -0
  51. data/test/test_keyboard_map.rb +108 -0
  52. data/test/test_locale.rb +159 -0
  53. data/test/test_mgba.rb +26 -0
  54. data/test/test_overlay_renderer.rb +199 -0
  55. data/test/test_player.rb +903 -0
  56. data/test/test_recorder.rb +180 -0
  57. data/test/test_rom_loader.rb +149 -0
  58. data/test/test_save_state_manager.rb +289 -0
  59. data/test/test_settings_hotkeys.rb +434 -0
  60. data/test/test_settings_window.rb +1039 -0
  61. data/test/test_tip_service.rb +138 -0
  62. data/test/test_toast_overlay.rb +216 -0
  63. data/test/test_virtual_keyboard.rb +39 -0
  64. data/test/test_xor_delta.rb +61 -0
  65. metadata +234 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 33c95c309c99b4b2f8161eb0c9d605ab6e42ffc600831799e4565590d3b651c1
4
+ data.tar.gz: ae2e108992b45760a77d60a21a4aebaf3f20dce42d4f5b0b4b770b310b10d3b2
5
+ SHA512:
6
+ metadata.gz: c5725d01740bf6646f955163579e9a210a433736bb83a043ac6c4b82348da9a219152163299429276c12ad9a2d8c1a0e32c1684674088a10b22c5729062102f1
7
+ data.tar.gz: cdaca542e525412429b9692a72b556368b4d121dbebed77b017e87d24801da37808abe8345fe6b3648950f2a6661119775977e275048901460cd08f0f3da904a
@@ -0,0 +1,113 @@
1
+ gemba bundles the following third-party fonts in the assets/ directory.
2
+ Both are licensed under the SIL Open Font License, Version 1.1.
3
+
4
+ ================================================================================
5
+ JetBrains Mono NL
6
+ ================================================================================
7
+
8
+ Copyright 2020 The JetBrains Mono Project Authors
9
+ https://github.com/JetBrains/JetBrainsMono
10
+
11
+ Licensed under the SIL Open Font License, Version 1.1.
12
+ https://scripts.sil.org/OFL
13
+
14
+ Used for: FPS overlay and monospaced on-screen indicators.
15
+
16
+ ================================================================================
17
+ Ark Pixel Font (12px, Proportional, Japanese)
18
+ ================================================================================
19
+
20
+ Copyright 2021 TakWolf
21
+ https://github.com/TakWolf/ark-pixel-font
22
+
23
+ Licensed under the SIL Open Font License, Version 1.1.
24
+ https://scripts.sil.org/OFL
25
+
26
+ Used for: Toast notifications and UI text overlays (CJK-capable).
27
+
28
+ ================================================================================
29
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
30
+ ================================================================================
31
+
32
+ PREAMBLE
33
+ The goals of the Open Font License (OFL) are to stimulate worldwide
34
+ development of collaborative font projects, to support the font creation
35
+ efforts of academic and linguistic communities, and to provide a free and
36
+ open framework in which fonts may be shared and improved in partnership
37
+ with others.
38
+
39
+ The fonts covered by the Open Font License can be used, studied, modified
40
+ and redistributed freely as long as they are not sold by themselves. The
41
+ fonts, including any derivative works, can be bundled, embedded,
42
+ redistributed and/or sold with any software provided that any reserved
43
+ names are not used by derivative works. The fonts and derivatives,
44
+ however, cannot be released under any other type of license. The
45
+ requirement for fonts to remain under this license does not apply to any
46
+ document created using the fonts or their derivatives.
47
+
48
+ DEFINITIONS
49
+ "Font Software" refers to the set of files released by the Copyright
50
+ Holder(s) under this license and clearly marked as such. This may
51
+ include source files, build scripts and documentation.
52
+
53
+ "Reserved Font Name" refers to any names specified as such after the
54
+ copyright statement(s).
55
+
56
+ "Original Version" refers to the collection of Font Software components as
57
+ distributed by the Copyright Holder(s).
58
+
59
+ "Modified Version" refers to any derivative made by adding to, deleting,
60
+ or substituting -- in part or in whole -- any of the components of the
61
+ Original Version, by changing formats or by porting the Font Software to a
62
+ new environment.
63
+
64
+ "Author" refers to any designer, engineer, programmer, technical
65
+ writer or other person who contributed to the Font Software.
66
+
67
+ PERMISSION & CONDITIONS
68
+ Permission is hereby granted, free of charge, to any person obtaining
69
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
70
+ redistribute, and sell modified and unmodified copies of the Font
71
+ Software, subject to the following conditions:
72
+
73
+ 1) Neither the Font Software nor any of its individual components,
74
+ in Original or Modified Versions, may be sold by itself.
75
+
76
+ 2) Original or Modified Versions of the Font Software may be bundled,
77
+ redistributed and/or sold with any software, provided that each copy
78
+ contains the above copyright notice and this license. These can be
79
+ included either as stand-alone text files, human-readable headers or
80
+ in the appropriate machine-readable metadata fields within text or
81
+ binary files as long as those fields can be easily viewed by the user.
82
+
83
+ 3) No Modified Version of the Font Software may use the Reserved Font
84
+ Name(s) unless explicit written permission is granted by the corresponding
85
+ Copyright Holder. This restriction only applies to the primary font name as
86
+ presented to the users.
87
+
88
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
89
+ Software shall not be used to promote, endorse or advertise any
90
+ Modified Version, except to acknowledge the contribution(s) of the
91
+ Copyright Holder(s) and the Author(s) or with their explicit written
92
+ permission.
93
+
94
+ 5) The Font Software, modified or unmodified, in part or in whole,
95
+ must be distributed entirely under this license, and must not be
96
+ distributed under any other license. The requirement for fonts to
97
+ remain under this license does not apply to any document created
98
+ using the Font Software.
99
+
100
+ TERMINATION
101
+ This license becomes null and void if any of the above conditions are
102
+ not met.
103
+
104
+ DISCLAIMER
105
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
106
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
107
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
108
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
109
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
110
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
111
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
112
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
113
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
data/bin/gemba ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # When running from a development checkout (not installed as a gem),
5
+ # add lib/ to the load path and activate Bundler for gem dependencies.
6
+ if File.exist?(File.expand_path("../lib/gemba.rb", __dir__))
7
+ require "bundler/setup"
8
+ path = File.expand_path("../lib", __dir__)
9
+ $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
10
+ end
11
+
12
+ require_relative "../lib/gemba/cli"
13
+
14
+ Gemba::CLI.run
@@ -0,0 +1,185 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+
5
+ # On Windows (MinGW/UCRT), Ruby's win32.h and mingw-w64's sys/time.h both
6
+ # declare gettimeofday() with incompatible signatures. Defining this guard
7
+ # suppresses mingw-w64's declaration so Ruby's is the only one in scope.
8
+ # See: https://github.com/rake-compiler/rake-compiler-dock/issues/32
9
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/
10
+ $CPPFLAGS << ' -D_GETTIMEOFDAY_DEFINED'
11
+ end
12
+
13
+ # Diagnostic dump for CI debugging — written before any search so we can
14
+ # always see what the environment looks like, even when the build fails.
15
+ def dump_mgba_search_diagnostics
16
+ puts "=" * 60
17
+ puts "gemba extconf.rb diagnostics"
18
+ puts "=" * 60
19
+ puts "RUBY_PLATFORM: #{RUBY_PLATFORM}"
20
+ puts "RbConfig host_os: #{RbConfig::CONFIG['host_os']}"
21
+ puts "RbConfig prefix: #{RbConfig::CONFIG['prefix']}"
22
+ puts "RbConfig sitearchdir: #{RbConfig::CONFIG['sitearchdir']}"
23
+ puts "MGBA_DIR env: #{ENV['MGBA_DIR'].inspect}"
24
+ puts "PKG_CONFIG_PATH env: #{ENV['PKG_CONFIG_PATH'].inspect}"
25
+ puts "PATH (first 3): #{ENV['PATH']&.split(File::PATH_SEPARATOR)&.first(3)&.join(', ')}"
26
+
27
+ # Check common locations for mgba headers/libs
28
+ candidates = [
29
+ RbConfig::CONFIG['prefix'],
30
+ "#{RbConfig::CONFIG['prefix']}/msys64/ucrt64",
31
+ '/ucrt64',
32
+ '/usr',
33
+ '/usr/local',
34
+ '/opt/homebrew',
35
+ ]
36
+
37
+ candidates.each do |prefix|
38
+ inc = "#{prefix}/include/mgba/core/core.h"
39
+ libs = Dir.glob("#{prefix}/lib/*mgba*") rescue []
40
+ bins = Dir.glob("#{prefix}/bin/*mgba*") rescue []
41
+ next if !File.exist?(inc) && libs.empty? && bins.empty?
42
+ puts "\n #{prefix}/"
43
+ puts " header: #{File.exist?(inc) ? 'FOUND' : 'missing'} (#{inc})"
44
+ puts " libs: #{libs.empty? ? 'none' : libs.join(', ')}"
45
+ puts " bins: #{bins.empty? ? 'none' : bins.join(', ')}"
46
+ end
47
+
48
+ # On Windows, also check what pacman says
49
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/
50
+ msys2_root = "#{RbConfig::CONFIG['prefix']}/msys64"
51
+ pacman = "#{msys2_root}/usr/bin/pacman"
52
+ if File.exist?(pacman)
53
+ puts "\npacman -Q mgba:"
54
+ puts `"#{pacman}" -Q 2>&1`.lines.grep(/mgba/i).map { |l| " #{l}" }.join
55
+ puts "pacman -Ql mgba (headers/libs only):"
56
+ ql = `"#{pacman}" -Ql mingw-w64-ucrt-x86_64-mgba 2>&1`
57
+ puts ql.lines.grep(/\.(h|a|dll|lib|pc)/).first(20).map { |l| " #{l}" }.join
58
+ else
59
+ puts "\npacman not found at #{pacman}"
60
+ end
61
+ end
62
+
63
+ puts "=" * 60
64
+ end
65
+
66
+ dump_mgba_search_diagnostics
67
+
68
+ def add_mgba_deps
69
+ # Common dependencies of libmgba (needed when linking statically)
70
+ $libs << " -lz" unless $libs.include?('-lz')
71
+ $libs << " -lm" unless $libs.include?('-lm')
72
+ $libs << " -lpthread" unless $libs.include?('-lpthread')
73
+
74
+ # libmgba's static build also links libpng and libzip
75
+ pkg_config('libpng') || ($libs << " -lpng" unless $libs.include?('-lpng'))
76
+ pkg_config('libzip') || ($libs << " -lzip" unless $libs.include?('-lzip'))
77
+
78
+ # macOS: CoreFoundation for config directory resolution
79
+ if RUBY_PLATFORM =~ /darwin/
80
+ $LDFLAGS << " -framework CoreFoundation" unless $LDFLAGS.include?('CoreFoundation')
81
+ end
82
+ end
83
+
84
+ def check_mgba
85
+ have_header('mgba/core/core.h') or return false
86
+ # Try with deps first (needed for static linking on macOS where
87
+ # -undefined dynamic_lookup hides missing symbols until runtime)
88
+ saved_libs = $libs.dup
89
+ add_mgba_deps
90
+ return true if have_library('mgba')
91
+ # Fall back without deps (shared lib on Linux — deps baked into .so)
92
+ $libs = saved_libs
93
+ have_library('mgba')
94
+ end
95
+
96
+ def find_mgba
97
+ # 1. MGBA_DIR env var (explicit override)
98
+ if ENV['MGBA_DIR']
99
+ dir = ENV['MGBA_DIR']
100
+ $INCFLAGS << " -I#{dir}/include"
101
+ $LDFLAGS << " -L#{dir}/lib"
102
+ if check_mgba
103
+ return true
104
+ end
105
+ abort "MGBA_DIR=#{dir} set but libmgba not found there"
106
+ end
107
+
108
+ # 2. Vendor install (from `rake mgba:deps`)
109
+ vendor_install = File.expand_path('../../vendor/install', __dir__)
110
+ if File.directory?(vendor_install)
111
+ $INCFLAGS << " -I#{vendor_install}/include"
112
+ $LDFLAGS << " -L#{vendor_install}/lib"
113
+ if check_mgba
114
+ return true
115
+ end
116
+ end
117
+
118
+ # 3. pkg-config
119
+ if pkg_config('mgba')
120
+ add_mgba_deps
121
+ return true
122
+ end
123
+
124
+ # 4. Homebrew / common prefix paths (macOS) / system paths (Linux)
125
+ search_prefixes = [
126
+ '/opt/homebrew', # Apple Silicon
127
+ '/usr/local', # Intel Homebrew / manual builds
128
+ '/usr' # System
129
+ ]
130
+
131
+ # Debian/Ubuntu multiarch lib dirs (e.g. /usr/lib/aarch64-linux-gnu)
132
+ multiarch_dirs = Dir.glob('/usr/lib/*-linux-gnu').select { |d| File.directory?(d) }
133
+
134
+ search_prefixes.each do |prefix|
135
+ inc = "#{prefix}/include"
136
+ if File.exist?("#{inc}/mgba/core/core.h")
137
+ $INCFLAGS << " -I#{inc}"
138
+ multiarch_dirs.each { |d| $LDFLAGS << " -L#{d}" unless $LDFLAGS.include?(d) }
139
+ $LDFLAGS << " -L#{prefix}/lib" unless $LDFLAGS.include?("#{prefix}/lib")
140
+ if check_mgba
141
+ return true
142
+ end
143
+ end
144
+ end
145
+
146
+ # 5. MSYS2/MinGW (Windows) — mgba has no .pc file so pkg-config won't find it
147
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/
148
+ ruby_prefix = RbConfig::CONFIG['prefix']
149
+ msys2_prefixes = [
150
+ "#{ruby_prefix}/msys64/ucrt64", # UCRT64 env inside Ruby's MSYS2
151
+ "#{ruby_prefix}/msys64/mingw64", # MINGW64 env
152
+ ruby_prefix, # Direct prefix (standalone MSYS2)
153
+ ]
154
+
155
+ msys2_prefixes.each do |prefix|
156
+ inc = "#{prefix}/include"
157
+ lib = "#{prefix}/lib"
158
+ if File.exist?("#{inc}/mgba/core/core.h")
159
+ $INCFLAGS << " -I#{inc}"
160
+ $LDFLAGS << " -L#{lib}"
161
+ if check_mgba
162
+ return true
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ false
169
+ end
170
+
171
+ unless find_mgba
172
+ abort <<~MSG
173
+ libmgba not found. Install it:
174
+
175
+ macOS: rake deps (builds from source)
176
+ Debian: sudo apt install libmgba-dev
177
+ Windows: pacman -S mingw-w64-ucrt-x86_64-mgba (MSYS2)
178
+
179
+ Or set MGBA_DIR=/path/to/mgba/install
180
+ MSG
181
+ end
182
+
183
+ $srcs = ['gemba_ext.c']
184
+
185
+ create_makefile('gemba_ext')