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/README.md
CHANGED
@@ -15,13 +15,12 @@
|
|
15
15
|
|
16
16
|
# Gruesome
|
17
17
|
|
18
|
-
The Ruby Z-Code Emulator and IF Manager (Currently in progress). It
|
18
|
+
The Ruby Z-Code Emulator and IF Manager (Currently in progress). It currently can
|
19
19
|
play version 3 games such as the ZORK trilogy.
|
20
20
|
|
21
21
|
## Currently implemented
|
22
22
|
|
23
23
|
* Majority of version 3 Z-Machine (Enough to play most games)
|
24
|
-
* WARNING: Save and Restore are not implemented!!!!! Don't get eaten by a grue!
|
25
24
|
|
26
25
|
## To play
|
27
26
|
|
data/lib/gruesome/cli.rb
CHANGED
@@ -5,66 +5,66 @@ require_relative 'machine'
|
|
5
5
|
require_relative 'logo'
|
6
6
|
|
7
7
|
module Gruesome
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
8
|
+
class CLI
|
9
|
+
BANNER = <<-USAGE
|
10
|
+
Usage:
|
11
|
+
gruesome play STORY_FILE
|
12
|
+
|
13
|
+
Description:
|
14
|
+
The 'play' command will start a session of the story given as STORY_FILE
|
15
|
+
|
16
|
+
Example:
|
17
|
+
gruesome play zork1.z3
|
18
|
+
|
19
|
+
USAGE
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def parse_options
|
23
|
+
@opts = OptionParser.new do |opts|
|
24
|
+
opts.banner = BANNER.gsub(/^ /, '')
|
25
|
+
|
26
|
+
opts.separator ''
|
27
|
+
opts.separator 'Options:'
|
28
|
+
|
29
|
+
opts.on('-h', '--help', 'Display this help') do
|
30
|
+
puts opts
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
@opts.parse!
|
36
|
+
end
|
37
|
+
|
38
|
+
def CLI.run
|
39
|
+
begin
|
40
|
+
parse_options
|
41
|
+
rescue OptionParser::InvalidOption => e
|
42
|
+
warn e
|
43
|
+
exit -1
|
44
|
+
end
|
45
|
+
|
46
|
+
def fail
|
47
|
+
puts @opts
|
48
|
+
exit -1
|
49
|
+
end
|
50
|
+
|
51
|
+
if ARGV.empty?
|
52
|
+
fail
|
53
|
+
end
|
54
|
+
|
55
|
+
case ARGV.first
|
56
|
+
when 'play'
|
57
|
+
fail unless ARGV[1]
|
58
|
+
|
59
|
+
Gruesome::Logo.print
|
60
|
+
|
61
|
+
puts
|
62
|
+
puts "--------------------------------------------------------------------------------"
|
63
|
+
puts
|
64
|
+
|
65
|
+
Gruesome::Machine.new(ARGV[1]).execute
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
70
|
end
|
data/lib/gruesome/logo.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
# DO NOT REMOVE ABOVE COMMENT! IT IS MAGIC!
|
4
4
|
|
5
5
|
module Gruesome
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
module Logo
|
7
|
+
# I'm just making sure this works regardless of the unicode format this
|
8
|
+
# source file is saved as...
|
9
|
+
LOGO = <<ENDLOGO
|
10
10
|
▄▄▄▄▄ ▄▄▄▄▄
|
11
11
|
▀████▄ ▄████▀
|
12
12
|
▀████▄ ▄████▀
|
@@ -21,8 +21,8 @@ module Gruesome
|
|
21
21
|
▀▀▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀▀ ▀▀▀▀▀▀ ▀▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀▀▀▀
|
22
22
|
ENDLOGO
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def Logo.print
|
25
|
+
puts LOGO
|
26
|
+
end
|
27
|
+
end
|
28
28
|
end
|
data/lib/gruesome/machine.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require_relative 'z/machine'
|
2
2
|
|
3
3
|
module Gruesome
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Machine
|
5
|
+
def initialize(story_file)
|
6
|
+
# Later, detect the type
|
7
|
+
#
|
8
|
+
# For now, assume Z-Machine
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
@machine = Z::Machine.new(story_file)
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def execute
|
14
|
+
@machine.execute
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
data/lib/gruesome/version.rb
CHANGED
@@ -7,24 +7,24 @@ require_relative 'header'
|
|
7
7
|
require_relative 'zscii'
|
8
8
|
|
9
9
|
module Gruesome
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
module Z
|
11
|
+
class AbbreviationTable
|
12
|
+
def initialize(memory)
|
13
|
+
@memory = memory
|
14
|
+
@header = Header.new(@memory.contents)
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def lookup(alphabet, index, translation_alphabet)
|
18
|
+
abbrev_index = (32 * (alphabet)) + index
|
19
|
+
addr = @header.abbrev_tbl_addr + abbrev_index*2
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
# this will yield a word address, which we multiply by 2
|
22
|
+
# to get into a byte address
|
23
|
+
str_addr = @memory.force_readw(addr)
|
24
|
+
str_addr *= 2
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
ZSCII.translate(translation_alphabet, @header.version, @memory.force_readzstr(str_addr)[1], nil)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
30
|
end
|