zemu 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/lib/zemu/config.rb +21 -18
- data/lib/zemu/instance.rb +25 -0
- data/lib/zemu/interactive.rb +9 -3
- data/lib/zemu.rb +2 -2
- data/src/debug.c +5 -0
- data/src/memory.c.erb +22 -6
- data/src/memory.h.erb +2 -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: 99d9e825251363ade2a565f28d7545f81b3dc93221951980a12bed3d3b8ab82c
|
4
|
+
data.tar.gz: c93e03bccdf934341909811d4a2d07fb58d31121cd25983b0659495a2d9b176c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c4024d10bfd6521b25f98f8172e40163cd635d354961554406532c48f58b2063a3ac945a0378907c472db3287dff3f8643f7bfbbf256684b81a9511a15dd3e1
|
7
|
+
data.tar.gz: c826fa009c55c9890faa7d9ef5f172c3ec123a1912e55ff75dca57c51e377cac7014b9d07f8ea9ab682e9ae1ea718c0fae70fda42b0eb0a471fe24c2f494ef96
|
data/lib/zemu/config.rb
CHANGED
@@ -466,18 +466,9 @@ module Zemu
|
|
466
466
|
#
|
467
467
|
#
|
468
468
|
def initialize
|
469
|
-
@blocks = []
|
470
469
|
@initialize_from = nil
|
471
470
|
|
472
471
|
super
|
473
|
-
|
474
|
-
num_sectors.times do
|
475
|
-
sector = []
|
476
|
-
sector_size.times do
|
477
|
-
sector << 0
|
478
|
-
end
|
479
|
-
@blocks << sector
|
480
|
-
end
|
481
472
|
|
482
473
|
# Initialize from provided file if applicable.
|
483
474
|
unless @initialize_from.nil?
|
@@ -486,14 +477,6 @@ module Zemu
|
|
486
477
|
if (file_size != num_sectors * sector_size)
|
487
478
|
raise RangeError, "Initialization file for Zemu::Config::BlockDrive '#{name}' is of wrong size."
|
488
479
|
end
|
489
|
-
|
490
|
-
File.open(@initialize_from, "rb") do |f|
|
491
|
-
num_sectors.times do |s|
|
492
|
-
sector_size.times do |b|
|
493
|
-
@blocks[s][b] = f.getbyte()
|
494
|
-
end
|
495
|
-
end
|
496
|
-
end
|
497
480
|
end
|
498
481
|
|
499
482
|
when_setup do
|
@@ -626,7 +609,27 @@ eos
|
|
626
609
|
|
627
610
|
# Array of sectors of this drive.
|
628
611
|
def blocks
|
629
|
-
|
612
|
+
b = []
|
613
|
+
|
614
|
+
if @initialize_from.nil?
|
615
|
+
num_sectors.times do
|
616
|
+
this_block = []
|
617
|
+
sector_size.times do
|
618
|
+
this_block << 0
|
619
|
+
end
|
620
|
+
b << this_block
|
621
|
+
end
|
622
|
+
return b
|
623
|
+
end
|
624
|
+
|
625
|
+
File.open(@initialize_from, "rb") do |f|
|
626
|
+
num_sectors.times do
|
627
|
+
this_block = f.read(sector_size)
|
628
|
+
b << this_block.unpack("C" * sector_size)
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
b
|
630
633
|
end
|
631
634
|
|
632
635
|
# Set file to initialize from.
|
data/lib/zemu/instance.rb
CHANGED
@@ -37,6 +37,14 @@ module Zemu
|
|
37
37
|
"L'" => 19
|
38
38
|
}
|
39
39
|
|
40
|
+
# Mapping of extended registers
|
41
|
+
# to the registers that comprise them.
|
42
|
+
REGISTERS_EXTENDED = {
|
43
|
+
"HL" => ["H", "L"],
|
44
|
+
"BC" => ["B", "C"],
|
45
|
+
"DE" => ["D", "E"]
|
46
|
+
}
|
47
|
+
|
40
48
|
# States that the emulated machine can be in.
|
41
49
|
class RunState
|
42
50
|
# Currently executing an instruction.
|
@@ -91,6 +99,12 @@ module Zemu
|
|
91
99
|
REGISTERS.each do |reg, num|
|
92
100
|
r[reg] = @wrapper.zemu_debug_register(@instance, num)
|
93
101
|
end
|
102
|
+
|
103
|
+
REGISTERS_EXTENDED.each do |reg, components|
|
104
|
+
hi = components[0]
|
105
|
+
lo = components[1]
|
106
|
+
r[reg] = (r[hi] << 8) | r[lo]
|
107
|
+
end
|
94
108
|
|
95
109
|
return r
|
96
110
|
end
|
@@ -105,6 +119,16 @@ module Zemu
|
|
105
119
|
return @wrapper.zemu_debug_get_memory(address)
|
106
120
|
end
|
107
121
|
|
122
|
+
# Set the value in memory at a given address.
|
123
|
+
#
|
124
|
+
# @param address The address in memory to be set.
|
125
|
+
# @param value The value to set to.
|
126
|
+
#
|
127
|
+
# Returns nothing.
|
128
|
+
def set_memory(address, value)
|
129
|
+
@wrapper.zemu_debug_set_memory(address, value)
|
130
|
+
end
|
131
|
+
|
108
132
|
# Write a string to the serial line of the emulated CPU.
|
109
133
|
#
|
110
134
|
# @param string The string to be sent.
|
@@ -245,6 +269,7 @@ module Zemu
|
|
245
269
|
wrapper.attach_function :zemu_debug_pc, [:pointer], :uint16
|
246
270
|
|
247
271
|
wrapper.attach_function :zemu_debug_get_memory, [:uint16], :uint8
|
272
|
+
wrapper.attach_function :zemu_debug_set_memory, [:uint16, :uint8], :void
|
248
273
|
|
249
274
|
configuration.io.each do |device|
|
250
275
|
device.functions.each do |f|
|
data/lib/zemu/interactive.rb
CHANGED
@@ -5,7 +5,13 @@ module Zemu
|
|
5
5
|
# Constructor.
|
6
6
|
#
|
7
7
|
# Create a new interactive wrapper for the given instance.
|
8
|
-
|
8
|
+
# The options hash allows the user to configure the behaviour
|
9
|
+
# of the interactive instance:
|
10
|
+
# :print_serial => true if serial input/output should be logged
|
11
|
+
# to the emulator window.
|
12
|
+
def initialize(instance, options = {})
|
13
|
+
@print_serial = options[:print_serial]
|
14
|
+
|
9
15
|
@instance = instance
|
10
16
|
|
11
17
|
@symbol_table = {}
|
@@ -275,12 +281,12 @@ module Zemu
|
|
275
281
|
|
276
282
|
unless input.empty?
|
277
283
|
@instance.serial_puts input
|
278
|
-
log "Serial in: #{input}"
|
284
|
+
log "Serial in: #{input} ($#{input.ord.to_s(16)})" if @print_serial
|
279
285
|
end
|
280
286
|
|
281
287
|
unless output.empty?
|
282
288
|
@master.write output
|
283
|
-
log "Serial out: #{output}"
|
289
|
+
log "Serial out: #{output} ($#{output.ord.to_s(16)})" if @print_serial
|
284
290
|
end
|
285
291
|
end
|
286
292
|
end
|
data/lib/zemu.rb
CHANGED
@@ -73,10 +73,10 @@ module Zemu
|
|
73
73
|
# Starts an interactive instance of an emulator, according to the given configuration.
|
74
74
|
#
|
75
75
|
# @param [Zemu::Config] configuration The configuration for which an emulator will be generated.
|
76
|
-
def Zemu::start_interactive(configuration)
|
76
|
+
def Zemu::start_interactive(configuration, options = {})
|
77
77
|
instance = start(configuration)
|
78
78
|
|
79
|
-
interactive = InteractiveInstance.new(instance)
|
79
|
+
interactive = InteractiveInstance.new(instance, options)
|
80
80
|
interactive.run
|
81
81
|
end
|
82
82
|
|
data/src/debug.c
CHANGED
data/src/memory.c.erb
CHANGED
@@ -9,10 +9,11 @@
|
|
9
9
|
|
10
10
|
zuint8 zemu_memory_read(void * context, zuint16 address)
|
11
11
|
{
|
12
|
+
zuint32 address_32 = address;
|
12
13
|
<% memory.each do |mem| %>
|
13
|
-
if (
|
14
|
+
if (address_32 >= 0x<%= mem.address.to_s(16) %> && address_32 < 0x<%= (mem.address + mem.size).to_s(16) %>)
|
14
15
|
{
|
15
|
-
return zemu_memory_block_<%= mem.name %>[
|
16
|
+
return zemu_memory_block_<%= mem.name %>[address_32 - 0x<%= mem.address.to_s(16) %>];
|
16
17
|
}
|
17
18
|
<% end %>
|
18
19
|
/* Unmapped memory has a value of 0. */
|
@@ -21,23 +22,38 @@ zuint8 zemu_memory_read(void * context, zuint16 address)
|
|
21
22
|
|
22
23
|
void zemu_memory_write(void * context, zuint16 address, zuint8 value)
|
23
24
|
{
|
25
|
+
zuint32 address_32 = address;
|
24
26
|
<% memory.each do |mem| %>
|
25
27
|
<% next if mem.readonly? %>
|
26
|
-
if (
|
28
|
+
if (address_32 >= 0x<%= mem.address.to_s(16) %> && address_32 < 0x<%= (mem.address + mem.size).to_s(16) %>)
|
27
29
|
{
|
28
|
-
zemu_memory_block_<%= mem.name %>[
|
30
|
+
zemu_memory_block_<%= mem.name %>[address_32 - 0x<%= mem.address.to_s(16) %>] = value;
|
29
31
|
}
|
30
32
|
<% end %>
|
31
33
|
}
|
32
34
|
|
33
35
|
zuint8 zemu_memory_peek(zuint16 address)
|
34
36
|
{
|
37
|
+
zuint32 address_32 = address;
|
35
38
|
<% memory.each do |mem| %>
|
36
|
-
if (
|
39
|
+
if (address_32 >= 0x<%= mem.address.to_s(16) %> && address_32 < 0x<%= (mem.address + mem.size).to_s(16) %>)
|
37
40
|
{
|
38
|
-
return zemu_memory_block_<%= mem.name %>[
|
41
|
+
return zemu_memory_block_<%= mem.name %>[address_32 - 0x<%= mem.address.to_s(16) %>];
|
39
42
|
}
|
40
43
|
<% end %>
|
41
44
|
/* Unmapped memory has a value of 0. */
|
42
45
|
return 0;
|
43
46
|
}
|
47
|
+
|
48
|
+
void zemu_memory_poke(zuint16 address, zuint8 value)
|
49
|
+
{
|
50
|
+
zuint32 address_32 = address;
|
51
|
+
<% memory.each do |mem| %>
|
52
|
+
<% next if mem.readonly? %>
|
53
|
+
if (address_32 >= 0x<%= mem.address.to_s(16) %> && address_32 < 0x<%= (mem.address + mem.size).to_s(16) %>)
|
54
|
+
{
|
55
|
+
zemu_memory_block_<%= mem.name %>[address_32 - 0x<%= mem.address.to_s(16) %>] = value;
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
<% end %>
|
59
|
+
}
|
data/src/memory.h.erb
CHANGED
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.4.
|
4
|
+
version: 0.4.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: 2021-
|
11
|
+
date: 2021-11-18 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
|