mos6510 0.1.2 → 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: 6bc91397c661fd7527b56cbb2ff74e164aeae1bc24bcfe3ccc346a612a1cd3e6
4
- data.tar.gz: 430f09a9f00e20e0097eebd836f578abd421096208e4d30cbfc22a0b7744c63b
3
+ metadata.gz: ba8bdd4a50128bae8029b543930ac001d3d458667d42cca6fdfa98dd3e6428ee
4
+ data.tar.gz: fe874fe7083bff2b5478f3bbef3055fb7bb011615372c702db062b34ecaf9519
5
5
  SHA512:
6
- metadata.gz: 4275d34503ca804d4ea3d4f3d7c767c2b3ccb79870328ad9a2ae14f0f4532b1d9710ac6ddbef82b14c6358e4bbf2cb5cad4c436136d3178e69687b69d2becbf6
7
- data.tar.gz: d05c8f6bdcb23af228133a0b1343afc008f90c776bea8f525b1810eff1585e4e0f81897c5f6fe1de6646febd3c97fb9a79e5f7ccdc85fc9dee39064fd9edb719
6
+ metadata.gz: 8baadc0f4cf8e047a3de48c943554dead32df7cf866dc52814bb38fb0ec88a07513557b1ed19e577d71bc950de01b3a653fd9a190bc034ca6b5367d29c87807b
7
+ data.tar.gz: 18e83005a3aa7ae75dbf630331edfae281ac0cd6d187b890922e30fb9fb276cefbce926caee9e3833ac54a41f219d6decf5643f6a79be9cf2cff8b70fcc1f9b5
data/Gemfile.lock CHANGED
@@ -1,16 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mos6510 (0.1.2)
5
- mini_racer (~> 0.6.2)
4
+ mos6510 (0.1.3)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
9
+ coderay (1.1.3)
10
10
  diff-lcs (1.5.0)
11
- libv8-node (16.10.0.0-x86_64-darwin)
12
- mini_racer (0.6.2)
13
- libv8-node (~> 16.10.0.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
16
  rspec (3.11.0)
16
17
  rspec-core (~> 3.11.0)
@@ -32,6 +33,7 @@ PLATFORMS
32
33
  DEPENDENCIES
33
34
  bundler (~> 2.0)
34
35
  mos6510!
36
+ pry (~> 0.14)
35
37
  rake (~> 10.0)
36
38
  rspec (~> 3.11)
37
39
 
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