amaterasu 0.6.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 (158) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +54 -0
  5. data/Gemfile +32 -0
  6. data/Gemfile.lock +267 -0
  7. data/LICENSE +21 -0
  8. data/README.md +115 -0
  9. data/Steepfile +7 -0
  10. data/exe/amaterasu +23 -0
  11. data/lib/amaterasu/cartridge/mbc1.rb +56 -0
  12. data/lib/amaterasu/cartridge/rom.rb +118 -0
  13. data/lib/amaterasu/cartridge.rb +68 -0
  14. data/lib/amaterasu/cli.rb +60 -0
  15. data/lib/amaterasu/emulator.rb +121 -0
  16. data/lib/amaterasu/game_boy/apu.rb +12 -0
  17. data/lib/amaterasu/game_boy/bus.rb +161 -0
  18. data/lib/amaterasu/game_boy/cpu/instructions/adc.rb +64 -0
  19. data/lib/amaterasu/game_boy/cpu/instructions/add16.rb +73 -0
  20. data/lib/amaterasu/game_boy/cpu/instructions/add8.rb +63 -0
  21. data/lib/amaterasu/game_boy/cpu/instructions/and.rb +62 -0
  22. data/lib/amaterasu/game_boy/cpu/instructions/base.rb +38 -0
  23. data/lib/amaterasu/game_boy/cpu/instructions/call.rb +48 -0
  24. data/lib/amaterasu/game_boy/cpu/instructions/cb_bit.rb +52 -0
  25. data/lib/amaterasu/game_boy/cpu/instructions/cb_res.rb +49 -0
  26. data/lib/amaterasu/game_boy/cpu/instructions/cb_rl.rb +70 -0
  27. data/lib/amaterasu/game_boy/cpu/instructions/cb_rlc.rb +68 -0
  28. data/lib/amaterasu/game_boy/cpu/instructions/cb_rr.rb +70 -0
  29. data/lib/amaterasu/game_boy/cpu/instructions/cb_rrc.rb +68 -0
  30. data/lib/amaterasu/game_boy/cpu/instructions/cb_set.rb +51 -0
  31. data/lib/amaterasu/game_boy/cpu/instructions/cb_sla.rb +69 -0
  32. data/lib/amaterasu/game_boy/cpu/instructions/cb_sra.rb +71 -0
  33. data/lib/amaterasu/game_boy/cpu/instructions/cb_srl.rb +69 -0
  34. data/lib/amaterasu/game_boy/cpu/instructions/cb_swap.rb +67 -0
  35. data/lib/amaterasu/game_boy/cpu/instructions/cp.rb +61 -0
  36. data/lib/amaterasu/game_boy/cpu/instructions/daa.rb +59 -0
  37. data/lib/amaterasu/game_boy/cpu/instructions/dec.rb +64 -0
  38. data/lib/amaterasu/game_boy/cpu/instructions/di.rb +21 -0
  39. data/lib/amaterasu/game_boy/cpu/instructions/ei.rb +19 -0
  40. data/lib/amaterasu/game_boy/cpu/instructions/halt.rb +19 -0
  41. data/lib/amaterasu/game_boy/cpu/instructions/inc.rb +64 -0
  42. data/lib/amaterasu/game_boy/cpu/instructions/jp.rb +54 -0
  43. data/lib/amaterasu/game_boy/cpu/instructions/jr.rb +45 -0
  44. data/lib/amaterasu/game_boy/cpu/instructions/ld16.rb +79 -0
  45. data/lib/amaterasu/game_boy/cpu/instructions/ld8.rb +210 -0
  46. data/lib/amaterasu/game_boy/cpu/instructions/ldh.rb +61 -0
  47. data/lib/amaterasu/game_boy/cpu/instructions/misc.rb +53 -0
  48. data/lib/amaterasu/game_boy/cpu/instructions/nop.rb +19 -0
  49. data/lib/amaterasu/game_boy/cpu/instructions/or.rb +56 -0
  50. data/lib/amaterasu/game_boy/cpu/instructions/pop.rb +39 -0
  51. data/lib/amaterasu/game_boy/cpu/instructions/push.rb +43 -0
  52. data/lib/amaterasu/game_boy/cpu/instructions/ret.rb +70 -0
  53. data/lib/amaterasu/game_boy/cpu/instructions/rotate.rb +120 -0
  54. data/lib/amaterasu/game_boy/cpu/instructions/rst.rb +33 -0
  55. data/lib/amaterasu/game_boy/cpu/instructions/sbc.rb +64 -0
  56. data/lib/amaterasu/game_boy/cpu/instructions/stop.rb +19 -0
  57. data/lib/amaterasu/game_boy/cpu/instructions/sub.rb +63 -0
  58. data/lib/amaterasu/game_boy/cpu/instructions/xor.rb +60 -0
  59. data/lib/amaterasu/game_boy/cpu/instructions.rb +600 -0
  60. data/lib/amaterasu/game_boy/cpu/registers.rb +264 -0
  61. data/lib/amaterasu/game_boy/cpu.rb +232 -0
  62. data/lib/amaterasu/game_boy/dma.rb +114 -0
  63. data/lib/amaterasu/game_boy/interrupts.rb +108 -0
  64. data/lib/amaterasu/game_boy/joypad.rb +127 -0
  65. data/lib/amaterasu/game_boy/oam/sprite.rb +106 -0
  66. data/lib/amaterasu/game_boy/oam.rb +29 -0
  67. data/lib/amaterasu/game_boy/ppu/modes/disabled.rb +29 -0
  68. data/lib/amaterasu/game_boy/ppu/modes/h_blank.rb +45 -0
  69. data/lib/amaterasu/game_boy/ppu/modes/oam_scan.rb +93 -0
  70. data/lib/amaterasu/game_boy/ppu/modes/rendering/bg_win_fetcher.rb +204 -0
  71. data/lib/amaterasu/game_boy/ppu/modes/rendering/pixel_emitter.rb +83 -0
  72. data/lib/amaterasu/game_boy/ppu/modes/rendering/pixel_fifo.rb +70 -0
  73. data/lib/amaterasu/game_boy/ppu/modes/rendering/sprite_fetcher.rb +140 -0
  74. data/lib/amaterasu/game_boy/ppu/modes/rendering.rb +108 -0
  75. data/lib/amaterasu/game_boy/ppu/modes/v_blank.rb +43 -0
  76. data/lib/amaterasu/game_boy/ppu/modes.rb +22 -0
  77. data/lib/amaterasu/game_boy/ppu/registers/lcd_control.rb +57 -0
  78. data/lib/amaterasu/game_boy/ppu/registers/lcd_status.rb +88 -0
  79. data/lib/amaterasu/game_boy/ppu/registers.rb +131 -0
  80. data/lib/amaterasu/game_boy/ppu.rb +207 -0
  81. data/lib/amaterasu/game_boy/ram.rb +70 -0
  82. data/lib/amaterasu/game_boy/serial.rb +91 -0
  83. data/lib/amaterasu/game_boy/timer.rb +230 -0
  84. data/lib/amaterasu/game_boy/vram/tile.rb +68 -0
  85. data/lib/amaterasu/game_boy/vram/tile_data.rb +52 -0
  86. data/lib/amaterasu/game_boy/vram/tile_map.rb +71 -0
  87. data/lib/amaterasu/game_boy/vram.rb +51 -0
  88. data/lib/amaterasu/hal/console.rb +23 -0
  89. data/lib/amaterasu/hal/sdl2/bindings.rb +59 -0
  90. data/lib/amaterasu/hal/sdl2.rb +127 -0
  91. data/lib/amaterasu/utils/bit_ops.rb +22 -0
  92. data/lib/amaterasu.rb +13 -0
  93. data/sig/akane/cartridge/rom.rbs +29 -0
  94. data/sig/akane/cartridge.rbs +12 -0
  95. data/sig/akane/cli.rbs +16 -0
  96. data/sig/akane/emulator.rbs +19 -0
  97. data/sig/akane/game_boy/apu.rbs +7 -0
  98. data/sig/akane/game_boy/bus.rbs +25 -0
  99. data/sig/akane/game_boy/cpu/instructions/adc.rbs +18 -0
  100. data/sig/akane/game_boy/cpu/instructions/add16.rbs +19 -0
  101. data/sig/akane/game_boy/cpu/instructions/add8.rbs +18 -0
  102. data/sig/akane/game_boy/cpu/instructions/and.rbs +18 -0
  103. data/sig/akane/game_boy/cpu/instructions/base.rbs +20 -0
  104. data/sig/akane/game_boy/cpu/instructions/call.rbs +18 -0
  105. data/sig/akane/game_boy/cpu/instructions/cb_bit.rbs +20 -0
  106. data/sig/akane/game_boy/cpu/instructions/cb_res.rbs +19 -0
  107. data/sig/akane/game_boy/cpu/instructions/cb_rl.rbs +21 -0
  108. data/sig/akane/game_boy/cpu/instructions/cb_rlc.rbs +21 -0
  109. data/sig/akane/game_boy/cpu/instructions/cb_rr.rbs +21 -0
  110. data/sig/akane/game_boy/cpu/instructions/cb_rrc.rbs +21 -0
  111. data/sig/akane/game_boy/cpu/instructions/cb_set.rbs +20 -0
  112. data/sig/akane/game_boy/cpu/instructions/cb_sla.rbs +21 -0
  113. data/sig/akane/game_boy/cpu/instructions/cb_sra.rbs +21 -0
  114. data/sig/akane/game_boy/cpu/instructions/cb_srl.rbs +21 -0
  115. data/sig/akane/game_boy/cpu/instructions/cb_swap.rbs +21 -0
  116. data/sig/akane/game_boy/cpu/instructions/cp.rbs +18 -0
  117. data/sig/akane/game_boy/cpu/instructions/daa.rbs +17 -0
  118. data/sig/akane/game_boy/cpu/instructions/dec.rbs +19 -0
  119. data/sig/akane/game_boy/cpu/instructions/di.rbs +13 -0
  120. data/sig/akane/game_boy/cpu/instructions/ei.rbs +13 -0
  121. data/sig/akane/game_boy/cpu/instructions/halt.rbs +13 -0
  122. data/sig/akane/game_boy/cpu/instructions/inc.rbs +19 -0
  123. data/sig/akane/game_boy/cpu/instructions/jp.rbs +18 -0
  124. data/sig/akane/game_boy/cpu/instructions/jr.rbs +18 -0
  125. data/sig/akane/game_boy/cpu/instructions/ld16.rbs +18 -0
  126. data/sig/akane/game_boy/cpu/instructions/ld8.rbs +31 -0
  127. data/sig/akane/game_boy/cpu/instructions/ldh.rbs +23 -0
  128. data/sig/akane/game_boy/cpu/instructions/misc.rbs +20 -0
  129. data/sig/akane/game_boy/cpu/instructions/nop.rbs +13 -0
  130. data/sig/akane/game_boy/cpu/instructions/or.rbs +18 -0
  131. data/sig/akane/game_boy/cpu/instructions/pop.rbs +17 -0
  132. data/sig/akane/game_boy/cpu/instructions/push.rbs +18 -0
  133. data/sig/akane/game_boy/cpu/instructions/ret.rbs +20 -0
  134. data/sig/akane/game_boy/cpu/instructions/rotate.rbs +23 -0
  135. data/sig/akane/game_boy/cpu/instructions/rst.rbs +17 -0
  136. data/sig/akane/game_boy/cpu/instructions/sbc.rbs +19 -0
  137. data/sig/akane/game_boy/cpu/instructions/stop.rbs +13 -0
  138. data/sig/akane/game_boy/cpu/instructions/sub.rbs +18 -0
  139. data/sig/akane/game_boy/cpu/instructions/xor.rbs +19 -0
  140. data/sig/akane/game_boy/cpu/instructions.rbs +12 -0
  141. data/sig/akane/game_boy/cpu/registers.rbs +56 -0
  142. data/sig/akane/game_boy/cpu.rbs +39 -0
  143. data/sig/akane/game_boy/interrupts.rbs +28 -0
  144. data/sig/akane/game_boy/joypad.rbs +25 -0
  145. data/sig/akane/game_boy/oam/sprite.rbs +30 -0
  146. data/sig/akane/game_boy/ppu/modes/disabled.rbs +17 -0
  147. data/sig/akane/game_boy/ppu/modes/h_blank.rbs +20 -0
  148. data/sig/akane/game_boy/ppu/modes/oam_scan.rbs +28 -0
  149. data/sig/akane/game_boy/ppu/modes/rendering.rbs +26 -0
  150. data/sig/akane/game_boy/ppu/modes/v_blank.rbs +20 -0
  151. data/sig/akane/game_boy/ppu/modes.rbs +13 -0
  152. data/sig/akane/game_boy/ppu.rbs +59 -0
  153. data/sig/akane/game_boy/ram.rbs +16 -0
  154. data/sig/akane/game_boy/serial.rbs +21 -0
  155. data/sig/akane/game_boy/timer.rbs +30 -0
  156. data/sig/akane/utils/bit_ops.rbs +11 -0
  157. data/sig/akane.rbs +3 -0
  158. metadata +226 -0
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module Utils
5
+ # Bit Operation utility module.
6
+ module BitOps
7
+ module_function
8
+
9
+ def set_bit(value, pos)
10
+ value | (1 << pos)
11
+ end
12
+
13
+ def clear_bit(value, pos)
14
+ value & ~(1 << pos)
15
+ end
16
+
17
+ def bit(value, pos)
18
+ (value >> pos) & 1
19
+ end
20
+ end
21
+ end
22
+ end
data/lib/amaterasu.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zeitwerk'
4
+ require 'debug'
5
+
6
+ loader = Zeitwerk::Loader.for_gem
7
+ loader.inflector.inflect('cli' => 'CLI')
8
+ loader.inflector.inflect('hal' => 'HAL')
9
+ loader.inflector.inflect('sdl2' => 'SDL2')
10
+ loader.setup
11
+
12
+ # Base module to mirror the emulator name and group everything.
13
+ module Amaterasu; end
@@ -0,0 +1,29 @@
1
+ module Amaterasu
2
+ class Cartridge
3
+ class Rom
4
+ CARTRIDGE_TYPES: Hash[Integer, Symbol]
5
+ ROM_SIZES: Hash[Integer, Integer]
6
+ RAM_SIZES: Hash[Integer, Integer]
7
+
8
+ def self.from_file: (String file_path) -> Rom
9
+
10
+ def initialize: (Array[Integer] data) -> void
11
+
12
+ def read_byte: (Integer offset) -> Integer
13
+ def header: () -> Array[Integer]
14
+ def title: () -> String
15
+ def manufacturer_code: () -> Array[Integer]
16
+ def cgb_flag: () -> Integer
17
+ def new_licensee_code: () -> Array[Integer]
18
+ def sgb_flag: () -> Integer
19
+ def cartridge_type: () -> Symbol
20
+ def rom_size: () -> Integer
21
+ def ram_size: () -> Integer
22
+ def destination_code: () -> Integer
23
+ def old_licensee_code: () -> Integer
24
+ def mask_rom_version: () -> Integer
25
+ def header_checksum: () -> Integer
26
+ def valid_checksum?: () -> bool
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ module Amaterasu
2
+ class Cartridge
3
+ def self.load_rom: (String file_path) -> Cartridge
4
+
5
+ def initialize: (rom: Rom, ?mbc: nil, ?ram: nil) -> void
6
+
7
+ def read_rom: (Integer offset) -> Integer
8
+ def write_rom: (Integer offset, Integer value) -> void
9
+ def read_ram: (Integer offset) -> Integer
10
+ def write_ram: (Integer offset, Integer value) -> void
11
+ end
12
+ end
data/sig/akane/cli.rbs ADDED
@@ -0,0 +1,16 @@
1
+ module Amaterasu
2
+ class CLI
3
+ type emulator_options = {
4
+ audio: String?,
5
+ cycles: Integer?,
6
+ debug: bool,
7
+ profile: Symbol?,
8
+ steps: Integer?,
9
+ trace: Array[String]?,
10
+ video: String?,
11
+ rom_path: String
12
+ }
13
+
14
+ def self.parse: (Array[String] arguments) -> emulator_options
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module Amaterasu
2
+ class Emulator
3
+ CYCLES_PER_FRAME: Integer
4
+
5
+ def initialize: (
6
+ audio: String,
7
+ cycles: Integer,
8
+ debug: bool,
9
+ profiling: String,
10
+ steps: Integer,
11
+ trace: String,
12
+ video: String,
13
+ rom_path: String
14
+ ) -> void
15
+ def start: (CLI::emulator_options options) -> void
16
+ def advance_cycle: () -> void
17
+ def stop: () -> void
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module Amaterasu
2
+ module GameBoy
3
+ class Apu
4
+ def tick: () -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ module Amaterasu
2
+ module GameBoy
3
+ class Bus
4
+ def initialize: (
5
+ cartridge: Amaterasu::Cartridge,
6
+ ppu: Ppu,
7
+ apu: Apu,
8
+ wram: Ram,
9
+ hram: Ram,
10
+ interrupts: Interrupts,
11
+ timer: Timer,
12
+ serial: Serial,
13
+ joypad: Joypad
14
+ ) -> void
15
+
16
+ def read_byte: (address: Integer) -> Integer
17
+ def write_byte: (address: Integer, value: Integer) -> void
18
+
19
+ private
20
+
21
+ def read_io: (Integer address) -> Integer
22
+ def write_io: (Integer address, Integer value) -> void
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Adc < Base
8
+ def initialize: (cpu: Cpu, source: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol source) -> Proc
13
+ def adc_a: (Integer value) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Add16 < Base
8
+ def initialize: (cpu: Cpu, target: Symbol, source: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol source, Symbol target) -> Proc
13
+ def add16: (Integer value) -> void
14
+ def add16_sig8: () -> void
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Add8 < Base
8
+ def initialize: (cpu: Cpu, source: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol source) -> Proc
13
+ def add_a: (Integer value) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class And < Base
8
+ def initialize: (cpu: Cpu, source: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol source) -> Proc
13
+ def and_a: (Integer value) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Base
8
+ attr_reader mnemonic: String
9
+
10
+ def initialize: (cpu: Cpu) -> void
11
+ def execute: () -> void
12
+
13
+ private
14
+
15
+ def format_operand: (Symbol ?operand) -> String
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Call < Base
8
+ def initialize: (cpu: Cpu, ?condition: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol ?condition) -> Proc
13
+ def call: (bool condition) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbBit < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, bit_pos: Integer, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Integer bit_pos, Symbol target) -> Proc
15
+ def bit_test: (Integer bit, Integer target_value) -> void
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbRes < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, bit_pos: Integer, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Integer bit_pos, Symbol target) -> Proc
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbRl < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def rl_reg8: (Integer reg8_value) -> void
16
+ def rl_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbRlc < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def rlc_reg8: (Integer reg8_value) -> void
16
+ def rlc_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbRr < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def rr_reg8: (Integer reg8_value) -> void
16
+ def rr_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbRrc < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def rrc_reg8: (Integer reg8_value) -> void
16
+ def rrc_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbSet < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, bit_pos: Integer, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Integer bit_pos, Symbol target) -> Proc
15
+ def set: (Integer bit_pos, Symbol target) -> void
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbSla < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def sla_reg8: (Integer reg8_value) -> void
16
+ def sla_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbSra < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def sra_reg8: (Integer reg8) -> void
16
+ def sra_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbSrl < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def srl_reg8: (Integer reg8) -> void
16
+ def srl_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class CbSwap < Base
8
+ include Utils::BitOps
9
+
10
+ def initialize: (cpu: Cpu, target: Symbol) -> void
11
+
12
+ private
13
+
14
+ def build_logic: (Symbol target) -> Proc
15
+ def swap: (Integer reg8) -> void
16
+ def swap_mem_hl: () -> void
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Cp < Base
8
+ def initialize: (cpu: Cpu, source: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol source) -> Proc
13
+ def cp_a: (Integer value) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Daa < Base
8
+ def initialize: (cpu: Cpu) -> void
9
+
10
+ private
11
+
12
+ def daa: () -> void
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Dec < Base
8
+ def initialize: (cpu: Cpu, operand: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol operand) -> Proc
13
+ def dec: (Integer value) -> Integer
14
+ def dec16: (Integer value) -> void
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Di < Base
8
+ def initialize: (cpu: Cpu) -> void
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Ei < Base
8
+ def initialize: (cpu: Cpu) -> void
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Halt < Base
8
+ def initialize: (cpu: Cpu) -> void
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Inc < Base
8
+ def initialize: (cpu: Cpu, operand: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol operand) -> Proc
13
+ def inc: (Integer value) -> Integer
14
+ def inc16: (Integer value) -> void
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Jp < Base
8
+ def initialize: (cpu: Cpu, location: Symbol, ?condition: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol location, Symbol ?condition) -> Proc
13
+ def jp: (condition: bool) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Amaterasu
4
+ module GameBoy
5
+ class Cpu
6
+ module Instructions
7
+ class Jr < Base
8
+ def initialize: (cpu: Cpu, ?condition: Symbol) -> void
9
+
10
+ private
11
+
12
+ def build_logic: (Symbol ?condition) -> Proc
13
+ def jr: (bool condition) -> void
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end