/*************************************************************************** * Copyright (C) 2006 Nicolas Hadacek * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "mem24_memory.h" #include #include "common/global/global.h" #include "common/common/misc.h" Mem24::Memory::Memory(const Data &data) : Device::Memory(data) { fill(BitValue()); } void Mem24::Memory::fill(BitValue value) { _data = Device::Array(device().nbBytes()); for (uint i=0; i<_data.count(); i++) _data[i] = value; } void Mem24::Memory::copyFrom(const Device::Memory &memory) { Q_ASSERT( device().name()==memory.device().name() ); _data = static_cast(memory)._data; } Device::Array Mem24::Memory::arrayForWriting() const { Device::Array data(_data.count()); for (uint i=0; ioffset ); return _data[offset]; } void Mem24::Memory::setByte(uint offset, BitValue value) { Q_ASSERT( _data.size()>offset ); Q_ASSERT( value<=0xFF ); _data[offset] = value; } BitValue Mem24::Memory::checksum() const { BitValue cs = 0x0000; for (uint i=0; i<_data.count(); i++) cs += _data[i]; return cs.maskWith(0xFFFF); } //----------------------------------------------------------------------------- void Mem24::Memory::savePartial(TQTextStream &stream, HexBuffer::Format format) const { HexBuffer hb = toHexBuffer(); hb.savePartial(stream, format); } //----------------------------------------------------------------------------- HexBuffer Mem24::Memory::toHexBuffer() const { HexBuffer hb; for (uint k=0; k &inRange) { BitValue mask = 0xFF; for (uint k=0; k