|
|
@ -34,8 +34,8 @@ module DFHack
|
|
|
|
def float
|
|
|
|
def float
|
|
|
|
Float.new
|
|
|
|
Float.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def bit(shift)
|
|
|
|
def bit(shift, enum=nil)
|
|
|
|
BitField.new(shift, 1)
|
|
|
|
BitField.new(shift, 1, enum)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def bits(shift, len, enum=nil)
|
|
|
|
def bits(shift, len, enum=nil)
|
|
|
|
BitField.new(shift, len, enum)
|
|
|
|
BitField.new(shift, len, enum)
|
|
|
@ -147,7 +147,7 @@ module DFHack
|
|
|
|
out << '>'
|
|
|
|
out << '>'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def inspect_field(n, o, s)
|
|
|
|
def inspect_field(n, o, s)
|
|
|
|
if s.kind_of?(BitField) and s._len == 1
|
|
|
|
if s.kind_of?(BitField) and s._len == 1 and not s._enum
|
|
|
|
send(n) ? n.to_s : ''
|
|
|
|
send(n) ? n.to_s : ''
|
|
|
|
elsif s.kind_of?(Pointer)
|
|
|
|
elsif s.kind_of?(Pointer)
|
|
|
|
"#{n}=#{s._at(@_memaddr+o).inspect}"
|
|
|
|
"#{n}=#{s._at(@_memaddr+o).inspect}"
|
|
|
@ -242,7 +242,7 @@ module DFHack
|
|
|
|
|
|
|
|
|
|
|
|
def _get
|
|
|
|
def _get
|
|
|
|
v = DFHack.memory_read_int32(@_memaddr) >> @_shift
|
|
|
|
v = DFHack.memory_read_int32(@_memaddr) >> @_shift
|
|
|
|
if @_len == 1
|
|
|
|
if @_len == 1 and not @_enum
|
|
|
|
((v & 1) == 0) ? false : true
|
|
|
|
((v & 1) == 0) ? false : true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
v &= _mask
|
|
|
|
v &= _mask
|
|
|
@ -252,7 +252,7 @@ module DFHack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def _set(v)
|
|
|
|
def _set(v)
|
|
|
|
if @_len == 1
|
|
|
|
if @_len == 1 and (not @_enum or v == false or v == true)
|
|
|
|
# allow 'bit = 0'
|
|
|
|
# allow 'bit = 0'
|
|
|
|
v = (v && v != 0 ? 1 : 0)
|
|
|
|
v = (v && v != 0 ? 1 : 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|