gruesome 0.0.3 → 0.0.4
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.
- data/README.md +1 -2
- data/lib/gruesome/cli.rb +62 -62
- data/lib/gruesome/logo.rb +8 -8
- data/lib/gruesome/machine.rb +11 -11
- data/lib/gruesome/version.rb +1 -1
- data/lib/gruesome/z/abbreviation_table.rb +17 -17
- data/lib/gruesome/z/decoder.rb +273 -273
- data/lib/gruesome/z/dictionary.rb +144 -144
- data/lib/gruesome/z/header.rb +40 -40
- data/lib/gruesome/z/instruction.rb +42 -42
- data/lib/gruesome/z/machine.rb +51 -50
- data/lib/gruesome/z/memory.rb +301 -232
- data/lib/gruesome/z/object_table.rb +424 -424
- data/lib/gruesome/z/opcode.rb +489 -491
- data/lib/gruesome/z/opcode_class.rb +9 -9
- data/lib/gruesome/z/operand_type.rb +10 -10
- data/lib/gruesome/z/processor.rb +378 -361
- data/lib/gruesome/z/zscii.rb +307 -307
- data/lib/gruesome.rb +3 -3
- data/spec/z/memory_spec.rb +72 -72
- data/spec/z/processor_spec.rb +1883 -1883
- metadata +3 -3
data/spec/z/memory_spec.rb
CHANGED
@@ -1,90 +1,90 @@
|
|
1
1
|
require_relative '../../lib/gruesome/z/memory'
|
2
2
|
|
3
3
|
describe Gruesome::Z::Memory do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
before(:each) do
|
5
|
+
zork = File.open('test/zork1.z3', 'r')
|
6
|
+
@zork_memory = Gruesome::Z::Memory.new(zork.read(zork.size))
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
describe "#readb" do
|
10
|
+
it "should read a byte in header" do
|
11
|
+
@zork_memory.readb(0x0).should eql(3)
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
it "should read a byte in dynamic memory" do
|
15
|
+
@zork_memory.readb(0x100).should eql(32)
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
it "should read a byte in static memory" do
|
19
|
+
@zork_memory.readb(0x2E53).should eql(47)
|
20
|
+
@zork_memory.readb(0x4E36).should eql(0)
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
it "should not read a byte in high memory" do
|
24
|
+
lambda {@zork_memory.readb(0x4E37)}.should raise_error(RuntimeError)
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
describe "#readw" do
|
29
|
+
it "should read a word in header" do
|
30
|
+
@zork_memory.readw(0x0).should eql(768)
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
it "should read a word in dynamic memory" do
|
34
|
+
@zork_memory.readw(0x100).should eql(8403)
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
it "should read a word in static memory" do
|
38
|
+
@zork_memory.readw(0x2E53).should eql(12127)
|
39
|
+
@zork_memory.readw(0x4E35).should eql(256)
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
it "should not read a word in high memory" do
|
43
|
+
lambda{@zork_memory.readw(0x4E36)}.should raise_error(RuntimeError)
|
44
|
+
end
|
45
|
+
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
describe "#writeb" do
|
48
|
+
it "should write a byte in dynamic memory" do
|
49
|
+
@zork_memory.writeb(0x100, 128)
|
50
|
+
@zork_memory.readb(0x100).should eql(128)
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
it "should not write a byte in static memory" do
|
54
|
+
@zork_memory.force_writeb(0x2E53, 123)
|
55
|
+
lambda{@zork_memory.writeb(0x2E53, 128)}.should raise_error(RuntimeError)
|
56
|
+
@zork_memory.readb(0x2E53).should eql(123)
|
57
|
+
@zork_memory.force_writeb(0x4E36, 123)
|
58
|
+
lambda{@zork_memory.writeb(0x4E36, 128)}.should raise_error(RuntimeError)
|
59
|
+
@zork_memory.readb(0x4E36).should eql(123)
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
it "should not write a byte in high memory" do
|
63
|
+
@zork_memory.force_writeb(0x4E37, 123)
|
64
|
+
lambda{@zork_memory.writeb(0x4E37, 128)}.should raise_error(RuntimeError)
|
65
|
+
@zork_memory.force_readb(0x4E37).should eql(123)
|
66
|
+
end
|
67
|
+
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
describe "#writew" do
|
70
|
+
it "should write a word in dynamic memory" do
|
71
|
+
@zork_memory.writew(0x100, 12345)
|
72
|
+
@zork_memory.readw(0x100).should eql(12345)
|
73
|
+
end
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
75
|
+
it "should not write a word in static memory" do
|
76
|
+
@zork_memory.force_writew(0x2E53, 23456)
|
77
|
+
lambda{@zork_memory.writew(0x2E53, 12345)}.should raise_error(RuntimeError)
|
78
|
+
@zork_memory.readw(0x2E53).should eql(23456)
|
79
|
+
@zork_memory.force_writew(0x4E35, 23456)
|
80
|
+
lambda{@zork_memory.writew(0x4E35, 12345)}.should raise_error(RuntimeError)
|
81
|
+
@zork_memory.readw(0x4E35).should eql(23456)
|
82
|
+
end
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
it "should not write a word in high memory" do
|
85
|
+
@zork_memory.force_writew(0x4E36, 23456)
|
86
|
+
lambda{@zork_memory.writew(0x4E36, 12345)}.should raise_error(RuntimeError)
|
87
|
+
@zork_memory.force_readw(0x4E36).should eql(23456)
|
88
|
+
end
|
89
|
+
end
|
90
90
|
end
|