Class: Gruesome::Z::AbbreviationTable
- Inherits:
-
Object
- Object
- Gruesome::Z::AbbreviationTable
- Defined in:
- lib/gruesome/z/abbreviation_table.rb
Instance Method Summary collapse
-
#initialize(memory) ⇒ AbbreviationTable
constructor
A new instance of AbbreviationTable.
- #lookup(alphabet, index, translation_alphabet) ⇒ Object
Constructor Details
#initialize(memory) ⇒ AbbreviationTable
Returns a new instance of AbbreviationTable.
12 13 14 15 |
# File 'lib/gruesome/z/abbreviation_table.rb', line 12 def initialize(memory) @memory = memory @header = Header.new(@memory.contents) end |
Instance Method Details
#lookup(alphabet, index, translation_alphabet) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gruesome/z/abbreviation_table.rb', line 17 def lookup(alphabet, index, translation_alphabet) abbrev_index = (32 * (alphabet)) + index addr = @header.abbrev_tbl_addr + abbrev_index*2 # this will yield a word address, which we multiply by 2 # to get into a byte address str_addr = @memory.force_readw(addr) str_addr *= 2 ZSCII.translate(translation_alphabet, @header.version, @memory.force_readzstr(str_addr)[1], nil) end |