class ZX7

ZX7 decoding routines.

in ZX7::Macros

Example:

require 'z80'
require 'zxutils/zx7'

class Program
  include Z80

  macro_import  ZX7

                ld  hl, source
                ld  de, destination
                call decompress
                # ...
   dzx7_standard :decompress
   # or
   decompress   dzx7_standard
end
Get compressor from

World Of Spectrum: ZX7

Constants

COMMAND

Public Class Methods

compress(data) click to toggle source

ZX7.compress(data) -> data (zx7 compressed)

# File lib/zxutils/zx7.rb, line 37
def self.compress(data)
    begin
        file = Tempfile.new 'zx7-pack-', encoding: 'ascii-8bit', binmode: true
        file.write data
        file.close
        unless COMMAND && File.executable?(ZX7::COMMAND)
            raise "Download: http://www.worldofspectrum.org/pub/sinclair/games-extras/ZX7_(WindowsExecutable).zip and unpack zx7.exe to any directory on a PATH."
        end
        system ZX7::COMMAND, file.path
        IO.read(file.path + '.zx7', mode: 'rb')
    ensure
        File.unlink(file.path + '.zx7') rescue false
        file.unlink
    end
end