mos6510 0.1.1 → 0.1.3

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: c1927df1cea683c92fa0ae002561b2f45038c73ba643df8b1a754f29d17baac0
4
- data.tar.gz: 22aadae8ca292253552029f949c7149849a1856b4ace763deaf08962c271603c
3
+ metadata.gz: ba8bdd4a50128bae8029b543930ac001d3d458667d42cca6fdfa98dd3e6428ee
4
+ data.tar.gz: fe874fe7083bff2b5478f3bbef3055fb7bb011615372c702db062b34ecaf9519
5
5
  SHA512:
6
- metadata.gz: ef97362b9a142a5a1f054075f41e98f7347865771e316f7113b58f2174fb6b01e0fb05c0b6bb845ff413629a27fe648dc574e7f4729ffabf731e4bb0f1231ea9
7
- data.tar.gz: ba8db5d0b2b31e91fe5811cfa32b867b63a59ee18a59d229f8fb10f41761335cd5f6ece1a0750fa8016f2d94137c6746c5db1df35bb3a542c0354e42574489d2
6
+ metadata.gz: 8baadc0f4cf8e047a3de48c943554dead32df7cf866dc52814bb38fb0ec88a07513557b1ed19e577d71bc950de01b3a653fd9a190bc034ca6b5367d29c87807b
7
+ data.tar.gz: 18e83005a3aa7ae75dbf630331edfae281ac0cd6d187b890922e30fb9fb276cefbce926caee9e3833ac54a41f219d6decf5643f6a79be9cf2cff8b70fcc1f9b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+ Bumped versions of mini_racer so we can run on Ruby 3.1. Also bumped rspec.
5
+
3
6
  ## 0.1.1
4
7
  Bumped version of mini_racer, as 0.2.6 doesn't want to compile and install on my Mac.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,30 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mos6510 (0.1.1)
5
- mini_racer (~> 0.3.1)
4
+ mos6510 (0.1.3)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
- diff-lcs (1.3)
11
- libv8 (8.4.255.0-x86_64-darwin-19)
12
- mini_racer (0.3.1)
13
- libv8 (~> 8.4.255)
9
+ coderay (1.1.3)
10
+ diff-lcs (1.5.0)
11
+ method_source (1.0.0)
12
+ pry (0.14.1)
13
+ coderay (~> 1.1)
14
+ method_source (~> 1.0)
14
15
  rake (10.5.0)
15
- rspec (3.8.0)
16
- rspec-core (~> 3.8.0)
17
- rspec-expectations (~> 3.8.0)
18
- rspec-mocks (~> 3.8.0)
19
- rspec-core (3.8.2)
20
- rspec-support (~> 3.8.0)
21
- rspec-expectations (3.8.4)
16
+ rspec (3.11.0)
17
+ rspec-core (~> 3.11.0)
18
+ rspec-expectations (~> 3.11.0)
19
+ rspec-mocks (~> 3.11.0)
20
+ rspec-core (3.11.0)
21
+ rspec-support (~> 3.11.0)
22
+ rspec-expectations (3.11.0)
22
23
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.8.0)
24
- rspec-mocks (3.8.1)
24
+ rspec-support (~> 3.11.0)
25
+ rspec-mocks (3.11.1)
25
26
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.8.0)
27
- rspec-support (3.8.2)
27
+ rspec-support (~> 3.11.0)
28
+ rspec-support (3.11.0)
28
29
 
29
30
  PLATFORMS
30
31
  ruby
@@ -32,8 +33,9 @@ PLATFORMS
32
33
  DEPENDENCIES
33
34
  bundler (~> 2.0)
34
35
  mos6510!
36
+ pry (~> 0.14)
35
37
  rake (~> 10.0)
36
- rspec (~> 3.0)
38
+ rspec (~> 3.11)
37
39
 
38
40
  BUNDLED WITH
39
41
  2.1.4
data/README.md CHANGED
@@ -7,9 +7,10 @@ Additionally, the gem allows you to supply an object which simulates the SID pro
7
7
  (Sound Interface Device - the sound chip from the Commodore 64). This object will receive
8
8
  `poke` calls whenever the simulated program writes to the addresses mapped to the SID.
9
9
 
10
- Be warned: This gem is a HUGE hack! Basically it is just wrapping a MOS 6510 simulator
11
- stolen (*) from the [jsSID](https://github.com/jhohertz/jsSID) project. I'd love to do a
12
- pure-Ruby implementation one day, but just needed a MOS 6510 emulator for another project.
10
+ Be warned: This is just a very raw conversion of a JavaScript implementation stolen (*)
11
+ from the [jsSID](https://github.com/jhohertz/jsSID) project. It has bugs, probably
12
+ because of my conversion. I'd love fix this one day, but just needed a MOS 6510 emulator
13
+ for another project.
13
14
 
14
15
  (*) This explains the GPL v2 license of this project.
15
16
 
data/lib/mos6510/cpu.rb CHANGED
@@ -1,51 +1,38 @@
1
- require 'mini_racer'
2
-
3
1
  module Mos6510
4
2
  class Cpu
5
3
  def initialize(sid: nil)
6
- @context = MiniRacer::Context.new
7
-
8
- # Just define the name space used by the main mos6510 emulator
9
- @context.eval 'function jsSID() {}'
10
-
11
- @context.load(File.join(__dir__, 'jssid.mos6510.js'))
12
-
13
- @context.eval <<~EOS
14
- var memory = new Array(65536);
15
- for(var i=0; i<65536; i++) {
16
- memory[i]=0;
17
- }
18
- var sid = null;
19
- EOS
20
-
21
- if sid
22
- @context.attach("sidPoke", proc{ |address, value| sid.poke(address, value) })
23
- @context.eval <<~EOS
24
- sid = {
25
- poke: function(address, value) { sidPoke(address, value); }
26
- };
27
- EOS
28
- end
4
+ @memory = [0] * 65536
5
+ @sid = sid
29
6
  end
30
7
 
31
8
  def load(bytes, from: 0)
32
9
  bytes.each_with_index do |byte, index|
33
- @context.eval "memory[#{from + index}] = #{byte};"
10
+ @memory[from + index] = byte
34
11
  end
35
12
  end
36
13
 
37
14
  def start
38
- @context.eval <<~EOS
39
- var cpu = new jsSID.MOS6510(memory, sid);
40
- EOS
15
+ @cpu = Mos6510.new(@memory, sid: @sid)
41
16
  end
42
17
 
43
18
  def jsr(address, accumulator_value=0)
44
- @context.eval "cpu.cpuJSR(#{address}, #{accumulator_value});"
19
+ @cpu.jsr(address, accumulator_value)
20
+ end
21
+
22
+ def step
23
+ @cpu.step
24
+ end
25
+
26
+ def pc
27
+ @cpu.pc
28
+ end
29
+
30
+ def pc=(new_pc)
31
+ @cpu.pc = new_pc
45
32
  end
46
33
 
47
34
  def peek(address)
48
- @context.eval "cpu.mem[#{address}]"
35
+ @cpu.getmem(address)
49
36
  end
50
37
  end
51
38
  end