Class: AxePackedAppleDosPic

Inherits:
AppleDosPic show all
Defined in:
lib/native_file_types/apple2/PackedHiResPicFormats.rb

Overview

picture packed with “The Axe Packer”

Instance Attribute Summary

Attributes inherited from NativeFileType

#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data

Instance Method Summary collapse

Methods inherited from AppleDosPic

file_system_file_types, #header_length, load_address

Methods inherited from AppleHiResPic

buffer_to_picture, file_system_file_types, matching_score, #picture_format, #picture_height, #picture_width, scanline_offsets, #to_picture

Methods inherited from NativeFileType

#<=>, #==, all_native_file_types, best_fit, code_for_tests, compatability_score, #data_without_header, file_type_matches?, #full_filename, #header_length, #initialize, is_valid_file_if, #load_address, load_address, matching_score, native_file_types_possible_on_file_system, non_matching_score, #to_hex_dump, #to_info_dump, #type_description

Methods included from SubclassTracking

extended

Constructor Details

This class inherits a constructor from NativeFileType

Instance Method Details

#unpacked_picture_bytesObject



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
# File 'lib/native_file_types/apple2/PackedHiResPicFormats.rb', line 12

def unpacked_picture_bytes
  
#    puts @@scanline_offsets.length
  packed_buffer=data_without_header
  unpacked_buffer="\000"*8192
  p=0
  parity=1
  row=1
  column=0
  done=false
  while !done do
    b=packed_buffer[p]
    if b==0 then          
      run_length=packed_buffer[p+1]
      colour=packed_buffer[p+2]
      p+=2
    else
      run_length=1
      colour=b
    end
    run_length.times do |i|
      destination_offset=@@scanline_offsets[row]+column
      unpacked_buffer[destination_offset]=colour
      row+=2
      if row>=192 then
        row=parity
        column+=1
        if column>=40 then
          if parity==0 then
            done=true
          else
            row=0
            column=0
            parity=0
          end
        end
      end
    end
    p+=1
    done=true if p==packed_buffer.length
  end
  
  unpacked_buffer
end