zemu 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zemu/config.rb +3 -2
- data/lib/zemu/instance.rb +7 -0
- data/lib/zemu/interactive.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2155a9588f54ef36a46f88d07f6ef7a1cb01a27ef8f8b104a2e1118cddbbdfb6
|
4
|
+
data.tar.gz: fd698260726fc03616d6f42c72039e9a04e4a34f77f04e2d3832a604e7c1ec64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da88a0cc1dbbd30c9849b400c2fbfea989ff81f500fb51dd0c2fffd8af81a65fca231ddb1937e51205a4b9a7ac0a72ffa435ad0aa8941d9350b4edd42aca9027
|
7
|
+
data.tar.gz: 4a430f4fa54f8514d4c41a561e0ca92957d361025ce69ffb77a797a2d12b858b2462543ad5cc0eb8b87cd6d1688fa2c826179bd0255085f9d328de8e8629ab0d
|
data/lib/zemu/config.rb
CHANGED
@@ -241,14 +241,15 @@ module Zemu
|
|
241
241
|
|
242
242
|
# Parameters accessible by this configuration object.
|
243
243
|
def params
|
244
|
-
return %w(name compiler output_directory)
|
244
|
+
return %w(name compiler output_directory clock_speed)
|
245
245
|
end
|
246
246
|
|
247
247
|
# Initial value for parameters of this configuration object.
|
248
248
|
def params_init
|
249
249
|
return {
|
250
250
|
"compiler" => "clang",
|
251
|
-
"output_directory" => "bin"
|
251
|
+
"output_directory" => "bin",
|
252
|
+
"clock_speed" => 0
|
252
253
|
}
|
253
254
|
end
|
254
255
|
|
data/lib/zemu/instance.rb
CHANGED
@@ -38,6 +38,8 @@ module Zemu
|
|
38
38
|
}
|
39
39
|
|
40
40
|
def initialize(configuration)
|
41
|
+
@clock = configuration.clock_speed
|
42
|
+
|
41
43
|
@wrapper = make_wrapper(configuration)
|
42
44
|
|
43
45
|
@serial = []
|
@@ -47,6 +49,11 @@ module Zemu
|
|
47
49
|
@wrapper.zemu_reset(@instance)
|
48
50
|
end
|
49
51
|
|
52
|
+
# Returns the clock speed of this instance in Hz.
|
53
|
+
def clock_speed
|
54
|
+
return @clock
|
55
|
+
end
|
56
|
+
|
50
57
|
# Returns a hash containing current values of the emulated
|
51
58
|
# machine's registers. All names are as those given in the Z80
|
52
59
|
# reference manual.
|
data/lib/zemu/interactive.rb
CHANGED
@@ -115,6 +115,9 @@ module Zemu
|
|
115
115
|
actual_cycles = 0
|
116
116
|
|
117
117
|
while ((cycles == -1) || (cycles_left > 0))
|
118
|
+
# Get time before execution.
|
119
|
+
start = Time.now
|
120
|
+
|
118
121
|
old_pc = r16("PC")
|
119
122
|
|
120
123
|
process_serial
|
@@ -122,6 +125,18 @@ module Zemu
|
|
122
125
|
cycles_left -= cycles_done
|
123
126
|
actual_cycles += cycles_done
|
124
127
|
|
128
|
+
# Get time after execution.
|
129
|
+
ending = Time.now
|
130
|
+
|
131
|
+
# Get elapsed time and calculate padding time to match clock speed.
|
132
|
+
if @instance.clock_speed > 0
|
133
|
+
elapsed = ending - start
|
134
|
+
|
135
|
+
execution_time = actual_cycles * (1/@instance.clock_speed)
|
136
|
+
padding = execution_time - elapsed
|
137
|
+
sleep(padding) unless padding < 0
|
138
|
+
end
|
139
|
+
|
125
140
|
# Have we hit a breakpoint or HALT instruction?
|
126
141
|
if @instance.break?
|
127
142
|
log "Hit breakpoint at #{r16("PC")}."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zemu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Valentine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Zemu is a gem which allows the user to configure a Z80-based system
|